示例#1
0
 /**
  * Run the migration process
  *
  * @return string
  *
  * @access public
  */
 public function run()
 {
     @set_time_limit(300);
     ob_start();
     //prevent from any kind of notice, warning printout
     switch (aam_Core_Request::post('step')) {
         case 'collect':
             $response = $this->collect();
             break;
         case 'migrate':
             $response = $this->migrate();
             break;
         case 'cleanup':
             $response = $this->cleanup();
             break;
         case 'complete':
             $response = $this->complete();
             break;
         default:
             $response = array('status' => 'failure');
             break;
     }
     ob_end_clean();
     return json_encode($response);
 }
示例#2
0
文件: role.php 项目: dot2006/jobify
 /**
  *
  * @param type $delete_users
  * @return boolean
  */
 public function delete($delete_users = false)
 {
     $role = new WP_Roles();
     if ($this->getId() !== 'administrator') {
         if ($delete_users) {
             if (current_user_can('delete_users')) {
                 //delete users first
                 $users = new WP_User_Query(array('number' => '', 'blog_id' => get_current_blog_id(), 'role' => aam_Core_Request::post('role')));
                 foreach ($users->get_results() as $user) {
                     //user can not delete himself
                     if ($user->data->ID !== get_current_user_id()) {
                         wp_delete_user($user->data->ID);
                     }
                 }
                 $role->remove_role($this->getId());
                 $status = true;
             } else {
                 $status = false;
             }
         } else {
             $role->remove_role($this->getId());
             $status = true;
         }
     } else {
         $status = false;
     }
     return $status;
 }
示例#3
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);
 }
示例#4
0
 /**
  *
  */
 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')));
         }
     }
 }
示例#5
0
文件: role.php 项目: dot2006/jobify
 /**
  *
  * @return type
  */
 public function delete()
 {
     if ($this->getSubject()->delete(aam_Core_Request::post('delete_users'))) {
         $status = 'success';
     } else {
         $status = 'failure';
     }
     return json_encode(array('status' => $status));
 }
 /**
  * Remove extension
  *
  * @return string
  *
  * @access public
  */
 public function remove()
 {
     $license = aam_Core_Request::post('license');
     $ext = aam_Core_Request::post('extension');
     if ($this->getRepository()->remove($ext, $license)) {
         $response = array('status' => 'success');
     } else {
         $response = array('status' => 'failure', 'reasons' => $this->getRepository()->getErrors());
     }
     return json_encode($response);
 }
示例#7
0
 /**
  * 
  * @return type
  */
 public function processAjax()
 {
     switch (aam_Core_Request::post('sub_action')) {
         case 'map_data':
             $response = $this->getMapData();
             break;
         default:
             $response = json_encode(array('status' => 'failure'));
             break;
     }
     return $response;
 }
示例#8
0
 /**
  * Remove extension
  *
  * @return string
  *
  * @access public
  */
 public function remove()
 {
     $extension = new aam_Core_Extension();
     $license = aam_Core_Request::post('license');
     $ext = aam_Core_Request::post('extension');
     if ($extension && $extension->remove($ext, $license)) {
         $response = array('status' => 'success');
     } else {
         $response = array('status' => 'failure');
     }
     return json_encode($response);
 }
示例#9
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'));
 }
示例#10
0
 /**
  * Clear Default Access settings
  * 
  * @return string
  * 
  * @access public
  */
 public function clearDefaultAccess()
 {
     aam_Core_API::deleteBlogOption($this->getOptionName(aam_Core_Request::post('id')));
     return json_encode(array('status' => 'success'));
 }
示例#11
0
 /**
  * Save ConfigPress
  * 
  * @return string
  * 
  * @access protected
  */
 protected function saveConfigPress()
 {
     $result = aam_Core_ConfigPress::write(aam_Core_Request::post('config'));
     return json_encode(array('status' => $result === false ? 'failure' : 'success'));
 }
