* @copyright Copyright C 2013 Vasyl Martyniuk
* @license GNU General Public License {@link http://www.gnu.org/licenses/}
*/
class aam_View_Manager extends aam_View_Abstract {
/**
*
* @var type
*/
private $_cmanager = array();
/**
*
* @var type
*/
private $_features = array();
/**
* Constructor
*
* The filter "aam_cpanel" can be used to control the Control Panel items.
*
* @return void
*
* @access public
*/
public function __construct() {
parent::__construct();
$this->setCManager(
apply_filters('aam_ui_subjects', $this->getDefaultSubjects())
);
$this->setFeatures(
apply_filters('aam_ui_features', $this->getDefaultFeatures())
);
}
/**
*
* @return type
*/
protected function getDefaultSubjects() {
return array(
'roles' => array(
'position' => 5,
'segment' => 'role',
'label' => __('Roles', 'aam'),
'title' => __('Role Manager', 'aam'),
'class' => 'manager-item manager-item-role',
'id' => 'aam_role',
'content' => array(new aam_View_Role(), 'content')
),
'users' => array(
'position' => 10,
'segment' => 'user',
'label' => __('Users', 'aam'),
'title' => __('User Manager', 'aam'),
'class' => 'manager-item manager-item-user',
'id' => 'aam_user',
'content' => array(new aam_View_User(), 'content')
),
'visitor' => array(
'position' => 15,
'segment' => 'visitor',
'label' => __('Visitor', 'aam'),
'title' => __('Visitor Manager', 'aam'),
'class' => 'manager-item manager-item-visitor',
'id' => 'aam_visitor',
'content' => array(new aam_View_Visitor(), 'content')
)
);
}
/**
*
* @return type
*/
protected function getDefaultFeatures() {
return array(
'admin_menu' => array(
'id' => 'admin_menu',
'position' => 5,
'title' => __('Admin Menu', 'aam'),
'anonimus' => false,
'content' => array(new aam_View_Menu(), 'content'),
'help' => __('Control Access to Admin Menu. Restrict access to entire Menu or Submenu. Notice, the menu is rendered based on Role\'s or User\'s capabilities.', 'aam')
),
'metabox' => array(
'id' => 'metabox',
'position' => 10,
'title' => __('Metabox & Widget', 'aam'),
'anonimus' => true,
'content' => array(new aam_View_Metabox(), 'content'),
'help' => __('Filter the list of Metaboxes or Widgets for selected Role or User. If metabox or widget is not listed, try to click Refresh the List button or Copy & Paste direct link to page where specific metabox or widget is shown and hit Retrieve Metaboxes from Link button.', 'aam')
),
'capability' => array(
'id' => 'capability',
'position' => 15,
'title' => __('Capability', 'aam'),
'anonimus' => false,
'content' => array(new aam_View_Capability(), 'content'),
'help' => __('Manage the list of Capabilities for selected User or Role. Notice, list of user\'s capabilities are inherited from user\'s Role.
Warning! Be very careful with capabilities. Deleting or unchecking any capability may cause temporary or permanent constrol lost over some features or WordPress dashboard.', 'aam')
),
'post_access' => array(
'id' => 'post_access',
'position' => 20,
'title' => __('Posts & Categories', 'aam'),
'anonimus' => true,
'content' => array(new aam_View_Post(), 'content'),
'help' => __('Manage access to individual Post or Term. Notice, under Post, we assume any post, page or custom post type. And under Term - any term like Post Categories.', 'aam')
),
'event_manager' => array(
'id' => 'event_manager',
'position' => 25,
'title' => __('Event Manager', 'aam'),
'anonimus' => false,
'content' => array(new aam_View_Event(), 'content'),
'help' => __('Define your own action when some event appeared in your WordPress blog. This sections allows you to trigger an action on event like post content change, or page status update. You can setup to send email notification, change the post status or write your own custom event handler.', 'aam')
),
'config_press' => array(
'id' => 'configpress',
'position' => 30,
'title' => __('ConfigPress', 'aam'),
'anonimus' => true,
'content' => array(new aam_View_ConfigPress(), 'content'),
'help' => __('Control AAM behavior with ConfigPress. For more details please check ConfigPress tutorial.', 'aam')
)
);
}
/**
* Set Control Panel items
*
* @param array $cpanel
*
* @return void
*
* @access public
*/
public function setCManager(array $cmanager) {
$final = array();
foreach ($cmanager as $item) {
if (!isset($final[$item['position']])) {
$final[$item['position']] = $item;
} else {
aam_Extension_Console::log(
"Control Manager position {$item['position']} reserved already"
);
}
}
ksort($final);
$this->_cmanager = $final;
}
/**
* Get Control Panel items
*
* @return array
*
* @access public
*/
public function getCManager() {
return $this->_cmanager;
}
/**
*
* @param type $list
*/
public function setFeatures($list) {
$final = array();
foreach ($list as $item) {
if (!isset($final[$item['position']])) {
$final[$item['position']] = $item;
} else {
aam_Extension_Console::log(
"Feature position {$item['position']} reserved already"
);
}
}
ksort($final);
$this->_features = $final;
}
/**
*
* @return type
*/
public function getFeatures() {
return $this->_features;
}
/**
* Run the Manager
*
* @return string
*
* @access public
*/
public function run() {
return $this->loadTemplate(dirname(__FILE__) . '/tmpl/manager.phtml');
}
/**
*
* @return type
*/
public function isVisitor() {
return ($this->getSubject()->getUID() === 'visitor' ? true : false);
}
/**
*
*/
public function retrieveFeatures() {
?>