/** * Возвращает код получателя */ public function getUserIdTo() { foreach ($this->to as $addr) { $userId = UserBean::inst()->getUserIdByMail($addr[0]); if (is_integer($userId)) { return $userId; //--- } } return null; }
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; }
/** @return AdminUserBean */ public static function inst() { return parent::inst(); }
/** * Загрузка пользователя по 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; }
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; }
/** * Получение свойства по его названию. * Если данные пользователя не установлены или требуемое свойство не загружено - загрузем данные из базы. */ final function __get($property) { return UserBean::inst()->getUserProperty($this->userId, $property); }
/** * Метод удаляет аватар (с удалением загруженной картинки) */ public function deleteUserAvatar($userId, $avatarId) { $avatarId = PsCheck::int($avatarId); UserBean::inst()->unsetUserAvatar($userId, $avatarId); return AvatarUploader::inst()->deleteUploadedFile($avatarId, $userId); }
/** * Создание нового пользователя на основе данных формы регистрации * @return type */ public static function createUser(RegFormData $regData) { //Создадим пользователя в базе UserBean::inst()->createUser($regData); //Авторизуем нового пользователя self::loginImpl($regData->getUserMail(), $regData->getPassword(), UserLoadType::CLIENT(), true); }