예제 #1
0
 /**
  * Query database for list of users
  * 
  * Based on filters and settings get the list of users from database
  * 
  * @return \WP_User_Query
  * 
  * @access public
  */
 public function query()
 {
     if ($search = trim(aam_Core_Request::request('sSearch'))) {
         $search = "{$search}*";
     }
     $args = array('number' => '', 'blog_id' => get_current_blog_id(), 'role' => aam_Core_Request::request('role'), 'fields' => 'all', 'number' => aam_Core_Request::request('iDisplayLength'), 'offset' => aam_Core_Request::request('iDisplayStart'), 'search' => $search, 'search_columns' => array('user_login', 'user_email', 'display_name'), 'orderby' => 'user_nicename', 'order' => 'ASC');
     return new WP_User_Query($args);
 }
예제 #2
0
파일: abstract.php 프로젝트: dot2006/jobify
 /**
  *
  */
 public function __construct()
 {
     if (is_null(self::$_subject)) {
         $subject_class = 'aam_Control_Subject_' . ucfirst(trim(aam_Core_Request::request('subject'), ''));
         if (class_exists($subject_class)) {
             $this->setSubject(new $subject_class(aam_Core_Request::request('subject_id')));
         }
     }
 }
예제 #3
0
 /**
  * Construct the Object
  * 
  * Instantiate the subject one type that is going to be shared with all view
  * models.
  * 
  * @return void
  * 
  * @access public
  */
 public function __construct()
 {
     if (is_null(self::$_subject)) {
         $subject_class = 'aam_Control_Subject_' . ucfirst(trim(aam_Core_Request::request('subject'), ''));
         if (class_exists($subject_class)) {
             $this->setSubject(new $subject_class(aam_Core_Request::request('subject_id')));
             //check if view for current subject can be managed
             $this->isManagable();
         }
     }
     //control default option list
     add_filter('aam_default_option_list', array($this, 'defaultOption'));
 }
예제 #4
0
 /**
  * Get Role List
  * 
  * @return string JSON Encoded role list
  * 
  * @access public
  */
 public function retrieveList()
 {
     //retrieve list of users
     $count = count_users();
     $user_count = $count['avail_roles'];
     //filter by name
     $search = strtolower(trim(aam_Core_Request::request('sSearch')));
     $filtered = array();
     $roles = get_editable_roles();
     foreach ($roles as $id => $role) {
         if (!$search || preg_match('/^' . $search . '/i', $role['name'])) {
             $filtered[$id] = $role;
         }
     }
     $response = array('iTotalRecords' => count($roles), 'iTotalDisplayRecords' => count($filtered), 'sEcho' => aam_Core_Request::request('sEcho'), 'aaData' => array());
     foreach ($filtered as $role => $data) {
         $users = isset($user_count[$role]) ? $user_count[$role] : 0;
         $response['aaData'][] = array($role, $users, translate_user_role($data['name']), '');
     }
     return json_encode($response);
 }
