コード例 #1
0
 function _get_teaser_post_types($post_types, $args = array())
 {
     if (is_admin() || pp_is_content_administrator() || !empty($args['skip_teaser']) || defined('XMLRPC_REQUEST')) {
         return array();
     }
     return apply_filters('pp_teased_post_types', array(), $post_types, $args);
 }
コード例 #2
0
ファイル: pp_main.php プロジェクト: severnrescue/web
 function load_user_config()
 {
     // ===== Query Filters to limit/enable the current user
     if ($this->filtering_enabled) {
         global $pagenow;
         $is_unfiltered = pp_unfiltered();
         $is_administrator = pp_is_content_administrator();
         // even users who are unfiltered in terms of their own access will normally have some of these filters applied to force inclusion of readable private posts in get_pages() listing, post counts, etc.
         if ($is_front = pp_is_front()) {
             $front_filtering = !$is_unfiltered || !defined('PP_ALLOW_UNFILTERED_FRONT');
         }
         // (also use content filters on front end to FILTER IN private content which WP inappropriately hides from administrators)
         if ($is_front && $front_filtering || (!$is_unfiltered || 'nav-menus.php' == $pagenow)) {
             global $query_interceptor;
             if (!isset($query_interceptor)) {
                 // since this could possibly fire on multiple 'set_current_user' calls, avoid redundancy
                 require_once dirname(__FILE__) . '/query-interceptor_pp.php';
                 $query_interceptor = new PP_QueryInterceptor(array('direct_file_access' => $this->direct_file_access));
             }
         }
         if ($is_front && $front_filtering) {
             global $pp_qry_int_front;
             require_once dirname(__FILE__) . '/query-interceptor-front_pp.php';
             $pp_qry_int_front = new PP_QueryInterceptorFront();
             require_once dirname(__FILE__) . '/front_pp.php';
             if ($is_unfiltered && $is_administrator) {
                 require_once dirname(__FILE__) . '/comments-int-administrator_pp.php';
             }
         }
         if (!$is_unfiltered) {
             global $cap_interceptor;
             if (!isset($cap_interceptor)) {
                 require_once dirname(__FILE__) . '/cap-interceptor_pp.php';
                 $cap_interceptor = new PP_CapInterceptor();
             }
             require_once dirname(__FILE__) . '/comments-interceptor_pp.php';
         }
         if ($is_front && $front_filtering || !$is_unfiltered && (!defined('DOING_AUTOSAVE') || !DOING_AUTOSAVE)) {
             pp_init_terms_interceptor();
         } elseif (is_admin() && $is_unfiltered) {
             require_once dirname(__FILE__) . '/admin/terms-interceptor-administrator_pp.php';
             // for filtering of post count
         }
         // ported or low-level query filters to work around limitations in WP core API
         if (!$this->direct_file_access && (!$is_front || $front_filtering) && (!defined('XMLRPC_REQUEST') || !$is_administrator)) {
             // don't add for direct file access or administrator XML-RPC
             //add_filter( 'query', array( &$this, 'get_pages_query_watch' ), 50, 1 );
             add_filter('get_pages', array(&$this, 'flt_get_pages'), 1, 2);
         }
     }
 }
コード例 #3
0
 public function flt_sticky_posts($post_ids)
 {
     if ($post_ids && !pp_is_content_administrator()) {
         global $wpdb;
         $clauses = array_fill_keys(array('distinct', 'join', 'groupby', 'orderby', 'limits'), '');
         $clauses['fields'] = 'ID';
         $clauses['where'] = "AND ID IN ('" . implode("','", $post_ids) . "')";
         $clauses = apply_filters('pp_posts_clauses', $clauses);
         $post_ids = $wpdb->get_col("SELECT {$clauses['distinct']} ID FROM {$wpdb->posts} {$clauses['join']} WHERE 1=1 {$clauses['where']}");
     }
     return $post_ids;
 }
