コード例 #1
0
 /**
  * {@inheritdoc }
  */
 protected function getConfig()
 {
     $config = mvb_Model_API::getBlogOption(WPACCESS_PREFIX . 'config_' . $this->getID());
     if (!$config) {
         //TODO - Delete is deprecated
         $options = (object) $this->getOldData(WPACCESS_PREFIX . 'options');
         $m_order = $this->getOldData(WPACCESS_PREFIX . 'menu_order');
         $restric = $this->getOldData(WPACCESS_PREFIX . 'restrictions');
         $exclude = $this->getExcludeList($restric);
         $config = (object) array();
         $config->menu = isset($options->menu) ? $options->menu : array();
         $config->metaboxes = isset($options->metaboxes) ? $options->metaboxes : array();
         $config->menu_order = is_array($m_order) ? $m_order : array();
         $config->restrictions = is_array($restric) ? $restric : array();
         $config->excludes = is_array($exclude) ? $exclude : array();
     }
     $roles = mvb_Model_API::getRoleList();
     $this->setMenu($config->menu);
     $this->setMenuOrder($config->menu_order);
     $this->setMetaboxes($config->metaboxes);
     if (isset($roles[$this->getID()]['capabilities'])) {
         $this->setCapabilities($roles[$this->getID()]['capabilities']);
     }
     $this->setRestrictions($config->restrictions);
     $this->setExcludes($config->excludes);
 }
コード例 #2
0
ファイル: manager.php プロジェクト: Netsoro/gdnlteamgroup
 /**
  * Initiate an object and other parameters
  *
  * @param object Main Object
  * @param string $role Current role to work with
  * @param string $rser Current user to work with
  */
 public function __construct($parent, $role = FALSE, $user = FALSE)
 {
     $templatePath = WPACCESS_TEMPLATE_DIR . 'admin_options.html';
     $this->template = mvb_Model_Template::readTemplate($templatePath);
     $this->roles = mvb_Model_API::getRoleList();
     $this->setCurrentRole($role);
     $this->setCurrentUser($user);
     $this->initConfig();
     mvb_Model_Label::initAllLabels();
 }
コード例 #3
0
 public static function renderRoleSelector($tmpl)
 {
     $tmpl = mvb_Model_Template::retrieveSub('ROLE_LIST', $tmpl);
     $list = '';
     foreach (mvb_Model_API::getRoleList() as $role => $data) {
         $selected = self::$parent->getCurrentRole() == $role ? 'selected' : '';
         $markers = array('###value###' => $role, '###title###' => stripcslashes($data['name']) . ' ', '###selected###' => $selected);
         $list .= mvb_Model_Template::updateMarkers($markers, $tmpl);
     }
     return $list;
 }
コード例 #4
0
ファイル: rolemetabox.php プロジェクト: Netsoro/gdnlteamgroup
 /**
  *
  * @global array $submenu
  * @param string $tmpl
  * @param mvb_Model_Manager $parent
  * @return string
  */
 public static function render($tmpl, $parent)
 {
     self::$user_summary = count_users();
     $list_tmpl = mvb_Model_Template::retrieveSub('DELETE_ROLE_LIST', $tmpl);
     $item_tmpl = mvb_Model_Template::retrieveSub('DELETE_ROLE_ITEM', $list_tmpl);
     $list = '';
     foreach (mvb_Model_API::getRoleList() as $role => $data) {
         $list .= self::renderRoleRow($role, $data, $item_tmpl);
     }
     $list = mvb_Model_Template::replaceSub('DELETE_ROLE_ITEM', $list, $list_tmpl);
     return mvb_Model_Template::replaceSub('DELETE_ROLE_LIST', $list, $tmpl);
 }
コード例 #5
0
ファイル: roleconfig.php プロジェクト: Netsoro/gdnlteamgroup
 /**
  * {@inheritdoc }
  */
 protected function getConfig()
 {
     $config = mvb_Model_API::getBlogOption(WPACCESS_PREFIX . 'config_' . $this->getID());
     if ($config) {
         $this->setMenu($config->menu);
         $this->setMenuOrder($config->menu_order);
         $this->setMetaboxes($config->metaboxes);
         $this->setRestrictions($config->restrictions);
     }
     $roles = mvb_Model_API::getRoleList(FALSE);
     //TODO - Potensially hole
     if (isset($roles[$this->getID()]['capabilities'])) {
         $this->setCapabilities($roles[$this->getID()]['capabilities']);
     }
 }
コード例 #6
0
 /**
  * Initiate an object and other parameters
  * 
  * @param string $currentRole Current role to work with
  * @param string $currentUser Current user to work with
  * @param object Main Object
  */
 function __construct($pObj, $currentRole = FALSE, $currentUser = FALSE)
 {
     $this->pObj = $pObj;
     $this->templObj = new mvb_Model_Template();
     $templatePath = WPACCESS_TEMPLATE_DIR . 'admin_options.html';
     $this->template = $this->templObj->readTemplate($templatePath);
     $this->roles = mvb_Model_API::getRoleList();
     $this->custom_caps = mvb_Model_API::getBlogOption(WPACCESS_PREFIX . 'custom_caps', array());
     $this->setCurrentRole($currentRole);
     $this->setCurrentUser($currentUser);
     if ($this->currentUser) {
         $this->config = mvb_Model_API::getUserAccessConfig($this->currentUser);
     } else {
         $this->config = mvb_Model_API::getRoleAccessConfig($this->currentRole);
     }
     //get cache. Compatible with version previouse versions
     $cache = mvb_Model_API::getBlogOption(WPACCESS_PREFIX . 'cache', NULL);
     if (is_array($cache)) {
         //yeap this is new version
         $this->cache = $cache;
     } else {
         //TODO - will be deprecated
         $cache = mvb_Model_API::getBlogOption(WPACCESS_PREFIX . 'options', array());
         $this->cache = isset($cache['settings']) ? $cache['settings'] : array();
         mvb_Model_API::updateBlogOption(WPACCESS_PREFIX . 'cache', $this->cache);
     }
     $this->userSummary = count_users();
 }
