예제 #1
0
 function option_checkbox($option_name, $tab_name, $section_name, $hint_text = '', $trailing_html = '', $args = array())
 {
     $return = array('in_scope' => false, 'no_storage' => false, 'disabled' => false, 'title' => '');
     if (in_array($option_name, $this->form_options[$tab_name][$section_name])) {
         if (empty($args['no_storage'])) {
             $this->all_options[] = $option_name;
         }
         if (isset($args['val'])) {
             $return['val'] = $args['val'];
         } else {
             $return['val'] = !empty($args['no_storage']) ? 0 : pp_get_option($option_name, $this->option_args);
         }
         $disabled_clause = !empty($args['disabled']) || $this->hide_network_option($option_name) ? "disabled='disabled'" : '';
         $style = !empty($args['style']) ? $args['style'] : '';
         $title = !empty($args['title']) ? " title='" . esc_attr($args['title']) . "'" : '';
         echo "<div class='agp-vspaced_input'>" . "<label for='{$option_name}'{$title}><input name='{$option_name}' type='checkbox' {$disabled_clause} {$style} id='{$option_name}' value='1' " . checked('1', $return['val'], false) . " /> " . $this->option_captions[$option_name] . "</label>";
         if ($hint_text && $this->display_hints) {
             echo "<div class='pp-subtext'>" . $hint_text . "</div>";
         }
         echo "</div>";
         if ($trailing_html) {
             echo $trailing_html;
         }
         $return['in_scope'] = true;
     }
     return $return;
 }
예제 #2
0
 function add_meta_boxes()
 {
     // ========= register WP-rendered metaboxes ============
     $post_type = pp_find_post_type();
     if (!current_user_can('pp_assign_roles') || apply_filters('pp_disable_exception_ui', false, 'post', 0, $post_type)) {
         return;
     }
     $hidden_types = apply_filters('pp_hidden_post_types', array());
     if (!empty($hidden_types[$post_type])) {
         return;
     }
     if (!in_array($post_type, pp_get_enabled_post_types())) {
         if (!in_array($post_type, array('revision')) && pp_get_option('display_hints')) {
             $type_obj = get_post_type_object($post_type);
             if ($type_obj->public) {
                 if (!in_array($post_type, apply_filters('pp_unfiltered_post_types', array()))) {
                     add_meta_box("pp_enable_type", __('Press Permit Settings', 'pp'), array(&$this, 'draw_settings_ui'), $post_type, 'advanced', 'default', array());
                 }
             }
         }
         return;
     }
     //if ( ! $this->_roles_editable( $src_name, $object_type ) )
     //	return;
     $ops = _pp_can_set_exceptions('read', $post_type, array('via_item_source' => 'post', 'for_item_source' => 'post')) ? array('read' => true) : array();
     $operations = apply_filters('pp_item_edit_exception_ops', $ops, 'post', $post_type);
     foreach (array_keys($operations) as $op) {
         if ($op_obj = pp_get_op_object($op, $post_type)) {
             // $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null
             add_meta_box("pp_{$op}_{$post_type}_exceptions", sprintf(__('%s Exceptions', 'pp'), $op_obj->noun_label), array(&$this, 'draw_exceptions_ui'), $post_type, 'advanced', 'default', array('op' => $op));
         }
     }
 }
예제 #3
0
function ppx_force_defaults($options)
{
    if (!pp_get_option('advanced_options')) {
        foreach (ppx_default_options() as $key => $val) {
            $options["pp_{$key}"] = $val;
        }
    }
    return $options;
}
예제 #4
0
function _cme_update_pp_usage()
{
    static $updated;
    if (!empty($updated)) {
        return true;
    }
    if (!current_user_can('pp_manage_settings')) {
        return false;
    }
    if (!empty($_REQUEST['update_filtered_types'])) {
        // update Press Permit "Filtered Post Types".  This determines whether type-specific capability definitions are forced
        $options = array('enabled_post_types', 'enabled_taxonomies');
        foreach ($options as $option_basename) {
            if (!isset($_POST["{$option_basename}-options"])) {
                continue;
            }
            $unselected = array();
            $value = array();
            foreach ($_POST["{$option_basename}-options"] as $key) {
                if (empty($_POST["{$option_basename}-{$key}"])) {
                    $unselected[$key] = true;
                } else {
                    $value[$key] = true;
                }
            }
            if ($current = pp_get_option($option_basename)) {
                if ($current = array_diff_key($current, $unselected)) {
                    $value = array_merge($current, $value);
                }
                // retain setting for any types which were previously enabled for filtering but are currently not registered
            }
            $value = stripslashes_deep($value);
            pp_update_option($option_basename, $value);
            $updated = true;
        }
        if (pp_wp_ver('3.5')) {
            pp_update_option('define_create_posts_cap', !empty($_REQUEST['pp_define_create_posts_cap']));
        }
    }
    if (!empty($_REQUEST['SaveRole'])) {
        if (!empty($_REQUEST['role'])) {
            $pp_only = (array) pp_get_option('supplemental_role_defs');
            if (empty($_REQUEST['pp_only_role'])) {
                $pp_only = array_diff($pp_only, array($_REQUEST['role']));
            } else {
                $pp_only[] = $_REQUEST['role'];
            }
            pp_update_option('supplemental_role_defs', array_unique($pp_only));
            _cme_pp_default_pattern_role($_REQUEST['role']);
        }
    }
    if ($updated) {
        pp_refresh_options();
    }
    return $updated;
}
예제 #5
0
 function force_distinct_post_caps()
 {
     // but only if the post type has PP filtering enabled
     global $wp_post_types;
     $core_meta_caps = array_fill_keys(array('read_post', 'edit_post', 'delete_post'), true);
     $append_caps = array('edit_published_posts' => 'edit_posts', 'edit_private_posts' => 'edit_posts', 'delete_posts' => 'edit_posts', 'delete_others_posts' => 'delete_posts', 'delete_published_posts' => 'delete_posts', 'delete_private_posts' => 'delete_posts', 'read' => 'read');
     if ($force_create_posts_cap = pp_wp_ver('3.5-beta') && pp_get_option('define_create_posts_cap')) {
         foreach (array('post', 'page') as $post_type) {
             if ($force_create_posts_cap && $wp_post_types[$post_type]->cap->create_posts == $wp_post_types[$post_type]->cap->edit_posts) {
                 $wp_post_types[$post_type]->cap->create_posts = "create_{$post_type}s";
             }
         }
         $append_caps['create_posts'] = 'create_posts';
     }
     // post types which are enabled for PP filtering must have distinct type-related cap definitions
     foreach (pp_get_enabled_post_types() as $post_type) {
         // append missing capability definitions
         foreach ($append_caps as $prop => $default) {
             if (!isset($wp_post_types[$post_type]->cap->{$prop})) {
                 $wp_post_types[$post_type]->cap->{$prop} = 'read' == $prop ? 'read' : $wp_post_types[$post_type]->cap->{$default};
             }
         }
         $wp_post_types[$post_type]->map_meta_cap = true;
         $type_caps = array_diff_key((array) $wp_post_types[$post_type]->cap, $core_meta_caps);
         $cap_base = 'attachment' == $post_type ? 'file' : $post_type;
         foreach (array('post', 'page') as $generic_type) {
             if ($post_type != $generic_type) {
                 // page is not prevented from having 'page' cap defs, but IS prevented from having 'post' cap defs
                 // force distinct capability_type
                 if ($generic_type == $wp_post_types[$post_type]->capability_type) {
                     $wp_post_types[$post_type]->capability_type = $post_type;
                 }
                 // Replace "edit_posts" with "edit_doohickys". This is not ideal, but as of WP 3.4, no plural name is defined unless unless type-specific caps are already set.
                 // If this is a problem, just define the type caps in the register_post_type call, or modify existing $wp_post_types[$post_type]->cap values by hooking to the init action at priority 40.
                 //foreach( array_keys( array_intersect( (array) $wp_post_types[$generic_type]->cap, $type_caps ) ) as $cap_property ) {
                 foreach (array_keys($type_caps) as $cap_property) {
                     if (!in_array($type_caps[$cap_property], (array) $wp_post_types[$generic_type]->cap)) {
                         continue;
                     }
                     if ('create_posts' == $cap_property) {
                         $type_caps[$cap_property] = str_replace("_{$generic_type}", "_{$cap_base}", $wp_post_types[$generic_type]->cap->{$cap_property});
                     } else {
                         $type_caps[$cap_property] = str_replace("_{$generic_type}", "_{$cap_base}", $cap_property);
                     }
                 }
             }
         }
         $wp_post_types[$post_type]->cap = (object) array_merge((array) $wp_post_types[$post_type]->cap, $type_caps);
         $wp_post_types[$post_type]->plural_name = pp_plural_name_from_cap($wp_post_types[$post_type]);
         $this->all_type_caps = array_merge($this->all_type_caps, array_fill_keys($type_caps, true));
     }
     // end foreach post type
     // need this for casting to other types even if "post" type is not enabled for PP filtering
     $wp_post_types['post']->cap->set_posts_status = 'set_posts_status';
 }
예제 #6
0
 public static function _pp_show_contextual_help()
 {
     $screen_obj = get_current_screen();
     $link_section = '';
     if (is_object($screen_obj)) {
         $screen = $screen_obj->id;
     }
     if (strpos($screen, 'pp-')) {
         $match = array();
         if (!preg_match("/admin_page_pp-[^@]*-*/", $screen, $match)) {
             if (!preg_match("/_page_pp-[^@]*-*/", $screen, $match)) {
                 preg_match("/pp-[^@]*-*/", $screen, $match);
             }
         }
         if ($match) {
             if ($pos = strpos($match[0], 'pp-')) {
                 $link_section = substr($match[0], $pos + strlen('pp-'));
                 $link_section = str_replace('_t', '', $link_section);
             }
         }
     } elseif (in_array($screen_obj->base, array('post', 'page', 'upload', 'users', 'edit-tags', 'edit'))) {
         $link_section = $screen_obj->base;
     }
     if ($link_section) {
         $link_section = str_replace('.php', '', $link_section);
         $link_section = str_replace('/', '~', $link_section);
         $help = '';
         if (in_array($screen, array('post', 'page'))) {
             global $post;
             $id_arg = "&amp;post_id=" . $post->ID;
         } elseif (in_array($screen_obj->base, array('edit-tags')) && !empty($_REQUEST['tag_ID'])) {
             if ($term = get_term($_REQUEST['tag_ID'], $_REQUEST['taxonomy'])) {
                 $id_arg = "&amp;term_taxonomy_id=" . $term->term_taxonomy_id;
             }
         } else {
             $id_arg = '';
         }
         $help .= '<ul><li>' . sprintf(__('%1$s Press Permit Documentation%2$s', 'pp'), "<a href='http://presspermit.com/docs/?pp_topic={$link_section}' target='_blank'>", '</a>') . '</li><li>' . sprintf(__('%1$s Press Permit Support Forums%2$s', 'pp'), "<a href='http://presspermit.com/forums/?pp_topic={$link_section}' target='_blank'>", '</a>') . '</li><li>' . sprintf(__('%1$s Press Permit Support Forums (with config data upload) *%2$s', 'pp'), "<a href='admin.php?page=pp-settings&amp;pp_support_forum=1&amp;pp_topic={$link_section}{$id_arg}' target='_blank'>", '</a></li>');
         $key = pp_get_option('support_key');
         if (!$key || 1 != $key[0]) {
             $help .= '<li>' . sprintf(__('%1$s Buy a Press Permit Support Key%2$s', 'pp'), "<a href='http://presspermit.com/purchase/'>", '</a></li>');
         }
         $help .= '</ul>';
         $help .= '<div style="margin-left:20px">';
         $help .= __('* to control which configuration data is uploaded, see Permissions > Settings > Install > Help', 'pp');
         $help .= '</div>';
     }
     echo $help;
 }
예제 #7
0
 function flt_hide_pp_only_roles($roles)
 {
     if ($pp_only = (array) pp_get_option('supplemental_role_defs')) {
         global $pp_role_defs;
         if (!empty($_REQUEST['user_id'])) {
             // display role already set for this user, regardless of pp_only setting
             $user = new WP_User((int) $_REQUEST['user_id']);
             if (!empty($user->roles)) {
                 $pp_only = array_diff($pp_only, $user->roles);
             }
         }
         $roles = array_diff_key($roles, array_fill_keys($pp_only, true));
     }
     return $roles;
 }