예제 #5
0
 /**
  * Process the ajax call
  *
  * @return string
  *
  * @access public
  */
 public function run()
 {
     switch (aam_Core_Request::request('sub_action')) {
         case 'role_list':
             $response = $this->retrieveRoleList();
             break;
         case 'pure_role_list':
             $response = $this->retrievePureRoleList();
             break;
         case 'user_list':
             $response = $this->retrieveUserList();
             break;
         case 'add_role':
             $response = $this->addRole();
             break;
         case 'edit_role':
             $response = $this->editRole();
             break;
         case 'delete_role':
             $response = $this->deleteRole();
             break;
         case 'block_user':
             $response = $this->blockUser();
             break;
         case 'delete_user':
             $response = $this->deleteUser();
             break;
         case 'load_metaboxes':
             $response = $this->loadMetaboxes();
             break;
         case 'init_link':
             $response = $this->initLink();
             break;
         case 'load_capabilities':
             $response = $this->loadCapabilities();
             break;
         case 'role_capabilities':
             $response = $this->getRoleCapabilities();
             break;
         case 'add_capability':
             $response = $this->addCapability();
             break;
         case 'delete_capability':
             $response = $this->deleteCapability();
             break;
         case 'restore_capability':
             $response = $this->restoreCapability();
             break;
         case 'post_type_list':
             $response = $this->getPostTypeList();
             break;
         case 'post_list':
             $response = $this->getPostList();
             break;
         case 'post_tree':
             $response = $this->getPostTree();
             break;
         case 'post_breadcrumb':
             $response = $this->generatePostBreadcrumb();
             break;
         case 'save_access':
             $response = $this->saveAccess();
             break;
         case 'get_access':
             $response = $this->getAccess();
             break;
         case 'clear_access':
             $response = $this->clearAccess();
             break;
         case 'delete_post':
             $response = $this->deletePost();
             break;
         case 'event_list':
             $response = $this->getEventList();
             break;
         case 'save':
             $response = $this->save();
             break;
         case 'check_roleback':
             $response = $this->checkRoleback();
             break;
         case 'roleback':
             $response = $this->roleback();
             break;
         case 'install_extension':
             $response = $this->installExtension();
             break;
         case 'remove_extension':
             $response = $this->removeExtension();
             break;
         case 'save_configpress':
             $response = $this->saveConfigPress();
             break;
             //TODO - Remove in 07/15/2014
         //TODO - Remove in 07/15/2014
         case 'migrate':
             $response = $this->migrate();
             break;
         default:
             $response = apply_filters('aam_ajax_call', -1, $this->getSubject());
             break;
     }
     return $response;
 }
예제 #6
0
 /**
  *
  * @param type $default
  * @param aam_Control_Subject $subject
  * @return type
  */
 public function ajax($default, aam_Control_Subject $subject = null)
 {
     $this->setSubject($subject);
     switch (aam_Core_Request::request('sub_action')) {
         case 'site_list':
             $response = $this->getSiteList();
             break;
         case 'pin_site':
             $response = $this->pinSite();
             break;
         case 'unpin_site':
             $response = $this->unpinSite();
             break;
         default:
             $response = $default;
             break;
     }
     return $response;
 }
예제 #7
0
 /**
  * Process the ajax call
  *
  * @return string
  *
  * @access public
  */
 public function processAjax()
 {
     $sub_method = aam_Core_Request::request('sub_action');
     if (method_exists($this, $sub_method)) {
         $response = call_user_func(array($this, $sub_method));
     } else {
         $response = apply_filters('aam_ajax_call', self::DEFAULT_AJAX_RESPONSE, $this->getSubject());
     }
     return $response;
 }
예제 #8
0
 /**
  * Control Edit Post/Term
  *
  * Make sure that current user does not have access to edit Post or Term
  *
  * @return void
  *
  * @access public
  */
 public function adminActionEdit()
 {
     $user = $this->getUser();
     if (aam_Core_Request::request('taxonomy')) {
         $control = $user->getObject(aam_Control_Object_Term::UID, aam_Core_Request::request('tag_ID'));
         if ($control->has('backend', aam_Control_Object_Post::ACTION_EDIT)) {
             $this->reject();
         }
     } elseif ($post = $this->getPost()) {
         $control = $user->getObject(aam_Control_Object_Post::UID, $post->ID);
         if ($control->has('backend', aam_Control_Object_Post::ACTION_EDIT)) {
             $this->reject();
         }
     }
 }
예제 #9
0
 /**
  *
  * @global type $wp_post_types
  * @return type
  */
 public function getPostTree()
 {
     global $wp_post_types;
     $type = aam_Core_Request::request('root');
     $tree = array();
     if ($type == "source") {
         if (is_array($wp_post_types)) {
             foreach ($wp_post_types as $post_type => $data) {
                 //show only list of post type which have User Interface
                 if ($data->show_ui) {
                     $tree[] = (object) array('text' => $data->label, 'expanded' => FALSE, 'hasChildren' => TRUE, 'id' => $post_type, 'classes' => 'important');
                 }
             }
         }
     } else {
         if (preg_match('/^[\\d]+$/', $type)) {
             $taxonomy = $this->getTaxonomyByTerm($type);
             $tree = $this->buildBranch(NULL, $taxonomy, $type);
         } else {
             $tree = $this->buildBranch($type);
         }
     }
     if (!count($tree)) {
         $tree[] = (object) array('text' => '<i>' . __('[empty]', 'aam') . '</i>', 'hasChildren' => FALSE, 'classes' => 'post-ontree', 'id' => 'empty-' . uniqid());
     }
     return json_encode($tree);
 }
