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


PHP Base::getUser方法代碼示例

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


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

示例1: get_user_groups

 public static function get_user_groups($user_id = null)
 {
     if (is_null($user_id)) {
         $user = Base::getUser();
         $groups = $user['groups'];
         $inheritance = (!empty($user['inheritance']) and is_array($user['inheritance'])) ? $user['inheritance'] : array();
         $groups = array_unique(array_merge($groups, $inheritance));
         // may comment this line to disable inheritance
     } else {
         $user_model = new \GCore\Admin\Models\User();
         $user = $user_model->find('first', array('conditions' => array('id' => $user_id)));
         if (!empty($user)) {
             $groups = Arr::getVal($user, array('GroupUser', '[n]', 'group_id'), self::get_public_groups());
             $user_groups_paths = Arr::getVal($user, array('Group', '[n]', 'path'), array());
             $user_inheritance = array();
             foreach ($user_groups_paths as $user_groups_path) {
                 $user_inheritance = array_merge($user_inheritance, array_filter(explode('.', $user_groups_path)));
             }
             $user_inheritance = array_unique($user_inheritance);
             $groups = array_unique(array_merge($groups, $user_inheritance));
             // may comment this line to disable inheritance
             $user = $user['User'];
             if (!empty($user['activation'])) {
                 return self::get_public_groups();
             }
             if ($user['blocked'] == 1) {
                 return self::get_public_groups();
             }
         }
     }
     return $groups;
 }
開發者ID:ejailesb,項目名稱:repo_empr,代碼行數:32,代碼來源:authenticate.php

示例2: check_rules

 public static function check_rules($rules, $groups = array(), $owner_id = null, $user_id = null)
 {
     $user = Base::getUser();
     if (empty($groups)) {
         $groups = Authenticate::get_user_groups($user_id);
     }
     if (!empty($owner_id) and $owner_id == $user['id']) {
         $groups[] = 'owner';
     }
     if (!is_array($rules)) {
         $rules = (array) $rules;
     }
     //check if any denied groups match user's groups
     $denied = array_keys($rules, -1);
     if (count(array_intersect($denied, $groups)) > 0) {
         //one or more of the user's groups is denied, return false
         return false;
     }
     //check if any allowed groups match user's groups
     $allowed = array_keys($rules, 1);
     if (count(array_intersect($allowed, $groups)) > 0) {
         //one or more of the user's groups is denied, return false
         return true;
     }
     //check if any not set groups match user's groups
     $not_set = array_keys($rules, '');
     if (count(array_intersect($not_set, $groups)) > 0) {
         //one or more of the user's groups is denied, return false
         return 0;
     }
     return null;
 }
開發者ID:ejailesb,項目名稱:repo_empr,代碼行數:32,代碼來源:authorize.php

示例3: initialize

 function initialize()
 {
     //start the session
     $user = Base::getUser();
     Event::trigger('on_initialize');
 }
開發者ID:ejailesb,項目名稱:repo_empr,代碼行數:6,代碼來源:app.php

示例4: beforeSave

 function beforeSave(&$data, &$params, $mode)
 {
     foreach ($this->params_fields as $params_field) {
         if (isset($data[$params_field]) and is_array($data[$params_field])) {
             $p_obj = new Parameter($data[$params_field]);
             $data[$params_field] = $p_obj->toString();
         }
     }
     if (isset($data['extras']) and is_array($data['extras'])) {
         $base_string = new Base64($data['extras']);
         $data['extras'] = $base_string->encode();
     }
     if (array_key_exists('alias', $data) and empty($data['alias']) and !empty($data['title'])) {
         $count = 1;
         $test = $alias = Str::slug($data['title']);
         redo:
         $exists = $this->find('first', array('fields' => array($this->pkey), 'conditions' => array('alias' => $test)));
         if (!empty($exists)) {
             $count++;
             $test = $alias . $count;
             goto redo;
         }
         $data['alias'] = $test;
     }
     if ($mode == 'create' and in_array('user_id', $this->table_fields) and !isset($data['user_id'])) {
         $user = Base::getUser();
         $data['user_id'] = $user['id'];
     }
 }
開發者ID:ejailesb,項目名稱:repo_empr,代碼行數:29,代碼來源:gmodel.php

示例5: function

 */
$app->get('/api/v1/queue/', function () use($base) {
    if (ApiHandler::validKey()) {
        ApiHandler::sendResponse(200, true, array('queue' => $base->getQueue()->getQueue()));
    } else {
        ApiHandler::notAuthenticated();
    }
});
/**
 * Add song to the queue
 */
$app->post('/api/v1/queue/add/', function () use($base) {
    if (ApiHandler::validKey()) {
        $song_info = $base->getSong()->getSongInformationFromGrooveShark($_POST['songID']);
        $base->getSong()->setSongInformation($song_info['SongID'], $song_info['SongName'], $song_info['ArtistName'], $song_info['ArtistID'], $song_info['CoverArtFilename'], $_POST['songPriority']);
        $base->getUser()->getUserByApiKey($_GET['apikey']);
        if ($base->getQueue()->addSongToQueue($base->getSong(), $base->getUser())) {
            ApiHandler::sendResponse(200, true);
        } else {
            ApiHandler::sendResponse(500, false);
        }
    } else {
        ApiHandler::notAuthenticated();
    }
});
/**
 * Register
 */
$app->post('/api/v1/register/', function () use($base) {
    $register = $base->getUser()->registerUser($_POST['username'], $_POST['password']);
    if ($register === USER_ALREADY_EXISTS) {
開發者ID:nbar1,項目名稱:gs,代碼行數:31,代碼來源:routes.php


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