コード例 #4
0
ファイル: pp_load.php プロジェクト: severnrescue/web
function pp_supplement_user_allcaps(&$user)
{
    global $pp_cap_helper;
    if (pp_is_content_administrator()) {
        // give content administrators (users with pp_administer_content capability in WP role) all PP-defined caps and type-specific post caps
        $user->allcaps = apply_filters('pp_administrator_caps', array_merge($user->allcaps, $pp_cap_helper->all_type_caps));
    } else {
        if (!$user->ID) {
            global $pp_role_defs;
            $user->allcaps = array_merge($user->allcaps, array_fill_keys($pp_role_defs->anon_user_caps, true));
        } else {
            global $wp_roles, $wp_post_types, $wpdb;
            // merge in caps from supplemental direct role assignments
            foreach (array_keys($user->site_roles) as $role_name) {
                if (isset($wp_roles->role_objects[$role_name])) {
                    $user->allcaps = array_merge($user->allcaps, $wp_roles->role_objects[$role_name]->capabilities);
                } elseif (!strpos($role_name, ':')) {
                    $user->allcaps = array_merge($user->allcaps, array_fill_keys(apply_filters('pp_role_caps', array(), $role_name), true));
                }
            }
            if (PP_MULTISITE && !is_user_member_of_blog() && empty($user->allcaps)) {
                $user->allcaps['read'] = true;
            }
        }
        // merge in caps from typecast WP role assignments (and also clear false-valued allcaps entries)
        $pp_cap_caster = pp_init_cap_caster();
        $user->allcaps = array_merge(array_diff($user->allcaps, array(false, 0)), $pp_cap_caster->get_user_typecast_caps($user));
    }
}
コード例 #5
0
 public static function get_pp_groups_for_user($user_id, $args = array())
 {
     $defaults = array('agent_type' => 'pp_group', 'member_type' => 'member', 'status' => 'active', 'cols' => 'all', 'metagroup_type' => null, 'force_refresh' => false, 'query_user_ids' => false);
     $args = array_merge($defaults, $args);
     if (is_null($args['metagroup_type'])) {
         unset($args['metagroup_type']);
     }
     extract($args, EXTR_SKIP);
     global $wpdb;
     $groups_table = apply_filters('pp_use_groups_table', $wpdb->pp_groups, $agent_type);
     $members_table = apply_filters('pp_use_group_members_table', $wpdb->pp_group_members, $agent_type);
     if (empty($members_table)) {
         return array();
     }
     if ($cols == 'all' || !empty($metagroup_type)) {
         $join = apply_filters('pp_get_groups_for_user_join', "INNER JOIN {$groups_table} AS g ON {$members_table}.group_id = g.ID", $user_id, $args);
     } else {
         $join = '';
     }
     if ('any' == $status) {
         $status = '';
     }
     $status_clause = $status ? $wpdb->prepare("AND status = %s", $status) : '';
     $metagroup_clause = !empty($metagroup_type) ? $wpdb->prepare("AND g.metagroup_type = %s", $metagroup_type) : '';
     $user_id = (int) $user_id;
     $user_groups = array();
     if ('pp_group' == $agent_type) {
         static $all_group;
         static $auth_group;
         if (!pp_is_content_administrator() || !pp_get_option('suppress_administrator_metagroups')) {
             if (!isset($all_group)) {
                 $all_group = pp_get_metagroup('wp_role', 'wp_all');
             }
             if (!isset($auth_group)) {
                 $auth_group = pp_get_metagroup('wp_role', 'wp_auth');
             }
         }
     }
     if ('all' == $cols) {
         $query = "SELECT * FROM {$members_table} {$join} WHERE user_id = '{$user_id}' AND member_type = '{$member_type}' {$status_clause} {$metagroup_clause} ORDER BY {$members_table}.group_id";
         $results = $wpdb->get_results($query);
         foreach ($results as $row) {
             $user_groups[$row->group_id] = (object) (array) $row;
         }
         // force storage by value
         if ('pp_group' == $agent_type) {
             if ($all_group) {
                 $user_groups[$all_group->ID] = $all_group;
             }
             if ($auth_group) {
                 $user_groups[$auth_group->ID] = $auth_group;
             }
         }
         $user_groups = apply_filters('pp_get_pp_groups_for_user', $user_groups, $results, $user_id, $args);
     } else {
         if ($query_user_ids) {
             static $user_groups;
             if (!isset($user_groups)) {
                 $user_groups = array();
             }
             if (!isset($user_groups[$agent_type])) {
                 $user_groups[$agent_type] = array();
             }
         } else {
             $user_groups = array($agent_type => array());
             $query_user_ids = $user_id;
         }
         if (!isset($user_groups[$agent_type][$user_id]) || $force_refresh) {
             $query = "SELECT user_id, group_id, add_date_gmt FROM {$members_table} {$join} WHERE user_id IN ('" . implode("','", (array) $query_user_ids) . "') AND member_type = '{$member_type}' {$status_clause} {$metagroup_clause} ORDER BY group_id";
             $results = $wpdb->get_results($query);
             foreach ($results as $row) {
                 $user_groups[$agent_type][$row->user_id][$row->group_id] = $row->add_date_gmt;
             }
         }
         if ('pp_group' == $agent_type) {
             foreach ((array) $query_user_ids as $_user_id) {
                 if ($all_group) {
                     $user_groups[$agent_type][$_user_id][$all_group->ID] = '0000-00-00 00:00:00';
                 }
                 if ($auth_group) {
                     $user_groups[$agent_type][$_user_id][$auth_group->ID] = '0000-00-00 00:00:00';
                 }
             }
         }
         return isset($user_groups[$agent_type][$user_id]) ? $user_groups[$agent_type][$user_id] : array();
     }
     return $user_groups;
 }