/** * */ function manage() { $content = $this->getMainOptionsList(); $this->template = $this->renderSiteSelector($this->template); $this->template = $this->renderRoleSelector($this->template); $this->template = $this->renderUserSelector($this->template); $this->template = $this->renderDeleteRoleList($this->template); $content = $this->templObj->replaceSub('MAIN_OPTIONS_LIST', $content, $this->template); $blog = mvb_Model_API::getCurrentBlog(); //TODO - render_mss do not like it if (mvb_Model_API::isNetworkPanel() || isset($_REQUEST['render_mss'])) { $s_link = network_admin_url('users.php?page=wp_access'); $blog_id = isset($_GET['site']) ? $_GET['site'] : get_current_blog_id(); $s_link = add_query_arg('site', $blog_id, $s_link); } else { $s_link = admin_url('users.php?page=wp_access'); } $markerArray = array('###current_role###' => $this->roles[$this->currentRole]['name'], '###form_action###' => $s_link, '###current_role_id###' => $this->currentRole, '###site_url###' => $blog->getURL(), '###message_class###' => isset($_POST['submited']) || isset($_GET['show_message']) ? 'message-active' : 'message-passive', '###nonce###' => wp_nonce_field(WPACCESS_PREFIX . 'options')); //get current user data if ($this->currentUser) { $c_user = get_userdata($this->currentUser); $markerArray['###current_user###'] = $c_user->user_login; $markerArray['###current_user_id###'] = $c_user->ID; } else { $markerArray['###current_user###'] = mvb_Model_Label::get('LABEL_120'); } //Apply all blogs $t = $this->templObj->retrieveSub('APPLY_ALL', $content); if (mvb_Model_API::isNetworkPanel() || isset($_REQUEST['render_mss'])) { $content = $this->templObj->replaceSub('APPLY_ALL', $t, $content); } else { $content = $this->templObj->replaceSub('APPLY_ALL', '', $content); } $content = $this->templObj->updateMarkers($markerArray, $content); $content = $this->templObj->clearTemplate($content); //add filter to future add-ons $content = apply_filters(WPACCESS_PREFIX . 'option_page', $content); echo $content; }
/** * * @param type $role */ public function getUserList($role) { $args = array('number' => '', 'blog_id' => mvb_Model_API::getCurrentBlog()->getID(), 'role' => $role, 'fields' => 'all', 'orderby' => 'user_nicename', 'order' => 'ASC'); // Query the user IDs for this page $wp_user_search = new WP_User_Query($args); return $wp_user_search->get_results(); }
protected function deprive_role($skip_id, $role, $replace_role) { global $wpdb; //TODO Should be better way to grab the list of users $blog = mvb_Model_API::getCurrentBlog(); $query = "SELECT user_id FROM {$wpdb->usermeta} WHERE "; $query .= 'meta_key = "' . $blog->getPrefix() . 'capabilities"'; $list = $wpdb->get_results($query); if (is_array($list) && count($list)) { foreach ($list as $row) { if ($row->user_id == $skip_id) { continue; } $m = new mvb_Model_User($row->user_id); if ($m->has_cap($role)) { $m->remove_role($role); $m->add_role($replace_role); } } } }