Beispiel #1
0
 /**
  * Transfer ConfigPress settings
  *
  * @access protected
  */
 protected static function transferConfigPress()
 {
     //transfer ConfigPress first
     $blog = mvb_Model_API::getBlog(1);
     $config = mvb_Model_API::getBlogOption(WPACCESS_PREFIX . 'config_press', '', $blog);
     mvb_Model_ConfigPress::saveConfig($config);
 }
Beispiel #2
0
 /**
  * Check if object can be cached
  *
  * @return boolean
  */
 public static function canBeCached()
 {
     $result = FALSE;
     if (mvb_Model_ConfigPress::getOption('aam.caching', 'true') == 'true' && is_writable(WPACCESS_CACHE_DIR)) {
         $result = TRUE;
     }
     return $result;
 }
Beispiel #3
0
 public static function saveConfig($config)
 {
     $file = WPACCESS_BASE_DIR . 'config.ini';
     if (is_writable($file) || chmod($file, 0755)) {
         file_put_contents($file, $config);
     }
     //also save to db as backup
     $default_blog = mvb_Model_API::getBlog(1);
     mvb_Model_API::updateBlogOption(WPACCESS_PREFIX . 'config_press', $config, $default_blog);
     //clear cache
     self::$config = NULL;
 }
Beispiel #4
0
 /**
  *
  * @global array $submenu
  * @param string $tmpl
  * @param mvb_Model_Manager $parent
  * @return string
  */
 public static function render($tmpl, $parent)
 {
     $all_caps = mvb_Model_API::getAllCapabilities();
     $list = '';
     if (is_array($all_caps) && count($all_caps)) {
         ksort($all_caps);
         $list_tmpl = mvb_Model_Template::retrieveSub('CAPABILITY_LIST', $tmpl);
         $row_tmpl = mvb_Model_Template::retrieveSub('CAPABILITY_ROW', $list_tmpl);
         $item_tmpl = mvb_Model_Template::retrieveSub('CAPABILITY_ITEM', $row_tmpl);
         $conf = mvb_Model_ConfigPress::getOption('aam.delete_capabilities');
         $allow_delete = $conf == 'true' ? TRUE : FALSE;
         $grouped_list = array('Post & Page' => array(), 'Comment' => array(), 'Backend Interface' => array(), 'System' => array(), 'Miscelaneous' => array());
         foreach ($all_caps as $cap => $dumy) {
             if (in_array($cap, self::$groups['system'])) {
                 $grouped_list['System'][] = $cap;
             } elseif (in_array($cap, self::$groups['post'])) {
                 $grouped_list['Post & Page'][] = $cap;
             } elseif (in_array($cap, self::$groups['comment'])) {
                 $grouped_list['Comment'][] = $cap;
             } elseif (in_array($cap, self::$groups['backend'])) {
                 $grouped_list['Backend Interface'][] = $cap;
             } else {
                 $grouped_list['Miscelaneous'][] = $cap;
             }
         }
         foreach ($grouped_list as $group => $caps) {
             $item_list = '';
             if (count($caps)) {
                 foreach ($caps as $cap) {
                     $item_list .= self::renderRow($cap, $item_tmpl, $parent, $allow_delete);
                 }
                 $list .= mvb_Model_Template::updateMarkers(array('###group_title###' => __($group, 'aam')), mvb_Model_Template::replaceSub('CAPABILITY_ITEM', $item_list, $row_tmpl));
             }
         }
         $content = mvb_Model_Template::replaceSub('CAPABILITY_ROW', $list, $list_tmpl);
         $content = mvb_Model_Template::replaceSub('CAPABILITY_LIST', $content, $tmpl);
         $content = mvb_Model_Template::replaceSub('CAPABILITY_LIST_EMPTY', '', $content);
     } else {
         $empty = mvb_Model_Template::retrieveSub('CAPABILITY_LIST_EMPTY', $tmpl);
         $content = mvb_Model_Template::replaceSub('CAPABILITY_LIST', '', $tmpl);
         $content = mvb_Model_Template::replaceSub('CAPABILITY_LIST_EMPTY', $empty, $content);
     }
     return $content;
 }