예제 #8
0
 public static function deactivate_key()
 {
     if (PP_MULTISITE && !is_super_admin() && (pp_is_network_activated(PPC_BASENAME) || pp_is_mu_plugin(PPC_FILE))) {
         return;
     }
     require_once dirname(__FILE__) . '/plugin_pp.php';
     $support_key = pp_get_option('support_key');
     $request_vars = array('key' => $support_key[1], 'site' => site_url(''));
     $response = PP_Plugin_Status::callhome('deactivate-key', $request_vars);
     $result = json_decode($response);
     if ($result[0] == "0") {
         pp_delete_option('support_key');
     }
     echo $response;
     exit;
 }
예제 #9
0
 public static function can_set_exceptions($operation, $for_item_type, $args)
 {
     $defaults = array('item_id' => 0, 'via_item_source' => 'post', 'via_item_type' => '', 'for_item_source' => 'post');
     extract(array_merge($defaults, $args), EXTR_SKIP);
     if (!($is_administrator = pp_is_user_administrator())) {
         $enabled = 'read' == $operation ? pp_get_option('non_admins_set_read_exceptions') : pp_get_option('non_admins_set_edit_exceptions');
         if (!$enabled) {
             return false;
         }
     }
     if (in_array($via_item_source, array('post', 'term')) && 'read' == $operation) {
         $can = $is_administrator || current_user_can('pp_set_read_exceptions');
     } else {
         $can = false;
     }
     // also filter for Administrators to account for non-applicable operations
     return apply_filters('pp_can_set_exceptions', $can, $operation, $for_item_type, array_merge($args, compact('is_administrator')));
 }
function _pp_flt_map_media_meta_cap($caps, $cap, $user_id, $args)
{
    if (!empty($args[0])) {
        $post = is_object($args[0]) ? $args[0] : get_post($args[0]);
        if ($post && 'attachment' == $post->post_type) {
            if (!empty($post->post_parent)) {
                $post_status = get_post_status($post->ID);
            } elseif ('inherit' == $post->post_status) {
                $post_status = pp_get_option('unattached_files_private') ? 'private' : 'publish';
            } else {
                $post_status = $post->post_status;
            }
            $post_type = get_post_type_object($post->post_type);
            $post_author_id = $post->post_author;
            $caps = array_diff($caps, (array) $cap);
            switch ($cap) {
                case 'read_post':
                case 'read_page':
                    $status_obj = get_post_status_object($post_status);
                    if ($status_obj->public || $status_obj->private && $user_id == $post_author_id) {
                        $caps[] = $post_type->cap->read;
                        break;
                    }
                    // If no author set yet, default to current user for cap checks.
                    if (!$post_author_id) {
                        $post_author_id = $user_id;
                    }
                    if ($status_obj->private) {
                        $caps[] = $post_type->cap->read_private_posts;
                    } else {
                        $caps = map_meta_cap('edit_post', $user_id, $post->ID);
                    }
                    $caps = apply_filters('pp_map_attachment_read_caps', $caps, $post, $user_id);
                    break;
                default:
                    require_once dirname(__FILE__) . '/media-edit-metacap-workaround_pp.php';
                    $args = array_merge($args, compact('post', 'post_status', 'post_type', 'post_author_id'));
                    $caps = _ppff_flt_map_media_edit_meta_cap($caps, $cap, $user_id, $args);
            }
        }
    }
    return $caps;
}
예제 #11
0
파일: api_pp.php 프로젝트: severnrescue/web
/**
 * Retrieve the Permission Group object for a WP Role or other metagroup, by providing its name
 * @param string metagroup_type
 * @param string metagroup_id
 * @param array args :
 *   - cols (return format - 'all' | 'id')
 * @return object Permission Group (unless cols = 'id')
 *  - ID
 *  - group_name
 *  - group_description
 *  - metagroup_type
 *  - metagroup_id
 */
function pp_get_metagroup($metagroup_type, $metagroup_id, $args = array())
{
    $defaults = array('cols' => 'all');
    extract(array_merge($defaults, $args), EXTR_SKIP);
    global $wpdb;
    $site_key = md5(get_option('site_url') . constant('DB_NAME') . $wpdb->prefix);
    // guard against groups table being imported into a different database (with mismatching options table)
    if (!($buffered_groups = pp_get_option("buffer_metagroup_id_{$site_key}"))) {
        $buffered_groups = array();
    }
    $key = $metagroup_id . ':' . $wpdb->pp_groups;
    // PP setting may change to/from netwide groups after buffering
    if (!isset($buffered_groups[$key])) {
        if ($group = $wpdb->get_row("SELECT * FROM {$wpdb->pp_groups} WHERE metagroup_type = '{$metagroup_type}' AND metagroup_id = '{$metagroup_id}' LIMIT 1")) {
            $group->group_id = $group->ID;
            $group->status = 'active';
            $buffered_groups[$key] = $group;
            pp_update_option("buffer_metagroup_id_{$site_key}", $buffered_groups);
        }
    }
    if ('id' == $cols) {
        return isset($buffered_groups[$key]) ? $buffered_groups[$key]->ID : false;
    } else {
        return isset($buffered_groups[$key]) ? $buffered_groups[$key] : false;
    }
}
예제 #12
0
" />
<?php 
        //echo esc_html( __( 'Posts with a custom Visibility or Editability require a corresponding Permission Group role assignment.', 'pp' ) );
        $pp_groups_list_table->search_box(__('Search Groups', 'pp'), 'group');
        ?>

<?php 
        $pp_groups_list_table->display();
        ?>

</form>

<br class="clear" />

