Exemple #1
0
 /**
  *
  * @param type $object_id
  */
 public function init($object_id)
 {
     $filename = aam_Core_API::getBlogOption('aam_' . self::UID, '');
     if ($filename && file_exists(AAM_TEMP_DIR . $filename)) {
         $this->setOption($filename);
         $this->setConfig(file_get_contents(AAM_TEMP_DIR . $filename));
         $this->parseConfig(AAM_TEMP_DIR . $filename);
     }
 }
Exemple #2
0
 protected function getMapData()
 {
     $stats = aam_Core_API::getBlogOption('aam_security_login_stats', array());
     $list = array();
     foreach ($stats as $country => $data) {
         $list[] = array($country, $data['failed']);
     }
     return json_encode(array('list' => $list));
 }
Exemple #3
0
 /**
  * Constructor
  *
  * The filter "aam_cpanel" can be used to control the Control Panel items.
  *
  * @return void
  *
  * @access public
  */
 public function __construct()
 {
     parent::__construct();
     //get repository
     $repository = aam_Core_API::getBlogOption('aam_extensions', array(), 1);
     if (is_array($repository)) {
         $this->_repository = $repository;
     }
 }
Exemple #4
0
function aam_migration_note()
{
    if (class_exists('aam_Core_Migrate') && !aam_Core_API::getBlogOption('aam_migrated')) {
        echo "<div class='update-nag'>";
        echo __('Migrate your old AAM settings to the new AAM platform. ', 'aam');
        echo '<a href="#" id="aam_migrate">' . __('Click to Migrate', 'aam') . '</a>';
        echo '</div>';
    }
}
 /**
  * Read ConfigPress File content
  * 
  * @return string
  * 
  * @access public
  * @static
  */
 public static function read()
 {
     $filename = aam_Core_API::getBlogOption('aam_configpress', '');
     if ($filename && file_exists(AAM_TEMP_DIR . $filename)) {
         $content = file_get_contents(AAM_TEMP_DIR . $filename);
     } else {
         $content = '';
     }
     return $content;
 }
Exemple #6
0
 public static function query($ip)
 {
     $response = aam_Core_API::cURL('http://freegeoip.net/xml/' . $ip, false, true);
     if ($response['status'] == 'success') {
         $data = simplexml_load_string($response['content']);
         $geodata = (object) array('countryCode' => (string) $data->CountryCode, 'countryName' => (string) $data->CountryName, 'region' => (string) $data->RegionCode, 'city' => (string) $data->City, 'zip' => (string) $data->ZipCode);
     } else {
         $geodata = null;
     }
     return $geodata;
 }
Exemple #7
0
 /**
  * Check if specified user can be managed by current user
  * 
  * @param WP_User $user
  * 
  * @return boolean
  * 
  * @access public
  */
 public function canManage(WP_User $user = null)
 {
     //AAM does not support multi-roles. Get only one first role
     $roles = $user->roles;
     $role = get_role(array_shift($roles));
     //get user's highest level
     $level = aam_Core_API::getUserLevel();
     if (empty($role->capabilities['level_' . $level]) || !$role->capabilities['level_' . $level] || aam_Core_API::isSuperAdmin()) {
         $response = true;
     } else {
         $response = false;
     }
     return $response;
 }
Exemple #8
0
 /**
  * Check if view can be managed
  * 
  * @return void
  * 
  * @access public
  * @throw Exception You are not allowed to manage current view 
  */
 public function isManagable()
 {
     if ($this->getSubject()->getUID() == aam_Control_Subject_Role::UID) {
         $caps = $this->getSubject()->capabilities;
     } elseif ($this->getSubject()->getUID == aam_Control_Subject_User::UID) {
         //AAM does not support multi-roles. Get only one first role
         $roles = $this->getSubject()->roles;
         $caps = get_role(array_shift($roles))->capabilities;
     } else {
         $caps = apply_filters('aam_managable_capabilities', null, $this);
     }
     if ($caps && !aam_Core_API::isSuperAdmin()) {
         //get user's highest level
         $level = aam_Core_API::getUserLevel();
         if (!empty($caps['level_' . $level]) && $caps['level_' . $level]) {
             throw new Exception(__('You are not allowed to manager current view', 'aam'));
         }
     }
     return true;
 }
 /**
  * Get ConfigPress parameter
  * 
  * @param string $param
  * @param mixed $default
  * 
  * @return mixed
  * 
  * @access public
  * @static
  */
 public static function getParam($param, $default = null)
 {
     //initialize the ConfigPress if empty
     if (is_null(self::$_config)) {
         $filename = aam_Core_API::getBlogOption('aam_configpress', '');
         if ($filename && file_exists(AAM_TEMP_DIR . $filename)) {
             //parse the file content & create Config INI Object
             self::parseConfig(AAM_TEMP_DIR . $filename);
         }
     }
     //find the parameter
     $tree = self::$_config;
     foreach (explode('.', $param) as $section) {
         if (isset($tree->{$section})) {
             $tree = $tree->{$section};
         } else {
             $tree = $default;
             break;
         }
     }
     return self::parseParam($tree, $default);
 }
