Exemplo n.º 1
0
 public static function cred_scripts()
 {
     $agent_type = isset($_REQUEST['agent_type']) ? pp_sanitize_key($_REQUEST['agent_type']) : 'pp_group';
     $agent_id = isset($_REQUEST['agent_id']) ? (int) $_REQUEST['agent_id'] : 0;
     if (!pp_has_group_cap('pp_manage_members', $agent_id, $agent_type) && !_pp_any_group_manager() && !current_user_can('pp_assign_roles') && !pp_bulk_roles_enabled()) {
         return array();
     }
     $vars = array('addRoles' => __('Add Roles', 'pp'), 'clearRole' => __('clear', 'pp'), 'noConditions' => __('No statuses selected!', 'pp'), 'pleaseReview' => __('Review selection(s) below, then click Save.', 'pp'), 'alreadyRole' => __('Role already selected!', 'pp'), 'noAction' => __('No Action selected!', 'pp'), 'submissionMsg' => __('Role submission in progress...', 'pp'), 'reloadRequired' => __('Reload form for further changes to this role', 'pp'), 'ajaxurl' => admin_url(''));
     $vars['agentType'] = $agent_type;
     $vars['agentID'] = $agent_id;
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
     wp_enqueue_script('pp_permit_edit', PP_URLPATH . "/admin/js/pp_permit_edit{$suffix}.js", array('jquery', 'jquery-form'), PPC_VERSION);
     wp_localize_script('pp_permit_edit', 'ppCred', $vars);
     return $vars;
 }
Exemplo n.º 2
0
 function build_menu()
 {
     if (strpos($_SERVER['REQUEST_URI'], 'wp-admin/network/')) {
         return;
     }
     $do_groups = current_user_can('pp_edit_groups') || _pp_any_group_manager();
     $do_settings = current_user_can('pp_manage_settings');
     if (!$do_groups && !$do_settings) {
         return;
     }
     $pp_cred_menu = $this->get_menu('permits');
     $pp_options_menu = $this->get_menu('options');
     if ('pp-groups' == $pp_cred_menu) {
         //  Manually set menu indexes for positioning below Users menu
         global $menu;
         $pp_cred_key = !defined('PP_DISABLE_MENU_TWEAK') && !defined('OZH_MENU_VER') && isset($menu[70]) && $menu[70][2] == 'users.php' && !isset($menu[72]) ? 72 : null;
         add_menu_page(__('Permissions', 'pp'), __('Permissions', 'pp'), 'read', $pp_cred_menu, array(&$this, 'menu_handler'), PP_URLPATH . '/admin/images/menu/users-c.png', $pp_cred_key);
     }
     $handler = array(&$this, 'menu_handler');
     if ($do_groups) {
         add_submenu_page($pp_cred_menu, __('Groups', 'pp'), __('Groups', 'pp'), 'read', 'pp-groups', $handler);
         if (current_user_can('pp_create_groups')) {
             add_submenu_page($pp_cred_menu, __('Add New Permission Group'), '- ' . __ppw('Add New'), 'read', 'pp-group-new', $handler);
         }
     }
     if (current_user_can('list_users') && current_user_can('pp_administer_content')) {
         add_submenu_page($pp_cred_menu, __('Users', 'pp'), __('Users', 'pp'), 'read', 'pp-users', $handler);
     }
     if ($do_settings) {
         do_action('pp_permissions_menu', $pp_options_menu, $handler);
         $settings_caption = 'pp-groups' == $pp_options_menu ? __('Settings', 'pp') : __('Permissions', 'pp');
         add_submenu_page($pp_options_menu, $settings_caption, $settings_caption, 'read', 'pp-settings', $handler);
     }
     // satisfy WordPress' demand that all admin links be properly defined in menu
     global $pp_plugin_page;
     if (in_array($pp_plugin_page, array('pp-edit-permissions', 'pp-attachments_utility'))) {
         $titles = array('pp-edit-permissions' => __('Edit Permissions', 'pp'));
         add_submenu_page($pp_cred_menu, $titles[$pp_plugin_page], '', 'read', $pp_plugin_page, $handler);
     }
     do_action('pp_admin_menu');
     if ('pp-groups' == $pp_cred_menu && $do_settings) {
         add_submenu_page($pp_cred_menu, __('About Press Permit', 'pp'), __('About', 'pp'), 'read', 'pp-about', array(&$this, 'menu_handler'));
     }
 }
 function ajax_user_can()
 {
     return current_user_can('pp_edit_groups') || _pp_any_group_manager();
 }