<?php 
        if (defined('BP_VERSION') && !defined('PPCE_VERSION') && pp_get_option('display_extension_hints')) {
            if (0 === validate_plugin("pp-buddypress-role-groups/pp-buddypress-role-groups.php")) {
                $msg = __('To assign roles or exceptions to BuddyPress groups, activate the PP BuddyPress Role Groups', 'pp');
            } elseif (true == pp_key_status()) {
                $msg = sprintf(__('To assign roles or exceptions to BuddyPress groups, %1$sinstall%2$s the PP BuddyPress Role Groups plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>');
            } else {
                $msg = sprintf(__('To assign roles or exceptions to BuddyPress groups, %1$senter%2$s or %3$spurchase%4$s a support key and install the PP BuddyPress Role Groups plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>', '<a href="http://presspermit.com/purchase">', '</a>');
            }
            echo "<div class='pp-ext-promo'>{$msg}</div>";
        }
        ?>

</div>
<?php 
        break;
}
예제 #13
0
 function processAdminGeneral($post)
 {
     global $wp_roles;
     // Create a new role.
     if (!empty($post['CreateRole'])) {
         if ($newrole = $this->createRole($post['create-name'])) {
             ak_admin_notify(__('New role created.', $this->cm->ID));
             $this->cm->current = $newrole;
         } else {
             if (empty($post['create-name']) && (!defined('WPLANG') || !WPLANG)) {
                 ak_admin_error('Error: No role name specified.', $this->cm->ID);
             } else {
                 ak_admin_error(__('Error: Failed creating the new role.', $this->cm->ID));
             }
         }
         // Copy current role to a new one.
     } elseif (!empty($post['CopyRole'])) {
         $current = get_role($post['current']);
         if ($newrole = $this->createRole($post['copy-name'], $current->capabilities)) {
             ak_admin_notify(__('New role created.', $this->cm->ID));
             $this->cm->current = $newrole;
         } else {
             if (empty($post['copy-name']) && (!defined('WPLANG') || !WPLANG)) {
                 ak_admin_error('Error: No role name specified.', $this->cm->ID);
             } else {
                 ak_admin_error(__('Error: Failed creating the new role.', $this->cm->ID));
             }
         }
         // Save role changes. Already saved at start with self::saveRoleCapabilities().
     } elseif (!empty($post['SaveRole'])) {
         if (MULTISITE) {
             global $wp_roles;
             if (method_exists($wp_roles, 'reinit')) {
                 $wp_roles->reinit();
             }
         }
         $this->saveRoleCapabilities($post['current'], $post['caps'], $post['level']);
         if (defined('PP_ACTIVE')) {
             // log customized role caps for subsequent restoration
             // for bbPress < 2.2, need to log customization of roles following bbPress activation
             $plugins = function_exists('bbp_get_version') && version_compare(bbp_get_version(), '2.2', '<') ? array('bbpress.php') : array();
             // back compat
             if (!($customized_roles = get_option('pp_customized_roles'))) {
                 $customized_roles = array();
             }
             $customized_roles[$post['role']] = (object) array('caps' => array_map('boolval', $post['caps']), 'plugins' => $plugins);
             update_option('pp_customized_roles', $customized_roles);
             global $wpdb;
             $wpdb->query("UPDATE {$wpdb->options} SET autoload = 'no' WHERE option_name = 'pp_customized_roles'");
         }
         // Create New Capability and adds it to current role.
     } elseif (!empty($post['AddCap'])) {
         if (MULTISITE) {
             global $wp_roles;
             if (method_exists($wp_roles, 'reinit')) {
                 $wp_roles->reinit();
             }
         }
         $role = get_role($post['current']);
         $role->name = $post['current'];
         // bbPress workaround
         if ($newname = $this->createNewName($post['capability-name'])) {
             $role->add_cap($newname['name']);
             $this->cm->message = __('New capability added to role.');
             // for bbPress < 2.2, need to log customization of roles following bbPress activation
             $plugins = function_exists('bbp_get_version') && version_compare(bbp_get_version(), '2.2', '<') ? array('bbpress.php') : array();
             // back compat
             if (!($customized_roles = get_option('pp_customized_roles'))) {
                 $customized_roles = array();
             }
             $customized_roles[$post['role']] = (object) array('caps' => array_merge($role->capabilities, array($newname['name'] => 1)), 'plugins' => $plugins);
             update_option('pp_customized_roles', $customized_roles);
             global $wpdb;
             $wpdb->query("UPDATE {$wpdb->options} SET autoload = 'no' WHERE option_name = 'pp_customized_roles'");
         } else {
             $this->cm->message = __('Incorrect capability name.');
         }
     } elseif (!empty($post['update_filtered_types'])) {
         if (cme_update_pp_usage()) {
             ak_admin_notify(__('Capability settings saved.', $this->cm->ID));
         } else {
             ak_admin_error(__('Error saving capability settings.', $this->cm->ID));
         }
     } else {
         // TODO: Implement exceptions. This must be a fatal error.
         ak_admin_error(__('Bad form received.', $this->cm->ID));
     }
     if (!empty($newrole) && defined('PP_ACTIVE')) {
         if (!empty($post['CreateRole']) && !empty($_REQUEST['new_role_pp_only']) || !empty($post['CopyRole']) && !empty($_REQUEST['copy_role_pp_only'])) {
             $pp_only = (array) pp_get_option('supplemental_role_defs');
             $pp_only[] = $newrole;
             pp_update_option('supplemental_role_defs', $pp_only);
             _cme_pp_default_pattern_role($newrole);
             pp_refresh_options();
         }
     }
 }
예제 #14
0
 /**
  * Prepare the query variables
  *
  * @access private
  */
 function prepare_query()
 {
     global $wpdb;
     $qv =& $this->query_vars;
     $groups_table = apply_filters('pp_use_groups_table', $wpdb->pp_groups, $this->agent_type);
     if (is_array($qv['fields'])) {
         $qv['fields'] = array_unique($qv['fields']);
         $this->query_fields = array();
         foreach ($qv['fields'] as $field) {
             $this->query_fields[] = $groups_table . '.' . esc_sql($field);
         }
         $this->query_fields = implode(',', $this->query_fields);
     } elseif ('all' == $qv['fields']) {
         $this->query_fields = "{$groups_table}.*";
     } else {
         $this->query_fields = "{$groups_table}.ID";
     }
     $this->query_from = "FROM {$groups_table}";
     $this->query_where = "WHERE 1=1";
     $group_variant = isset($_REQUEST['group_variant']) ? pp_sanitize_key($_REQUEST['group_variant']) : '';
     $group_variant = apply_filters('pp_query_group_variant', $group_variant);
     $require_meta_types = array();
     if ('wp_role' == $group_variant) {
         $require_meta_types[] = 'wp_role';
     }
     if ($require_meta_types) {
         $this->query_where .= " AND {$groups_table}.metagroup_type IN ('" . implode("','", $require_meta_types) . "')";
     }
     $skip_meta_types = array();
     if ($group_variant && 'wp_role' != $group_variant) {
         $skip_meta_types[] = 'wp_role';
     } else {
         $pp_only_roles = (array) pp_get_option('supplemental_role_defs');
         if (defined('CAPSMAN_ENH_VERSION') && version_compare(CAPSMAN_ENH_VERSION, '1.4.10', '<')) {
             // version 1.4.9 and earlier stored redundant elements
             $_pp_only_roles = (array) $pp_only_roles;
             $pp_only_roles = array_unique($pp_only_roles);
             if (count($pp_only_roles) != count($_pp_only_roles)) {
                 pp_update_option('supplemental_role_defs', $pp_only_roles);
             }
         }
         if (pp_get_option('anonymous_unfiltered')) {
             $pp_only_roles = array_merge($pp_only_roles, array('wp_anon', 'wp_all'));
         }
         $pp_only_roles = implode("','", $pp_only_roles);
         $this->query_where .= " AND ( ( {$groups_table}.metagroup_type != 'wp_role' ) OR ( {$groups_table}.metagroup_id NOT IN ( '{$pp_only_roles}' ) ) )";
     }
     if ($skip_meta_types) {
         $this->query_where .= " AND {$groups_table}.metagroup_type NOT IN ('" . implode("','", $skip_meta_types) . "')";
     }
     global $wp_roles;
     $admin_roles = array();
     if (isset($wp_roles->role_objects)) {
         foreach (array_keys($wp_roles->role_objects) as $wp_role_name) {
             if (!empty($wp_roles->role_objects[$wp_role_name]->capabilities['pp_administer_content']) || !empty($wp_roles->role_objects[$wp_role_name]->capabilities['pp_unfiltered'])) {
                 $admin_roles[$wp_role_name] = true;
             }
         }
     }
     if ($admin_roles) {
         $this->query_where .= " AND {$groups_table}.metagroup_id NOT IN ('" . implode("','", array_keys($admin_roles)) . "')";
     }
     $skip_meta_ids = array();
     if (!defined('RVY_VERSION') || defined('SCOPER_DEFAULT_MONITOR_GROUPS') || defined('PP_DEFAULT_MONITOR_GROUPS')) {
         $skip_meta_ids = array_merge($skip_meta_ids, array('rv_pending_rev_notice_ed_nr_', 'rv_scheduled_rev_notice_ed_nr_'));
     }
     if ($skip_meta_ids) {
         $this->query_where .= " AND {$groups_table}.metagroup_id NOT IN ('" . implode("','", $skip_meta_ids) . "')";
     }
     //$this->query_where .= "AND $groups_table.metagroup_id != 'wp_anon'";
     // sorting
     if ('ID' == $qv['orderby'] || 'id' == $qv['orderby']) {
         $orderby = 'ID';
     } else {
         $orderby = 'group_name';
     }
     $qv['order'] = strtoupper($qv['order']);
     if ('ASC' == $qv['order']) {
         $order = 'ASC';
     } else {
         $order = 'DESC';
     }
     $this->query_orderby = "ORDER BY {$orderby} {$order}";
     // limit
     if ($qv['number']) {
         if ($qv['offset']) {
             $this->query_limit = $wpdb->prepare("LIMIT %d, %d", $qv['offset'], $qv['number']);
         } else {
             $this->query_limit = $wpdb->prepare("LIMIT %d", $qv['number']);
         }
     }
     $search = trim($qv['search']);
     if ($search) {
         $leading_wild = ltrim($search, '*') != $search;
         $trailing_wild = rtrim($search, '*') != $search;
         if ($leading_wild && $trailing_wild) {
             $wild = 'both';
         } elseif ($leading_wild) {
             $wild = 'leading';
         } elseif ($trailing_wild) {
             $wild = 'trailing';
         } else {
             $wild = false;
         }
         if ($wild) {
             $search = trim($search, '*');
         }
         if (is_numeric($search)) {
             $search_columns = array('ID');
         } else {
             $search_columns = array('group_name');
         }
         $this->query_where .= $this->get_search_sql($search, $search_columns, $wild);
     }
     // if user cannot edit all groups, filter displayed groups based on group-specific role assignments
     if (!pp_is_user_administrator()) {
         $reqd_caps = apply_filters('pp_edit_groups_reqd_caps', 'pp_manage_members', 'edit-group');
         if (!current_user_can($reqd_caps)) {
             global $wpdb, $pp_current_user;
             $exc_agent_type = in_array($this->agent_type, array('pp_group', 'pp_net_group')) ? 'pp_group' : $this->agent_type;
             $group_ids = isset($pp_current_user->except['manage_' . $exc_agent_type][$exc_agent_type]['']['additional'][$exc_agent_type]['']) ? $pp_current_user->except['manage_' . $exc_agent_type][$exc_agent_type]['']['additional'][$exc_agent_type][''] : array();
             $this->query_where .= " AND {$groups_table}.ID IN ('" . implode("','", $group_ids) . "')";
         }
     }
     $blog_id = absint($qv['blog_id']);
     if (!empty($qv['include'])) {
         $ids = implode(',', wp_parse_id_list($qv['include']));
         $this->query_where .= " AND {$groups_table}.ID IN ({$ids})";
     } elseif (!empty($qv['exclude'])) {
         $ids = implode(',', wp_parse_id_list($qv['exclude']));
         $this->query_where .= " AND {$groups_table}.ID NOT IN ({$ids})";
     }
     do_action_ref_array('pp_pre_group_query', array(&$this));
 }
예제 #15
0
function _pp_support_upload($args = array())
{
    require_once dirname(__FILE__) . '/plugin_pp.php';
    //$args['post_id'] = 1;
    //$args['term_taxonomy_id'] = 1;
    $request_vars = array('site' => site_url(''));
    global $wpdb;
    $ok = (array) pp_get_option('support_data');
    $pp_config = array();
    $pp_old = array();
    //if ( ! empty( $ok['pp_options'] ) ) {
    global $pp_site_options;
    $options = array();
    foreach (array('default_category', 'permalink_structure', '_bbp_default_role', '_bbp_private_forums', '_bbp_use_wp_editor', '_bbp_allow_anonymous', '_bbp_allow_global_access', '_bbp_db_version', 'bp-active-components', 'users_can_register', 'comment_moderation', 'comment_registration', 'registration', 'default_role', 'db_version', 'enable_app', 'enable_xmlrpc', 'sticky_posts', 'initial_db_version') as $opt) {
        $options[$opt] = get_option($opt);
    }
    ksort($options);
    $pp_config['options'] = gzcompress(serialize($options));
    ksort($pp_site_options);
    $pp_config['pp_options'] = gzcompress(serialize($pp_site_options));
    $pp_config['rvy_options'] = gzcompress(serialize($wpdb->get_results("SELECT option_name, option_value, option_id FROM {$wpdb->options} WHERE option_name LIKE 'rvy_%' ORDER BY option_name", ARRAY_N)));
    if (PP_MULTISITE) {
        global $pp_netwide_options, $pp_net_options;
        if (is_array($pp_net_options)) {
            ksort($pp_net_options);
            if (!empty($pp_net_options)) {
                $pp_config['pp_net_options'] = gzcompress(serialize($pp_net_options));
            }
        }
        ksort($pp_netwide_options);
        if (!empty($pp_netwide_options)) {
            $pp_config['pp_netwide_options'] = gzcompress(serialize($pp_netwide_options));
        }
        $sitemeta_table = $wpdb->base_prefix . 'sitemeta';
        if ($rvy_net_options = $wpdb->get_results("SELECT meta_key, meta_value, site_id, meta_id FROM {$sitemeta_table} WHERE meta_key LIKE 'rvy_%' ORDER BY meta_key", ARRAY_N)) {
            $pp_config['rvy_net_options'] = gzcompress(serialize($rvy_net_options));
        }
    }
    //}
    if (!empty($ok['wp_roles_types'])) {
        global $wp_post_types, $wp_taxonomies, $wp_post_statuses, $wp_roles;
        // strip labels, label_count props
        $pp_config['wp_roles'] = gzcompress(serialize($wp_roles));
        // strip out labels and some other properties for perf
        foreach (array('wp_post_types', 'wp_taxonomies', 'wp_post_statuses') as $var) {
            $wp_data = ${$var};
            $arr = array();
            foreach (array_keys($wp_data) as $member) {
                $arr[$member] = array();
                foreach (array_keys(get_object_vars($wp_data[$member])) as $prop) {
                    if (!in_array($prop, array('labels', 'label_count', 'can_export', 'description'))) {
                        $arr[$member][$prop] = $wp_data[$member]->{$prop};
                    }
                }
            }
            $pp_config[$var] = gzcompress(serialize($arr));
        }
    }
    if (!empty($ok['theme'])) {
        $th = wp_get_theme();
        $theme_data = array();
        foreach (array('name', 'title', 'version', 'parent_theme', 'template') as $prop) {
            $theme_data[$prop] = $th->{$prop};
        }
        $theme_data['errors'] = $th->errors();
        $pp_config['theme'] = gzcompress(serialize($theme_data));
        $pp_config['widgets'] = gzcompress(serialize((array) get_option('sidebars_widgets')));
    }
    if (file_exists(ABSPATH . 'wp-admin/includes/plugin.php')) {
        include_once ABSPATH . 'wp-admin/includes/plugin.php';
    }
    if (!empty($ok['active_plugins']) && function_exists('get_plugin_data')) {
        $active_plugins = array();
        foreach (wp_get_active_and_valid_plugins() as $file) {
            // reduce to relative path for privacy
            $slug = array();
            if ($part = @basename(dirname(dirname(dirname($file))))) {
                $slug[] = $part;
            }
            if ($part = @basename(dirname(dirname($file)))) {
                $slug[] = $part;
            }
            if ($part = @basename(dirname($file))) {
                $slug[] = $part;
            }
            $slug[] = basename($file);
            $slug = implode('/', $slug);
            $active_plugins[$slug] = array_diff_key(get_plugin_data($file), array_fill_keys(array('Author', 'AuthorURI', 'TextDomain', 'DomainPath', 'Title', 'AuthorName', 'Description'), true));
        }
        $pp_config['active_plugins'] = gzcompress(serialize($active_plugins));
        if (function_exists('get_dropins')) {
            $pp_config['dropins'] = gzcompress(serialize(get_dropins()));
        }
    }
    if (!empty($ok['installed_plugins']) && function_exists('get_plugins')) {
        if ($installed_plugins = get_plugins()) {
            foreach (array_keys($installed_plugins) as $key) {
                $installed_plugins[$key] = array_diff_key($installed_plugins[$key], array_fill_keys(array('Author', 'AuthorURI', 'TextDomain', 'DomainPath', 'Title', 'AuthorName', 'Description', 'PluginURI', 'Network'), true));
            }
            $pp_config['installed_plugins'] = gzcompress(serialize($installed_plugins));
        }
    }
    // if uploading for a specific post or term
    if (!empty($args['term_taxonomy_id']) && !empty($ok['post_data'])) {
        $pp_config['term_data'] = gzcompress(serialize($wpdb->get_results($wpdb->prepare("SELECT term_taxonomy_id, taxonomy, term_id FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id = %d", $args['term_taxonomy_id']), ARRAY_A)));
    }
    if (!empty($args['post_id']) && !empty($ok['post_data'])) {
        $pp_config['post_data'] = gzcompress(serialize($wpdb->get_row($wpdb->prepare("SELECT ID, post_type, post_author, post_status, post_parent FROM {$wpdb->posts} WHERE ID = %d LIMIT 1", $args['post_id']))));
        $post_terms = $wpdb->get_results($wpdb->prepare("SELECT tr.term_taxonomy_id, tr.object_id, tt.taxonomy, tt.term_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id = %d ORDER BY tt.taxonomy, tt.term_taxonomy_id", $args['post_id']), ARRAY_A);
        $pp_config['post_terms'] = gzcompress(serialize($post_terms));
        if (!empty($ok['pp_permissions'])) {
            if (!empty($wpdb->pp_conditions) && !empty($pp_config['post_terms'])) {
                $pp_config['pp_post_conditions'] = gzcompress(serialize($wpdb->get_results("SELECT * FROM {$wpdb->pp_conditions} WHERE scope = 'term' AND item_id IN ('" . implode("','", array_keys($post_terms)) . "') ORDER BY item_source, item_id, attribute, scope", ARRAY_N)));
            }
        }
    }
    if (!empty($ok['pp_permissions'])) {
        $pp_config['ppc_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id as id, agent_id AS agent, agent_type AS a_type, role_name as r, assigner_id as by_id  FROM {$wpdb->ppc_roles} ORDER BY assignment_id DESC LIMIT 5000")));
        $pp_config['ppc_exceptions'] = gzcompress(serialize($wpdb->get_results("SELECT e.*, COUNT(i.eitem_id) AS count FROM {$wpdb->ppc_exceptions} AS e INNER JOIN {$wpdb->ppc_exception_items} AS i ON e.exception_id = i.exception_id GROUP BY e.exception_id ORDER BY e.exception_id DESC LIMIT 5000", ARRAY_N)));
        $pp_config['ppc_exception_items'] = gzcompress(serialize($wpdb->get_results("SELECT eitem_id AS eitem, exception_id AS eid, item_id AS item, assign_for AS a_for, inherited_from AS inh FROM {$wpdb->ppc_exception_items} ORDER BY eitem_id DESC LIMIT 10000", ARRAY_N)));
    }
    if (!empty($ok['pp_groups'])) {
        $pp_config['pp_groups'] = gzcompress(serialize($wpdb->get_results("SELECT ID, group_name AS gname, metagroup_id AS mid, metagroup_type AS mtype FROM {$wpdb->pp_groups} ORDER BY ID DESC LIMIT 1000", ARRAY_N)));
        if (PP_MULTISITE) {
            $wpdb->pp_groups_netwide = $wpdb->base_prefix . 'pp_groups';
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->pp_groups_netwide}'"))) {
                $pp_config['pp_net_groups'] = gzcompress(serialize($wpdb->get_results("SELECT ID, group_name AS gname, metagroup_id AS mid, metagroup_type AS mtype FROM {$wpdb->pp_groups_netwide} ORDER BY ID DESC LIMIT 1000", ARRAY_N)));
            }
        }
        if (!empty($wpdb->pp_circles)) {
            $pp_config['pp_circles'] = gzcompress(serialize($wpdb->get_results("SELECT * FROM {$wpdb->pp_circles} ORDER BY group_type, group_id", ARRAY_N)));
        }
    }
    if (!empty($ok['pp_group_members'])) {
        $pp_config['pp_wp_group_members'] = gzcompress(serialize($wpdb->get_results("SELECT gm.group_id AS g, gm.user_id AS u FROM {$wpdb->pp_group_members} AS gm INNER JOIN {$wpdb->pp_groups} AS g ON gm.group_id = g.ID AND g.metagroup_type = 'wp_role' ORDER BY gm.add_date_gmt DESC LIMIT 5000", ARRAY_N)));
        $pp_config['pp_group_members'] = gzcompress(serialize($wpdb->get_results("SELECT gm.group_id AS g, gm.user_id AS u FROM {$wpdb->pp_group_members} AS gm INNER JOIN {$wpdb->pp_groups} AS g ON gm.group_id = g.ID AND g.metagroup_type != 'wp_role' ORDER BY gm.add_date_gmt DESC LIMIT 2500", ARRAY_N)));
        if (PP_MULTISITE) {
            $wpdb->pp_group_members_netwide = $wpdb->base_prefix . 'pp_group_members';
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->pp_group_members_netwide}'"))) {
                $pp_config['pp_net_group_members'] = gzcompress(serialize($wpdb->get_results("SELECT group_id AS g, user_id AS u FROM {$wpdb->pp_group_members_netwide} LIMIT 2500", ARRAY_N)));
            }
        }
    }
    $wpdb->ppi_imported = $wpdb->prefix . 'ppi_imported';
    if (@mysql_num_rows(@mysql_query("SHOW TABLES LIKE '{$wpdb->ppi_imported}'"))) {
        $wpdb->ppi_runs = $wpdb->prefix . 'ppi_runs';
        $wpdb->ppi_errors = $wpdb->prefix . 'ppi_errors';
    }
    if (!empty($wpdb->ppi_runs)) {
        if (!empty($ok['ppc_roles']) || !empty($ok['pp_imports'])) {
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->ppi_runs}'"))) {
                $pp_old['ppi_runs'] = gzcompress(serialize($wpdb->get_results("SELECT * FROM {$wpdb->ppi_runs} ORDER BY import_date", ARRAY_N)));
            }
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->ppi_errors}'"))) {
                $pp_old['ppi_errors'] = gzcompress(serialize($wpdb->get_results("SELECT * FROM {$wpdb->ppi_errors} ORDER BY run_id, ID", ARRAY_N)));
            }
        }
        if (!empty($ok['pp_imports'])) {
            if ($ppi_ver = (array) get_option('ppi_version')) {
                $prefix = PP_MULTISITE ? $wpdb->base_prefix : $wpdb->prefix;
                if ($wpdb->query("SHOW COLUMNS FROM {$wpdb->ppi_imported} LIKE 'source_tbl'")) {
                    if (defined('PPI_LEGACY_UPLOAD') && $wpdb->query("SHOW COLUMNS FROM {$wpdb->ppi_imported} LIKE 'source_table'")) {
                        $extra_cols = ", REPLACE( source_table, '{$prefix}', '' ), REPLACE( import_table, '{$prefix}', '' )";
                    } else {
                        $extra_cols = '';
                    }
                    $pp_old['ppi_imported'] = gzcompress(serialize($wpdb->get_results("SELECT run_id, source_tbl AS src, source_id AS src_id, rel_id, import_tbl AS tbl, import_id AS to_id{$extra_cols} FROM {$wpdb->ppi_imported} ORDER BY run_id DESC, source_tbl, source_id LIMIT 25000", ARRAY_N)));
                } else {
                    $pp_old['ppi_imported'] = gzcompress(serialize($wpdb->get_results("SELECT run_id, REPLACE( source_table, '{$prefix}', '' ) AS src, source_id AS src_id, rel_id, REPLACE( import_table, '{$prefix}', '' ) AS tbl, import_id AS to_id FROM {$wpdb->ppi_imported} ORDER BY run_id DESC, source_table, source_id LIMIT 25000", ARRAY_N)));
                }
            }
        }
    }
    if (!empty($ok['pp_imports'])) {
        // RS
        $wpdb->user2role2object_rs = $wpdb->prefix . 'user2role2object_rs';
        $wpdb->role_scope_rs = $wpdb->prefix . 'role_scope_rs';
        $wpdb->groups_rs = $wpdb->prefix . 'groups_rs';
        $wpdb->user2group_rs = $wpdb->prefix . 'user2group_rs';
        //if ( ! empty( $ok['pp_options'] ) ) {
        $pp_old['rs_options'] = gzcompress(serialize($wpdb->get_results("SELECT option_name AS name, option_value AS val, option_id AS id FROM {$wpdb->options} WHERE option_name LIKE 'scoper_%' ORDER BY option_name", ARRAY_N)));
        if (PP_MULTISITE) {
            $pp_old['rs_net_options'] = gzcompress(serialize($wpdb->get_results("SELECT meta_key AS mkey, meta_value AS val, site_id AS site, meta_id AS mid FROM {$sitemeta_table} WHERE meta_key LIKE 'scoper_%' ORDER BY meta_key", ARRAY_N)));
        }
        //}
        if (!empty($ok['pp_permissions'])) {
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->user2role2object_rs}'"))) {
                $pp_old['rs_wp_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, user_id, role_name AS r, date_limited AS dlim, content_date_limited AS clim FROM {$wpdb->user2role2object_rs} WHERE scope = 'blog' AND role_type = 'wp' ORDER BY assignment_id DESC LIMIT 5000", ARRAY_N)));
                $pp_old['rs_site_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, user_id, group_id, role_name AS r, date_limited AS dlim, content_date_limited AS clim FROM {$wpdb->user2role2object_rs} WHERE scope = 'blog' ORDER BY assignment_id DESC LIMIT 2500", ARRAY_N)));
                $pp_old['rs_term_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, user_id, group_id, role_name AS r, src_or_tx_name AS st_name, obj_or_term_id AS ot_id, assign_for AS a_for, inherited_from AS inh, date_limited AS dlim, content_date_limited AS clim FROM {$wpdb->user2role2object_rs} WHERE scope = 'term' ORDER BY assignment_id DESC LIMIT 1000", ARRAY_N)));
                $pp_old['rs_obj_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, user_id, group_id, role_name AS r, obj_or_term_id AS ot_id, assign_for AS a_for, inherited_from AS inh, date_limited AS dlim FROM {$wpdb->user2role2object_rs} WHERE scope = 'object' ORDER BY assignment_id DESC LIMIT 10000", ARRAY_N)));
            }
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->role_scope_rs}'"))) {
                $pp_old['rs_restrictions'] = gzcompress(serialize($wpdb->get_results("SELECT requirement_id AS id, role_name AS r, topic AS topic, src_or_tx_name AS st_name, obj_or_term_id AS ot_id, max_scope, require_for AS r_for, inherited_from AS inh FROM {$wpdb->role_scope_rs} ORDER BY requirement_id DESC LIMIT 5000", ARRAY_N)));
            }
        }
        if (!empty($ok['pp_groups'])) {
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->groups_rs}'"))) {
                $pp_old['rs_groups'] = gzcompress(serialize($wpdb->get_results("SELECT ID, group_name AS name, group_meta_id AS gmid FROM {$wpdb->groups_rs} ORDER BY ID DESC LIMIT 500", ARRAY_N)));
            }
            if (PP_MULTISITE) {
                $wpdb->net_groups_rs = $wpdb->base_prefix . 'groups_rs';
                if (!empty($ok['pp_groups']) && mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->net_groups_rs}'"))) {
                    $pp_old['rs_net_groups'] = gzcompress(serialize($wpdb->get_results("SELECT ID, group_name AS name, group_meta_id AS gmid FROM {$wpdb->net_groups_rs} ORDER BY ID DESC LIMIT 500", ARRAY_N)));
                }
            }
        }
        if (!empty($ok['pp_group_members']) && mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->user2group_rs}'"))) {
            $pp_old['rs_group_members'] = gzcompress(serialize($wpdb->get_results("SELECT group_id AS gid, user_id AS uid FROM {$wpdb->user2group_rs} LIMIT 5000", ARRAY_N)));
        }
        // PP One
        $wpdb->pp_roles = $wpdb->prefix . 'pp_roles';
        $wpdb->pp_conditions = $wpdb->prefix . 'pp_conditions';
        $wpdb->pp_circles = $wpdb->prefix . 'pp_circles';
        if (!empty($ok['pp_groups']) && empty($pp_config['pp_circles']) && mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->pp_circles}'"))) {
            $pp_old['pp_circles'] = gzcompress(serialize($wpdb->get_results("SELECT * FROM {$wpdb->pp_circles} ORDER BY group_type, group_id", ARRAY_N)));
        }
        if (!empty($ok['pp_permissions']) && mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->pp_roles}'"))) {
            $pp_old['pp1_site_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, group_type AS gtype, group_id AS gid, role_name AS r FROM {$wpdb->pp_roles} WHERE scope = 'site' ORDER BY assignment_id DESC LIMIT 5000", ARRAY_N)));
            $pp_old['pp1_term_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, group_type AS gtype, group_id AS gid, role_name AS r, item_id, assign_for AS a_for, inherited_from AS inh FROM {$wpdb->pp_roles} WHERE scope = 'term' ORDER BY assignment_id DESC LIMIT 1000", ARRAY_N)));
            $pp_old['pp1_obj_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, group_type AS gtype, group_id AS gid, role_name AS r, item_id, assign_for AS a_for, inherited_from AS inh FROM {$wpdb->pp_roles} WHERE scope = 'object' ORDER BY assignment_id DESC LIMIT 10000", ARRAY_N)));
        }
    }
    if (!empty($ok['error_log'])) {
        $base_path = str_replace('\\', '/', ABSPATH);
        $base_path_back = str_replace('/', '\\', ABSPATH);
        if ($path = _pp_get_errlog_path()) {
            $size = filesize($path);
            if (defined('PPI_ERROR_LOG_UPLOAD_LIMIT') && PPI_ERROR_LOG_UPLOAD_LIMIT > 1000 && PPI_ERROR_LOG_UPLOAD_LIMIT < 750000) {
                $limit = PPI_ERROR_LOG_UPLOAD_LIMIT;
            } else {
                $limit = 125000;
            }
            // with typical compression rate of 15 and base64 encoding, compressed size ~ 10k
            if ($size) {
                if ($size > $limit) {
                    $fp = fopen($path, 'r');
                    fseek($fp, $size - $limit);
                    $data = fread($fp, $size);
                } else {
                    $data = file_get_contents($path);
                }
                // trim to relative paths for privacy
                if ($base_path) {
                    $data = str_replace($base_path, './', $data);
                }
                if ($base_path_back) {
                    $data = str_replace($base_path_back, '.\\', $data);
                }
                $error_log = base64_encode(gzcompress($data));
            }
        }
    } else {
        $error_log = '';
    }
    $hashes = array();
    foreach (array('pp_config', 'pp_old', 'error_log') as $var) {
        if (!empty(${$var})) {
            if (PP_MULTISITE && 'error_log' != $var) {
                global $blog_id;
                ${$var}['site'] = $blog_id;
            }
            ${$var} = base64_encode(gzcompress(serialize(${$var})));
            $hashes[$var] = md5(${$var});
        }
        unset($var);
    }
    if ($response = PP_Plugin_Status::callhome('config-check', $request_vars, $hashes)) {
        $need_data = json_decode($response);
    } else {
        $need_data = false;
    }
    if ($need_data) {
        $post_data = array();
        // add each data array to $post_data unless config-check did not indicate it is needed
        if (in_array('pp_config', $need_data)) {
            $post_data['pp_config'] = $pp_config;
        }
        if (in_array('pp_old', $need_data)) {
            $post_data['pp_old'] = $pp_old;
        }
        if (in_array('error_log', $need_data)) {
            $post_data['error_log'] = $error_log;
        }
        $response = PP_Plugin_Status::callhome('config-upload', $request_vars, $post_data);
        return $response;
    } else {
        return -1;
    }
}
예제 #16
0
 function update_page_options($args)
 {
     global $pp_default_options;
     do_action('pp_update_options', $args);
     $default_prefix = apply_filters('pp_options_apply_default_prefix', '', $args);
     foreach (explode(',', $_POST['all_options']) as $option_basename) {
         $value = isset($_POST[$option_basename]) ? $_POST[$option_basename] : '';
         if (!is_array($value)) {
             $value = trim($value);
         }
         if ('beta_updates' == $option_basename) {
             if (stripslashes_deep($value) != pp_get_option('beta_updates')) {
                 // force regeneration and buffering of file update urls
                 delete_site_transient('update_plugins');
                 pp_get_version_info(true, false, true);
                 wp_update_plugins();
             }
         }
         pp_update_option($default_prefix . $option_basename, stripslashes_deep($value), $args);
     }
     foreach (explode(',', $_POST['all_otype_options']) as $option_basename) {
         // support stored default values (to apply to any post type which does not have an explicit setting)
         if (isset($_POST[$option_basename][0])) {
             $_POST[$option_basename][''] = $_POST[$option_basename][0];
             unset($_POST[$option_basename][0]);
         }
         $value = isset($pp_default_options[$option_basename]) ? $pp_default_options[$option_basename] : array();
         if ($current = pp_get_option($option_basename)) {
             // retain setting for any types which were previously enabled for filtering but are currently not registered
             $value = array_merge($value, $current);
         }
         if (isset($_POST[$option_basename])) {
             $value = array_merge($value, $_POST[$option_basename]);
         }
         foreach (array_keys($value) as $key) {
             $value[$key] = stripslashes_deep($value[$key]);
         }
         pp_update_option($default_prefix . $option_basename, $value, $args);
     }
     if (!empty($_POST['post_blockage_priority'])) {
         // once this is switched on manually, don't ever default-disable it again
         if (get_option('ppperm_legacy_exception_handling')) {
             delete_option('ppperm_legacy_exception_handling');
             require_once dirname(__FILE__) . '/admin/admin-load_pp.php';
             _pp_dashboard_dismiss_msg();
         }
     }
     if (!empty($_POST['do_group_index_drop'])) {
         if (get_option('pp_need_group_index_drop')) {
             require_once dirname(__FILE__) . '/admin/update_pp.php';
             PP_Updated::do_index_drop(PP_Updated::drop_group_indexes_sql(), 'pp_did_group_index_drop');
             delete_option('pp_need_group_index_drop');
         }
     }
 }