Exemple #10
0
 /**
  * Get default Term Access
  * 
  * @param array                   $access
  * @param aam_Control_Object_Term $object
  * 
  * @return array
  * 
  * @access public
  */
 public function termAccessOption($access, $object)
 {
     global $wp_post_types;
     $this->setSubject($object->getSubject());
     //find the object type
     $post_type = null;
     foreach ($wp_post_types as $type => $dump) {
         if (is_object_in_taxonomy($type, $object->getTerm()->taxonomy)) {
             $post_type = $type;
             break;
         }
     }
     if (empty($access)) {
         $access = aam_Core_API::getBlogOption($this->getOptionName($post_type), array());
     }
     return $access;
 }
Exemple #11
0
 /**
  * Get Post or Term access
  *
  * @return string
  *
  * @access public
  */
 public function getAccess()
 {
     return json_encode(array('html' => $this->loadTemplate(dirname(__FILE__) . '/tmpl/control_area.phtml'), 'counter' => apply_filters('wpaccess_restrict_limit', aam_Core_API::getBlogOption('aam_access_limit', 0))));
 }
Exemple #12
0
 /**
  * Change the Update flag
  *
  * This will stop to run the update again
  *
  * @return boolean
  *
  * @access public
  */
 public function updateFlag()
 {
     return aam_Core_API::updateBlogOption('aam_updated', AAM_VERSION, 1);
 }
 /**
  * @inheritdoc
  */
 public function setFlag($flag, $value = true)
 {
     $option = 'aam_' . self::UID . '_' . $this->getId() . "_{$flag}";
     if ($value === true) {
         aam_Core_API::updateBlogOption($option, $value);
     } else {
         aam_Core_API::deleteBlogOption($option);
     }
 }
Exemple #14
0
 protected function complete()
 {
     aam_Core_API::updateBlogOption('aam_migrated', 1, 1);
     return array('status' => 'success', 'stop' => 1);
 }
Exemple #15
0
 /**
  *
  * @param type $object
  * @param type $object_id
  * @return type
  */
 public function deleteOption($object, $object_id = 0)
 {
     return aam_Core_API::deleteBlogOption($this->getOptionName($object, $object_id));
 }
 /**
  * Filter list of editable roles
  *
  * Does not allow for current user manager roles that have same or higher Level
  *
  * @param array $roles
  *
  * @return array
  *
  * @access public
  */
 public function editableRoles($roles)
 {
     $filtered = array();
     $level = aam_Core_API::getUserLevel();
     //check if super admin is specified
     if (aam_Core_API::isSuperAdmin() === false) {
         foreach ($roles as $role => $info) {
             if (empty($info['capabilities']["level_{$level}"]) || !$info['capabilities']["level_{$level}"]) {
                 $filtered[$role] = $info;
             }
         }
     } else {
         $filtered = $roles;
     }
     return $filtered;
 }
 protected function unpinSite()
 {
     return json_encode(array('status' => aam_Core_API::deleteBlogOption('aam_default_site', 1) ? 'success' : 'failure'));
 }
Exemple #18
0
 /**
  * 
  * @param type $errors
  * @param type $redirect_to
  */
 public function loginFailure($errors, $redirect_to)
 {
     $this->_cache = aam_Core_API::getBlogOption('aam_security_login_cache', array());
     $this->_cacheLimit = aam_Core_ConfigPress::getParam('security.login.cache_limit', 1000);
     if ($this->isGeoLookupOn()) {
         $this->_stats = aam_Core_API::getBlogOption('aam_security_login_stats', array());
         $info = $this->retrieveGeoData();
         if ($info instanceof stdClass) {
             if (!isset($this->_stats[$info->countryCode])) {
                 $this->_stats[$info->countryCode] = array('failed' => 0);
             }
             $this->_stats[$info->countryCode]['failed']++;
             aam_Core_API::updateBlogOption('aam_security_login_stats', $this->_stats);
         }
     }
     if ($this->isLoginLockoutOn()) {
         $this->loginLockout();
     }
     aam_Core_API::updateBlogOption('aam_security_login_cache', $this->_cache);
     return $errors;
 }
Exemple #19
0
 /**
  *
  * @return type
  */
 public function getAccess()
 {
     $type = aam_Core_Request::post('type');
     $object_id = aam_Core_Request::post('id');
     if ($type === 'term') {
         $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('settings' => $object->getOption(), 'counter' => apply_filters('wpaccess_restrict_limit', aam_Core_API::getBlogOption('aam_access_limit', 0))));
 }
