public static function renderSiteSelector($tmpl) { global $wpdb; $tmpl = mvb_Model_Template::retrieveSub('MULTISITE_SELECTOR', $tmpl); $content = ''; $render_mss = mvb_Model_Helper::getParam('render_mss', 'REQUEST'); if (mvb_Model_API::isNetworkPanel() || $render_mss) { $list_tmpl = mvb_Model_Template::retrieveSub('ROLE_LIST', $tmpl); $list = ''; $sites = mvb_Model_Helper::getSiteList(); $current = mvb_Model_Helper::getParam('site', 'REQUEST', get_current_blog_id()); if (is_array($sites)) { foreach ($sites as $site) { $blog_prefix = $wpdb->get_blog_prefix($site->blog_id); //get Site Name $query = "SELECT option_value FROM {$blog_prefix}options "; $query .= "WHERE option_name = 'blogname'"; $name = $wpdb->get_var($query); if ($site->blog_id == $current) { $is_current = 'selected'; $c_name = $name; } else { $is_current = ''; } $markers = array('###value###' => $site->blog_id, '###title###' => $name . ' ', '###selected###' => $is_current); $list .= mvb_Model_Template::updateMarkers($markers, $list_tmpl); } } $content = mvb_Model_Template::replaceSub('ROLE_LIST', $list, $tmpl); $markers = array('###current_site###' => mvb_Model_Helper::cutStr($c_name, 15), '###title_full###' => $c_name); $content = mvb_Model_Template::updateMarkers($markers, $content); } return $content; }
/** * Check if user is super admin * * @since version 1.5.5 * @param int $user_id * @return bool */ public static function isSuperAdmin($user_id = FALSE) { $user_id = $user_id ? $user_id : get_current_user_id(); if (mvb_Model_API::isNetworkPanel()) { $super = is_super_admin($user_id) ? TRUE : FALSE; } else { $super = self::getCurrentUser()->has_cap(WPACCESS_SADMIN_ROLE) ? TRUE : FALSE; } return $super; }
/** * Check if user is super admin * * @since version 1.5.5 * @param int $user_id * @return bool */ public static function isSuperAdmin($user_id = FALSE) { $super = FALSE; $user_id = $user_id ? $user_id : get_current_user_id(); if (mvb_Model_API::isNetworkPanel() && is_super_admin($user_id)) { $super = TRUE; } elseif (!mvb_Model_API::isNetworkPanel()) { //check if user has a rule Super Admin $data = get_userdata($user_id); $cap_val = self::getCurrentBlog()->getPrefix() . 'capabilities'; if (isset($data->{$cap_val}[WPACCESS_SADMIN_ROLE])) { $super = TRUE; } else { //check if answer is stored $answer = self::getBlogOption(WPACCESS_FTIME_MESSAGE, 0); if (!$answer) { $super = TRUE; } } } return $super; }
/** * */ public function manager_page() { $c_role = isset($_REQUEST['role']) ? $_REQUEST['role'] : FALSE; $c_user = isset($_REQUEST['user']) ? $_REQUEST['user'] : FALSE; if (mvb_Model_API::isNetworkPanel()) { //require phpQuery require_once WPACCESS_BASE_DIR . 'library/phpQuery/phpQuery.php'; //TODO - I don't like site $blog_id = isset($_GET['site']) ? $_GET['site'] : get_current_blog_id(); $c_blog = mvb_Model_API::getBlog($blog_id); $m = new mvb_Model_Manager($this, $c_role, $c_user); $m->do_save(); $params = array('page' => 'wp_access', 'render_mss' => 1, 'site' => $blog_id, 'role' => $c_role, 'user' => $c_user); $link = get_admin_url($c_blog->getID(), 'users.php'); $url = add_query_arg($params, $link); $result = mvb_Model_Helper::cURL($url, TRUE, TRUE); if (isset($result['content']) && $result['content']) { $content = phpQuery::newDocument($result['content']); echo $content['#aam_wrap']->htmlOuter(); unset($content); } else { wp_die(mvb_Model_Label::get('LABEL_145')); } } else { $m = new mvb_Model_Manager($this, $c_role, $c_user); $m->do_save(); $m->manage(); } }
function do_save() { if (isset($_POST['submited'])) { $params = isset($_POST['wpaccess']) ? $_POST['wpaccess'] : array(); $error_message = NULL; if (mvb_Model_API::isNetworkPanel() && mvb_Model_ConfigPress::getOption('aam.multisite.apply_all') == 'true') { $limit = apply_filters(WPACCESS_PREFIX . 'msar_restrict_limit', WPACCESS_APPLY_LIMIT); foreach (mvb_Model_Helper::getSiteList() as $i => $site) { if ($site->blog_id == $_GET['site']) { continue; } elseif ($i + 1 >= WPACCESS_APPLY_LIMIT && $limit != -1) { $error_message = mvb_Model_Label::get('LABEL_148'); break; } mvb_Model_API::setCurrentBlog($site->blog_id); $this->initConfig(); $this->config->setMenu(isset($params['menu']) ? $params['menu'] : array()); $this->config->setMetaboxes(isset($params['metabox']) ? $params['metabox'] : array()); $this->config->setCapabilities(isset($params['advance']) ? $params['advance'] : array()); $this->config->saveConfig(); } } //overwrite current blog //TODO - maybe there is better way if (isset($_GET['site'])) { mvb_Model_API::setCurrentBlog($_GET['site']); } $this->config->setMenu(isset($params['menu']) ? $params['menu'] : array()); $this->config->setMetaboxes(isset($params['metabox']) ? $params['metabox'] : array()); $this->config->setCapabilities(isset($params['advance']) ? $params['advance'] : array()); $this->config->saveConfig(); mvb_Model_ConfigPress::saveConfig(stripslashes($params['config_press'])); } else { $error_message = FALSE; } return $error_message; }
/** * */ public function accessManagerPage() { $c_role = mvb_Model_Helper::getParam('current_role', 'REQUEST'); $c_user = mvb_Model_Helper::getParam('current_user', 'REQUEST'); if (mvb_Model_API::isNetworkPanel()) { //TODO - I don't like site $blog_id = isset($_GET['site']) ? $_GET['site'] : get_current_blog_id(); $c_blog = mvb_Model_API::getBlog($blog_id); $m = new mvb_Model_Manager($this, $c_role, $c_user); $error = $m->do_save(); $params = array('page' => 'wp_access', 'render_mss' => 1, 'site' => $blog_id, 'show_message' => isset($_POST['submited']) && is_null($error) ? 1 : 0, 'current_role' => $c_role, 'current_user' => $c_user); $link = get_admin_url($c_blog->getID(), 'admin.php'); $url = add_query_arg($params, $link); $result = mvb_Model_Helper::cURL($url, TRUE, TRUE); if (isset($result['content']) && $result['content']) { $content = phpQuery::newDocument($result['content']); if ($error) { //TODO $content['.plugin-notification']->append('<p>' . mvb_Model_Label::get('LABEL_167') . ' <a href="' . WPACCESS_ERROR167_URL . '" target="_blank">' . mvb_Model_Label::get('LABEL_168') . '</a></p>'); } echo $content['#aam_wrap']->htmlOuter(); unset($content); } else { wp_die(mvb_Model_Label::get('LABEL_145')); } } else { $m = new mvb_Model_Manager($this, $c_role, $c_user); $m->do_save(); $m->manage(); } }
/** * * @global type $wpdb * @param type $template * @return type */ function renderSiteSelector($template) { global $wpdb; $m_tempate = $this->templObj->retrieveSub('MULTISITE_SELECTOR', $template); if (mvb_Model_API::isNetworkPanel() || isset($_REQUEST['render_mss'])) { $listTemplate = $this->templObj->retrieveSub('ROLE_LIST', $m_tempate); $list = ''; $sites = mvb_Model_Helper::getSiteList(); $current = isset($_REQUEST['site']) ? $_REQUEST['site'] : get_current_blog_id(); if (is_array($sites)) { foreach ($sites as $site) { $blog_prefix = $wpdb->get_blog_prefix($site->blog_id); //get Site Name $query = "SELECT option_value FROM {$blog_prefix}options "; $query .= "WHERE option_name = 'blogname'"; $name = $wpdb->get_var($query); if ($site->blog_id == $current) { $is_current = 'selected="selected"'; $c_name = $name; } else { $is_current = ''; } $markers = array('###value###' => $site->blog_id, '###title###' => $name . ' ', '###selected###' => $is_current); $list .= $this->templObj->updateMarkers($markers, $listTemplate); } } $m_tempate = $this->templObj->replaceSub('ROLE_LIST', $list, $m_tempate); $m_array = array('###current_site###' => strlen($c_name) > 15 ? substr($c_name, 0, 14) . '...' : $c_name, '###title_full###' => $c_name); $m_tempate = $this->templObj->updateMarkers($m_array, $m_tempate); } else { $m_tempate = ''; } return $this->templObj->replaceSub('MULTISITE_SELECTOR', $m_tempate, $template); }