예제 #17
0
    function display($agent_type, $id_suffix, $current_selections = array(), $args = array())
    {
        $defaults = array('agent_id' => 0, 'context' => '', 'label_select' => _x('Select &gt;', 'user', 'pp'), 'label_unselect' => _x('&lt; Unselect', 'user', 'pp'), 'label_selections' => __('Current Selections:', 'pp'), 'display_stored_selections' => true, 'create_dropdowns' => false, 'width' => '', 'width_current' => '', 'label_headline' => true, 'multi_select' => true, 'use_selection_js' => true);
        $args = apply_filters('pp_agents_selection_ui_args', array_merge($defaults, $args), $agent_type, $id_suffix);
        extract($args, EXTR_SKIP);
        $width = $width ? "width:{$width}px;" : '';
        $this->register_ajax_js($agent_type, $id_suffix, $context, $agent_id, $args);
        if ('user' == $agent_type) {
            if (defined('PP_USER_LASTNAME_SEARCH') && !defined('PP_USER_SEARCH_FIELD')) {
                $default_search_field = 'last_name';
            } elseif (defined('PP_USER_SEARCH_FIELD')) {
                $default_search_field = PP_USER_SEARCH_FIELD;
            } else {
                $default_search_field = '';
            }
        }
        if (true === $label_headline) {
            if ('user' == $agent_type) {
                if ($default_search_field) {
                    $search_caption = __(ucwords(str_replace('_', ' ', $default_search_field)), 'pp');
                    $label_headline = sprintf(__('Find Users by %s', 'pp'), $search_caption);
                } else {
                    $label_headline = __('Find Users', 'pp');
                }
            } else {
                $label_headline = __('Select Groups', 'pp');
            }
        }
        ?>
		<table id="pp-agent-selection_<?php 
        echo $id_suffix;
        ?>
-wrapper" class="pp-agents-selection">
		<tr><td id="pp-agent-selection_<?php 
        echo $id_suffix;
        ?>
 " style="vertical-align:top">
		<h4><?php 
        echo $label_headline;
        ?>
</h4>
		<input id="agent_search_text_<?php 
        echo $id_suffix;
        ?>
" type="text" size="8" />
		<button type="button" class="pp-agent-search-submit" id="agent_submit_<?php 
        echo $id_suffix;
        ?>
"><?php 
        echo __ppw("Search");
        ?>
</button>
		
		<?php 
        if ('user' == $agent_type) {
            ?>
			<br />
			<?php 
            $title = !defined('PP_USER_SEARCH_META_FIELDS') && pp_is_user_administrator() && pp_get_option('advanced_options') && pp_get_option('display_hints') ? __('For additional fields, define constant PP_USER_SEARCH_META_FIELDS', 'pp') : '';
            $fields = array('first_name' => __('First Name', 'pp'), 'last_name' => __('Last Name', 'pp'), 'nickname' => __('Nickname', 'pp'));
            if (defined('PP_USER_SEARCH_META_FIELDS')) {
                $custom_fields = str_replace(' ', '', PP_USER_SEARCH_META_FIELDS);
                $custom_fields = explode(',', $custom_fields);
                foreach ($custom_fields as $cfield) {
                    $fields[$cfield] = __(ucwords(str_replace('_', ' ', $cfield)), 'pp');
                }
            }
            if (isset($fields[$default_search_field])) {
                unset($fields[$default_search_field]);
            }
            $ilim = defined('PP_USER_SEARCH_META_FIELDS') ? 6 : 3;
            for ($i = 0; $i < $ilim; $i++) {
                ?>
				<div class="pp-user-meta-search" <?php 
                if ($i > 0 && empty($_GET["pp_search_user_meta_key_{$i}_{$id_suffix}"])) {
                    echo ' style="display:none;"';
                }
                ?>
>
				<select id="pp_search_user_meta_key_<?php 
                echo $i;
                ?>
_<?php 
                echo $id_suffix;
                ?>
">
				<option value=""><?php 
                _e('(user field)', 'pp');
                ?>
</option>
				<?php 
                foreach ($fields as $field => $lbl) {
                    ?>
					<option value="<?php 
                    echo $field;
                    ?>
"><?php 
                    echo $lbl;
                    ?>
</option>
				<?php 
                }
                ?>
				</select>
				&nbsp;
				<input id="pp_search_user_meta_val_<?php 
                echo $i;
                ?>
_<?php 
                echo $id_suffix;
                ?>
" type="text" <?php 
                if (empty($_GET["pp_search_user_meta_key_{$i}_{$id_suffix}"])) {
                    echo 'style="display:none"';
                }
                ?>
 title="<?php 
                echo $title;
                ?>
" size="8" />
				<?php 
                if ($i < $ilim - 1) {
                    ?>
				&nbsp;<span class="pp-usermeta-field-more" <?php 
                    if (empty($_GET["pp_search_user_meta_key_{$i}_{$id_suffix}"])) {
                        echo 'style="display:none"';
                    }
                    ?>
>+</span>
				<?php 
                }
                ?>
				</div>
			<?php 
            }
            ?>
		<?php 
        }
        ?>
		
		<?php 
        if ('user' == $agent_type && pp_get_option('user_search_by_role')) {
            ?>
			<select id="pp_search_role_<?php 
            echo $id_suffix;
            ?>
" class="pp-search-role">
			<option value=""><?php 
            _e('(any WP role)', 'pp');
            ?>
</option>
			<?php 
            wp_dropdown_roles();
            ?>
			</select>
		<?php 
        }
        ?>
		</td>
		
		<?php 
        if ($display_stored_selections) {
            ?>
			<td style="vertical-align:top" class="pp-members-current">
			</td>
		<?php 
        }
        ?>
		
		</tr>
		
		<tr><td>
		<h4><?php 
        _e('Search Results:', 'pp');
        ?>
<img class="waiting" style="display:none;float:right" src="<?php 
        echo esc_url(admin_url('images/wpspin_light.gif'));
        ?>
" alt="" /></h4>
		
		<select id="agent_results_<?php 
        echo $id_suffix;
        ?>
" class="pp_agent_results" <?php 
        if ($multi_select) {
            ?>
multiple="multiple" style="height:160px;<?php 
        } else {
            ?>
style="display:none;<?php 
        }
        echo $width;
        ?>
"></select>
		<span id="agent_msg_<?php 
        echo $id_suffix;
        ?>
"></span>
		</td>

		<?php 
        if ($display_stored_selections) {
            if ($width_current) {
                $width = "width:{$width_current}px;";
            }
            ?>
		<td class="pp-members-current">
		<h4><?php 
            echo $label_selections;
            ?>
</h4>
		
		<select id='<?php 
            echo $id_suffix;
            ?>
' name='<?php 
            echo $id_suffix;
            ?>
[]' multiple='multiple' style='height:160px;<?php 
            echo $width;
            ?>
'>
		
<?php 
            if ('user' == $agent_type) {
                $display_property = defined('PP_USER_RESULTS_DISPLAY_NAME') ? 'display_name' : 'user_login';
            } else {
                $display_property = 'display_name';
            }
            foreach ($current_selections as $agent) {
                $attribs = isset($agent->display_name) && $agent->user_login != $agent->display_name ? 'title="' . esc_attr($agent->display_name) . '"' : '';
                ?>
		<?php 
                $data = apply_filters('pp_agents_selection_ui_attribs', array('attribs' => $attribs, 'user_caption' => $agent->{$display_property}), $agent_type, $id_suffix, $agent);
                ?>
		<option value="<?php 
                echo $agent->ID;
                ?>
" <?php 
                echo $data['attribs'];
                ?>
><?php 
                echo $data['user_caption'];
                ?>
</option>
<?php 
            }
            ?>

		</select><br />
		</td>
		<?php 
        }
        ?>
		
		</tr>
		
		<?php 
        do_action('_pp_agents_selection_ui_select_pre', $id_suffix);
        ?>
		<tr>
		<?php 
        do_action('pp_agents_selection_ui_select_pre', $id_suffix);
        ?>
		

		<td><button type="button" id="select_agents_<?php 
        echo $id_suffix;
        ?>
" class="pp_add" style="float:right<?php 
        if (!$multi_select) {
            ?>
;display:none;<?php 
        }
        ?>
"><?php 
        echo $label_select;
        ?>
</button></td>
		
		<?php 
        if ($display_stored_selections) {
            ?>
		<td class="pp-members-current"><button type="button" id="unselect_agents_<?php 
            echo $id_suffix;
            ?>
" class="pp_remove"><?php 
            echo $label_unselect;
            ?>
</button></td>
		<?php 
        }
        ?>
		
		</tr>
		</table>	
<?php 
        if (!defined('PPM_VERSION') && pp_get_option('display_extension_hints')) {
            if (0 === validate_plugin("pp-membership/pp-membership.php")) {
                $msg = __('To set date limits on group membership, activate the PP Membership plugin.', 'pp');
            } elseif (true == pp_key_status()) {
                $msg = sprintf(__('To set date limits on group membership, %1$sinstall%2$s the PP Membership plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>');
            } else {
                $msg = sprintf(__('To set date limits on group membership, %1$senter%2$s or %3$spurchase%4$s a support key and install the PP Membership plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>', '<a href="http://presspermit.com/purchase">', '</a>');
            }
            echo "<div class='pp-ext-promo'>{$msg}</div>";
        }
        $csv = $current_selections ? implode(',', array_keys($current_selections)) : '';
        $csv = apply_filters('pp_agents_selection_ui_csv', $csv, $id_suffix, $current_selections);
        ?>
		<input type="hidden" id="<?php 
        echo $id_suffix;
        ?>
_csv" name="<?php 
        echo $id_suffix;
        ?>
_csv" value="<?php 
        echo $csv;
        ?>
" />
		<?php 
    }
 function load_exceptions($via_item_source, $for_item_source, $via_item_type, $item_id, $args = array())
 {
     global $wpdb, $wp_roles;
     $this->loaded_item_id = $item_id;
     if (!isset($this->current_exceptions)) {
         $this->current_exceptions = array();
         $this->agent_info = array();
     }
     $args = array_merge(compact('for_item_source', 'item_id'), array('for_item_type' => '', 'for_item_status' => ''), $args, array('cols' => 'e.agent_type, e.agent_id, e.operation, e.mod_type, i.eitem_id, i.assign_for', 'return_raw_results' => true, 'inherited_from' => '', 'assign_for' => '', 'hierarchical' => false));
     $for_item_type = isset($args['for_item_type']) ? $args['for_item_type'] : $via_item_type;
     extract($args, EXTR_SKIP);
     if ('term' == $via_item_source && !$for_item_type) {
         unset($args['for_item_source']);
         $args['post_types'] = array('');
     }
     //if ( 'term' == $for_item_source )
     $args['cols'] .= ', e.for_item_type';
     if (!empty($agent_type)) {
         $agents_by_type = array($agent_type => array());
     } else {
         $agents_by_type = array();
     }
     $exc = ppc_get_exceptions($args);
     foreach ($exc as $row) {
         pp_set_array_elem($this->current_exceptions, array($row->for_item_type, $row->operation, $row->agent_type, $row->agent_id, $row->assign_for, $row->mod_type));
         $this->current_exceptions[$row->for_item_type][$row->operation][$row->agent_type][$row->agent_id][$row->assign_for][$row->mod_type] = $row->eitem_id;
         if (!isset($agents_by_type[$row->agent_type])) {
             $agents_by_type[$row->agent_type] = array();
         }
         $agents_by_type[$row->agent_type][] = $row->agent_id;
     }
     foreach (array_keys($agents_by_type) as $agent_type) {
         $agents_by_type[$agent_type] = array_unique($agents_by_type[$agent_type]);
         $ids = $agents_by_type[$agent_type];
         if (!empty($agent_id)) {
             $ids = array_merge($ids, (array) $agent_id);
         }
         // ajax passes in specific id(s)
         if ('user' == $agent_type) {
             $this->agent_info['user'] = $wpdb->get_results("SELECT ID, user_login as name, display_name FROM {$wpdb->users} WHERE ID IN ('" . implode("','", array_map('intval', $ids)) . "') ORDER BY user_login", OBJECT_K);
         } elseif ('pp_group' != $agent_type) {
             $args = array('ids' => $ids);
             $this->agent_info[$agent_type] = pp_get_groups($agent_type, $args);
         }
     }
     // retrieve info for all WP roles regardless of exception storage
     $_args = array('cols' => "ID, group_name AS name, metagroup_type, metagroup_id");
     if (!empty($agent_id)) {
         // ajax usage
         $_args['ids'] = (array) $agent_id;
     } else {
         $_where = isset($agents_by_type['pp_group']) ? "ID IN ('" . implode("','", $agents_by_type['pp_group']) . "')" : "  metagroup_type != 'wp_role'";
         if (!($pp_only_roles = pp_get_option('supplemental_role_defs'))) {
             $pp_only_roles = array();
         }
         $_args['where'] = " AND ( {$_where} OR ( metagroup_type = 'wp_role' AND metagroup_id NOT IN ('" . implode("','", $pp_only_roles) . "') ) )";
     }
     $this->agent_info['pp_group'] = pp_get_groups('pp_group', $_args);
     $this->agent_info['wp_role'] = array();
     // rekey WP role exceptions
     foreach ($this->agent_info['pp_group'] as $agent_id => $group) {
         if ('wp_role' == $group->metagroup_type) {
             /*
             if ( 'wp_anon' == $group->metagroup_id ) {
             	unset( $this->agent_info['pp_group'][$agent_id] );
             	continue;
             }
             */
             $this->agent_info['wp_role'][$agent_id] = (object) $this->agent_info['pp_group'][$agent_id];
             if ($role_exists = isset($wp_roles->role_names[$group->metagroup_id])) {
                 $this->agent_info['wp_role'][$agent_id]->name = $wp_roles->role_names[$group->metagroup_id];
             }
             unset($this->agent_info['pp_group'][$agent_id]);
             if ($role_exists || in_array($group->metagroup_id, array('wp_anon', 'wp_all', 'wp_auth'))) {
                 foreach (array_keys($this->current_exceptions) as $for_item_type) {
                     foreach (array_keys($this->current_exceptions[$for_item_type]) as $op) {
                         if (isset($this->current_exceptions[$for_item_type][$op]['pp_group'][$agent_id])) {
                             $this->current_exceptions[$for_item_type][$op]['wp_role'][$agent_id] = (array) $this->current_exceptions[$for_item_type][$op]['pp_group'][$agent_id];
                             unset($this->current_exceptions[$for_item_type][$op]['pp_group'][$agent_id]);
                         }
                     }
                 }
             }
         }
     }
     // don't include orphaned assignments in metabox tab count
     foreach (array_keys($this->current_exceptions) as $for_item_type) {
         foreach (array_keys($this->current_exceptions[$for_item_type]) as $op) {
             foreach (array_keys($this->current_exceptions[$for_item_type][$op]) as $agent_type) {
                 $this->current_exceptions[$for_item_type][$op][$agent_type] = array_intersect_key($this->current_exceptions[$for_item_type][$op][$agent_type], $this->agent_info[$agent_type]);
             }
         }
     }
     // determine if inclusions are set for any agents
     $where = 'term' == $via_item_source ? "AND e.via_item_type = '{$via_item_type}'" : '';
     $where .= 'term' == $via_item_source ? '' : " AND e.for_item_source = '{$for_item_source}'";
     $query_users = isset($this->agent_info['user']) ? array_keys($this->agent_info['user']) : array();
     if (!empty($args['agent_type']) && 'user' == $args['agent_type'] && !empty($args['agent_id'])) {
         $query_users = array_merge($query_users, (array) $args['agent_id']);
     }
     $user_clause = $query_users ? "OR ( e.agent_type = 'user' AND e.agent_id IN ('" . implode("','", $query_users) . "') )" : '';
     //$agents_clause = "( ( e.agent_type = 'pp_group' AND e.agent_id IN ('" . implode( "','", array_keys($this->agent_info['wp_role']) ) . "') ) $user_clause )";
     $agents_clause = "( ( e.agent_type = 'pp_group' ) {$user_clause} )";
     $_assignment_modes = $hierarchical ? array('item', 'children') : array('item');
     // Populate only for wp roles, groups and users with stored exceptions.  Will query for additional individual users as needed.
     foreach ($_assignment_modes as $_assign_for) {
         $results = $wpdb->get_results("SELECT DISTINCT e.agent_type, e.agent_id, e.operation, e.for_item_type FROM {$wpdb->ppc_exceptions} AS e INNER JOIN {$wpdb->ppc_exception_items} AS i ON e.exception_id = i.exception_id WHERE {$agents_clause} AND i.assign_for = '{$_assign_for}' AND e.mod_type = 'include' {$where}");
         foreach ($results as $row) {
             //$_agent_type = ( 'pp_group' == $row->agent_type ) ? 'wp_role' : $row->agent_type;
             if ('pp_group' == $row->agent_type && in_array($row->agent_id, array_keys($this->agent_info['wp_role']))) {
                 $_agent_type = 'wp_role';
             } else {
                 $_agent_type = $row->agent_type;
             }
             pp_set_array_elem($this->inclusions_active, array($row->for_item_type, $row->operation, $_agent_type, $row->agent_id, $_assign_for));
             $this->inclusions_active[$row->for_item_type][$row->operation][$_agent_type][$row->agent_id][$_assign_for] = true;
         }
     }
 }
예제 #19
0
function _cme_new_blog($new_blog_id)
{
    if ($autocreate_roles = get_site_option('cme_autocreate_roles')) {
        global $wp_roles, $blog_id;
        $restore_blog_id = $blog_id;
        switch_to_blog(1);
        $wp_roles->reinit();
        $main_site_caps = array();
        $role_captions = array();
        $admin_role = $wp_roles->get_role('administrator');
        $main_admin_caps = $admin_role->capabilities;
        if (defined('PP_ACTIVE')) {
            $main_pp_only = (array) pp_get_option('supplemental_role_defs');
        }
        //$pp_only[]= $newrole;
        foreach ($autocreate_roles as $role_name) {
            if ($role = get_role($role_name)) {
                $main_site_caps[$role_name] = $role->capabilities;
                $role_captions[$role_name] = $wp_roles->role_names[$role_name];
            }
        }
        switch_to_blog($new_blog_id);
        $wp_roles->reinit();
        if (defined('PP_ACTIVE')) {
            pp_refresh_options();
            $blog_pp_only = (array) pp_get_option('supplemental_role_defs');
        }
        foreach ($main_site_caps as $role_name => $caps) {
            if ($blog_role = $wp_roles->get_role($role_name)) {
                $stored_role_caps = !empty($blog_role->capabilities) && is_array($blog_role->capabilities) ? array_intersect($blog_role->capabilities, array(true, 1)) : array();
                // Find caps to add and remove
                $add_caps = array_diff_key($caps, $stored_role_caps);
                $del_caps = array_intersect_key(array_diff_key($stored_role_caps, $caps), $main_admin_caps);
                // don't mess with caps that are totally unused on main site
                // Add new capabilities to role
                foreach ($add_caps as $cap => $grant) {
                    $blog_role->add_cap($cap);
                }
                // Remove capabilities from role
                foreach ($del_caps as $cap => $grant) {
                    $blog_role->remove_cap($cap);
                }
            } else {
                $wp_roles->add_role($role_name, $role_captions[$role_name], $caps);
            }
            if (defined('PP_ACTIVE')) {
                if (in_array($role_name, $main_pp_only)) {
                    _cme_pp_default_pattern_role($role_name);
                    $blog_pp_only[] = $role_name;
                } else {
                    array_diff($blog_pp_only, array($role_name));
                }
            }
        }
        if (defined('PP_ACTIVE')) {
            pp_update_option('supplemental_role_defs', $blog_pp_only);
        }
        switch_to_blog($restore_blog_id);
        $wp_roles->reinit();
        if (defined('PP_ACTIVE')) {
            pp_refresh_options();
        }
    }
}
예제 #20
0
<ul class="pp-notes">
<li><?php 
printf(__('%1$sUsers who have Supplemental Roles (directly or via group)%2$s', 'pp'), "<a href='{$url}?pp_has_roles=1'>", '</a>');
?>
</li>
<li><?php 
printf(__('%1$sUsers who have Exceptions  (directly or via group)%2$s', 'pp'), "<a href='{$url}?pp_has_exceptions=1'>", '</a>');
?>
</li>
<li><?php 
printf(__('%1$sUsers who have Supplemental Roles or Exceptions  (directly or via group)%2$s', 'pp'), "<a href='{$url}?pp_has_perms=1'>", '</a>');
?>
</li>
</ul>
</div>

<?php 
if (pp_get_option('display_hints')) {
    ?>
<span class="pp-subtext">
<?php 
    printf(__('%1$snote%2$s: If you don&apos;t see the Site Role column on the Users screen, make sure it is enabled in Screen Options. ', 'pp'), '<strong>', '</strong>');
    ?>
</span>
<?php 
}
?>

</div>

</div>
예제 #21
0
 function download_package($package)
 {
     if (!preg_match('!^(http|https|ftp)://!i', $package) && file_exists($package)) {
         //Local file or remote?
         return $package;
     }
     //must be a local file..
     if (empty($package)) {
         return new WP_Error('no_package', $this->strings['no_package']);
     }
     $this->skin->feedback('downloading_package', $package);
     $key_data = pp_get_option('support_key');
     $key_arg = is_array($key_data) && isset($key_data[1]) ? $key_data[1] : '';
     $vars = array('VERSION', 'KEY', 'URL');
     $values = array(urlencode(PPC_VERSION), urlencode($key_arg), urlencode(get_option('siteurl')));
     $package = str_replace($vars, $values, $package);
     $download_file = download_url($package);
     if (is_wp_error($download_file)) {
         return new WP_Error('download_failed', $this->strings['download_failed'], $download_file->get_error_message());
     }
     return $download_file;
 }
예제 #22
0
 /**
  * Reports on the availability of new updates and the update key
  *
  * @author Jonathan Davis
  * @author Kevin Behrens
  *
  * @return void
  **/
 public static function status($plugin_file, $plugin_data, $status)
 {
     $updates = self::get_version_info();
     $key = pp_get_option('support_key');
     $activated = isset($key[0]) ? $key[0] == '1' : false;
     global $pp_extensions;
     $slug = '';
     foreach ($pp_extensions as $_slug => $ext) {
         if ($plugin_file == $ext->basename) {
             $slug = $_slug;
             $current_version = $ext->version;
             break;
         }
     }
     if (!$slug) {
         return;
     }
     $version_info = isset($updates->response[$plugin_file]) ? $updates->response[$plugin_file] : false;
     if (!empty($version_info) && isset($version_info->new_version)) {
         // Core update available
         if (version_compare($version_info->new_version, $current_version, '>') || !pp_get_option('beta_updates') && preg_match("/dev|alpha|beta|rc/i", $current_version)) {
             $network = is_network_admin() ? 'network/' : '';
             $details_url = admin_url("{$network}plugin-install.php?tab=plugin-information&plugin={$slug}&TB_iframe=true&width=600&height=800");
             $update_url = wp_nonce_url("update.php?action={$slug}&plugin=" . $plugin_file, 'upgrade-plugin_' . $slug);
             if (!$activated) {
                 // Key not active for extension update
                 $update_url = 'http://presspermit.com/' . 'purchase/';
                 $message = sprintf(__('There is a new version of %1$s, but <a href="%2$s">your support key</a> is not activated. No automatic update available. <a href="%3$s">Purchase a Press Permit Pro support key</a> for one-click updates and support resources. <a href="%4$s" class="thickbox" title="%5$s">View version %6$s details</a>.', 'pp'), $plugin_data['Name'], admin_url('admin.php?page=pp-settings&pp_tab=install'), 'http://presspermit.com/' . 'purchase/', $details_url, esc_attr($plugin_data['Name']), $version_info->new_version);
                 set_site_transient('ppc_update_info', false);
             } else {
                 $message = sprintf(__ppw('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">upgrade automatically</a>.'), $plugin_data['Name'], $details_url, esc_attr($plugin_data['Name']), $version_info->new_version, $update_url);
             }
             echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update"><div class="update-message">' . $message . '</div></td></tr>';
             return;
         }
     }
     if (!$activated) {
         // No update availableKey not active
         $message = sprintf(__('Activate your <a href="%1$s">support key</a> for Press Permit Pro extensions and support resources.', 'pp'), admin_url('admin.php?page=pp-settings&pp_tab=install'), 'http://presspermit.com/' . "purchase/");
         echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update"><div class="update-message">' . $message . '</div></td></tr>';
         set_site_transient('ppc_update_info', false);
         return;
     }
 }
예제 #23
0
    function pp_types_ui($defined)
    {
        if (current_user_can('pp_manage_settings')) {
            ?>

		<dl>
			<dt><?php 
            _e('Force Type-Specific Capabilities', 'capsman');
            ?>
</dt>
			<dd style="text-align:center;">
				<?php 
            $caption = __('Force unique capability names for:', 'capsman');
            echo "<p>{$caption}</p>";
            if (pp_get_option('display_hints')) {
                ?>

				<div class="cme-subtext" style="margin-top:0">
				<?php 
                _e('(PP Filtered Post Types, Taxonomies)', 'capsman');
                ?>

				</div>
				<?php 
            }
            echo "<table style='width:100%'><tr>";
            $unfiltered['type'] = apply_filters('pp_unfiltered_post_types', array('forum', 'topic', 'reply'));
            // bbPress' dynamic role def requires additional code to enforce stored caps
            $unfiltered['taxonomy'] = apply_filters('pp_unfiltered_taxonomies', array('post_status', 'topic-tag'));
            // avoid confusion with Edit Flow administrative taxonomy
            $hidden['type'] = apply_filters('pp_hidden_post_types', array());
            $hidden['taxonomy'] = apply_filters('pp_hidden_taxonomies', array());
            foreach (array_keys($defined) as $item_type) {
                echo '<td style="width:50%">';
                $option_name = 'taxonomy' == $item_type ? 'enabled_taxonomies' : 'enabled_post_types';
                $enabled = pp_get_option($option_name);
                foreach ($defined[$item_type] as $key => $type_obj) {
                    if (!$key) {
                        continue;
                    }
                    if (in_array($key, $unfiltered[$item_type])) {
                        continue;
                    }
                    $id = "{$option_name}-" . $key;
                    ?>

						<div style="text-align:left">
						<?php 
                    if (!empty($hidden[$item_type][$key])) {
                        ?>

							<input name="<?php 
                        echo $id;
                        ?>
" type="hidden" id="<?php 
                        echo $id;
                        ?>
" value="1" />
							<input name="<?php 
                        echo "{$option_name}-options[]";
                        ?>
" type="hidden" value="<?php 
                        echo $key;
                        ?>
" />
						
						<?php 
                    } else {
                        ?>

							<div class="agp-vspaced_input">
							<label for="<?php 
                        echo $id;
                        ?>
" title="<?php 
                        echo $key;
                        ?>
">
							<input name="<?php 
                        echo "{$option_name}-options[]";
                        ?>
" type="hidden" value="<?php 
                        echo $key;
                        ?>
" />
							<input name="<?php 
                        echo $id;
                        ?>
" type="checkbox" id="<?php 
                        echo $id;
                        ?>
" value="1" <?php 
                        checked('1', !empty($enabled[$key]));
                        ?>
 /> <?php 
                        echo $type_obj->label;
                        ?>

							
							<?php 
                        echo '</label></div>';
                    }
                    // displaying checkbox UI
                    echo '</div>';
                }
                echo '</td>';
            }
            ?>

				</tr>
				</table>
				
				<?php 
            if (pp_wp_ver('3.5')) {
                $define_create_posts_cap = pp_get_option('define_create_posts_cap');
                ?>

					<div>
					<label for="pp_define_create_posts_cap">
					<input name="pp_define_create_posts_cap" type="checkbox" id="pp_define_create_posts_cap" value="1" <?php 
                checked('1', $define_create_posts_cap);
                ?>
 /> <?php 
                _e('Use create_posts capability');
                ?>

					</label>
					</div>
				<?php 
            }
            ?>

				
				<input type="submit" name="update_filtered_types" value="<?php 
            _e('Update', 'capsman');
            ?>
" class="button" />
			</dd>
		</dl>
		<?php 
        }
    }
예제 #24
0
    function admin_notice()
    {
        if (!is_super_admin()) {
            return;
        }
        if (get_option('pp_post_blockage_priority') || !get_option('ppperm_legacy_exception_handling')) {
            return;
        }
        $msg_id = 'post_blockage_priority';
        $dismissals = (array) pp_get_option('dismissals');
        if (isset($dismissals[$msg_id])) {
            return;
        }
        $message = __('An improvement to permissions handling is available. Please review Permissions > Settings > Core > Permissions.', 'pp');
        global $pp_plugin_page;
        // thanks to GravityForms for the nifty dismissal script
        ?>
		<div class='updated' style='<?php 
        if ($pp_plugin_page) {
            echo 'margin-top:30px;';
        }
        ?>
padding:5px;line-height:18px;<?php 
        global $pp_plugin_page;
        if (!empty($pp_plugin_page)) {
            echo 'margin-right:120px;';
        }
        ?>
position:relative;' id='pp_dashboard_message'><?php 
        echo $message;
        ?>
&nbsp; &nbsp;
			<a href="javascript:void(0);" onclick="PPDismissNotice();" style='fl-oat:right;'><?php 
        _e("Dismiss", "pp");
        ?>
</a>
		</div>
		<script type="text/javascript">
			function PPDismissNotice(){
				jQuery("#pp_dashboard_message").slideUp();
				jQuery.post(ajaxurl, {action:"pp_dismiss_msg", msg_id:"<?php 
        echo $msg_id;
        ?>
", cookie: encodeURIComponent(document.cookie)});
			}
		</script>
		<?php 
    }
 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;
 }
예제 #26
0
?>
">&nbsp;&nbsp;<a class="cme-neg-all" href="#" title="<?php 
_e('negate all (storing as disabled capabilities)', 'capsman');
?>
">X</a> <a class="cme-switch-all" href="#" title="<?php 
_e('negate none (add/remove all capabilities normally)', 'capsman');
?>
">X</a>
				</span>
				</td></tr>
				
				</table>
				
				<br />
				<?php 
if (!defined('PP_ACTIVE') || pp_get_option('display_hints')) {
    ?>
				<div class="cme-subtext">
					<?php 
    _e('Note: Underscores replace spaces in stored capability name ("edit users" => "edit_users").', 'pp');
    ?>
				</div>
				<?php 
}
?>
				</span>
				
			</dd>
		</dl>

		<?php 
예제 #27
0
 function retrieve_exceptions($operations = array(), $for_item_sources = array(), $args = array())
 {
     $args['ug_clause'] = $this->get_usergroups_clause('e', array('user_adjust' => pp_get_option('user_exceptions')));
     // note: Custom Group and User assignments are only for additions
     $args['operations'] = $operations;
     $args['for_item_sources'] = $for_item_sources;
     $this->except = array_merge($this->except, ppc_get_exceptions($args));
 }
예제 #28
0
    function display($agent_type, $id_suffix, $current_selections = array(), $args = array())
    {
        $defaults = array('agent_id' => 0, 'context' => '', 'label_select' => _x('Select &gt;', 'user', 'pp'), 'label_unselect' => _x('&lt; Unselect', 'user', 'pp'), 'label_selections' => __('Current Selections:', 'pp'), 'display_stored_selections' => true, 'create_dropdowns' => false, 'width' => '', 'width_current' => '', 'label_headline' => true, 'multi_select' => true, 'use_selection_js' => true);
        $args = apply_filters('pp_agents_selection_ui_args', array_merge($defaults, $args), $agent_type, $id_suffix);
        extract($args, EXTR_SKIP);
        $width = $width ? "width:{$width}px;" : '';
        $this->register_ajax_js($agent_type, $id_suffix, $context, $agent_id, $args);
        if (true === $label_headline) {
            $label_headline = 'user' == $agent_type ? __('Select Users', 'pp') : __('Select Groups', 'pp');
        }
        ?>
		<table id="pp-agent-selection_<?php 
        echo $id_suffix;
        ?>
-wrapper" class="pp-agents-selection">
		<tr><td id="pp-agent-selection_<?php 
        echo $id_suffix;
        ?>
">
		<h4><?php 
        echo $label_headline;
        ?>
</h4>
		<input id="agent_search_text_<?php 
        echo $id_suffix;
        ?>
" type="text" size="8" />
		<button type="button" class="pp-agent-search-submit" id="agent_submit_<?php 
        echo $id_suffix;
        ?>
"><?php 
        echo __ppw("Search");
        ?>
</button>
		<img class="waiting" style="display:none;" src="<?php 
        echo esc_url(admin_url('images/wpspin_light.gif'));
        ?>
" alt="" />
		
		<?php 
        if ('user' == $agent_type && pp_get_option('user_search_by_role')) {
            ?>
			<br /><select id="pp_search_role_<?php 
            echo $id_suffix;
            ?>
">
			<option value=""><?php 
            _e('(any WP role)', 'pp');
            ?>
</option>
			<?php 
            wp_dropdown_roles();
            ?>
			</select>
		<?php 
        }
        ?>
		
		</td>
		
		<?php 
        if ($display_stored_selections) {
            ?>
		<td style="vertical-align:bottom" class="pp-members-current"><h4><?php 
            echo $label_selections;
            ?>
</h4></td>
		<?php 
        }
        ?>
		
		</tr>
		
		<tr><td>
		<select id="agent_results_<?php 
        echo $id_suffix;
        ?>
" class="pp_agent_results" <?php 
        if ($multi_select) {
            ?>
multiple="multiple" style="height:160px;<?php 
        } else {
            ?>
style="display:none;<?php 
        }
        echo $width;
        ?>
"></select>
		<span id="agent_msg_<?php 
        echo $id_suffix;
        ?>
"></span>
		</td>

		<?php 
        if ($display_stored_selections) {
            if ($width_current) {
                $width = "width:{$width_current}px;";
            }
            ?>
		<td class="pp-members-current">
		<select id='<?php 
            echo $id_suffix;
            ?>
' name='<?php 
            echo $id_suffix;
            ?>
[]' multiple='multiple' style='height:160px;<?php 
            echo $width;
            ?>
float:right'>
		
<?php 
            $display_property = 'user' == $agent_type ? 'user_login' : 'display_name';
            foreach ($current_selections as $agent) {
                $attribs = isset($agent->display_name) && $agent->user_login != $agent->display_name ? 'title="' . esc_attr($agent->display_name) . '"' : '';
                ?>
		<?php 
                $data = apply_filters('pp_agents_selection_ui_attribs', array('attribs' => $attribs, 'user_caption' => $agent->{$display_property}), $agent_type, $id_suffix, $agent);
                ?>
		<option value="<?php 
                echo $agent->ID;
                ?>
" <?php 
                echo $data['attribs'];
                ?>
><?php 
                echo $data['user_caption'];
                ?>
</option>
<?php 
            }
            ?>

		</select><br />
		</td>
		<?php 
        }
        ?>
		
		</tr>
		
		<?php 
        do_action('_pp_agents_selection_ui_select_pre', $id_suffix);
        ?>
		<tr>
		<?php 
        do_action('pp_agents_selection_ui_select_pre', $id_suffix);
        ?>
		

		<td><button type="button" id="select_agents_<?php 
        echo $id_suffix;
        ?>
" class="pp_add" style="float:right<?php 
        if (!$multi_select) {
            ?>
;display:none;<?php 
        }
        ?>
"><?php 
        echo $label_select;
        ?>
</button></td>
		
		<?php 
        if ($display_stored_selections) {
            ?>
		<td class="pp-members-current"><button type="button" id="unselect_agents_<?php 
            echo $id_suffix;
            ?>
" class="pp_remove"><?php 
            echo $label_unselect;
            ?>
</button></td>
		<?php 
        }
        ?>
		
		</tr>
		</table>	
<?php 
        if (!defined('PPM_VERSION') && pp_get_option('display_extension_hints')) {
            if (0 === validate_plugin("pp-membership/pp-membership.php")) {
                $msg = __('To set date limits on group membership, activate the PP Membership plugin.', 'pp');
            } elseif (true == pp_key_status()) {
                $msg = sprintf(__('To set date limits on group membership, %1$sinstall%2$s the PP Membership plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>');
            } else {
                $msg = sprintf(__('To set date limits on group membership, %1$senter%2$s or %3$spurchase%4$s a support key and install the PP Membership plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>', '<a href="http://presspermit.com/purchase">', '</a>');
            }
            echo "<div class='pp-ext-promo'>{$msg}</div>";
        }
        $csv = $current_selections ? implode(',', array_keys($current_selections)) : '';
        $csv = apply_filters('pp_agents_selection_ui_csv', $csv, $id_suffix, $current_selections);
        ?>
		<input type="hidden" id="<?php 
        echo $id_suffix;
        ?>
_csv" name="<?php 
        echo $id_suffix;
        ?>
_csv" value="<?php 
        echo $csv;
        ?>
" />
		<?php 
    }
예제 #29
0
function pp_options($args = array())
{
    if (!current_user_can('pp_manage_settings')) {
        wp_die(__ppw('Cheatin&#8217; uh?'));
    }
    do_action('pp_options_ui');
    global $pp, $pp_admin, $pp_options_ui;
    $pp->load_config();
    //$pp->load_user_config();
    $pp_options_ui = new PP_OptionsUI($args);
    $ui = $pp_options_ui;
    // shorten syntax
    $ui->all_options = array();
    $ui->tab_captions = apply_filters('pp_option_tabs', array());
    $ui->section_captions = apply_filters('pp_section_captions', array());
    $ui->option_captions = apply_filters('pp_option_captions', array());
    $ui->form_options = apply_filters('pp_option_sections', array());
    $ui->display_hints = pp_get_option('display_hints');
    if ($_hidden = apply_filters('pp_hide_options', array())) {
        $hidden = array();
        foreach (array_keys($_hidden) as $option_name) {
            if (!is_array($_hidden[$option_name]) && strlen($option_name) > 3) {
                $hidden[] = substr($option_name, 3);
            }
        }
        foreach (array_keys($ui->form_options) as $tab) {
            foreach (array_keys($ui->form_options[$tab]) as $section) {
                $ui->form_options[$tab][$section] = array_diff($ui->form_options[$tab][$section], $hidden);
            }
        }
    }
    ?>
	<div class='wrap'>
	<?php 
    echo '<form id="pp_settings_form" action="" method="post">';
    wp_nonce_field('pp-update-options');
    do_action('pp_options_form');
    ?>
	<?php 
    pp_icon();
    ?>

	<div class="submit pp-submit" style="border:none;position:absolute;right:20px;top:25px;">
	<input type="submit" name="pp_submit" class="button-primary" value="<?php 
    _e('Save Changes', 'pp');
    ?>
" />
	</div>
	<h2>
	<?php 
    $title = apply_filters('pp_options_form_title', _e('Press Permit Settings', 'pp'));
    _e($title);
    ?>
	</h2>
	
	<?php 
    if ($subheading = apply_filters('pp_options_form_subheading', '')) {
        echo $subheading;
    }
    $color_class = apply_filters('pp_options_form_color_class', 'pp-backtan');
    $class_selected = "agp-selected_agent agp-agent {$color_class}";
    $class_unselected = "agp-unselected_agent agp-agent";
    ?>
	<script type="text/javascript">
	/* <![CDATA[ */
	jQuery(document).ready( function($) {
		$('li.agp-agent a').click(function() {
			$('li.agp-agent').removeClass( 'agp-selected_agent <?php 
    echo $color_class;
    ?>
' );
			$('li.agp-agent').addClass( 'agp-unselected_agent' );
			$(this).parent().addClass( 'agp-selected_agent <?php 
    echo $color_class;
    ?>
' );
			$('.pp-options-wrapper > div').hide();
			$('#' + $(this).attr('class') ).show();
		});
	});
	/* ]]> */
	</script>
	<?php 
    $default_tab = isset($_REQUEST['pp_tab']) && isset($ui->tab_captions[$_REQUEST['pp_tab']]) ? $_REQUEST['pp_tab'] : 'install';
    $default_tab = apply_filters('pp_options_default_tab', $default_tab);
    // @todo: prevent line breaks in these links
    echo "<ul class='pp-list_horiz' style='margin-bottom:-0.1em'>";
    foreach ($ui->tab_captions as $tab => $caption) {
        if (!empty($ui->form_options[$tab])) {
            $class = $default_tab == $tab ? $class_selected : $class_unselected;
            // @todo: return to last tab
            echo "<li class='{$class}'><a class='pp-{$tab}' href='javascript:void(0)'>" . $ui->tab_captions[$tab] . '</a></li>';
        }
    }
    echo '</ul>';
    echo '<div class="pp-options-wrapper">';
    $table_class = 'form-table pp-form-table pp-options-table';
    if (isset($_REQUEST['pp_submit'])) {
        ?>
		<div id="message" class="updated"><p>
		<strong><?php 
        _e('Settings were updated.', 'pp');
        ?>
&nbsp;</strong>
		</p></div>
	<?php 
    } elseif (isset($_REQUEST['pp_defaults'])) {
        ?>
		<div id="message" class="updated"><p>
		<strong><?php 
        _e('Settings were reset to defaults.', 'pp');
        ?>
&nbsp;</strong>
		</p></div>
	<?php 
    }
    foreach (array_keys($ui->tab_captions) as $tab) {
        $display = $default_tab == $tab ? '' : 'display:none';
        echo "<div id='pp-{$tab}' style='clear:both;margin:0;{$display}' class='pp-options {$color_class}'>";
        do_action("pp_{$tab}_options_pre_ui");
        echo "<table class='{$table_class}' id='pp-{$tab}_table'>";
        do_action("pp_{$tab}_options_ui");
        echo '</table></div>';
    }
    echo '</div>';
    // pp-options-wrapper
    $pp_options_ui->filter_network_options();
    echo "<input type='hidden' name='all_options' value='" . implode(',', $ui->all_options) . "' />";
    echo "<input type='hidden' name='all_otype_options' value='" . implode(',', $ui->all_otype_options) . "' />";
    echo "<input type='hidden' name='pp_submission_topic' value='options' />";
    ?>

	<p class="submit pp-submit" style="border:none;">
	<input type="submit" name="pp_submit" class="button-primary" value="<?php 
    _e('Save Changes', 'pp');
    ?>
" />
	</p>

	<?php 
    $msg = __("All settings in this form (including those on undisplayed tabs) will be reset to DEFAULTS.  Are you sure?", 'pp');
    $js_call = "javascript:if (confirm('{$msg}')) {return true;} else {return false;}";
    ?>
	<p class="submit pp-submit-alternate" style="border:none;float:left">
	<input type="submit" name="pp_defaults" value="<?php 
    _e('Revert to Defaults', 'pp');
    ?>
" onclick="<?php 
    echo $js_call;
    ?>
" />
	</p>
	</form>
	<p style='clear:both'>
	</p>
	</div>

	<?php 
}
예제 #30
0
function pp_key_active()
{
    $opt_val = (array) pp_get_option('support_key');
    return !empty($opt_val[0]) && in_array($opt_val[0], array(1, -1));
}