本文整理汇总了PHP中has_permission函数的典型用法代码示例。如果您正苦于以下问题:PHP has_permission函数的具体用法?PHP has_permission怎么用?PHP has_permission使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了has_permission函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($context = null)
{
// Get a list of modules with a controller matching
// $context ('content', 'appearance', 'settings', 'statistics', or 'developer')
foreach (module_list() as $module) {
if (module_controller_exists($context, $module)) {
$this->actions[] = $module;
}
}
// Do we have any actions?
if (!count($this->actions)) {
return '<ul class="nav-sub clearfix"></ul>';
}
// Grab our module permissions so we know who can see what on the sidebar
$permissions = config_item('module_permissions');
// Build up our menu array
foreach ($this->actions as $module) {
// Make sure the user has permission to view this page.
if (isset($permissions[$context][$module]) && has_permission($permissions[$context][$module]) || !array_key_exists($module, $permissions[$context])) {
// Grab our module config array, if any.
$mod_config = module_config($module);
$display_name = isset($mod_config['name']) ? $mod_config['name'] : $module;
$title = isset($mod_config['description']) ? $mod_config['description'] : $module;
$menu_topic = isset($mod_config['menu_topic'][$context]) ? $mod_config['menu_topic'][$context] : $display_name;
// Drop-down menus?
if (isset($mod_config['menus']) && isset($mod_config['menus'][$context])) {
$menu_view = $mod_config['menus'][$context];
} else {
$menu_view = '';
}
$this->menu[$menu_topic][$module] = array('title' => $title, 'display_name' => $display_name, 'menu_view' => $menu_view, 'menu_topic' => $menu_topic);
}
}
return $this->build_menu($context);
}
示例2: __construct
/**
* Class constructor - setup paging and keyboard shortcuts as well as
* load various libraries
*
*/
public function __construct()
{
parent::__construct();
$this->load->library('template');
$this->load->library('assets');
$this->load->library('ui/contexts');
// Pagination config
$this->pager = array('full_tag_open' => '<div class="pagination pagination-right"><ul>', 'full_tag_close' => '</ul></div>', 'next_link' => '→', 'prev_link' => '←', 'next_tag_open' => '<li>', 'next_tag_close' => '</li>', 'prev_tag_open' => '<li>', 'prev_tag_close' => '</li>', 'first_tag_open' => '<li>', 'first_tag_close' => '</li>', 'last_tag_open' => '<li>', 'last_tag_close' => '</li>', 'cur_tag_open' => '<li class="active"><a href="#">', 'cur_tag_close' => '</a></li>', 'num_tag_open' => '<li>', 'num_tag_close' => '</li>');
$this->limit = $this->settings_lib->item('site.list_limit');
// load the keyboard shortcut keys
$shortcut_data = array('shortcuts' => config_item('ui.current_shortcuts'), 'shortcut_keys' => $this->settings_lib->find_all_by('module', 'core.ui'));
Template::set('shortcut_data', $shortcut_data);
// Profiler Bar?
if (ENVIRONMENT == 'development') {
if ($this->settings_lib->item('site.show_profiler') and has_permission('Bonfire.Profiler.View')) {
// Profiler bar?
if (!$this->input->is_cli_request() and !$this->input->is_ajax_request()) {
$this->load->library('Console');
$this->output->enable_profiler(TRUE);
}
}
}
// Basic setup
Template::set_theme($this->config->item('template.admin_theme'), 'junk');
}
示例3: index
public function index($type=null)
{
// Get a list of modules with a controller matching
// $type ('content', 'appearance', 'settings', 'statistics', or 'developer')
foreach (module_list() as $module)
{
if (module_controller_exists($type, $module))
{
$this->actions[] = $module;
}
}
// Do we have any actions?
if (!count($this->actions))
{
return '<ul class="nav-sub clearfix"></ul>';
}
// Grab our module permissions so we know who can see what on the sidebar
$permissions = config_item('module_permissions');
// Build a ul to return
$list = "<ul class='nav-sub clearfix'>\n";
foreach ($this->actions as $module)
{
// Make sure the user has permission to view this page.
if ((isset($permissions[$type][$module]) && has_permission($permissions[$type][$module])) || !array_key_exists($module, $permissions[$type]))
{
// Is this the current module?
if ($module == $this->uri->segment(3))
{
$class = 'class="current"';
}
else
{
$class = '';
}
// Build our list item.
$list .= '<li><a href="'. site_url('admin/'. $type .'/'. $module) .'" '. $class;
// Icon
/*
if ($icon = module_icon($module))
{
$list .= ' style="background: url('. $icon .')"';
}
*/
$list .= '>'. ucwords(str_replace('_', '', $module)) ."</a></li>\n";
}
}
$list .= "</ul>\n";
return $list;
}
示例4: require_permission
function require_permission($permissions)
{
if (has_permission($permissions)) {
return true;
} else {
http_response_code(401);
dispatch('siteuser/user_login');
exit;
}
}
示例5: index
public function index()
{
if (!is_logged()) {
redirect('login');
}
// Use the same permissions for the list but use different statuses.
$surveys = array();
if (has_permission('view survey list any')) {
redirect('surveys');
} else {
if (has_permission('view survey list assigned')) {
redirect('surveys/open');
}
}
// If regular user just show a empty page.
$this->load->view('base/html_start');
$this->load->view('components/navigation', array('active_menu' => 'dashboard'));
$this->load->view('base/html_end');
}
示例6: type
public function type($type = '')
{
//restrict access to users with Institutions.View permission
$warning = array('type' => 'warning', 'text' => 'You dont have permission to view inistitutions');
$this->auth->restrict($warning, 'Institutions.View');
if (!$type) {
$this->index();
return;
}
// SB Admin CSS - Include on every page
$this->layout->add_css('sb-admin');
// SB Admin Scripts - Include with every page
$this->layout->add_js('sb-admin');
// get all institution by the type requested
$institutions = $this->institution_model->get_by_type($type);
$data['institutions'] = $institutions;
//find the institution type string for display in the view
$institution_type = $this->institutions_type[$type];
$data['institution_type'] = $institution_type;
$parent = $institution_type->parent;
$parent_institution_type = null;
$parent_institutions = array();
if ($parent) {
$parent_institution_type = $this->institutions_type[$parent];
$parent_institutions = $this->app->get_institutions_by_type($parent_institution_type->id_type);
}
// define institution columns. May be i should find a better way to do
// this.
$institution_columns = array('Institution');
if ($parent_institution_type && $parent_institution_type->nom_type) {
$institution_columns[] = $parent_institution_type->nom_type;
}
$institution_columns[] = 'Nom Responsable';
$institution_columns[] = 'Prenom Responsable';
if (has_permission('Institutions.Edit') || has_permission('Institutions.Delete')) {
$institution_columns[] = 'Actions';
}
$data['institution_columns'] = $institution_columns;
$data['parent_institutions'] = $parent_institutions;
$this->layout->view('institution_list', $data);
}
示例7: save_settings
/**
* Perform form validation and save the settings to the database
*
* @param array $extended_settings An optional array of settings from the
* extended_settings config file
*
* @return bool
*/
private function save_settings($extended_settings = array())
{
$this->form_validation->set_rules('title', 'lang:bf_site_name', 'required|trim');
$this->form_validation->set_rules('system_email', 'lang:bf_site_email', 'required|trim|valid_email');
$this->form_validation->set_rules('list_limit', 'Items <em>p.p.</em>', 'required|trim|numeric');
$this->form_validation->set_rules('password_min_length', 'lang:bf_password_length', 'required|trim|numeric');
$this->form_validation->set_rules('password_force_numbers', 'lang:bf_password_force_numbers', 'trim|numeric');
$this->form_validation->set_rules('password_force_symbols', 'lang:bf_password_force_symbols', 'trim|numeric');
$this->form_validation->set_rules('password_force_mixed_case', 'lang:bf_password_force_mixed_case', 'trim|numeric');
$this->form_validation->set_rules('password_show_labels', 'lang:bf_password_show_labels', 'trim|numeric');
$this->form_validation->set_rules('languages[]', 'lang:bf_language', 'required|trim|is_array');
// Setup the validation rules for any extended settings
$extended_data = array();
foreach ($extended_settings as $field) {
if (empty($field['permission']) || has_permission($field['permission'])) {
$this->form_validation->set_rules($field['name'], $field['label'], $field['rules']);
$extended_data["ext.{$field['name']}"] = $this->input->post($field['name']);
}
}
if ($this->form_validation->run() === false) {
return false;
}
$data = array(array('name' => 'site.title', 'value' => $this->input->post('title')), array('name' => 'site.system_email', 'value' => $this->input->post('system_email')), array('name' => 'site.status', 'value' => $this->input->post('status')), array('name' => 'site.list_limit', 'value' => $this->input->post('list_limit')), array('name' => 'auth.allow_register', 'value' => isset($_POST['allow_register']) ? 1 : 0), array('name' => 'auth.user_activation_method', 'value' => isset($_POST['user_activation_method']) ? $_POST['user_activation_method'] : 0), array('name' => 'auth.login_type', 'value' => $this->input->post('login_type')), array('name' => 'auth.use_usernames', 'value' => isset($_POST['use_usernames']) ? $this->input->post('use_usernames') : 0), array('name' => 'auth.allow_remember', 'value' => isset($_POST['allow_remember']) ? 1 : 0), array('name' => 'auth.remember_length', 'value' => (int) $this->input->post('remember_length')), array('name' => 'auth.use_extended_profile', 'value' => isset($_POST['use_ext_profile']) ? 1 : 0), array('name' => 'auth.allow_name_change', 'value' => $this->input->post('allow_name_change') ? 1 : 0), array('name' => 'auth.name_change_frequency', 'value' => $this->input->post('name_change_frequency')), array('name' => 'auth.name_change_limit', 'value' => $this->input->post('name_change_limit')), array('name' => 'auth.password_min_length', 'value' => $this->input->post('password_min_length')), array('name' => 'auth.password_force_numbers', 'value' => $this->input->post('password_force_numbers')), array('name' => 'auth.password_force_symbols', 'value' => $this->input->post('password_force_symbols')), array('name' => 'auth.password_force_mixed_case', 'value' => $this->input->post('password_force_mixed_case')), array('name' => 'auth.password_show_labels', 'value' => $this->input->post('password_show_labels') ? 1 : 0), array('name' => 'site.show_profiler', 'value' => isset($_POST['show_profiler']) ? 1 : 0), array('name' => 'site.show_front_profiler', 'value' => isset($_POST['show_front_profiler']) ? 1 : 0), array('name' => 'site.languages', 'value' => $this->input->post('languages') != '' ? serialize($this->input->post('languages')) : ''), array('name' => 'password_iterations', 'value' => $this->input->post('password_iterations')));
log_activity($this->current_user->id, lang('bf_act_settings_saved') . ': ' . $this->input->ip_address(), 'core');
// Save the settings to the DB
$updated = $this->settings_model->update_batch($data, 'name');
// If the update was successful and there are extended settings to save,
if ($updated && !empty($extended_data)) {
// Save them
$updated = $this->save_extended_settings($extended_data);
}
return $updated;
}
示例8: CreateFolder
function CreateFolder($resourceType, $currentFolder)
{
global $_FolderClass;
global $Config;
if (!isset($_GET)) {
global $_GET;
}
$sErrorNumber = '0';
$sErrorMsg = '';
if (!has_permission($currentFolder, $resourceType) || $_FolderClass < 8) {
if (!has_open_access()) {
$sErrorNumber = 103;
echo '<Error number="' . $sErrorNumber . '" />';
return;
}
}
if (isset($_GET['NewFolderName'])) {
$sess_id = session_id();
if (!isset($sess_id) || $sess_id != $_COOKIE['FCK_NmSp_acl']) {
session_id($_COOKIE['FCK_NmSp_acl']);
session_start();
}
global $Dwfck_conf_values;
global $dwfck_conf;
$dwfck_conf = $_SESSION['dwfck_conf'];
if (empty($dwfck_conf)) {
$dwfck_conf['deaccent'] = isset($Dwfck_conf_values['deaccent']) ? $Dwfck_conf_values['deaccent'] : 1;
$dwfck_conf['useslash'] = isset($Dwfck_conf_values['useslash']) ? $Dwfck_conf_values['useslash'] : 0;
$dwfck_conf['sepchar'] = isset($Dwfck_conf_values['sepchar']) ? $Dwfck_conf_values['sepchar'] : '_';
}
$sNewFolderName = $_GET['NewFolderName'];
$sNewFolderName = str_replace(' ', $dwfck_conf['sepchar'], $sNewFolderName);
$sNewFolderName = Dwfck_sanitize($sNewFolderName);
if (strpos($sNewFolderName, '..') !== FALSE) {
$sErrorNumber = '102';
} else {
// Map the virtual path to the local server path of the current folder.
$sServerDir = ServerMapFolder($resourceType, $currentFolder, 'CreateFolder');
if ($Dwfck_conf_values['fnencode'] == 'url' || $Config['osWindows'] && !isset($Dwfck_conf_values['fnencode'])) {
$sServerDir = encode_dir($sServerDir);
}
if ($Config['osWindows']) {
$sServerDir = normalizeWIN($sServerDir);
}
if (is_writable($sServerDir)) {
$sServerDir .= $sNewFolderName;
$sErrorMsg = CreateServerFolder($sServerDir);
switch ($sErrorMsg) {
case '':
$sErrorNumber = '0';
break;
case 'Invalid argument':
case 'No such file or directory':
$sErrorNumber = '102';
// Path too long.
break;
default:
$sErrorNumber = '110';
break;
}
} else {
$sErrorNumber = '103';
}
}
} else {
$sErrorNumber = '102';
}
// Create the "Error" node.
echo '<Error number="' . $sErrorNumber . '" />';
}
示例9: lang
</p>
<?php
echo Modules::run('roles/settings/matrix');
?>
</fieldset>
<?php
}
?>
<fieldset class="form-actions">
<input type="submit" name="save" class="btn btn-primary" value="<?php
echo lang('role_save_role');
?>
" />
<?php
echo lang('bf_or') . ' ' . anchor(SITE_AREA . '/settings/roles', lang('bf_action_cancel'));
if (isset($role) && $role->can_delete == 1 && has_permission('Bonfire.Roles.Delete')) {
?>
<button type="submit" name="delete" class="btn btn-danger" onclick="return confirm('<?php
e(js_escape(lang('role_delete_confirm') . ' ' . lang('role_delete_note')));
?>
')"><span class="icon-trash icon-white"></span> <?php
echo lang('role_delete_role');
?>
</button>
<?php
}
?>
</fieldset>
<?php
echo form_close();
?>
示例10: anchor
<li>
<a href="#" class="bttn bttn-primary bttn-small bttn-dropdown bttn-icon-edit" data-dropdown="action-bttn">Edit</a>
<ul class="action-dropdown for-bttn-small">
<?php
if (has_permission('edit any survey')) {
?>
<li><?php
echo anchor($survey_entity->get_url_edit(), 'Modify');
?>
</li>
<?php
}
?>
<?php
if (has_permission('delete any survey')) {
?>
<?php
$class = 'danger';
?>
<?php
$class .= !$survey_entity->status_allows('delete any survey') ? ' disabled' : '';
?>
<li><?php
echo anchor_csrf($survey_entity->get_url_delete(), 'Delete', array('class' => $class, 'data-confirm-action' => 'Are you sure you want to delete: <em>' . $survey_entity->title . '</em>?'));
?>
</li>
<?php
}
?>
</ul>
示例11: lang
<?php
if (has_permission('Bonfire.Users.Manage')) {
?>
<ul class="nav nav-pills">
<li <?php
echo $this->uri->segment(4) == '' ? 'class="active"' : '';
?>
>
<a href="<?php
echo site_url(SITE_AREA . '/settings/users');
?>
"><?php
echo lang('bf_users');
?>
</a>
</li>
<li <?php
echo $this->uri->segment(4) == 'create' ? 'class="active"' : '';
?>
>
<a href="<?php
echo site_url(SITE_AREA . '/settings/users/create');
?>
" id="create_new">Nouvel utilisateur</a>
</li>
</ul>
<?php
}
示例12: anchor
?>
</p>
</div>
<div class="text-right">
<br/>
<input type="submit" name="submit" value="Edit Navigation" /> or <?php
echo anchor(SITE_AREA . '/content/navigation', lang('navigation_cancel'));
?>
</div>
<?php
echo form_close();
?>
<?php
if (isset($navigation) && has_permission('Navigation.Content.Delete')) {
?>
<div class="box delete rounded">
<a class="button" id="delete-me" href="<?php
echo site_url(SITE_AREA . '/content/navigation/delete/' . $id);
?>
" onclick="return confirm('<?php
echo lang('navigation_delete_confirm');
?>
')"><?php
echo lang('navigation_delete_record');
?>
</a>
<h3><?php
echo lang('navigation_delete_record');
示例13: include_all
function include_all($x)
{
extract($x);
#add a few extra variables that will be usefull in the output;
#x = array('elements'=>, 'element_info'=>, 'user_id'=>, 'db'=>)
#Example: $data = include_all(compact('elements', 'element_info', 'user_id', 'db'));
#when there is no resource_class_id, find it from the project where instance was created. WILL ASSUME THAT RESOURCE_CLASS_ID FILLED OUT IS A REQUIREMENT FOR ALL S3DB THAT SHARE RULES
if ($_REQUEST['project_id'] == '') {
$project_id = $element_info['project_id'];
} else {
$project_id = $_REQUEST['project_id'];
}
if (!$model) {
$model = 'nsy';
}
if ($letter == '') {
$letter = strtoupper(substr($elements, 0, 1));
}
if (is_array($GLOBALS['s3map'][$GLOBALS['plurals'][$GLOBALS['s3codes'][$letter]]])) {
foreach ($GLOBALS['s3map'][$GLOBALS['plurals'][$GLOBALS['s3codes'][$letter]]] as $replace => $with) {
$element_info[$replace] = $element_info[$with];
}
}
#if element is a class, return the class id
if ($letter == 'D') {
$element_info['acl'] = $user_id == '1' ? '222' : (user_is_admin($user_id, $db) ? '212' : (user_is_public($user_id, $db) ? '210' : '211'));
$element_info['created_by'] = $user_id;
$element_info['description'] = $GLOBALS['s3db_info']['server']['site_intro'];
$element_info['name'] = $GLOBALS['s3db_info']['server']['site_title'];
if ($element_info['deployment_id'] == $GLOBALS['s3db_info']['deployment']['Did']) {
$element_info['self'] = 1;
}
}
if ($letter == 'G') {
#echo '<pre>';print_r($x);exit;
$e = 'groups';
#$element_info['group_id'] = $element_info['account_id'];
#$element_info['groupname'] = $element_info['account_uname'];
#$element_info['acl'] = groupAcl($element_info, $user_id, $db);
$uid_info = uid($element_info['account_id']);
$element_info['deployment_id'] = ereg_replace('^D', '', $uid_info['Did']);
$strictuid = 1;
$strictsharedwith = 1;
$uid = 'G' . $element_info['group_id'];
$shared_with = 'U' . $user_id;
#$element_info['acl'] = permissionOnResource(compact('user_id', 'shared_with', 'db', 'uid','key','strictsharedwith','strictuid'));
$element_info['acl'] = groupAcl($element_info, $user_id, $db, $timer);
if ($timer) {
$timer->setMarker('Included resource information for ' . $letter);
}
#echo '<pre>';print_r($element_info);exit;
}
if ($letter == 'U') {
if ($element_info['account_addr_id'] != '') {
$sql = "select * from s3db_addr where addr_id = '" . $element_info['account_addr_id'] . "'";
$fields = array('addr1', 'addr2', 'city', 'state', 'postal_code', 'country');
$db->query($sql);
while ($db->next_record()) {
for ($i = 0; $i < count($fields); $i++) {
$element_info[$fields[$i]] = $db->f($fields[$i]);
}
}
$element_info = array_delete($element_info, 'account_addr_id');
}
$element_info['user_id'] = $element_info['account_id'];
$element_info['username'] = $element_info['account_uname'];
$element_info['login'] = $element_info['account_lid'];
$element_info['address'] = $element_info['addr1'];
$uid_info = uid($element_info['account_id']);
$element_info['deployment_id'] = ereg_replace('^D', '', $uid_info['Did']);
if ($user_id != '1' && $element_info['created_by'] != $user_id && $element_info['account_id'] != $user_id) {
#if user is not seing himself and user is not admin and user was not the creator of element, then hide address, email, phone, etc.
$keys2Remove = array('account_email' => '', 'account_phone' => '', 'addr1' => '', 'addr2' => '', 'city' => '', 'state' => '', 'postal_code' => '', 'country' => '');
if (is_array($element_info)) {
$element_info = array_diff_key($element_info, $keys2Remove);
}
}
if ($user_id != '1' && $element_info['created_by'] != $user_id && $user_id != $element_info['account_id']) {
if (is_array($element_info)) {
$element_info = array_diff_key($element_info, array('account_type' => '', 'account_status' => ''));
}
} else {
//if this user has been created with a filter, what is that filter
$permission_info = array('uid' => 'U' . $element_info['created_by'], 'shared_with' => 'U' . $element_info['account_id']);
$hp = has_permission($permission_info, $db);
if ($hp) {
$element_info['filter'] = $hp;
}
}
if (is_array($element_info)) {
$element_info = array_diff_key($element_info, array('account_pwd' => ''));
}
$user_id_who_asks = $user_id;
$uid = 'U' . $element_info['user_id'];
$shared_with = $user_id_who_asks;
$strictuid = 1;
$strictsharedwith = 1;
$onPermissions = compact('user_id', 'shared_with', 'db', 'uid', 'key', 'strictsharedwith', 'strictuid');
if ($element_info['acl'] == '') {
$element_info['acl'] = userAcl(compact('key', 'element_info', 'user_id_who_asks', 'db'));
//.........这里部分代码省略.........
示例14: lang
</div>
</div>
</fieldset>
<?php
}
// Allow modules to render custom fields
Events::trigger('render_user_form');
?>
<!-- Start of User Meta -->
<?php
$this->load->view('users/user_meta');
?>
<!-- End of User Meta -->
<?php
if (isset($user) && has_permission('Permissions.' . ucfirst($user->role_name) . '.Manage') && $user->id != $this->auth->user_id() && ($user->banned || $user->deleted)) {
?>
<fieldset>
<legend><?php
echo lang('us_account_status');
?>
</legend>
<?php
$field = 'activate';
if ($user->active) {
$field = 'de' . $field;
}
?>
<div class="control-group">
<div class="controls">
<label for="<?php
示例15: ob_start
<?php
/******************/
// This Page Lets the Admin Add and Delete Editors to this site.
/*****************/
ob_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/Gamesite/core/init.php';
// Check if Admin is logged in, if not, redirect him to index.php
if (!has_permission('admin')) {
permission_error_redirect('index.php');
}
include 'includes/head.php';
include 'includes/navigation.php';
// Delete Editors
if (isset($_GET['delete'])) {
$delete_id = sanitize($_GET['delete']);
// Delete from DB and run query with Header Redirect.
$db->query("delete from admin where id = '{$delete_id}' ");
$_SESSION['success_flash'] = 'Editor has been deleted.';
header('Location: Editors.php');
}
// If Add New Editor is clicked
if (isset($_GET['add'])) {
// SET ALL OF THE FORM VARIABLES
$name = isset($_POST['name']) ? sanitize($_POST['name']) : '';
$email = isset($_POST['email']) ? sanitize($_POST['email']) : '';
$password = isset($_POST['password']) ? sanitize($_POST['password']) : '';
$confirm = isset($_POST['confirm']) ? sanitize($_POST['confirm']) : '';
$permissions = isset($_POST['permissions']) ? sanitize($_POST['permissions']) : '';
// set errors to a empty array
$errors = array();