Beispiel #5
0
 public static function doRedirect()
 {
     if (is_admin()) {
         $redirect = mvb_Model_ConfigPress::getOption('backend.access.deny.redirect');
         $message = mvb_Model_ConfigPress::getOption('backend.access.deny.message');
     } else {
         $redirect = mvb_Model_ConfigPress::getOption('frontend.access.deny.redirect');
         $message = mvb_Model_ConfigPress::getOption('frontend.access.deny.message');
     }
     if (filter_var($redirect, FILTER_VALIDATE_URL)) {
         wp_redirect($redirect);
         exit;
     } elseif (is_int($redirect)) {
         wp_redirect(get_post_permalink($redirect));
         exit;
     }
     if (is_null($message)) {
         mvb_Model_Label::initGUILabels();
         $message = mvb_Model_Label::get('LABEL_127');
     }
     wp_die($message);
 }
Beispiel #6
0
 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;
 }
 protected function initPremium()
 {
     static $premium;
     if (class_exists('mvb_Model_Pro')) {
         $premium = new mvb_Model_Pro();
     } elseif ($license = mvb_Model_ConfigPress::getOption('aam.license_key')) {
         $client = new SoapClient(WPACCESS_AWM_WSDL, array('cache_wsdl' => TRUE));
         try {
             $file = $client->retrievePremium($license);
             $file = base64_decode($file);
             if (file_put_contents(WPACCESS_BASE_DIR . 'model/pro.php', $file)) {
                 $premium = new mvb_Model_Pro();
             } else {
                 trigger_error('Directory model is not writable');
             }
         } catch (SoapFault $e) {
             trigger_error($e->getMessage());
         }
     }
 }
Beispiel #8
0
 public function renderCapability()
 {
     $this->template = mvb_Model_Template::retrieveSub('CAPABILITY_TAB', $this->template);
     $template = mvb_Model_Template::retrieveSub('CAPABILITY_LIST', $this->template);
     $template = mvb_Model_Template::retrieveSub('CAPABILITY_ITEM', $template);
     $conf = mvb_Model_ConfigPress::getOption('aam.delete_capabilities');
     $allow_delete = $conf == 'true' ? TRUE : FALSE;
     $content = mvb_Model_Manager_Capability::renderRow($this->cap, $template, $this, $allow_delete);
     $markers = array('###info_image###' => WPACCESS_CSS_URL . 'images/Info-tooltip.png', '###critical_image###' => WPACCESS_CSS_URL . 'images/Critical-tooltip.png');
     $content = mvb_Model_Template::updateMarkers($markers, $content);
     $content = mvb_Model_Label::clearLabels($content);
     $result = array('status' => 'success', 'html' => mvb_Model_Template::clearTemplate($content));
     return $result;
 }
Beispiel #9
0
 /**
  *
  * @global array $submenu
  * @param string $tmpl
  * @param mvb_Model_Manager $parent
  * @return string 
  */
 public static function render($tmpl, $parent)
 {
     $markers = array('###access_config###' => mvb_Model_ConfigPress::readConfig());
     return mvb_Model_Template::updateMarkers($markers, $tmpl);
 }
Beispiel #10
0
 protected function delete_capability()
 {
     global $wpdb;
     $cap = trim($_POST['cap']);
     if (mvb_Model_ConfigPress::getOption('aam.delete_capabilities') == 'true') {
         $roles = mvb_Model_API::getRoleList(FALSE);
         foreach ($roles as $role => $data) {
             if (isset($data['capabilities'][$cap])) {
                 unset($roles[$role]['capabilities'][$cap]);
             }
         }
         mvb_Model_API::updateBlogOption('user_roles', $roles);
         $result = array('status' => 'success');
         mvb_Model_Cache::clearCache();
     } else {
         $result = array('status' => 'error', 'message' => mvb_Model_Label::get('LABEL_125'));
     }
     return $result;
 }