當前位置: 首頁>>代碼示例>>PHP>>正文


PHP BackendUser::hasSuperUser方法代碼示例

本文整理匯總了PHP中BackendUser::hasSuperUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP BackendUser::hasSuperUser方法的具體用法?PHP BackendUser::hasSuperUser怎麽用?PHP BackendUser::hasSuperUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BackendUser的用法示例。


在下文中一共展示了BackendUser::hasSuperUser方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validate

 function validate($data, $action, $options = array())
 {
     $data = parent::validate($data, $action, $options);
     if (!$data) {
         return $data;
     }
     switch ($action) {
         case 'create':
             $data['active'] = array_key_exists('active', $data) ? $data['active'] : true;
             //We need either an email, mobile number or username to register a user
             //Lower ASCII only
             if (!empty($data['username'])) {
                 $data['username'] = filter_var(trim($data['username']), FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
                 //TODO Make the banned usernames configurable
                 $banned_usernames = array('root', 'admin', 'superadmin', 'superuser', 'webadmin', 'postmaster', 'webdeveloper', 'webmaster', 'administrator', 'sysadmin');
                 if (in_array($data['username'], $banned_usernames) && BackendUser::hasSuperUser()) {
                     Backend::addError('Please choose a valid username');
                     return false;
                 }
             }
             if (empty($data['username']) && empty($data['email']) && empty($data['mobile'])) {
                 Backend::addError('Please provide a username');
             }
             //If the username is an email address, make it the email address
             if (!empty($data['username']) && filter_var($data['username'], FILTER_VALIDATE_EMAIL)) {
                 if (!empty($data['email'])) {
                     list($data['username'], $data['email']) = array($data['email'], $data['username']);
                 } else {
                     $data['email'] = $data['username'];
                     unset($data['username']);
                 }
             }
             $data['salt'] = get_random('numeric');
             $data['password'] = md5($data['salt'] . $data['password'] . Controller::$salt);
             if (ConfigValue::get('application.confirmUser')) {
                 $data['confirmed'] = false;
             } else {
                 $data['confirmed'] = array_key_exists('confirmed', $data) ? $data['confirmed'] : true;
             }
             break;
         case 'update':
             if (!empty($data['password'])) {
                 $data['password'] = md5($this->array['salt'] . $data['password'] . Controller::$salt);
             }
             break;
     }
     return $data;
 }
開發者ID:jrgns,項目名稱:backend-php,代碼行數:48,代碼來源:BackendUserObj.obj.php


注:本文中的BackendUser::hasSuperUser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。