当前位置: 首页>>代码示例>>PHP>>正文


PHP scoper_get_results函数代码示例

本文整理汇总了PHP中scoper_get_results函数的典型用法代码示例。如果您正苦于以下问题:PHP scoper_get_results函数的具体用法?PHP scoper_get_results怎么用?PHP scoper_get_results使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了scoper_get_results函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_page_ancestors

 function get_page_ancestors()
 {
     $ancestors = get_option("scoper_page_ancestors");
     if (is_array($ancestors)) {
         return $ancestors;
     }
     $ancestors = array();
     global $wpdb;
     if (awp_ver('3.0')) {
         $post_types = get_post_types(array('hierarchical' => true, 'public' => true));
         $where = "WHERE post_type IN ('" . implode("','", $post_types) . "') AND post_status != 'auto-draft'";
     } else {
         $where = "WHERE post_type != 'revision' AND post_type != 'post' AND post_status != 'auto-draft'";
     }
     if ($pages = scoper_get_results("SELECT ID, post_parent FROM {$wpdb->posts} {$where}")) {
         $parents = array();
         foreach ($pages as $page) {
             if ($page->post_parent) {
                 $parents[$page->ID] = $page->post_parent;
             }
         }
         foreach ($pages as $page) {
             $ancestors[$page->ID] = ScoperAncestry::_walk_ancestors($page->ID, array(), $parents);
             if (empty($ancestors[$page->ID])) {
                 unset($ancestors[$page->ID]);
             }
         }
         update_option("scoper_page_ancestors", $ancestors);
     }
     return $ancestors;
 }
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:31,代码来源:ancestry_lib_rs.php

示例2: 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;
}
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:32,代码来源:revisions_lib_rs.php

示例3: get_user_level

 function get_user_level($user_ids)
 {
     static $user_levels;
     $return_array = is_array($user_ids);
     // if an array was passed in, return results as an array
     if (!is_array($user_ids)) {
         if (IS_MU_RS && function_exists('is_super_admin') && is_super_admin()) {
             // mu site administrator may not be a user for the current blog
             return 10;
         }
         $orig_user_id = $user_ids;
         $user_ids = (array) $user_ids;
     }
     if (!isset($user_levels)) {
         $user_levels = array();
     }
     if (array_diff($user_ids, array_keys($user_levels))) {
         // one or more of the users were not already logged
         $role_levels = ScoperUserEdit::get_role_levels();
         // local buffer for performance
         // If the listed user ids were logged following a search operation, save extra DB queries by getting the levels of all those users now
         global $wp_user_search;
         if (!empty($wp_user_search->results)) {
             $query_users = $wp_user_search->results;
             $query_users = array_unique(array_merge($query_users, $user_ids));
         } else {
             $query_users = $user_ids;
         }
         // get the WP roles for user
         global $wpdb;
         $results = scoper_get_results("SELECT user_id, role_name FROM {$wpdb->user2role2object_rs} WHERE scope = 'blog' AND role_type = 'wp' AND user_id IN ('" . implode("','", array_map('intval', $query_users)) . "')");
         //echo("SELECT user_id, role_name FROM $wpdb->user2role2object_rs WHERE scope = 'blog' AND role_type = 'wp' AND user_id IN ('" . implode( "','", $query_users ) . "')");
         // credit each user for the highest role level they have
         foreach ($results as $row) {
             if (!isset($role_levels[$row->role_name])) {
                 continue;
             }
             if (!isset($user_levels[$row->user_id]) || $role_levels[$row->role_name] > $user_levels[$row->user_id]) {
                 $user_levels[$row->user_id] = $role_levels[$row->role_name];
             }
         }
         // note any "No Role" users
         if ($no_role_users = array_diff($query_users, array_keys($user_levels))) {
             $user_levels = $user_levels + array_fill_keys($no_role_users, 0);
         }
     }
     if ($return_array) {
         $return = array_intersect_key($user_levels, array_fill_keys($user_ids, true));
     } else {
         $return = isset($user_levels[$orig_user_id]) ? $user_levels[$orig_user_id] : 0;
     }
     return $return;
 }
开发者ID:btj,项目名称:cscircles-wp-content,代码行数:53,代码来源:user_lib_rs.php

示例4: scoper_apply_custom_default_options

function scoper_apply_custom_default_options($options_var)
{
    global $wpdb, $scoper_options_sitewide;
    if ($results = scoper_get_results("SELECT meta_key, meta_value FROM {$wpdb->sitemeta} WHERE site_id = '{$wpdb->siteid}' AND meta_key LIKE 'scoper_default_%'")) {
        foreach ($results as $row) {
            $option_basename = str_replace('scoper_default_', '', $row->meta_key);
            if (!empty($scoper_options_sitewide[$option_basename])) {
                continue;
            }
            // custom defaults are only for blog-specific options
            if (isset($GLOBALS[$options_var][$option_basename])) {
                $GLOBALS[$options_var][$option_basename] = maybe_unserialize($row->meta_value);
            }
        }
    }
}
开发者ID:par-orillonsoft,项目名称:creationOfSociety,代码行数:16,代码来源:mu-init_rs.php

