本文整理汇总了PHP中session::permission方法的典型用法代码示例。如果您正苦于以下问题:PHP session::permission方法的具体用法?PHP session::permission怎么用?PHP session::permission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类session
的用法示例。
在下文中一共展示了session::permission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: results
public function results()
{
if (!input::get('search_id')) {
$this->index();
return;
}
// Parameters
$params = array('join_columns' => array('`u`.`verified`=1', '`u`.`active`=1', '`u`.`group_id` IN (' . implode(',', session::permission('users_groups_browse', 'users')) . ')', '`u`.`type_id` IN (' . implode(',', session::permission('users_types_browse', 'users')) . ')'), 'join_items' => array());
// Process filters
$params = $this->parseCounters($params);
// Process query string
$qstring = $this->parseQuerystring($params['max']);
// Get users
$users = array();
if ($params['total']) {
$users = $this->users_model->getUsers('in_list', isset($params['values']['type_id']) ? $params['values']['type_id'] : 0, $params['join_columns'], $params['join_items'], $qstring['order'], $qstring['limit']);
}
// Get fields
$fields = $this->fields_model->getFields('users', isset($params['values']['type_id']) ? $params['values']['type_id'] : 0, 'view', 'in_list');
// Set pagination
$config = array('base_url' => config::siteURL('users/results?' . $qstring['url']), 'total_items' => $params['total'], 'max_items' => config::item('max_search_results', 'system'), 'items_per_page' => config::item('users_per_page', 'users'), 'current_page' => $qstring['page'], 'uri_segment' => 'page');
$pagination = loader::library('pagination', $config, null);
// Assign vars
view::assign(array('users' => $users, 'fields' => $fields, 'pagination' => $pagination));
// Set meta tags
$this->metatags_model->set('users', 'users_search_results');
// Set title
view::setTitle(__('search_results', 'system'), false);
// Assign actions
view::setAction('users?' . substr($qstring['url'], 0, -1), __('search_modify', 'system'), array('class' => 'icon-text icon-users-search-edit'));
// Load view
view::load('users/index');
}
示例2: add
public function add()
{
// Get URI vars
$slugID = urldecode(utf8::trim(uri::segment(4)));
// Do we have a slug ID?
if ($slugID == '') {
error::show404();
}
// Get user
if (!($user = $this->users_model->getUser($slugID)) || !$user['active'] || !$user['verified']) {
error::show404();
}
// Is this a self request
if ($user['user_id'] == session::item('user_id')) {
router::redirect($user['slug']);
} elseif (!in_array($user['group_id'], session::permission('users_groups_browse', 'users')) || !in_array($user['type_id'], session::permission('users_types_browse', 'users'))) {
view::noAccess();
}
// Does blocked user exist?
if ($blocked = $this->users_blocked_model->getUser($user['user_id'], true)) {
view::setError(__('user_duplicate', 'users_blocked'));
router::redirect($user['slug']);
}
// Block user
$this->users_blocked_model->addUser($user['user_id']);
// Success
view::setInfo(__('user_blocked', 'users_blocked'));
//router::redirect($user['slug']);
router::redirect('users/blocked');
}
示例3: getPictures
public static function getPictures($params = array())
{
if (!session::permission('users_groups_browse', 'users') && !session::permission('users_types_browse', 'users')) {
return '';
}
loader::model('pictures/pictures');
$template = isset($params['template']) ? $params['template'] : 'pictures/helpers/pictures';
$user = isset($params['user']) && $params['user'] ? $params['user'] : array();
$userID = $user ? $user['user_id'] : (isset($params['user_id']) ? $params['user_id'] : 0);
$params['albums'] = true;
if ($userID) {
$params['join_columns'][] = '`p`.`user_id`=' . $userID;
}
if (!$userID || $userID != session::item('user_id')) {
if ($userID) {
$params['privacy'] = $userID;
} else {
$params['join_columns'][] = '`a`.`public`=1';
$params['join_columns'][] = '`u`.`verified`=1';
$params['join_columns'][] = '`u`.`active`=1';
$params['join_columns'][] = '`u`.`group_id` IN (' . implode(',', session::permission('users_groups_browse', 'users')) . ')';
$params['join_columns'][] = '`u`.`type_id` IN (' . implode(',', session::permission('users_types_browse', 'users')) . ')';
}
}
$params['limit'] = isset($params['limit']) ? $params['limit'] : 10;
$params['order'] = isset($params['order']) ? $params['order'] : '';
$pictures = codebreeder::instance()->pictures_model->getPictures('in_list', $params['join_columns'], array(), $params['order'], $params['limit'], $params);
view::assign(array('pictures' => $pictures, 'user' => $user, 'params' => $params), '', $template);
return view::load($template, array(), 1);
}
示例4: savePictureFile
public function savePictureFile($fileID, $adID, $ad, $extra = array())
{
// Basic picture data
$picture = array('file_id' => $fileID, 'ad_id' => $adID, 'user_id' => session::item('user_id'), 'post_date' => date_helper::now(), 'active' => session::permission('pictures_approve', 'classifieds') ? 1 : 9, 'order_id' => $ad['total_pictures'] + $ad['total_pictures_i'] + 1);
// Do we have extras?
if ($extra) {
// Merge extras
$picture = array_merge($picture, $extra);
}
// Save picture
$pictureID = $this->db->insert('classifieds_pictures_data', $picture);
// Do we have picture ID?
if ($pictureID) {
// Update album's counter
$column = $picture['active'] == 1 ? 'total_pictures' : 'total_pictures_i';
$this->db->query("UPDATE `:prefix:classifieds_data` SET `{$column}`=`{$column}`+1 WHERE `user_id`=? AND `ad_id`=? LIMIT 1", array(session::item('user_id'), $adID));
// Does album have a cover?
if (!$ad['picture_id']) {
// Update ad cover
$this->classifieds_model->updatePicture($adID, $pictureID);
}
// Action hook
hook::action('classifieds/pictures/insert', $pictureID, $picture);
}
return $pictureID;
}
示例5: getTimeline
public static function getTimeline($user = array(), $privacy = 2, $template = 'timeline/helpers/timeline')
{
loader::model('timeline/timeline');
// Get actions
$actions = codebreeder::instance()->timeline_model->getActions($user ? $user['user_id'] : 0, true, 0, config::item('actions_per_page', 'timeline'));
$ratings = array();
// Do we have actions and are we logged in?
if ($actions && users_helper::isLoggedin()) {
foreach ($actions as $action) {
if ($action['rating']) {
$ratings[$action['relative_resource']][] = $action['item_id'];
} else {
$ratings['timeline'][] = $action['action_id'];
}
}
// Load votes and like models
loader::model('comments/votes');
loader::model('comments/likes');
// Get likes and votes
$likes = codebreeder::instance()->likes_model->getMultiLikes($ratings);
$votes = codebreeder::instance()->votes_model->getMultiVotes($ratings);
$ratings = $likes + $votes;
}
// Can we post messages?
$post = session::permission('messages_post', 'timeline') && codebreeder::instance()->users_model->getPrivacyAccess($user['user_id'], $privacy, false) ? true : false;
view::assign(array('actions' => $actions, 'user' => $user, 'post' => $post, 'ratings' => $ratings), '', $template);
// Update comments pagination
config::set('comments_per_page', config::item('comments_per_page', 'timeline'), 'comments');
return view::load($template, array(), 1);
}
示例6: getComments
public static function getComments($resource, $userID, $itemID, $total, $privacy = 2, $post = true, $info = true, $static = false)
{
// Can we post comments?
$post = $post && session::permission('comments_view', 'comments') && session::permission('comments_post', 'comments') ? true : false;
if ($userID) {
$post = $privacy && codebreeder::instance()->users_model->getPrivacyAccess($userID, $privacy, false) ? true : false;
}
loader::controller('comments');
echo codebreeder::instance()->comments->browse($resource, $itemID, $total, 1, $post, $info, $static);
}
示例7: __construct
public function __construct()
{
parent::__construct();
if (!config::item('feedback_active', 'feedback')) {
error::show404();
} elseif (!session::permission('feedback_access', 'feedback')) {
view::noAccess();
}
loader::model('feedback/feedback');
}
示例8: index
public function index()
{
if (session::permission('users_manage', 'users')) {
loader::controller('cp/users');
$this->users->browse();
} else {
view::noAccess(false);
// Load view
view::load('cp/home');
}
}
示例9: __construct
public function __construct()
{
parent::__construct();
// Does user have permission to access this plugin?
if (!session::permission('settings_manage', 'users')) {
view::noAccess();
}
view::setCustomParam('section', 'users');
view::setCustomParam('options', config::item('cp_top_nav', 'lists', 'users', 'items'));
view::setTrail('cp/users', __('users', 'system_navigation'));
}
示例10: __construct
public function __construct()
{
parent::__construct();
// Does user have permission to access this plugin?
if (!session::permission('plans_manage', 'billing')) {
view::noAccess();
}
view::setCustomParam('section', 'billing');
view::setCustomParam('options', config::item('cp_top_nav', 'lists', 'billing', 'items'));
loader::model('billing/plans');
view::setTrail('cp/billing/transactions', __('billing', 'system_navigation'));
view::setTrail('cp/billing/plans', __('billing_plans', 'system_navigation'));
}
示例11: __construct
public function __construct()
{
parent::__construct();
// Does user have permission to access this plugin?
if (!session::permission('languages_manage', 'system')) {
view::noAccess();
}
view::setCustomParam('section', 'system');
view::setCustomParam('options', config::item('cp_top_nav', 'lists', 'system', 'items', 'system/languages', 'items'));
loader::model('system/languages');
view::setTrail('cp/system/config/system', __('system', 'system_navigation'));
view::setTrail('cp/system/languages/', __('system_languages', 'system_navigation'));
}
示例12: __construct
public function __construct()
{
parent::__construct();
// Does user have permission to access this plugin?
if (!session::permission('newsletters_manage', 'newsletters')) {
view::noAccess();
}
view::setCustomParam('section', 'content');
view::setCustomParam('options', config::item('cp_top_nav', 'lists', 'content', 'items', 'content/newsletters', 'items'));
view::setTrail('cp/system/plugins', __('content', 'system_navigation'));
view::setTrail('cp/content/newsletters', __('newsletters', 'system_navigation'));
loader::model('newsletters/newsletters', array(), 'newsletters_model');
}
示例13: __construct
public function __construct()
{
parent::__construct();
// Does user have permission to access this plugin?
if (!session::permission('counters_manage', 'utilities')) {
view::noAccess();
}
view::setCustomParam('section', 'system');
view::setCustomParam('options', config::item('cp_top_nav', 'lists', 'system', 'items', 'system/utilities', 'items'));
loader::model('utilities/counters', array(), 'recalculate_model');
view::setTrail('cp/system/config/system', __('system', 'system_navigation'));
view::setTrail('cp/utilities/counters', __('utilities_counters', 'system_navigation'));
}
示例14: saveAdData
public function saveAdData($adID, $userID, $adOld, $fields, $extra = array())
{
// Is this a new ad?
if (!$adID) {
$extra['post_date'] = date_helper::now();
}
// Do we have user ID?
if ($userID) {
$extra['active'] = session::permission('ads_approve', 'classifieds') ? 1 : 9;
$extra['user_id'] = $userID;
}
// Save ad
if (!($newAdID = $this->fields_model->saveValues('classified_ad', $adID, $adOld, $fields, $extra))) {
return 0;
}
// Is this a new ad?
if (!$adID && $userID) {
$column = $extra['active'] == 1 ? 'total_classifieds' : 'total_classifieds_i';
$this->db->query("UPDATE `:prefix:users` SET `{$column}`=`{$column}`+1 WHERE `user_id`=? LIMIT 1", array($userID));
}
// Did ad status change?
if ($adID && $extra['active'] != $adOld['active']) {
// Did we approve this ad?
if ($extra['active'] == 1) {
$this->db->query("UPDATE `:prefix:users` SET `total_classifieds`=`total_classifieds`+1, `total_classifieds_i`=`total_classifieds_i`-1 WHERE `user_id`=? LIMIT 1", array($adOld['user_id']));
} elseif ($adID && $adOld['active'] == 1) {
$this->db->query("UPDATE `:prefix:users` SET `total_classifieds`=`total_classifieds`-1, `total_classifieds_i`=`total_classifieds_i`+1 WHERE `user_id`=? LIMIT 1", array($adOld['user_id']));
}
}
if (!$adID) {
// Deduct credits?
if (config::item('credits_active', 'billing') && session::permission('ads_credits', 'classifieds')) {
loader::model('billing/credits');
$this->credits_model->removeCredits(session::item('user_id'), session::permission('ads_credits', 'classifieds'));
}
}
if ($adID) {
// Update timeline action
timeline_helper::update(true, 'classified_ad_post', $adOld['user_id'], $newAdID, $extra['active']);
// Action hook
hook::action('classifieds/update', $newAdID, $extra);
} else {
// Save timeline action
if (session::item('timeline_classified_post', 'config') === false || session::item('timeline_classified_post', 'config')) {
timeline_helper::save('classified_ad_post', $userID, $newAdID, $extra['active']);
}
// Action hook
hook::action('classifieds/insert', $newAdID, $extra);
}
return $newAdID;
}
示例15: submit
public function submit()
{
// Does user have permission to submit reports?
if (!session::permission('reports_post', 'reports')) {
view::setError(__('no_action', 'system'));
view::load('system/elements/blank', array('autoclose' => true));
return false;
}
$resource = uri::segment(3);
$itemID = uri::segment(4);
if (!$resource || !($resourceID = config::item('resources', 'core', $resource, 'resource_id')) || !config::item('resources', 'core', $resource, 'report')) {
view::setError(__('resource_invalid', 'system'));
view::load('system/elements/blank', array('autoclose' => true));
return false;
}
if (!$itemID || !is_numeric($itemID) || $itemID < 0) {
view::setError(__('item_invalid', 'reports'));
view::load('system/elements/blank', array('autoclose' => true));
return false;
}
// Does this item exist?
if (!($userID = $this->reports_model->getUserID($resource, $itemID))) {
view::setError(__('item_invalid', 'reports'));
view::load('system/elements/blank', array('autoclose' => true));
return false;
}
// Did we report this already?
if ($this->reports_model->isReported($resourceID, $itemID)) {
view::setError(__('report_exists', 'reports'));
view::load('system/elements/blank', array('autoclose' => true));
return false;
}
// Get subjects
$subjects = array();
$data = $this->reports_subjects_model->getSubjects(false, true);
foreach ($data as $subject) {
$subjects[$subject['subject_id']] = $subject['name'];
}
$subjects = $subjects ? array('' => __('select', 'system')) + $subjects : $subjects;
// Assign vars
view::assign(array('subjects' => $subjects));
// Process form values
if (input::post('do_submit_report')) {
$this->_submitReport($resource, $resourceID, $userID, $itemID, $subjects);
}
// Set title
view::setTitle(__('report_submit', 'reports'));
// Load view
view::load('report/index');
}