* @copyright Copyright (c) 2010 - 2016, Vladimir Garagulya
**/
class URE_Role_View extends URE_View {
public $role_default_html = '';
private $role_to_copy_html = '';
private $role_select_html = '';
private $role_delete_html = '';
public function __construct() {
parent::__construct();
$capabilities = URE_Capabilities::get_instance();
$this->caps_to_remove = $capabilities->get_caps_to_remove();
}
// end of __construct()
public function role_default_prepare_html($select_width=200) {
$roles = $this->editor->get('roles');
if (!isset($roles) || !$roles) {
// get roles data from database
$roles = $this->lib->get_user_roles();
}
ksort( $roles );
$caps_access_restrict_for_simple_admin = $this->lib->get_option('caps_access_restrict_for_simple_admin', 0);
$show_admin_role = $this->lib->show_admin_role_allowed();
if ($select_width>0) {
$select_style = 'style="width: '. $select_width .'px"';
} else {
$select_style = '';
}
$wp_default_role = get_option( 'default_role' );
$this->role_default_html = '';
}
// end of role_default_prepare_html()
private function role_select_copy_prepare_html( $select_width=200 ) {
$current_user = wp_get_current_user();
$key_capability = URE_Own_Capabilities::get_key_capability();
$user_is_ure_admin = current_user_can( $key_capability );
$role_to_skip = ( $user_is_ure_admin ) ? '' : $current_user->roles[0];
$caps_access_restrict_for_simple_admin = $this->lib->get_option( 'caps_access_restrict_for_simple_admin', 0 );
$show_admin_role = $this->lib->show_admin_role_allowed();
$this->role_to_copy_html = '';
}
// end of role_select_copy_prepare_html()
private function role_delete_prepare_html() {
$roles_can_delete = $this->editor->get_roles_can_delete();
if ( is_array( $roles_can_delete ) && count( $roles_can_delete ) > 0) {
ksort( $roles_can_delete );
$this->role_delete_html = '';
foreach ($roles_can_delete as $key => $value) {
$this->role_delete_html .= '';
}
$this->role_delete_html .= '';
$this->role_delete_html .= '';
} else {
$this->role_delete_html = '';
}
}
// end of role_delete_prepare_html()
/**
* Build HTML for select drop-down list from capabilities we can remove
*
* @return string
**/
public static function caps_to_remove_html() {
global $wp_roles;
$capabilities = URE_Capabilities::get_instance();
$caps_to_remove = $capabilities->get_caps_to_remove();
if ( empty( $caps_to_remove ) || !is_array( $caps_to_remove ) && count( $caps_to_remove )===0 ) {
return '';
}
$caps = array_keys($caps_to_remove);
asort($caps);
$network_admin = filter_input(INPUT_POST, 'network_admin', FILTER_SANITIZE_NUMBER_INT);
$current_role = filter_input(INPUT_POST, 'current_role', FILTER_SANITIZE_STRING);
if (!isset($wp_roles->roles[$current_role])) {
$current_role = '';
}
ob_start();
?>
role_select_copy_prepare_html( $select_width );
$multisite = $this->lib->get( 'multisite' );
if ( $multisite && !is_network_admin() ) {
$this->role_default_prepare_html( $select_width );
}
$this->role_delete_prepare_html();
}
// end of role_edit_prepare_html()
public function display_edit_dialogs() {
$multisite = $this->lib->get('multisite');
$current_role = $this->editor->get('current_role');
$current_role_name = $this->editor->get('current_role_name');
?>
current_role
* @param boolean $role_delete
* @param boolean $capability_remove
*/
public function toolbar() {
$caps_access_restrict_for_simple_admin = $this->lib->get_option('caps_access_restrict_for_simple_admin', 0);
if ($caps_access_restrict_for_simple_admin) {
$add_del_role_for_simple_admin = $this->lib->get_option('add_del_role_for_simple_admin', 1);
} else {
$add_del_role_for_simple_admin = 1;
}
$super_admin = $this->lib->is_super_admin();
$multisite = $this->lib->get('multisite');
?>
lib->get('multisite');
$active_for_network = $this->lib->get('active_for_network');
?>
role_select_html; ?>
display_options();
$this->display_caps();
$ao = $this->editor->get('role_additional_options');
$current_role = $this->editor->get('current_role');
$ao->show($current_role);
?>