当前位置: 首页>>代码示例>>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;未经允许,请勿转载。