Exemple #20
0
 /**
  * Remove Extension from the repository
  *
  * @param string $extension
  * @param string $license
  *
  * @return boolean
  *
  * @access public
  */
 public function remove($extension, $license)
 {
     global $wp_filesystem;
     $this->initFilesystem();
     $repository = aam_Core_API::getBlogOption('aam_extensions', array(), 1);
     $response = false;
     if (isset($repository[$extension])) {
         $basedir = $repository[$extension]->basedir;
         if ($wp_filesystem->rmdir($basedir, true)) {
             $response = true;
             unset($repository[$extension]);
             aam_Core_API::updateBlogOption('aam_extensions', $repository, 1);
         }
     }
     return $response;
 }
Exemple #21
0
 /**
  *
  * @global type $wp_post_types
  * @return type
  */
 protected function buildMetaboxList()
 {
     global $wp_post_types;
     $cache = aam_Core_API::getBlogOption('aam_metabox_cache', array());
     if ($this->getSubject()->getUID() == 'visitor') {
         $list = array('widgets' => isset($cache['widgets']) ? $cache['widgets'] : array());
     } else {
         $list = $cache;
     }
     $content = '<div id="metabox_list">';
     foreach ($list as $screen => $metaboxes) {
         $content .= '<div class="group">';
         switch ($screen) {
             case 'dashboard':
                 $content .= '<h4>' . __('Dashboard Widgets', 'aam') . '</h4>';
                 break;
             case 'widgets':
                 $content .= '<h4>' . __('Frontend Widgets', 'aam') . '</h4>';
                 break;
             default:
                 $content .= '<h4>' . $wp_post_types[$screen]->labels->name;
                 $content .= '</h4>';
                 break;
         }
         $content .= '<div>';
         $content .= '<div class="metabox-group">';
         $i = 1;
         $metaboxControl = $this->getSubject()->getObject(aam_Control_Object_Metabox::UID);
         foreach ($metaboxes as $metabox) {
             if ($i++ == 1) {
                 $content .= '<div class=metabox-row>';
             }
             //prepare title
             if (strlen($metabox['title']) > 18) {
                 $title = substr($metabox['title'], 0, 15) . '...';
             } else {
                 $title = $metabox['title'];
             }
             //prepare selected
             if ($metaboxControl->has($screen, $metabox['id'])) {
                 $checked = 'checked="checked"';
             } else {
                 $checked = '';
             }
             $metabox_id = "metabox_{$screen}_{$metabox['id']}";
             $content .= '<div class="metabox-item">';
             $content .= sprintf('<label for="%s" tooltip="%s">%s</label>', $metabox_id, esc_js($metabox['title']), $title);
             $content .= sprintf('<input type="checkbox" id="%s" name="aam[%s][%s][%s]" %s />', $metabox_id, aam_Control_Object_Metabox::UID, $screen, $metabox['id'], $checked);
             $content .= '<label for="' . $metabox_id . '"><span></span></label>';
             $content .= '</div>';
             if ($i > 3) {
                 $content .= '</div>';
                 $i = 1;
             }
         }
         if ($i != 1) {
             $content .= '</div>';
         }
         $content .= '</div></div></div>';
     }
     $content .= '</div>';
     return json_encode(array('content' => $content));
 }
Exemple #22
0
 /**
  * Check if system requires update
  *
  * @return void
  *
  * @access public
  */
 public function checkUpdate()
 {
     if (aam_Core_API::getBlogOption('aam_updated', '', 1) != AAM_VERSION) {
         $update = new aam_Core_Update($this);
         $update->run();
     }
 }
Exemple #23
0
 /**
  * Remove Extension from the repository
  *
  * @param string $extension
  *
  * @return boolean
  *
  * @access public
  */
 public function remove($extension)
 {
     global $wp_filesystem;
     $repository = aam_Core_API::getBlogOption('aam_extensions', array(), 1);
     //if extension has been downloaded as part of dev license, it'll be
     //not present in the repository list
     if (isset($repository[$extension])) {
         unset($repository[$extension]);
         aam_Core_API::updateBlogOption('aam_extensions', $repository, 1);
     }
     if ($this->hasExtension($extension)) {
         $this->initFilesystem();
         $wp_filesystem->rmdir($this->_basedir . '/' . $this->prepareExtFName($extension), true);
     }
     return true;
 }
Exemple #24
0
 /**
  * Delete Visitor's Cache
  *
  * @return boolean
  *
  * @access public
  */
 public function clearCache()
 {
     return aam_Core_API::deleteBlogOption('aam_visitor_cache');
 }