예제 #1
0
 /**
  * Возвращает код получателя
  */
 public function getUserIdTo()
 {
     foreach ($this->to as $addr) {
         $userId = UserBean::inst()->getUserIdByMail($addr[0]);
         if (is_integer($userId)) {
             return $userId;
             //---
         }
     }
     return null;
 }
예제 #2
0
 public static function validateEmail($mail, $mustPresent = false)
 {
     if (!$mail) {
         return 'required';
     }
     if (ps_strlen($mail) > EMAIL_MAXLEN) {
         return 'maxlength';
     }
     if (!PsCheck::isEmail($mail)) {
         return 'email';
     }
     $hasMail = UserBean::inst()->hasMail($mail);
     if ($hasMail && !$mustPresent || !$hasMail && $mustPresent) {
         return 'remote';
     }
     return false;
 }
예제 #3
0
 /** @return AdminUserBean */
 public static function inst()
 {
     return parent::inst();
 }
예제 #4
0
 /**
  * Загрузка пользователя по email.
  * 
  * @param str $email - электронный адрес пользователя
  * @return PsUser
  */
 public static function instByMail($email)
 {
     $userId = UserBean::inst()->getUserIdByMail($email);
     check_condition(is_inumeric($userId), "Электронный адрес [{$email}] не зарегистрирован");
     return self::inst($userId);
 }
 public function __construct()
 {
     $this->loggedIn = SessionArrayHelper::hasInt(SESSION_USER_PARAM);
     $this->userId = $this->loggedIn ? SessionArrayHelper::getInt(SESSION_USER_PARAM) : null;
     $this->loggedInAsAdmin = $this->loggedIn ? UserBean::inst()->isAdmin($this->userId) : false;
 }
예제 #6
0
파일: AdminBean.php 프로젝트: ilivanoff/www
 public function __construct($parentClass, $userId)
 {
     check_condition($parentClass === 'AdminManager' && ++self::$cnt === 1, 'Trying to create one more instance of ' . __CLASS__);
     check_condition(UserBean::inst()->isAdmin($userId), "User [{$userId}] is not admin");
     $this->adminId = $userId;
 }
예제 #7
0
 /**
  * Получение свойства по его названию.
  * Если данные пользователя не установлены или требуемое свойство не загружено - загрузем данные из базы.
  */
 final function __get($property)
 {
     return UserBean::inst()->getUserProperty($this->userId, $property);
 }
예제 #8
0
 /**
  * Метод удаляет аватар (с удалением загруженной картинки)
  */
 public function deleteUserAvatar($userId, $avatarId)
 {
     $avatarId = PsCheck::int($avatarId);
     UserBean::inst()->unsetUserAvatar($userId, $avatarId);
     return AvatarUploader::inst()->deleteUploadedFile($avatarId, $userId);
 }
예제 #9
0
 /**
  * Создание нового пользователя на основе данных формы регистрации
  * @return type
  */
 public static function createUser(RegFormData $regData)
 {
     //Создадим пользователя в базе
     UserBean::inst()->createUser($regData);
     //Авторизуем нового пользователя
     self::loginImpl($regData->getUserMail(), $regData->getPassword(), UserLoadType::CLIENT(), true);
 }