19 require_once(BASE.
"wcmf/lib/presentation/class.Controller.php");
20 require_once(BASE.
"wcmf/lib/presentation/class.WCMFInifileParser.php");
21 require_once(BASE.
"wcmf/lib/persistence/class.PersistenceFacade.php");
22 require_once(BASE.
"wcmf/lib/model/class.Node.php");
23 require_once(BASE.
"wcmf/lib/util/class.ObjectFactory.php");
24 require_once(BASE.
"wcmf/lib/presentation/ListboxFunctions.php");
69 if (strlen($request->getContext()) == 0)
71 $request->setContext(
'user');
72 $response->setContext(
'user');
75 parent::initialize($request, $response);
79 $this->_userManager = &$objectFactory->createInstanceFromConfig(
'implementation',
'UserManager');
86 if($this->_request->getAction() ==
'newprincipal')
88 if(strlen($this->_request->getValue(
'newtype')) == 0)
94 if(in_array($this->_request->getAction(), array(
'editprincipal',
'save')))
96 if(strlen($this->_request->getValue(
'oid')) == 0)
102 if($this->_request->getAction() ==
'delprincipal')
104 if(strlen($this->_request->getValue(
'deleteoids')) == 0)
106 $this->
setErrorMsg(
"No 'deleteoids' given in data.");
117 if ($this->_request->getAction() ==
'delprincipal')
131 $this->_userManager->startTransaction();
136 if($this->_request->getAction() ==
'delprincipal')
138 $deleteOIDs = split(
',', $this->_request->getValue(
'deleteoids'));
139 foreach($deleteOIDs as $oid)
141 $this->
beforeDelete($this->_userManager->getPrincipal($oid));
142 $this->_userManager->removePrincipal($oid);
145 $this->_userManager->commitTransaction();
146 $this->_response->setAction(
'overview');
151 if($this->_request->getAction() ==
'newprincipal')
153 $newType = $this->_request->getValue(
'newtype');
154 $newNode =
new Node($newType);
156 if($newType ==
'user')
157 $newPrincipal = &$this->_userManager->createUser(
'',
'', $newNode->getOID(),
'',
'');
159 $newPrincipal = &$this->_userManager->createRole($newNode->getOID());
162 if($newType ==
'user')
163 $this->_userManager->setUserProperty($newNode->getOID(),
USER_PROPERTY_LOGIN,
'user'.$newPrincipal->getDBID());
165 $this->_userManager->setRoleProperty($newNode->getOID(),
ROLE_PROPERTY_NAME,
'role'.$newPrincipal->getDBID());
166 $newPrincipal->save();
171 $this->_request->setAction(
'editprincipal');
172 $this->_request->setValue(
'oid', $newPrincipal->getOID());
176 if (in_array($this->_request->getAction(), array(
'editprincipal',
'save')) || in_array($this->_request->getContext(), array(
'user',
'role')))
179 $principal = &$this->_userManager->getPrincipal($this->_request->getValue(
'oid'));
182 if ($this->_request->getAction() ==
'save')
184 $saveNode = &$this->_request->getValue($this->_request->getValue(
'oid'));
194 $this->_userManager->setUserProperty($principal->getLogin(), $property, $value);
199 if ($this->_request->hasValue(
'changepassword'))
201 $this->_userManager->resetPassword($principal->getLogin(), $this->_request->getValue(
'newpassword1'),
202 $this->_request->getValue(
'newpassword2'));
205 $roles = $this->_userManager->listRoles();
206 $userRoles = $this->_userManager->listUserRoles($principal->getLogin());
207 $principals = $this->_request->getValue(
'principals');
208 foreach($roles as $curRole)
210 if ((is_array($principals) && in_array($curRole, $principals)) && (!is_array($userRoles) || !in_array($curRole, $userRoles)))
211 $this->_userManager->addUserToRole($curRole, $principal->getLogin());
212 if ((!is_array($principals) || !in_array($curRole, $principals)) && (is_array($userRoles) && in_array($curRole, $userRoles)))
213 $this->_userManager->removeUserFromRole($curRole, $principal->getLogin());
224 $this->_userManager->setRoleProperty($principal->getName(), $property, $value);
229 $users = $this->_userManager->listUsers();
230 $roleMembers = $this->_userManager->listRoleMembers($principal->getName());
231 $principals = $this->_request->getValue(
'principals');
232 foreach($users as $curUser)
234 if (in_array($curUser, $principals) && !in_array($curUser, $roleMembers))
235 $this->_userManager->addUserToRole($principal->getName(), $curUser);
236 if (!in_array($curUser, $principals) && in_array($curUser, $roleMembers))
237 $this->_userManager->removeUserFromRole($principal->getName(), $curUser);
240 $this->
afterUpdate($this->_userManager->getPrincipal($this->_request->getValue(
'oid')));
244 $principal = &$this->_userManager->getPrincipal($this->_request->getValue(
'oid'));
247 $principalBaseList = $this->_userManager->listRoles();
248 $principalList = $this->_userManager->listUserRoles($principal->getLogin());
252 $principalBaseList = $this->_userManager->listUsers();
253 $principalList = $this->_userManager->listRoleMembers($principal->getName());
257 $this->_response->setValue(
'oid', $this->_request->getValue(
'oid'));
258 $this->_response->setValue(
'newtype', $this->_request->getValue(
'newtype'));
259 $this->_response->setValue(
'principal', $principal);
260 $this->_response->setValue(
'principalBaseList', join(
"|", $principalBaseList));
261 $this->_response->setValue(
'principalList', join(
",", $principalList));
264 array_push($configFiles,
'');
265 $this->_response->setValue(
'configFiles', join(
"|", $configFiles));
268 $this->_userManager->commitTransaction();
271 $this->_response->setAction(
'ok');
beforeDelete(&$principal)
const USER_PROPERTY_LOGIN
Node is the basic component for building trees (although a Node can have one than more parents)...
initialize(&$request, &$response)
Controller is the base class of all controllers. If a Controller has a view it is expected to reside ...
const USER_PROPERTY_FIRSTNAME
PrincipalController is used to edit users and roles.
const USER_PROPERTY_CONFIG