* @copyright Copyright (c) 2010 - 2016, Vladimir Garagulya
**/
class URE_User_View extends URE_View {
private $user_to_edit = null;
public function __construct() {
parent::__construct();
$this->user_to_edit = $this->editor->get('user_to_edit');
}
// end of __construct()
public function display_edit_dialogs() {
}
// end of display_edit_dialogs()
/**
* output HTML code to create URE toolbar
*
* @param boolean $role_delete
* @param boolean $capability_remove
*/
public function toolbar() {
?>
user_to_edit->ID}", "ure_user_{$this->user_to_edit->ID}") . '" >';
$anchor_end = '';
if (class_exists('user_switching') && current_user_can('switch_to_user', $this->user_to_edit->ID)) {
$switch_to_user_link = user_switching::switch_to_url($this->user_to_edit);
$switch_to_user = '' . esc_html__('Switch To', 'user-role-editor') . '';
}
} else {
$anchor_start = '';
$anchor_end = '';
}
$user_info = ' ' . $anchor_start . esc_html( $this->user_to_edit->user_login );
if ($this->user_to_edit->display_name !== $this->user_to_edit->user_login) {
$user_info .= ' ('. esc_html( $this->user_to_edit->display_name ) .')';
}
$user_info .= $anchor_end . '';
if (is_multisite() && $this->lib->is_super_admin($this->user_to_edit->ID)) {
$user_info .= ' ' . esc_html__('Network Super Admin', 'user-role-editor') . '';
}
if (!empty($switch_to_user)) {
$user_info .= ' ' . $switch_to_user;
}
return $user_info;
}
// end of get_user_info()
public function show_primary_role_dropdown_list($user_roles) {
?>
lib->show_admin_role_allowed();
$values = array_values($this->user_to_edit->roles);
$primary_role = array_shift($values); // get 1st element from roles array
// Is PolyLang plugin active?
$use_pll = function_exists('pll__');
$roles = $this->editor->get('roles');
foreach ($roles as $role_id => $role) {
if (($show_admin_role || $role_id !== 'administrator') && ($role_id !== $primary_role)) {
if ( $this->editor->user_can( $role_id ) ) {
$checked = 'checked="checked"';
} else {
$checked = '';
}
$role_name = $use_pll ? pll__( $role['name'] ) : $role['name'];
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- $checked is one of two hardcoded literals set above, not user input.
echo ' ';
// phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
}
// end of show_secondary_roles()
public function display() {
$caps_readable = $this->editor->get('caps_readable');
$show_deprecated_caps = $this->editor->get('show_deprecated_caps');
$edit_user_caps_mode = $this->editor->get_edit_user_caps_mode();
$caps_access_restrict_for_simple_admin = $this->lib->get_option('caps_access_restrict_for_simple_admin', 0);
$user_info = $this->get_user_info();
$select_primary_role = apply_filters('ure_users_select_primary_role', true);
?>