示例#12
0
 /**
  * Save ConfigPress
  *
  * @return string
  *
  * @access public
  */
 public function saveConfigPress()
 {
     if (current_user_can(aam_Core_ConfigPress::getParam('aam.menu.configpress.capability', 'administrator'))) {
         $result = aam_Core_ConfigPress::write(aam_Core_Request::post('config'));
     } else {
         $result = false;
     }
     return json_encode(array('status' => $result === false ? 'failure' : 'success'));
 }
 protected function pinSite()
 {
     return json_encode(array('status' => aam_Core_API::updateBlogOption('aam_default_site', aam_Core_Request::post('blog'), 1) ? 'success' : 'failure'));
 }
示例#14
0
 /**
  *
  * @return type
  */
 public function save()
 {
     $this->getSubject()->save($this->prepareSaveOptions(aam_Core_Request::post('aam')));
     return json_encode(array('status' => 'success'));
 }
示例#15
0
 /**
  * Hanlde Metabox initialization process
  *
  * @return void
  *
  * @access public
  */
 public function metaboxes()
 {
     global $post;
     //make sure that nobody is playing with screen options
     if ($post instanceof WP_Post) {
         $screen = $post->post_type;
     } elseif ($screen_object = get_current_screen()) {
         $screen = $screen_object->id;
     } else {
         $screen = '';
     }
     if (aam_Core_Request::get('aam_meta_init')) {
         try {
             $model = new aam_View_Metabox();
             $model->run($screen);
         } catch (Exception $e) {
         }
     } else {
         $this->getUser()->getObject(aam_Control_Object_Metabox::UID)->filterBackend($screen);
     }
 }
示例#16
0
文件: ajax.php 项目: dot2006/jobify
 /**
  * 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 '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 '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;
             //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;
 }
示例#17
0
 /**
  * 
  * @param type $user
  * @param type $username
  * @param type $password
  * @return type
  */
 public function authenticate($user, $username, $password)
 {
     if (!is_wp_error($user)) {
         $login_history = get_user_meta($user->ID, 'aam_login_history', true);
         $ip = aam_Core_Request::server('REMOTE_ADDR');
     }
     return $user;
 }
示例#18
0
 /**
  * Restore default access level for object
  *
  * @return string
  *
  * @access public
  */
 public function clearAccess()
 {
     $type = aam_Core_Request::post('type');
     $object_id = aam_Core_Request::post('id');
     if ($type === aam_Control_Object_Term::UID) {
         $object = $this->getSubject()->getObject(aam_Control_Object_Term::UID, $object_id);
     } else {
         $object = $this->getSubject()->getObject(aam_Control_Object_Post::UID, $object_id);
     }
     return json_encode(array('status' => $object->delete() ? 'success' : 'failure'));
 }
示例#19
0
 /**
  *
  * @global type $wp_post_types
  * @return type
  */
 public function retrieveList()
 {
     global $wp_post_types;
     if (aam_Core_Request::post('refresh') == 1) {
         aam_Core_API::deleteBlogOption('aam_metabox_cache');
         $type_list = array_keys($wp_post_types);
         array_unshift($type_list, self::GROUP_WIDGETS);
         foreach ($type_list as $type) {
             if ($type == 'widgets') {
                 $url = add_query_arg('aam_meta_init', 1, admin_url('index.php'));
             } else {
                 $url = add_query_arg('aam_meta_init', 1, admin_url('post-new.php?post_type=' . $type));
             }
             //grab metaboxes
             aam_Core_API::cURL($url);
         }
     }
     return $this->buildMetaboxList();
 }
 /**
  *
  * @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);
 }
示例#21
0
文件: api.php 项目: dot2006/jobify
 /**
  * Check if SSL is used
  * 
  * @return boolean
  * 
  * @access public
  * @static
  */
 public static function isSSL()
 {
     if (force_ssl_admin()) {
         $response = true;
     } elseif (aam_Core_Request::server('HTTPS')) {
         $response = true;
     } elseif (aam_Core_Request::server('REQUEST_SCHEME') == 'https') {
         $response = true;
     } else {
         $response = false;
     }
     return $response;
 }
示例#22
0
 /**
  *
  * @return type
  */
 public function deleteCapability()
 {
     $roles = new WP_Roles();
     $capability = trim(aam_Core_Request::post('capability'));
     if ($capability) {
         foreach ($roles->role_objects as $role) {
             $role->remove_cap($capability);
         }
         $response = array('status' => 'success');
     } else {
         $response = array('status' => 'failure');
     }
     return json_encode($response);
 }