示例5: scoper_fix_page_parent_recursion

function scoper_fix_page_parent_recursion()
{
    global $wpdb;
    $arr_parent = array();
    $arr_children = array();
    if ($results = scoper_get_results("SELECT ID, post_parent FROM {$wpdb->posts} WHERE post_type = 'page'")) {
        foreach ($results as $row) {
            $arr_parent[$row->ID] = $row->post_parent;
            if (!isset($arr_children[$row->post_parent])) {
                $arr_children[$row->post_parent] = array();
            }
            $arr_children[$row->post_parent][] = $row->ID;
        }
        // if a page's parent is also one of its children, set parent to Main
        foreach ($arr_parent as $page_id => $parent_id) {
            if (isset($arr_children[$page_id]) && in_array($parent_id, $arr_children[$page_id])) {
                scoper_query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_parent = '0' WHERE ID = %d", $page_id));
            }
        }
    }
}
开发者ID:btj,项目名称:cscircles-wp-content,代码行数:21,代码来源:update-legacy_rs.php

示例6: get_assigned_roles

 function get_assigned_roles($scope, $role_basis, $src_or_tx_name, $args = array())
 {
     global $wpdb;
     $defaults = array('id' => false, 'ug_id' => 0, 'join' => '', 'role_handles' => '');
     $args = array_merge($defaults, (array) $args);
     extract($args);
     $id = is_string($id) ? (int) $id : $id;
     $ug_id = is_string($ug_id) ? (int) $ug_id : $ug_id;
     if (BLOG_SCOPE_RS == $scope) {
         return ScoperRoleAssignments::get_assigned_blog_roles($role_basis);
     }
     $roles = array();
     switch ($role_basis) {
         case ROLE_BASIS_USER:
             $col_ug_id = 'user_id';
             $ug_clause = $ug_id ? " AND user_id = '{$ug_id}'" : 'AND user_id > 0';
             break;
         case ROLE_BASIS_GROUPS:
             $col_ug_id = 'group_id';
             $ug_clause = $ug_id ? " AND group_id = '{$ug_id}'" : 'AND group_id > 0';
             break;
     }
     $id_clause = false === $id ? '' : "AND obj_or_term_id = '{$id}'";
     if ($role_handles) {
         if (!is_array($role_handles)) {
             $role_handles = (array) $role_handles;
         }
         $role_clause = $role_handles ? "AND role_name IN ('" . implode("', '", scoper_role_handles_to_names($role_handles)) . "')" : '';
     } else {
         $role_clause = '';
     }
     $qry = "SELECT {$col_ug_id}, obj_or_term_id, role_name, assign_for, assignment_id, inherited_from, date_limited, start_date_gmt, end_date_gmt, content_date_limited, content_min_date_gmt, content_max_date_gmt FROM {$wpdb->user2role2object_rs} AS uro " . "{$join} WHERE role_type = 'rs' {$role_clause} AND scope = %s AND src_or_tx_name = %s {$id_clause} {$ug_clause}";
     $results = scoper_get_results($wpdb->prepare($qry, $scope, $src_or_tx_name));
     foreach ($results as $role) {
         $role_handle = 'rs_' . $role->role_name;
         $roles[$role->obj_or_term_id][$role_handle][$role->{$col_ug_id}] = (array) $role;
     }
     return $roles;
 }
开发者ID:btj,项目名称:cscircles-wp-content,代码行数:39,代码来源:role_assignment_lib_rs.php

示例7: 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;
 }
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:40,代码来源:users-interceptor_rs.php

示例8: scoper_attach_linked_uploads

