本文整理汇总了PHP中is_user_administrator_rs函数的典型用法代码示例。如果您正苦于以下问题:PHP is_user_administrator_rs函数的具体用法?PHP is_user_administrator_rs怎么用?PHP is_user_administrator_rs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_user_administrator_rs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _validate_assigner_roles
function _validate_assigner_roles($scope, $src_or_tx_name, $item_id, $roles)
{
if (!$item_id && !is_user_administrator_rs()) {
return false;
}
$user_has_role = array();
if (TERM_SCOPE_RS == $scope) {
foreach (array_keys($roles) as $role_handle) {
$role_attributes = $this->scoper->role_defs->get_role_attributes($role_handle);
$args = array('src_name' => $role_attributes->src_name, 'object_type' => $role_attributes->object_type);
$user_has_role[$role_handle] = $this->user_has_role_in_term($role_handle, $src_or_tx_name, $item_id, $args);
}
} else {
if ($require_blogwide_editor = scoper_get_option('role_admin_blogwide_editor_only')) {
global $current_user;
$is_user_administrator = is_user_administrator_rs();
$is_content_administrator = is_content_administrator_rs();
}
foreach (array_keys($roles) as $role_handle) {
// a user must have a blog-wide edit cap to modify editing role assignments (even if they have Editor role assigned for some current object)
if ($require_blogwide_editor) {
if (!$is_user_administrator && 'admin' == $require_blogwide_editor) {
$user_has_role[$role_handle] = false;
continue;
}
if (!$is_content_administrator && 'admin_content' == $require_blogwide_editor) {
$user_has_role[$role_handle] = false;
continue;
}
$src_name = $this->scoper->role_defs->member_property($role_handle, 'src_name');
$object_type = $this->scoper->role_defs->member_property($role_handle, 'object_type');
static $can_edit_blogwide;
if (!isset($can_edit_blogwide)) {
$can_edit_blogwide = array();
}
if (!isset($can_edit_blogwide[$src_name][$object_type])) {
$can_edit_blogwide[$src_name][$object_type] = $this->scoper->user_can_edit_blogwide($src_name, $object_type, array('require_others_cap' => true));
}
if (!$can_edit_blogwide[$src_name][$object_type]) {
$user_has_role[$role_handle] = false;
continue;
}
}
if (!empty($this->scoper->role_defs->role_caps[$role_handle])) {
$user_has_role[$role_handle] = cr_user_can(array_keys($this->scoper->role_defs->role_caps[$role_handle]), $item_id);
}
}
}
return $user_has_role;
}
示例2: scoper_mu_users_menu
function scoper_mu_users_menu()
{
if (!defined('DEFINE_GROUPS_RS') || !scoper_get_site_option('mu_sitewide_groups')) {
return;
}
$cap_req = is_user_administrator_rs() || current_user_can('recommend_group_membership') ? 'read' : 'manage_groups';
$groups_caption = defined('GROUPS_CAPTION_RS') ? GROUPS_CAPTION_RS : __('Role Groups', 'scoper');
global $scoper_admin;
$menu_name = awp_ver('3.1') ? 'users.php' : 'ms-admin.php';
add_submenu_page($menu_name, $groups_caption, $groups_caption, $cap_req, 'rs-groups', array(&$scoper_admin, 'menu_handler'));
if (scoper_get_option('mu_sitewide_groups')) {
global $plugin_page_cr;
// satisfy WordPress' demand that all admin links be properly defined in menu
if ('rs-default_groups' == $plugin_page_cr) {
add_submenu_page($menu_name, __('User Groups', 'scoper'), __('Default Groups', 'scoper'), $cap_req, 'rs-default_groups', array(&$scoper_admin, 'menu_handler'));
}
if ('rs-group_members' == $plugin_page_cr) {
add_submenu_page($menu_name, __('User Groups', 'scoper'), __('Group Members', 'scoper'), $cap_req, 'rs-group_members', array(&$scoper_admin, 'menu_handler'));
}
}
}
示例3: flt_manage_posts_columns
function flt_manage_posts_columns($defaults)
{
global $current_user, $scoper, $scoper_role_usage;
$object_type = cr_find_post_type();
if ($blogwide_role_requirement = scoper_get_option('role_admin_blogwide_editor_only')) {
if ('admin' == $blogwide_role_requirement && !is_user_administrator_rs()) {
return $defaults;
} elseif ('content_admin' == $blogwide_role_requirement && !is_content_administrator_rs()) {
return $defaults;
} elseif ($blogwide_role_requirement) {
if (!$scoper->user_can_edit_blogwide('post', $object_type, array('require_others_cap' => true))) {
return $defaults;
}
}
}
$use_object_roles = scoper_get_otype_option('use_object_roles', 'post', $object_type);
$use_term_roles = scoper_get_otype_option('use_term_roles', 'post', $object_type);
if ($use_term_roles && !empty($scoper_role_usage->any_restricted_terms) || $use_object_roles && !empty($scoper_role_usage->any_restricted_objects)) {
if (scoper_get_otype_option('restrictions_column', 'post', $object_type)) {
$defaults['restricted'] = __('Restrict', 'scoper');
}
}
if (!empty($scoper_role_usage->have_termrole_ids['post'])) {
if (scoper_get_otype_option('term_roles_column', 'post', $object_type)) {
$defaults['termroles'] = __('Term Roles', 'scoper');
}
}
if ($use_object_roles && !empty($scoper_role_usage->have_objrole_ids['post'])) {
if (scoper_get_otype_option('object_roles_column', 'post', $object_type)) {
$otype_display_name = $scoper->data_sources->member_property('post', 'object_types', $object_type, 'display_name');
//$defaults['objroles'] = sprintf( _ x('%s Roles', 'Post or Page', 'scoper'), $otype_display_name);
$defaults['objroles'] = sprintf(__('%s Roles', 'scoper'), $otype_display_name);
}
}
return $defaults;
}
示例4: scoper_object_roles_list
function scoper_object_roles_list($viewing_user, $args = array())
{
$html = '';
if (!USER_ROLES_RS && !GROUP_ROLES_RS) {
wp_die(__awp('Cheatin’ uh?'));
}
$defaults = array('enforce_duration_limits' => true, 'is_user_profile' => false, 'echo' => true);
$args = array_merge($defaults, (array) $args);
extract($args);
global $scoper, $wpdb, $current_user;
if ($viewing_user) {
if (!is_object($viewing_user)) {
global $current_rs_user;
if ($viewing_user == $current_rs_user->ID) {
$viewing_user = $current_rs_user;
} else {
$viewing_user = new WP_Scoped_User($viewing_user);
}
}
}
$all_roles = array();
$role_display = array();
foreach ($scoper->role_defs->get_all_keys() as $role_handle) {
if ($viewing_user) {
$role_display[$role_handle] = $scoper->role_defs->get_display_name($role_handle, OBJECT_UI_RS);
} else {
$role_display[$role_handle] = $scoper->role_defs->get_abbrev($role_handle, OBJECT_UI_RS);
}
}
if (!$is_user_profile) {
$require_blogwide_editor = scoper_get_option('role_admin_blogwide_editor_only');
if ('admin' === $require_blogwide_editor && !is_user_administrator_rs()) {
return false;
}
if ('admin_content' === $require_blogwide_editor && !is_content_administrator_rs()) {
return false;
}
} else {
$require_blogwide_editor = false;
}
foreach ($scoper->data_sources->get_all() as $src_name => $src) {
$otype_count = 0;
if (!empty($src->taxonomy_only) || $src_name == 'group' && !$viewing_user) {
continue;
}
$strict_objects = $scoper->get_restrictions(OBJECT_SCOPE_RS, $src_name);
foreach ($src->object_types as $object_type => $otype) {
$otype_count++;
$disable_role_admin = false;
if ($require_blogwide_editor) {
if (!$scoper->user_can_edit_blogwide('post', $object_type, array('require_others_cap' => true))) {
$disable_role_admin = true;
}
}
if (!empty($src->cols->type) && !empty($otype->name)) {
$col_type = $src->cols->type;
$otype_clause = "AND {$src->table}.{$col_type} = '{$otype->name}'";
} elseif ($otype_count < 2) {
$otype_clause = '';
} else {
continue;
}
$col_id = $src->cols->id;
$col_name = $src->cols->name;
$ug_clause_for_user_being_viewed = $viewing_user ? $viewing_user->get_user_clause('uro') : '';
// TODO: replace join with uro subselect
$qry = "SELECT DISTINCT {$src->table}.{$col_name}, {$src->table}.{$col_id}, uro.role_name, uro.date_limited, uro.start_date_gmt, uro.end_date_gmt" . " FROM {$src->table} ";
$join = " INNER JOIN {$wpdb->user2role2object_rs} AS uro" . " ON uro.obj_or_term_id = {$src->table}.{$col_id}" . " AND uro.src_or_tx_name = '{$src_name}'" . " AND uro.scope = 'object' AND uro.role_type = 'rs'";
$duration_clause = $enforce_duration_limits ? scoper_get_duration_clause("{$src->table}.{$src->cols->date}") : '';
$status_clause = 'post' == $src_name ? "AND post_status != 'auto-draft'" : '';
// TODO: version update script to delete post roles on auto-drafts (stored via default roles)
$where = " WHERE 1=1 {$status_clause} {$otype_clause} {$duration_clause} {$ug_clause_for_user_being_viewed}";
$orderby = " ORDER BY {$src->table}.{$col_name} ASC, uro.role_name ASC";
$qry .= $join . $where . $orderby;
$results = scoper_get_results($qry);
if (!is_user_administrator_rs()) {
// no need to filter admins - just query the assignments
// only list role assignments which the logged-in user can administer
$args['required_operation'] = OP_EDIT_RS;
// Possible TODO: re-implement OP_ADMIN distinction with admin-specific capabilities
/*
if ( cr_get_reqd_caps( $src_name, OP_ADMIN_RS, $object_type ) {
$args['required_operation'] = OP_ADMIN_RS;
} else {
$reqd_caps = array();
foreach (array_keys($src->statuses) as $status_name) {
$admin_caps = $scoper->cap_defs->get_matching($src_name, $object_type, OP_ADMIN_RS, $status_name);
$delete_caps = $scoper->cap_defs->get_matching($src_name, $object_type, OP_DELETE_RS, $status_name);
$reqd_caps[$object_type][$status_name] = array_merge(array_keys($admin_caps), array_keys($delete_caps));
}
$args['force_reqd_caps'] = $reqd_caps;
}
*/
$qry = "SELECT {$src->table}.{$col_id} FROM {$src->table} WHERE 1=1";
$args['require_full_object_role'] = true;
$qry_flt = apply_filters('objects_request_rs', $qry, $src_name, $object_type, $args);
$cu_admin_results = scoper_get_col($qry_flt);
if (empty($viewing_user) || $current_user->ID != $viewing_user->ID) {
foreach ($results as $key => $row) {
if (!in_array($row->{$col_id}, $cu_admin_results)) {
//.........这里部分代码省略.........
示例5: update_group_members_multi_status
function update_group_members_multi_status($group_id, $current_members)
{
$posted_members = array();
$is_administrator = is_user_administrator_rs();
$can_manage = $is_administrator || current_user_can('manage_groups');
$can_moderate = $can_manage || current_user_can('recommend_group_membership');
if (!$can_moderate && !current_user_can('request_group_membership')) {
return;
}
if ($can_manage) {
$posted_members['active'] = explode(',', trim($_POST['current_agents_rs_csv'], ','));
} else {
$current_members = array_diff_key($current_members, array('active' => true));
}
if ($can_moderate) {
$current_members['recommended'] = ScoperAdminLib::get_group_members($group_id, COL_ID_RS, false, array('status' => 'recommended'));
if (!empty($_POST['recommended_agents_rs_csv'])) {
$posted_members['recommended'] = explode(',', trim($_POST['recommended_agents_rs_csv'], ','));
}
}
$current_members['requested'] = ScoperAdminLib::get_group_members($group_id, COL_ID_RS, false, array('status' => 'requested'));
if (!empty($_POST['requested_agents_rs_csv'])) {
$posted_members['requested'] = explode(',', trim($_POST['requested_agents_rs_csv'], ','));
}
$all_current_members = agp_array_flatten($current_members);
$all_posted_members = agp_array_flatten($posted_members);
foreach ($current_members as $status => $stored) {
// remove group memberships which were not posted for any status
foreach ($stored as $user_id) {
if ($user_id) {
if (!in_array($user_id, $all_posted_members)) {
ScoperAdminLib::remove_group_user($group_id, $user_id);
}
}
}
}
foreach ($posted_members as $status => $posted) {
// insert or update group memberships as specified
foreach ($posted as $user_id) {
if ($user_id) {
if (!in_array($user_id, $all_current_members)) {
ScoperAdminLib::add_group_user($group_id, $user_id, $status);
} elseif (!in_array($user_id, $current_members[$status])) {
ScoperAdminLib::update_group_user($group_id, $user_id, $status);
}
}
}
}
}
示例6: user_can_admin_terms_rs
function user_can_admin_terms_rs($taxonomy = '', $term_id = '', $user = '')
{
if (is_user_administrator_rs()) {
return true;
}
global $scoper;
if (!is_object($user)) {
$user = $GLOBALS['current_rs_user'];
}
$taxonomies = array();
$qualifying_caps = array();
if ($tx_obj = get_taxonomy($taxonomy)) {
$qualifying_caps = array($tx_obj->cap->manage_terms => 1);
$taxonomies[$taxonomy] = 1;
} else {
foreach ($scoper->cap_defs->get_all() as $cap_name => $capdef) {
if (isset($capdef->op_type) && OP_ADMIN_RS == $capdef->op_type && !empty($capdef->object_types)) {
foreach ($capdef->object_types as $_object_type) {
if (isset($scoper->taxonomies->members[$_object_type])) {
if (!$taxonomy || $_object_type == $taxonomy) {
$qualifying_caps[$cap_name] = 1;
$taxonomies[$_object_type] = 1;
}
}
}
}
}
}
if (empty($qualifying_caps)) {
return false;
}
// does current user have any blog-wide admin caps for term admin?
$qualifying_roles = $scoper->role_defs->qualify_roles(array_flip($qualifying_caps), 'rs');
if ($user_blog_roles = array_intersect_key($user->blog_roles[ANY_CONTENT_DATE_RS], $qualifying_roles)) {
if ($term_id) {
$strict_terms = $scoper->get_restrictions(TERM_SCOPE_RS, $taxonomy);
foreach (array_keys($user_blog_roles) as $role_handle) {
// can't blend in blog role if term requires term role assignment
// Presence of an "unrestrictions" element in array indicates that the role is default-restricted.
if (isset($strict_terms['unrestrictions'][$role_handle][$term_id]) || (!isset($strict_terms['unrestrictions'][$role_handle]) || !is_array($strict_terms['unrestrictions'][$role_handle])) && !isset($strict_terms['restrictions'][$role_handle][$term_id])) {
return true;
}
}
} else {
// todo: more precision by checking whether ANY terms are non-strict for the qualifying role(s)
return true;
}
}
// does current user have any term-specific admin caps for term admin?
if ($taxonomies) {
foreach (array_keys($taxonomies) as $taxonomy) {
if (!isset($user->term_roles[$taxonomy])) {
$user->get_term_roles_daterange($taxonomy);
}
// call daterange function populate term_roles property - possible perf enhancement for subsequent code even though we don't conider content_date-limited roles here
if (!empty($user->term_roles[$taxonomy][ANY_CONTENT_DATE_RS])) {
foreach (array_keys($user->term_roles[$taxonomy][ANY_CONTENT_DATE_RS]) as $role_handle) {
if (!empty($scoper->role_defs->role_caps[$role_handle])) {
if (array_intersect_key($qualifying_caps, $scoper->role_defs->role_caps[$role_handle])) {
if (!$term_id || in_array($term_id, $user->term_roles[$taxonomy][ANY_CONTENT_DATE_RS][$role_handle])) {
return true;
}
}
}
}
}
}
}
// endif any taxonomies have cap defined
}
示例7: ui_user_roles
function ui_user_roles()
{
if (!is_user_administrator_rs() && !scoper_get_option('display_user_profile_roles')) {
return;
}
global $profileuser, $current_rs_user;
$profile_user_rs = $profileuser->ID == $current_rs_user->ID ? $current_rs_user : new WP_Scoped_User($profileuser->ID);
include_once dirname(__FILE__) . '/profile_ui_rs.php';
ScoperProfileUI::display_ui_user_roles($profile_user_rs);
}
示例8: die
<?php
if (basename(__FILE__) == basename($_SERVER['SCRIPT_FILENAME'])) {
die('This page cannot be called directly.');
}
global $scoper, $wpdb, $current_rs_user;
$role_assigner = init_role_assigner();
require_once dirname(__FILE__) . '/admin_lib-bulk_rs.php';
require_once dirname(__FILE__) . '/admin_ui_lib_rs.php';
require_once dirname(__FILE__) . '/role_assignment_lib_rs.php';
$role_bases = array();
$agents = array();
$is_administrator = is_user_administrator_rs();
if (USER_ROLES_RS && $is_administrator) {
$role_bases[] = ROLE_BASIS_USER;
$agents[ROLE_BASIS_USER] = $scoper->users_who_can('', COLS_ID_NAME_RS);
$agent_list_prefix[ROLE_BASIS_USER] = '';
}
if (GROUP_ROLES_RS && $is_administrator) {
if ($agents[ROLE_BASIS_GROUPS] = ScoperAdminLib::get_all_groups(UNFILTERED_RS)) {
$role_bases[] = ROLE_BASIS_GROUPS;
$agent_list_prefix[ROLE_BASIS_GROUPS] = __('Groups') . ': ';
}
}
if (empty($role_bases)) {
wp_die(__awp('Cheatin’ uh?'));
}
$duration_limits_enabled = scoper_get_option('role_duration_limits');
$content_date_limits_enabled = scoper_get_option('role_content_date_limits');
$agent_names = array();
foreach ($role_bases as $role_basis) {
示例9:
continue;
}
}
if ($i % 2 == 0) {
$style = 'class=\'alternate\'';
} else {
$style = '';
}
?>
<tr <?php
echo $style;
?>
>
<td><?php
$name = $result->meta_id ? ScoperAdminLib::get_metagroup_name($result->meta_id, $result->display_name) : $result->display_name;
if ((!$result->meta_id || strpos($result->meta_id, '_ed_')) && (is_user_administrator_rs() || current_user_can('recommend_group_membership', $result->ID))) {
$url = "admin.php?page=rs-groups&mode=edit&id={$result->ID}";
echo "<a class='edit' href='{$url}'>{$name}</a>";
} else {
echo $name;
}
?>
</td>
<td><?php
if ($result->meta_id) {
echo ScoperAdminLib::get_metagroup_descript($result->meta_id, $result->descript);
} else {
echo $result->descript;
}
?>
</td>
示例10: item_tree
function item_tree($scope, $mode, $src, $otype_or_tx, $all_items, $assigned_roles, $strict_items, $role_defs_by_otype, $role_codes, $args = array())
{
$defaults = array('admin_items' => '', 'editable_roles' => '', 'ul_class' => 'rs-termlist', 'ie_link_style' => '', 'object_names' => '', 'table_captions' => '', 'err' => '', 'object_status' => '', 'agent_caption_plural' => '', 'agent_list_prefix' => '', 'agent_names' => '', 'default_hide_empty' => false, 'role_bases' => array(ROLE_BASIS_USER, ROLE_BASIS_GROUPS), 'single_item' => false);
$args = array_merge($defaults, (array) $args);
extract($args);
global $scoper;
if (!is_object($src)) {
$src = $scoper->data_sources->get($src);
}
$col_id = $src->cols->id;
$col_name = $src->cols->name;
$col_parent = isset($src->cols->parent) ? $src->cols->parent : '';
$item_label = $otype_or_tx->labels->singular_name;
if (TERM_SCOPE_RS == $scope) {
$src_or_tx_name = $otype_or_tx->name;
$edit_url_base = !empty($otype_or_tx->edit_url) ? $otype_or_tx->edit_url : '';
} else {
$src_or_tx_name = $src->name;
$edit_url_base = !empty($src->edit_url) ? $src->edit_url : '';
}
if ($default_hide_empty) {
$hide_tr_sfx = '-hide';
$hide_li_sfx = '-hide';
} else {
$hide_tr_sfx = '';
$hide_li_sfx = '';
}
$nextlink = '';
$prevlink = '';
if (empty($admin_items)) {
$admin_items = array();
}
if (empty($agent_caption_plural)) {
$agent_caption_plural = __('Users or Groups', 'scoper');
}
if (empty($agent_list_prefix)) {
$agent_list_prefix = array();
$agent_list_prefix[ROLE_BASIS_USER] = '';
$agent_list_prefix[ROLE_BASIS_GROUPS] = __('Groups') . ': ';
}
static $prevtext, $nexttext, $is_administrator, $role_header, $agents_header;
if (empty($prevtext)) {
// buffer prev/next caption for display with each term
//$prevtext = _ x('prev', '|abbreviated link to previous item', 'scoper');
//$nexttext = _ x('next', '|abbreviated link to next item', 'scoper');
$prevtext = __('prev', 'scoper');
$nexttext = __('next', 'scoper');
$is_administrator = is_administrator_rs($src, 'user');
$role_header = __awp('Role');
switch ($mode) {
case ROLE_ASSIGNMENT_RS:
//$agents_header = sprintf( _ x('Current %s', 'users or groups', 'scoper'), $agent_caption_plural);
$agents_header = sprintf(__('Current %s', 'scoper'), $agent_caption_plural);
break;
case ROLE_RESTRICTION_RS:
$agents_header = __('Current Restrictions', 'scoper');
break;
default:
return;
}
}
// disregard roles that don't apply to this scope
foreach ($role_defs_by_otype as $object_type => $role_defs) {
foreach ($role_defs as $role_handle => $role) {
if (!isset($role->valid_scopes[$scope])) {
unset($role_defs_by_otype[$object_type][$role_handle]);
}
}
}
// for object scope, assign "private post reader" role, but label it as "post reader" to limit confusion
$role_display_name = array();
foreach ($role_defs_by_otype as $role_defs) {
foreach (array_keys($role_defs) as $role_handle) {
$role_display_name[$role_handle] = $scoper->role_defs->get_display_name($role_handle, $scope . '_ui');
}
}
// display a separate role assignment list for each individual term / object
$last_id = -1;
$last_name = '';
$last_parent_id = -1;
$parent_id = 0;
$parents = array();
$depth = 0;
$_top_link = "<a{$ie_link_style} href='#scoper_top'>" . __('top', 'scoper') . '</a>';
$tr_display = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false ? 'block' : 'table-row';
$show_all_caption = __('show all', 'scoper');
echo "<ul class='{$ul_class}' style='padding-left:0.1em;'>";
if (empty($all_items)) {
$all_items = array();
}
if (!$single_item && is_user_administrator_rs() && 'nav_menu' != $src_or_tx_name) {
// TODO: action handler for new menu item storage
if (ROLE_ASSIGNMENT_RS == $mode) {
$root_caption = sprintf(__('DEFAULTS for new %s', 'scoper'), $otype_or_tx->labels->name);
} else {
$root_caption = sprintf(__('DEFAULTS for all %s', 'scoper'), $otype_or_tx->labels->name);
}
if (TERM_SCOPE_RS == $scope) {
$root_item = (object) array($col_id => 0, $col_name => $root_caption, $col_parent => 0);
array_unshift($all_items, $root_item);
//.........这里部分代码省略.........
示例11: get_all_groups
function get_all_groups($filtering = UNFILTERED_RS, $cols = COLS_ALL_RS, $args = array())
{
$defaults = array('include_norole_groups' => false, 'reqd_caps' => 'manage_groups', 'where' => '');
$args = array_merge($defaults, (array) $args);
extract($args);
if ($filtering && is_user_administrator_rs()) {
$filtering = 0;
}
if ($filtering) {
$cache_flag = 'usergroups';
global $current_rs_user;
$cache = $current_rs_user->cache_get($cache_flag);
} else {
$cache_flag = 'all_usergroups';
$cache_id = 'all';
$cache = wpp_cache_get($cache_id, $cache_flag);
}
$ckey = md5($cols . $reqd_caps);
if (!isset($cache[$ckey])) {
global $wpdb;
if ($filtering && !is_user_administrator_rs() && !cr_user_can($reqd_caps, 0, 0, array('skip_any_object_check' => true, 'skip_any_term_check' => true, 'skip_id_generation' => true))) {
$duration_clause = scoper_get_duration_clause();
global $scoper;
$role_handles = $scoper->role_defs->qualify_roles($reqd_caps);
$role_names = array();
foreach (array_keys($role_handles) as $role_handle) {
$role = scoper_explode_role_handle($role_handle);
$role_names[] = $role->role_name;
}
$role_clause = "AND uro.role_name IN ('" . implode("','", $role_names) . "')";
$join = "INNER JOIN {$wpdb->user2role2object_rs} AS uro" . " ON uro.obj_or_term_id = {$wpdb->groups_rs}.{$wpdb->groups_id_col}" . " AND uro.src_or_tx_name = 'group' AND uro.scope = 'object' {$role_clause} {$duration_clause}";
$_where = "WHERE uro.user_id = {$current_rs_user->ID}";
} else {
$join = '';
$_where = 'WHERE 1=1 ';
}
// append supplemental where clause, if any was passed in
$_where .= $where;
if (COL_ID_RS == $cols) {
$query = "SELECT DISTINCT {$wpdb->groups_id_col} FROM {$wpdb->groups_rs} {$join} {$_where}";
} else {
$query = "SELECT DISTINCT {$wpdb->groups_id_col} AS ID, {$wpdb->groups_name_col} AS display_name, {$wpdb->groups_descript_col} as descript, {$wpdb->groups_meta_id_col} as meta_id" . " FROM {$wpdb->groups_rs} {$join} {$_where} ORDER BY {$wpdb->groups_name_col}";
}
if (COL_ID_RS == $cols) {
$cache[$ckey] = scoper_get_col($query);
} else {
$cache[$ckey] = scoper_get_results($query);
}
}
if ($filtering) {
$current_rs_user->cache_set($cache, $cache_flag);
} else {
wpp_cache_set($cache_id, $cache, $cache_flag);
}
if (COLS_ALL_RS == $cols) {
// strip out anon metagroup if we're not using it (have to do this after cache storage / retrieval)
if (!defined('SCOPER_ANON_METAGROUP')) {
foreach (array_keys($cache[$ckey]) as $key) {
if ('wp_anon' == $cache[$ckey][$key]->meta_id) {
unset($cache[$ckey][$key]);
break;
}
}
}
// strip out groups that don't use roles, unless arg asked for them
if (!$include_norole_groups) {
foreach (array_keys($cache[$ckey]) as $key) {
if (strpos($cache[$ckey][$key]->meta_id, '_nr_')) {
unset($cache[$ckey][$key]);
}
}
}
}
if (!$cache[$ckey]) {
$cache[$ckey] = array();
}
return $cache[$ckey];
}
示例12: act_tweak_metaboxes
function act_tweak_metaboxes()
{
static $been_here;
if (isset($been_here)) {
return;
}
$been_here = true;
global $wp_meta_boxes;
if (empty($wp_meta_boxes)) {
return;
}
$object_type = cr_find_post_type();
if (empty($wp_meta_boxes[$object_type])) {
return;
}
$object_id = scoper_get_object_id();
$is_administrator = is_user_administrator_rs();
$can_admin_object = $is_administrator || $this->scoper_admin->user_can_admin_object('post', $object_type, $object_id);
if ($can_admin_object) {
$this->init_item_roles_ui();
$this->item_roles_ui->load_roles('post', $object_type, $object_id);
}
foreach ($wp_meta_boxes[$object_type] as $context => $priorities) {
foreach ($priorities as $priority => $boxes) {
foreach (array_keys($boxes) as $box_id) {
if ($role_handle = array_search($box_id, $this->meta_box_ids)) {
// eliminate metabox shells for roles which will be suppressed for this user
if (!$is_administrator && (!$can_admin_object || !$this->scoper_admin->user_can_admin_role($role_handle, $object_id, 'post', $object_type))) {
unset($wp_meta_boxes[$object_type][$context][$priority][$box_id]);
} elseif ($can_admin_object) {
if ($title_suffix = $this->item_roles_ui->get_rolecount_caption($role_handle)) {
if (!strpos($wp_meta_boxes[$object_type][$context][$priority][$box_id]['title'], $title_suffix)) {
$wp_meta_boxes[$object_type][$context][$priority][$box_id]['title'] .= $title_suffix;
}
}
}
}
}
}
}
}
示例13: scoper_mnt_save_object
//.........这里部分代码省略.........
if ('post' == $src_name) {
update_post_meta($object_id, '_scoper_custom', true);
} else {
$custom_role_objects[$object_id] = true;
update_option("scoper_custom_{$src_name}", $custom_role_objects);
}
}
}
// endif user-modified roles/restrictions weren't already saved
// apply default roles for new object
if ($is_new_object && !$roles_customized) {
// NOTE: this means we won't apply default roles if any roles have been manually assigned to the new object
scoper_inherit_parent_roles($object_id, OBJECT_SCOPE_RS, $src_name, 0, $object_type);
}
// Inherit parent roles / restrictions, but only if a new parent is set and roles haven't been manually edited for this object
if (isset($set_parent) && $set_parent != $last_parent && !$roles_customized) {
// clear previously propagated role assignments
if (!$is_new_object) {
$args = array('inherited_only' => true, 'clear_propagated' => true);
ScoperAdminLib::clear_restrictions(OBJECT_SCOPE_RS, $src_name, $object_id, $args);
ScoperAdminLib::clear_roles(OBJECT_SCOPE_RS, $src_name, $object_id, $args);
}
// apply propagating roles, restrictions from selected parent
if ($set_parent) {
scoper_inherit_parent_roles($object_id, OBJECT_SCOPE_RS, $src_name, $set_parent, $object_type);
scoper_inherit_parent_restrictions($object_id, OBJECT_SCOPE_RS, $src_name, $set_parent, $object_type);
}
}
// endif new parent selection (or new object)
// Roles/Restrictions were just edited manually, so store role settings (which may contain default roles even if no manual settings were made)
if ($new_role_settings && !empty($_POST['rs_object_roles']) && (empty($_POST['action']) || 'autosave' != $_POST['action']) && !defined('XMLRPC_REQUEST')) {
$role_assigner = init_role_assigner();
$require_blogwide_editor = scoper_get_option('role_admin_blogwide_editor_only');
if (('admin' != $require_blogwide_editor || is_user_administrator_rs()) && ('admin_content' != $require_blogwide_editor || is_content_administrator_rs())) {
if ($object_type && $scoper_admin->user_can_admin_object($src_name, $object_type, $object_id)) {
// store any object role (read/write/admin access group) selections
$role_bases = array();
if (GROUP_ROLES_RS) {
$role_bases[] = ROLE_BASIS_GROUPS;
}
if (USER_ROLES_RS) {
$role_bases[] = ROLE_BASIS_USER;
}
$set_roles = array_fill_keys($role_bases, array());
$set_restrictions = array();
$default_restrictions = $scoper->get_default_restrictions(OBJECT_SCOPE_RS);
foreach ($role_defs as $role_handle => $role_def) {
if (!isset($role_def->valid_scopes[OBJECT_SCOPE_RS])) {
continue;
}
$role_code = 'r' . array_search($role_handle, $role_handles);
// make sure the role assignment UI for this role was actually reviewed
if (!isset($_POST["last_objscope_{$role_code}"])) {
continue;
}
foreach ($role_bases as $role_basis) {
$id_prefix = $role_code . substr($role_basis, 0, 1);
$for_entity_agent_ids = isset($_POST[$id_prefix]) ? $_POST[$id_prefix] : array();
$for_children_agent_ids = isset($_POST["p_{$id_prefix}"]) ? $_POST["p_{$id_prefix}"] : array();
// NOTE: restrict_roles, assign_roles functions validate current user roles before modifying assignments
// handle csv-entered agent names
if (!empty($use_csv_entry[$role_basis])) {
$csv_id = "{$id_prefix}_csv";
if ($csv_for_item = ScoperAdminLib::agent_ids_from_csv($csv_id, $role_basis)) {
$for_entity_agent_ids = array_merge($for_entity_agent_ids, $csv_for_item);
}
示例14: scoper_admin_object_restrictions
//.........这里部分代码省略.........
$object_names = array();
$object_status = array();
$listed_objects = array();
$unlisted_objects = array();
$col_id = $src->cols->id;
$col_parent = isset($src->cols->parent) && !$ignore_hierarchy ? $src->cols->parent : '';
$object_ids = array();
if (isset($strict_objects['restrictions'])) {
foreach (array_keys($strict_objects['restrictions']) as $role_handle) {
$object_ids = $object_ids + array_keys($strict_objects['restrictions'][$role_handle]);
}
} elseif (isset($strict_objects['unrestrictions'])) {
foreach (array_keys($strict_objects['unrestrictions']) as $role_handle) {
$object_ids = $object_ids + array_keys($strict_objects['unrestrictions'][$role_handle]);
}
}
$object_ids = array_flip(array_unique($object_ids));
// Get the obj name, parent associated with each role (also sets $object_names, $unlisted objects)
$listed_objects = ScoperAdminBulkParent::get_objects_info($object_ids, $object_names, $object_status, $unlisted_objects, $src, $otype, $ignore_hierarchy);
if ($col_parent) {
if ($listed_objects) {
if ($unlisted_objects) {
// query for any parent objects which don't have their own role assignments
$listed_objects = ScoperAdminBulkParent::add_missing_parents($listed_objects, $unlisted_objects, $col_parent);
}
// convert keys from object ID to title+ID so we can alpha sort them
$listed_objects_alpha = array();
foreach (array_keys($listed_objects) as $id) {
$listed_objects_alpha[$listed_objects[$id]->{$src->cols->name} . chr(11) . $id] = $listed_objects[$id];
}
uksort($listed_objects_alpha, "strnatcasecmp");
$listed_objects = ScoperAdminBulkParent::order_by_hierarchy($listed_objects_alpha, $col_id, $col_parent);
}
// endif any listed objects
} else {
// endif doing object hierarchy
if ($listed_objects) {
// convert keys from object ID to title+ID so we can alpha sort them
$listed_objects_alpha = array();
foreach (array_keys($listed_objects) as $id) {
$listed_objects_alpha[$listed_objects[$id]->{$src->cols->name} . chr(11) . $id] = $listed_objects[$id];
}
uksort($listed_objects_alpha, "strnatcasecmp");
// convert to ordinal integer index
$listed_objects = array_combine(array_keys(array_fill(0, count($listed_objects_alpha), true)), $listed_objects_alpha);
}
}
if (!$is_administrator) {
$cu_admin_results = ScoperAdminBulk::filter_objects_listing(ROLE_RESTRICTION_RS, $strict_objects, $src, $object_type);
} else {
$cu_admin_results = '';
}
// no need to filter admins
// membuffer ids so user_can_admin_role() doesn't trigger a separate has_cap query for each one
if ($cu_admin_results) {
$scoper->listed_ids[$src_name] = $cu_admin_results;
}
global $scoper_admin;
$role_display = array();
$editable_roles = array();
$role_defs_by_otype = array();
$role_defs_by_otype[$object_type] = $scoper->role_defs->get_matching('rs', $src_name, $object_type);
foreach (array_keys($role_defs_by_otype[$object_type]) as $role_handle) {
$role_display[$role_handle] = $scoper->role_defs->get_abbrev($role_handle, OBJECT_UI_RS);
if ($cu_admin_results && !is_user_administrator_rs()) {
foreach (array_keys($cu_admin_results) as $object_id) {
if ($scoper_admin->user_can_admin_role($role_handle, $object_id, $src_name, $object_type)) {
$editable_roles[$object_id][$role_handle] = true;
}
}
}
}
$table_captions = ScoperAdminUI::restriction_captions(OBJECT_SCOPE_RS, '', $item_label_singular, $item_label);
$args = array('admin_items' => $cu_admin_results, 'editable_roles' => $editable_roles, 'default_hide_empty' => !empty($otype->admin_default_hide_empty), 'ul_class' => 'rs-objlist', 'object_names' => $object_names, 'object_status' => $object_status, 'table_captions' => $table_captions, 'ie_link_style' => '', 'err' => $err);
ScoperAdminBulk::item_tree(OBJECT_SCOPE_RS, ROLE_RESTRICTION_RS, $src, $otype, $listed_objects, '', $strict_objects, $role_defs_by_otype, $role_codes, $args);
//ScoperAdminBulk::item_tree( OBJECT_SCOPE_RS, ROLE_ASSIGNMENT_RS, $src, $otype, $all_objects, $object_roles, $strict_objects, $role_defs_by_otype, $role_codes, $args);
echo '<hr /><div style="background-color: white;"></div>';
echo '<div class="rs-objlistkey">';
$args = array('display_links' => true, 'display_restriction_key' => true);
ScoperAdminUI::role_owners_key($otype, $args);
echo '</div>';
echo '</form><br /><h4 style="margin-bottom:0.1em"><a name="scoper_notes"></a>' . __("Notes", 'scoper') . ':</h4><ul class="rs-notes">';
echo '<li>';
printf(__('To edit all roles for any %1$s, click on the %1$s name.', 'scoper'), $otype->labels->singular_name);
echo '</li>';
echo '<li>';
printf(__("To edit the %s via its default editor, click on the ID link.", 'scoper'), $otype->labels->singular_name);
echo '</li>';
if (!$is_administrator) {
echo '<li>';
printf(__('To enhance performance, the role editing checkboxes here may not include some roles which you can only edit due to your own %1$s-specific role. In such cases, click on the editing link to edit roles for the individual %1$s.', 'scoper'), $otype->labels->singular_name);
echo '</li>';
}
echo '</ul>';
echo '<a href="#scoper_top">' . __('top', 'scoper') . '</a>';
?>
</div>
<?php
}
示例15: update_user_groups_multi_status
function update_user_groups_multi_status($user_id, $stored_groups, $editable_group_ids)
{
global $current_rs_user;
$posted_groups = array();
$is_administrator = is_user_administrator_rs();
$can_manage = $is_administrator || current_user_can('manage_groups');
$can_moderate = $can_manage || current_user_can('recommend_group_membership');
if (!$can_moderate && !current_user_can('request_group_membership')) {
return;
}
if ($can_manage) {
$posted_groups['active'] = explode(',', trim($_POST['current_agents_rs_csv'], ''));
} else {
$stored_groups = array_diff_key($stored_groups, array('active' => true));
}
if ($can_moderate) {
$posted_groups['recommended'] = !empty($_POST['recommended_agents_rs_csv']) ? explode(',', trim($_POST['recommended_agents_rs_csv'], '')) : array();
$stored_groups['recommended'] = array_fill_keys($current_rs_user->get_groups_for_user($current_rs_user->ID, array('status' => 'recommended')), true);
$editable_group_ids['recommended'] = ScoperAdminLib::get_all_groups(FILTERED_RS, COL_ID_RS, array('reqd_caps' => 'recommend_group_membership'));
if (isset($editable_group_ids['active'])) {
$editable_group_ids['recommended'] = array_unique($editable_group_ids['recommended'] + $editable_group_ids['active']);
}
}
$stored_groups['requested'] = array_fill_keys($current_rs_user->get_groups_for_user($current_rs_user->ID, array('status' => 'requested')), true);
$editable_group_ids['requested'] = ScoperAdminLib::get_all_groups(FILTERED_RS, COL_ID_RS, array('reqd_caps' => 'request_group_membership'));
if (isset($editable_group_ids['recommended'])) {
$editable_group_ids['requested'] = array_unique($editable_group_ids['requested'] + $editable_group_ids['recommended']);
}
$posted_groups['requested'] = !empty($_POST['requested_agents_rs_csv']) ? explode(',', trim($_POST['requested_agents_rs_csv'], '')) : array();
$all_posted_groups = agp_array_flatten($posted_groups);
$all_stored_groups = array();
foreach (array_keys($stored_groups) as $status) {
$all_stored_groups = $all_stored_groups + $stored_groups[$status];
}
foreach ($stored_groups as $status => $stored) {
if (!$editable_group_ids[$status]) {
continue;
}
// remove group memberships which were not posted for any status, if logged user can edit the group
foreach (array_keys($stored) as $group_id) {
if (!in_array($group_id, $all_posted_groups)) {
if (in_array($group_id, $editable_group_ids[$status])) {
ScoperAdminLib::remove_group_user($group_id, $user_id);
}
}
}
}
foreach ($posted_groups as $status => $posted) {
if (!$editable_group_ids[$status]) {
continue;
}
// insert or update group memberships as specified, if logged user can edit the group
foreach ($posted as $group_id) {
if (in_array($group_id, $editable_group_ids[$status])) {
if (!in_array($group_id, $all_stored_groups)) {
ScoperAdminLib::add_group_user($group_id, $user_id, $status);
} elseif (!in_array($group_id, $stored_groups[$status])) {
ScoperAdminLib::update_group_user($group_id, $user_id, $status);
}
}
}
}
}