Example #1
0
/**
 * User can get information about other users if they are active, retricted or suspended
 *
 * Suspended is needed to be coherent with the GUI where the suspended users are displayed
 * like active users to people (otherwise it breaks Mylyn on trackers due to workflow manager)
 *
 * @param string $identifier
 * @param PFUser $user
 * @param PFUser $current_user
 * @return array
 */
function user_to_soap($identifier, PFUser $user = null, PFUser $current_user)
{
    if ($user !== null && ($user->isActive() || $user->isRestricted() || $user->isSuspended())) {
        if ($current_user->canSee($user)) {
            return array('identifier' => $identifier, 'username' => $user->getUserName(), 'id' => $user->getId(), 'real_name' => $user->getRealName(), 'email' => $user->getEmail(), 'ldap_id' => $user->getLdapId());
        }
    }
}
Example #2
0
 /**
  * Update db entry of 'user' table with values in object
  * @param PFUser $user
  */
 public function updateDb(PFUser $user)
 {
     if (!$user->isAnonymous()) {
         $old_user = $this->getUserByIdWithoutCache($user->getId());
         $userRow = $user->toRow();
         if ($user->getPassword() != '') {
             $password_handler = PasswordHandlerFactory::getPasswordHandler();
             if (!$password_handler->verifyHashPassword($user->getPassword(), $user->getUserPw()) || $password_handler->isPasswordNeedRehash($user->getUserPw())) {
                 // Update password
                 $userRow['clear_password'] = $user->getPassword();
             }
         }
         if ($user->getLegacyUserPw() !== '' && !ForgeConfig::get('sys_keep_md5_hashed_password')) {
             $userRow['user_pw'] = '';
         }
         $result = $this->getDao()->updateByRow($userRow);
         if ($result) {
             if ($user->isSuspended() || $user->isDeleted()) {
                 $this->getDao()->deleteAllUserSessions($user->getId());
             }
             $this->_getEventManager()->processEvent(Event::USER_MANAGER_UPDATE_DB, array('old_user' => $old_user, 'new_user' => &$user));
         }
         return $result;
     }
     return false;
 }