19 require_once(BASE.
"wcmf/lib/core/class.WCMFException.php");
 
   20 require_once(BASE.
"wcmf/lib/util/class.Message.php");
 
   21 require_once(BASE.
"wcmf/lib/persistence/class.PersistenceFacade.php");
 
   22 require_once(BASE.
"wcmf/lib/util/class.InifileParser.php");
 
   27 define(
"USER_PROPERTY_LOGIN", 
"login");
 
   28 define(
"USER_PROPERTY_NAME", 
"name");
 
   29 define(
"USER_PROPERTY_FIRSTNAME", 
"firstname");
 
   30 define(
"USER_PROPERTY_CONFIG", 
"config");
 
   31 define(
"ROLE_PROPERTY_NAME", 
"name");
 
   64     $this->_initParams = $params;
 
   65     $this->_userRepository = $this->
initialize($this->_initParams);
 
   69     if (($roleConfig = $parser->getSection(
'roleconfig')) !== 
false) {
 
   70       $this->_roleConfig = $roleConfig;
 
   81     return md5($password);
 
   87   function onError($message, $file=
'', $line=
'')
 
  123   function &
createUser($name, $firstname, $login, $password, $passwordRepeated)
 
  125     if ($password != $passwordRepeated) {
 
  131     if ($this->
getUser($login) != null) {
 
  132       $this->
onError(
Message::get(
"The login '%1%' already exists", array($login)), __FILE__, __LINE__);
 
  137     $user = &$this->
createUserImpl($name, $firstname, $login, $password);
 
  140     $this->_userRepository[
'users'][
sizeof($this->_userRepository[
'users'])] = &$user;
 
  151     if (($user = $this->
getUser($login)) == null) {
 
  152       $this->
onError(
Message::get(
"The login '%1%' does not exist", array($login)), __FILE__, __LINE__);
 
  157     for($i=0; $i<
sizeof($this->_userRepository[
'users']); $i++)
 
  159       if ($this->_userRepository[
'users'][$i]->getLogin() == $login) {
 
  160         array_splice($this->_userRepository[
'users'][$i], $i, 1);
 
  174       $this->
onError(
Message::get(
"Unknown user property: '%1%'", array($property)), __FILE__, __LINE__);
 
  180       $this->
onError(
Message::get(
"The login '%1%' already exists", array($value)), __FILE__, __LINE__);
 
  182     if (($user = $this->
getUser($login)) == null) {
 
  183       $this->
onError(
Message::get(
"The login '%1%' does not exist", array($login)), __FILE__, __LINE__);
 
  186     $user = &$this->
getUser($login);
 
  190     if (strlen($validationMsg) > 0) {
 
  191       $this->
onError($validationMsg, __FILE__, __LINE__);
 
  209     if (($user = $this->
getUser($login)) == null) {
 
  210       $this->
onError(
Message::get(
"The login '%1%' does not exist", array($login)), __FILE__, __LINE__);
 
  213     if ($newPassword != $newPasswordRepeated) {
 
  222     $user = &$this->
getUser($login);
 
  223     $user->setPassword($newPassword);
 
  233   function changePassword($login, $oldPassword, $newPassword, $newPasswordRepeated)
 
  235     if (($user = $this->
getUser($login)) == null) {
 
  236       $this->
onError(
Message::get(
"The login '%1%' does not exist", array($login)), __FILE__, __LINE__);
 
  241     if ($user->getPassword() != $oldPassword) {
 
  244     if ($newPassword != $newPasswordRepeated) {
 
  253     $user = &$this->
getUser($login);
 
  254     $user->setPassword($newPassword);
 
  267     if ($this->
getRole($name) != null) {
 
  268       $this->
onError(
Message::get(
"The role '%1%' already exists", array($name)), __FILE__, __LINE__);
 
  273     $this->_userRepository[
'roles'][
sizeof($this->_userRepository[
'roles'])] = &$role;
 
  284     if (($role = $this->
getRole($name)) == null) {
 
  285       $this->
onError(
Message::get(
"The role '%1%' does not exist", array($name)), __FILE__, __LINE__);
 
  290     for($i=0; $i<
sizeof($this->_userRepository[
'roles']); $i++)
 
  292       if ($this->_userRepository[
'roles'][$i]->getName() == $name) {
 
  293         array_splice($this->_userRepository[
'roles'][$i], $i, 1);
 
  307       $this->
onError(
Message::get(
"Unknown role property: '%1%'", array($property)), __FILE__, __LINE__);
 
  313       $this->
onError(
Message::get(
"The role '%1%' already exists", array($value)), __FILE__, __LINE__);
 
  315     if (($role = $this->
getRole($name)) == null) {
 
  316       $this->
onError(
Message::get(
"The role '%1%' does not exist", array($name)), __FILE__, __LINE__);
 
  319     $role = &$this->
getRole($name);
 
  323     if (strlen($validationMsg) > 0) {
 
  324       $this->
onError($validationMsg, __FILE__, __LINE__);
 
  341     if (($role = $this->
getRole($rolename)) == null) {
 
  342       $this->
onError(
Message::get(
"The role '%1%' does not exist", array($rolename)), __FILE__, __LINE__);
 
  344     if (($user = $this->
getUser($login)) == null) {
 
  345       $this->
onError(
Message::get(
"The login '%1%' does not exist", array($login)), __FILE__, __LINE__);
 
  347     if ($user != null && $user->hasRole($rolename)) {
 
  348       $this->
onError(
Message::get(
"The user '%1%' already has the role '%2%'", array($login, $rolename)), __FILE__, __LINE__);
 
  353     if ($this->_roleConfig && isset($this->_roleConfig[$rolename])) {
 
  365     if (($role = $this->
getRole($rolename)) == null) {
 
  366       $this->
onError(
Message::get(
"The role '%1%' does not exist", array($rolename)), __FILE__, __LINE__);
 
  368     if (($user = $this->
getUser($login)) == null) {
 
  369       $this->
onError(
Message::get(
"The login '%1%' does not exist", array($login)), __FILE__, __LINE__);
 
  371     if ($user != null && !$user->hasRole($rolename)) {
 
  372       $this->
onError(
Message::get(
"The user '%1%' does not have the role '%2%'", array($login, $rolename)), __FILE__, __LINE__);
 
  377     if ($this->_roleConfig && isset($this->_roleConfig[$rolename])) {
 
  389     for($i=0; $i<
sizeof($this->_userRepository[
'users']); $i++) {
 
  390       array_push($result, $this->_userRepository[
'users'][$i]->getLogin());
 
  402     for($i=0; $i<
sizeof($this->_userRepository[
'roles']); $i++) {
 
  403       array_push($result, $this->_userRepository[
'roles'][$i]->getName());
 
  414     if (($user = &$this->
getUser($login)) == null) {
 
  415       $this->
onError(
Message::get(
"The login '%1%' does not exist", array($login)), __FILE__, __LINE__);
 
  417     $roles = $user->getRoles();
 
  419     for($i=0; $i<
sizeof($roles); $i++) {
 
  420       array_push($result, $roles[$i]->getName());
 
  431     if (($role = &$this->
getRole($rolename)) == null) {
 
  432       $this->
onError(
Message::get(
"The role '%1%' does not exist", array($rolename)), __FILE__, __LINE__);
 
  435     for($i=0; $i<
sizeof($this->_userRepository[
'users']); $i++)
 
  437       $curUser = &$this->_userRepository[
'users'][$i];
 
  439       if (in_array($rolename, $roles)) {
 
  440         array_push($result, $curUser->getLogin());
 
  453     for($i=0; $i<
sizeof($this->_userRepository[
'users']); $i++)
 
  455       $curUser = &$this->_userRepository[
'users'][$i];
 
  456       if ($curUser->getLogin() == $login) {
 
  470     for($i=0; $i<
sizeof($this->_userRepository[
'roles']); $i++)
 
  472       $curRole = &$this->_userRepository[
'roles'][$i];
 
  473       if ($curRole->getName() == $name) {
 
  490       $principalArray = &$this->_userRepository[
'users'];
 
  493       $principalArray = &$this->_userRepository[
'roles'];
 
  496       $this->
onError(
Message::get(
"Unknown object type: '%1%'", array($oidParts[
'type'])), __FILE__, __LINE__);
 
  498     for($i=0; $i<
sizeof($principalArray); $i++)
 
  500       $curPrincipal = &$principalArray[$i];
 
  501       if ($curPrincipal->getDBID() == $oidParts[
'id'][0]) {
 
  502         $principal = &$curPrincipal;
 
  517     if ($principal != null)
 
  526         $this->
onError(
Message::get(
"Unknown object type: '%1%'", array($oidParts[
'type'])), __FILE__, __LINE__);
 
  530       $this->
onError(
Message::get(
"The principal does not exist: '%1%'", array($oid)), __FILE__, __LINE__);
 
  542     if (($className = $parser->getValue(
'User', 
'implementation')) === 
false) {
 
  543       $this->
onError($parser->getErrorMsg());
 
  556     if (($className = $parser->getValue(
'Role', 
'implementation')) === 
false) {
 
  557       $this->
onError($parser->getErrorMsg());
 
  574     WCMFException::throwEx(
"initialize() must be implemented by derived class: ".get_class($this), __FILE__, __LINE__);
 
  588     WCMFException::throwEx(
"createUserImpl() must be implemented by derived class: ".get_class($this), __FILE__, __LINE__);
 
  599     WCMFException::throwEx(
"removeUserImpl() must be implemented by derived class: ".get_class($this), __FILE__, __LINE__);
 
  610     WCMFException::throwEx(
"setUserPropertyImpl() must be implemented by derived class: ".get_class($this), __FILE__, __LINE__);
 
  621     WCMFException::throwEx(
"createRoleImpl() must be implemented by derived class: ".get_class($this), __FILE__, __LINE__);
 
  632     WCMFException::throwEx(
"removeRoleImpl() must be implemented by derived class: ".get_class($this), __FILE__, __LINE__);
 
  643     WCMFException::throwEx(
"setRolePropertyImpl() must be implemented by derived class: ".get_class($this), __FILE__, __LINE__);
 
  654     WCMFException::throwEx(
"addUserToRoleImpl() must be implemented by derived class: ".get_class($this), __FILE__, __LINE__);
 
  665     WCMFException::throwEx(
"removeUserFromRoleImpl() must be implemented by derived class: ".get_class($this), __FILE__, __LINE__);
 
resetPassword($login, $newPassword, $newPasswordRepeated)
const USER_PROPERTY_LOGIN
get($message, $parameters=null, $domain='', $lang='')
addUserToRoleImpl(&$role, &$user)
changePassword($login, $oldPassword, $newPassword, $newPasswordRepeated)
removeUserFromRoleImpl(&$role, &$user)
onError($message, $file='', $line='')
setRoleProperty($name, $property, $value)
throwEx($message, $file='', $line='')
& createUser($name, $firstname, $login, $password, $passwordRepeated)
setRolePropertyImpl(&$role, $property, $value)
& createUserImpl($name, $firstname, $login, $password)
UserManager is used to edit users and roles. UserManager supports the following operations: ...
decomposeOID($oid, $validate=true)
encryptPassword($password)
setUserProperty($login, $property, $value)
addUserToRole($rolename, $login)
const USER_PROPERTY_FIRSTNAME
listRoleMembers($rolename)
setUserPropertyImpl(&$user, $property, $value)
const USER_PROPERTY_CONFIG
removeUserFromRole($rolename, $login)