function scoper_attach_linked_uploads($echo = false)
{
    global $wpdb;
    require_once SCOPER_ABSPATH . '/uploads_rs.php';
    if (MULTISITE) {
        global $wpdb, $blog_id;
        $blog_ids = scoper_get_col("SELECT blog_id FROM {$wpdb->blogs} ORDER BY blog_id");
        $orig_blog_id = $blog_id;
    } else {
        $blog_ids = array('1');
    }
    foreach ($blog_ids as $id) {
        if (count($blog_ids) > 1) {
            switch_to_blog($id);
            _e("<br /><strong>site {$id} :</strong><br />");
        }
        $uploads = scoper_get_upload_info();
        $site_url = untrailingslashit(get_option('siteurl'));
        if (false === strpos($uploads['baseurl'], $site_url)) {
            if ($echo) {
                _e('<strong>Note</strong>: Direct access to uploaded file attachments cannot be filtered because your WP_CONTENT_DIR is not in the WordPress branch.', 'scoper');
                echo '<br /><br />';
                _e('The operation was terminated due to an invalid configuration.', 'scoper');
            }
            return false;
        }
        $post_types = array_diff(get_post_types(array('public' => true)), array('attachment'));
        $post_type_in = "'" . implode("','", $post_types) . "'";
        if ($post_ids = scoper_get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type IN ({$post_type_in}) ORDER BY post_type, post_title")) {
            $stored_attachments = array();
            if ($results = scoper_get_results("SELECT post_parent, guid FROM {$wpdb->posts} WHERE post_type = 'attachment'")) {
                foreach ($results as $row) {
                    if (!isset($stored_attachments[$row->post_parent])) {
                        $stored_attachments[$row->post_parent] = array();
                    }
                    $stored_attachments[$row->post_parent][$row->guid] = true;
                }
            }
            // for reasonable memory usage, only hold 10 posts in memory at a time
            $found_links = 0;
            $num_inserted = 0;
            $num_posts = count($post_ids);
            $bite_size = 10;
            $num_bites = $num_posts / $bite_size;
            if ($num_posts % $bite_size) {
                $num_bites++;
            }
            $upload_path = $uploads['baseurl'];
            $upload_dir = $uploads['basedir'];
            if ($echo) {
                printf(__("<strong>checking %s posts / pages...</strong>", 'scoper'), $num_posts);
                echo '<br /><br />';
            }
            for ($i = 0; $i < $num_bites; $i++) {
                $id_in = "'" . implode("','", array_slice($post_ids, $i * $bite_size, $bite_size)) . "'";
                if (!($results = scoper_get_results("SELECT ID, post_content, post_author, post_title, post_type FROM {$wpdb->posts} WHERE ID IN ({$id_in})"))) {
                    continue;
                }
                foreach ($results as $row) {
                    $linked_uploads = array();
                    // preg_match technique learned from http://stackoverflow.com/questions/138313/how-to-extract-img-src-title-and-alt-from-html-using-php
                    $tags = array('img' => array(), 'a' => array());
                    $content = $row->post_content;
                    preg_match_all('/<img[^>]+>/i', $row->post_content, $tags['img']);
                    preg_match_all('/<a[^>]+>/i', $row->post_content, $tags['a']);
                    // don't care that this will terminate with any enclosed tags (i.e. img)
                    foreach (array_keys($tags) as $tag_type) {
                        foreach ($tags[$tag_type]['0'] as $found_tag) {
                            $found_attribs = array('src' => '', 'href' => '', 'title' => '', 'alt' => '');
                            if (!preg_match_all('/(alt|title|src|href)=("[^"]*")/i', $found_tag, $tag_attributes)) {
                                continue;
                            }
                            foreach ($tag_attributes[1] as $key => $attrib_name) {
                                $found_attribs[$attrib_name] = trim($tag_attributes[2][$key], "'" . '"');
                            }
                            if (!$found_attribs['href'] && !$found_attribs['src']) {
                                continue;
                            }
                            $file_url = $found_attribs['src'] ? $found_attribs['src'] : $found_attribs['href'];
                            if (!strpos($file_url, '.')) {
                                continue;
                            }
                            if (MULTISITE && strpos($uploads['url'], 'blogs.dir')) {
                                $file_url = str_replace('/files/', "/wp-content/blogs.dir/{$blog_id}/files/", $file_url);
                            }
                            // links can't be registered as attachments unless they're in the WP uploads path
                            if (false === strpos($file_url, $upload_path)) {
                                if ($echo) {
                                    //printf( _ x( '<span class="rs-brown">skipping unfilterable file in %1$s "%2$s":</span> %3$s', 'post_type, post_title, file_url', 'scoper' ), __(ucwords($row->post_type)), $row->post_title, $file_url);
                                    printf(__('<span class="rs-brown">skipping unfilterable file in %1$s "%2$s":</span> %3$s', 'scoper'), __(ucwords($row->post_type)), $row->post_title, $file_url);
                                    echo '<br /><br />';
                                }
                                continue;
                            }
                            // make sure the linked file actually exists
                            if (!file_exists(str_replace($upload_path, $upload_dir, $file_url))) {
                                if ($echo) {
                                    //printf( _ x( '<span class="rs-brown">skipping unfilterable file in %1$s "%2$s":</span> %3$s', 'post_type, post_title, file_url', 'scoper' ), __(ucwords($row->post_type)), $row->post_title, $file_url);
                                    printf(__('<span class="rs-red">skipping missing file in %1$s "%2$s":</span> %3$s', 'scoper'), __(ucwords($row->post_type)), $row->post_title, $file_url);
                                    echo '<br /><br />';
//.........这里部分代码省略.........
开发者ID:par-orillonsoft,项目名称:creationOfSociety,代码行数:101,代码来源:attachments_utility.php

示例9: flt_get_others_drafts

 function flt_get_others_drafts($results)
 {
     global $wpdb, $current_user, $scoper;
     // buffer titles in case they were filtered previously
     $titles = scoper_get_property_array($results, 'ID', 'post_title');
     // WP 2.3 added pending status, but no new hook or hook argument
     $draft_query = strpos($wpdb->last_query, 'draft');
     $pending_query = strpos($wpdb->last_query, 'pending');
     if ($draft_query && $pending_query) {
         $status_clause = "AND ( post_status = 'draft' OR post_status = 'pending' )";
     } elseif ($draft_query) {
         $status_clause = "AND post_status = 'draft'";
     } else {
         $status_clause = "AND post_status = 'pending'";
     }
     $object_type = cr_find_post_type();
     if (!$object_type) {
         $object_type = 'post';
     }
     if (!($otype_val = $scoper->data_sources->member_property('post', 'object_types', $object_type, 'val'))) {
         $otype_val = $object_type;
     }
     $qry = "SELECT ID, post_title, post_author FROM {$wpdb->posts} WHERE post_type = '{$otype_val}' AND post_author != '{$current_user->ID}' {$status_clause}";
     $qry = apply_filters('objects_request_rs', $qry, 'post', '', '');
     $items = scoper_get_results($qry);
     // restore buffered titles in case they were filtered previously
     scoper_restore_property_array($items, $titles, 'ID', 'post_title');
     return $items;
 }
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:29,代码来源:hardway-admin_non-administrator-legacy_rs.php

示例10: scoper_retrieve_options

function scoper_retrieve_options($sitewide = false)
{
    global $wpdb;
    if ($sitewide) {
        global $scoper_site_options;
        $scoper_site_options = array();
        if ($results = scoper_get_results("SELECT meta_key, meta_value FROM {$wpdb->sitemeta} WHERE site_id = '{$wpdb->siteid}' AND meta_key LIKE 'scoper_%'")) {
            foreach ($results as $row) {
                $scoper_site_options[$row->meta_key] = $row->meta_value;
            }
        }
        $scoper_site_options = apply_filters('site_options_rs', $scoper_site_options);
        return $scoper_site_options;
    } else {
        global $scoper_blog_options;
        $scoper_blog_options = array();
        if ($results = scoper_get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE 'scoper_%'")) {
            foreach ($results as $row) {
                $scoper_blog_options[$row->option_name] = $row->option_value;
            }
        }
        $scoper_blog_options = apply_filters('options_rs', $scoper_blog_options);
        return $scoper_blog_options;
    }
}
开发者ID:btj,项目名称:cscircles-wp-content,代码行数:25,代码来源:role-scoper_init.php

示例11: scoper_get_parent_roles

function scoper_get_parent_roles($obj_or_term_id, $scope, $src_or_tx_name, $parent_id, $object_type = '')
{
    global $wpdb, $scoper;
    $role_clause = '';
    if (!$parent_id && OBJECT_SCOPE_RS == $scope) {
        // for default roles, need to distinguish between otype-specific roles
        // (note: this only works w/ RS role type. Default object roles are disabled for WP role type because we'd be stuck assigning all default roles to both post & page.)
        $src = $scoper->data_sources->get($src_or_tx_name);
        if (!empty($src->cols->type)) {
            if (!$object_type) {
                $object_type = cr_find_object_type($src_name, $object_id);
            }
            if ($object_type) {
                $role_defs = $scoper->role_defs->get_matching('rs', $src_or_tx_name, $object_type);
                if ($role_names = scoper_role_handles_to_names(array_keys($role_defs))) {
                    $role_clause = "AND role_type = 'rs' AND role_name IN ('" . implode("', '", $role_names) . "')";
                }
            }
        }
    }
    // Since this is a new object, propagate roles from parent (if any are marked for propagation)
    $qry = "SELECT * FROM {$wpdb->user2role2object_rs} WHERE scope = %s AND assign_for IN ('children', 'both') {$role_clause} AND src_or_tx_name = %s AND obj_or_term_id = %d ORDER BY role_type, role_name";
    $results = scoper_get_results($wpdb->prepare($qry, $scope, $src_or_tx_name, $parent_id));
    return $results;
}
开发者ID:btj,项目名称:cscircles-wp-content,代码行数:25,代码来源:filters-admin-save_rs.php

示例12: restrict_roles

 function restrict_roles($scope, $src_or_tx_name, $item_id, $roles, $args = array())
 {
     $defaults = array('implicit_removal' => false, 'is_auto_insertion' => false, 'force_flush' => false);
     $args = array_merge($defaults, (array) $args);
     extract($args);
     global $wpdb;
     $is_administrator = is_administrator_rs($src_or_tx_name, 'user');
     $delete_reqs = array();
     $role_change = false;
     $default_strict_modes = array(false);
     $strict_role_in = '';
     // for object restriction, handle auto-setting of equivalent object roles ( 'post reader' for 'private post reader', 'post author' for 'post editor' ).  There is no logical distinction between these roles where a single object is concerned.
     if (OBJECT_SCOPE_RS == $scope) {
         foreach (array_keys($roles) as $role_handle) {
             $equiv_role_handles = array();
             if ($objscope_equivalents = $this->scoper->role_defs->member_property($role_handle, 'objscope_equivalents')) {
                 foreach ($objscope_equivalents as $equiv_role_handle) {
                     if (!isset($roles[$equiv_role_handle])) {
                         // if the equiv role was set manually, leave it alone.  This would not be normal RS behavior
                         $roles[$equiv_role_handle] = $roles[$role_handle];
                     }
                 }
             }
         }
     }
     if ($item_id) {
         $default_restrictions = $this->scoper->get_default_restrictions($scope);
         $default_strict_roles = !empty($default_restrictions[$src_or_tx_name]) ? array_keys($default_restrictions[$src_or_tx_name]) : array();
         if ($default_strict_roles) {
             $strict_role_in = "'" . implode("', '", scoper_role_handles_to_names($default_strict_roles)) . "'";
             $default_strict_modes[] = true;
         }
     }
     foreach ($default_strict_modes as $default_strict) {
         $stored_reqs = array();
         $req_ids = array();
         if ($default_strict && $strict_role_in) {
             $role_clause = "AND role_name IN ({$strict_role_in})";
         } elseif ($strict_role_in) {
             $role_clause = "AND role_name NOT IN ({$strict_role_in})";
         } else {
             $role_clause = '';
         }
         // IMPORTANT: max_scope value determines whether we are inserting / updating RESTRICTIONS or UNRESTRICTIONS
         if (TERM_SCOPE_RS == $scope) {
             $query_max_scope = $default_strict ? 'blog' : 'term';
         } else {
             $query_max_scope = $default_strict ? 'blog' : 'object';
         }
         // Storage of 'blog' max_scope as object restriction does not eliminate any term restrictions.  It merely indicates, for data sources that are default strict, that this object does not restrict roles
         $qry = "SELECT requirement_id AS assignment_id, require_for AS assign_for, inherited_from, role_name FROM {$wpdb->role_scope_rs} WHERE topic = %s AND max_scope = %s" . " AND src_or_tx_name = %s AND obj_or_term_id = %d AND role_type = 'rs' {$role_clause}";
         if ($results = scoper_get_results($wpdb->prepare($qry, $scope, $query_max_scope, $src_or_tx_name, $item_id))) {
             foreach ($results as $key => $req) {
                 $role_handle = 'rs_' . $req->role_name;
                 if (OBJECT_SCOPE_RS == $scope && isset($is_objscope_equiv[$role_handle])) {
                     $role_handle = $is_objscope_equiv[$role_handle];
                 }
                 $stored_reqs[$role_handle] = array('assignment_id' => $req->assignment_id, 'assign_for' => $req->assign_for, 'inherited_from' => $req->inherited_from);
                 $req_ids[$role_handle][$req->assignment_id] = array();
             }
         }
         if (!$is_administrator) {
             $user_has_role = $this->_validate_assigner_roles($scope, $src_or_tx_name, $item_id, $roles);
         }
         if ($implicit_removal) {
             // Stored restrictions which are not mirrored in $roles will be deleted (along with their prodigy)
             foreach (array_keys($stored_reqs) as $role_handle) {
                 $max_scope = isset($roles[$role_handle]['max_scope']) ? $roles[$role_handle]['max_scope'] : false;
                 if ($max_scope != $query_max_scope) {
                     $delete_reqs = $delete_reqs + $req_ids[$role_handle];
                 }
             }
         }
         foreach ($roles as $role_handle => $setting) {
             if (!$is_administrator && empty($user_has_role[$role_handle])) {
                 continue;
             }
             if ($default_strict && !in_array($role_handle, $default_strict_roles)) {
                 continue;
             }
             if (!$default_strict && !empty($default_strict_roles) && in_array($role_handle, $default_strict_roles)) {
                 continue;
             }
             $max_scope = $setting['max_scope'];
             if ($max_scope != $query_max_scope) {
                 $require_for = REMOVE_ASSIGNMENT_RS;
             } elseif ($setting['for_item']) {
                 $require_for = $setting['for_children'] ? ASSIGN_FOR_BOTH_RS : ASSIGN_FOR_ENTITY_RS;
             } else {
                 $require_for = $setting['for_children'] ? ASSIGN_FOR_CHILDREN_RS : REMOVE_ASSIGNMENT_RS;
             }
             $update_require_for = array(ASSIGN_FOR_ENTITY_RS => array(), ASSIGN_FOR_CHILDREN_RS => array(), ASSIGN_FOR_BOTH_RS => array());
             $stored_req = isset($stored_reqs[$role_handle]) ? $stored_reqs[$role_handle] : array();
             $unused_byref_arg = '';
             $comparison = $this->_compare_role_settings($require_for, $stored_req, $delete_reqs, $update_require_for, $unused_byref_arg, $unused_byref_arg);
             $insert_restriction = $comparison['unset'] ? false : $require_for;
             // Mark assignment for propagation to child items (But don't do so on storage of default restriction to root item. Default restrictions are only applied at item creation.)
             $propagate_restriction = $item_id && isset($comparison['new_propagation']) ? $comparison['new_propagation'] : '';
             if ($comparison['role_change']) {
                 $role_change = true;
//.........这里部分代码省略.........
开发者ID:btj,项目名称:cscircles-wp-content,代码行数:101,代码来源:role_assigner_rs.php

示例13: dropdown_pages

 function dropdown_pages($object_id = '', $stored_parent_id = '')
 {
     global $scoper, $wpdb;
     // buffer titles in case they are filtered on get_pages hook
     $titles = ScoperAdminBulkParent::get_page_titles();
     if (!is_numeric($object_id)) {
         global $post_ID;
         if (empty($post_ID)) {
             $object_id = $scoper->data_sources->detect('id', 'post', 0, 'post');
         } else {
             $object_id = $post_ID;
         }
     }
     if ($object_id && !is_numeric($stored_parent_id)) {
         $stored_parent_id = $scoper->data_sources->detect('parent', 'post', $object_id);
     }
     // make sure the currently stored parent page remains in dropdown regardless of current user roles
     if ($stored_parent_id) {
         $preserve_or_clause = " {$wpdb->posts}.ID = '{$stored_parent_id}' ";
         $args['preserve_or_clause'] = array();
         foreach (array_keys($scoper->data_sources->member_property('post', 'statuses')) as $status_name) {
             $args['preserve_or_clause'][$status_name] = $preserve_or_clause;
         }
     }
     // alternate_caps is a 2D array because objects_request / objects_where filter supports multiple alternate sets of qualifying caps
     $args['force_reqd_caps']['page'] = array();
     foreach (array_keys($scoper->data_sources->member_property('post', 'statuses')) as $status_name) {
         $args['force_reqd_caps']['page'][$status_name] = array('edit_others_pages');
     }
     $args['alternate_reqd_caps'][0] = array('create_child_pages');
     $all_pages_by_id = array();
     if ($results = scoper_get_results("SELECT ID, post_parent, post_title FROM {$wpdb->posts} WHERE post_type = 'page'")) {
         foreach ($results as $row) {
             $all_pages_by_id[$row->ID] = $row;
         }
     }
     $object_type = awp_post_type_from_uri();
     // Editable / associable draft and pending pages will be included in Page Parent dropdown in Edit Forms, but not elsewhere
     if (is_admin() && 'page' != $object_type) {
         $status_clause = "AND {$wpdb->posts}.post_status IN ('publish', 'private')";
     } else {
         $status_clause = "AND {$wpdb->posts}.post_status IN ('publish', 'private', 'pending', 'draft')";
     }
     $qry_parents = "SELECT ID, post_parent, post_title FROM {$wpdb->posts} WHERE post_type = 'page' {$status_clause} ORDER BY menu_order";
     $qry_parents = apply_filters('objects_request_rs', $qry_parents, 'post', 'page', $args);
     $filtered_pages_by_id = array();
     if ($results = scoper_get_results($qry_parents)) {
         foreach ($results as $row) {
             $filtered_pages_by_id[$row->ID] = $row;
         }
     }
     $hidden_pages_by_id = array_diff_key($all_pages_by_id, $filtered_pages_by_id);
     // temporarily add in the hidden parents so we can order the visible pages by hierarchy
     $pages = ScoperAdminBulkParent::add_missing_parents($filtered_pages_by_id, $hidden_pages_by_id, 'post_parent');
     // convert keys from post ID to title+ID so we can alpha sort them
     $args['pages'] = array();
     foreach (array_keys($pages) as $id) {
         $args['pages'][$pages[$id]->post_title . chr(11) . $id] = $pages[$id];
     }
     // natural case alpha sort
     uksort($args['pages'], "strnatcasecmp");
     $args['pages'] = ScoperAdminBulkParent::order_by_hierarchy($args['pages'], 'ID', 'post_parent');
     // take the hidden parents back out
     foreach ($args['pages'] as $key => $page) {
         if (isset($hidden_pages_by_id[$page->ID])) {
             unset($args['pages'][$key]);
         }
     }
     $output = '';
     // restore buffered titles in case they were filtered on get_pages hook
     scoper_restore_property_array($args['pages'], $titles, 'ID', 'post_title');
     if ($object_id) {
         $args['object_id'] = $object_id;
         $args['retain_page_ids'] = true;
         // retain static log to avoid redundant entries by subsequent call with use_parent_clause=false
         ScoperHardwayParentLegacy::walk_parent_dropdown($output, $args, true, $stored_parent_id);
     }
     // next we'll add disjointed branches, but don't allow this page's descendants to be offered as a parent
     $arr_parent = array();
     $arr_children = array();
     if ($results = scoper_get_results("SELECT ID, post_parent FROM {$wpdb->posts} WHERE post_type = 'page' {$status_clause}")) {
         foreach ($results as $row) {
             $arr_parent[$row->ID] = $row->post_parent;
             if (!isset($arr_children[$row->post_parent])) {
                 $arr_children[$row->post_parent] = array();
             }
             $arr_children[$row->post_parent][] = $row->ID;
         }
         $descendants = array();
         if (!empty($arr_children[$object_id])) {
             foreach ($arr_parent as $page_id => $parent_id) {
                 if (!$parent_id || $page_id == $object_id) {
                     continue;
                 }
                 do {
                     if ($object_id == $parent_id) {
                         $descendants[$page_id] = true;
                         break;
                     }
                     $parent_id = $arr_parent[$parent_id];
//.........这里部分代码省略.........
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:101,代码来源:hardway-parent-legacy_rs.php

示例14: load_roles

 function load_roles($src_name, $object_type, $object_id)
 {
     //log_mem_usage_rs( 'start ItemRolesUI::load_roles()' );
     if ('edit.php' == $GLOBALS['pagenow']) {
         return;
     }
     if (!scoper_get_otype_option('use_object_roles', $src_name, $object_type)) {
         return;
     }
     if (!($src = $this->scoper->data_sources->get($src_name))) {
         return;
     }
     $this->loaded_src_name = $src_name;
     $this->loaded_object_type = $object_type;
     $this->loaded_object_id = $object_id;
     $this->indicate_blended_roles = scoper_get_option('indicate_blended_roles');
     $this->all_agents = array();
     $this->agent_captions = array();
     $this->agent_captions_plural = array();
     $this->eligible_agent_ids = array();
     // note: if object_id = 0, default roles will be retrieved
     $get_defaults = !$object_id;
     $obj_roles = array();
     $role_defs = $this->scoper->role_defs->get_matching('rs', $src_name, $object_type);
     $this->role_handles = array_keys($role_defs);
     // for default roles, distinguish between various object types
     $filter_role_handles = $object_id ? '' : array_keys($role_defs);
     if (GROUP_ROLES_RS) {
         $this->current_roles[ROLE_BASIS_GROUPS] = ScoperRoleAssignments::organize_assigned_roles(OBJECT_SCOPE_RS, $src_name, $object_id, $filter_role_handles, ROLE_BASIS_GROUPS, $get_defaults);
     }
     //log_mem_usage_rs( 'load_roles: organize_assigned_roles for groups' );
     if (USER_ROLES_RS) {
         $this->current_roles[ROLE_BASIS_USER] = ScoperRoleAssignments::organize_assigned_roles(OBJECT_SCOPE_RS, $src_name, $object_id, $filter_role_handles, ROLE_BASIS_USER, $get_defaults);
     }
     //log_mem_usage_rs( 'load_roles: organize_assigned_roles for users' );
     if (GROUP_ROLES_RS) {
         $this->all_groups = ScoperAdminLib::get_all_groups(UNFILTERED_RS);
         //log_mem_usage_rs( 'load_roles: get_all_groups' );
         if (!empty($this->all_groups)) {
             $this->agent_captions[ROLE_BASIS_GROUPS] = __('Group', 'scoper');
             $this->agent_captions_plural[ROLE_BASIS_GROUPS] = __('Groups', 'scoper');
             $this->all_agents[ROLE_BASIS_GROUPS] = $this->all_groups;
             $this->all_agents[ROLE_BASIS_GROUPS] = $this->all_groups;
         }
         //log_mem_usage_rs( 'load_roles: set all_groups properties' );
     }
     if (USER_ROLES_RS) {
         $this->agent_captions[ROLE_BASIS_USER] = __('User', 'scoper');
         $this->agent_captions_plural[ROLE_BASIS_USER] = __awp('Users');
         // note: all users are eligible for a reading role assignment, but we may not be displaying user checkboxes
         $user_csv_input = scoper_get_option("user_role_assignment_csv");
         if (!$user_csv_input) {
             $this->all_agents[ROLE_BASIS_USER] = $this->scoper->users_who_can('', COLS_ID_NAME_RS);
         } elseif ($object_id) {
             $assignees = array();
             if ($this->current_roles[ROLE_BASIS_USER]) {
                 foreach (array_keys($this->current_roles[ROLE_BASIS_USER]) as $role_handle) {
                     $assignees = array_merge($assignees, array_keys($this->current_roles[ROLE_BASIS_USER][$role_handle]['assigned']));
                 }
             }
             $assignees = array_unique($assignees);
             global $wpdb;
             $this->all_agents[ROLE_BASIS_USER] = scoper_get_results("SELECT ID, display_name FROM {$wpdb->users} WHERE ID IN ('" . implode("','", $assignees) . "')");
         } else {
             $this->all_agents[ROLE_BASIS_USER] = array();
         }
         //log_mem_usage_rs( 'load_roles: users_who_can for all_agents' );
         //users eligible for an editing role assignments are those who have the basic edit cap via taxonomy or blog role
         if (scoper_get_otype_option('limit_object_editors', $src_name, $object_type)) {
             // Limit eligible page contribs/editors based on blog ownership of "edit_posts"
             // Otherwise, since pages are generally not categorized, only Blog Editors and Admins are eligible for object role ass'n
             // It's more useful to exclude Blog Subscribers while including all others
             $role_object_type = 'page' == $object_type ? 'post' : $object_type;
             $reqd_caps = $this->scoper->cap_defs->get_matching($src_name, $role_object_type, OP_EDIT_RS, '', BASE_CAPS_RS);
             // status-specific and 'others' caps will not be returned
             $args = array('ignore_strict_terms' => true, 'ignore_group_roles' => true, 'skip_object_roles' => true);
             $this->eligible_agent_ids[ROLE_BASIS_USER][OP_EDIT_RS] = $this->scoper->users_who_can(array_keys($reqd_caps), COL_ID_RS, '', 0, $args);
             //log_mem_usage_rs( 'load_roles: users_who_can for eligible_agent_ids' );
         }
     }
     $this->blog_term_roles = array();
     // Pull object and blog/term role assignments for all roles
     // Do this first so contained / containing roles can be accounted for in UI
     foreach ($role_defs as $role_handle => $role_def) {
         if ($this->indicate_blended_roles && isset($role_def->valid_scopes[OBJECT_SCOPE_RS])) {
             // might need to check term/blog assignment of a different role to reflect object's current status
             if (!empty($role_def->other_scopes_check_role) && !empty($src->cols->status)) {
                 $status = $this->scoper->data_sources->detect('status', $src, $object_id);
                 if (isset($role_def->other_scopes_check_role[$status])) {
                     $blog_term_role_handle = $role_def->other_scopes_check_role[$status];
                 } elseif (isset($role_def->other_scopes_check_role[''])) {
                     $blog_term_role_handle = $role_def->other_scopes_check_role[''];
                 } else {
                     $blog_term_role_handle = $role_handle;
                 }
             } else {
                 $blog_term_role_handle = $role_handle;
             }
             $this_args = array('skip_object_roles' => true, 'object_type' => $object_type, 'ignore_group_roles' => true);
             if (empty($user_csv_input)) {
//.........这里部分代码省略.........
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:101,代码来源:item_roles_ui_rs.php

示例15: flt_get_terms


//.........这里部分代码省略.........
         $search = like_escape($search);
         $where .= " AND (t.name LIKE '%{$search}%')";
     }
     $selects = array();
     switch ($fields) {
         case 'all':
             $selects = array('t.*', 'tt.*');
             break;
         case 'ids':
         case 'id=>parent':
             $selects = array('t.term_id', 'tt.term_taxonomy_id', 'tt.parent', 'tt.count');
             break;
         case 'names':
             $selects = array('t.term_id', 'tt.term_taxonomy_id', 'tt.parent', 'tt.count', 't.name');
             break;
         case 'count':
             $orderby = '';
             $order = '';
             $selects = array('COUNT(*)');
     }
     $select_this = implode(', ', apply_filters('get_terms_fields', $selects, $args));
     // === BEGIN Role Scoper MODIFICATION: run the query through scoping filter
     //
     $query_base = "SELECT DISTINCT {$select_this} 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 IN ({$in_taxonomies}) {$where} {$parent_or} {$orderby} {$order} {$limit}";
     // only force application of scoped query filter if we're NOT doing a teaser
     if ('all' == $fields) {
         $do_teaser = $scoper->is_front() && empty($skip_teaser) && scoper_get_otype_option('do_teaser', 'post');
     } else {
         $do_teaser = false;
     }
     $query = apply_filters('terms_request_rs', $query_base, $taxonomies[0], array('skip_teaser' => !$do_teaser, 'is_term_admin' => $is_term_admin, 'required_operation' => $required_operation, 'post_type' => $post_type));
     // if no filering was applied because the teaser is enabled, prevent a redundant query
     if (!empty($exclude_tree) || $query_base != $query || $parent || 'all' != $fields) {
         $terms = scoper_get_results($query);
     } else {
         $terms = $results;
     }
     if ('count' == $fields) {
         $term_count = $wpdb->get_var($query);
         return $term_count;
     }
     if ('all' == $fields && empty($include)) {
         update_term_cache($terms);
     }
     // RS: don't cache an empty array, just in case something went wrong
     if (empty($terms)) {
         return array();
     }
     //
     // === END Role Scoper MODIFICATION ===
     // ====================================
     // === BEGIN Role Scoper ADDITION: Support a disjointed terms tree with some parents hidden
     //
     if ('all' == $fields) {
         $ancestors = ScoperAncestry::get_term_ancestors($taxonomy);
         // array of all ancestor IDs for keyed term_id, with direct parent first
         if ($parent > 0 || !$hierarchical) {
             // in Category Edit form, need to list all editable cats even if parent is not editable
             $remap_parents = false;
             $enforce_actual_depth = true;
             $remap_thru_excluded_parent = false;
         } else {
             // if these settings were passed into this get_terms call, use them
             if (is_admin()) {
                 $remap_parents = true;
             } else {
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:67,代码来源:hardway-taxonomy-legacy_rs.php


注:本文中的scoper_get_results函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。