本文整理汇总了PHP中scoper_get_col函数的典型用法代码示例。如果您正苦于以下问题:PHP scoper_get_col函数的具体用法?PHP scoper_get_col怎么用?PHP scoper_get_col使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scoper_get_col函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ec_getDaysEvents
function ec_getDaysEvents($query)
{
if (strpos($query, 'eventscalendar_main')) {
static $busy;
// IMPORTANT: don't execute recursively on db calls below
if (empty($busy)) {
$busy = true;
global $wpdb;
static $post_id_in;
// local buffer of readable post IDs which are related to any event
if (!isset($post_id_in)) {
$qry = "SELECT postID FROM {$wpdb->prefix}eventscalendar_main";
$event_ids = scoper_get_col($qry);
$event_id_in = "'" . implode("','", $event_ids) . "'";
// now generate and execute a scoped query for readable/unpublished posts
$post_qry = "SELECT ID FROM {$wpdb->posts} WHERE 1=1 AND {$wpdb->posts}.ID IN ({$event_id_in})";
// custom arguments to force inclusion of unpublished posts (only relationship to an unreadable published/private posts can make an event unreadable)
$reqd_caps = array();
$reqd_caps['post'] = array('publish' => array('read'), 'private' => array('read_private_posts'), 'draft' => array('read'), 'pending' => array('read'), 'future' => array('read'));
$post_qry = apply_filters('objects_request_rs', $post_qry, 'post', 'post', array('skip_teaser' => true, 'force_reqd_caps' => $reqd_caps));
$post_ids = scoper_get_col($post_qry);
$post_id_in = "'" . implode("','", $post_ids) . "'";
}
$id_clause = "( `postID` IS NULL OR `postID` IN ( {$post_id_in} ) ) AND";
$table_name = $wpdb->prefix . 'eventscalendar_main';
$query = str_replace("SELECT * FROM `{$table_name}` WHERE ", "SELECT * FROM `{$table_name}` WHERE {$id_clause} ", $query);
$busy = false;
}
}
return $query;
}
示例2: scoper_requested_file_rule_expire
function scoper_requested_file_rule_expire()
{
if (scoper_get_option('file_filtering')) {
if ($key = scoper_get_option('file_filtering_regen_key')) {
if (!empty($_GET['key']) && $key == $_GET['key']) {
// user must store their own non-null key before this will work
global $wpdb;
if (IS_MU_RS) {
$blog_ids = scoper_get_col("SELECT blog_id FROM {$wpdb->blogs} ORDER BY blog_id");
$orig_blog_id = $GLOBALS['blog_id'];
foreach ($blog_ids as $id) {
switch_to_blog($id);
scoper_query("DELETE FROM {$wpdb->postmeta} WHERE meta_key = '_rs_file_key'");
}
} else {
scoper_query("DELETE FROM {$wpdb->postmeta} WHERE meta_key = '_rs_file_key'");
}
scoper_expire_file_rules();
if (IS_MU_RS) {
_e("File attachment access keys and rewrite rules will be regenerated for each site at next access.", 'scoper');
} else {
_e("File attachment access keys and rewrite rules were regenerated.", 'scoper');
}
} else {
_e('Invalid argument.', 'scoper');
}
} else {
_e('Please configure File Filtering options!', 'scoper');
}
} else {
_e('The function is disabled.', 'scoper');
}
exit(0);
}
示例3: rs_get_post_revisions
function rs_get_post_revisions($post_id, $status = 'inherit', $args = array())
{
global $wpdb;
$defaults = array('order' => 'DESC', 'orderby' => 'post_modified_gmt', 'use_memcache' => true, 'fields' => COLS_ALL_RS, 'return_flipped' => false, 'where' => '');
$args = wp_parse_args($args, $defaults);
extract($args);
if (COL_ID_RS == $fields) {
// performance opt for repeated calls by user_has_cap filter
if ($use_memcache) {
static $last_results;
if (!isset($last_results)) {
$last_results = array();
} elseif (isset($last_results[$post_id][$status])) {
return $last_results[$post_id][$status];
}
}
$revisions = scoper_get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'revision' AND post_parent = '{$post_id}' AND post_status = '{$status}' {$where}");
if ($return_flipped) {
$revisions = array_fill_keys($revisions, true);
}
if ($use_memcache) {
if (!isset($last_results[$post_id])) {
$last_results[$post_id] = array();
}
$last_results[$post_id][$status] = $revisions;
}
} else {
$order_clause = $order && $orderby ? "ORDER BY {$orderby} {$order}" : '';
$revisions = scoper_get_results("SELECT * FROM {$wpdb->posts} WHERE post_type = 'revision' AND post_parent = '{$post_id}' AND post_status = '{$status}' {$order_clause}");
}
return $revisions;
}
示例4: log_object_save
function log_object_save($src_name, $object_id, $is_new_object, $col_parent, $set_parent)
{
global $wpdb;
$is_new_object = true;
$qry = "SELECT assignment_id FROM {$wpdb->user2role2object_rs} WHERE scope = 'object' AND src_or_tx_name = '{$src_name}' AND obj_or_term_id = '{$object_id}'";
if ($assignment_ids = scoper_get_col($qry)) {
$is_new_object = false;
} else {
$qry = "SELECT requirement_id FROM {$wpdb->role_scope_rs} WHERE topic = 'object' AND src_or_tx_name = '{$src_name}' AND obj_or_term_id = '{$object_id}'";
if ($requirement_ids = scoper_get_col($qry)) {
$is_new_object = false;
}
}
if ($col_parent) {
if (!$is_new_object) {
$last_parents = get_option("scoper_last_parents_{$src_name}");
if (!is_array($last_parents)) {
$last_parents = array();
}
if (isset($last_parents[$object_id])) {
$last_parent = $last_parents[$object_id];
}
}
if (isset($set_parent) && $set_parent != $last_parent && ($set_parent || $last_parent)) {
$last_parents[$object_id] = $set_parent;
update_option("scoper_last_parents_{$src_name}", $last_parents);
}
}
return $is_new_object;
}
示例5: flt_sticky_posts
function flt_sticky_posts($post_ids)
{
if ($post_ids && !is_content_administrator_rs()) {
global $wpdb;
$post_ids = scoper_get_col(apply_filters('objects_request_rs', "SELECT ID FROM {$wpdb->posts} WHERE ID IN ('" . implode("','", $post_ids) . "')", 'post'));
}
return $post_ids;
}
示例6: get_groups_for_user
function get_groups_for_user($user_id, $args = array())
{
return array();
if (empty($args['no_cache'])) {
// use -1 here to ignore accidental storage of other groups for zero user_id
$cache = wpp_cache_get(-1, 'group_membership_for_user');
if (is_array($cache)) {
return $cache;
}
}
global $wpdb;
if (empty($wpdb->groups_rs)) {
return array();
}
// include WP metagroup for anonymous user
$user_groups = scoper_get_col("SELECT {$wpdb->groups_id_col} FROM {$wpdb->groups_rs} WHERE {$wpdb->groups_rs}.{$wpdb->groups_meta_id_col} = 'wp_anon'");
if ($user_groups && empty($args['no_cache'])) {
// users should always be in at least a metagroup. Problem with caching empty result on user creation beginning with WP 2.8
$user_groups = array_fill_keys($user_groups, 1);
wpp_cache_set(-1, $user_groups, 'group_membership_for_user');
}
return $user_groups;
}
示例7: filter_objects_listing
function filter_objects_listing($mode, &$role_settings, $src, $object_type)
{
global $wpdb;
$filter_args = array();
// only list role assignments which the logged-in user can administer
$filter_args['required_operation'] = OP_EDIT_RS;
// Possible TODO: re-implement OP_ADMIN distinction with admin-specific capabilities
/* global $scoper;
if ( cr_get_reqd_caps( $src->name, OP_ADMIN_RS, $object_type ) ) {
$filter_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));
}
$filter_args['force_reqd_caps'] = $reqd_caps;
}
*/
$qry = "SELECT {$src->table}.{$src->cols->id} FROM {$src->table} WHERE 1=1 AND {$src->cols->type} = '{$object_type}'";
//$filter_args['require_full_object_role'] = true;
$qry_flt = apply_filters('objects_request_rs', $qry, $src->name, $object_type, $filter_args);
if ($cu_admin_results = scoper_get_col($qry_flt)) {
$cu_admin_results = array_fill_keys($cu_admin_results, true);
}
if (ROLE_ASSIGNMENT_RS == $mode) {
foreach (array_keys($role_settings) as $role_basis) {
foreach (array_keys($role_settings[$role_basis]) as $obj_id) {
if (!isset($cu_admin_results[$obj_id])) {
unset($role_settings[$role_basis][$obj_id]);
}
}
}
} else {
$setting_types = array('restrictions', 'unrestrictions');
foreach ($setting_types as $setting_type) {
if (isset($role_settings[$setting_type])) {
foreach (array_keys($role_settings[$setting_type]) as $role_handle) {
foreach (array_keys($role_settings[$setting_type][$role_handle]) as $obj_id) {
if (!isset($cu_admin_results[$obj_id])) {
unset($role_settings[$setting_type][$role_handle][$obj_id]);
}
}
}
}
}
}
return $cu_admin_results;
}
示例8: groups_who_can
function groups_who_can($reqd_caps, $cols = COLS_ALL_RS, $object_src_name = '', $object_id = 0, $args = array())
{
global $wpdb;
$defaults = array('orderby' => '', 'disable_memcache' => false, 'force_refresh' => false);
$args = array_merge($defaults, (array) $args);
extract($args);
$cache_flag = "rs_groups_who_can";
$cache_id = md5(serialize($reqd_caps) . $cols . 'src' . $object_src_name . 'id' . $object_id . serialize($args));
if (!$force_refresh) {
$groups = wpp_cache_get($cache_id, $cache_flag);
if (is_array($groups)) {
return $groups;
}
}
if (!is_array($reqd_caps)) {
$reqd_caps = $reqd_caps ? array($reqd_caps) : array();
}
if (!$orderby && (COLS_ALL_RS == $cols || COLS_ID_DISPLAYNAME_RS == $cols)) {
$orderby = " ORDER BY display_name";
}
if (!is_array($args)) {
$args = array();
}
if (isset($args['ignore_group_roles'])) {
unset($args['ignore_group_roles']);
}
$args['ignore_user_roles'] = 1;
$args['querying_groups'] = 1;
$where = $this->flt_users_where('', $reqd_caps, $object_src_name, $object_id, $args);
if (COL_ID_RS == $cols) {
$qry = "SELECT DISTINCT group_id as ID FROM {$wpdb->user2role2object_rs} AS gro WHERE 1=1 {$where} AND gro.group_id > 0 {$orderby}";
$groups = scoper_get_col($qry);
} else {
$grp = $wpdb->groups_rs;
$qry = "SELECT DISTINCT {$grp}.{$wpdb->groups_id_col} AS ID, {$grp}.{$wpdb->groups_name_col} AS display_name, {$grp}.{$wpdb->groups_descript_col} as descript FROM {$grp}" . " INNER JOIN {$wpdb->user2group_rs} as u2g ON u2g.{$wpdb->user2group_gid_col} = {$grp}.{$wpdb->groups_id_col}" . " INNER JOIN {$wpdb->user2role2object_rs} AS gro ON {$grp}.{$wpdb->groups_id_col} = gro.group_id WHERE 1=1 {$where} {$orderby}";
$groups = scoper_get_results($qry);
}
wpp_cache_set($cache_id, $groups, $cache_flag);
return $groups;
}
示例9: scoper_limit_subscribe2_autosub
function scoper_limit_subscribe2_autosub($query)
{
global $wpdb;
if ("SELECT DISTINCT user_id FROM {$wpdb->usermeta} WHERE {$wpdb->usermeta}.meta_key='s2_autosub' AND {$wpdb->usermeta}.meta_value='yes'" == $query) {
global $scoper, $subscribe2_category_rs;
//rs_errlog("subscribe2 cat creation: $subscribe2_category_rs");
$post_roles = $scoper->role_defs->qualify_roles('read', 'rs', 'post');
// WP roles containing the 'activate plugins' capability are always honored regardless of object or term restritions
$admin_roles_wp = array();
global $wp_roles;
if (isset($wp_roles->roles)) {
$admin_cap_name = defined('SCOPER_CONTENT_ADMIN_CAP') ? constant('SCOPER_CONTENT_ADMIN_CAP') : 'activate_plugins';
foreach (array_keys($wp_roles->roles) as $wp_role_name) {
if (!empty($wp_roles->roles[$wp_role_name]['capabilities'])) {
if (array_intersect_key($wp_roles->roles[$wp_role_name]['capabilities'], array($admin_cap_name => 1))) {
$admin_roles_wp = array_merge($admin_roles_wp, array($wp_role_name => 1));
}
}
}
}
if ($admin_roles_wp) {
$admin_roles_wp = scoper_role_names_to_handles(array_keys($admin_roles_wp), 'wp', true);
}
//arg: return as array keys
$args = array('id' => $subscribe2_category_rs);
$restrictions = $scoper->get_restrictions(TERM_SCOPE_RS, 'category', $args);
$restricted_roles = array();
if (!empty($restrictions['unrestrictions'])) {
if ($restrictions['unrestrictions'] = array_intersect_key($restrictions['unrestrictions'], $post_roles)) {
foreach ($restrictions['unrestrictions'] as $role_handle => $entries) {
if (!isset($entries[$subscribe2_category_rs]) || 'children' == $entries[$subscribe2_category_rs]) {
$restricted_roles[$role_handle] = true;
}
}
}
}
if (!empty($restrictions['restrictions'])) {
if ($restrictions['restrictions'] = array_intersect_key($restrictions['restrictions'], $post_roles)) {
foreach ($restrictions['restrictions'] as $role_handle => $entries) {
if (isset($entries[$subscribe2_category_rs]) && 'children' != $entries[$subscribe2_category_rs]) {
$restricted_roles[$role_handle] = true;
}
}
}
}
$unrestricted_roles = array_diff_key($post_roles, $restricted_roles);
// for our purposes, a role is only restricted if all its contained qualifying roles are also restricted
if ($restricted_roles) {
foreach (array_keys($restricted_roles) as $role_handle) {
if ($contained_roles = $scoper->role_defs->get_contained_roles($role_handle, false, 'rs')) {
if ($contained_roles = array_intersect_key($contained_roles, $unrestricted_roles)) {
unset($restricted_roles[$role_handle]);
}
}
}
$unrestricted_roles = array_diff_key($post_roles, $restricted_roles);
}
// account for WP blog roles
$unrestricted_roles_wp = array();
$restricted_roles_wp = array();
if ($post_roles_wp = $scoper->role_defs->qualify_roles('read', 'wp', 'post')) {
foreach (array_keys($post_roles_wp) as $wp_role) {
if ($contains_rs_roles = $scoper->role_defs->get_contained_roles($wp_role, false, 'rs')) {
if ($contains_rs_roles = array_intersect_key($contains_rs_roles, $unrestricted_roles)) {
$unrestricted_roles_wp = array_merge($unrestricted_roles_wp, array($wp_role => true));
}
}
}
$restricted_roles_wp = array_diff_key($post_roles_wp, $unrestricted_roles_wp);
}
$unrestricted_roles_wp = array_merge($unrestricted_roles_wp, $admin_roles_wp);
$role_in_wp = implode("', '", scoper_role_handles_to_names(array_keys($unrestricted_roles_wp)));
/*
dump($post_roles);
dump($restricted_roles);
dump($restricted_roles_wp);
dump($unrestricted_roles);
dump($unrestricted_roles_wp);
*/
// account for blog roles, where allowed
if ($unrestricted_roles) {
$wp_role_clause = !empty($role_in_wp) ? "OR ( role_type = 'wp' AND scope = 'blog' AND role_name IN ('{$role_in_wp}') )" : '';
$role_in = implode("', '", scoper_role_handles_to_names(array_keys($unrestricted_roles)));
$qry = "SELECT DISTINCT user_id FROM {$wpdb->user2role2object_rs}" . " WHERE user_id > 0 AND (" . " ( role_type = 'rs' AND scope = 'blog' AND role_name IN ('{$role_in}') ) {$wp_role_clause} )";
$users = scoper_get_col($qry);
$qry = "SELECT DISTINCT group_id FROM {$wpdb->user2role2object_rs}" . " WHERE group_id > 0 AND (" . " ( role_type = 'rs' AND scope = 'blog' AND role_name IN ('{$role_in}') ) {$wp_role_clause} )";
if ($groups = scoper_get_col($qry)) {
foreach ($groups as $group_id) {
if ($group_members = ScoperAdminLib::get_group_members($group_id, $cols, true)) {
$users = array_merge($users, $group_members);
}
}
$users = array_unique($users);
}
} else {
$users = array();
}
// account for category roles
$role_in = implode("', '", scoper_role_handles_to_names(array_keys($post_roles)));
$qry = "SELECT DISTINCT user_id FROM {$wpdb->user2role2object_rs}" . " WHERE user_id > 0 AND role_type = 'rs' AND scope = 'term' AND role_name IN ('{$role_in}')" . " AND assign_for IN ('entity', 'both')" . " AND src_or_tx_name = 'category' AND obj_or_term_id = '{$subscribe2_category_rs}'";
//.........这里部分代码省略.........
示例10: get_applied_object_roles
function get_applied_object_roles($user = '')
{
if (is_object($user)) {
$cache_flag = 'rs_object-roles';
// v 1.1: changed cache key from "object_roles" to "object-roles" to match new key format for blog, term roles
$cache = $user->cache_get($cache_flag);
$limit = '';
$u_g_clause = $user->get_user_clause('');
} else {
$cache_flag = 'rs_applied_object-roles';
// v 1.1: changed cache key from "object_roles" to "object-roles" to match new key format for blog, term roles
$cache_id = 'all';
$cache = wpp_cache_get($cache_id, $cache_flag);
$u_g_clause = '';
}
if (is_array($cache)) {
return $cache;
}
$role_handles = array();
global $wpdb;
// object roles support date limits, but content date limits (would be redundant and a needless performance hit)
$duration_clause = scoper_get_duration_clause('', $wpdb->user2role2object_rs);
if ($role_names = scoper_get_col("SELECT DISTINCT role_name FROM {$wpdb->user2role2object_rs} WHERE role_type='rs' AND scope='object' {$duration_clause} {$u_g_clause}")) {
$role_handles = scoper_role_names_to_handles($role_names, 'rs', true);
}
//arg: return role keys as array key
if (is_object($user)) {
$user->cache_force_set($role_handles, $cache_flag);
} else {
wpp_cache_force_set($cache_id, $role_handles, $cache_flag);
}
return $role_handles;
}
示例11: update_rs_role_defs
function update_rs_role_defs($sitewide = false, $customize_defaults = false)
{
$default_prefix = $customize_defaults ? 'default_' : '';
$default_role_caps = apply_filters('define_role_caps_rs', cr_role_caps());
$cap_defs = new CR_Capabilities();
$cap_defs = apply_filters('define_capabilities_rs', $cap_defs);
$cap_defs->add_member_objects(cr_cap_defs());
global $scoper, $scoper_role_types;
$role_defs = new CR_Roles();
$role_defs->add_member_objects(cr_role_defs());
$role_defs = apply_filters('define_roles_rs', $role_defs);
$reviewed_roles = explode(',', $_POST['reviewed_roles']);
$disable_caps = array();
$add_caps = array();
foreach ($default_role_caps as $role_handle => $default_caps) {
if (!in_array($role_handle, $reviewed_roles)) {
continue;
}
if ($role_defs->member_property($role_handle, 'no_custom_caps') || $role_defs->member_property($role_handle, 'anon_user_blogrole')) {
continue;
}
$posted_set_caps = empty($_POST["{$role_handle}_caps"]) ? array() : $_POST["{$role_handle}_caps"];
// html IDs have any spaces stripped out of cap names. Replace them for processing.
$set_caps = array();
foreach ($posted_set_caps as $cap_name) {
if (strpos($cap_name, ' ')) {
$set_caps[] = str_replace('_', ' ', $cap_name);
} else {
$set_caps[] = $cap_name;
}
}
// deal with caps which are locked into role, therefore displayed as a disabled checkbox and not included in $_POST
foreach (array_keys($default_caps) as $cap_name) {
if (!in_array($cap_name, $set_caps) && $cap_defs->member_property($cap_name, 'no_custom_remove')) {
$set_caps[] = $cap_name;
}
}
$disable_caps[$role_handle] = array_fill_keys(array_diff(array_keys($default_caps), $set_caps), true);
$add_caps[$role_handle] = array_fill_keys(array_diff($set_caps, array_keys($default_caps)), true);
}
scoper_update_option($default_prefix . 'disabled_role_caps', $disable_caps, $sitewide);
scoper_update_option($default_prefix . 'user_role_caps', $add_caps, $sitewide);
scoper_refresh_options();
$scoper->load_definition('cap_defs');
global $wp_roles;
// synchronize WP roles as requested
if (!empty($_POST['sync_wp_roles'])) {
foreach ($_POST['sync_wp_roles'] as $sync_request) {
$scoper->log_cap_usage($scoper->role_defs, $scoper->cap_defs);
$sync_handles = explode(':', $sync_request);
$rs_role_handle = $sync_handles[0];
$wp_role_handle = $sync_handles[1];
$wp_role_name = str_replace('wp_', '', $wp_role_handle);
// only remove caps which are defined for this RS role's data source and object type
$role_attributes = $scoper->role_defs->get_role_attributes($rs_role_handle);
$otype_caps = $scoper->cap_defs->get_matching($role_attributes->src_name, $role_attributes->object_type, '', STATUS_ANY_RS);
// make the roledef change for all blogs if RS role def is sitewide
if (IS_MU_RS && $sitewide) {
global $wpdb, $blog_id;
$blog_ids = scoper_get_col("SELECT blog_id FROM {$wpdb->blogs}");
$orig_blog_id = $blog_id;
} else {
$blog_ids = array('');
}
foreach ($blog_ids as $id) {
if (count($blog_ids) > 1) {
switch_to_blog($id);
}
if (!isset($wp_roles->role_objects[$wp_role_name])) {
continue;
}
if ($wp_missing_caps = array_diff_key($scoper->role_defs->role_caps[$rs_role_handle], $wp_roles->role_objects[$wp_role_name]->capabilities)) {
foreach (array_keys($wp_missing_caps) as $cap_name) {
$wp_roles->add_cap($wp_role_name, $cap_name);
}
}
$wp_defined_caps = array_intersect_key($wp_roles->role_objects[$wp_role_name]->capabilities, $otype_caps);
if ($wp_extra_caps = array_diff_key($wp_defined_caps, $scoper->role_defs->role_caps[$rs_role_handle])) {
foreach (array_keys($wp_extra_caps) as $cap_name) {
$wp_roles->remove_cap($wp_role_name, $cap_name);
}
}
}
if (count($blog_ids) > 1) {
switch_to_blog($orig_blog_id);
}
$wp_roles = new WP_Roles();
}
}
$scoper->role_defs->locked = false;
$scoper->log_wp_roles($scoper->role_defs);
$scoper->role_defs->lock();
}
示例12: flt_nav_menu_items
function flt_nav_menu_items($items, $menu_name, $args)
{
global $wpdb;
$item_types = array();
foreach ($items as $key => $item) {
if (!isset($item_types[$item->type])) {
$item_types["{$item->type}"] = array();
}
if (!isset($item_types[$item->type][$item->object])) {
$item_types[$item->type][$item->object] = array($key => $item->object_id);
} else {
$item_types[$item->type][$item->object][$key] = $item->object_id;
}
}
$teaser_enabled = scoper_get_otype_option('do_teaser', 'post');
// remove unreadable terms
if (isset($item_types['taxonomy'])) {
foreach ($item_types['taxonomy'] as $taxonomy => $item_ids) {
if ($teaser_enabled) {
if ($taxonomy_obj = get_taxonomy($taxonomy)) {
foreach ($taxonomy_obj->object_type as $post_type) {
// don't remove a term if it is associated with a post type that's being teased
if (scoper_get_otype_option('use_teaser', 'post', $post_type)) {
continue 2;
}
}
}
}
/*
$query_base = "SELECT t.term_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE 1=1 AND tt.taxonomy = '$taxonomy'";
$query = apply_filters( 'terms_request_rs', $query_base, $taxonomy ); //, array( 'skip_teaser' => true ) );
$okay_ids = scoper_get_col($query);
*/
$hide_empty = isset($args['hide_empty']) ? $args['hide_empty'] : 0;
$okay_ids = get_terms($taxonomy, "fields=ids&hierarchical=0&hide_empty={$hide_empty}");
if ($remove_ids = array_diff($item_ids, $okay_ids)) {
$items = array_diff_key($items, $remove_ids);
}
}
}
// remove unreadable posts
if (isset($item_types['post_type'])) {
foreach ($item_types['post_type'] as $post_type => $item_ids) {
$where = apply_filters('objects_where_rs', '', 'post', $post_type, array('skip_teaser' => true));
$okay_ids = scoper_get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = '{$post_type}' {$where} AND ID IN ('" . implode("','", $item_ids) . "')");
if ($remove_ids = array_diff($item_ids, $okay_ids)) {
if ($teaser_enabled && scoper_get_otype_option('use_teaser', 'post', $post_type)) {
require_once dirname(__FILE__) . '/teaser_rs.php';
$teaser_prepend = ScoperTeaser::get_teaser_text('prepend', 'name', 'post', $post_type);
$teaser_append = ScoperTeaser::get_teaser_text('append', 'name', 'post', $post_type);
foreach (array_keys($remove_ids) as $key) {
$items[$key]->title = $teaser_prepend . $items[$key]->title . $teaser_append;
}
} else {
$items = array_diff_key($items, $remove_ids);
}
}
}
}
return $items;
}
示例13: item_deletion_aftermath
function item_deletion_aftermath($scope, $src_or_tx_name, $obj_or_term_id)
{
global $wpdb;
// delete role assignments for deleted term
if ($ass_ids = scoper_get_col("SELECT assignment_id FROM {$wpdb->user2role2object_rs} WHERE src_or_tx_name = '{$src_or_tx_name}' AND scope = '{$scope}' AND obj_or_term_id = '{$obj_or_term_id}'")) {
$id_in = "'" . implode("', '", $ass_ids) . "'";
scoper_query("DELETE FROM {$wpdb->user2role2object_rs} WHERE assignment_id IN ({$id_in})");
// Propagated roles will be converted to direct-assigned roles if the original progenetor goes away. Removal of a "link" in the parent/child propagation chain has no effect.
scoper_query("UPDATE {$wpdb->user2role2object_rs} SET inherited_from = '0' WHERE inherited_from IN ({$id_in})");
}
if ($req_ids = scoper_get_col("SELECT requirement_id FROM {$wpdb->role_scope_rs} WHERE topic = '{$scope}' AND src_or_tx_name = '{$src_or_tx_name}' AND obj_or_term_id = '{$obj_or_term_id}'")) {
$id_in = "'" . implode("', '", $req_ids) . "'";
scoper_query("DELETE FROM {$wpdb->role_scope_rs} WHERE requirement_id IN ({$id_in})");
// Propagated requirements will be converted to direct-assigned roles if the original progenetor goes away. Removal of a "link" in the parent/child propagation chain has no effect.
scoper_query("UPDATE {$wpdb->role_scope_rs} SET inherited_from = '0' WHERE inherited_from IN ({$id_in})");
}
}
示例14: clear_all_file_rules
function clear_all_file_rules()
{
global $wpdb, $blog_id;
$blog_ids = scoper_get_col("SELECT blog_id FROM {$wpdb->blogs} ORDER BY blog_id");
$orig_blog_id = $blog_id;
foreach ($blog_ids as $id) {
switch_to_blog($id);
require_once dirname(__FILE__) . '/uploads_rs.php';
$uploads = scoper_get_upload_info();
$htaccess_path = trailingslashit($uploads['basedir']) . '.htaccess';
if (file_exists($htaccess_path)) {
ScoperRewrite::insert_with_markers($htaccess_path, 'Role Scoper', '');
}
}
switch_to_blog($orig_blog_id);
}
示例15: objects_where_scope_clauses
//.........这里部分代码省略.........
//$where[$date_key][$objscope_clause][TERM_SCOPE_RS] = agp_implode(' ) OR ( ', $taxonomy_clauses, ' ( ', ' ) ');
// strict taxonomy clauses (if any are present, they must all be satisfied)
if (!empty($taxonomy_clauses[true])) {
$where[$date_key][$objscope_clause][TERM_SCOPE_RS] = agp_implode(' ) AND ( ', $taxonomy_clauses[true], ' ( ', ' ) ');
// non-strict taxonomy clauses
} elseif (!empty($taxonomy_clauses[false])) {
$where[$date_key][$objscope_clause][TERM_SCOPE_RS] = agp_implode(' ) OR ( ', $taxonomy_clauses[false], ' ( ', ' ) ');
} else {
$where[$date_key][$objscope_clause][TERM_SCOPE_RS] = '1=2';
}
// all taxonomy clauses concat: ( [strict taxonomy clause 1] [AND] [strict taxonomy clause 2]... ) [OR] [taxonomy 3 clauses] [OR] ...
//$where[$date_key][$objscope_clause][TERM_SCOPE_RS] = agp_implode(' ) OR ( ', $taxonomy_clauses, ' ( ', ' ) ');
}
break;
case OBJECT_SCOPE_RS:
// should only exist with nullstring objscope_clause
if ($user_qualifies_for_obj_roles) {
global $wpdb;
$u_g_clause = $user->get_user_clause('uro');
foreach (array_keys($scope_criteria[OBJECT_SCOPE_RS]) as $role_type) {
//should be only one
if ($scope_criteria[OBJECT_SCOPE_RS][$role_type]) {
ksort($scope_criteria[OBJECT_SCOPE_RS][$role_type]);
}
// sort array for efficient membuffering of query results
// Combine all qualifying (and applied) object roles into a single OR clause
$role_in = "'" . implode("', '", array_keys($scope_criteria[OBJECT_SCOPE_RS][$role_type])) . "'";
static $cache_obj_ids = array();
if ('post.php' == $GLOBALS['pagenow'] && !empty($_REQUEST['action']) || did_action('save_post') || !empty($_GET['doaction'])) {
$force_refresh = true;
}
$objrole_subselect = "SELECT DISTINCT uro.obj_or_term_id FROM {$wpdb->user2role2object_rs} AS uro WHERE uro.role_type = '{$role_spec->role_type}' AND uro.scope = 'object' AND uro.assign_for IN ('entity', 'both') AND uro.role_name IN ({$role_in}) AND uro.src_or_tx_name = '{$src_name}' {$object_roles_duration_clause} {$u_g_clause} ";
if (!isset($cache_obj_ids[$objrole_subselect]) || !empty($force_refresh)) {
$cache_obj_ids[$objrole_subselect] = scoper_get_col($objrole_subselect);
}
if ($cache_obj_ids[$objrole_subselect]) {
$where[$date_key][$objscope_clause][OBJECT_SCOPE_RS] = "{$src_table}.{$src->cols->id} IN ( '" . implode("','", $cache_obj_ids[$objrole_subselect]) . "' )";
} else {
$where[$date_key][$objscope_clause][OBJECT_SCOPE_RS] = "1=2";
}
if (defined('RVY_VERSION') && $objrole_revisions_clause) {
$where[$date_key][$objscope_clause][OBJECT_SCOPE_RS] = "( {$where[$date_key][$objscope_clause]['object']} OR ( {$src_table}.{$src->cols->type} = 'revision' AND {$src_table}.{$src->cols->parent} IN ( '" . implode("','", $cache_obj_ids[$objrole_subselect]) . "' ) ) )";
}
}
}
break;
}
// end scope switch
}
// end foreach scope
/*
// --- optional hack to require read_private cap via blog role AND object role
if ( ! empty($require_blog_and_obj_role) ) {
if ( ! isset($where[$date_key][''][BLOG_SCOPE_RS]) )
$where[$date_key][''][BLOG_SCOPE_RS] = '1=2';
if ( ! isset($where[$date_key][''][TERM_SCOPE_RS]) )
$where[$date_key][''][TERM_SCOPE_RS] = '1=2';
if ( ! isset($where[$date_key][''][OBJECT_SCOPE_RS]) )
$where[$date_key][''][OBJECT_SCOPE_RS] = '1=2';
$where[$date_key][''] = "( ( {$where[$date_key]['']['blog']} ) OR ( {$where[$date_key]['']['term']} ) ) AND ( {$where[$date_key]['']['object']} )";
}
else
// --- end hack