本文整理汇总了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;
}
示例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;
}
示例3: initialize
function initialize()
{
//start the session
$user = Base::getUser();
Event::trigger('on_initialize');
}
示例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'];
}
}
示例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) {