예제 #10
0
 /**
  *
  * @return type
  */
 protected function getActivityList()
 {
     $response = array('iTotalRecords' => 0, 'iTotalDisplayRecords' => 0, 'sEcho' => aam_Core_Request::request('sEcho'), 'aaData' => array());
     $activity = $this->getSubject()->getObject(aam_Control_Object_Activity::UID);
     $activities = $activity->getOption();
     foreach ($activities as $user_id => $list) {
         $user = new WP_User($user_id);
         if ($user->ID && is_array($list)) {
             foreach ($list as $time => $data) {
                 $response['aaData'][] = array($user->ID, $user->display_name ? $user->display_name : $user->user_nicename, $activity->decorate($data), date('Y-m-d H:i:s', $time));
             }
         }
     }
     return json_encode($response);
 }
예제 #11
0
 /**
  *
  * @global type $wp_post_statuses
  * @global type $wp_post_types
  * @return type
  */
 public function retrievePostList()
 {
     global $wp_post_statuses, $wp_post_types, $wp_taxonomies;
     $term = trim(aam_Core_Request::request('term'));
     //default behavior
     if (empty($term)) {
         $post_type = 'post';
         //root for each Post Type
     } elseif (isset($wp_post_types[$term])) {
         $post_type = $term;
         $term = '';
     } else {
         $taxonomy = $this->getTaxonomy($term);
         if (isset($wp_taxonomies[$taxonomy])) {
             //take in consideration only first object type
             $post_type = $wp_taxonomies[$taxonomy]->object_type[0];
         } else {
             $post_type = 'post';
         }
     }
     $args = array('numberposts' => aam_Core_Request::request('iDisplayLength'), 'offset' => aam_Core_Request::request('iDisplayStart'), 'fields' => 'ids', 'term' => $term, 'taxonomy' => !empty($taxonomy) ? $taxonomy : '', 'post_type' => $post_type, 's' => aam_Core_Request::request('sSearch'), 'post_status' => array());
     $argsAll = array('numberposts' => '999999', 'fields' => 'ids', 'term' => $term, 'taxonomy' => !empty($taxonomy) ? $taxonomy : '', 'post_type' => $post_type, 's' => aam_Core_Request::request('sSearch'), 'post_status' => array());
     if ($post_type != 'attachment') {
         //attachment has only inherit status
         foreach ($wp_post_statuses as $status => $data) {
             if ($data->show_in_admin_status_list) {
                 $args['post_status'][] = $status;
                 $argsAll['post_status'][] = $status;
             }
         }
     }
     $total = 0;
     foreach (wp_count_posts($post_type) as $status => $number) {
         if ($wp_post_statuses[$status]->show_in_admin_status_list) {
             $total += $number;
         }
     }
     //get displayed total
     $displayTotal = count(get_posts($argsAll));
     $response = array('iTotalRecords' => $total, 'iTotalDisplayRecords' => $displayTotal, 'sEcho' => aam_Core_Request::request('sEcho'), 'aaData' => array());
     foreach (get_posts($args) as $post_id) {
         $post = $this->getSubject()->getObject(aam_Control_Object_Post::UID, $post_id);
         $response['aaData'][] = array($post->getPost()->ID, $post->getPost()->post_status, get_edit_post_link($post->getPost()->ID), $post->getPost()->post_title, $wp_post_statuses[$post->getPost()->post_status]->label, '', $post->getOption() && !$post->getInherited() ? 1 : 0);
     }
     return json_encode($response);
 }