コード例 #7
0
ファイル: upgrade.php プロジェクト: Netsoro/gdnlteamgroup
 protected static function upgradeTo165()
 {
     global $wpdb;
     //add custom capabilities
     self::extendCapabilities(array('edit_comment' => 1, 'approve_comment' => 1, 'unapprove_comment' => 1, 'reply_comment' => 1, 'quick_edit_comment' => 1, 'spam_comment' => 1, 'unspam_comment' => 1, 'trash_comment' => 1, 'untrash_comment' => 1, 'delete_comment' => 1, 'edit_permalink' => 1));
     $roles = mvb_Model_API::getRoleList(FALSE);
     //upgrade Restrictions - Roles first
     foreach ($roles as $role => $dummy) {
         $config = mvb_Model_API::getBlogOption(WPACCESS_PREFIX . 'config_' . $role);
         if (!$config) {
             $options = (object) self::getRoleOldData($role, WPACCESS_PREFIX . 'options');
             $m_order = self::getRoleOldData($role, WPACCESS_PREFIX . 'menu_order');
             $restric = self::getRoleOldData($role, WPACCESS_PREFIX . 'restrictions');
             $exclude = self::getExcludeList($restric);
             $config = (object) array();
             $config->menu = isset($options->menu) ? $options->menu : array();
             $config->metaboxes = isset($options->metaboxes) ? $options->metaboxes : array();
             $config->menu_order = is_array($m_order) ? $m_order : array();
             $config->restrictions = is_array($restric) ? $restric : array();
             $config->excludes = is_array($exclude) ? $exclude : array();
         } else {
             $config->excludes = array();
         }
         $up_config = new stdClass();
         $up_config->menu = $config->menu;
         $up_config->metaboxes = $config->metaboxes;
         $up_config->menu_order = $config->menu_order;
         $up_config->restrictions = self::prepareRestrictions($config->restrictions, $config->excludes);
         mvb_Model_API::updateBlogOption(WPACCESS_PREFIX . 'config_' . $role, $up_config);
     }
     //update all users
     $query = "SELECT * FROM {$wpdb->usermeta} WHERE meta_key = '" . WPACCESS_PREFIX . "_config'";
     $results = $wpdb->get_results($query);
     if (is_array($results)) {
         foreach ($results as $user) {
             $config = unserialize($user->meta_value);
             if (!$config) {
                 $options = (object) self::getUserOldData($user->user_id, WPACCESS_PREFIX . 'options');
                 $m_order = self::getUserOldData($user->user_id, WPACCESS_PREFIX . 'menu_order');
                 $restric = self::getUserOldData($user->user_id, WPACCESS_PREFIX . 'restrictions');
                 $exclude = self::getExcludeList($restric);
                 $config = (object) array();
                 $config->menu = isset($options->menu) ? $options->menu : array();
                 $config->metaboxes = isset($options->metaboxes) ? $options->metaboxes : array();
                 $config->menu_order = is_array($m_order) ? $m_order : array();
                 $config->restrictions = is_array($restric) ? $restric : array();
                 $config->excludes = is_array($exclude) ? $exclude : array();
             } else {
                 $config->excludes = array();
             }
             $up_config = new stdClass();
             $up_config->menu = $config->menu;
             $up_config->metaboxes = $config->metaboxes;
             $up_config->menu_order = $config->menu_order;
             $up_config->restrictions = self::prepareRestrictions($config->restrictions, $config->excludes);
             update_user_meta($user->user_id, WPACCESS_PREFIX . 'config', $up_config);
         }
     }
 }
コード例 #8
0
 protected function create_super()
 {
     global $wpdb;
     $answer = intval($_POST['answer']);
     $user_id = get_current_user_id();
     if ($answer == 1) {
         $role_list = mvb_Model_API::getRoleList(FALSE);
         if (isset($role_list[WPACCESS_SADMIN_ROLE])) {
             $result = array('result' => 'success', 'new_role' => WPACCESS_SADMIN_ROLE);
         } else {
             $result = $this->create_role('Super Admin', mvb_Model_API::getAllCapabilities());
         }
         if ($result['result'] == 'success') {
             //update current user role
             if (!is_user_member_of_blog(get_current_blog_id())) {
                 $this->add_blog_admin();
             } else {
                 $this->assign_role(WPACCESS_SADMIN_ROLE, $user_id);
             }
             $this->deprive_role($user_id, WPACCESS_SADMIN_ROLE, WPACCESS_ADMIN_ROLE);
             mvb_Model_API::updateBlogOption(WPACCESS_FTIME_MESSAGE, $answer);
         } else {
             $result = array('result' => 'error');
         }
     } else {
         $result = array('result' => 'error');
     }
     return $result;
 }