Example #1
0
 function admin_head()
 {
     global $pagenow, $plugin_page_cr;
     echo '<link rel="stylesheet" href="' . SCOPER_URLPATH . '/admin/role-scoper.css" type="text/css" />' . "\n";
     if ('rs-about' == $plugin_page_cr) {
         echo '<link rel="stylesheet" href="' . SCOPER_URLPATH . '/admin/about/about.css" type="text/css" />' . "\n";
     }
     if (in_array($pagenow, array('post.php', 'post-new.php'))) {
         $src_name = 'post';
         $object_type = cr_find_post_type();
     } elseif (isset($_GET['src_name']) && isset($_GET['object_type'])) {
         $src_name = sanitize_key($_GET['src_name']);
         $object_type = sanitize_key($_GET['object_type']);
     }
     if (!empty($object_type)) {
         // dynamically set checkbox titles for user/group object role selection
         $src = $this->scoper->data_sources->get($src_name);
         $otype_def = $this->scoper->data_sources->member_property($src_name, 'object_types', $object_type);
         if (!empty($src) && !empty($src->cols->parent) && empty($otype_def->ignore_object_hierarchy)) {
             if (!empty($otype_def->labels)) {
                 $obj_title = sprintf(__('assign role for this %s', 'scoper'), agp_strtolower($otype_def->labels->singular_name));
                 $child_title = sprintf(__('assign role for sub-%s', 'scoper'), agp_strtolower($otype_def->labels->name));
                 $js_params = "var role_for_object_title = '{$obj_title}';" . "var role_for_children_title = '{$child_title}';";
                 // TODO: replace some of this JS with equivalent JQuery
                 echo "\n" . '<script type="text/javascript">' . $js_params . '</script>';
                 echo "\n" . "<script type='text/javascript' src='" . SCOPER_URLPATH . "/admin/rs-objrole-cbox-maint.js'></script>";
             }
         }
     }
     add_filter('contextual_help_list', array(&$this, 'flt_contextual_help_list'), 10, 2);
     if (0 === strpos($plugin_page_cr, 'rs-') && strpos($plugin_page_cr, 'roles')) {
         // add Ajax goodies we need for role duration/content date limit editing Bulk Role Admin
         if (!awp_ver('3.4')) {
             wp_print_scripts(array('page'));
         }
         require_once dirname(__FILE__) . '/admin_lib-bulk_rs.php';
         ScoperAdminBulkLib::date_limits_js();
     }
     // TODO: replace some of this JS with equivalent JQuery
     echo "\n" . "<script type='text/javascript' src='" . SCOPER_URLPATH . "/admin/agapetry.js'></script>";
     echo "\n" . "<script type='text/javascript' src='" . SCOPER_URLPATH . "/admin/role-scoper.js'></script>";
     if (scoper_get_option('group_ajax') && (in_array($pagenow, array('user-edit.php', 'profile.php')) || 'rs-groups' == $plugin_page_cr)) {
         global $scoper_user_search;
         if ('rs-groups' == $plugin_page_cr) {
             $agent_type = 'users';
             $agent_id = isset($_GET['id']) ? $_GET['id'] : 0;
         } else {
             $agent_type = 'groups';
             if ('profile.php' == $pagenow) {
                 global $current_user;
                 $agent_id = $current_user->ID;
             } else {
                 $agent_id = (int) $_GET['user_id'];
             }
         }
         require_once dirname(__FILE__) . '/user_search_ui_rs.php';
         $scoper_user_search = new ScoperUserSearch($agent_type);
         $scoper_user_search->output_js($agent_type, $agent_id);
     }
 }