当前位置: 首页>>代码示例>>PHP>>正文


PHP Current_User::allowUsername方法代码示例

本文整理汇总了PHP中Current_User::allowUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP Current_User::allowUsername方法的具体用法?PHP Current_User::allowUsername怎么用?PHP Current_User::allowUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Current_User的用法示例。


在下文中一共展示了Current_User::allowUsername方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authenticate

 public function authenticate()
 {
     if (empty($this->password)) {
         return false;
     }
     $db = new PHPWS_DB('user_authorization');
     if (!Current_User::allowUsername($this->user->username)) {
         return false;
     }
     $password_hash = md5($this->user->username . $this->password);
     $db->addColumn('username');
     $db->addWhere('username', strtolower($this->user->username));
     $db->addWhere('password', $password_hash);
     $result = $db->select('one');
     return !PHPWS_Error::logIfError($result) && (bool) $result;
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:16,代码来源:local.php

示例2: postStaff

 public function postStaff()
 {
     @($staff_id = (int) $_POST['staff_id']);
     if (!empty($staff_id)) {
         $this->loadStaff($staff_id);
     } else {
         @($user_name = $_POST['username']);
         if (empty($user_name) || !Current_User::allowUsername($user_name)) {
             $this->message = dgettext('checkin', 'Please try another user name');
             return false;
         }
         // Test user name, make sure exists
         $db = new PHPWS_DB('checkin_staff');
         $db->addWhere('user_id', 'users.id');
         $db->addWhere('users.username', $user_name);
         $db->addColumn('id');
         $result = $db->select('one');
         if (PHPWS_Error::logIfError($result)) {
             $this->message = dgettext('checkin', 'Problem saving user.');
             return false;
         } elseif ($result) {
             $this->message = dgettext('checkin', 'User already is staff member.');
             return false;
         }
         // user is allowed and new, get user_id to create staff
         $db = new PHPWS_DB('users');
         $db->addWhere('username', $user_name);
         $db->addColumn('id');
         $user_id = $db->select('one');
         if (PHPWS_Error::logIfError($result)) {
             $this->message = dgettext('checkin', 'Problem saving user.');
             return false;
         }
         if (!$user_id) {
             $this->message = dgettext('checkin', 'Could not locate anyone with this user name.');
             return false;
         }
         $this->loadStaff();
         $this->staff->user_id = $user_id;
     }
     // Blank filter to begin with
     $filter = 0x0;
     // Update last name filter
     if ($_POST['last_name'] == 'yes') {
         $filter = $filter | LAST_NAME_BITMASK;
         if (!empty($_POST['last_name_filter'])) {
             $this->staff->filter_type = $filter;
             // parseFilter() checks filter_type, so it needs to be updated early
             $this->staff->parseFilter($_POST['last_name_filter']);
         } else {
             $this->message[] = dgettext('checkin', 'Please enter a last name filter.');
         }
     } else {
         $this->staff->lname_filter = null;
         $this->staff->lname_regexp = null;
     }
     // Update reason filter
     if ($_POST['reason'] == 'yes') {
         $filter = $filter | REASON_BITMASK;
         if (!empty($_POST['reason_filter'])) {
             $this->staff->_reasons = $_POST['reason_filter'];
         } else {
             $this->message[] = dgettext('checkin', 'Please pick one or more reasons.');
         }
     }
     // Update gender filter
     if ($_POST['gender'] == 'yes') {
         $filter = $filter | GENDER_BITMASK;
         if (isset($_POST['gender_filter'])) {
             $this->staff->gender_filter = $_POST['gender_filter'];
         } else {
             $this->message[] = dgettext('checkin', 'Please choose a gender filter.');
         }
     } else {
         $this->staff->gender_filter = null;
     }
     // Update birthdate filter
     if ($_POST['birthdate'] == 'yes') {
         $filter = $filter | BIRTHDATE_BITMASK;
         if (!empty($_POST['start_date']) && !empty($_POST['end_date'])) {
             $this->staff->birthdate_filter_start = strtotime($_POST['start_date']);
             $this->staff->birthdate_filter_end = strtotime($_POST['end_date']);
         } else {
             $this->message[] = dgettext('checkin', 'Please enter a start and end date.');
         }
     } else {
         $this->staff->birthdate_filter_start = null;
         $this->staff->birthdate_filter_end = null;
     }
     // Update filter_type
     $this->staff->filter_type = $filter;
     return empty($this->message) ? true : false;
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:93,代码来源:Checkin_Admin.php

示例3: setUsername

 public function setUsername($username)
 {
     $username = strtolower($username);
     if (empty($username) || !Current_User::allowUsername($username)) {
         return PHPWS_Error::get(USER_ERR_BAD_USERNAME, 'users', 'setUsername', $username);
     }
     if (strlen($username) < USERNAME_LENGTH) {
         return PHPWS_Error::get(USER_ERR_BAD_USERNAME, 'users', 'setUsername', $username);
     }
     if ($this->isDuplicateUsername($username, $this->id) || $this->isDuplicateDisplayName($username, $this->id)) {
         return PHPWS_Error::get(USER_ERR_DUP_USERNAME, 'users', 'setUsername', $username);
     }
     if ($this->isDuplicateGroup($username, $this->id)) {
         return PHPWS_Error::get(USER_ERR_DUP_GROUPNAME, 'users', 'setUsername', $username);
     }
     $this->username = $username;
     return true;
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:18,代码来源:Users.php

示例4: loginUser

 /**
  * Logs in a user dependant on their authorization setting
  */
 public static function loginUser($username, $password = null)
 {
     if (!Current_User::allowUsername($username)) {
         return PHPWS_Error::get(USER_BAD_CHARACTERS, 'users', 'Current_User::loginUser');
     }
     // First check if they are currently a user
     $user = new PHPWS_User();
     $db = new PHPWS_DB('users');
     $db->addWhere('username', strtolower($username));
     $result = $db->loadObject($user);
     if (PHPWS_Error::isError($result)) {
         return $result;
     }
     if ($result == false) {
         if (PHPWS_Error::logIfError($user->setUsername($username))) {
             return false;
         }
     } else {
         // This user is in the local database
         if (!$user->approved) {
             return PHPWS_Error::get(USER_NOT_APPROVED, 'users', 'Current_User::loginUser');
         }
         if (!$user->loadScript()) {
             Layout::add(dgettext('users', 'Could not load authentication script. Please contact site administrator.'));
             return false;
         }
     }
     if (!Current_User::loadAuthorization($user)) {
         Layout::add(dgettext('users', 'Could not load authentication script. Please contact site administrator.'));
         return false;
     }
     $auth = Current_User::getAuthorization();
     $auth->setPassword($password);
     $result = $auth->authenticate();
     if (PHPWS_Error::isError($result)) {
         return $result;
     }
     if ($result == true) {
         // If the user id is zero and the authorization wants a new
         // user created
         if (!$user->id && $auth->create_new_user) {
             $user->setActive(true);
             $user->setApproved(true);
             $auth->createUser();
             $user->save();
             PHPWS_Core::initModClass('users', 'Action.php');
             User_Action::assignDefaultGroup($user);
         }
         if (!$user->active) {
             return PHPWS_Error::get(USER_DEACTIVATED, 'users', 'Current_User:loginUser', $user->username);
         }
         if ($auth->localUser()) {
             $user->login();
         }
         unset($_SESSION['User']);
         $_SESSION['User'] = $user;
         return true;
     } else {
         return false;
     }
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:64,代码来源:Current_User.php


注:本文中的Current_User::allowUsername方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。