Version Description
- 30.06.2013
- Pro version only: added 'Export/Import' functionality to 'export' all user roles to the local file and 'import' them then to other WordPress blog or other sites of muliti-site WordPress network, or just restore roles to previous state after playing with them with test purpose.
- Added integration with the Gravity Forms plugin. User Role Editor shows Gravity Forms user capabilities at the custom capabilities section.
- Code is fully restructured and encapsulated to PHP classes. Internal global variables are not in use anymore.
Download this release
Release Info
Developer | shinephp |
Plugin | User Role Editor |
Version | 4.0 |
Comparing to | |
See all releases |
Code changes from version 3.14.1 to 4.0
- images/user-role-editor-pro.png +0 -0
- images/vum-ebook-250-250.jpg +0 -0
- images/vum-submit.jpg +0 -0
- includes/class-advertisement.php +110 -0
- includes/class-garvs-wp-lib.php +214 -0
- includes/class-ure-lib.php +1880 -0
- includes/class-user-role-editor.php +572 -0
- includes/define-constants.php +20 -0
- includes/misc-support-stuff.php +31 -0
- includes/ure-class-advertisement.php +0 -141
- includes/ure-lib.php +0 -1323
- includes/ure-options.php +0 -242
- includes/ure-role-edit.php +20 -114
- includes/ure-user-edit.php +37 -26
- js/ure-js.js +6 -5
- lang/ure-ca.mo +0 -0
- lang/ure-ca.po +752 -0
- lang/ure-ru_RU.mo +0 -0
- lang/ure-ru_RU.po +280 -276
- readme.txt +16 -4
- user-role-editor.php +27 -517
images/user-role-editor-pro.png
ADDED
Binary file
|
images/vum-ebook-250-250.jpg
DELETED
Binary file
|
images/vum-submit.jpg
DELETED
Binary file
|
includes/class-advertisement.php
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* User Role Editor plugin: advertisement showing class
|
5 |
+
* Author: Vladimir Garagulya
|
6 |
+
* email: vladimir@shinephp.com
|
7 |
+
* site: http://shinephp.com
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
|
11 |
+
class ure_Advertisement {
|
12 |
+
|
13 |
+
private $slots = array(0=>'', 1=>'', 2=>'');
|
14 |
+
|
15 |
+
function __construct() {
|
16 |
+
|
17 |
+
$used = array(-1);
|
18 |
+
$index = $this->rand_unique( $used );
|
19 |
+
$this->slots[$index] = $this->admin_menu_editor();
|
20 |
+
|
21 |
+
$used[] = $index;
|
22 |
+
$index = $this->rand_unique( $used );
|
23 |
+
$this->slots[$index] = $this->manage_wp();
|
24 |
+
|
25 |
+
$this->slots[] = $this->user_role_editor();
|
26 |
+
|
27 |
+
}
|
28 |
+
// end of __construct
|
29 |
+
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Returns random number not included into input array
|
33 |
+
*
|
34 |
+
* @param array $used - array of numbers used already
|
35 |
+
*
|
36 |
+
* @return int
|
37 |
+
*/
|
38 |
+
private function rand_unique( $used = array(-1) ) {
|
39 |
+
$index = rand(0, 2);
|
40 |
+
while (in_array($index, $used)) {
|
41 |
+
$index = rand(0, 2);
|
42 |
+
}
|
43 |
+
|
44 |
+
return $index;
|
45 |
+
}
|
46 |
+
// return rand_unique()
|
47 |
+
|
48 |
+
|
49 |
+
// content of Admin Menu Editor advertisement slot
|
50 |
+
private function admin_menu_editor() {
|
51 |
+
|
52 |
+
$output = '
|
53 |
+
<div style="text-align: center;">
|
54 |
+
<a href="http://w-shadow.com/admin-menu-editor-pro/?utm_source=UserRoleEditor&utm_medium=banner&utm_campaign=Plugins " target="_new" >
|
55 |
+
<img src="'. URE_PLUGIN_URL . 'images/admin-menu-editor-pro.jpg' .'" alt="Admin Menu Editor Pro" title="Move, rename, hide, add admin menu items, restrict access"/>
|
56 |
+
</a>
|
57 |
+
</div>
|
58 |
+
';
|
59 |
+
|
60 |
+
return $output;
|
61 |
+
}
|
62 |
+
// end of admin_menu_editor()
|
63 |
+
|
64 |
+
|
65 |
+
// content of Manage WP advertisement slot
|
66 |
+
private function manage_wp() {
|
67 |
+
|
68 |
+
$output = '
|
69 |
+
<div style="text-align: center;">
|
70 |
+
<a title="ManageWP" href="http://managewp.com/?utm_source=user_role_editor&utm_medium=Banner&utm_content=mwp250_2&utm_campaign=Plugins" target="_new" >
|
71 |
+
<img width="250" height="250" alt="ManageWP" src="'. URE_PLUGIN_URL .'images/mwp250_2.png">
|
72 |
+
</a>
|
73 |
+
</div>
|
74 |
+
';
|
75 |
+
|
76 |
+
return $output;
|
77 |
+
}
|
78 |
+
// end of manage_wp()
|
79 |
+
|
80 |
+
|
81 |
+
// content of User Role Editor advertisement slot
|
82 |
+
private function user_role_editor() {
|
83 |
+
|
84 |
+
$output = '
|
85 |
+
<div style="text-align: center;">
|
86 |
+
<a href="http://role-editor.com?utm_source=UserRoleEditor&utm_medium=banner&utm_campaign=Plugins " target="_new" >
|
87 |
+
<img src="'. URE_PLUGIN_URL . 'images/user-role-editor-pro.png' .'" alt="User Role Editor Pro" title="More functionality and premium support with Pro version of User Role Editor."/>
|
88 |
+
</a>
|
89 |
+
</div>
|
90 |
+
';
|
91 |
+
|
92 |
+
return $output;
|
93 |
+
}
|
94 |
+
// end of user_role_editor()
|
95 |
+
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Output all existed ads slots
|
99 |
+
*/
|
100 |
+
public function display() {
|
101 |
+
|
102 |
+
foreach ($this->slots as $slot) {
|
103 |
+
echo $slot."\n";
|
104 |
+
}
|
105 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ladimir Garagulya
|
5 |
+
* Author email: vladimir@shinephp.com
|
6 |
+
* Author URI: http://shinephp.com
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* This class contains general stuff for usage at WordPress plugins
|
13 |
+
*/
|
14 |
+
class Garvs_WP_Lib {
|
15 |
+
|
16 |
+
private static $instance = null; // object exemplar reference
|
17 |
+
private $options_id = ''; // identifire to save/retrieve plugin options to/from wp_option DB table
|
18 |
+
private $options = array(); // plugin options data
|
19 |
+
|
20 |
+
public $log_to_file = false; // set to true in order to record data about critical actions to log file
|
21 |
+
private $log_file_name = ''; // file name to write log messages
|
22 |
+
|
23 |
+
/**
|
24 |
+
* class constructor
|
25 |
+
* @param string $option_name identifire to save/retrieve plugin options to/from wp_option DB table
|
26 |
+
*/
|
27 |
+
public function __construct($option_name) {
|
28 |
+
|
29 |
+
$this->init_options($option_name);
|
30 |
+
|
31 |
+
add_action('admin_notices', array(&$this, 'show_message'));
|
32 |
+
|
33 |
+
}
|
34 |
+
// end of __construct()
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* get current options for this plugin
|
39 |
+
*/
|
40 |
+
public function init_options($options_id) {
|
41 |
+
$this->options_id = $options_id;
|
42 |
+
$this->options = get_option($options_id);
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Return HTML formatted message
|
47 |
+
*
|
48 |
+
* @param string $message message text
|
49 |
+
* @param string $error_style message div CSS style
|
50 |
+
*/
|
51 |
+
public function show_message($message, $error_style=false) {
|
52 |
+
|
53 |
+
if ($message) {
|
54 |
+
if ($error_style) {
|
55 |
+
echo '<div id="message" class="error" >';
|
56 |
+
} else {
|
57 |
+
echo '<div id="message" class="updated fade">';
|
58 |
+
}
|
59 |
+
echo $message . '</div>';
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
63 |
+
// end of show_message()
|
64 |
+
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Returns value by name from GET/POST/REQUEST. Minimal type checking is provided
|
68 |
+
*
|
69 |
+
* @param string $var_name Variable name to return
|
70 |
+
* @param string $request_type type of request to process get/post/request (default)
|
71 |
+
* @param string $var_type variable type to provide value checking
|
72 |
+
* @return mix variable value from request
|
73 |
+
*/
|
74 |
+
public function get_request_var($var_name, $request_type='request', $var_type='string') {
|
75 |
+
|
76 |
+
$result = 0;
|
77 |
+
if ($request_type == 'get') {
|
78 |
+
if (isset($_GET[$var_name])) {
|
79 |
+
$result = $_GET[$var_name];
|
80 |
+
}
|
81 |
+
} else if ($request_type == 'post') {
|
82 |
+
if (isset($_POST[$var_name])) {
|
83 |
+
if ($var_type!='checkbox') {
|
84 |
+
$result = $_POST[$var_name];
|
85 |
+
} else {
|
86 |
+
$result = 1;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
} else {
|
90 |
+
if (isset($_REQUEST[$var_name])) {
|
91 |
+
$result = $_REQUEST[$var_name];
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
if ($result) {
|
96 |
+
if ($var_type == 'int' && !is_numeric($result)) {
|
97 |
+
$result = 0;
|
98 |
+
}
|
99 |
+
if ($var_type!='int') {
|
100 |
+
$result = esc_attr($result);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
return $result;
|
105 |
+
}
|
106 |
+
// end of get_request_var
|
107 |
+
|
108 |
+
|
109 |
+
/**
|
110 |
+
* returns option value for option with name in $option_name
|
111 |
+
*/
|
112 |
+
public function get_option($option_name, $default = false) {
|
113 |
+
|
114 |
+
if ( isset( $this->options[ $option_name ] ) ) {
|
115 |
+
return $this->options[$option_name];
|
116 |
+
} else {
|
117 |
+
return $default;
|
118 |
+
}
|
119 |
+
|
120 |
+
}
|
121 |
+
// end of get_option()
|
122 |
+
|
123 |
+
|
124 |
+
/**
|
125 |
+
* puts option value according to $option_name option name into options array property
|
126 |
+
*/
|
127 |
+
public function put_option($option_name, $option_value, $flush_options=false) {
|
128 |
+
|
129 |
+
$this->options[$option_name] = $option_value;
|
130 |
+
if ($flush_options) {
|
131 |
+
$this->flush_options();
|
132 |
+
}
|
133 |
+
|
134 |
+
}
|
135 |
+
// end of put_option()
|
136 |
+
|
137 |
+
|
138 |
+
/**
|
139 |
+
* saves options array into WordPress database wp_options table
|
140 |
+
*/
|
141 |
+
public function flush_options() {
|
142 |
+
|
143 |
+
update_option($this->options_id, $this->options);
|
144 |
+
|
145 |
+
}
|
146 |
+
// end of flush_options()
|
147 |
+
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Check product versrion and stop execution if product version is not compatible
|
151 |
+
* @param type $must_have_version
|
152 |
+
* @param type $version_to_check
|
153 |
+
* @param type $error_message
|
154 |
+
* @return type
|
155 |
+
*/
|
156 |
+
public static function check_version($must_have_version, $version_to_check, $error_message, $plugin_file_name) {
|
157 |
+
|
158 |
+
if (version_compare( $must_have_version, $version_to_check, '<' ) ) {
|
159 |
+
if ( is_admin() && ( !defined('DOING_AJAX') || !DOING_AJAX ) ) {
|
160 |
+
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
161 |
+
deactivate_plugins( $plugin_file_name );
|
162 |
+
wp_die( $error_message );
|
163 |
+
} else {
|
164 |
+
return;
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
168 |
+
// end of check_version()
|
169 |
+
|
170 |
+
|
171 |
+
/**
|
172 |
+
* plugin specific library fabric
|
173 |
+
*
|
174 |
+
* @param string $lib_id as 'ure' for User Role Editor plugin. It will creates and returns exemplar of Ure_Lib class
|
175 |
+
* file class-ure-lib.php with URE_Lib class should be place at the same folder as Garvs_WP_Lib class
|
176 |
+
* @return
|
177 |
+
*/
|
178 |
+
public static function get_library($lib_id) {
|
179 |
+
|
180 |
+
if (self::$instance==null) {
|
181 |
+
require_once( 'class-' . $lib_id .'-lib.php' );
|
182 |
+
$class_id = ucfirst($lib_id) .'_Lib';
|
183 |
+
self::$instance = new $class_id;
|
184 |
+
}
|
185 |
+
|
186 |
+
return self::$instance;
|
187 |
+
|
188 |
+
}
|
189 |
+
// end of get_library()
|
190 |
+
|
191 |
+
|
192 |
+
/**
|
193 |
+
* returns 'selected' HTML cluster if $value matches to $etalon
|
194 |
+
*
|
195 |
+
* @param string $value
|
196 |
+
* @param string $etalon
|
197 |
+
* @return string
|
198 |
+
*/
|
199 |
+
public function option_selected($value, $etalon) {
|
200 |
+
$selected = '';
|
201 |
+
if (strcasecmp($value, $etalon) == 0) {
|
202 |
+
$selected = 'selected="selected"';
|
203 |
+
}
|
204 |
+
|
205 |
+
return $selected;
|
206 |
+
}
|
207 |
+
// end of option_selected()
|
208 |
+
|
209 |
+
|
210 |
+
//
|
211 |
+
}
|
212 |
+
// end of Garvs_WP_Lib class
|
213 |
+
|
214 |
+
?>
|
includes/class-ure-lib.php
ADDED
@@ -0,0 +1,1880 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Stuff specific for User Role Editor WordPress plugin
|
4 |
+
* Author: Vladimir Garagulya
|
5 |
+
* Author email: vladimir@shinephp.com
|
6 |
+
* Author URI: http://shinephp.com
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* This class contains general stuff for usage at WordPress plugins
|
13 |
+
*/
|
14 |
+
class Ure_Lib extends Garvs_WP_Lib {
|
15 |
+
|
16 |
+
public $roles = null;
|
17 |
+
public $notification = ''; // notification message to show on page
|
18 |
+
public $apply_to_all = 0;
|
19 |
+
|
20 |
+
private $capabilities_to_save = null;
|
21 |
+
private $current_role = '';
|
22 |
+
private $wp_default_role = '';
|
23 |
+
private $current_role_name = '';
|
24 |
+
private $user_to_edit = '';
|
25 |
+
private $show_deprecated_caps = false;
|
26 |
+
private $caps_readable = false;
|
27 |
+
private $user_to_check = array(); // cached list of user IDs, who has Administrator role
|
28 |
+
private $full_capabilities = false;
|
29 |
+
private $ure_object = 'role'; // what to process, 'role' or 'user'
|
30 |
+
private $role_default_html = '';
|
31 |
+
private $role_to_copy_html = '';
|
32 |
+
private $role_select_html = '';
|
33 |
+
private $role_delete_html = '';
|
34 |
+
private $capability_remove_html = '';
|
35 |
+
private $integrate_with_gravity_forms = false;
|
36 |
+
|
37 |
+
|
38 |
+
/** class constructor
|
39 |
+
*
|
40 |
+
* @param string $option_name
|
41 |
+
*
|
42 |
+
*/
|
43 |
+
function __construct() {
|
44 |
+
|
45 |
+
parent::__construct('user_role_editor');
|
46 |
+
|
47 |
+
$this->integrate_with_gravity_forms = class_exists('GFForms');
|
48 |
+
|
49 |
+
}
|
50 |
+
// end of __construct()
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* return key capability to have access to User Role Editor Plugin
|
55 |
+
*
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
public function get_key_capability() {
|
59 |
+
if (!is_multisite()) {
|
60 |
+
$key_capability = URE_KEY_CAPABILITY;
|
61 |
+
} else {
|
62 |
+
if (defined('URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE') && URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE == 1) {
|
63 |
+
$key_capability = URE_KEY_CAPABILITY;
|
64 |
+
} else {
|
65 |
+
$key_capability = 'manage_network_users';
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
return $key_capability;
|
70 |
+
}
|
71 |
+
// end of get_key_capability()
|
72 |
+
|
73 |
+
|
74 |
+
/**
|
75 |
+
* return front-end according to the context - role or user editor
|
76 |
+
*/
|
77 |
+
public function editor() {
|
78 |
+
|
79 |
+
if (!$this->editor_init0()) {
|
80 |
+
$this->show_message(__('Error: wrong request', 'URE'));
|
81 |
+
return false;
|
82 |
+
}
|
83 |
+
$this->process_user_request();
|
84 |
+
$this->editor_init1();
|
85 |
+
$this->show_editor();
|
86 |
+
|
87 |
+
}
|
88 |
+
// end of editor()
|
89 |
+
|
90 |
+
|
91 |
+
private function advertisement() {
|
92 |
+
|
93 |
+
if (!class_exists('User_Role_Editor_Pro')) {
|
94 |
+
$ure_advert = new ure_Advertisement();
|
95 |
+
$ure_advert->display();
|
96 |
+
}
|
97 |
+
}
|
98 |
+
// end of advertisement()
|
99 |
+
|
100 |
+
|
101 |
+
private function output_role_edit_dialogs() {
|
102 |
+
?>
|
103 |
+
<script language="javascript" type="text/javascript">
|
104 |
+
|
105 |
+
var ure_current_role = '<?php echo $this->current_role; ?>';
|
106 |
+
|
107 |
+
</script>
|
108 |
+
|
109 |
+
<!-- popup dialogs markup -->
|
110 |
+
<div id="ure_add_role_dialog" class="ure-modal-dialog" style="padding: 10px;">
|
111 |
+
<form id="ure_add_role_form" name="ure_add_role_form" method="POST">
|
112 |
+
<div class="ure-label"><?php echo __('Role name (ID): ', 'ure'); ?></div>
|
113 |
+
<div class="ure-input"><input type="text" name="user_role_id" id="user_role_id" size="25"/></div>
|
114 |
+
<div class="ure-label"><?php echo __('Display Role Name: ', 'ure'); ?></div>
|
115 |
+
<div class="ure-input"><input type="text" name="user_role_name" id="user_role_name" size="25"/></div>
|
116 |
+
<div class="ure-label"><?php echo __('Make copy of: ', 'ure'); ?></div>
|
117 |
+
<div class="ure-input"><?php echo $this->role_to_copy_html; ?></div>
|
118 |
+
</form>
|
119 |
+
</div>
|
120 |
+
|
121 |
+
<div id="ure_delete_role_dialog" class="ure-modal-dialog">
|
122 |
+
<div style="padding:10px;">
|
123 |
+
<div class="ure-label"><?php _e('Select Role:', 'ure');?></div>
|
124 |
+
<div class="ure-input"><?php echo $this->role_delete_html; ?></div>
|
125 |
+
</div>
|
126 |
+
</div>
|
127 |
+
|
128 |
+
|
129 |
+
<div id="ure_default_role_dialog" class="ure-modal-dialog">
|
130 |
+
<div style="padding:10px;">
|
131 |
+
<?php echo $this->role_default_html; ?>
|
132 |
+
</div>
|
133 |
+
</div>
|
134 |
+
|
135 |
+
|
136 |
+
<div id="ure_delete_capability_dialog" class="ure-modal-dialog">
|
137 |
+
<div style="padding:10px;">
|
138 |
+
<div class="ure-label"><?php _e('Delete:', 'ure');?></div>
|
139 |
+
<div class="ure-input"><?php echo $this->capability_remove_html; ?></div>
|
140 |
+
</div>
|
141 |
+
</div>
|
142 |
+
|
143 |
+
<div id="ure_add_capability_dialog" class="ure-modal-dialog">
|
144 |
+
<div style="padding:10px;">
|
145 |
+
<div class="ure-label"><?php echo __('Capability name (ID): ', 'ure'); ?></div>
|
146 |
+
<div class="ure-input"><input type="text" name="capability_id" id="capability_id" size="25"/></div>
|
147 |
+
</div>
|
148 |
+
</div>
|
149 |
+
|
150 |
+
<?php
|
151 |
+
do_action('ure_dialogs_html');
|
152 |
+
}
|
153 |
+
// end of output_role_edit_dialogs()
|
154 |
+
|
155 |
+
|
156 |
+
private function show_editor() {
|
157 |
+
|
158 |
+
$this->show_message($this->notification);
|
159 |
+
?>
|
160 |
+
<div class="wrap">
|
161 |
+
<div class="icon32" id="icon-options-general"><br/></div>
|
162 |
+
<h2><?php _e('User Role Editor', 'ure'); ?></h2>
|
163 |
+
<div id="poststuff">
|
164 |
+
<div class="ure-sidebar" >
|
165 |
+
<?php
|
166 |
+
$this->advertisement();
|
167 |
+
$this->about();
|
168 |
+
?>
|
169 |
+
</div>
|
170 |
+
|
171 |
+
<div class="has-sidebar" >
|
172 |
+
<form id="ure_form" method="post" action="<?php echo URE_PARENT.'?page='.URE_PLUGIN_FILE;?>" >
|
173 |
+
<div id="ure_form_controls">
|
174 |
+
<?php
|
175 |
+
wp_nonce_field('user-role-editor', 'ure_nonce');
|
176 |
+
settings_fields('ure-options');
|
177 |
+
if ($this->ure_object == 'user') {
|
178 |
+
require_once(URE_PLUGIN_DIR . 'includes/ure-user-edit.php');
|
179 |
+
} else {
|
180 |
+
$this->set_current_role();
|
181 |
+
$this->role_edit_prepare_html();
|
182 |
+
require_once(URE_PLUGIN_DIR . 'includes/ure-role-edit.php');
|
183 |
+
}
|
184 |
+
?>
|
185 |
+
</div>
|
186 |
+
</form>
|
187 |
+
<?php
|
188 |
+
if ($this->ure_object == 'role') {
|
189 |
+
$this->output_role_edit_dialogs();
|
190 |
+
}
|
191 |
+
?>
|
192 |
+
</div>
|
193 |
+
</div>
|
194 |
+
</div>
|
195 |
+
<?php
|
196 |
+
|
197 |
+
}
|
198 |
+
// end of show_editor()
|
199 |
+
|
200 |
+
|
201 |
+
// validate information about user we intend to edit
|
202 |
+
private function check_user_to_edit() {
|
203 |
+
|
204 |
+
if ($this->ure_object == 'user') {
|
205 |
+
if (!isset($_REQUEST['user_id'])) {
|
206 |
+
return false; // user_id value is missed
|
207 |
+
}
|
208 |
+
$user_id = $_REQUEST['user_id'];
|
209 |
+
if (!is_numeric($user_id)) {
|
210 |
+
return false;
|
211 |
+
}
|
212 |
+
if (!$user_id) {
|
213 |
+
return false;
|
214 |
+
}
|
215 |
+
$this->user_to_edit = get_user_to_edit($user_id);
|
216 |
+
if (empty($this->user_to_edit)) {
|
217 |
+
return false;
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
return true;
|
222 |
+
}
|
223 |
+
// end of check_user_to_edit()
|
224 |
+
|
225 |
+
|
226 |
+
private function init_current_role_name() {
|
227 |
+
|
228 |
+
if (!isset($this->roles[$_POST['user_role']])) {
|
229 |
+
$mess = __('Error: ', 'ure') . __('Role', 'ure') . ' <em>' . esc_html($_POST['user_role']) . '</em> ' . __('does not exist', 'ure');
|
230 |
+
$this->current_role = '';
|
231 |
+
$this->current_role_name = '';
|
232 |
+
} else {
|
233 |
+
$this->current_role = $_POST['user_role'];
|
234 |
+
$this->current_role_name = $this->roles[$this->current_role]['name'];
|
235 |
+
$mess = '';
|
236 |
+
}
|
237 |
+
|
238 |
+
return $mess;
|
239 |
+
|
240 |
+
}
|
241 |
+
// end of init_current_role_name()
|
242 |
+
|
243 |
+
|
244 |
+
/**
|
245 |
+
* prepare capabilities from user input to save at the database
|
246 |
+
*/
|
247 |
+
private function prepare_capabilities_to_save() {
|
248 |
+
$this->capabilities_to_save = array();
|
249 |
+
foreach ($this->full_capabilities as $available_capability) {
|
250 |
+
$cap_id = str_replace(' ', URE_SPACE_REPLACER, $available_capability['inner']);
|
251 |
+
if (isset($_POST[$cap_id])) {
|
252 |
+
$this->capabilities_to_save[$available_capability['inner']] = true;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
256 |
+
// end of prepare_capabilities_to_save()
|
257 |
+
|
258 |
+
|
259 |
+
/**
|
260 |
+
* save changes to the roles or user
|
261 |
+
* @param string $mess - notification message to the user
|
262 |
+
* @return string - notification message to the user
|
263 |
+
*/
|
264 |
+
private function permissions_object_update($mess) {
|
265 |
+
|
266 |
+
if ($this->ure_object == 'role') { // save role changes to database
|
267 |
+
if (count($this->capabilities_to_save) > 0) {
|
268 |
+
if ($this->update_roles()) {
|
269 |
+
if ($mess) {
|
270 |
+
$mess .= '<br/>';
|
271 |
+
}
|
272 |
+
$mess = __('Role', 'ure') . ' <em>' . __($this->roles[$this->current_role]['name'], 'ure') . '</em> ' .
|
273 |
+
__('is updated successfully', 'ure');
|
274 |
+
} else {
|
275 |
+
if ($mess) {
|
276 |
+
$mess .= '<br/>';
|
277 |
+
}
|
278 |
+
$mess = __('Error occured during role update', 'ure');
|
279 |
+
}
|
280 |
+
}
|
281 |
+
} else {
|
282 |
+
if ($this->update_user($this->user_to_edit)) {
|
283 |
+
if ($mess) {
|
284 |
+
$mess .= '<br/>';
|
285 |
+
}
|
286 |
+
$mess = __('User', 'ure') . ' <<em>' . $this->user_to_edit->display_name . '</em>> ' .
|
287 |
+
__('capabilities are updated successfully', 'ure');
|
288 |
+
} else {
|
289 |
+
if ($mess) {
|
290 |
+
$mess .= '<br/>';
|
291 |
+
}
|
292 |
+
$mess = __('Error occured during user update', 'ure');
|
293 |
+
}
|
294 |
+
}
|
295 |
+
return $mess;
|
296 |
+
}
|
297 |
+
// end of permissions_object_update()
|
298 |
+
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Process user request
|
302 |
+
*/
|
303 |
+
private function process_user_request() {
|
304 |
+
|
305 |
+
$this->notification = '';
|
306 |
+
if (isset($_POST['action'])) {
|
307 |
+
if (empty($_POST['ure_nonce']) || !wp_verify_nonce($_POST['ure_nonce'], 'user-role-editor')) {
|
308 |
+
echo '<h3>Wrong nonce. Action prohibitied.</h3>';
|
309 |
+
exit;
|
310 |
+
}
|
311 |
+
|
312 |
+
$action = $_POST['action'];
|
313 |
+
// restore roles capabilities from the backup record
|
314 |
+
if ($action == 'reset') {
|
315 |
+
$this->reset_user_roles();
|
316 |
+
exit;
|
317 |
+
} else if ($action == 'add-new-role') {
|
318 |
+
// process new role create request
|
319 |
+
$this->notification = $this->new_role_create();
|
320 |
+
} else if ($action == 'delete-role') {
|
321 |
+
$this->notification = $this->delete_role();
|
322 |
+
} else if ($action == 'change-default-role') {
|
323 |
+
$this->notification = $this->change_default_role();
|
324 |
+
} else if ($action == 'caps-readable') {
|
325 |
+
if ($this->caps_readable) {
|
326 |
+
$this->caps_readable = 0;
|
327 |
+
} else {
|
328 |
+
$this->caps_readable = 1;
|
329 |
+
}
|
330 |
+
update_option('ure_caps_readable', $this->caps_readable);
|
331 |
+
} else if ($action == 'show-deprecated-caps') {
|
332 |
+
if ($this->show_deprecated_caps) {
|
333 |
+
$this->show_deprecated_caps = 0;
|
334 |
+
} else {
|
335 |
+
$this->show_deprecated_caps = 1;
|
336 |
+
}
|
337 |
+
update_option('ure_show_deprecated_caps', $this->show_deprecated_caps);
|
338 |
+
} else if ($action == 'add-new-capability') {
|
339 |
+
$this->notification = $this->add_new_capability();
|
340 |
+
} else if ($action == 'delete-user-capability') {
|
341 |
+
$this->notification = $this->delete_capability();
|
342 |
+
} else if ($action == 'roles_restore_note') {
|
343 |
+
$this->notification = __('User Roles are restored to WordPress default values. ', 'ure');
|
344 |
+
} else if ($action == 'update') {
|
345 |
+
$this->roles = $this->get_user_roles();
|
346 |
+
$this->init_full_capabilities();
|
347 |
+
if (isset($_POST['user_role'])) {
|
348 |
+
$this->notification = $this->init_current_role_name();
|
349 |
+
}
|
350 |
+
$this->prepare_capabilities_to_save();
|
351 |
+
$this->notification = $this->permissions_object_update($this->notification);
|
352 |
+
} else {
|
353 |
+
do_action('ure_process_user_request');
|
354 |
+
} // if ($action
|
355 |
+
}
|
356 |
+
|
357 |
+
}
|
358 |
+
// end of process_user_request()
|
359 |
+
|
360 |
+
|
361 |
+
private function editor_init0() {
|
362 |
+
$this->caps_readable = get_option('ure_caps_readable');
|
363 |
+
$this->show_deprecated_caps = get_option('ure_show_deprecated_caps');
|
364 |
+
$this->wp_default_role = get_option('default_role');
|
365 |
+
|
366 |
+
// could be sent as by POST, as by GET
|
367 |
+
if (isset($_REQUEST['object'])) {
|
368 |
+
$this->ure_object = $_REQUEST['object'];
|
369 |
+
if (!$this->check_user_to_edit()) {
|
370 |
+
return false;
|
371 |
+
}
|
372 |
+
} else {
|
373 |
+
$this->ure_object = 'role';
|
374 |
+
}
|
375 |
+
|
376 |
+
if (isset($_POST['ure_apply_to_all'])) {
|
377 |
+
$this->apply_to_all = 1;
|
378 |
+
} else {
|
379 |
+
$this->apply_to_all = 0;
|
380 |
+
}
|
381 |
+
|
382 |
+
return true;
|
383 |
+
}
|
384 |
+
// end of editor_init0()
|
385 |
+
|
386 |
+
|
387 |
+
private function editor_init1() {
|
388 |
+
|
389 |
+
if (!isset($this->roles) || !$this->roles) {
|
390 |
+
// get roles data from database
|
391 |
+
$this->roles = $this->get_user_roles();
|
392 |
+
}
|
393 |
+
|
394 |
+
$this->init_full_capabilities();
|
395 |
+
|
396 |
+
if (!class_exists('User_Role_Editor_Pro')) {
|
397 |
+
require_once(URE_PLUGIN_DIR . 'includes/class-advertisement.php');
|
398 |
+
}
|
399 |
+
|
400 |
+
}
|
401 |
+
// end of editor_init1()
|
402 |
+
|
403 |
+
|
404 |
+
/**
|
405 |
+
* return id of role last in the list of sorted roles
|
406 |
+
*
|
407 |
+
*/
|
408 |
+
private function get_last_role_id() {
|
409 |
+
|
410 |
+
// get the key of the last element in roles array
|
411 |
+
$last_role_id = array_pop(array_keys($this->roles));
|
412 |
+
|
413 |
+
return $last_role_id;
|
414 |
+
}
|
415 |
+
// end of get_last_role_id()
|
416 |
+
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Check if user has "Administrator" role assigned
|
420 |
+
*
|
421 |
+
* @global wpdb $wpdb
|
422 |
+
* @param int $user_id
|
423 |
+
* @return boolean returns true is user has Role "Administrator"
|
424 |
+
*/
|
425 |
+
private function has_administrator_role($user_id) {
|
426 |
+
global $wpdb;
|
427 |
+
|
428 |
+
if (empty($user_id) || !is_numeric($user_id)) {
|
429 |
+
return false;
|
430 |
+
}
|
431 |
+
|
432 |
+
$table_name = (!is_multisite() && defined('CUSTOM_USER_META_TABLE')) ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
|
433 |
+
$meta_key = $wpdb->prefix . 'capabilities';
|
434 |
+
$query = "SELECT count(*)
|
435 |
+
FROM $table_name
|
436 |
+
WHERE user_id=$user_id AND meta_key='$meta_key' AND meta_value like '%administrator%'";
|
437 |
+
$has_admin_role = $wpdb->get_var($query);
|
438 |
+
if ($has_admin_role > 0) {
|
439 |
+
$result = true;
|
440 |
+
} else {
|
441 |
+
$result = false;
|
442 |
+
}
|
443 |
+
// cache checking result for the future use
|
444 |
+
$this->lib->user_to_check[$user_id] = $result;
|
445 |
+
|
446 |
+
return $result;
|
447 |
+
}
|
448 |
+
|
449 |
+
// end of has_administrator_role()
|
450 |
+
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Checks if user is superadmin under multi-site environment or has administrator role for the standalone WP
|
454 |
+
*
|
455 |
+
* @global int $current_user
|
456 |
+
* @param int $user_id
|
457 |
+
* @return boolean true
|
458 |
+
*/
|
459 |
+
public function user_is_admin($user_id = false)
|
460 |
+
{
|
461 |
+
global $current_user;
|
462 |
+
|
463 |
+
if (!$user_id) {
|
464 |
+
if (empty($current_user) && function_exists('get_currentuserinfo')) {
|
465 |
+
get_currentuserinfo();
|
466 |
+
}
|
467 |
+
$user_id = !empty($current_user) ? $current_user->ID : 0;
|
468 |
+
}
|
469 |
+
|
470 |
+
if (!$user_id) {
|
471 |
+
return false;
|
472 |
+
}
|
473 |
+
|
474 |
+
$user = new WP_User($user_id);
|
475 |
+
|
476 |
+
$simple_admin = $this->has_administrator_role($user_id);
|
477 |
+
|
478 |
+
if (is_multisite()) {
|
479 |
+
$super_admins = get_super_admins();
|
480 |
+
$super_admin = is_array($super_admins) && in_array($user->user_login, $super_admins);
|
481 |
+
} else {
|
482 |
+
$super_admin = false;
|
483 |
+
}
|
484 |
+
|
485 |
+
return $simple_admin || $super_admin;
|
486 |
+
}
|
487 |
+
// end of user_is_admin()
|
488 |
+
|
489 |
+
|
490 |
+
/**
|
491 |
+
* return array with WordPress user roles
|
492 |
+
*
|
493 |
+
* @global WP_Roles $wp_roles
|
494 |
+
* @global type $wp_user_roles
|
495 |
+
* @return array
|
496 |
+
*/
|
497 |
+
public function get_user_roles() {
|
498 |
+
|
499 |
+
global $wp_roles, $wpdb;
|
500 |
+
|
501 |
+
if (!isset($wp_roles)) {
|
502 |
+
$wp_roles = new WP_Roles();
|
503 |
+
}
|
504 |
+
|
505 |
+
if (function_exists('bbp_filter_blog_editable_roles')) { // bbPress plugin is active
|
506 |
+
$this->roles = bbp_filter_blog_editable_roles($wp_roles->roles); // exclude bbPress roles
|
507 |
+
$bbp_full_caps = bbp_get_caps_for_role(bbp_get_keymaster_role());
|
508 |
+
// exclude capabilities automatically added by bbPress bbp_dynamic_role_caps() and not bbPress related: read, level_0, all s2Member levels, e.g. access_s2member_level_0, etc.
|
509 |
+
$built_in_wp_caps = $this->get_built_in_wp_caps();
|
510 |
+
$bbp_only_caps = array();
|
511 |
+
foreach ($bbp_full_caps as $bbp_cap => $val) {
|
512 |
+
if (isset($built_in_wp_caps[$bbp_cap]) || substr($bbp_cap, 0, 15) == 'access_s2member') {
|
513 |
+
continue;
|
514 |
+
}
|
515 |
+
$bbp_only_caps[$bbp_cap] = $val;
|
516 |
+
}
|
517 |
+
// remove bbPress dynamically created capabilities from WordPress persistent roles in order to not save them to database with any role update
|
518 |
+
$cap_removed = false;
|
519 |
+
foreach ($bbp_only_caps as $bbp_cap => $val) {
|
520 |
+
foreach ($this->roles as &$role) {
|
521 |
+
if (isset($role['capabilities'][$bbp_cap])) {
|
522 |
+
unset($role['capabilities'][$bbp_cap]);
|
523 |
+
$cap_removed = true;
|
524 |
+
}
|
525 |
+
}
|
526 |
+
}
|
527 |
+
/*
|
528 |
+
if ($cap_removed) {
|
529 |
+
// save changes to database
|
530 |
+
$option_name = $wpdb->prefix.'user_roles';
|
531 |
+
update_option($option_name, $this->roles);
|
532 |
+
}
|
533 |
+
*/
|
534 |
+
} else {
|
535 |
+
$this->roles = $wp_roles->roles;
|
536 |
+
}
|
537 |
+
|
538 |
+
if (is_array($this->roles) && count($this->roles) > 0) {
|
539 |
+
asort($this->roles);
|
540 |
+
}
|
541 |
+
|
542 |
+
return $this->roles;
|
543 |
+
}
|
544 |
+
// end of get_user_roles()
|
545 |
+
|
546 |
+
/*
|
547 |
+
// restores User Roles from the backup record
|
548 |
+
private function restore_user_roles()
|
549 |
+
{
|
550 |
+
global $wpdb, $wp_roles;
|
551 |
+
|
552 |
+
$error_message = 'Error! ' . __('Database operation error. Check log file.', 'ure');
|
553 |
+
$option_name = $wpdb->prefix . 'user_roles';
|
554 |
+
$backup_option_name = $wpdb->prefix . 'backup_user_roles';
|
555 |
+
$query = "select option_value
|
556 |
+
from $wpdb->options
|
557 |
+
where option_name='$backup_option_name'
|
558 |
+
limit 0, 1";
|
559 |
+
$option_value = $wpdb->get_var($query);
|
560 |
+
if ($wpdb->last_error) {
|
561 |
+
$this->log_event($wpdb->last_error, true);
|
562 |
+
return $error_message;
|
563 |
+
}
|
564 |
+
if ($option_value) {
|
565 |
+
$query = "update $wpdb->options
|
566 |
+
set option_value='$option_value'
|
567 |
+
where option_name='$option_name'
|
568 |
+
limit 1";
|
569 |
+
$record = $wpdb->query($query);
|
570 |
+
if ($wpdb->last_error) {
|
571 |
+
$this->log_event($wpdb->last_error, true);
|
572 |
+
return $error_message;
|
573 |
+
}
|
574 |
+
$wp_roles = new WP_Roles();
|
575 |
+
$reload_link = wp_get_referer();
|
576 |
+
$reload_link = remove_query_arg('action', $reload_link);
|
577 |
+
$reload_link = add_query_arg('action', 'roles_restore_note', $reload_link);
|
578 |
+
?>
|
579 |
+
<script type="text/javascript" >
|
580 |
+
document.location = '<?php echo $reload_link; ?>';
|
581 |
+
</script>
|
582 |
+
<?php
|
583 |
+
$mess = '';
|
584 |
+
} else {
|
585 |
+
$mess = __('No backup data. It is created automatically before the first role data update.', 'ure');
|
586 |
+
}
|
587 |
+
if (isset($_REQUEST['user_role'])) {
|
588 |
+
unset($_REQUEST['user_role']);
|
589 |
+
}
|
590 |
+
|
591 |
+
return $mess;
|
592 |
+
}
|
593 |
+
// end of restore_user_roles()
|
594 |
+
*/
|
595 |
+
|
596 |
+
private function convert_caps_to_readable($caps_name)
|
597 |
+
{
|
598 |
+
|
599 |
+
$caps_name = str_replace('_', ' ', $caps_name);
|
600 |
+
$caps_name = ucfirst($caps_name);
|
601 |
+
|
602 |
+
return $caps_name;
|
603 |
+
}
|
604 |
+
// ure_ConvertCapsToReadable
|
605 |
+
|
606 |
+
|
607 |
+
public function show_message($message)
|
608 |
+
{
|
609 |
+
|
610 |
+
if ($message) {
|
611 |
+
if (strpos(strtolower($message), 'error') === false) {
|
612 |
+
$class = 'updated fade';
|
613 |
+
} else {
|
614 |
+
$class = 'error';
|
615 |
+
}
|
616 |
+
echo '<div class="' . $class . '" style="margin:0;">' . $message . '</div><br style="clear: both;"/>';
|
617 |
+
}
|
618 |
+
}
|
619 |
+
// end of show_message()
|
620 |
+
|
621 |
+
|
622 |
+
private function make_roles_backup()
|
623 |
+
{
|
624 |
+
global $wpdb;
|
625 |
+
|
626 |
+
// check if backup user roles record exists already
|
627 |
+
$backup_option_name = $wpdb->prefix . 'backup_user_roles';
|
628 |
+
$query = "select option_id
|
629 |
+
from $wpdb->options
|
630 |
+
where option_name='$backup_option_name'
|
631 |
+
limit 0, 1";
|
632 |
+
$option_id = $wpdb->get_var($query);
|
633 |
+
if ($wpdb->last_error) {
|
634 |
+
$this->log_event($wpdb->last_error, true);
|
635 |
+
return false;
|
636 |
+
}
|
637 |
+
if (!$option_id) {
|
638 |
+
// create user roles record backup
|
639 |
+
$serialized_roles = mysql_real_escape_string(serialize($this->lib->roles));
|
640 |
+
$query = "insert into $wpdb->options
|
641 |
+
(option_name, option_value, autoload)
|
642 |
+
values ('$backup_option_name', '$serialized_roles', 'no')";
|
643 |
+
$record = $wpdb->query($query);
|
644 |
+
if ($wpdb->last_error) {
|
645 |
+
$this->log_event($wpdb->last_error, true);
|
646 |
+
return false;
|
647 |
+
}
|
648 |
+
}
|
649 |
+
|
650 |
+
return true;
|
651 |
+
}
|
652 |
+
// end of ure_make_roles_backup()
|
653 |
+
|
654 |
+
|
655 |
+
/**
|
656 |
+
* return array with roles which we could delete, e.g self-created and not used with any blog user
|
657 |
+
*
|
658 |
+
* @global wpdb $wpdb - WP database object
|
659 |
+
* @return array
|
660 |
+
*/
|
661 |
+
private function get_roles_can_delete()
|
662 |
+
{
|
663 |
+
global $wpdb;
|
664 |
+
|
665 |
+
$table_name = (!is_multisite() && defined('CUSTOM_USER_META_TABLE')) ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
|
666 |
+
$meta_key = $wpdb->prefix . 'capabilities';
|
667 |
+
$default_role = get_option('default_role');
|
668 |
+
$standard_roles = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
|
669 |
+
$roles_can_delete = array();
|
670 |
+
foreach ($this->roles as $key => $role) {
|
671 |
+
$can_delete = true;
|
672 |
+
// check if it is default role for new users
|
673 |
+
if ($key == $default_role) {
|
674 |
+
$can_delete = false;
|
675 |
+
continue;
|
676 |
+
}
|
677 |
+
// check if it is standard role
|
678 |
+
if (in_array($key, $standard_roles)) {
|
679 |
+
continue;
|
680 |
+
}
|
681 |
+
// check if user with such role exists
|
682 |
+
$query = "SELECT meta_value
|
683 |
+
FROM $table_name
|
684 |
+
WHERE meta_key='$meta_key' AND meta_value like '%$key%'";
|
685 |
+
$roles_used = $wpdb->get_results($query);
|
686 |
+
if ($roles_used && count($roles_used > 0)) {
|
687 |
+
foreach ($roles_used as $role_used) {
|
688 |
+
$role_name = unserialize($role_used->meta_value);
|
689 |
+
foreach ($role_name as $key1 => $value1) {
|
690 |
+
if ($key == $key1) {
|
691 |
+
$can_delete = false;
|
692 |
+
break;
|
693 |
+
}
|
694 |
+
}
|
695 |
+
if (!$can_delete) {
|
696 |
+
break;
|
697 |
+
}
|
698 |
+
}
|
699 |
+
}
|
700 |
+
if ($can_delete) {
|
701 |
+
$roles_can_delete[$key] = $role['name'] . ' (' . $key . ')';
|
702 |
+
}
|
703 |
+
}
|
704 |
+
|
705 |
+
return $roles_can_delete;
|
706 |
+
}
|
707 |
+
// end of get_roles_can_delete()
|
708 |
+
|
709 |
+
|
710 |
+
/**
|
711 |
+
* return array of built-in WP capabilities (WP 3.1 wp-admin/includes/schema.php)
|
712 |
+
*
|
713 |
+
* @return array
|
714 |
+
*/
|
715 |
+
public function get_built_in_wp_caps() {
|
716 |
+
$caps = array();
|
717 |
+
$caps['switch_themes'] = 1;
|
718 |
+
$caps['edit_themes'] = 1;
|
719 |
+
$caps['activate_plugins'] = 1;
|
720 |
+
$caps['edit_plugins'] = 1;
|
721 |
+
$caps['edit_users'] = 1;
|
722 |
+
$caps['edit_files'] = 1;
|
723 |
+
$caps['manage_options'] = 1;
|
724 |
+
$caps['moderate_comments'] = 1;
|
725 |
+
$caps['manage_categories'] = 1;
|
726 |
+
$caps['manage_links'] = 1;
|
727 |
+
$caps['upload_files'] = 1;
|
728 |
+
$caps['import'] = 1;
|
729 |
+
$caps['unfiltered_html'] = 1;
|
730 |
+
$caps['edit_posts'] = 1;
|
731 |
+
$caps['edit_others_posts'] = 1;
|
732 |
+
$caps['edit_published_posts'] = 1;
|
733 |
+
$caps['publish_posts'] = 1;
|
734 |
+
$caps['edit_pages'] = 1;
|
735 |
+
$caps['read'] = 1;
|
736 |
+
$caps['level_10'] = 1;
|
737 |
+
$caps['level_9'] = 1;
|
738 |
+
$caps['level_8'] = 1;
|
739 |
+
$caps['level_7'] = 1;
|
740 |
+
$caps['level_6'] = 1;
|
741 |
+
$caps['level_5'] = 1;
|
742 |
+
$caps['level_4'] = 1;
|
743 |
+
$caps['level_3'] = 1;
|
744 |
+
$caps['level_2'] = 1;
|
745 |
+
$caps['level_1'] = 1;
|
746 |
+
$caps['level_0'] = 1;
|
747 |
+
$caps['edit_others_pages'] = 1;
|
748 |
+
$caps['edit_published_pages'] = 1;
|
749 |
+
$caps['publish_pages'] = 1;
|
750 |
+
$caps['delete_pages'] = 1;
|
751 |
+
$caps['delete_others_pages'] = 1;
|
752 |
+
$caps['delete_published_pages'] = 1;
|
753 |
+
$caps['delete_posts'] = 1;
|
754 |
+
$caps['delete_others_posts'] = 1;
|
755 |
+
$caps['delete_published_posts'] = 1;
|
756 |
+
$caps['delete_private_posts'] = 1;
|
757 |
+
$caps['edit_private_posts'] = 1;
|
758 |
+
$caps['read_private_posts'] = 1;
|
759 |
+
$caps['delete_private_pages'] = 1;
|
760 |
+
$caps['edit_private_pages'] = 1;
|
761 |
+
$caps['read_private_pages'] = 1;
|
762 |
+
$caps['unfiltered_upload'] = 1;
|
763 |
+
$caps['edit_dashboard'] = 1;
|
764 |
+
$caps['update_plugins'] = 1;
|
765 |
+
$caps['delete_plugins'] = 1;
|
766 |
+
$caps['install_plugins'] = 1;
|
767 |
+
$caps['update_themes'] = 1;
|
768 |
+
$caps['install_themes'] = 1;
|
769 |
+
$caps['update_core'] = 1;
|
770 |
+
$caps['list_users'] = 1;
|
771 |
+
$caps['remove_users'] = 1;
|
772 |
+
$caps['add_users'] = 1;
|
773 |
+
$caps['promote_users'] = 1;
|
774 |
+
$caps['edit_theme_options'] = 1;
|
775 |
+
$caps['delete_themes'] = 1;
|
776 |
+
$caps['export'] = 1;
|
777 |
+
$caps['delete_users'] = 1;
|
778 |
+
$caps['create_users'] = 1;
|
779 |
+
|
780 |
+
return $caps;
|
781 |
+
}
|
782 |
+
// end of get_built_in_wp_caps()
|
783 |
+
|
784 |
+
|
785 |
+
/**
|
786 |
+
* return the array of unused user capabilities
|
787 |
+
*
|
788 |
+
* @global WP_Roles $wp_roles
|
789 |
+
* @global wpdb $wpdb
|
790 |
+
* @return array
|
791 |
+
*/
|
792 |
+
private function get_caps_to_remove()
|
793 |
+
{
|
794 |
+
global $wp_roles;
|
795 |
+
|
796 |
+
// build full capabilities list from all roles except Administrator
|
797 |
+
$full_caps_list = array();
|
798 |
+
foreach ($wp_roles->roles as $role) {
|
799 |
+
// validate if capabilities is an array
|
800 |
+
if (isset($role['capabilities']) && is_array($role['capabilities'])) {
|
801 |
+
foreach ($role['capabilities'] as $capability => $value) {
|
802 |
+
if (!isset($full_caps_list[$capability])) {
|
803 |
+
$full_caps_list[$capability] = 1;
|
804 |
+
}
|
805 |
+
}
|
806 |
+
}
|
807 |
+
}
|
808 |
+
|
809 |
+
$caps_to_exclude = $this->get_built_in_wp_caps();
|
810 |
+
|
811 |
+
$caps_to_remove = array();
|
812 |
+
foreach ($full_caps_list as $capability => $value) {
|
813 |
+
if (!isset($caps_to_exclude[$capability])) { // do not touch built-in WP caps
|
814 |
+
// check roles
|
815 |
+
$cap_in_use = false;
|
816 |
+
foreach ($wp_roles->role_objects as $wp_role) {
|
817 |
+
if ($wp_role->name != 'administrator') {
|
818 |
+
if ($wp_role->has_cap($capability)) {
|
819 |
+
$cap_in_use = true;
|
820 |
+
break;
|
821 |
+
}
|
822 |
+
}
|
823 |
+
}
|
824 |
+
if (!$cap_in_use) {
|
825 |
+
$caps_to_remove[$capability] = 1;
|
826 |
+
}
|
827 |
+
}
|
828 |
+
}
|
829 |
+
|
830 |
+
return $caps_to_remove;
|
831 |
+
}
|
832 |
+
// end of get_caps_to_remove()
|
833 |
+
|
834 |
+
|
835 |
+
/**
|
836 |
+
* Build HTML for select drop-down list from capabilities we can remove
|
837 |
+
*
|
838 |
+
* @return string
|
839 |
+
*/
|
840 |
+
private function get_caps_to_remove_html() {
|
841 |
+
|
842 |
+
$caps_to_remove = $this->get_caps_to_remove();
|
843 |
+
if (!empty($caps_to_remove) && is_array($caps_to_remove) && count($caps_to_remove) > 0) {
|
844 |
+
$html = '<select id="remove_user_capability" name="remove_user_capability" width="200" style="width: 200px">';
|
845 |
+
foreach ($caps_to_remove as $key => $value) {
|
846 |
+
$html .= '<option value="' . $key . '">' . $key . '</option>';
|
847 |
+
}
|
848 |
+
$html .= '</select>';
|
849 |
+
} else {
|
850 |
+
$html = '';
|
851 |
+
}
|
852 |
+
|
853 |
+
return $html;
|
854 |
+
}
|
855 |
+
// end of getCapsToRemoveHTML()
|
856 |
+
|
857 |
+
|
858 |
+
/**
|
859 |
+
* returns array of deprecated capabilities
|
860 |
+
*
|
861 |
+
* @return array
|
862 |
+
*/
|
863 |
+
private function get_deprecated_caps()
|
864 |
+
{
|
865 |
+
|
866 |
+
$dep_caps = array(
|
867 |
+
'level_0' => 0,
|
868 |
+
'level_1' => 0,
|
869 |
+
'level_2' => 0,
|
870 |
+
'level_3' => 0,
|
871 |
+
'level_4' => 0,
|
872 |
+
'level_5' => 0,
|
873 |
+
'level_6' => 0,
|
874 |
+
'level_7' => 0,
|
875 |
+
'level_8' => 0,
|
876 |
+
'level_9' => 0,
|
877 |
+
'level_10' => 0,
|
878 |
+
'edit_files' => 0);
|
879 |
+
|
880 |
+
return $dep_caps;
|
881 |
+
}
|
882 |
+
// end of get_deprecated_caps()
|
883 |
+
|
884 |
+
|
885 |
+
/**
|
886 |
+
* output HTML-code for capabilities list
|
887 |
+
* @param boolean $core - if true, then show WordPress core capabilities, else custom (plugins and themes created)
|
888 |
+
* @param boolean $for_role - if true, it is role capabilities list, else - user specific capabilities list
|
889 |
+
*/
|
890 |
+
private function show_capabilities($core = true, $for_role = true) {
|
891 |
+
|
892 |
+
$onclick_for_admin = '';
|
893 |
+
if (!( is_multisite() && is_super_admin() )) { // do not limit SuperAdmin for multi-site
|
894 |
+
if ($core && 'administrator' == $this->current_role) {
|
895 |
+
$onclick_for_admin = 'onclick="turn_it_back(this)"';
|
896 |
+
}
|
897 |
+
}
|
898 |
+
|
899 |
+
if ($core) {
|
900 |
+
$quant = count($this->get_built_in_wp_caps());
|
901 |
+
$deprecated_caps = $this->get_deprecated_caps();
|
902 |
+
} else {
|
903 |
+
$quant = count($this->full_capabilities) - count($this->get_built_in_wp_caps());
|
904 |
+
$deprecated_caps = array();
|
905 |
+
}
|
906 |
+
$quant_in_column = (int) $quant / 3;
|
907 |
+
$printed_quant = 0;
|
908 |
+
foreach ($this->full_capabilities as $capability) {
|
909 |
+
if ($core) {
|
910 |
+
if (!$capability['wp_core']) { // show WP built-in capabilities 1st
|
911 |
+
continue;
|
912 |
+
}
|
913 |
+
} else {
|
914 |
+
if ($capability['wp_core']) { // show plugins and themes added capabilities
|
915 |
+
continue;
|
916 |
+
}
|
917 |
+
}
|
918 |
+
if (!$this->show_deprecated_caps && isset($deprecated_caps[$capability['inner']])) {
|
919 |
+
$hidden_class = 'class="hidden"';
|
920 |
+
} else {
|
921 |
+
$hidden_class = '';
|
922 |
+
}
|
923 |
+
if (isset($deprecated_caps[$capability['inner']])) {
|
924 |
+
$labelStyle = 'style="color:#BBBBBB;"';
|
925 |
+
} else {
|
926 |
+
$labelStyle = '';
|
927 |
+
}
|
928 |
+
$checked = '';
|
929 |
+
$disabled = '';
|
930 |
+
if ($for_role) {
|
931 |
+
if (isset($this->roles[$this->current_role]['capabilities'][$capability['inner']]) &&
|
932 |
+
!empty($this->roles[$this->current_role]['capabilities'][$capability['inner']])) {
|
933 |
+
$checked = 'checked="checked"';
|
934 |
+
}
|
935 |
+
} else {
|
936 |
+
if (user_can($this->user_to_edit->ID, $capability['inner'])) {
|
937 |
+
$checked = 'checked="checked"';
|
938 |
+
if (!isset($this->user_to_edit->caps[$capability['inner']])) {
|
939 |
+
$disabled = 'disabled="disabled"';
|
940 |
+
}
|
941 |
+
}
|
942 |
+
}
|
943 |
+
$cap_id = str_replace(' ', URE_SPACE_REPLACER, $capability['inner']);
|
944 |
+
echo '<input type="checkbox" name="' . $cap_id . '" id="' . $cap_id . '" value="' . $capability['inner'] . '" ' .
|
945 |
+
$hidden_class . ' ' . $checked . ' ' . $disabled . ' ' . $onclick_for_admin . ' />';
|
946 |
+
if (empty($hidden_class)) {
|
947 |
+
if ($this->caps_readable) {
|
948 |
+
$cap_ind = 'human';
|
949 |
+
$cap_ind_alt = 'inner';
|
950 |
+
} else {
|
951 |
+
$cap_ind = 'inner';
|
952 |
+
$cap_ind_alt = 'human';
|
953 |
+
}
|
954 |
+
echo '<label for="' . $cap_id . '" title="' . $capability[$cap_ind_alt] . '" ' . $labelStyle . ' > ' .
|
955 |
+
$capability[$cap_ind] . '</label> ' . $this->capability_help_link($capability['inner']) . '<br/>';
|
956 |
+
$printed_quant++;
|
957 |
+
if ($printed_quant >= $quant_in_column) {
|
958 |
+
$printed_quant = 0;
|
959 |
+
echo '</td>
|
960 |
+
<td style="vertical-align:top;">';
|
961 |
+
}
|
962 |
+
} // if ('hidden'
|
963 |
+
}
|
964 |
+
}
|
965 |
+
// end of ure_show_capabilities()
|
966 |
+
|
967 |
+
|
968 |
+
/**
|
969 |
+
* output HTML code to create URE toolbar
|
970 |
+
*
|
971 |
+
* @param string $this->current_role
|
972 |
+
* @param boolean $role_delete
|
973 |
+
* @param boolean $capability_remove
|
974 |
+
*/
|
975 |
+
private function toolbar($role_delete = false, $capability_remove = false) {
|
976 |
+
|
977 |
+
?>
|
978 |
+
<div id="ure_toolbar" >
|
979 |
+
<button id="ure_select_all" class="ure_toolbar_button">Select All</button>
|
980 |
+
<?php
|
981 |
+
if ('administrator' != $this->current_role) {
|
982 |
+
?>
|
983 |
+
<button id="ure_unselect_all" class="ure_toolbar_button">Unselect All</button>
|
984 |
+
<button id="ure_reverse_selection" class="ure_toolbar_button">Reverse</button>
|
985 |
+
<?php
|
986 |
+
}
|
987 |
+
if ($this->ure_object == 'role') {
|
988 |
+
|
989 |
+
?>
|
990 |
+
|
991 |
+
<hr />
|
992 |
+
<div id="ure_update">
|
993 |
+
<button id="ure_update_role" class="ure_toolbar_button button-primary">Update</button>
|
994 |
+
</div>
|
995 |
+
<hr />
|
996 |
+
<button id="ure_add_role" class="ure_toolbar_button">Add New Role</button>
|
997 |
+
<button id="ure_add_capability" class="ure_toolbar_button">Add New Capability</button>
|
998 |
+
<?php
|
999 |
+
if (!empty($role_delete)) {
|
1000 |
+
?>
|
1001 |
+
<button id="ure_delete_role" class="ure_toolbar_button">Delete Role</button>
|
1002 |
+
<?php
|
1003 |
+
}
|
1004 |
+
if ($capability_remove) {
|
1005 |
+
?>
|
1006 |
+
<button id="ure_delete_capability" class="ure_toolbar_button">Delete Capability</button>
|
1007 |
+
<?php
|
1008 |
+
}
|
1009 |
+
?>
|
1010 |
+
<hr />
|
1011 |
+
<button id="ure_default_role" class="ure_toolbar_button">Default Role</button>
|
1012 |
+
<hr />
|
1013 |
+
<div id="ure_service_tools">
|
1014 |
+
<?php
|
1015 |
+
do_action('ure_role_edit_toolbar');
|
1016 |
+
?>
|
1017 |
+
<button id="ure_reset_roles" class="ure_toolbar_button" title="Reset Roles to its original state">Reset</button>
|
1018 |
+
</div>
|
1019 |
+
<?php
|
1020 |
+
} else {
|
1021 |
+
?>
|
1022 |
+
|
1023 |
+
<hr />
|
1024 |
+
<div id="ure_update_user">
|
1025 |
+
<button id="ure_update_role" class="ure_toolbar_button button-primary">Update</button>
|
1026 |
+
</div>
|
1027 |
+
<?php
|
1028 |
+
}
|
1029 |
+
?>
|
1030 |
+
|
1031 |
+
</div>
|
1032 |
+
<?php
|
1033 |
+
}
|
1034 |
+
// end of toolbar()
|
1035 |
+
|
1036 |
+
|
1037 |
+
/**
|
1038 |
+
* return link to the capability according its name in $capability parameter
|
1039 |
+
*
|
1040 |
+
* @param string $capability
|
1041 |
+
* @return string
|
1042 |
+
*/
|
1043 |
+
private function capability_help_link($capability) {
|
1044 |
+
|
1045 |
+
if (empty($capability)) {
|
1046 |
+
return '';
|
1047 |
+
}
|
1048 |
+
|
1049 |
+
switch ($capability) {
|
1050 |
+
case 'activate_plugins':
|
1051 |
+
$url = 'http://www.shinephp.com/activate_plugins-wordpress-capability/';
|
1052 |
+
break;
|
1053 |
+
case 'add_users':
|
1054 |
+
$url = 'http://www.shinephp.com/add_users-wordpress-user-capability/';
|
1055 |
+
break;
|
1056 |
+
case 'create_users':
|
1057 |
+
$url = 'http://www.shinephp.com/create_users-wordpress-user-capability/';
|
1058 |
+
break;
|
1059 |
+
case 'delete_others_pages':
|
1060 |
+
case 'delete_others_posts':
|
1061 |
+
case 'delete_pages':
|
1062 |
+
case 'delete_posts':
|
1063 |
+
case 'delete_private_pages':
|
1064 |
+
case 'delete_private_posts':
|
1065 |
+
case 'delete_published_pages':
|
1066 |
+
case 'delete_published_posts':
|
1067 |
+
$url = 'http://www.shinephp.com/delete-posts-and-pages-wordpress-user-capabilities-set/';
|
1068 |
+
break;
|
1069 |
+
case 'delete_plugins':
|
1070 |
+
$url = 'http://www.shinephp.com/delete_plugins-wordpress-user-capability/';
|
1071 |
+
break;
|
1072 |
+
case 'delete_themes':
|
1073 |
+
$url = 'http://www.shinephp.com/delete_themes-wordpress-user-capability/';
|
1074 |
+
break;
|
1075 |
+
case 'delete_users':
|
1076 |
+
$url = 'http://www.shinephp.com/delete_users-wordpress-user-capability/';
|
1077 |
+
break;
|
1078 |
+
case 'edit_dashboard':
|
1079 |
+
$url = 'http://www.shinephp.com/edit_dashboard-wordpress-capability/';
|
1080 |
+
break;
|
1081 |
+
case 'edit_files':
|
1082 |
+
$url = 'http://www.shinephp.com/edit_files-wordpress-user-capability/';
|
1083 |
+
break;
|
1084 |
+
case 'edit_plugins':
|
1085 |
+
$url = 'http://www.shinephp.com/edit_plugins-wordpress-user-capability';
|
1086 |
+
break;
|
1087 |
+
case 'moderate_comments':
|
1088 |
+
$url = 'http://www.shinephp.com/moderate_comments-wordpress-user-capability/';
|
1089 |
+
break;
|
1090 |
+
case 'read':
|
1091 |
+
$url = 'http://shinephp.com/wordpress-read-capability/';
|
1092 |
+
break;
|
1093 |
+
case 'update_core':
|
1094 |
+
$url = 'http://www.shinephp.com/update_core-capability-for-wordpress-user/';
|
1095 |
+
break;
|
1096 |
+
default:
|
1097 |
+
$url = '';
|
1098 |
+
}
|
1099 |
+
// end of switch
|
1100 |
+
if (!empty($url)) {
|
1101 |
+
$link = '<a href="' . $url . '" title="read about ' . $capability . ' user capability" target="new"><img src="' . URE_PLUGIN_URL . '/images/help.png" alt="' . __('Help', 'ure') . '" /></a>';
|
1102 |
+
} else {
|
1103 |
+
$link = '';
|
1104 |
+
}
|
1105 |
+
|
1106 |
+
return $link;
|
1107 |
+
}
|
1108 |
+
// end of capability_help_link()
|
1109 |
+
|
1110 |
+
|
1111 |
+
/**
|
1112 |
+
* Go through all users and if user has non-existing role lower him to Subscriber role
|
1113 |
+
*
|
1114 |
+
*/
|
1115 |
+
private function validate_user_roles() {
|
1116 |
+
|
1117 |
+
global $wp_roles;
|
1118 |
+
|
1119 |
+
$default_role = get_option('default_role');
|
1120 |
+
if (empty($default_role)) {
|
1121 |
+
$default_role = 'subscriber';
|
1122 |
+
}
|
1123 |
+
$users_query = new WP_User_Query(array('fields' => 'ID'));
|
1124 |
+
$users = $users_query->get_results();
|
1125 |
+
foreach ($users as $user_id) {
|
1126 |
+
$user = get_user_by('id', $user_id);
|
1127 |
+
if (is_array($user->roles) && count($user->roles) > 0) {
|
1128 |
+
foreach ($user->roles as $role) {
|
1129 |
+
$user_role = $role;
|
1130 |
+
break;
|
1131 |
+
}
|
1132 |
+
} else {
|
1133 |
+
$user_role = is_array($user->roles) ? '' : $user->roles;
|
1134 |
+
}
|
1135 |
+
if (!empty($user_role) && !isset($wp_roles->roles[$user_role])) { // role doesn't exists
|
1136 |
+
$user->set_role($default_role); // set the lowest level role for this user
|
1137 |
+
$user_role = '';
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
if (empty($user_role)) {
|
1141 |
+
// Cleanup users level capabilities from non-existed roles
|
1142 |
+
$cap_removed = true;
|
1143 |
+
while (count($user->caps) > 0 && $cap_removed) {
|
1144 |
+
foreach ($user->caps as $capability => $value) {
|
1145 |
+
if (!isset($this->full_capabilities[$capability])) {
|
1146 |
+
$user->remove_cap($capability);
|
1147 |
+
$cap_removed = true;
|
1148 |
+
break;
|
1149 |
+
}
|
1150 |
+
$cap_removed = false;
|
1151 |
+
}
|
1152 |
+
} // while ()
|
1153 |
+
}
|
1154 |
+
} // foreach()
|
1155 |
+
}
|
1156 |
+
// end of validate_user_roles()
|
1157 |
+
|
1158 |
+
|
1159 |
+
private function add_capability_to_full_caps_list($cap_id) {
|
1160 |
+
$cap = array();
|
1161 |
+
$cap['inner'] = $cap_id;
|
1162 |
+
$cap['human'] = __($this->convert_caps_to_readable($cap_id), 'ure');
|
1163 |
+
if (isset($this->built_in_wp_caps[$cap_id])) {
|
1164 |
+
$cap['wp_core'] = true;
|
1165 |
+
} else {
|
1166 |
+
$cap['wp_core'] = false;
|
1167 |
+
}
|
1168 |
+
if (!isset($this->full_capabilities[$cap_id])) {
|
1169 |
+
$this->full_capabilities[$cap_id] = $cap;
|
1170 |
+
}
|
1171 |
+
|
1172 |
+
}
|
1173 |
+
// end of build_capability()
|
1174 |
+
|
1175 |
+
|
1176 |
+
private function init_full_capabilities() {
|
1177 |
+
$this->built_in_wp_caps = $this->get_built_in_wp_caps();
|
1178 |
+
$this->full_capabilities = array();
|
1179 |
+
foreach ($this->roles as $role) {
|
1180 |
+
// validate if capabilities is an array
|
1181 |
+
if (isset($role['capabilities']) && is_array($role['capabilities'])) {
|
1182 |
+
foreach ($role['capabilities'] as $key => $value) {
|
1183 |
+
$this->add_capability_to_full_caps_list($key);
|
1184 |
+
}
|
1185 |
+
}
|
1186 |
+
}
|
1187 |
+
// Get Gravity Forms plugin capabilities, if available
|
1188 |
+
if ($this->integrate_with_gravity_forms) {
|
1189 |
+
$gf_caps = GFCommon::all_caps();
|
1190 |
+
foreach ($gf_caps as $gf_cap) {
|
1191 |
+
$this->add_capability_to_full_caps_list($gf_cap);
|
1192 |
+
}
|
1193 |
+
}
|
1194 |
+
unset($this->built_in_wp_caps);
|
1195 |
+
asort($this->full_capabilities);
|
1196 |
+
}
|
1197 |
+
// end of init_full_capabilities()
|
1198 |
+
|
1199 |
+
|
1200 |
+
/**
|
1201 |
+
* reset user roles to WordPress default roles
|
1202 |
+
*/
|
1203 |
+
private function reset_user_roles() {
|
1204 |
+
global $wp_roles;
|
1205 |
+
|
1206 |
+
//$active_plugins = ure_deactivate_plugins(); // deactivate all plugins
|
1207 |
+
|
1208 |
+
$wp_roles->roles = array();
|
1209 |
+
$wp_roles->role_objects = array();
|
1210 |
+
$wp_roles->role_names = array();
|
1211 |
+
$wp_roles->use_db = true;
|
1212 |
+
|
1213 |
+
require_once(ABSPATH . '/wp-admin/includes/schema.php');
|
1214 |
+
populate_roles();
|
1215 |
+
$wp_roles->reinit();
|
1216 |
+
|
1217 |
+
/*
|
1218 |
+
// return recently deactivated plugins to its original state
|
1219 |
+
if ( is_array( $active_plugins ) && count( $active_plugins ) > 0 ) {
|
1220 |
+
activate_plugins( $active_plugins, $reload_link);
|
1221 |
+
}
|
1222 |
+
//$this->validate_user_roles(); // if user has non-existing role lower him to Subscriber role
|
1223 |
+
*/
|
1224 |
+
$reload_link = wp_get_referer();
|
1225 |
+
$reload_link = remove_query_arg('action', $reload_link);
|
1226 |
+
|
1227 |
+
?>
|
1228 |
+
<script type="text/javascript" >
|
1229 |
+
jQuery.ure_postGo('<?php echo $reload_link; ?>',
|
1230 |
+
{ action: 'roles_restore_note',
|
1231 |
+
ure_nonce: ure_data.wp_nonce} );
|
1232 |
+
</script>
|
1233 |
+
<?php
|
1234 |
+
}
|
1235 |
+
// end of reset_user_roles()
|
1236 |
+
|
1237 |
+
|
1238 |
+
// Save Roles to database
|
1239 |
+
private function save_roles() {
|
1240 |
+
global $wpdb;
|
1241 |
+
|
1242 |
+
if (!isset($this->roles[$this->current_role])) {
|
1243 |
+
return false;
|
1244 |
+
}
|
1245 |
+
$this->roles[$this->current_role]['capabilities'] = $this->capabilities_to_save;
|
1246 |
+
$option_name = $wpdb->prefix . 'user_roles';
|
1247 |
+
|
1248 |
+
$result = update_option($option_name, $this->roles);
|
1249 |
+
|
1250 |
+
return $result;
|
1251 |
+
}
|
1252 |
+
// end of save_roles()
|
1253 |
+
|
1254 |
+
|
1255 |
+
function direct_site_roles_update($blog_ids) {
|
1256 |
+
global $wpdb;
|
1257 |
+
|
1258 |
+
if (!isset($this->roles[$this->current_role])) {
|
1259 |
+
$this->roles[$this->current_role]['name'] = $this->current_role_name;
|
1260 |
+
}
|
1261 |
+
$this->roles[$this->current_role]['capabilities'] = $this->capabilities_to_save;
|
1262 |
+
$serialized_roles = serialize($this->roles);
|
1263 |
+
foreach ($blog_ids as $blog_id) {
|
1264 |
+
$prefix = $wpdb->get_blog_prefix($blog_id);
|
1265 |
+
$options_table_name = $prefix . 'options';
|
1266 |
+
$option_name = $prefix . 'user_roles';
|
1267 |
+
$query = "update $options_table_name
|
1268 |
+
set option_value='$serialized_roles'
|
1269 |
+
where option_name='$option_name'
|
1270 |
+
limit 1";
|
1271 |
+
$record = $wpdb->query($query);
|
1272 |
+
if ($wpdb->last_error) {
|
1273 |
+
$this->log_event($wpdb->last_error, true);
|
1274 |
+
return false;
|
1275 |
+
}
|
1276 |
+
if ($record == 0) {
|
1277 |
+
return false;
|
1278 |
+
}
|
1279 |
+
}
|
1280 |
+
}
|
1281 |
+
// end of direct_site_roles_update()
|
1282 |
+
|
1283 |
+
|
1284 |
+
/**
|
1285 |
+
* Process user request on save roles update
|
1286 |
+
*
|
1287 |
+
* @global wpdb $wpdb
|
1288 |
+
* @return boolean
|
1289 |
+
*/
|
1290 |
+
private function update_roles() {
|
1291 |
+
global $wpdb;
|
1292 |
+
|
1293 |
+
if (is_multisite() && is_super_admin() && $this->apply_to_all) { // update Role for the all blogs/sites in the network (permitted to superadmin only)
|
1294 |
+
if (defined('URE_DEBUG') && URE_DEBUG) {
|
1295 |
+
$time_shot = microtime();
|
1296 |
+
}
|
1297 |
+
|
1298 |
+
$old_blog = $wpdb->blogid;
|
1299 |
+
// Get all blog ids
|
1300 |
+
$blogIds = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
|
1301 |
+
if (defined('URE_MULTISITE_DIRECT_UPDATE') && URE_MULTISITE_DIRECT_UPDATE == 1) {
|
1302 |
+
$this->direct_site_roles_update($blogIds);
|
1303 |
+
} else {
|
1304 |
+
foreach ($blogIds as $blog_id) {
|
1305 |
+
switch_to_blog($blog_id);
|
1306 |
+
$this->roles = $this->get_user_roles();
|
1307 |
+
if (!$this->roles) {
|
1308 |
+
echo '<div class="error fade below-h2">' . URE_ERROR . '</div>';
|
1309 |
+
switch_to_blog($old_blog);
|
1310 |
+
$this->roles = $this->get_user_roles();
|
1311 |
+
return false;
|
1312 |
+
}
|
1313 |
+
if (!isset($this->roles[$this->current_role])) { // add new role to this blog
|
1314 |
+
$this->roles[$this->current_role] = array('name' => $this->current_role_name, 'capabilities' => array('read' => 1));
|
1315 |
+
}
|
1316 |
+
$this->save_roles();
|
1317 |
+
}
|
1318 |
+
switch_to_blog($old_blog);
|
1319 |
+
$this->roles = $this->get_user_roles();
|
1320 |
+
}
|
1321 |
+
|
1322 |
+
if (defined('URE_DEBUG') && URE_DEBUG) {
|
1323 |
+
echo '<div class="updated fade below-h2">Roles updated for ' . ( microtime() - $time_shot ) . ' milliseconds</div>';
|
1324 |
+
}
|
1325 |
+
} else {
|
1326 |
+
if (!$this->save_roles()) {
|
1327 |
+
return false;
|
1328 |
+
}
|
1329 |
+
}
|
1330 |
+
|
1331 |
+
return true;
|
1332 |
+
}
|
1333 |
+
// end of update_roles()
|
1334 |
+
|
1335 |
+
|
1336 |
+
/**
|
1337 |
+
* Write message to the log file
|
1338 |
+
*
|
1339 |
+
* @global type $wp_version
|
1340 |
+
* @param string $message
|
1341 |
+
* @param boolean $show_message
|
1342 |
+
*/
|
1343 |
+
private function log_event($message, $show_message = false) {
|
1344 |
+
global $wp_version;
|
1345 |
+
|
1346 |
+
$file_name = URE_PLUGIN_DIR . 'user-role-editor.log';
|
1347 |
+
$fh = fopen($file_name, 'a');
|
1348 |
+
$cr = "\n";
|
1349 |
+
$s = $cr . date("d-m-Y H:i:s") . $cr .
|
1350 |
+
'WordPress version: ' . $wp_version . ', PHP version: ' . phpversion() . ', MySQL version: ' . mysql_get_server_info() . $cr;
|
1351 |
+
fwrite($fh, $s);
|
1352 |
+
fwrite($fh, $message . $cr);
|
1353 |
+
fclose($fh);
|
1354 |
+
|
1355 |
+
if ($show_message) {
|
1356 |
+
$this->show_message('Error! ' . __('Error is occur. Please check the log file.', 'ure'));
|
1357 |
+
}
|
1358 |
+
}
|
1359 |
+
// end of log_event()
|
1360 |
+
|
1361 |
+
|
1362 |
+
/**
|
1363 |
+
* process new role create request
|
1364 |
+
*
|
1365 |
+
* @global WP_Roles $wp_roles
|
1366 |
+
*
|
1367 |
+
* @return string - message about operation result
|
1368 |
+
*
|
1369 |
+
*/
|
1370 |
+
private function new_role_create() {
|
1371 |
+
|
1372 |
+
global $wp_roles;
|
1373 |
+
|
1374 |
+
$mess = '';
|
1375 |
+
$this->current_role = '';
|
1376 |
+
if (isset($_POST['user_role_id']) && $_POST['user_role_id']) {
|
1377 |
+
$user_role_id = utf8_decode($_POST['user_role_id']);
|
1378 |
+
// sanitize user input for security
|
1379 |
+
$valid_name = preg_match('/[A-Za-z0-9_\-]*/', $user_role_id, $match);
|
1380 |
+
if (!$valid_name || ($valid_name && ($match[0] != $user_role_id))) { // some non-alphanumeric charactes found!
|
1381 |
+
return __('Error: Role ID must contain latin characters, digits, hyphens or underscore only!', 'ure');
|
1382 |
+
}
|
1383 |
+
|
1384 |
+
if ($user_role_id) {
|
1385 |
+
$user_role_name = isset($_POST['user_role_name']) ? $_POST['user_role_name'] : false;
|
1386 |
+
if (!empty($user_role_name)) {
|
1387 |
+
$user_role_name = sanitize_text_field($user_role_name);
|
1388 |
+
} else {
|
1389 |
+
$user_role_name = $user_role_id; // as user role name is empty, use user role ID instead
|
1390 |
+
}
|
1391 |
+
|
1392 |
+
if (!isset($wp_roles)) {
|
1393 |
+
$wp_roles = new WP_Roles();
|
1394 |
+
}
|
1395 |
+
if (isset($wp_roles->roles[$user_role_id])) {
|
1396 |
+
return sprintf('Error! ' . __('Role %s exists already', 'ure'), $user_role_id);
|
1397 |
+
}
|
1398 |
+
$user_role_id = strtolower($user_role_id);
|
1399 |
+
$this->current_role = $user_role_id;
|
1400 |
+
|
1401 |
+
$user_role_copy_from = isset($_POST['user_role_copy_from']) ? $_POST['user_role_copy_from'] : false;
|
1402 |
+
if (!empty($user_role_copy_from) && $user_role_copy_from != 'none' && $wp_roles->is_role($user_role_copy_from)) {
|
1403 |
+
$role = $wp_roles->get_role($user_role_copy_from);
|
1404 |
+
$capabilities = $role->capabilities;
|
1405 |
+
} else {
|
1406 |
+
$capabilities = array('read' => 1, 'level_0' => 1);
|
1407 |
+
}
|
1408 |
+
// add new role to the roles array
|
1409 |
+
$result = add_role($user_role_id, $user_role_name, $capabilities);
|
1410 |
+
if (!isset($result) || empty($result)) {
|
1411 |
+
$mess = 'Error! ' . __('Error is encountered during new role create operation', 'ure');
|
1412 |
+
} else {
|
1413 |
+
$mess = sprintf(__('Role %s is created successfully', 'ure'), $user_role_name);
|
1414 |
+
}
|
1415 |
+
}
|
1416 |
+
}
|
1417 |
+
return $mess;
|
1418 |
+
}
|
1419 |
+
// end of newRoleCreate()
|
1420 |
+
|
1421 |
+
|
1422 |
+
private function delete_role() {
|
1423 |
+
global $wp_roles;
|
1424 |
+
|
1425 |
+
$mess = '';
|
1426 |
+
if (isset($_POST['user_role_id']) && $_POST['user_role_id']) {
|
1427 |
+
$role = $_POST['user_role_id'];
|
1428 |
+
//$result = remove_role($_POST['user_role']);
|
1429 |
+
// use this modified code from remove_role() directly as remove_role() returns nothing to check
|
1430 |
+
if (!isset($wp_roles)) {
|
1431 |
+
$wp_roles = new WP_Roles();
|
1432 |
+
}
|
1433 |
+
if (isset($wp_roles->roles[$role])) {
|
1434 |
+
unset($wp_roles->role_objects[$role]);
|
1435 |
+
unset($wp_roles->role_names[$role]);
|
1436 |
+
unset($wp_roles->roles[$role]);
|
1437 |
+
$result = update_option($wp_roles->role_key, $wp_roles->roles);
|
1438 |
+
} else {
|
1439 |
+
$result = false;
|
1440 |
+
}
|
1441 |
+
if (empty($result)) {
|
1442 |
+
$mess = 'Error! ' . __('Error encountered during role delete operation', 'ure');
|
1443 |
+
} else {
|
1444 |
+
$mess = sprintf(__('Role %s is deleted successfully', 'ure'), $role);
|
1445 |
+
}
|
1446 |
+
unset($_POST['user_role']);
|
1447 |
+
}
|
1448 |
+
|
1449 |
+
return $mess;
|
1450 |
+
}
|
1451 |
+
// end of ure_delete_role()
|
1452 |
+
|
1453 |
+
|
1454 |
+
/**
|
1455 |
+
* Change default WordPress role
|
1456 |
+
* @global WP_Roles $wp_roles
|
1457 |
+
* @return string
|
1458 |
+
*/
|
1459 |
+
private function change_default_role() {
|
1460 |
+
global $wp_roles;
|
1461 |
+
|
1462 |
+
$mess = '';
|
1463 |
+
if (!isset($wp_roles)) {
|
1464 |
+
$wp_roles = new WP_Roles();
|
1465 |
+
}
|
1466 |
+
if (!empty($_POST['user_role_id'])) {
|
1467 |
+
$user_role_id = $_POST['user_role_id'];
|
1468 |
+
unset($_POST['user_role_id']);
|
1469 |
+
$errorMessage = 'Error! ' . __('Error encountered during default role change operation', 'ure');
|
1470 |
+
if (isset($wp_roles->role_objects[$user_role_id]) && $user_role_id !== 'administrator') {
|
1471 |
+
$result = update_option('default_role', $user_role_id);
|
1472 |
+
if (empty($result)) {
|
1473 |
+
$mess = $errorMessage;
|
1474 |
+
} else {
|
1475 |
+
$mess = sprintf(__('Default role for new users is set to %s successfully', 'ure'), $wp_roles->role_names[$user_role_id]);
|
1476 |
+
}
|
1477 |
+
} else {
|
1478 |
+
$mess = $errorMessage;
|
1479 |
+
}
|
1480 |
+
}
|
1481 |
+
|
1482 |
+
return $mess;
|
1483 |
+
}
|
1484 |
+
// end of change_default_role()
|
1485 |
+
|
1486 |
+
|
1487 |
+
/**
|
1488 |
+
* Not really used in the plugin - just storage for the translation strings
|
1489 |
+
*/
|
1490 |
+
private function translation_data() {
|
1491 |
+
// for the translation purpose
|
1492 |
+
if (false) {
|
1493 |
+
// Standard WordPress roles
|
1494 |
+
__('Editor', 'ure');
|
1495 |
+
__('Author', 'ure');
|
1496 |
+
__('Contributor', 'ure');
|
1497 |
+
__('Subscriber', 'ure');
|
1498 |
+
// Standard WordPress capabilities
|
1499 |
+
__('Switch themes', 'ure');
|
1500 |
+
__('Edit themes', 'ure');
|
1501 |
+
__('Activate plugins', 'ure');
|
1502 |
+
__('Edit plugins', 'ure');
|
1503 |
+
__('Edit users', 'ure');
|
1504 |
+
__('Edit files', 'ure');
|
1505 |
+
__('Manage options', 'ure');
|
1506 |
+
__('Moderate comments', 'ure');
|
1507 |
+
__('Manage categories', 'ure');
|
1508 |
+
__('Manage links', 'ure');
|
1509 |
+
__('Upload files', 'ure');
|
1510 |
+
__('Import', 'ure');
|
1511 |
+
__('Unfiltered html', 'ure');
|
1512 |
+
__('Edit posts', 'ure');
|
1513 |
+
__('Edit others posts', 'ure');
|
1514 |
+
__('Edit published posts', 'ure');
|
1515 |
+
__('Publish posts', 'ure');
|
1516 |
+
__('Edit pages', 'ure');
|
1517 |
+
__('Read', 'ure');
|
1518 |
+
__('Level 10', 'ure');
|
1519 |
+
__('Level 9', 'ure');
|
1520 |
+
__('Level 8', 'ure');
|
1521 |
+
__('Level 7', 'ure');
|
1522 |
+
__('Level 6', 'ure');
|
1523 |
+
__('Level 5', 'ure');
|
1524 |
+
__('Level 4', 'ure');
|
1525 |
+
__('Level 3', 'ure');
|
1526 |
+
__('Level 2', 'ure');
|
1527 |
+
__('Level 1', 'ure');
|
1528 |
+
__('Level 0', 'ure');
|
1529 |
+
__('Edit others pages', 'ure');
|
1530 |
+
__('Edit published pages', 'ure');
|
1531 |
+
__('Publish pages', 'ure');
|
1532 |
+
__('Delete pages', 'ure');
|
1533 |
+
__('Delete others pages', 'ure');
|
1534 |
+
__('Delete published pages', 'ure');
|
1535 |
+
__('Delete posts', 'ure');
|
1536 |
+
__('Delete others posts', 'ure');
|
1537 |
+
__('Delete published posts', 'ure');
|
1538 |
+
__('Delete private posts', 'ure');
|
1539 |
+
__('Edit private posts', 'ure');
|
1540 |
+
__('Read private posts', 'ure');
|
1541 |
+
__('Delete private pages', 'ure');
|
1542 |
+
__('Edit private pages', 'ure');
|
1543 |
+
__('Read private pages', 'ure');
|
1544 |
+
__('Delete users', 'ure');
|
1545 |
+
__('Create users', 'ure');
|
1546 |
+
__('Unfiltered upload', 'ure');
|
1547 |
+
__('Edit dashboard', 'ure');
|
1548 |
+
__('Update plugins', 'ure');
|
1549 |
+
__('Delete plugins', 'ure');
|
1550 |
+
__('Install plugins', 'ure');
|
1551 |
+
__('Update themes', 'ure');
|
1552 |
+
__('Install themes', 'ure');
|
1553 |
+
__('Update core', 'ure');
|
1554 |
+
__('List users', 'ure');
|
1555 |
+
__('Remove users', 'ure');
|
1556 |
+
__('Add users', 'ure');
|
1557 |
+
__('Promote users', 'ure');
|
1558 |
+
__('Edit theme options', 'ure');
|
1559 |
+
__('Delete themes', 'ure');
|
1560 |
+
__('Export', 'ure');
|
1561 |
+
}
|
1562 |
+
}
|
1563 |
+
// end of ure_TranslationData()
|
1564 |
+
|
1565 |
+
|
1566 |
+
/**
|
1567 |
+
* Update user roles and capabilities
|
1568 |
+
*
|
1569 |
+
* @global WP_Roles $wp_roles
|
1570 |
+
* @param WP_User $user
|
1571 |
+
* @return boolean
|
1572 |
+
*/
|
1573 |
+
private function update_user($user) {
|
1574 |
+
global $wp_roles;
|
1575 |
+
|
1576 |
+
$primary_role = array_shift(array_values($user->roles)); // get 1st element from roles array as user primary role
|
1577 |
+
if (empty($primary_role) || !isset($this->roles[$primary_role])) {
|
1578 |
+
$primary_role = '';
|
1579 |
+
}
|
1580 |
+
if (function_exists('bbp_filter_blog_editable_roles')) { // bbPress plugin is active
|
1581 |
+
$bbp_user_role = bbp_get_user_role($user->ID);
|
1582 |
+
} else {
|
1583 |
+
$bbp_user_role = '';
|
1584 |
+
}
|
1585 |
+
|
1586 |
+
// revoke all roles and capabilities from this user
|
1587 |
+
$user->roles = array();
|
1588 |
+
$user->remove_all_caps();
|
1589 |
+
|
1590 |
+
// restore primary role
|
1591 |
+
if (!empty($primary_role)) {
|
1592 |
+
$user->add_role($primary_role);
|
1593 |
+
}
|
1594 |
+
|
1595 |
+
// restore bbPress user role if she had one
|
1596 |
+
if (!empty($bbp_user_role)) {
|
1597 |
+
$user->add_role($bbp_user_role);
|
1598 |
+
}
|
1599 |
+
|
1600 |
+
// add other roles to user
|
1601 |
+
foreach ($_POST as $key => $value) {
|
1602 |
+
$result = preg_match('/^wp_role_(.+)/', $key, $match);
|
1603 |
+
if ($result === 1) {
|
1604 |
+
$role = $match[1];
|
1605 |
+
if (isset($wp_roles->roles[$role])) {
|
1606 |
+
$user->add_role($role);
|
1607 |
+
}
|
1608 |
+
}
|
1609 |
+
}
|
1610 |
+
|
1611 |
+
// add individual capabilities to user
|
1612 |
+
if (count($this->capabilities_to_save) > 0) {
|
1613 |
+
foreach ($this->capabilities_to_save as $key => $value) {
|
1614 |
+
foreach ($user->roles as $role_id => $role) {
|
1615 |
+
if (empty($role['capabilities'][$key])) {
|
1616 |
+
$user->add_cap($key);
|
1617 |
+
}
|
1618 |
+
}
|
1619 |
+
}
|
1620 |
+
}
|
1621 |
+
$user->update_user_level_from_caps();
|
1622 |
+
|
1623 |
+
return true;
|
1624 |
+
}
|
1625 |
+
// end of ure_update_user()
|
1626 |
+
|
1627 |
+
|
1628 |
+
/**
|
1629 |
+
* Add new capability
|
1630 |
+
*
|
1631 |
+
* @global WP_Roles $wp_roles
|
1632 |
+
* @return string
|
1633 |
+
*/
|
1634 |
+
private function add_new_capability() {
|
1635 |
+
global $wp_roles;
|
1636 |
+
|
1637 |
+
$mess = '';
|
1638 |
+
if (isset($_POST['capability_id']) && $_POST['capability_id']) {
|
1639 |
+
$user_capability = $_POST['capability_id'];
|
1640 |
+
// sanitize user input for security
|
1641 |
+
$valid_name = preg_match('/[A-Za-z0-9_\-]*/', $user_capability, $match);
|
1642 |
+
if (!$valid_name || ($valid_name && ($match[0] != $user_capability))) { // some non-alphanumeric charactes found!
|
1643 |
+
return 'Error! ' . __('Error: Capability name must contain latin characters and digits only!', 'ure');
|
1644 |
+
;
|
1645 |
+
}
|
1646 |
+
|
1647 |
+
if ($user_capability) {
|
1648 |
+
$user_capability = strtolower($user_capability);
|
1649 |
+
if (!isset($wp_roles)) {
|
1650 |
+
$wp_roles = new WP_Roles();
|
1651 |
+
}
|
1652 |
+
$wp_roles->use_db = true;
|
1653 |
+
$administrator = $wp_roles->get_role('administrator');
|
1654 |
+
if (!$administrator->has_cap($user_capability)) {
|
1655 |
+
$wp_roles->add_cap('administrator', $user_capability);
|
1656 |
+
$mess = sprintf(__('Capability %s is added successfully', 'ure'), $user_capability);
|
1657 |
+
} else {
|
1658 |
+
$mess = sprintf('Error! ' . __('Capability %s exists already', 'ure'), $user_capability);
|
1659 |
+
}
|
1660 |
+
}
|
1661 |
+
}
|
1662 |
+
|
1663 |
+
return $mess;
|
1664 |
+
}
|
1665 |
+
// end of add_new_capability()
|
1666 |
+
|
1667 |
+
|
1668 |
+
/**
|
1669 |
+
* Delete capability
|
1670 |
+
*
|
1671 |
+
* @global wpdb $wpdb
|
1672 |
+
* @global WP_Roles $wp_roles
|
1673 |
+
* @return string - information message
|
1674 |
+
*/
|
1675 |
+
private function delete_capability() {
|
1676 |
+
global $wpdb, $wp_roles;
|
1677 |
+
|
1678 |
+
$mess = '';
|
1679 |
+
if (!empty($_POST['user_capability_id'])) {
|
1680 |
+
$capability_id = $_POST['user_capability_id'];
|
1681 |
+
$caps_to_remove = $this->get_caps_to_remove();
|
1682 |
+
if (!is_array($caps_to_remove) || count($caps_to_remove) == 0 || !isset($caps_to_remove[$capability_id])) {
|
1683 |
+
return sprintf(__('Error! You do not have permission to delete this capability: %s!', 'ure'), $capability_id);
|
1684 |
+
}
|
1685 |
+
|
1686 |
+
// process users
|
1687 |
+
$usersId = $wpdb->get_col("SELECT $wpdb->users.ID FROM $wpdb->users");
|
1688 |
+
foreach ($usersId as $user_id) {
|
1689 |
+
$user = get_user_to_edit($user_id);
|
1690 |
+
if ($user->has_cap($capability_id)) {
|
1691 |
+
$user->remove_cap($capability_id);
|
1692 |
+
}
|
1693 |
+
}
|
1694 |
+
|
1695 |
+
// process roles
|
1696 |
+
foreach ($wp_roles->role_objects as $wp_role) {
|
1697 |
+
if ($wp_role->has_cap($capability_id)) {
|
1698 |
+
$wp_role->remove_cap($capability_id);
|
1699 |
+
}
|
1700 |
+
}
|
1701 |
+
|
1702 |
+
$mess = sprintf(__('Capability %s is removed successfully', 'ure'), $capability_id);
|
1703 |
+
}
|
1704 |
+
|
1705 |
+
return $mess;
|
1706 |
+
}
|
1707 |
+
// end of remove_capability()
|
1708 |
+
|
1709 |
+
|
1710 |
+
/**
|
1711 |
+
* Returns list of user roles, except 1st one, and bbPress assigned as they are shown by WordPress and bbPress theirselves.
|
1712 |
+
*
|
1713 |
+
* @param type $user WP_User from wp-includes/capabilities.php
|
1714 |
+
* @return array
|
1715 |
+
*/
|
1716 |
+
public function other_user_roles($user) {
|
1717 |
+
|
1718 |
+
global $wp_roles;
|
1719 |
+
|
1720 |
+
if (!is_array($user->roles) || count($user->roles) <= 1) {
|
1721 |
+
return '';
|
1722 |
+
}
|
1723 |
+
|
1724 |
+
// get bbPress assigned user role
|
1725 |
+
if (function_exists('bbp_filter_blog_editable_roles')) {
|
1726 |
+
$bb_press_role = bbp_get_user_role($user->ID);
|
1727 |
+
} else {
|
1728 |
+
$bb_press_role = '';
|
1729 |
+
}
|
1730 |
+
|
1731 |
+
$roles = array();
|
1732 |
+
foreach ($user->roles as $key => $value) {
|
1733 |
+
if (!empty($bb_press_role) && $bb_press_role === $value) {
|
1734 |
+
// exclude bbPress assigned role
|
1735 |
+
continue;
|
1736 |
+
}
|
1737 |
+
$roles[] = $value;
|
1738 |
+
}
|
1739 |
+
array_shift($roles); // exclude primary role which is shown by WordPress itself
|
1740 |
+
|
1741 |
+
return $roles;
|
1742 |
+
}
|
1743 |
+
// end of ure_other_user_roles()
|
1744 |
+
|
1745 |
+
|
1746 |
+
/**
|
1747 |
+
* Returns text presentation of user roles
|
1748 |
+
*
|
1749 |
+
* @param type $roles user roles list
|
1750 |
+
* @return string
|
1751 |
+
*/
|
1752 |
+
public function roles_text($roles) {
|
1753 |
+
global $wp_roles;
|
1754 |
+
|
1755 |
+
if (is_array($roles) && count($roles) > 0) {
|
1756 |
+
$role_names = array();
|
1757 |
+
foreach ($roles as $role) {
|
1758 |
+
$role_names[] = $wp_roles->roles[$role]['name'];
|
1759 |
+
}
|
1760 |
+
$output = implode(', ', $role_names);
|
1761 |
+
} else {
|
1762 |
+
$output = '';
|
1763 |
+
}
|
1764 |
+
|
1765 |
+
return $output;
|
1766 |
+
}
|
1767 |
+
// end of roles_text()
|
1768 |
+
|
1769 |
+
|
1770 |
+
/**
|
1771 |
+
* display opening part of the HTML box with title and CSS style
|
1772 |
+
*
|
1773 |
+
* @param string $title
|
1774 |
+
* @param string $style
|
1775 |
+
*/
|
1776 |
+
private function display_box_start($title, $style = '') {
|
1777 |
+
?>
|
1778 |
+
<div class="postbox" style="float: left; <?php echo $style; ?>">
|
1779 |
+
<h3 style="cursor:default;"><span><?php echo $title ?></span></h3>
|
1780 |
+
<div class="inside">
|
1781 |
+
<?php
|
1782 |
+
}
|
1783 |
+
// end of display_box_start()
|
1784 |
+
|
1785 |
+
|
1786 |
+
/**
|
1787 |
+
* close HTML box opened by display_box_start() call
|
1788 |
+
*/
|
1789 |
+
function display_box_end() {
|
1790 |
+
?>
|
1791 |
+
</div>
|
1792 |
+
</div>
|
1793 |
+
<?php
|
1794 |
+
}
|
1795 |
+
// end of display_box_end()
|
1796 |
+
|
1797 |
+
|
1798 |
+
private function about() {
|
1799 |
+
$this->display_box_start(__('About this Plugin:', 'ure'));
|
1800 |
+
?>
|
1801 |
+
<a class="ure_rsb_link" style="background-image:url(<?php echo URE_PLUGIN_URL . 'images/vladimir.png'; ?>);" target="_blank" href="http://www.shinephp.com/"><?php _e("Author's website", 'ure'); ?></a>
|
1802 |
+
<a class="ure_rsb_link" style="background-image:url(<?php echo URE_PLUGIN_URL . 'images/user-role-editor-icon.png'; ?>);" target="_blank" href="http://role-editor.com"><?php _e('Plugin webpage', 'ure'); ?></a>
|
1803 |
+
<a class="ure_rsb_link" style="background-image:url(<?php echo URE_PLUGIN_URL . 'images/changelog-icon.png'; ?>);" target="_blank" href="http://www.shinephp.com/user-role-editor-wordpress-plugin/#changelog"><?php _e('Changelog', 'ure'); ?></a>
|
1804 |
+
<a class="ure_rsb_link" style="background-image:url(<?php echo URE_PLUGIN_URL . 'images/faq-icon.png'; ?>);" target="_blank" href="http://www.shinephp.com/user-role-editor-wordpress-plugin/#faq"><?php _e('FAQ', 'ure'); ?></a>
|
1805 |
+
<?php
|
1806 |
+
if (!class_exists('User_Role_Editor_Pro')) {
|
1807 |
+
?>
|
1808 |
+
<hr />
|
1809 |
+
<div style="text-align: center;">
|
1810 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
1811 |
+
<input type="hidden" name="cmd" value="_s-xclick">
|
1812 |
+
<input type="hidden" name="encrypted"
|
1813 |
+
value="-----BEGIN PKCS7-----MIIHZwYJKoZIhvcNAQcEoIIHWDCCB1QCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBME5QAQYFDddWBHA4YXI1x3dYmM77clH5s0CgokYnLVk0P8keOxMtYyNQo6xJs6pY1nJfE3tqNg8CZ3btJjmOUa6DsE+K8Nm6OxGHMQF45z8WAs+f/AvQWdSpPXD0eSMu9osNgmC3yv46hOT3B1J3rKkpeZzMThCdUfECqu+lluzELMAkGBSsOAwIaBQAwgeQGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQIeMSZk/UuZnuAgcAort75TUUbtDhmdTi1N0tR9W75Ypuw5nBw01HkZFsFHoGezoT95c3ZesHAlVprhztPrizl1UzE9COQs+3p62a0o+BlxUolkqUT3AecE9qs9dNshqreSvmC8SOpirOroK3WE7DStUvViBfgoNAPTTyTIAKKX24uNXjfvx1jFGMQGBcFysbb3OTkc/B6OiU2G951U9R8dvotaE1RQu6JwaRgwA3FEY9d/P8M+XdproiC324nzFel5WlZ8vtDnMyuPxOgggOHMIIDgzCCAuygAwIBAgIBADANBgkqhkiG9w0BAQUFADCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgk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RhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tAgEAMAkGBSsOAwIaBQCgXTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xMTEyMTAwODU3MjdaMCMGCSqGSIb3DQEJBDEWBBSFh6YmkoVtYdMaDd5G6EN0dGcPpzANBgkqhkiG9w0BAQEFAASBgAB91K/+gsmpbKxILdCVXCkiOg1zSG+tfq2EZSNzf8z/R1E3HH8qPdm68OToILsgWohKFwE+RCwcQ0iq77wd0alnWoknvhBBoFC/U0yJ3XmA3Hkgrcu6yhVijY/Odmf6WWcz79/uLGkvBSECbjTY0GLxvhRlsh2nAioCfxAr1cFo-----END PKCS7-----">
|
1814 |
+
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
1815 |
+
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
1816 |
+
</form>
|
1817 |
+
</div>
|
1818 |
+
<?php
|
1819 |
+
}
|
1820 |
+
$this->display_box_end();
|
1821 |
+
}
|
1822 |
+
// end of about()
|
1823 |
+
|
1824 |
+
|
1825 |
+
private function set_current_role() {
|
1826 |
+
if (!isset($this->current_role) || !$this->current_role) {
|
1827 |
+
if (isset($_REQUEST['user_role']) && $_REQUEST['user_role'] && isset($this->roles[$_REQUEST['user_role']])) {
|
1828 |
+
$this->current_role = $_REQUEST['user_role'];
|
1829 |
+
} else {
|
1830 |
+
$this->current_role = $this->get_last_role_id();
|
1831 |
+
}
|
1832 |
+
$this->current_role_name = $this->roles[$this->current_role]['name'];
|
1833 |
+
}
|
1834 |
+
}
|
1835 |
+
// end of set_current_role()
|
1836 |
+
|
1837 |
+
|
1838 |
+
private function role_edit_prepare_html() {
|
1839 |
+
|
1840 |
+
$you_are_admin = defined('URE_SHOW_ADMIN_ROLE') && $this->user_is_admin();
|
1841 |
+
|
1842 |
+
$this->role_default_html = '<select id="default_user_role" name="default_user_role" width="200" style="width: 200px">';
|
1843 |
+
$this->role_to_copy_html = '<select id="user_role_copy_from" name="user_role_copy_from" width="200" style="width: 200px">
|
1844 |
+
<option value="none" selected="selected">' . __('None', 'ure') . '</option>';
|
1845 |
+
$this->role_select_html = '<select id="user_role" name="user_role" onchange="ure_role_change(this.value);">';
|
1846 |
+
foreach ($this->roles as $key => $value) {
|
1847 |
+
$selected1 = $this->option_selected($key, $this->current_role);
|
1848 |
+
$selected2 = $this->option_selected($key, $this->wp_default_role);
|
1849 |
+
if ($you_are_admin || $key != 'administrator') {
|
1850 |
+
$translated_name = __($value['name'], 'ure'); // get translation from URE language file, if exists
|
1851 |
+
if ($translated_name === $value['name']) { // get WordPress internal translation
|
1852 |
+
$translated_name = translate_user_role($translated_name);
|
1853 |
+
}
|
1854 |
+
$translated_name .= ' (' . $key . ')';
|
1855 |
+
$this->role_select_html .= '<option value="' . $key . '" ' . $selected1 . '>' . $translated_name . '</option>';
|
1856 |
+
$this->role_default_html .= '<option value="' . $key . '" ' . $selected2 . '>' . $translated_name . '</option>';
|
1857 |
+
$this->role_to_copy_html .= '<option value="' . $key . '" >' . $translated_name . '</option>';
|
1858 |
+
}
|
1859 |
+
}
|
1860 |
+
$this->role_select_html .= '</select>';
|
1861 |
+
$this->role_default_html .= '</select>';
|
1862 |
+
$this->role_to_copy_html .= '</select>';
|
1863 |
+
|
1864 |
+
$roles_can_delete = $this->get_roles_can_delete();
|
1865 |
+
if ($roles_can_delete && count($roles_can_delete) > 0) {
|
1866 |
+
$this->role_delete_html = '<select id="del_user_role" name="del_user_role" width="200" style="width: 200px">';
|
1867 |
+
foreach ($roles_can_delete as $key => $value) {
|
1868 |
+
$this->role_delete_html .= '<option value="' . $key . '">' . __($value, 'ure') . '</option>';
|
1869 |
+
}
|
1870 |
+
$this->role_delete_html .= '</select>';
|
1871 |
+
} else {
|
1872 |
+
$this->role_delete_html = '';
|
1873 |
+
}
|
1874 |
+
|
1875 |
+
$this->capability_remove_html = $this->get_caps_to_remove_html();
|
1876 |
+
}
|
1877 |
+
// end of role_edit_prepare_html()
|
1878 |
+
|
1879 |
+
}
|
1880 |
+
// end of URE_Lib class
|
includes/class-user-role-editor.php
ADDED
@@ -0,0 +1,572 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* main class of User Role Editor WordPress plugin
|
4 |
+
* Author: Vladimir Garagulya
|
5 |
+
* Author email: vladimir@shinephp.com
|
6 |
+
* Author URI: http://shinephp.com
|
7 |
+
* License: GPL v3
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
|
11 |
+
class User_Role_Editor {
|
12 |
+
// common code staff, including options data processor
|
13 |
+
protected $lib = null;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* class constructor
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
function __construct()
|
20 |
+
{
|
21 |
+
|
22 |
+
if (!is_admin()) {
|
23 |
+
return false;
|
24 |
+
}
|
25 |
+
|
26 |
+
// activation action
|
27 |
+
register_activation_hook(URE_PLUGIN_FILE, array(&$this, 'setup'));
|
28 |
+
|
29 |
+
// deactivation action
|
30 |
+
register_deactivation_hook(URE_PLUGIN_FILE, array(&$this, 'cleanup'));
|
31 |
+
|
32 |
+
// get plugin specific library object
|
33 |
+
$this->lib = Garvs_WP_Lib::get_library('ure');
|
34 |
+
|
35 |
+
add_action('admin_init', array(&$this, 'plugin_init'), 1);
|
36 |
+
|
37 |
+
// Add the translation function after the plugins loaded hook.
|
38 |
+
add_action('plugins_loaded', array(&$this, 'load_translation'));
|
39 |
+
|
40 |
+
// add own submenu
|
41 |
+
add_action('admin_menu', array(&$this, 'plugin_menu'));
|
42 |
+
|
43 |
+
// add a Settings link in the installed plugins page
|
44 |
+
add_filter('plugin_action_links', array(&$this, 'plugin_action_links'), 10, 2);
|
45 |
+
|
46 |
+
add_filter('plugin_row_meta', array(&$this, 'plugin_row_meta'), 10, 2);
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
// end of __construct()
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Plugin initialization
|
55 |
+
*
|
56 |
+
*/
|
57 |
+
public function plugin_init() {
|
58 |
+
|
59 |
+
global $current_user;
|
60 |
+
|
61 |
+
if (!empty($current_user->ID)) {
|
62 |
+
$user_id = $current_user->ID;
|
63 |
+
} else {
|
64 |
+
$user_id = 0;
|
65 |
+
}
|
66 |
+
|
67 |
+
// these filters and actions should prevent editing users with administrator role
|
68 |
+
// by other users with URE_KEY_CAPABILITY capability
|
69 |
+
if (!$this->lib->user_is_admin($user_id)) {
|
70 |
+
// Exclude administrator role from edit list.
|
71 |
+
add_filter('editable_roles', array( &$this, 'exclude_admin_role' ) );
|
72 |
+
// prohibit any actions with user who has Administrator role
|
73 |
+
add_filter('user_has_cap', array( &$this, 'not_edit_admin' ), 10, 3);
|
74 |
+
// exclude users with 'Administrator' role from users list
|
75 |
+
add_action('pre_user_query', array( &$this, 'exclude_administrators' ) );
|
76 |
+
// do not show 'Administrator (s)' view above users list
|
77 |
+
add_filter('views_users', array( &$this, 'exclude_admins_view' ) );
|
78 |
+
}
|
79 |
+
|
80 |
+
add_action('admin_enqueue_scripts', array( &$this, 'admin_load_js' ) );
|
81 |
+
add_action( 'user_row_actions', array( &$this, 'user_row'), 10, 2 );
|
82 |
+
add_action( 'edit_user_profile', array(&$this, 'edit_user_profile'), 10, 2);
|
83 |
+
add_filter( 'manage_users_columns', array(&$this, 'user_role_column'), 10, 5 );
|
84 |
+
add_filter( 'manage_users_custom_column', array(&$this, 'user_role_row'), 10, 3 );
|
85 |
+
add_action( 'profile_update', array(&$this, 'user_profile_update'), 10 );
|
86 |
+
|
87 |
+
|
88 |
+
if (function_exists('is_multisite') && is_multisite()) {
|
89 |
+
add_action( 'wpmu_new_blog', array( &$this, 'duplicate_roles_for_new_blog'), 10, 2 );
|
90 |
+
add_filter( 'all_plugins', array( &$this, 'exclude_from_plugins_list' ) );
|
91 |
+
}
|
92 |
+
|
93 |
+
}
|
94 |
+
// end of plugin_init()
|
95 |
+
|
96 |
+
|
97 |
+
|
98 |
+
/**
|
99 |
+
* exclude administrator role from the roles list
|
100 |
+
*
|
101 |
+
* @param string $roles
|
102 |
+
* @return array
|
103 |
+
*/
|
104 |
+
public function exclude_admin_role($roles)
|
105 |
+
{
|
106 |
+
|
107 |
+
if (isset($roles['administrator'])) {
|
108 |
+
unset($roles['administrator']);
|
109 |
+
}
|
110 |
+
|
111 |
+
return $roles;
|
112 |
+
}
|
113 |
+
// end of exclude_admin_role()
|
114 |
+
|
115 |
+
|
116 |
+
/**
|
117 |
+
* We have two vulnerable queries with user id at admin interface, which should be processed
|
118 |
+
* 1st: http://blogdomain.com/wp-admin/user-edit.php?user_id=ID&wp_http_referer=%2Fwp-admin%2Fusers.php
|
119 |
+
* 2nd: http://blogdomain.com/wp-admin/users.php?action=delete&user=ID&_wpnonce=ab34225a78
|
120 |
+
* If put Administrator user ID into such request, user with lower capabilities (if he has 'edit_users')
|
121 |
+
* can edit, delete admin record
|
122 |
+
* This function removes 'edit_users' capability from current user capabilities
|
123 |
+
* if request has admin user ID in it
|
124 |
+
*
|
125 |
+
* @param array $allcaps
|
126 |
+
* @param type $caps
|
127 |
+
* @param string $name
|
128 |
+
* @return array
|
129 |
+
*/
|
130 |
+
public function not_edit_admin($allcaps, $caps, $name)
|
131 |
+
{
|
132 |
+
|
133 |
+
$user_keys = array('user_id', 'user');
|
134 |
+
foreach ($user_keys as $user_key) {
|
135 |
+
$access_deny = false;
|
136 |
+
$user_id = $this->lib->get_request_var($user_key, 'get');
|
137 |
+
if (!empty($user_id)) {
|
138 |
+
if ($user_id == 1) { // built-in WordPress Admin
|
139 |
+
$access_deny = true;
|
140 |
+
} else {
|
141 |
+
if (!isset($this->lib->user_to_check[$user_id])) {
|
142 |
+
// check if user_id has Administrator role
|
143 |
+
$access_deny = $this->has_administrator_role($user_id);
|
144 |
+
} else {
|
145 |
+
// user_id was checked already, get result from cash
|
146 |
+
$access_deny = $this->lib->user_to_check[$user_id];
|
147 |
+
}
|
148 |
+
}
|
149 |
+
if ($access_deny) {
|
150 |
+
unset($allcaps['edit_users']);
|
151 |
+
}
|
152 |
+
break;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
return $allcaps;
|
157 |
+
}
|
158 |
+
// end of not_edit_admin()
|
159 |
+
|
160 |
+
|
161 |
+
/**
|
162 |
+
* add where criteria to exclude users with 'Administrator' role from users list
|
163 |
+
*
|
164 |
+
* @global wpdb $wpdb
|
165 |
+
* @param type $user_query
|
166 |
+
*/
|
167 |
+
public function exclude_administrators($user_query)
|
168 |
+
{
|
169 |
+
|
170 |
+
global $wpdb;
|
171 |
+
|
172 |
+
// get user_id of users with 'Administrator' role
|
173 |
+
$tableName = (!is_multisite() && defined('CUSTOM_USER_META_TABLE')) ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
|
174 |
+
$meta_key = $wpdb->prefix . 'capabilities';
|
175 |
+
$admin_role_key = '%"administrator"%';
|
176 |
+
$query = "select user_id
|
177 |
+
from $tableName
|
178 |
+
where meta_key='$meta_key' and meta_value like '$admin_role_key'";
|
179 |
+
$ids_arr = $wpdb->get_col($query);
|
180 |
+
if (is_array($ids_arr) && count($ids_arr) > 0) {
|
181 |
+
$ids = implode(',', $ids_arr);
|
182 |
+
$user_query->query_where .= " AND ( $wpdb->users.ID NOT IN ( $ids ) )";
|
183 |
+
}
|
184 |
+
}
|
185 |
+
// end of exclude_administrators()
|
186 |
+
|
187 |
+
|
188 |
+
|
189 |
+
/*
|
190 |
+
* Exclude view of users with Administrator role
|
191 |
+
*
|
192 |
+
*/
|
193 |
+
public function exclude_admins_view($views) {
|
194 |
+
|
195 |
+
unset($views['administrator']);
|
196 |
+
|
197 |
+
return $views;
|
198 |
+
}
|
199 |
+
// end of exclude_admins_view()
|
200 |
+
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Add/hide edit actions for every user row at the users list
|
204 |
+
*
|
205 |
+
* @global type $pagenow
|
206 |
+
* @global type $current_user
|
207 |
+
* @param string $actions
|
208 |
+
* @param type $user
|
209 |
+
* @return string
|
210 |
+
*/
|
211 |
+
public function user_row($actions, $user)
|
212 |
+
{
|
213 |
+
|
214 |
+
global $pagenow, $current_user;
|
215 |
+
|
216 |
+
if ($pagenow == 'users.php') {
|
217 |
+
if (is_super_admin() ||
|
218 |
+
(is_multisite() && defined('URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE') && URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE == 1 &&
|
219 |
+
current_user_can('administrator'))) {
|
220 |
+
if (isset($user->caps['administrator'])) {
|
221 |
+
if ($current_user->ID != $user->ID) {
|
222 |
+
unset($actions['edit']);
|
223 |
+
unset($actions['delete']);
|
224 |
+
unset($actions['remove']);
|
225 |
+
}
|
226 |
+
} else if ($current_user->has_cap(URE_KEY_CAPABILITY)) {
|
227 |
+
$actions['capabilities'] = '<a href="' .
|
228 |
+
wp_nonce_url("users.php?page=".URE_PLUGIN_FILE."&object=user&user_id={$user->ID}", "ure_user_{$user->ID}") .
|
229 |
+
'">' . __('Capabilities', 'ure') . '</a>';
|
230 |
+
}
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
return $actions;
|
235 |
+
}
|
236 |
+
// end of user_row()
|
237 |
+
|
238 |
+
|
239 |
+
/**
|
240 |
+
* every time when new blog created - duplicate to it roles from the main blog (1)
|
241 |
+
* @global wpdb $wpdb
|
242 |
+
* @global WP_Roles $wp_roles
|
243 |
+
* @param int $blog_id
|
244 |
+
* @param int $user_id
|
245 |
+
*
|
246 |
+
*/
|
247 |
+
public function duplicate_roles_for_new_blog($blog_id, $user_id)
|
248 |
+
{
|
249 |
+
|
250 |
+
global $wpdb, $wp_roles;
|
251 |
+
|
252 |
+
// get Id of 1st (main) blog
|
253 |
+
$blogIds = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs order by blog_id asc");
|
254 |
+
if (!isset($blogIds[0])) {
|
255 |
+
return;
|
256 |
+
}
|
257 |
+
$current_blog = $wpdb->blogid;
|
258 |
+
switch_to_blog($blogIds[0]);
|
259 |
+
$main_roles = new WP_Roles(); // get roles from primary blog
|
260 |
+
$default_role = get_option('default_role'); // get default role from primary blog
|
261 |
+
switch_to_blog($blog_id); // switch to the new created blog
|
262 |
+
$main_roles->use_db = false; // do not touch DB
|
263 |
+
$main_roles->add_cap('administrator', 'dummy_123456'); // just to save current roles into new blog
|
264 |
+
$main_roles->role_key = $wp_roles->role_key;
|
265 |
+
$main_roles->use_db = true; // save roles into new blog DB
|
266 |
+
$main_roles->remove_cap('administrator', 'dummy_123456'); // remove unneeded dummy capability
|
267 |
+
update_option('default_role', $default_role); // set default role for new blog as it set for primary one
|
268 |
+
switch_to_blog($current_blog); // return to blog where we were at the begin
|
269 |
+
}
|
270 |
+
// end of duplicate_roles_for_new_blog()
|
271 |
+
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Filter out URE plugin from not superadmin users
|
275 |
+
* @param type array $plugins plugins list
|
276 |
+
* @return type array $plugins updated plugins list
|
277 |
+
*/
|
278 |
+
public function exclude_from_plugins_list($plugins)
|
279 |
+
{
|
280 |
+
|
281 |
+
// if multi-site, then allow plugin activation for network superadmins and, if that's specially defined, - for single site administrators too
|
282 |
+
if (is_super_admin() || (defined('URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE') && URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE==1)) {
|
283 |
+
return $plugins;
|
284 |
+
}
|
285 |
+
|
286 |
+
// exclude URE from plugins list
|
287 |
+
foreach ($plugins as $key => $value) {
|
288 |
+
if ($key == 'user-role-editor/'.URE_PLUGIN_FILE) {
|
289 |
+
unset($plugins[$key]);
|
290 |
+
}
|
291 |
+
}
|
292 |
+
|
293 |
+
return $plugins;
|
294 |
+
}
|
295 |
+
// end of exclude_from_plugins_list()
|
296 |
+
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Load plugin translation files - linked to the 'plugins_loaded' action
|
300 |
+
*
|
301 |
+
*/
|
302 |
+
function load_translation()
|
303 |
+
{
|
304 |
+
|
305 |
+
load_plugin_textdomain('ure', '', dirname( plugin_basename( URE_PLUGIN_FULL_PATH ) ) .'/lang');
|
306 |
+
|
307 |
+
}
|
308 |
+
// end of ure_load_translation()
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Modify plugin actions link
|
312 |
+
*
|
313 |
+
* @param array $links
|
314 |
+
* @param string $file
|
315 |
+
* @return array
|
316 |
+
*/
|
317 |
+
public function plugin_action_links($links, $file)
|
318 |
+
{
|
319 |
+
|
320 |
+
if ($file == plugin_basename(dirname(URE_PLUGIN_FULL_PATH).'/'.URE_PLUGIN_FILE)) {
|
321 |
+
$settings_link = "<a href='" . URE_PARENT . "?page=".URE_PLUGIN_FILE."'>" . __('Settings', 'ure') . "</a>";
|
322 |
+
array_unshift($links, $settings_link);
|
323 |
+
}
|
324 |
+
|
325 |
+
return $links;
|
326 |
+
}
|
327 |
+
|
328 |
+
// end of plugin_action_links()
|
329 |
+
|
330 |
+
|
331 |
+
public function plugin_row_meta($links, $file) {
|
332 |
+
|
333 |
+
if ($file == plugin_basename(dirname(URE_PLUGIN_FULL_PATH) .'/'.URE_PLUGIN_FILE)) {
|
334 |
+
$links[] = '<a target="_blank" href="http://role-editor.com/changelog">' . __('Changelog', 'ure') . '</a>';
|
335 |
+
}
|
336 |
+
|
337 |
+
return $links;
|
338 |
+
}
|
339 |
+
|
340 |
+
// end of plugin_row_meta
|
341 |
+
|
342 |
+
|
343 |
+
|
344 |
+
public function plugin_menu() {
|
345 |
+
|
346 |
+
if (function_exists('add_submenu_page')) {
|
347 |
+
$key_capability = $this->lib->get_key_capability();
|
348 |
+
$ure_page = add_submenu_page('users.php', __('User Role Editor', 'ure'), __('User Role Editor', 'ure'), $key_capability,
|
349 |
+
URE_PLUGIN_FILE, array(&$this, 'edit_roles'));
|
350 |
+
add_action("admin_print_styles-$ure_page", array( &$this, 'admin_css_action' ) );
|
351 |
+
}
|
352 |
+
}
|
353 |
+
// end of plugin_menu()
|
354 |
+
|
355 |
+
|
356 |
+
public function admin_css_action() {
|
357 |
+
|
358 |
+
wp_enqueue_style('wp-jquery-ui-dialog');
|
359 |
+
wp_enqueue_style('ure_admin_css', URE_PLUGIN_URL . 'css/ure-admin.css', array(), false, 'screen');
|
360 |
+
}
|
361 |
+
// end of admin_css_action()
|
362 |
+
|
363 |
+
// call roles editor page
|
364 |
+
public function edit_roles() {
|
365 |
+
|
366 |
+
global $current_user;
|
367 |
+
|
368 |
+
if (!empty($current_user)) {
|
369 |
+
$user_id = $current_user->ID;
|
370 |
+
} else {
|
371 |
+
$user_id = false;
|
372 |
+
}
|
373 |
+
if (!$this->lib->user_is_admin($user_id)) {
|
374 |
+
if (is_multisite()) {
|
375 |
+
$admin = 'SuperAdministrator';
|
376 |
+
} else {
|
377 |
+
$admin = 'Administrator';
|
378 |
+
}
|
379 |
+
die(__('Only', 'ure') . ' ' . $admin . ' ' . __('is allowed to use', 'ure') . ' ' . 'User Role Editor');
|
380 |
+
}
|
381 |
+
|
382 |
+
$this->lib->editor();
|
383 |
+
|
384 |
+
}
|
385 |
+
// end of edit_roles()
|
386 |
+
|
387 |
+
|
388 |
+
|
389 |
+
/**
|
390 |
+
* execute on plugin activation
|
391 |
+
*/
|
392 |
+
function setup() {
|
393 |
+
|
394 |
+
$this->lib->put_option( 'ure_caps_readable', 0 );
|
395 |
+
$this->lib->put_option( 'ure_show_deprecated_caps', 1 );
|
396 |
+
$this->lib->flush_options();
|
397 |
+
$this->lib->make_roles_backup();
|
398 |
+
|
399 |
+
}
|
400 |
+
// end of setup()
|
401 |
+
|
402 |
+
|
403 |
+
/**
|
404 |
+
* Load plugin javascript stuff
|
405 |
+
*
|
406 |
+
* @param string $hook_suffix
|
407 |
+
*/
|
408 |
+
public function admin_load_js($hook_suffix){
|
409 |
+
|
410 |
+
if (class_exists('User_Role_Editor_Pro')) {
|
411 |
+
$ure_hook_suffix = 'users_page_user-role-editor-pro';
|
412 |
+
} else {
|
413 |
+
$ure_hook_suffix = 'users_page_user-role-editor';
|
414 |
+
}
|
415 |
+
if ($hook_suffix===$ure_hook_suffix) {
|
416 |
+
wp_enqueue_script('jquery-ui-dialog', false, array('jquery-ui-core','jquery-ui-button', 'jquery') );
|
417 |
+
wp_register_script( 'ure-js', plugins_url( '/js/ure-js.js', URE_PLUGIN_FULL_PATH ) );
|
418 |
+
wp_enqueue_script ( 'ure-js' );
|
419 |
+
wp_localize_script( 'ure-js', 'ure_data', array(
|
420 |
+
'wp_nonce' => wp_create_nonce('user-role-editor'),
|
421 |
+
'page_url' => URE_WP_ADMIN_URL . URE_PARENT .'?page='.URE_PLUGIN_FILE,
|
422 |
+
'is_multisite' => is_multisite() ? 1 : 0,
|
423 |
+
'select_all' => __('Select All', 'ure'),
|
424 |
+
'unselect_all' => __('Unselect All', 'ure'),
|
425 |
+
'reverse' => __('Reverse', 'ure'),
|
426 |
+
'update' => __('Update', 'ure'),
|
427 |
+
'confirm_submit' => __('Please confirm permissions update', 'ure'),
|
428 |
+
'add_new_role_title' => __('Add New Role', 'ure'),
|
429 |
+
'role_name_required' => __(' Role name (ID) can not be empty!', 'ure'),
|
430 |
+
'role_name_valid_chars' => __(' Role name (ID) must contain latin characters, digits, hyphens or underscore only!', 'ure'),
|
431 |
+
'add_role' => __('Add Role', 'ure'),
|
432 |
+
'delete_role' => __('Delete Role', 'ure'),
|
433 |
+
'cancel' => __('Cancel', 'ure'),
|
434 |
+
'add_capability' => __('Add Capability', 'ure'),
|
435 |
+
'delete_capability' => __('Delete Capability', 'ure'),
|
436 |
+
'reset' => __('Reset', 'ure'),
|
437 |
+
'reset_warning' => __('Reset Roles to WordPress defaults. Be careful, all changes made by you or plugins will be lost. Some plugins, e.g. S2Member, WooCommerce reactivation could be needed. Continue?', 'ure'),
|
438 |
+
'default_role' => __('Default Role', 'ure'),
|
439 |
+
'set_new_default_role' => __('Set New Default Role', 'ure'),
|
440 |
+
'delete_capability' => __('Delete Capability', 'ure'),
|
441 |
+
'delete_capability_warning' => __('Warning! Be careful - removing critical capability could crash some plugin or other custom code', 'ure'),
|
442 |
+
'capability_name_required' => __(' Capability name (ID) can not be empty!', 'ure'),
|
443 |
+
'capability_name_valid_chars' => __(' Capability name (ID) must contain latin characters, digits, hyphens or underscore only!', 'ure'),
|
444 |
+
) );
|
445 |
+
// load additional JS stuff for Pro version, if exists
|
446 |
+
do_action('ure_load_js');
|
447 |
+
}
|
448 |
+
|
449 |
+
}
|
450 |
+
// end of admin_load_js()
|
451 |
+
|
452 |
+
|
453 |
+
|
454 |
+
public function edit_user_profile($user) {
|
455 |
+
|
456 |
+
global $current_user, $wp_roles;
|
457 |
+
|
458 |
+
$result = stripos($_SERVER['REQUEST_URI'], 'network/user-edit.php');
|
459 |
+
if ($result !== false) { // exit, this code just for single site user profile only, not for network admin center
|
460 |
+
return;
|
461 |
+
}
|
462 |
+
if (!$this->lib->user_is_admin($current_user->ID)) {
|
463 |
+
return;
|
464 |
+
}
|
465 |
+
?>
|
466 |
+
<h3><?php _e('User Role Editor', 'ure'); ?></h3>
|
467 |
+
<table class="form-table">
|
468 |
+
<tr>
|
469 |
+
<th scope="row"><?php _e('Other Roles', 'ure'); ?></th>
|
470 |
+
<td>
|
471 |
+
<?php
|
472 |
+
$roles = $this->lib->other_user_roles($user);
|
473 |
+
if (is_array($roles) && count($roles) > 0) {
|
474 |
+
foreach ($roles as $role) {
|
475 |
+
echo '<input type="hidden" name="ure_other_roles[]" value="' . $role . '" />';
|
476 |
+
}
|
477 |
+
}
|
478 |
+
$output = $this->lib->roles_text($roles);
|
479 |
+
echo $output . ' >> <a href="' . wp_nonce_url("users.php?page=".URE_PLUGIN_FILE."&object=user&user_id={$user->ID}", "ure_user_{$user->ID}") . '">' . __('Edit', 'ure') . '</a>';
|
480 |
+
?>
|
481 |
+
</td>
|
482 |
+
</tr>
|
483 |
+
</table>
|
484 |
+
<?php
|
485 |
+
/*
|
486 |
+
<script type="text/javascript">
|
487 |
+
jQuery('#role').attr('disabled', 'disabled');
|
488 |
+
</script>
|
489 |
+
*/
|
490 |
+
?>
|
491 |
+
<?php
|
492 |
+
}
|
493 |
+
|
494 |
+
// end of ure_edit_user_profile()
|
495 |
+
|
496 |
+
/**
|
497 |
+
* add 'Other Roles' column to WordPress users list table
|
498 |
+
*
|
499 |
+
* @param array $columns WordPress users list table columns list
|
500 |
+
* @return array
|
501 |
+
*/
|
502 |
+
public function user_role_column($columns = array()) {
|
503 |
+
|
504 |
+
$columns['ure_roles'] = __('Other Roles', 'ure');
|
505 |
+
|
506 |
+
return $columns;
|
507 |
+
}
|
508 |
+
// end of user_role_column()
|
509 |
+
|
510 |
+
|
511 |
+
/**
|
512 |
+
* Return user's roles list for display in the WordPress Users list table
|
513 |
+
*
|
514 |
+
* @param string $retval
|
515 |
+
* @param string $column_name
|
516 |
+
* @param int $user_id
|
517 |
+
*
|
518 |
+
* @return string all user roles
|
519 |
+
*/
|
520 |
+
public function user_role_row($retval = '', $column_name = '', $user_id = 0)
|
521 |
+
{
|
522 |
+
|
523 |
+
// Only looking for User Role Editor other user roles column
|
524 |
+
if ('ure_roles' == $column_name) {
|
525 |
+
$user = get_userdata($user_id);
|
526 |
+
// Get the users roles
|
527 |
+
$roles = $this->lib->other_user_roles($user);
|
528 |
+
$retval = $this->lib->roles_text($roles);
|
529 |
+
}
|
530 |
+
|
531 |
+
// Pass retval through
|
532 |
+
return $retval;
|
533 |
+
}
|
534 |
+
// end of user_role_row()
|
535 |
+
|
536 |
+
|
537 |
+
// save additional user roles when user profile is updated, as WordPress itself doesn't know about them
|
538 |
+
public function user_profile_update($user_id) {
|
539 |
+
|
540 |
+
if (!current_user_can('edit_user', $user_id)) {
|
541 |
+
return;
|
542 |
+
}
|
543 |
+
$user = get_userdata($user_id);
|
544 |
+
|
545 |
+
if (isset($_POST['ure_other_roles'])) {
|
546 |
+
$new_roles = array_intersect($user->roles, $_POST['ure_other_roles']);
|
547 |
+
$skip_roles = array();
|
548 |
+
foreach ($new_roles as $role) {
|
549 |
+
$skip_roles['$role'] = 1;
|
550 |
+
}
|
551 |
+
unset($new_roles);
|
552 |
+
foreach ($_POST['ure_other_roles'] as $role) {
|
553 |
+
if (!isset($skip_roles[$role])) {
|
554 |
+
$user->add_role($role);
|
555 |
+
}
|
556 |
+
}
|
557 |
+
}
|
558 |
+
}
|
559 |
+
// update_user_profile()
|
560 |
+
|
561 |
+
|
562 |
+
|
563 |
+
// execute on plugin deactivation
|
564 |
+
function cleanup()
|
565 |
+
{
|
566 |
+
|
567 |
+
}
|
568 |
+
// end of setup()
|
569 |
+
|
570 |
+
|
571 |
+
}
|
572 |
+
// end of User_Role_Editor
|
includes/define-constants.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Constant definitions for use in WordPress plugin
|
5 |
+
* Author: Vladimir Garagulya
|
6 |
+
* Author email: vladimir@shinephp.com
|
7 |
+
* Author URI: http://shinephp.com
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
|
11 |
+
// general for any plugin
|
12 |
+
define('URE_WP_ADMIN_URL', admin_url());
|
13 |
+
define('URE_ERROR', 'Error is encountered');
|
14 |
+
|
15 |
+
// specific for User Role Editor plugin only
|
16 |
+
define('URE_PRO_VERSION', 0);
|
17 |
+
|
18 |
+
define('URE_SPACE_REPLACER', '_URE-SR_');
|
19 |
+
define('URE_PARENT', 'users.php');
|
20 |
+
define('URE_KEY_CAPABILITY', 'administrator');
|
includes/misc-support-stuff.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Miscellaneous support stuff, which should still be defined beyond of classes
|
5 |
+
*
|
6 |
+
* Author: Vladimir Garagulya
|
7 |
+
* Author email: vladimir@shinephp.com
|
8 |
+
* Author URI: http://shinephp.com
|
9 |
+
* License: GPL v3
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
|
13 |
+
// Support for Gravity Form capabilities
|
14 |
+
// As Gravity Form has integrated support for the Members plugin - let's imitate its presense,
|
15 |
+
// so GF code, like
|
16 |
+
// self::has_members_plugin())
|
17 |
+
// considers that is has members_plugin()
|
18 |
+
if (class_exists('GFForms') ) { // if Gravity Forms is installed
|
19 |
+
if (!function_exists('members_get_capabilities')) {
|
20 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
21 |
+
if (!is_plugin_active('members/members.php')) {
|
22 |
+
// define stub function to say "Gravity Forms" plugin: 'Hey! While I'm not the "Members" plugin, but I'm "User Role Editor" and
|
23 |
+
// I'm capable to manage your roles and capabilities too
|
24 |
+
function members_get_capabilities() {
|
25 |
+
|
26 |
+
}
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
?>
|
includes/ure-class-advertisement.php
DELETED
@@ -1,141 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* User Role Editor plugin: advertisement showing class
|
5 |
-
* Author: Vladimir Garagulya
|
6 |
-
* email: vladimir@shinephp.com
|
7 |
-
* site: http://shinephp.com
|
8 |
-
*
|
9 |
-
*/
|
10 |
-
|
11 |
-
class ure_Advertisement {
|
12 |
-
|
13 |
-
private $slots = array(0=>'', 1=>'', 2=>'');
|
14 |
-
|
15 |
-
function __construct() {
|
16 |
-
|
17 |
-
$used = array(-1);
|
18 |
-
$index = $this->rand_unique( $used );
|
19 |
-
$this->slots[$index] = $this->admin_menu_editor();
|
20 |
-
|
21 |
-
$used[] = $index;
|
22 |
-
$index = $this->rand_unique( $used );
|
23 |
-
$this->slots[$index] = $this->manage_wp();
|
24 |
-
|
25 |
-
$used[] = $index;
|
26 |
-
$index = $this->rand_unique( $used );
|
27 |
-
$this->slots[$index] = $this->video_user_manuals();
|
28 |
-
|
29 |
-
}
|
30 |
-
// end of __construct
|
31 |
-
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Returns random number not included into input array
|
35 |
-
*
|
36 |
-
* @param array $used - array of numbers used already
|
37 |
-
*
|
38 |
-
* @return int
|
39 |
-
*/
|
40 |
-
private function rand_unique( $used = array(-1) ) {
|
41 |
-
$index = rand(0, 2);
|
42 |
-
while (in_array($index, $used)) {
|
43 |
-
$index = rand(0, 2);
|
44 |
-
}
|
45 |
-
|
46 |
-
return $index;
|
47 |
-
}
|
48 |
-
// return rand_unique()
|
49 |
-
|
50 |
-
|
51 |
-
// content of Admin Menu Editor advertisement slot
|
52 |
-
private function admin_menu_editor() {
|
53 |
-
|
54 |
-
$output = '
|
55 |
-
<div style="text-align: center;">
|
56 |
-
<a href="http://w-shadow.com/admin-menu-editor-pro/?utm_source=UserRoleEditor&utm_medium=banner&utm_campaign=Plugins " target="_new" >
|
57 |
-
<img src="'. URE_PLUGIN_URL . 'images/admin-menu-editor-pro.jpg' .'" alt="Admin Menu Editor Pro" title="Move, rename, hide, add admin menu items, restrict access"/>
|
58 |
-
</a>
|
59 |
-
</div>
|
60 |
-
';
|
61 |
-
|
62 |
-
return $output;
|
63 |
-
}
|
64 |
-
// end of admin_menu_editor()
|
65 |
-
|
66 |
-
|
67 |
-
// content of Manage WP advertisement slot
|
68 |
-
private function manage_wp() {
|
69 |
-
|
70 |
-
$output = '
|
71 |
-
<div style="text-align: center;">
|
72 |
-
<a title="ManageWP" href="http://managewp.com/?utm_source=user_role_editor&utm_medium=Banner&utm_content=mwp250_2&utm_campaign=Plugins" target="_new" >
|
73 |
-
<img width="250" height="250" alt="ManageWP" src="'. URE_PLUGIN_URL .'images/mwp250_2.png">
|
74 |
-
</a>
|
75 |
-
</div>
|
76 |
-
';
|
77 |
-
|
78 |
-
return $output;
|
79 |
-
}
|
80 |
-
// end of manage_wp()
|
81 |
-
|
82 |
-
|
83 |
-
// content of Video User Manuals advertisement slot
|
84 |
-
private function video_user_manuals() {
|
85 |
-
|
86 |
-
ob_start();
|
87 |
-
?>
|
88 |
-
<div style="margin-left: 3px; margin-bottom: 3px; text-align: center; background: url(<?php echo URE_PLUGIN_URL . 'images/vum-ebook-250-250.jpg'; ?>) left top no-repeat;">
|
89 |
-
<div style="width: 250px; height: 250px; position: relative; ">
|
90 |
-
<form accept-charset="utf-8" action="https://app.getresponse.com/add_contact_webform.html" method="post" onsubmit="return quickValidate()" target="_blank">
|
91 |
-
<div style="display: none;">
|
92 |
-
<input type="hidden" name="webform_id" value="430680" />
|
93 |
-
</div>
|
94 |
-
<input id="vum_sub_name" type="text" name="name" class="text" tabindex="500" value="Enter your name" style="border: 0; position: absolute; left:129px;top:91px;height: 18px; width: 90px;background-color: #fff; font-size: 11px;" onfocus="this.value='';" />
|
95 |
-
<input class="text" id="vum_sub_email" type="text" name="email" tabindex="501" value="Email" style="border: 0; position: absolute; left:129px;top:126px;height: 18px; width: 90px;background-color: #fff; font-size: 11px;" onfocus="this.value='';" />
|
96 |
-
<input name="submit" type="image" alt="submit" tabindex="502" src="<?php echo URE_PLUGIN_URL; ?>images/vum-submit.jpg" width="100" height="25" style="background: none; border: 0;position: absolute; left:121px;top:154px;" />
|
97 |
-
<a href="http://www.videousermanuals.com/blog/report/?utm_campaign=plugin-ads&utm_medium=plugin&utm_source=user-role-editor" target="_blank" style="position: absolute; left: 7px;top: 63px;width:102px;height:152px;border:0;text-decoration: none;"> </a>
|
98 |
-
<a href="http://www.videousermanuals.com/blog/report/?utm_campaign=plugin-ads&utm_medium=plugin&utm_source=user-role-editor" target="_blank" style="position: absolute; left: 41px;top: 219px;width:163px;height:25px;border:0;text-decoration: none;"> </a>
|
99 |
-
</form>
|
100 |
-
</div>
|
101 |
-
<script type="text/javascript">
|
102 |
-
function quickValidate() {
|
103 |
-
if ((!jQuery('#vum_sub_name').val()) || (jQuery('#vum_sub_name').val() == 'Enter your name') )
|
104 |
-
{
|
105 |
-
alert('Your Name is required');
|
106 |
-
return false;
|
107 |
-
}
|
108 |
-
if ((!jQuery('#vum_sub_email').val()) || (jQuery('#vum_sub_email').val() == 'Email') )
|
109 |
-
{
|
110 |
-
alert('Your Email is required');
|
111 |
-
return false;
|
112 |
-
}
|
113 |
-
return true;
|
114 |
-
}
|
115 |
-
</script>
|
116 |
-
|
117 |
-
</div>
|
118 |
-
<?php
|
119 |
-
$output = ob_get_contents();
|
120 |
-
ob_end_clean();
|
121 |
-
|
122 |
-
return $output;
|
123 |
-
}
|
124 |
-
// end of manage_wp()
|
125 |
-
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Output all existed ads slots
|
129 |
-
*/
|
130 |
-
public function display() {
|
131 |
-
|
132 |
-
foreach ($this->slots as $slot) {
|
133 |
-
echo $slot."\n";
|
134 |
-
}
|
135 |
-
|
136 |
-
}
|
137 |
-
// end of display()
|
138 |
-
|
139 |
-
}
|
140 |
-
// end of ure_Advertisement
|
141 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/ure-lib.php
DELETED
@@ -1,1323 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* * User Role Editor plugin Library for general staff
|
4 |
-
* Author: Vladimir Garagulya vladimir@shinephp.com
|
5 |
-
*
|
6 |
-
*/
|
7 |
-
|
8 |
-
|
9 |
-
if (!function_exists("get_option")) {
|
10 |
-
die; // Silence is golden, direct call is prohibited
|
11 |
-
}
|
12 |
-
|
13 |
-
$ure_roles = false; $ure_capabilitiesToSave = false;
|
14 |
-
$ure_currentRole = false; $ure_currentRoleName = false;
|
15 |
-
$ure_toldAboutBackup = false; $ure_apply_to_all = false;
|
16 |
-
$ure_userToEdit = false; $ure_fullCapabilities = false;
|
17 |
-
$ure_show_deprecated_caps = false; $ure_caps_readable = false;
|
18 |
-
|
19 |
-
// this array will be used to cashe users checked for Administrator role
|
20 |
-
$ure_userToCheck = array();
|
21 |
-
|
22 |
-
function ure_logEvent($message, $showMessage = false) {
|
23 |
-
include(ABSPATH .'wp-includes/version.php');
|
24 |
-
|
25 |
-
$fileName = URE_PLUGIN_DIR.'/user-role-editor.log';
|
26 |
-
$fh = fopen($fileName,'a');
|
27 |
-
$cr = "\n";
|
28 |
-
$s = $cr.date("d-m-Y H:i:s").$cr.
|
29 |
-
'WordPress version: '.$wp_version.', PHP version: '.phpversion().', MySQL version: '.mysql_get_server_info().$cr;
|
30 |
-
fwrite($fh, $s);
|
31 |
-
fwrite($fh, $message.$cr);
|
32 |
-
fclose($fh);
|
33 |
-
|
34 |
-
if ($showMessage) {
|
35 |
-
ure_showMessage('Error! '.__('Error is occur. Please check the log file.', 'ure'));
|
36 |
-
}
|
37 |
-
}
|
38 |
-
// end of ure_logEvent()
|
39 |
-
|
40 |
-
|
41 |
-
// returns true is user has Role "Administrator"
|
42 |
-
function ure_has_administrator_role($user_id) {
|
43 |
-
global $wpdb, $ure_userToCheck;
|
44 |
-
|
45 |
-
if (empty($user_id) || !is_numeric($user_id)) {
|
46 |
-
return false;
|
47 |
-
}
|
48 |
-
|
49 |
-
$tableName = (!is_multisite() && defined('CUSTOM_USER_META_TABLE')) ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
|
50 |
-
$metaKey = $wpdb->prefix.'capabilities';
|
51 |
-
$query = "SELECT count(*)
|
52 |
-
FROM $tableName
|
53 |
-
WHERE user_id=$user_id AND meta_key='$metaKey' AND meta_value like '%administrator%'";
|
54 |
-
$hasAdminRole = $wpdb->get_var($query);
|
55 |
-
if ($hasAdminRole>0) {
|
56 |
-
$result = true;
|
57 |
-
} else {
|
58 |
-
$result = false;
|
59 |
-
}
|
60 |
-
$ure_userToCheck[$user_id] = $result;
|
61 |
-
|
62 |
-
return $result;
|
63 |
-
}
|
64 |
-
// end of ure_has_administrator_role()
|
65 |
-
|
66 |
-
|
67 |
-
// true if user is superadmin under multi-site environment or has administrator role
|
68 |
-
function ure_is_admin( $user_id = false ) {
|
69 |
-
global $current_user;
|
70 |
-
|
71 |
-
if ( ! $user_id ) {
|
72 |
-
if (empty($current_user) && function_exists('get_currentuserinfo')) {
|
73 |
-
get_currentuserinfo();
|
74 |
-
}
|
75 |
-
$user_id = ! empty($current_user) ? $current_user->ID : 0;
|
76 |
-
}
|
77 |
-
|
78 |
-
if ( ! $user_id )
|
79 |
-
return false;
|
80 |
-
|
81 |
-
$user = new WP_User($user_id);
|
82 |
-
|
83 |
-
$simpleAdmin = ure_has_administrator_role($user_id);
|
84 |
-
|
85 |
-
if ( is_multisite() ) {
|
86 |
-
$super_admins = get_super_admins();
|
87 |
-
$superAdmin = is_array( $super_admins ) && in_array( $user->user_login, $super_admins );
|
88 |
-
} else {
|
89 |
-
$superAdmin = false;
|
90 |
-
}
|
91 |
-
|
92 |
-
return $simpleAdmin || $superAdmin;
|
93 |
-
}
|
94 |
-
// end of ure_is_super_admin()
|
95 |
-
|
96 |
-
|
97 |
-
function ure_optionSelected($value, $etalon) {
|
98 |
-
$selected = '';
|
99 |
-
if (strcasecmp($value,$etalon)==0) {
|
100 |
-
$selected = 'selected="selected"';
|
101 |
-
}
|
102 |
-
|
103 |
-
return $selected;
|
104 |
-
}
|
105 |
-
// end of ure_optionSelected()
|
106 |
-
|
107 |
-
|
108 |
-
function ure_showMessage($message) {
|
109 |
-
|
110 |
-
if ($message) {
|
111 |
-
if (strpos(strtolower($message), 'error')===false) {
|
112 |
-
$class = 'updated fade';
|
113 |
-
} else {
|
114 |
-
$class = 'error';
|
115 |
-
}
|
116 |
-
echo '<div class="'.$class.'" style="margin:0;">'.$message.'</div><br style="clear: both;"/>';
|
117 |
-
}
|
118 |
-
|
119 |
-
}
|
120 |
-
// end of ure_showMessage()
|
121 |
-
|
122 |
-
|
123 |
-
function ure_getUserRoles() {
|
124 |
-
global $wp_roles, $wpdb;
|
125 |
-
|
126 |
-
if (!isset( $wp_roles ) ) {
|
127 |
-
$wp_roles = new WP_Roles();
|
128 |
-
}
|
129 |
-
|
130 |
-
if (function_exists('bbp_filter_blog_editable_roles') ) { // bbPress plugin is active
|
131 |
-
$ure_roles = bbp_filter_blog_editable_roles( $wp_roles->roles ); // exclude bbPress roles
|
132 |
-
$bbp_full_caps = bbp_get_caps_for_role( bbp_get_keymaster_role() );
|
133 |
-
// exclude capabilities automatically added by bbPress bbp_dynamic_role_caps() and not bbPress related: read, level_0, all s2Member levels, e.g. access_s2member_level_0, etc.
|
134 |
-
$built_in_wp_caps = ure_getBuiltInWPCaps();
|
135 |
-
$bbp_only_caps = array();
|
136 |
-
foreach ($bbp_full_caps as $bbp_cap=>$val) {
|
137 |
-
if (isset( $built_in_wp_caps[ $bbp_cap ] ) || substr($bbp_cap, 0, 15)=='access_s2member' ) {
|
138 |
-
continue;
|
139 |
-
}
|
140 |
-
$bbp_only_caps[$bbp_cap] = $val;
|
141 |
-
}
|
142 |
-
// remove bbPress dynamically created capabilities from WordPress persistent roles in order to not save them to database with any role update
|
143 |
-
$cap_removed = false;
|
144 |
-
foreach ($bbp_only_caps as $bbp_cap=>$val) {
|
145 |
-
foreach ($ure_roles as &$role) {
|
146 |
-
if (isset($role['capabilities'][$bbp_cap])) {
|
147 |
-
unset($role['capabilities'][$bbp_cap]);
|
148 |
-
$cap_removed = true;
|
149 |
-
}
|
150 |
-
}
|
151 |
-
}
|
152 |
-
/*
|
153 |
-
if ($cap_removed) {
|
154 |
-
// save changes to database
|
155 |
-
$option_name = $wpdb->prefix.'user_roles';
|
156 |
-
update_option($option_name, $ure_roles);
|
157 |
-
}
|
158 |
-
*/
|
159 |
-
} else {
|
160 |
-
$ure_roles = $wp_roles->roles;
|
161 |
-
}
|
162 |
-
|
163 |
-
if ( is_array( $ure_roles ) && count( $ure_roles ) > 0 ) {
|
164 |
-
asort( $ure_roles );
|
165 |
-
}
|
166 |
-
|
167 |
-
return $ure_roles;
|
168 |
-
}
|
169 |
-
// end of ure_getUserRoles()
|
170 |
-
|
171 |
-
|
172 |
-
/**
|
173 |
-
* deactivate all active plugins
|
174 |
-
*
|
175 |
-
* return array $plugins - active plugins which were deactivated
|
176 |
-
*/
|
177 |
-
function ure_deactivate_plugins() {
|
178 |
-
|
179 |
-
$plugins = get_option( 'active_plugins', array() );
|
180 |
-
$active_plugins = array();
|
181 |
-
foreach ($plugins as $plugin) {
|
182 |
-
if ( is_plugin_active($plugin) ) {
|
183 |
-
//Deactivate the plugin silently, Prevent deactivation hooks from running.
|
184 |
-
deactivate_plugins($plugin, true);
|
185 |
-
$active_plugins[] = $plugin;
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
return $active_plugins;
|
190 |
-
|
191 |
-
}
|
192 |
-
// end of ure_deactivate_plugins()
|
193 |
-
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Go through all users and if user has non-existing role lower him to Subscriber role
|
197 |
-
*
|
198 |
-
*/
|
199 |
-
function ure_validate_user_roles() {
|
200 |
-
|
201 |
-
global $wp_roles, $ure_fullCapabilities;
|
202 |
-
|
203 |
-
$default_role = get_option('default_role');
|
204 |
-
if (empty($default_role)) {
|
205 |
-
$default_role = 'subscriber';
|
206 |
-
}
|
207 |
-
$users_query = new WP_User_Query(array('fields' => 'ID'));
|
208 |
-
$users = $users_query->get_results();
|
209 |
-
foreach ($users as $user_id) {
|
210 |
-
$user = get_user_by('id', $user_id);
|
211 |
-
if (is_array($user->roles) && count($user->roles) > 0) {
|
212 |
-
foreach ($user->roles as $role) {
|
213 |
-
$user_role = $role;
|
214 |
-
break;
|
215 |
-
}
|
216 |
-
} else {
|
217 |
-
$user_role = is_array($user->roles) ? '' : $user->roles;
|
218 |
-
}
|
219 |
-
if (!empty($user_role) && !isset($wp_roles->roles[$user_role])) { // role doesn't exists
|
220 |
-
$user->set_role($default_role); // set the lowest level role for this user
|
221 |
-
$user_role = '';
|
222 |
-
}
|
223 |
-
|
224 |
-
if (empty($user_role)) {
|
225 |
-
// Cleanup users level capabilities from non-existed roles
|
226 |
-
$cap_removed = true;
|
227 |
-
while (count($user->caps) > 0 && $cap_removed) {
|
228 |
-
foreach ($user->caps as $capability => $value) {
|
229 |
-
if (!isset($ure_fullCapabilities[$capability])) {
|
230 |
-
$user->remove_cap( $capability );
|
231 |
-
$cap_removed = true;
|
232 |
-
break;
|
233 |
-
}
|
234 |
-
$cap_removed = false;
|
235 |
-
}
|
236 |
-
} // while ()
|
237 |
-
}
|
238 |
-
|
239 |
-
} // foreach()
|
240 |
-
|
241 |
-
}
|
242 |
-
// end of ure_validate_user_roles()
|
243 |
-
|
244 |
-
|
245 |
-
/**
|
246 |
-
* reset user roles to WordPress default roles
|
247 |
-
*/
|
248 |
-
function ure_reset_user_roles() {
|
249 |
-
global $wp_roles;
|
250 |
-
|
251 |
-
//$active_plugins = ure_deactivate_plugins(); // deactivate all plugins
|
252 |
-
|
253 |
-
$wp_roles->roles = array();
|
254 |
-
$wp_roles->role_objects = array();
|
255 |
-
$wp_roles->role_names = array();
|
256 |
-
$wp_roles->use_db = true;
|
257 |
-
|
258 |
-
require_once(ABSPATH . '/wp-admin/includes/schema.php');
|
259 |
-
populate_roles();
|
260 |
-
$wp_roles->reinit();
|
261 |
-
|
262 |
-
|
263 |
-
$reload_link = wp_get_referer();
|
264 |
-
$reload_link = remove_query_arg('action', $reload_link);
|
265 |
-
$reload_link = add_query_arg('action', 'roles_restore_note', $reload_link);
|
266 |
-
|
267 |
-
/*
|
268 |
-
// return recently deactivated plugins to its original state
|
269 |
-
if ( is_array( $active_plugins ) && count( $active_plugins ) > 0 ) {
|
270 |
-
activate_plugins( $active_plugins, $reload_link);
|
271 |
-
}
|
272 |
-
//ure_validate_user_roles(); // if user has non-existing role lower him to Subscriber role
|
273 |
-
*/
|
274 |
-
|
275 |
-
?>
|
276 |
-
<script type="text/javascript" >
|
277 |
-
document.location = '<?php echo $reload_link; ?>';
|
278 |
-
</script>
|
279 |
-
<?php
|
280 |
-
|
281 |
-
return '';
|
282 |
-
|
283 |
-
}
|
284 |
-
// end of ure_reset_user_roles()
|
285 |
-
|
286 |
-
|
287 |
-
/*
|
288 |
-
// restores User Roles from the backup record
|
289 |
-
function ure_restore_user_roles() {
|
290 |
-
|
291 |
-
global $wpdb, $wp_roles;
|
292 |
-
|
293 |
-
$errorMessage = 'Error! '.__('Database operation error. Check log file.', 'ure');
|
294 |
-
$option_name = $wpdb->prefix.'user_roles';
|
295 |
-
$backup_option_name = $wpdb->prefix.'backup_user_roles';
|
296 |
-
$query = "select option_value
|
297 |
-
from $wpdb->options
|
298 |
-
where option_name='$backup_option_name'
|
299 |
-
limit 0, 1";
|
300 |
-
$option_value = $wpdb->get_var($query);
|
301 |
-
if ($wpdb->last_error) {
|
302 |
-
ure_logEvent($wpdb->last_error, true);
|
303 |
-
return $errorMessage;
|
304 |
-
}
|
305 |
-
if ($option_value) {
|
306 |
-
$query = "update $wpdb->options
|
307 |
-
set option_value='$option_value'
|
308 |
-
where option_name='$option_name'
|
309 |
-
limit 1";
|
310 |
-
$record = $wpdb->query($query);
|
311 |
-
if ($wpdb->last_error) {
|
312 |
-
ure_logEvent($wpdb->last_error, true);
|
313 |
-
return $errorMessage;
|
314 |
-
}
|
315 |
-
$wp_roles = new WP_Roles();
|
316 |
-
$reload_link = wp_get_referer();
|
317 |
-
$reload_link = remove_query_arg('action', $reload_link);
|
318 |
-
$reload_link = add_query_arg('action', 'roles_restore_note', $reload_link);
|
319 |
-
?>
|
320 |
-
<script type="text/javascript" >
|
321 |
-
document.location = '<?php echo $reload_link; ?>';
|
322 |
-
</script>
|
323 |
-
<?php
|
324 |
-
$mess = '';
|
325 |
-
} else {
|
326 |
-
$mess = __('No backup data. It is created automatically before the first role data update.', 'ure');
|
327 |
-
}
|
328 |
-
if (isset($_REQUEST['user_role'])) {
|
329 |
-
unset($_REQUEST['user_role']);
|
330 |
-
}
|
331 |
-
|
332 |
-
return $mess;
|
333 |
-
}
|
334 |
-
// end of ure_restore_user_roles()
|
335 |
-
*/
|
336 |
-
|
337 |
-
function ure_makeRolesBackup() {
|
338 |
-
global $wpdb, $mess, $ure_roles, $ure_toldAboutBackup;
|
339 |
-
|
340 |
-
// check if backup user roles record exists already
|
341 |
-
$backup_option_name = $wpdb->prefix.'backup_user_roles';
|
342 |
-
$query = "select option_id
|
343 |
-
from $wpdb->options
|
344 |
-
where option_name='$backup_option_name'
|
345 |
-
limit 0, 1";
|
346 |
-
$option_id = $wpdb->get_var($query);
|
347 |
-
if ($wpdb->last_error) {
|
348 |
-
ure_logEvent($wpdb->last_error, true);
|
349 |
-
return false;
|
350 |
-
}
|
351 |
-
if (!$option_id) {
|
352 |
-
// create user roles record backup
|
353 |
-
$serialized_roles = mysql_real_escape_string(serialize($ure_roles));
|
354 |
-
$query = "insert into $wpdb->options
|
355 |
-
(option_name, option_value, autoload)
|
356 |
-
values ('$backup_option_name', '$serialized_roles', 'yes')";
|
357 |
-
$record = $wpdb->query($query);
|
358 |
-
if ($wpdb->last_error) {
|
359 |
-
ure_logEvent($wpdb->last_error, true);
|
360 |
-
return false;
|
361 |
-
}
|
362 |
-
if (!$ure_toldAboutBackup) {
|
363 |
-
$ure_toldAboutBackup = true;
|
364 |
-
$mess .= __('Backup record is created for the current role capabilities', 'ure');
|
365 |
-
}
|
366 |
-
}
|
367 |
-
|
368 |
-
return true;
|
369 |
-
}
|
370 |
-
// end of ure_makeRolesBackup()
|
371 |
-
|
372 |
-
|
373 |
-
// Save Roles to database
|
374 |
-
function ure_saveRolesToDb() {
|
375 |
-
global $wpdb, $ure_roles, $ure_capabilitiesToSave, $ure_currentRole;
|
376 |
-
|
377 |
-
if (!isset($ure_roles[$ure_currentRole])) {
|
378 |
-
return false;
|
379 |
-
}
|
380 |
-
$ure_roles[$ure_currentRole]['capabilities'] = $ure_capabilitiesToSave;
|
381 |
-
$option_name = $wpdb->prefix.'user_roles';
|
382 |
-
|
383 |
-
$result = update_option($option_name, $ure_roles);
|
384 |
-
|
385 |
-
return $result;
|
386 |
-
}
|
387 |
-
// end of saveRolesToDb()
|
388 |
-
|
389 |
-
|
390 |
-
function ure_direct_site_roles_update($blogIds) {
|
391 |
-
global $wpdb, $table_prefix, $ure_roles, $ure_capabilitiesToSave, $ure_currentRole, $ure_currentRoleName;
|
392 |
-
|
393 |
-
if (!isset($ure_roles[$ure_currentRole])) {
|
394 |
-
$ure_roles[$ure_currentRole]['name'] = $ure_currentRoleName;
|
395 |
-
}
|
396 |
-
$ure_roles[$ure_currentRole]['capabilities'] = $ure_capabilitiesToSave;
|
397 |
-
$serialized_roles = serialize($ure_roles);
|
398 |
-
foreach ($blogIds as $blog_id) {
|
399 |
-
$prefix = $wpdb->get_blog_prefix($blog_id);
|
400 |
-
$options_table_name = $prefix.'options';
|
401 |
-
$option_name = $prefix.'user_roles';
|
402 |
-
$query = "update $options_table_name
|
403 |
-
set option_value='$serialized_roles'
|
404 |
-
where option_name='$option_name'
|
405 |
-
limit 1";
|
406 |
-
$record = $wpdb->query($query);
|
407 |
-
if ($wpdb->last_error) {
|
408 |
-
ure_logEvent($wpdb->last_error, true);
|
409 |
-
return false;
|
410 |
-
}
|
411 |
-
if ($record==0) {
|
412 |
-
return false;
|
413 |
-
}
|
414 |
-
}
|
415 |
-
|
416 |
-
}
|
417 |
-
// end of ure_direct_site_roles_update()
|
418 |
-
|
419 |
-
|
420 |
-
function ure_updateRoles() {
|
421 |
-
global $wpdb, $ure_apply_to_all, $ure_roles, $ure_toldAboutBackup, $ure_currentRole, $ure_currentRoleName;
|
422 |
-
|
423 |
-
$ure_toldAboutBackup = false;
|
424 |
-
if (is_multisite() && is_super_admin() && $ure_apply_to_all) { // update Role for the all blogs/sites in the network (permitted to superadmin only)
|
425 |
-
|
426 |
-
if (defined('URE_DEBUG') && URE_DEBUG) {
|
427 |
-
$time_shot = microtime();
|
428 |
-
}
|
429 |
-
|
430 |
-
$old_blog = $wpdb->blogid;
|
431 |
-
// Get all blog ids
|
432 |
-
$blogIds = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
|
433 |
-
if (defined('URE_MULTISITE_DIRECT_UPDATE') && URE_MULTISITE_DIRECT_UPDATE == 1) {
|
434 |
-
ure_direct_site_roles_update($blogIds);
|
435 |
-
} else {
|
436 |
-
foreach ($blogIds as $blog_id) {
|
437 |
-
switch_to_blog($blog_id);
|
438 |
-
$ure_roles = ure_getUserRoles();
|
439 |
-
if (!$ure_roles) {
|
440 |
-
echo '<div class="error fade below-h2">'.URE_ERROR.'</div>';
|
441 |
-
switch_to_blog($old_blog);
|
442 |
-
$ure_roles = ure_getUserRoles();
|
443 |
-
return false;
|
444 |
-
}
|
445 |
-
if (!isset($ure_roles[$ure_currentRole])) { // add new role to this blog
|
446 |
-
$ure_roles[$ure_currentRole] = array( 'name' => $ure_currentRoleName, 'capabilities' => array('read'=>1) );
|
447 |
-
}
|
448 |
-
ure_saveRolesToDb();
|
449 |
-
}
|
450 |
-
switch_to_blog($old_blog);
|
451 |
-
$ure_roles = ure_getUserRoles();
|
452 |
-
}
|
453 |
-
|
454 |
-
if (defined('URE_DEBUG') && URE_DEBUG) {
|
455 |
-
echo '<div class="updated fade below-h2">Roles updated for '.( microtime() - $time_shot ).' milliseconds</div>';
|
456 |
-
}
|
457 |
-
|
458 |
-
} else {
|
459 |
-
if (!ure_saveRolesToDb()) {
|
460 |
-
return false;
|
461 |
-
}
|
462 |
-
}
|
463 |
-
|
464 |
-
return true;
|
465 |
-
}
|
466 |
-
// end of ure_updateRoles()
|
467 |
-
|
468 |
-
|
469 |
-
// process new role create request
|
470 |
-
function ure_newRoleCreate(&$ure_currentRole) {
|
471 |
-
|
472 |
-
global $wp_roles;
|
473 |
-
|
474 |
-
$mess = '';
|
475 |
-
$ure_currentRole = '';
|
476 |
-
if (isset($_POST['user_role_id']) && $_POST['user_role_id']) {
|
477 |
-
$user_role_id = utf8_decode($_POST['user_role_id']);
|
478 |
-
// sanitize user input for security
|
479 |
-
$valid_name = preg_match('/[A-Za-z0-9_\-]*/', $user_role_id, $match);
|
480 |
-
if (!$valid_name || ($valid_name && ($match[0]!=$user_role_id))) { // some non-alphanumeric charactes found!
|
481 |
-
return __('Error: Role ID must contain latin characters, digits, hyphens or underscore only!', 'ure');
|
482 |
-
}
|
483 |
-
|
484 |
-
if ($user_role_id) {
|
485 |
-
$user_role_name = isset( $_POST['user_role_name']) ? $_POST['user_role_name'] : false;
|
486 |
-
if (!empty($user_role_name)) {
|
487 |
-
$user_role_name = sanitize_text_field( $user_role_name );
|
488 |
-
} else {
|
489 |
-
$user_role_name = $user_role_id; // as user role name is empty, use user role ID instead
|
490 |
-
}
|
491 |
-
|
492 |
-
if (!isset($wp_roles)) {
|
493 |
-
$wp_roles = new WP_Roles();
|
494 |
-
}
|
495 |
-
if ( isset( $wp_roles->roles[ $user_role_id ] ) ) {
|
496 |
-
return sprintf( 'Error! '.__('Role %s exists already', 'ure'), $user_role_id );
|
497 |
-
}
|
498 |
-
$user_role_id = strtolower($user_role_id);
|
499 |
-
$ure_currentRole = $user_role_id;
|
500 |
-
|
501 |
-
$user_role_copy_from = isset($_POST['user_role_copy_from']) ? $_POST['user_role_copy_from'] : false;
|
502 |
-
if ( !empty($user_role_copy_from) && $user_role_copy_from!='none' && $wp_roles->is_role($user_role_copy_from) ) {
|
503 |
-
$role = $wp_roles->get_role( $user_role_copy_from );
|
504 |
-
$capabilities = $role->capabilities;
|
505 |
-
} else {
|
506 |
-
$capabilities = array('read'=>1, 'level_0'=>1);
|
507 |
-
}
|
508 |
-
// add new role to the roles array
|
509 |
-
$result = add_role($user_role_id, $user_role_name, $capabilities);
|
510 |
-
if ( !isset($result) || empty($result) ) {
|
511 |
-
$mess = 'Error! '.__('Error is encountered during new role create operation', 'ure');
|
512 |
-
} else {
|
513 |
-
$mess = sprintf(__('Role %s is created successfully', 'ure'), $user_role_name);
|
514 |
-
}
|
515 |
-
}
|
516 |
-
}
|
517 |
-
return $mess;
|
518 |
-
}
|
519 |
-
// end of newRoleCreate()
|
520 |
-
|
521 |
-
|
522 |
-
// define roles which we could delete, e.g self-created and not used with any blog user
|
523 |
-
function ure_getRolesCanDelete($ure_roles) {
|
524 |
-
global $wpdb;
|
525 |
-
|
526 |
-
$tableName = (!is_multisite() && defined('CUSTOM_USER_META_TABLE')) ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
|
527 |
-
$metaKey = $wpdb->prefix.'capabilities';
|
528 |
-
$defaultRole = get_option('default_role');
|
529 |
-
$standardRoles = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
|
530 |
-
$ure_rolesCanDelete = array();
|
531 |
-
foreach ($ure_roles as $key=>$role) {
|
532 |
-
$canDelete = true;
|
533 |
-
// check if it is default role for new users
|
534 |
-
if ($key==$defaultRole) {
|
535 |
-
$canDelete = false;
|
536 |
-
continue;
|
537 |
-
}
|
538 |
-
// check if it is standard role
|
539 |
-
foreach ($standardRoles as $standardRole) {
|
540 |
-
if ($key==$standardRole) {
|
541 |
-
$canDelete = false;
|
542 |
-
break;
|
543 |
-
}
|
544 |
-
}
|
545 |
-
if (!$canDelete) {
|
546 |
-
continue;
|
547 |
-
}
|
548 |
-
// check if user with such role exists
|
549 |
-
$query = "SELECT meta_value
|
550 |
-
FROM $tableName
|
551 |
-
WHERE meta_key='$metaKey' AND meta_value like '%$key%'";
|
552 |
-
$ure_rolesUsed = $wpdb->get_results($query);
|
553 |
-
if ($ure_rolesUsed && count($ure_rolesUsed>0)) {
|
554 |
-
foreach ($ure_rolesUsed as $roleUsed) {
|
555 |
-
$roleName = unserialize($roleUsed->meta_value);
|
556 |
-
foreach ($roleName as $key1=>$value1) {
|
557 |
-
if ($key==$key1) {
|
558 |
-
$canDelete = false;
|
559 |
-
break;
|
560 |
-
}
|
561 |
-
}
|
562 |
-
if (!$canDelete) {
|
563 |
-
break;
|
564 |
-
}
|
565 |
-
}
|
566 |
-
}
|
567 |
-
if ($canDelete) {
|
568 |
-
$ure_rolesCanDelete[$key] = $role['name'] .' ('. $key .')';
|
569 |
-
}
|
570 |
-
}
|
571 |
-
|
572 |
-
return $ure_rolesCanDelete;
|
573 |
-
}
|
574 |
-
// end of getRolesCanDelete()
|
575 |
-
|
576 |
-
|
577 |
-
function ure_deleteRole() {
|
578 |
-
global $wp_roles;
|
579 |
-
|
580 |
-
$mess = '';
|
581 |
-
if (isset($_POST['user_role_id']) && $_POST['user_role_id']) {
|
582 |
-
$role = $_POST['user_role_id'];
|
583 |
-
//$result = remove_role($_POST['user_role']);
|
584 |
-
// use this modified code from remove_role() directly as remove_role() returns nothing to check
|
585 |
-
if (!isset($wp_roles)) {
|
586 |
-
$wp_roles = new WP_Roles();
|
587 |
-
}
|
588 |
-
if (isset($wp_roles->roles[$role])) {
|
589 |
-
unset($wp_roles->role_objects[$role]);
|
590 |
-
unset($wp_roles->role_names[$role]);
|
591 |
-
unset($wp_roles->roles[$role]);
|
592 |
-
$result = update_option($wp_roles->role_key, $wp_roles->roles);
|
593 |
-
} else {
|
594 |
-
$result = false;
|
595 |
-
}
|
596 |
-
if (empty($result)) {
|
597 |
-
$mess = 'Error! '.__('Error encountered during role delete operation', 'ure');
|
598 |
-
} else {
|
599 |
-
$mess = sprintf(__('Role %s is deleted successfully', 'ure'), $role);
|
600 |
-
}
|
601 |
-
unset($_REQUEST['user_role']);
|
602 |
-
}
|
603 |
-
|
604 |
-
return $mess;
|
605 |
-
}
|
606 |
-
// end of ure_deleteRole()
|
607 |
-
|
608 |
-
|
609 |
-
function ure_changeDefaultRole() {
|
610 |
-
global $wp_roles;
|
611 |
-
|
612 |
-
$mess = '';
|
613 |
-
if (!isset($wp_roles)) {
|
614 |
-
$wp_roles = new WP_Roles();
|
615 |
-
}
|
616 |
-
if ( !empty($_POST['user_role_id']) ) {
|
617 |
-
$user_role_id = $_POST['user_role_id'];
|
618 |
-
unset($_POST['user_role_id']);
|
619 |
-
$errorMessage = 'Error! '.__('Error encountered during default role change operation', 'ure');
|
620 |
-
if ( isset($wp_roles->role_objects[$user_role_id]) && $user_role_id!=='administrator') {
|
621 |
-
$result = update_option( 'default_role', $user_role_id );
|
622 |
-
if (empty($result)) {
|
623 |
-
$mess = $errorMessage;
|
624 |
-
} else {
|
625 |
-
$mess = sprintf( __('Default role for new users is set to %s successfully', 'ure'), $wp_roles->role_names[ $user_role_id ] );
|
626 |
-
}
|
627 |
-
} else {
|
628 |
-
$mess = $errorMessage;
|
629 |
-
}
|
630 |
-
}
|
631 |
-
|
632 |
-
return $mess;
|
633 |
-
}
|
634 |
-
// end of ure_changeDefaultRole()
|
635 |
-
|
636 |
-
|
637 |
-
function ure_ConvertCapsToReadable($capsName) {
|
638 |
-
|
639 |
-
$capsName = str_replace('_', ' ', $capsName);
|
640 |
-
$capsName = ucfirst($capsName);
|
641 |
-
|
642 |
-
return $capsName;
|
643 |
-
}
|
644 |
-
// ure_ConvertCapsToReadable
|
645 |
-
|
646 |
-
|
647 |
-
function ure_TranslationData() {
|
648 |
-
|
649 |
-
// for the translation purpose
|
650 |
-
if (false) {
|
651 |
-
// Standard WordPress roles
|
652 |
-
__('Editor', 'ure');
|
653 |
-
__('Author', 'ure');
|
654 |
-
__('Contributor', 'ure');
|
655 |
-
__('Subscriber', 'ure');
|
656 |
-
// Standard WordPress capabilities
|
657 |
-
__('Switch themes', 'ure');
|
658 |
-
__('Edit themes', 'ure');
|
659 |
-
__('Activate plugins', 'ure');
|
660 |
-
__('Edit plugins', 'ure');
|
661 |
-
__('Edit users', 'ure');
|
662 |
-
__('Edit files', 'ure');
|
663 |
-
__('Manage options', 'ure');
|
664 |
-
__('Moderate comments', 'ure');
|
665 |
-
__('Manage categories', 'ure');
|
666 |
-
__('Manage links', 'ure');
|
667 |
-
__('Upload files', 'ure');
|
668 |
-
__('Import', 'ure');
|
669 |
-
__('Unfiltered html', 'ure');
|
670 |
-
__('Edit posts', 'ure');
|
671 |
-
__('Edit others posts', 'ure');
|
672 |
-
__('Edit published posts', 'ure');
|
673 |
-
__('Publish posts', 'ure');
|
674 |
-
__('Edit pages', 'ure');
|
675 |
-
__('Read', 'ure');
|
676 |
-
__('Level 10', 'ure');
|
677 |
-
__('Level 9', 'ure');
|
678 |
-
__('Level 8', 'ure');
|
679 |
-
__('Level 7', 'ure');
|
680 |
-
__('Level 6', 'ure');
|
681 |
-
__('Level 5', 'ure');
|
682 |
-
__('Level 4', 'ure');
|
683 |
-
__('Level 3', 'ure');
|
684 |
-
__('Level 2', 'ure');
|
685 |
-
__('Level 1', 'ure');
|
686 |
-
__('Level 0', 'ure');
|
687 |
-
__('Edit others pages', 'ure');
|
688 |
-
__('Edit published pages', 'ure');
|
689 |
-
__('Publish pages', 'ure');
|
690 |
-
__('Delete pages', 'ure');
|
691 |
-
__('Delete others pages', 'ure');
|
692 |
-
__('Delete published pages', 'ure');
|
693 |
-
__('Delete posts', 'ure');
|
694 |
-
__('Delete others posts', 'ure');
|
695 |
-
__('Delete published posts', 'ure');
|
696 |
-
__('Delete private posts', 'ure');
|
697 |
-
__('Edit private posts', 'ure');
|
698 |
-
__('Read private posts', 'ure');
|
699 |
-
__('Delete private pages', 'ure');
|
700 |
-
__('Edit private pages', 'ure');
|
701 |
-
__('Read private pages', 'ure');
|
702 |
-
__('Delete users', 'ure');
|
703 |
-
__('Create users', 'ure');
|
704 |
-
__('Unfiltered upload', 'ure');
|
705 |
-
__('Edit dashboard', 'ure');
|
706 |
-
__('Update plugins', 'ure');
|
707 |
-
__('Delete plugins', 'ure');
|
708 |
-
__('Install plugins', 'ure');
|
709 |
-
__('Update themes', 'ure');
|
710 |
-
__('Install themes', 'ure');
|
711 |
-
__('Update core', 'ure');
|
712 |
-
__('List users', 'ure');
|
713 |
-
__('Remove users', 'ure');
|
714 |
-
__('Add users', 'ure');
|
715 |
-
__('Promote users', 'ure');
|
716 |
-
__('Edit theme options', 'ure');
|
717 |
-
__('Delete themes', 'ure');
|
718 |
-
__('Export', 'ure');
|
719 |
-
}
|
720 |
-
}
|
721 |
-
// end of ure_TranslationData()
|
722 |
-
|
723 |
-
|
724 |
-
function ure_ArrayUnique($myArray) {
|
725 |
-
if (!is_array($myArray)) {
|
726 |
-
return $myArray;
|
727 |
-
}
|
728 |
-
|
729 |
-
foreach ($myArray as $key=>$value) {
|
730 |
-
$myArray[$key] = serialize($value);
|
731 |
-
}
|
732 |
-
|
733 |
-
$myArray = array_unique($myArray);
|
734 |
-
|
735 |
-
foreach ($myArray as $key=>$value) {
|
736 |
-
$myArray[$key] = unserialize($value);
|
737 |
-
}
|
738 |
-
|
739 |
-
return $myArray;
|
740 |
-
|
741 |
-
}
|
742 |
-
// end of ure_ArrayUnique()
|
743 |
-
|
744 |
-
|
745 |
-
// sort 2 dimensional array by column of its sub-array
|
746 |
-
class ure_TableSorter {
|
747 |
-
protected $column;
|
748 |
-
|
749 |
-
function __construct($column) {
|
750 |
-
$this->column = $column;
|
751 |
-
}
|
752 |
-
|
753 |
-
function sort($table) {
|
754 |
-
usort($table, array($this, 'compare'));
|
755 |
-
|
756 |
-
return $table;
|
757 |
-
}
|
758 |
-
|
759 |
-
function compare($a, $b) {
|
760 |
-
if ($a[$this->column] == $b[$this->column]) {
|
761 |
-
return 0;
|
762 |
-
}
|
763 |
-
|
764 |
-
return ($a[$this->column] < $b[$this->column]) ? -1 : 1;
|
765 |
-
}
|
766 |
-
}
|
767 |
-
// enf of ure_CapsSorter()
|
768 |
-
|
769 |
-
|
770 |
-
function ure_updateUser($user) {
|
771 |
-
global $wp_roles, $ure_capabilitiesToSave, $ure_roles;
|
772 |
-
|
773 |
-
$primary_role = array_shift(array_values($user->roles)); // get 1st element from roles array as user primary role
|
774 |
-
if (empty($primary_role) || !isset($ure_roles[$primary_role])) {
|
775 |
-
$primary_role = '';
|
776 |
-
}
|
777 |
-
if (function_exists('bbp_filter_blog_editable_roles') ) { // bbPress plugin is active
|
778 |
-
$bbp_user_role = bbp_get_user_role($user->ID);
|
779 |
-
} else {
|
780 |
-
$bbp_user_role = '';
|
781 |
-
}
|
782 |
-
|
783 |
-
// revoke all roles and capabilities from this user
|
784 |
-
$user->roles = array();
|
785 |
-
$user->remove_all_caps();
|
786 |
-
|
787 |
-
// restore primary role
|
788 |
-
if (!empty($primary_role)) {
|
789 |
-
$user->add_role($primary_role);
|
790 |
-
}
|
791 |
-
|
792 |
-
// restore bbPress user role if she had one
|
793 |
-
if (!empty($bbp_user_role)) {
|
794 |
-
$user->add_role($bbp_user_role);
|
795 |
-
}
|
796 |
-
|
797 |
-
// add other roles to user
|
798 |
-
foreach( $_POST as $key=>$value ) {
|
799 |
-
$result = preg_match( '/^wp_role_(.+)/', $key, $match);
|
800 |
-
if ($result === 1 ) {
|
801 |
-
$role = $match[ 1 ];
|
802 |
-
if ( isset( $wp_roles->roles[ $role ] ) ) {
|
803 |
-
$user->add_role($role);
|
804 |
-
}
|
805 |
-
}
|
806 |
-
}
|
807 |
-
|
808 |
-
// add individual capabilities to user
|
809 |
-
if ( count( $ure_capabilitiesToSave ) > 0 ) {
|
810 |
-
foreach ( $ure_capabilitiesToSave as $key=>$value ) {
|
811 |
-
foreach( $user->roles as $role_id=>$role) {
|
812 |
-
if ( empty( $role['capabilities'][$key] ) ) {
|
813 |
-
$user->add_cap($key);
|
814 |
-
}
|
815 |
-
}
|
816 |
-
}
|
817 |
-
}
|
818 |
-
$user->update_user_level_from_caps();
|
819 |
-
|
820 |
-
return true;
|
821 |
-
}
|
822 |
-
// end of ure_updateUser()
|
823 |
-
|
824 |
-
|
825 |
-
function ure_AddNewCapability() {
|
826 |
-
global $wp_roles;
|
827 |
-
|
828 |
-
$mess = '';
|
829 |
-
if (isset($_POST['capability_id']) && $_POST['capability_id']) {
|
830 |
-
$user_capability = $_POST['capability_id'];
|
831 |
-
// sanitize user input for security
|
832 |
-
$valid_name = preg_match('/[A-Za-z0-9_\-]*/', $user_capability, $match);
|
833 |
-
if (!$valid_name || ($valid_name && ($match[0]!=$user_capability))) { // some non-alphanumeric charactes found!
|
834 |
-
return 'Error! '.__('Error: Capability name must contain latin characters and digits only!', 'ure');;
|
835 |
-
}
|
836 |
-
|
837 |
-
if ($user_capability) {
|
838 |
-
$user_capability = strtolower($user_capability);
|
839 |
-
if (!isset($wp_roles)) {
|
840 |
-
$wp_roles = new WP_Roles();
|
841 |
-
}
|
842 |
-
$wp_roles->use_db = true;
|
843 |
-
$administrator = $wp_roles->get_role('administrator');
|
844 |
-
if (!$administrator->has_cap($user_capability)) {
|
845 |
-
$wp_roles->add_cap('administrator', $user_capability);
|
846 |
-
$mess = sprintf(__('Capability %s is added successfully', 'ure'), $user_capability);
|
847 |
-
} else {
|
848 |
-
$mess = sprintf('Error! '.__('Capability %s exists already', 'ure'), $user_capability);
|
849 |
-
}
|
850 |
-
}
|
851 |
-
}
|
852 |
-
|
853 |
-
return $mess;
|
854 |
-
|
855 |
-
}
|
856 |
-
// end of ure_AddNewCapability
|
857 |
-
|
858 |
-
|
859 |
-
// returns array of built-in WP capabilities (WP 3.1 wp-admin/includes/schema.php)
|
860 |
-
function ure_getBuiltInWPCaps() {
|
861 |
-
$caps = array();
|
862 |
-
$caps['switch_themes'] = 1;
|
863 |
-
$caps['edit_themes'] = 1;
|
864 |
-
$caps['activate_plugins'] = 1;
|
865 |
-
$caps['edit_plugins'] = 1;
|
866 |
-
$caps['edit_users'] = 1;
|
867 |
-
$caps['edit_files'] = 1;
|
868 |
-
$caps['manage_options'] = 1;
|
869 |
-
$caps['moderate_comments'] = 1;
|
870 |
-
$caps['manage_categories'] = 1;
|
871 |
-
$caps['manage_links'] = 1;
|
872 |
-
$caps['upload_files'] = 1;
|
873 |
-
$caps['import'] = 1;
|
874 |
-
$caps['unfiltered_html'] = 1;
|
875 |
-
$caps['edit_posts'] = 1;
|
876 |
-
$caps['edit_others_posts'] = 1;
|
877 |
-
$caps['edit_published_posts'] = 1;
|
878 |
-
$caps['publish_posts'] = 1;
|
879 |
-
$caps['edit_pages'] = 1;
|
880 |
-
$caps['read'] = 1;
|
881 |
-
$caps['level_10'] = 1;
|
882 |
-
$caps['level_9'] = 1;
|
883 |
-
$caps['level_8'] = 1;
|
884 |
-
$caps['level_7'] = 1;
|
885 |
-
$caps['level_6'] = 1;
|
886 |
-
$caps['level_5'] = 1;
|
887 |
-
$caps['level_4'] = 1;
|
888 |
-
$caps['level_3'] = 1;
|
889 |
-
$caps['level_2'] = 1;
|
890 |
-
$caps['level_1'] = 1;
|
891 |
-
$caps['level_0'] = 1;
|
892 |
-
$caps['edit_others_pages'] = 1;
|
893 |
-
$caps['edit_published_pages'] = 1;
|
894 |
-
$caps['publish_pages'] = 1;
|
895 |
-
$caps['delete_pages'] = 1;
|
896 |
-
$caps['delete_others_pages'] = 1;
|
897 |
-
$caps['delete_published_pages'] = 1;
|
898 |
-
$caps['delete_posts'] = 1;
|
899 |
-
$caps['delete_others_posts'] = 1;
|
900 |
-
$caps['delete_published_posts'] = 1;
|
901 |
-
$caps['delete_private_posts'] = 1;
|
902 |
-
$caps['edit_private_posts'] = 1;
|
903 |
-
$caps['read_private_posts'] = 1;
|
904 |
-
$caps['delete_private_pages'] = 1;
|
905 |
-
$caps['edit_private_pages'] = 1;
|
906 |
-
$caps['read_private_pages'] = 1;
|
907 |
-
$caps['unfiltered_upload'] = 1;
|
908 |
-
$caps['edit_dashboard'] = 1;
|
909 |
-
$caps['update_plugins'] = 1;
|
910 |
-
$caps['delete_plugins'] = 1;
|
911 |
-
$caps['install_plugins'] = 1;
|
912 |
-
$caps['update_themes'] = 1;
|
913 |
-
$caps['install_themes'] = 1;
|
914 |
-
$caps['update_core'] = 1;
|
915 |
-
$caps['list_users'] = 1;
|
916 |
-
$caps['remove_users'] = 1;
|
917 |
-
$caps['add_users'] = 1;
|
918 |
-
$caps['promote_users'] = 1;
|
919 |
-
$caps['edit_theme_options'] = 1;
|
920 |
-
$caps['delete_themes'] = 1;
|
921 |
-
$caps['export'] = 1;
|
922 |
-
$caps['delete_users'] = 1;
|
923 |
-
$caps['create_users'] = 1;
|
924 |
-
|
925 |
-
return $caps;
|
926 |
-
}
|
927 |
-
//
|
928 |
-
|
929 |
-
// return the array of unused capabilities
|
930 |
-
function ure_getCapsToRemove() {
|
931 |
-
global $wp_roles, $wpdb;
|
932 |
-
|
933 |
-
// build full capabilities list from all roles except Administrator
|
934 |
-
$fullCapsList = array();
|
935 |
-
foreach($wp_roles->roles as $role) {
|
936 |
-
// validate if capabilities is an array
|
937 |
-
if (isset($role['capabilities']) && is_array($role['capabilities'])) {
|
938 |
-
foreach ($role['capabilities'] as $capability=>$value) {
|
939 |
-
if (!isset($fullCapsList[$capability])) {
|
940 |
-
$fullCapsList[$capability] = 1;
|
941 |
-
}
|
942 |
-
}
|
943 |
-
}
|
944 |
-
}
|
945 |
-
|
946 |
-
$capsToExclude = ure_getBuiltInWPCaps();
|
947 |
-
|
948 |
-
$capsToRemove = array();
|
949 |
-
foreach ($fullCapsList as $capability=>$value) {
|
950 |
-
if (!isset($capsToExclude[$capability])) {
|
951 |
-
// check roles
|
952 |
-
$capInUse = false;
|
953 |
-
foreach ($wp_roles->role_objects as $wp_role) {
|
954 |
-
if ($wp_role->name!='administrator') {
|
955 |
-
if ($wp_role->has_cap($capability)) {
|
956 |
-
$capInUse = true;
|
957 |
-
break;
|
958 |
-
}
|
959 |
-
}
|
960 |
-
}
|
961 |
-
if (!$capInUse) {
|
962 |
-
$capsToRemove[$capability] = 1;
|
963 |
-
}
|
964 |
-
}
|
965 |
-
}
|
966 |
-
|
967 |
-
return $capsToRemove;
|
968 |
-
}
|
969 |
-
// end of getCapsToRemove()
|
970 |
-
|
971 |
-
|
972 |
-
function ure_getCapsToRemoveHTML() {
|
973 |
-
$capsToRemove = ure_getCapsToRemove();
|
974 |
-
if (!empty($capsToRemove) && is_array($capsToRemove) && count($capsToRemove)>0) {
|
975 |
-
$html = '<select id="remove_user_capability" name="remove_user_capability" width="200" style="width: 200px">';
|
976 |
-
foreach ($capsToRemove as $key=>$value) {
|
977 |
-
$html .= '<option value="'.$key.'">'.$key.'</option>';
|
978 |
-
}
|
979 |
-
$html .= '</select>';
|
980 |
-
} else {
|
981 |
-
$html = '';
|
982 |
-
}
|
983 |
-
|
984 |
-
return $html;
|
985 |
-
}
|
986 |
-
// end of getCapsToRemoveHTML()
|
987 |
-
|
988 |
-
|
989 |
-
function ure_deleteCapability() {
|
990 |
-
global $wpdb, $wp_roles;
|
991 |
-
|
992 |
-
$mess = '';
|
993 |
-
if (!empty( $_POST['user_capability_id']) ) {
|
994 |
-
$capability_id = $_POST['user_capability_id'];
|
995 |
-
$capsToRemove = ure_getCapsToRemove();
|
996 |
-
if (!is_array($capsToRemove) || count($capsToRemove)==0 || !isset($capsToRemove[$capability_id])) {
|
997 |
-
return sprintf(__('Error! You do not have permission to delete this capability: %s!', 'ure'), $capability_id);
|
998 |
-
}
|
999 |
-
|
1000 |
-
// process users
|
1001 |
-
$usersId = $wpdb->get_col("SELECT $wpdb->users.ID FROM $wpdb->users");
|
1002 |
-
foreach ($usersId as $user_id) {
|
1003 |
-
$user = get_user_to_edit($user_id);
|
1004 |
-
if ($user->has_cap($capability_id)) {
|
1005 |
-
$user->remove_cap($capability_id);
|
1006 |
-
}
|
1007 |
-
}
|
1008 |
-
|
1009 |
-
// process roles
|
1010 |
-
foreach ($wp_roles->role_objects as $wp_role) {
|
1011 |
-
if ($wp_role->has_cap($capability_id)) {
|
1012 |
-
$wp_role->remove_cap($capability_id);
|
1013 |
-
}
|
1014 |
-
}
|
1015 |
-
|
1016 |
-
$mess = sprintf(__('Capability %s is removed successfully', 'ure'), $capability_id);
|
1017 |
-
}
|
1018 |
-
|
1019 |
-
return $mess;
|
1020 |
-
}
|
1021 |
-
// end of ure_removeCapability()
|
1022 |
-
|
1023 |
-
|
1024 |
-
// returns link to the capability according its name in $capability parameter
|
1025 |
-
function ure_capability_help_link($capability) {
|
1026 |
-
|
1027 |
-
if (empty($capability)) {
|
1028 |
-
return '';
|
1029 |
-
}
|
1030 |
-
|
1031 |
-
switch ($capability) {
|
1032 |
-
case 'activate_plugins':
|
1033 |
-
$url = 'http://www.shinephp.com/activate_plugins-wordpress-capability/';
|
1034 |
-
break;
|
1035 |
-
case 'add_users':
|
1036 |
-
$url = 'http://www.shinephp.com/add_users-wordpress-user-capability/';
|
1037 |
-
break;
|
1038 |
-
case 'create_users':
|
1039 |
-
$url = 'http://www.shinephp.com/create_users-wordpress-user-capability/';
|
1040 |
-
break;
|
1041 |
-
case 'delete_others_pages':
|
1042 |
-
case 'delete_others_posts':
|
1043 |
-
case 'delete_pages':
|
1044 |
-
case 'delete_posts':
|
1045 |
-
case 'delete_private_pages':
|
1046 |
-
case 'delete_private_posts':
|
1047 |
-
case 'delete_published_pages':
|
1048 |
-
case 'delete_published_posts':
|
1049 |
-
$url = 'http://www.shinephp.com/delete-posts-and-pages-wordpress-user-capabilities-set/';
|
1050 |
-
break;
|
1051 |
-
case 'delete_plugins':
|
1052 |
-
$url = 'http://www.shinephp.com/delete_plugins-wordpress-user-capability/';
|
1053 |
-
break;
|
1054 |
-
case 'delete_themes':
|
1055 |
-
$url = 'http://www.shinephp.com/delete_themes-wordpress-user-capability/';
|
1056 |
-
break;
|
1057 |
-
case 'delete_users':
|
1058 |
-
$url = 'http://www.shinephp.com/delete_users-wordpress-user-capability/';
|
1059 |
-
break;
|
1060 |
-
case 'edit_dashboard':
|
1061 |
-
$url = 'http://www.shinephp.com/edit_dashboard-wordpress-capability/';
|
1062 |
-
break;
|
1063 |
-
case 'edit_files':
|
1064 |
-
$url = 'http://www.shinephp.com/edit_files-wordpress-user-capability/';
|
1065 |
-
break;
|
1066 |
-
case 'edit_plugins':
|
1067 |
-
$url = 'http://www.shinephp.com/edit_plugins-wordpress-user-capability';
|
1068 |
-
break;
|
1069 |
-
case 'moderate_comments':
|
1070 |
-
$url = 'http://www.shinephp.com/moderate_comments-wordpress-user-capability/';
|
1071 |
-
break;
|
1072 |
-
case 'read':
|
1073 |
-
$url = 'http://shinephp.com/wordpress-read-capability/';
|
1074 |
-
break;
|
1075 |
-
case 'update_core':
|
1076 |
-
$url = 'http://www.shinephp.com/update_core-capability-for-wordpress-user/';
|
1077 |
-
break;
|
1078 |
-
default:
|
1079 |
-
$url = '';
|
1080 |
-
}
|
1081 |
-
// end of switch
|
1082 |
-
if (!empty($url)) {
|
1083 |
-
$link = '<a href="'.$url.'" title="read about '.$capability.' user capability" target="new"><img src="'.URE_PLUGIN_URL.'/images/help.png" alt="'.__('Help','ure').'" /></a>';
|
1084 |
-
} else {
|
1085 |
-
$link = '';
|
1086 |
-
}
|
1087 |
-
|
1088 |
-
return $link;
|
1089 |
-
}
|
1090 |
-
// end of ure_capability_help_link()
|
1091 |
-
|
1092 |
-
|
1093 |
-
// returns array of deprecated capabilities
|
1094 |
-
function ure_get_deprecated_caps() {
|
1095 |
-
|
1096 |
-
$dep_caps = array('level_0'=>0,
|
1097 |
-
'level_1'=>0,
|
1098 |
-
'level_2'=>0,
|
1099 |
-
'level_3'=>0,
|
1100 |
-
'level_4'=>0,
|
1101 |
-
'level_5'=>0,
|
1102 |
-
'level_6'=>0,
|
1103 |
-
'level_7'=>0,
|
1104 |
-
'level_8'=>0,
|
1105 |
-
'level_9'=>0,
|
1106 |
-
'level_10'=>0,
|
1107 |
-
'edit_files'=>0);
|
1108 |
-
|
1109 |
-
return $dep_caps;
|
1110 |
-
|
1111 |
-
}
|
1112 |
-
// end of get_deprecated_caps()
|
1113 |
-
|
1114 |
-
/**
|
1115 |
-
* output HTML-code for capabilities list
|
1116 |
-
* @global boolean $ure_currentRole
|
1117 |
-
* @global type $ure_show_deprecated_caps
|
1118 |
-
* @global boolean $ure_roles
|
1119 |
-
* @global boolean $ure_fullCapabilities
|
1120 |
-
* @global type $ure_caps_readable
|
1121 |
-
* @param boolean $core - if true, then show WordPress core capabilities, else custom (plugins and themes created)
|
1122 |
-
* @param boolean $for_role - if true, it is role capabilities list, else - user specific capabilities list
|
1123 |
-
*/
|
1124 |
-
function ure_show_capabilities( $core=true, $for_role=true ) {
|
1125 |
-
global $ure_currentRole, $ure_show_deprecated_caps, $ure_roles, $ure_fullCapabilities, $ure_caps_readable, $ure_userToEdit;
|
1126 |
-
|
1127 |
-
$onclick_for_admin = '';
|
1128 |
-
if (! ( is_multisite() && is_super_admin() ) ) { // do not limit SuperAdmin for multi-site
|
1129 |
-
if ( $core && 'administrator' == $ure_currentRole) {
|
1130 |
-
$onclick_for_admin = 'onclick="turn_it_back(this)"';
|
1131 |
-
}
|
1132 |
-
}
|
1133 |
-
|
1134 |
-
if ($core) {
|
1135 |
-
$quant = count( ure_getBuiltInWPCaps() );
|
1136 |
-
$deprecatedCaps = ure_get_deprecated_caps();
|
1137 |
-
} else {
|
1138 |
-
$quant = count( $ure_fullCapabilities ) - count( ure_getBuiltInWPCaps() );
|
1139 |
-
$deprecatedCaps = array();
|
1140 |
-
}
|
1141 |
-
$quantInColumn = (int) $quant / 3;
|
1142 |
-
$printed_quant = 0;
|
1143 |
-
foreach( $ure_fullCapabilities as $capability) {
|
1144 |
-
if ($core) {
|
1145 |
-
if ( !$capability['wp_core'] ) { // show WP built-in capabilities 1st
|
1146 |
-
continue;
|
1147 |
-
}
|
1148 |
-
} else {
|
1149 |
-
if ( $capability['wp_core'] ) { // show plugins and themes added capabilities
|
1150 |
-
continue;
|
1151 |
-
}
|
1152 |
-
}
|
1153 |
-
if (!$ure_show_deprecated_caps && isset($deprecatedCaps[$capability['inner']])) {
|
1154 |
-
$hidden_class = 'class="hidden"';
|
1155 |
-
} else {
|
1156 |
-
$hidden_class = '';
|
1157 |
-
}
|
1158 |
-
if (isset($deprecatedCaps[$capability['inner']])) {
|
1159 |
-
$labelStyle = 'style="color:#BBBBBB;"';
|
1160 |
-
} else {
|
1161 |
-
$labelStyle = '';
|
1162 |
-
}
|
1163 |
-
$checked = ''; $disabled = '';
|
1164 |
-
if ($for_role) {
|
1165 |
-
if (isset($ure_roles[$ure_currentRole]['capabilities'][$capability['inner']]) &&
|
1166 |
-
!empty($ure_roles[$ure_currentRole]['capabilities'][$capability['inner']])) {
|
1167 |
-
$checked = 'checked="checked"';
|
1168 |
-
}
|
1169 |
-
} else {
|
1170 |
-
if (user_can($ure_userToEdit->ID, $capability['inner'])) {
|
1171 |
-
$checked = 'checked="checked"';
|
1172 |
-
if (!isset($ure_userToEdit->caps[$capability['inner']])) {
|
1173 |
-
$disabled = 'disabled="disabled"';
|
1174 |
-
}
|
1175 |
-
}
|
1176 |
-
}
|
1177 |
-
$cap_id = str_replace(' ', URE_SPACE_REPLACER, $capability['inner']);
|
1178 |
-
echo '<input type="checkbox" name="'. $cap_id .'" id="' . $cap_id .'" value="'. $capability['inner'] .'" '. $hidden_class .' '. $checked .' '. $disabled .' '. $onclick_for_admin .' />';
|
1179 |
-
if ( empty( $hidden_class ) ) {
|
1180 |
-
if ( $ure_caps_readable ) {
|
1181 |
-
$capInd = 'human';
|
1182 |
-
$capIndAlt = 'inner';
|
1183 |
-
} else {
|
1184 |
-
$capInd = 'inner';
|
1185 |
-
$capIndAlt = 'human';
|
1186 |
-
}
|
1187 |
-
echo '<label for="'. $cap_id .'" title="'. $capability[$capIndAlt] .'" '. $labelStyle .' > '. $capability[$capInd] .'</label> '. ure_capability_help_link($capability['inner']) .'<br/>';
|
1188 |
-
$printed_quant++;
|
1189 |
-
if ($printed_quant>=$quantInColumn) {
|
1190 |
-
$printed_quant = 0;
|
1191 |
-
echo '</td>
|
1192 |
-
<td style="vertical-align:top;">';
|
1193 |
-
}
|
1194 |
-
} // if ('hidden'
|
1195 |
-
}
|
1196 |
-
|
1197 |
-
}
|
1198 |
-
// end of ure_show_capabilities()
|
1199 |
-
|
1200 |
-
|
1201 |
-
/**
|
1202 |
-
* Returns list of user roles, except 1st one, and bbPress assigned as they are shown by WordPress and bbPress theirselves.
|
1203 |
-
*
|
1204 |
-
* @param type $user WP_User from wp-includes/capabilities.php
|
1205 |
-
* @return array
|
1206 |
-
*/
|
1207 |
-
function ure_other_user_roles($user) {
|
1208 |
-
|
1209 |
-
global $wp_roles;
|
1210 |
-
|
1211 |
-
if ( !is_array($user->roles) || count($user->roles)<=1 ) {
|
1212 |
-
return '';
|
1213 |
-
}
|
1214 |
-
|
1215 |
-
// get bbPress assigned user role
|
1216 |
-
if ( function_exists('bbp_filter_blog_editable_roles') ) {
|
1217 |
-
$bb_press_role = bbp_get_user_role( $user->ID );
|
1218 |
-
} else {
|
1219 |
-
$bb_press_role = '';
|
1220 |
-
}
|
1221 |
-
|
1222 |
-
$roles = array();
|
1223 |
-
foreach ($user->roles as $key=>$value) {
|
1224 |
-
if ( !empty( $bb_press_role ) && $bb_press_role===$value ) {
|
1225 |
-
// exclude bbPress assigned role
|
1226 |
-
continue;
|
1227 |
-
}
|
1228 |
-
$roles[] = $value;
|
1229 |
-
}
|
1230 |
-
array_shift($roles); // exclude primary role which is shown by WordPress itself
|
1231 |
-
|
1232 |
-
return $roles;
|
1233 |
-
|
1234 |
-
}
|
1235 |
-
// end of ure_other_user_roles()
|
1236 |
-
|
1237 |
-
|
1238 |
-
/**
|
1239 |
-
* Returns list of user roles, except 1st one, and bbPress assigned as they are shown by WordPress and bbPress theirselves.
|
1240 |
-
*
|
1241 |
-
* @param type $roles user roles list
|
1242 |
-
* @return string
|
1243 |
-
*/
|
1244 |
-
function ure_other_user_roles_text($roles) {
|
1245 |
-
global $wp_roles;
|
1246 |
-
|
1247 |
-
if ( is_array($roles) && count( $roles ) > 0 ) {
|
1248 |
-
$role_names = array();
|
1249 |
-
foreach ($roles as $role) {
|
1250 |
-
$role_names[] = $wp_roles->roles[$role]['name'];
|
1251 |
-
}
|
1252 |
-
$output = implode(', ', $role_names);
|
1253 |
-
} else {
|
1254 |
-
$output = '';
|
1255 |
-
}
|
1256 |
-
|
1257 |
-
return $output;
|
1258 |
-
|
1259 |
-
}
|
1260 |
-
// end of ure_other_user_roles_text()
|
1261 |
-
|
1262 |
-
|
1263 |
-
// output HTML code to create URE toolbar
|
1264 |
-
function ure_toolbar($ure_currentRole, $ure_object, $roleDeleteHTML='', $capabilityRemoveHTML='') {
|
1265 |
-
|
1266 |
-
?>
|
1267 |
-
<div id="ure_toolbar" >
|
1268 |
-
<button id="ure_select_all" class="ure_toolbar_button">Select All</button>
|
1269 |
-
<?php
|
1270 |
-
if ('administrator' != $ure_currentRole ) {
|
1271 |
-
?>
|
1272 |
-
<button id="ure_unselect_all" class="ure_toolbar_button">Unselect All</button>
|
1273 |
-
<button id="ure_reverse_selection" class="ure_toolbar_button">Reverse</button>
|
1274 |
-
<?php
|
1275 |
-
}
|
1276 |
-
if ($ure_object == 'role') {
|
1277 |
-
|
1278 |
-
?>
|
1279 |
-
|
1280 |
-
<hr />
|
1281 |
-
<div id="ure_update">
|
1282 |
-
<button id="ure_update_role" class="ure_toolbar_button button-primary">Update</button>
|
1283 |
-
</div>
|
1284 |
-
<hr />
|
1285 |
-
<button id="ure_add_role" class="ure_toolbar_button">Add New Role</button>
|
1286 |
-
<button id="ure_add_capability" class="ure_toolbar_button">Add New Capability</button>
|
1287 |
-
<?php
|
1288 |
-
if (!empty($roleDeleteHTML)) {
|
1289 |
-
?>
|
1290 |
-
<button id="ure_delete_role" class="ure_toolbar_button">Delete Role</button>
|
1291 |
-
<?php
|
1292 |
-
}
|
1293 |
-
if (!empty($capabilityRemoveHTML)) {
|
1294 |
-
?>
|
1295 |
-
<button id="ure_delete_capability" class="ure_toolbar_button">Delete Capability</button>
|
1296 |
-
<?php
|
1297 |
-
}
|
1298 |
-
?>
|
1299 |
-
<hr />
|
1300 |
-
<button id="ure_default_role" class="ure_toolbar_button">Default Role</button>
|
1301 |
-
<hr />
|
1302 |
-
<div id="ure_service_tools">
|
1303 |
-
<button id="ure_reset_roles" class="ure_toolbar_button" title="Reset Roles to its original state">Reset</button>
|
1304 |
-
</div>
|
1305 |
-
<?php
|
1306 |
-
} else {
|
1307 |
-
?>
|
1308 |
-
|
1309 |
-
<hr />
|
1310 |
-
<div id="ure_update_user">
|
1311 |
-
<button id="ure_update_role" class="ure_toolbar_button button-primary">Update</button>
|
1312 |
-
</div>
|
1313 |
-
<?php
|
1314 |
-
}
|
1315 |
-
?>
|
1316 |
-
|
1317 |
-
</div>
|
1318 |
-
<?php
|
1319 |
-
|
1320 |
-
}
|
1321 |
-
// end of ure_toolbar()
|
1322 |
-
|
1323 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/ure-options.php
DELETED
@@ -1,242 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
*
|
4 |
-
* User Role Editor plugin management pages
|
5 |
-
*
|
6 |
-
*/
|
7 |
-
|
8 |
-
if (!defined('URE_PLUGIN_URL')) {
|
9 |
-
die; // Silence is golden, direct call is prohibited
|
10 |
-
}
|
11 |
-
|
12 |
-
$shinephpFavIcon = URE_PLUGIN_URL.'images/vladimir.png';
|
13 |
-
$mess = '';
|
14 |
-
|
15 |
-
$ure_caps_readable = get_option('ure_caps_readable');
|
16 |
-
$ure_show_deprecated_caps = get_option('ure_show_deprecated_caps');
|
17 |
-
$option_name = $wpdb->prefix.'user_roles';
|
18 |
-
|
19 |
-
// could be sent as by POST, as by GET
|
20 |
-
if (isset($_REQUEST['object'])) {
|
21 |
-
$ure_object = $_REQUEST['object'];
|
22 |
-
} else {
|
23 |
-
$ure_object = 'role';
|
24 |
-
}
|
25 |
-
|
26 |
-
if (isset($_POST['action'])) {
|
27 |
-
if (empty($_POST['ure_nonce']) || !wp_verify_nonce($_POST['ure_nonce'],'user-role-editor')) {
|
28 |
-
echo '<h3>Wrong nonce. Action prohibitied.</h3>';
|
29 |
-
return;
|
30 |
-
}
|
31 |
-
|
32 |
-
$action = $_POST['action'];
|
33 |
-
// restore roles capabilities from the backup record
|
34 |
-
if ($action=='reset') {
|
35 |
-
$mess = ure_reset_user_roles();
|
36 |
-
if (!$mess) {
|
37 |
-
return;
|
38 |
-
}
|
39 |
-
} else if ($action=='add-new-role') {
|
40 |
-
// process new role create request
|
41 |
-
$mess = ure_newRoleCreate($ure_currentRole);
|
42 |
-
} else if ($action=='delete-role') {
|
43 |
-
$mess = ure_deleteRole();
|
44 |
-
} else if ($action=='change-default-role') {
|
45 |
-
$mess = ure_changeDefaultRole();
|
46 |
-
} else if ($action=='caps-readable') {
|
47 |
-
if ($ure_caps_readable) {
|
48 |
-
$ure_caps_readable = 0;
|
49 |
-
} else {
|
50 |
-
$ure_caps_readable = 1;
|
51 |
-
}
|
52 |
-
update_option('ure_caps_readable', $ure_caps_readable);
|
53 |
-
} else if ($action=='show-deprecated-caps') {
|
54 |
-
if ($ure_show_deprecated_caps) {
|
55 |
-
$ure_show_deprecated_caps = 0;
|
56 |
-
} else {
|
57 |
-
$ure_show_deprecated_caps = 1;
|
58 |
-
}
|
59 |
-
update_option('ure_show_deprecated_caps', $ure_show_deprecated_caps);
|
60 |
-
} else if ($action=='add-new-capability') {
|
61 |
-
$mess = ure_AddNewCapability();
|
62 |
-
} else if ($action=='delete-user-capability') {
|
63 |
-
$mess = ure_deleteCapability();
|
64 |
-
} else if ($action=='roles_restore_note') {
|
65 |
-
$mess = __('User Roles are restored to WordPress default values. ', 'ure');
|
66 |
-
}
|
67 |
-
} else {
|
68 |
-
$action = '';
|
69 |
-
}
|
70 |
-
|
71 |
-
$defaultRole = get_option('default_role');
|
72 |
-
|
73 |
-
if (isset($_POST['ure_apply_to_all'])) {
|
74 |
-
$ure_apply_to_all = 1;
|
75 |
-
} else {
|
76 |
-
$ure_apply_to_all = 0;
|
77 |
-
}
|
78 |
-
|
79 |
-
if (!isset($ure_roles) || !$ure_roles) {
|
80 |
-
// get roles data from database
|
81 |
-
$ure_roles = ure_getUserRoles();
|
82 |
-
if (!$ure_roles) {
|
83 |
-
return;
|
84 |
-
}
|
85 |
-
}
|
86 |
-
|
87 |
-
$ure_rolesId = array();
|
88 |
-
foreach ($ure_roles as $key=>$value) {
|
89 |
-
$ure_rolesId[] = $key;
|
90 |
-
}
|
91 |
-
|
92 |
-
$built_in_wp_caps = ure_getBuiltInWPCaps();
|
93 |
-
$ure_fullCapabilities = array();
|
94 |
-
foreach($ure_roles as $role) {
|
95 |
-
// validate if capabilities is an array
|
96 |
-
if (isset($role['capabilities']) && is_array($role['capabilities'])) {
|
97 |
-
foreach ($role['capabilities'] as $key=>$value) {
|
98 |
-
$cap = array();
|
99 |
-
$cap['inner'] = $key;
|
100 |
-
$cap['human'] = __(ure_ConvertCapsToReadable($key),'ure');
|
101 |
-
if ( isset( $built_in_wp_caps[ $key ] ) ) {
|
102 |
-
$cap['wp_core'] = true;
|
103 |
-
} else {
|
104 |
-
$cap['wp_core'] = false;
|
105 |
-
}
|
106 |
-
if (!isset($ure_fullCapabilities[$key])) {
|
107 |
-
$ure_fullCapabilities[$key] = $cap;
|
108 |
-
}
|
109 |
-
}
|
110 |
-
}
|
111 |
-
}
|
112 |
-
asort($ure_fullCapabilities);
|
113 |
-
|
114 |
-
|
115 |
-
if ($ure_object=='user') {
|
116 |
-
if (!isset($_REQUEST['user_id'])) {
|
117 |
-
$mess .= ' user_id value is missed';
|
118 |
-
return;
|
119 |
-
}
|
120 |
-
$user_id = $_REQUEST['user_id'];
|
121 |
-
if (!is_numeric($user_id)) {
|
122 |
-
return;
|
123 |
-
}
|
124 |
-
if (!$user_id) {
|
125 |
-
return;
|
126 |
-
}
|
127 |
-
$ure_userToEdit = get_user_to_edit($user_id);
|
128 |
-
if (empty($ure_userToEdit)) {
|
129 |
-
return;
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
if ( isset( $_POST['action'] ) && $_POST['action'] == 'update' ) {
|
134 |
-
if ( isset( $_POST['user_role'] ) ) {
|
135 |
-
if (!isset($ure_roles[ $_POST['user_role'] ])) {
|
136 |
-
$mess = __('Error: ', 'ure') . __('Role', 'ure') . ' <em>' . $ure_currentRole . '</em> ' . __('does not exist', 'ure');
|
137 |
-
$ure_currentRole = '';
|
138 |
-
} else {
|
139 |
-
$ure_currentRole = $_POST['user_role'];
|
140 |
-
$ure_currentRoleName = $ure_roles[$ure_currentRole]['name'];
|
141 |
-
}
|
142 |
-
}
|
143 |
-
$ure_capabilitiesToSave = array();
|
144 |
-
foreach ($ure_fullCapabilities as $availableCapability) {
|
145 |
-
$cap_id = str_replace(' ', URE_SPACE_REPLACER, $availableCapability['inner']);
|
146 |
-
if (isset($_POST[$cap_id])) {
|
147 |
-
$ure_capabilitiesToSave[$availableCapability['inner']] = true;
|
148 |
-
}
|
149 |
-
}
|
150 |
-
if ($ure_object == 'role') { // save role changes to database
|
151 |
-
if (count($ure_capabilitiesToSave) > 0) {
|
152 |
-
if (ure_updateRoles()) {
|
153 |
-
if ($mess) {
|
154 |
-
$mess .= '<br/>';
|
155 |
-
}
|
156 |
-
$mess = __('Role', 'ure') . ' <em>' . __($ure_roles[$ure_currentRole]['name'], 'ure') . '</em> ' . __('is updated successfully', 'ure');
|
157 |
-
} else {
|
158 |
-
if ($mess) {
|
159 |
-
$mess .= '<br/>';
|
160 |
-
}
|
161 |
-
$mess = __('Error occured during role update', 'ure');
|
162 |
-
}
|
163 |
-
}
|
164 |
-
} else {
|
165 |
-
if (ure_updateUser($ure_userToEdit)) {
|
166 |
-
if ($mess) {
|
167 |
-
$mess .= '<br/>';
|
168 |
-
}
|
169 |
-
$mess = __('User', 'ure') . ' <<em>' . $ure_userToEdit->display_name . '</em>> ' . __('capabilities are updated successfully', 'ure');
|
170 |
-
} else {
|
171 |
-
if ($mess) {
|
172 |
-
$mess .= '<br/>';
|
173 |
-
}
|
174 |
-
$mess = __('Error occured during role update', 'ure');
|
175 |
-
}
|
176 |
-
}
|
177 |
-
}
|
178 |
-
|
179 |
-
$ure_advert = new ure_Advertisement();
|
180 |
-
|
181 |
-
// options page display part
|
182 |
-
function ure_displayBoxStart($title, $style='') {
|
183 |
-
?>
|
184 |
-
<div class="postbox" style="float: left; <?php echo $style; ?>">
|
185 |
-
<h3 style="cursor:default;"><span><?php echo $title ?></span></h3>
|
186 |
-
<div class="inside">
|
187 |
-
<?php
|
188 |
-
}
|
189 |
-
// end of ure_displayBoxStart()
|
190 |
-
|
191 |
-
function ure_displayBoxEnd() {
|
192 |
-
?>
|
193 |
-
</div>
|
194 |
-
</div>
|
195 |
-
<?php
|
196 |
-
}
|
197 |
-
// end of thanks_displayBoxEnd()
|
198 |
-
|
199 |
-
|
200 |
-
ure_showMessage($mess);
|
201 |
-
|
202 |
-
?>
|
203 |
-
<div id="poststuff">
|
204 |
-
<div class="ure-sidebar" >
|
205 |
-
<?php $ure_advert->display(); ?>
|
206 |
-
<?php ure_displayBoxStart(__('About this Plugin:', 'ure')); ?>
|
207 |
-
<a class="ure_rsb_link" style="background-image:url(<?php echo $shinephpFavIcon; ?>);" target="_blank" href="http://www.shinephp.com/"><?php _e("Author's website", 'ure'); ?></a>
|
208 |
-
<a class="ure_rsb_link" style="background-image:url(<?php echo URE_PLUGIN_URL . 'images/user-role-editor-icon.png'; ?>);" target="_blank" href="http://role-editor.com"><?php _e('Plugin webpage', 'ure'); ?></a>
|
209 |
-
<a class="ure_rsb_link" style="background-image:url(<?php echo URE_PLUGIN_URL . 'images/changelog-icon.png'; ?>);" target="_blank" href="http://www.shinephp.com/user-role-editor-wordpress-plugin/#changelog"><?php _e('Changelog', 'ure'); ?></a>
|
210 |
-
<a class="ure_rsb_link" style="background-image:url(<?php echo URE_PLUGIN_URL . 'images/faq-icon.png'; ?>);" target="_blank" href="http://www.shinephp.com/user-role-editor-wordpress-plugin/#faq"><?php _e('FAQ', 'ure'); ?></a>
|
211 |
-
<hr />
|
212 |
-
<div style="text-align: center;">
|
213 |
-
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
214 |
-
<input type="hidden" name="cmd" value="_s-xclick">
|
215 |
-
<input type="hidden" name="encrypted"
|
216 |
-
value="-----BEGIN PKCS7-----MIIHZwYJKoZIhvcNAQcEoIIHWDCCB1QCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBME5QAQYFDddWBHA4YXI1x3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3XmA3Hkgrcu6yhVijY/Odmf6WWcz79/uLGkvBSECbjTY0GLxvhRlsh2nAioCfxAr1cFo-----END PKCS7-----">
|
217 |
-
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
218 |
-
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
219 |
-
</form>
|
220 |
-
</div>
|
221 |
-
<?php ure_displayBoxEnd(); ?>
|
222 |
-
</div>
|
223 |
-
|
224 |
-
<div class="has-sidebar" >
|
225 |
-
<form id="ure_form" method="post" action="<?php echo URE_PARENT; ?>?page=user-role-editor.php" >
|
226 |
-
<div id="ure_form_controls">
|
227 |
-
<?php
|
228 |
-
wp_nonce_field('user-role-editor', 'ure_nonce');
|
229 |
-
settings_fields('ure-options');
|
230 |
-
?>
|
231 |
-
|
232 |
-
<?php
|
233 |
-
if ($ure_object == 'user') {
|
234 |
-
require_once(URE_PLUGIN_DIR .'includes/ure-user-edit.php');
|
235 |
-
} else {
|
236 |
-
require_once(URE_PLUGIN_DIR .'includes/ure-role-edit.php');
|
237 |
-
}
|
238 |
-
?>
|
239 |
-
</div>
|
240 |
-
</form>
|
241 |
-
</div>
|
242 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/ure-role-edit.php
CHANGED
@@ -10,87 +10,39 @@ if (!defined('URE_PLUGIN_URL')) {
|
|
10 |
die; // Silence is golden, direct call is prohibited
|
11 |
}
|
12 |
|
13 |
-
// create roles backup if it's not created yet
|
14 |
-
ure_makeRolesBackup();
|
15 |
-
|
16 |
-
if (!isset($ure_currentRole) || !$ure_currentRole) {
|
17 |
-
if (isset($_REQUEST['user_role']) && $_REQUEST['user_role'] && isset($ure_roles[$_REQUEST['user_role']])) {
|
18 |
-
$ure_currentRole = $_REQUEST['user_role'];
|
19 |
-
} else {
|
20 |
-
$ure_currentRole = $ure_rolesId[count($ure_rolesId) - 1];
|
21 |
-
}
|
22 |
-
$ure_currentRoleName = $ure_roles[$ure_currentRole]['name'];
|
23 |
-
}
|
24 |
-
|
25 |
-
$youAreAdmin = defined('URE_SHOW_ADMIN_ROLE') && ure_is_admin();
|
26 |
-
|
27 |
-
$roleDefaultHTML = '<select id="default_user_role" name="default_user_role" width="200" style="width: 200px">';
|
28 |
-
$roleToCopyHTML = '<select id="user_role_copy_from" name="user_role_copy_from" width="200" style="width: 200px">
|
29 |
-
<option value="none" selected="selected">'.__('None', 'ure').'</option>';
|
30 |
-
$roleSelectHTML = '<select id="user_role" name="user_role" onchange="ure_role_change(this.value);">';
|
31 |
-
foreach ($ure_roles as $key=>$value) {
|
32 |
-
$selected1 = ure_optionSelected($key, $ure_currentRole);
|
33 |
-
$selected2 = ure_optionSelected($key, $defaultRole);
|
34 |
-
if ($youAreAdmin || $key!='administrator') {
|
35 |
-
$translated_name = __($value['name'], 'ure'); // get translation from URE language file, if exists
|
36 |
-
if ($translated_name===$value['name']) { // get WordPress internal translation
|
37 |
-
$translated_name = translate_user_role($translated_name);
|
38 |
-
}
|
39 |
-
$translated_name .= ' ('. $key .')';
|
40 |
-
$roleSelectHTML .= '<option value="'.$key.'" '.$selected1.'>'.$translated_name.'</option>';
|
41 |
-
$roleDefaultHTML .= '<option value="'.$key.'" '.$selected2.'>'.$translated_name.'</option>';
|
42 |
-
$roleToCopyHTML .= '<option value="'.$key.'" >'.$translated_name.'</option>';
|
43 |
-
}
|
44 |
-
}
|
45 |
-
$roleSelectHTML .= '</select>';
|
46 |
-
$roleDefaultHTML .= '</select>';
|
47 |
-
$roleToCopyHTML .= '</select>';
|
48 |
-
|
49 |
-
$ure_rolesCanDelete = ure_getRolesCanDelete($ure_roles);
|
50 |
-
if ($ure_rolesCanDelete && count($ure_rolesCanDelete)>0) {
|
51 |
-
$roleDeleteHTML = '<select id="del_user_role" name="del_user_role" width="200" style="width: 200px">';
|
52 |
-
foreach ($ure_rolesCanDelete as $key=>$value) {
|
53 |
-
$roleDeleteHTML .= '<option value="'.$key.'">'.__($value, 'ure').'</option>';
|
54 |
-
}
|
55 |
-
$roleDeleteHTML .= '</select>';
|
56 |
-
} else {
|
57 |
-
$roleDeleteHTML = '';
|
58 |
-
}
|
59 |
-
|
60 |
-
$capabilityRemoveHTML = ure_getCapsToRemoveHTML();
|
61 |
-
|
62 |
?>
|
63 |
|
64 |
-
|
65 |
-
|
66 |
<?php
|
67 |
-
|
68 |
?>
|
69 |
-
<div style="float: left;"><?php echo __('Select Role:', 'ure').' '.$
|
70 |
<?php
|
71 |
-
if ($
|
72 |
$checked = 'checked="checked"';
|
73 |
} else {
|
74 |
$checked = '';
|
75 |
}
|
76 |
?>
|
77 |
<div style="display:inline;float:right;">
|
78 |
-
<input type="checkbox" name="ure_caps_readable" id="ure_caps_readable" value="1"
|
|
|
79 |
<label for="ure_caps_readable"><?php _e('Show capabilities in human readable form', 'ure'); ?></label><br />
|
80 |
<?php
|
81 |
-
if ($
|
82 |
$checked = 'checked="checked"';
|
83 |
} else {
|
84 |
$checked = '';
|
85 |
}
|
86 |
?>
|
87 |
-
<input type="checkbox" name="ure_show_deprecated_caps" id="ure_show_deprecated_caps" value="1"
|
|
|
88 |
<label for="ure_show_deprecated_caps"><?php _e('Show deprecated capabilities', 'ure'); ?></label>
|
89 |
</div>
|
90 |
<?php
|
91 |
if (is_multisite() && is_main_site( get_current_blog_id() ) && is_super_admin()) {
|
92 |
$hint = __('If checked, then apply action to ALL sites of this Network');
|
93 |
-
if ($
|
94 |
$checked = 'checked="checked"';
|
95 |
$fontColor = 'color:#FF0000;';
|
96 |
} else {
|
@@ -98,8 +50,10 @@ if (is_multisite() && is_main_site( get_current_blog_id() ) && is_super_admin())
|
|
98 |
$fontColor = '';
|
99 |
}
|
100 |
?>
|
101 |
-
<div style="float: right; margin-left:10px; margin-right: 20px; <?php echo $fontColor;?>" id="ure_apply_to_all_div"
|
102 |
-
|
|
|
|
|
103 |
</div>
|
104 |
<?php
|
105 |
}
|
@@ -110,15 +64,15 @@ if (is_multisite() && is_main_site( get_current_blog_id() ) && is_super_admin())
|
|
110 |
<table class="form-table" style="clear:none;" cellpadding="0" cellspacing="0">
|
111 |
<tr>
|
112 |
<td style="vertical-align:top;">
|
113 |
-
|
114 |
</td>
|
115 |
<td>
|
116 |
-
|
117 |
</td>
|
118 |
</tr>
|
119 |
</table>
|
120 |
<?php
|
121 |
-
$quant = count( $
|
122 |
if ($quant>0) {
|
123 |
echo '<hr />';
|
124 |
_e('Custom capabilities:', 'ure');
|
@@ -126,7 +80,7 @@ if (is_multisite() && is_main_site( get_current_blog_id() ) && is_super_admin())
|
|
126 |
<table class="form-table" style="clear:none;" cellpadding="0" cellspacing="0">
|
127 |
<tr>
|
128 |
<td style="vertical-align:top;">
|
129 |
-
|
130 |
</td>
|
131 |
<td></td>
|
132 |
</tr>
|
@@ -137,55 +91,7 @@ if (is_multisite() && is_main_site( get_current_blog_id() ) && is_super_admin())
|
|
137 |
|
138 |
<input type="hidden" name="object" value="role" />
|
139 |
<?php
|
140 |
-
|
141 |
?>
|
142 |
-
<div style="clear: left; float: left; width: 800px;">
|
143 |
-
</div>
|
144 |
-
</div>
|
145 |
-
|
146 |
-
<script language="javascript" type="text/javascript">
|
147 |
-
|
148 |
-
var ure_current_role = '<?php echo $ure_currentRole; ?>';
|
149 |
-
|
150 |
-
</script>
|
151 |
-
|
152 |
-
<!-- popup dialogs markup -->
|
153 |
-
<div id="ure_add_role_dialog" class="ure-modal-dialog" style="padding: 10px;">
|
154 |
-
<form id="ure_add_role_form" name="ure_add_role_form" method="POST">
|
155 |
-
<div class="ure-label"><?php echo __('Role name (ID): ', 'ure'); ?></div>
|
156 |
-
<div class="ure-input"><input type="text" name="user_role_id" id="user_role_id" size="25"/></div>
|
157 |
-
<div class="ure-label"><?php echo __('Display Role Name: ', 'ure'); ?></div>
|
158 |
-
<div class="ure-input"><input type="text" name="user_role_name" id="user_role_name" size="25"/></div>
|
159 |
-
<div class="ure-label"><?php echo __('Make copy of: ', 'ure'); ?></div>
|
160 |
-
<div class="ure-input"><?php echo $roleToCopyHTML; ?></div>
|
161 |
-
</form>
|
162 |
</div>
|
163 |
-
|
164 |
-
<div id="ure_delete_role_dialog" class="ure-modal-dialog">
|
165 |
-
<div style="padding:10px;">
|
166 |
-
<div class="ure-label"><?php _e('Select Role:', 'ure');?></div>
|
167 |
-
<div class="ure-input"><?php echo $roleDeleteHTML; ?></div>
|
168 |
-
</div>
|
169 |
-
</div>
|
170 |
-
|
171 |
-
|
172 |
-
<div id="ure_default_role_dialog" class="ure-modal-dialog">
|
173 |
-
<div style="padding:10px;">
|
174 |
-
<?php echo $roleDefaultHTML; ?>
|
175 |
-
</div>
|
176 |
-
</div>
|
177 |
-
|
178 |
-
|
179 |
-
<div id="ure_delete_capability_dialog" class="ure-modal-dialog">
|
180 |
-
<div style="padding:10px;">
|
181 |
-
<div class="ure-label"><?php _e('Delete:', 'ure');?></div>
|
182 |
-
<div class="ure-input"><?php echo $capabilityRemoveHTML; ?></div>
|
183 |
-
</div>
|
184 |
-
</div>
|
185 |
-
|
186 |
-
<div id="ure_add_capability_dialog" class="ure-modal-dialog">
|
187 |
-
<div style="padding:10px;">
|
188 |
-
<div class="ure-label"><?php echo __('Capability name (ID): ', 'ure'); ?></div>
|
189 |
-
<div class="ure-input"><input type="text" name="capability_id" id="capability_id" size="25"/></div>
|
190 |
-
</div>
|
191 |
-
</div>
|
10 |
die; // Silence is golden, direct call is prohibited
|
11 |
}
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
?>
|
14 |
|
15 |
+
<div class="has-sidebar-content">
|
|
|
16 |
<?php
|
17 |
+
$this->display_box_start(__('Select Role and change its capabilities list', 'ure'), 'min-width:700px;');
|
18 |
?>
|
19 |
+
<div style="float: left;"><?php echo __('Select Role:', 'ure').' '.$this->role_select_html; ?></div>
|
20 |
<?php
|
21 |
+
if ($this->caps_readable) {
|
22 |
$checked = 'checked="checked"';
|
23 |
} else {
|
24 |
$checked = '';
|
25 |
}
|
26 |
?>
|
27 |
<div style="display:inline;float:right;">
|
28 |
+
<input type="checkbox" name="ure_caps_readable" id="ure_caps_readable" value="1"
|
29 |
+
<?php echo $checked; ?> onclick="ure_turn_caps_readable(0);"/>
|
30 |
<label for="ure_caps_readable"><?php _e('Show capabilities in human readable form', 'ure'); ?></label><br />
|
31 |
<?php
|
32 |
+
if ($this->show_deprecated_caps) {
|
33 |
$checked = 'checked="checked"';
|
34 |
} else {
|
35 |
$checked = '';
|
36 |
}
|
37 |
?>
|
38 |
+
<input type="checkbox" name="ure_show_deprecated_caps" id="ure_show_deprecated_caps" value="1"
|
39 |
+
<?php echo $checked; ?> onclick="ure_turn_deprecated_caps(0);"/>
|
40 |
<label for="ure_show_deprecated_caps"><?php _e('Show deprecated capabilities', 'ure'); ?></label>
|
41 |
</div>
|
42 |
<?php
|
43 |
if (is_multisite() && is_main_site( get_current_blog_id() ) && is_super_admin()) {
|
44 |
$hint = __('If checked, then apply action to ALL sites of this Network');
|
45 |
+
if ($this->apply_to_all) {
|
46 |
$checked = 'checked="checked"';
|
47 |
$fontColor = 'color:#FF0000;';
|
48 |
} else {
|
50 |
$fontColor = '';
|
51 |
}
|
52 |
?>
|
53 |
+
<div style="float: right; margin-left:10px; margin-right: 20px; <?php echo $fontColor;?>" id="ure_apply_to_all_div">
|
54 |
+
<input type="checkbox" name="ure_apply_to_all" id="ure_apply_to_all" value="1"
|
55 |
+
<?php echo $checked; ?> title="<?php echo $hint;?>" onclick="ure_applyToAllOnClick(this)"/>
|
56 |
+
<label for="ure_apply_to_all" title="<?php echo $hint;?>"><?php _e('Apply to All Sites', 'ure');?></label>
|
57 |
</div>
|
58 |
<?php
|
59 |
}
|
64 |
<table class="form-table" style="clear:none;" cellpadding="0" cellspacing="0">
|
65 |
<tr>
|
66 |
<td style="vertical-align:top;">
|
67 |
+
<?php $this->show_capabilities( true, true ); ?>
|
68 |
</td>
|
69 |
<td>
|
70 |
+
<?php $this->toolbar(!empty($this->role_delete_html), !empty($this->capability_remove_html));?>
|
71 |
</td>
|
72 |
</tr>
|
73 |
</table>
|
74 |
<?php
|
75 |
+
$quant = count( $this->full_capabilities ) - count( $this->get_built_in_wp_caps() );
|
76 |
if ($quant>0) {
|
77 |
echo '<hr />';
|
78 |
_e('Custom capabilities:', 'ure');
|
80 |
<table class="form-table" style="clear:none;" cellpadding="0" cellspacing="0">
|
81 |
<tr>
|
82 |
<td style="vertical-align:top;">
|
83 |
+
<?php $this->show_capabilities( false, true ); ?>
|
84 |
</td>
|
85 |
<td></td>
|
86 |
</tr>
|
91 |
|
92 |
<input type="hidden" name="object" value="role" />
|
93 |
<?php
|
94 |
+
$this->display_box_end();
|
95 |
?>
|
96 |
+
<div style="clear: left; float: left; width: 800px;"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/ure-user-edit.php
CHANGED
@@ -14,12 +14,20 @@ if (!defined('URE_PLUGIN_URL')) {
|
|
14 |
|
15 |
<div class="has-sidebar-content">
|
16 |
<?php
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
-
$
|
22 |
-
|
23 |
|
24 |
?>
|
25 |
<table cellpadding="0" cellspacing="0">
|
@@ -27,23 +35,25 @@ if (!defined('URE_PLUGIN_URL')) {
|
|
27 |
<td> </td>
|
28 |
<td style="padding-left: 10px; padding-bottom: 5px;">
|
29 |
<?php
|
30 |
-
if ($
|
31 |
$checked = 'checked="checked"';
|
32 |
} else {
|
33 |
$checked = '';
|
34 |
}
|
35 |
?>
|
36 |
|
37 |
-
<input type="checkbox" name="ure_caps_readable" id="ure_caps_readable" value="1"
|
|
|
38 |
<label for="ure_caps_readable"><?php _e('Show capabilities in human readable form', 'ure'); ?></label>
|
39 |
<?php
|
40 |
-
if ($
|
41 |
$checked = 'checked="checked"';
|
42 |
} else {
|
43 |
$checked = '';
|
44 |
}
|
45 |
?>
|
46 |
-
<input type="checkbox" name="ure_show_deprecated_caps" id="ure_show_deprecated_caps" value="1"
|
|
|
47 |
<label for="ure_show_deprecated_caps"><?php _e('Show deprecated capabilities', 'ure'); ?></label>
|
48 |
</td>
|
49 |
</tr>
|
@@ -51,9 +61,9 @@ if (!defined('URE_PLUGIN_URL')) {
|
|
51 |
<td class="ure-user-roles">
|
52 |
<div style="margin-bottom: 5px; font-weight: bold;"><?php echo __('Primary Role:', 'ure'); ?></div>
|
53 |
<?php
|
54 |
-
$primary_role = array_shift(array_values($
|
55 |
-
if (!empty($primary_role) && isset($
|
56 |
-
echo $
|
57 |
} else {
|
58 |
echo 'None';
|
59 |
}
|
@@ -63,7 +73,7 @@ if (function_exists('bbp_filter_blog_editable_roles') ) { // bbPress plugin is
|
|
63 |
<?php
|
64 |
// Get the roles
|
65 |
$dynamic_roles = bbp_get_dynamic_roles();
|
66 |
-
$bbp_user_role = bbp_get_user_role($
|
67 |
if (!empty($bbp_user_role)) {
|
68 |
echo $dynamic_roles[$bbp_user_role]['name'];
|
69 |
}
|
@@ -71,15 +81,17 @@ if (function_exists('bbp_filter_blog_editable_roles') ) { // bbPress plugin is
|
|
71 |
?>
|
72 |
<div style="margin-top: 5px;margin-bottom: 5px; font-weight: bold;"><?php echo __('Other Roles:', 'ure'); ?></div>
|
73 |
<?php
|
74 |
-
$
|
75 |
-
foreach ($
|
76 |
-
if ( ($
|
77 |
-
if ( user_can( $
|
78 |
$checked = 'checked="checked"';
|
79 |
} else {
|
80 |
$checked = '';
|
81 |
}
|
82 |
-
echo '<label for="wp_role_' . $role_id .'"><input type="checkbox" id="wp_role_' . $role_id .
|
|
|
|
|
83 |
}
|
84 |
}
|
85 |
?>
|
@@ -89,22 +101,22 @@ if (function_exists('bbp_filter_blog_editable_roles') ) { // bbPress plugin is
|
|
89 |
<table class="form-table" style="clear:none;" cellpadding="0" cellspacing="0">
|
90 |
<tr>
|
91 |
<td style="vertical-align:top;">
|
92 |
-
<?php
|
93 |
</td>
|
94 |
<td>
|
95 |
-
<?php
|
96 |
</td>
|
97 |
</tr>
|
98 |
</table>
|
99 |
<?php
|
100 |
-
$quant = count( $
|
101 |
if ($quant>0) {
|
102 |
?>
|
103 |
<span style="font-weight: bold;"><?php _e('Custom capabilities:', 'ure'); ?></span>
|
104 |
<table class="form-table" style="clear:none;" cellpadding="0" cellspacing="0">
|
105 |
<tr>
|
106 |
<td style="vertical-align:top;">
|
107 |
-
<?php
|
108 |
</td>
|
109 |
</tr>
|
110 |
</table>
|
@@ -115,10 +127,9 @@ if (function_exists('bbp_filter_blog_editable_roles') ) { // bbPress plugin is
|
|
115 |
</tr>
|
116 |
</table>
|
117 |
<input type="hidden" name="object" value="user" />
|
118 |
-
<input type="hidden" name="user_id" value="<?php echo $
|
119 |
<?php
|
120 |
-
|
121 |
?>
|
122 |
|
123 |
-
</div>
|
124 |
-
|
14 |
|
15 |
<div class="has-sidebar-content">
|
16 |
<?php
|
17 |
+
if (!is_multisite() || current_user_can('manage_network_users')) {
|
18 |
+
$anchor_start = '<a href="' . wp_nonce_url("user-edit.php?user_id={$this->user_to_edit->ID}",
|
19 |
+
"ure_user_{$this->user_to_edit->ID}") .'" >';
|
20 |
+
$anchor_end = '</a>';
|
21 |
+
} else {
|
22 |
+
$anchor_start = '';
|
23 |
+
$anchor_end = '';
|
24 |
+
}
|
25 |
+
$user_info = ' <span style="font-weight: bold;">'.$anchor_start. $this->user_to_edit->user_login;
|
26 |
+
if ($this->user_to_edit->display_name!==$this->user_to_edit->user_login) {
|
27 |
+
$user_info .= ' ('.$this->user_to_edit->display_name.')';
|
28 |
}
|
29 |
+
$user_info .= $anchor_end.'</span>';
|
30 |
+
$this->display_box_start(__('Change capabilities for user', 'ure').$user_info, 'min-width:810px;');
|
31 |
|
32 |
?>
|
33 |
<table cellpadding="0" cellspacing="0">
|
35 |
<td> </td>
|
36 |
<td style="padding-left: 10px; padding-bottom: 5px;">
|
37 |
<?php
|
38 |
+
if ($this->caps_readable) {
|
39 |
$checked = 'checked="checked"';
|
40 |
} else {
|
41 |
$checked = '';
|
42 |
}
|
43 |
?>
|
44 |
|
45 |
+
<input type="checkbox" name="ure_caps_readable" id="ure_caps_readable" value="1"
|
46 |
+
<?php echo $checked; ?> onclick="ure_turn_caps_readable(<?php echo $this->user_to_edit->ID; ?>);" />
|
47 |
<label for="ure_caps_readable"><?php _e('Show capabilities in human readable form', 'ure'); ?></label>
|
48 |
<?php
|
49 |
+
if ($this->show_deprecated_caps) {
|
50 |
$checked = 'checked="checked"';
|
51 |
} else {
|
52 |
$checked = '';
|
53 |
}
|
54 |
?>
|
55 |
+
<input type="checkbox" name="ure_show_deprecated_caps" id="ure_show_deprecated_caps" value="1"
|
56 |
+
<?php echo $checked; ?> onclick="ure_turn_deprecated_caps(<?php echo $this->user_to_edit->ID; ?>);"/>
|
57 |
<label for="ure_show_deprecated_caps"><?php _e('Show deprecated capabilities', 'ure'); ?></label>
|
58 |
</td>
|
59 |
</tr>
|
61 |
<td class="ure-user-roles">
|
62 |
<div style="margin-bottom: 5px; font-weight: bold;"><?php echo __('Primary Role:', 'ure'); ?></div>
|
63 |
<?php
|
64 |
+
$primary_role = array_shift(array_values($this->user_to_edit->roles)); // get 1st element from roles array
|
65 |
+
if (!empty($primary_role) && isset($this->roles[$primary_role])) {
|
66 |
+
echo $this->roles[$primary_role]['name'];
|
67 |
} else {
|
68 |
echo 'None';
|
69 |
}
|
73 |
<?php
|
74 |
// Get the roles
|
75 |
$dynamic_roles = bbp_get_dynamic_roles();
|
76 |
+
$bbp_user_role = bbp_get_user_role($this->user_to_edit->ID);
|
77 |
if (!empty($bbp_user_role)) {
|
78 |
echo $dynamic_roles[$bbp_user_role]['name'];
|
79 |
}
|
81 |
?>
|
82 |
<div style="margin-top: 5px;margin-bottom: 5px; font-weight: bold;"><?php echo __('Other Roles:', 'ure'); ?></div>
|
83 |
<?php
|
84 |
+
$you_are_admin = defined('URE_SHOW_ADMIN_ROLE') && $this->user_is_admin();
|
85 |
+
foreach ($this->roles as $role_id => $role) {
|
86 |
+
if ( ($you_are_admin || $role_id!='administrator') && ($role_id!==$primary_role) ) {
|
87 |
+
if ( user_can( $this->user_to_edit->ID, $role_id ) ) {
|
88 |
$checked = 'checked="checked"';
|
89 |
} else {
|
90 |
$checked = '';
|
91 |
}
|
92 |
+
echo '<label for="wp_role_' . $role_id .'"><input type="checkbox" id="wp_role_' . $role_id .
|
93 |
+
'" name="wp_role_' . $role_id . '" value="' . $role_id . '"' . $checked .' /> ' .
|
94 |
+
__($role['name'], 'ure') . '</label><br />';
|
95 |
}
|
96 |
}
|
97 |
?>
|
101 |
<table class="form-table" style="clear:none;" cellpadding="0" cellspacing="0">
|
102 |
<tr>
|
103 |
<td style="vertical-align:top;">
|
104 |
+
<?php $this->show_capabilities( true, false ); ?>
|
105 |
</td>
|
106 |
<td>
|
107 |
+
<?php $this->toolbar();?>
|
108 |
</td>
|
109 |
</tr>
|
110 |
</table>
|
111 |
<?php
|
112 |
+
$quant = count( $this->full_capabilities ) - count( $this->get_built_in_wp_caps() );
|
113 |
if ($quant>0) {
|
114 |
?>
|
115 |
<span style="font-weight: bold;"><?php _e('Custom capabilities:', 'ure'); ?></span>
|
116 |
<table class="form-table" style="clear:none;" cellpadding="0" cellspacing="0">
|
117 |
<tr>
|
118 |
<td style="vertical-align:top;">
|
119 |
+
<?php $this->show_capabilities( false, false ); ?>
|
120 |
</td>
|
121 |
</tr>
|
122 |
</table>
|
127 |
</tr>
|
128 |
</table>
|
129 |
<input type="hidden" name="object" value="user" />
|
130 |
+
<input type="hidden" name="user_id" value="<?php echo $this->user_to_edit->ID; ?>" />
|
131 |
<?php
|
132 |
+
$this->display_box_end();
|
133 |
?>
|
134 |
|
135 |
+
</div>
|
|
js/ure-js.js
CHANGED
@@ -60,7 +60,7 @@ jQuery(function() {
|
|
60 |
jQuery("#ure_add_role").button({
|
61 |
label: ure_data.add_role
|
62 |
}).click(function(event){
|
63 |
-
|
64 |
jQuery(function($) {
|
65 |
$info = $('#ure_add_role_dialog');
|
66 |
$info.dialog({
|
@@ -68,12 +68,12 @@ jQuery("#ure_add_role").button({
|
|
68 |
modal: true,
|
69 |
autoOpen: true,
|
70 |
closeOnEscape: true,
|
71 |
-
width:
|
72 |
-
height:
|
73 |
resizable: false,
|
74 |
title: ure_data.add_new_role_title,
|
75 |
'buttons' : {
|
76 |
-
'Add Role': function () {
|
77 |
var role_id = $('#user_role_id').val();
|
78 |
if (role_id == '') {
|
79 |
alert( ure_data.role_name_required );
|
@@ -93,6 +93,7 @@ jQuery("#ure_add_role").button({
|
|
93 |
},
|
94 |
'Cancel': function() {
|
95 |
$(this).dialog('close');
|
|
|
96 |
}
|
97 |
}
|
98 |
});
|
@@ -152,7 +153,7 @@ jQuery("#ure_add_role").button({
|
|
152 |
modal: true,
|
153 |
autoOpen: true,
|
154 |
closeOnEscape: true,
|
155 |
-
width:
|
156 |
height: 190,
|
157 |
resizable: false,
|
158 |
title: ure_data.add_capability,
|
60 |
jQuery("#ure_add_role").button({
|
61 |
label: ure_data.add_role
|
62 |
}).click(function(event){
|
63 |
+
event.preventDefault();
|
64 |
jQuery(function($) {
|
65 |
$info = $('#ure_add_role_dialog');
|
66 |
$info.dialog({
|
68 |
modal: true,
|
69 |
autoOpen: true,
|
70 |
closeOnEscape: true,
|
71 |
+
width: 350,
|
72 |
+
height: 200,
|
73 |
resizable: false,
|
74 |
title: ure_data.add_new_role_title,
|
75 |
'buttons' : {
|
76 |
+
'Add Role': function () {
|
77 |
var role_id = $('#user_role_id').val();
|
78 |
if (role_id == '') {
|
79 |
alert( ure_data.role_name_required );
|
93 |
},
|
94 |
'Cancel': function() {
|
95 |
$(this).dialog('close');
|
96 |
+
return false;
|
97 |
}
|
98 |
}
|
99 |
});
|
153 |
modal: true,
|
154 |
autoOpen: true,
|
155 |
closeOnEscape: true,
|
156 |
+
width: 350,
|
157 |
height: 190,
|
158 |
resizable: false,
|
159 |
title: ure_data.add_capability,
|
lang/ure-ca.mo
ADDED
Binary file
|
lang/ure-ca.po
ADDED
@@ -0,0 +1,752 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: User Role Editor v. 2.0\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2013-05-17 11:12+0700\n"
|
6 |
+
"PO-Revision-Date: \n"
|
7 |
+
"Last-Translator: Efraim Bayarri <efraim.bayarri@gmail.com>\n"
|
8 |
+
"Language-Team: ShinePHP.com <vladimir@shinephp.com>\n"
|
9 |
+
"Language: \n"
|
10 |
+
"MIME-Version: 1.0\n"
|
11 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
+
"Content-Transfer-Encoding: 8bit\n"
|
13 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
14 |
+
"X-Poedit-Language: Spanish\n"
|
15 |
+
"X-Poedit-Country: RUSSIAN FEDERATION\n"
|
16 |
+
"X-Poedit-SourceCharset: utf-8\n"
|
17 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
|
18 |
+
"X-Poedit-Basepath: ../../\n"
|
19 |
+
"X-Textdomain-Support: yes\n"
|
20 |
+
"X-Poedit-SearchPath-0: user-role-editor\n"
|
21 |
+
|
22 |
+
# @ ure
|
23 |
+
#: ../user-role-editor.php:34
|
24 |
+
#, php-format
|
25 |
+
msgid "User Role Editor requires PHP %s or newer."
|
26 |
+
msgstr "User Role Editor requereix PHP %s o mes"
|
27 |
+
|
28 |
+
# @ ure
|
29 |
+
#: ../user-role-editor.php:35
|
30 |
+
#: ../user-role-editor.php:107
|
31 |
+
msgid "Please update!"
|
32 |
+
msgstr "Si us plau actualitza!"
|
33 |
+
|
34 |
+
# @ ure
|
35 |
+
#: ../user-role-editor.php:80
|
36 |
+
msgid "Only"
|
37 |
+
msgstr "Només"
|
38 |
+
|
39 |
+
# @ ure
|
40 |
+
#: ../user-role-editor.php:80
|
41 |
+
msgid "is allowed to use"
|
42 |
+
msgstr "se li permet utilitzar"
|
43 |
+
|
44 |
+
# @ ure
|
45 |
+
# @ default
|
46 |
+
#: ../user-role-editor.php:86
|
47 |
+
#: ../user-role-editor.php:312
|
48 |
+
#: ../user-role-editor.php:368
|
49 |
+
msgid "User Role Editor"
|
50 |
+
msgstr "User Role Editor"
|
51 |
+
|
52 |
+
# @ ure
|
53 |
+
#: ../user-role-editor.php:106
|
54 |
+
#, php-format
|
55 |
+
msgid "User Role Editor requires WordPress %s or newer."
|
56 |
+
msgstr "User Role Editor requereix Wordpress %s o més"
|
57 |
+
|
58 |
+
# @ ure
|
59 |
+
#: ../user-role-editor.php:139
|
60 |
+
msgid "Select All"
|
61 |
+
msgstr "Seleccionar-ho tot"
|
62 |
+
|
63 |
+
#: ../user-role-editor.php:140
|
64 |
+
msgid "Unselect All"
|
65 |
+
msgstr "De-selecciona-ho tot"
|
66 |
+
|
67 |
+
#: ../user-role-editor.php:141
|
68 |
+
msgid "Reverse"
|
69 |
+
msgstr "Invertir"
|
70 |
+
|
71 |
+
# @ ure
|
72 |
+
#: ../user-role-editor.php:142
|
73 |
+
msgid "Update"
|
74 |
+
msgstr "Actualitzar"
|
75 |
+
|
76 |
+
# @ ure
|
77 |
+
#: ../user-role-editor.php:143
|
78 |
+
msgid "Please confirm permissions update"
|
79 |
+
msgstr "Si us plau confirmeu l'actualització de permisos "
|
80 |
+
|
81 |
+
# @ ure
|
82 |
+
#: ../user-role-editor.php:144
|
83 |
+
msgid "Add New Role"
|
84 |
+
msgstr "Afegir nou Rol"
|
85 |
+
|
86 |
+
# @ ure
|
87 |
+
#: ../user-role-editor.php:145
|
88 |
+
msgid " Role name (ID) can not be empty!"
|
89 |
+
msgstr "El nom de rol (ID) no pot estar buit!"
|
90 |
+
|
91 |
+
# @ ure
|
92 |
+
#: ../user-role-editor.php:146
|
93 |
+
msgid " Role name (ID) must contain latin characters, digits, hyphens or underscore only!"
|
94 |
+
msgstr "Error: nom del rol (ID) ha de tenir només lletres llatines i dígits!"
|
95 |
+
|
96 |
+
# @ ure
|
97 |
+
#: ../user-role-editor.php:147
|
98 |
+
msgid "Add Role"
|
99 |
+
msgstr "Afegir nou Rol"
|
100 |
+
|
101 |
+
# @ ure
|
102 |
+
#: ../user-role-editor.php:148
|
103 |
+
msgid "Delete Role"
|
104 |
+
msgstr "Eliminar Rol"
|
105 |
+
|
106 |
+
# @ ure
|
107 |
+
#: ../user-role-editor.php:149
|
108 |
+
msgid "Cancel"
|
109 |
+
msgstr "Cancel·lar"
|
110 |
+
|
111 |
+
# @ ure
|
112 |
+
#: ../user-role-editor.php:150
|
113 |
+
msgid "Add Capability"
|
114 |
+
msgstr "Afegir nou privilegi"
|
115 |
+
|
116 |
+
# @ ure
|
117 |
+
#: ../user-role-editor.php:151
|
118 |
+
#: ../user-role-editor.php:156
|
119 |
+
msgid "Delete Capability"
|
120 |
+
msgstr "Eliminar privilegi"
|
121 |
+
|
122 |
+
# @ ure
|
123 |
+
#: ../user-role-editor.php:152
|
124 |
+
msgid "Reset"
|
125 |
+
msgstr "Reiniciar"
|
126 |
+
|
127 |
+
#: ../user-role-editor.php:153
|
128 |
+
msgid "Reset Roles to WordPress defaults. Be careful, all changes made by you or plugins will be lost. Some plugins, e.g. S2Member, WooCommerce reactivation could be needed. Continue?"
|
129 |
+
msgstr "Restableix funcions als valors per defecte de WordPress. Aneu amb compte, tots els canvis realitzats per vostè o per connectors es perdran. Alguns connectors, per exemple, S2Member, WooCommerce, podrian necessitar una reactivació. Continuar?"
|
130 |
+
|
131 |
+
# @ ure
|
132 |
+
#: ../user-role-editor.php:154
|
133 |
+
msgid "Default Role"
|
134 |
+
msgstr "Rol predeterminat"
|
135 |
+
|
136 |
+
# @ ure
|
137 |
+
#: ../user-role-editor.php:155
|
138 |
+
msgid "Set New Default Role"
|
139 |
+
msgstr "Assignar com a rol predeterminat"
|
140 |
+
|
141 |
+
# @ ure
|
142 |
+
#: ../user-role-editor.php:157
|
143 |
+
msgid "Warning! Be careful - removing critical capability could crash some plugin or other custom code"
|
144 |
+
msgstr "Advertència! Vés amb compte - Remoure privilegis crítics podria inutilitzar algun connector o algun altre codi personalitzat."
|
145 |
+
|
146 |
+
# @ ure
|
147 |
+
#: ../user-role-editor.php:158
|
148 |
+
msgid " Capability name (ID) can not be empty!"
|
149 |
+
msgstr "El nom de priviliegi (ID) no pot estar buit!"
|
150 |
+
|
151 |
+
# @ ure
|
152 |
+
#: ../user-role-editor.php:159
|
153 |
+
msgid " Capability name (ID) must contain latin characters, digits, hyphens or underscore only!"
|
154 |
+
msgstr "Error: el nom del privilegi (ID) només ha de contenir caràcters llatins i dígits."
|
155 |
+
|
156 |
+
# @ ure
|
157 |
+
#: ../user-role-editor.php:284
|
158 |
+
msgid "Settings"
|
159 |
+
msgstr "Opcions"
|
160 |
+
|
161 |
+
# @ ure
|
162 |
+
#: ../user-role-editor.php:294
|
163 |
+
#: ../includes/ure-options.php:209
|
164 |
+
msgid "Changelog"
|
165 |
+
msgstr "Registre de canvis"
|
166 |
+
|
167 |
+
# @ ure
|
168 |
+
#: ../user-role-editor.php:342
|
169 |
+
msgid "Capabilities"
|
170 |
+
msgstr "Capacitats"
|
171 |
+
|
172 |
+
# @ ure
|
173 |
+
#: ../user-role-editor.php:371
|
174 |
+
#: ../user-role-editor.php:407
|
175 |
+
msgid "Other Roles"
|
176 |
+
msgstr "Altres rols"
|
177 |
+
|
178 |
+
# @ ure
|
179 |
+
#: ../user-role-editor.php:381
|
180 |
+
msgid "Edit"
|
181 |
+
msgstr "Editar"
|
182 |
+
|
183 |
+
# ure
|
184 |
+
#: ../includes/ure-lib.php:35
|
185 |
+
msgid "Error is occur. Please check the log file."
|
186 |
+
msgstr "Ha ocorregut un error. Si us plau revisa l'arxiu de registres."
|
187 |
+
|
188 |
+
# @ ure
|
189 |
+
#: ../includes/ure-lib.php:364
|
190 |
+
msgid "Backup record is created for the current role capabilities"
|
191 |
+
msgstr "Ha estat creada una còpia de seguretat per a aquest Rol i els seus privilegis"
|
192 |
+
|
193 |
+
# @ ure
|
194 |
+
#: ../includes/ure-lib.php:481
|
195 |
+
msgid "Error: Role ID must contain latin characters, digits, hyphens or underscore only!"
|
196 |
+
msgstr "Error: nom del rol (ID) ha de tenir només lletres llatines i dígits!"
|
197 |
+
|
198 |
+
# @ ure
|
199 |
+
#: ../includes/ure-lib.php:496
|
200 |
+
#, php-format
|
201 |
+
msgid "Role %s exists already"
|
202 |
+
msgstr "Rol %s ja existeix"
|
203 |
+
|
204 |
+
# @ ure
|
205 |
+
#: ../includes/ure-lib.php:511
|
206 |
+
msgid "Error is encountered during new role create operation"
|
207 |
+
msgstr "Error trobat durant la creació d'un nou Rol"
|
208 |
+
|
209 |
+
# @ ure
|
210 |
+
#: ../includes/ure-lib.php:513
|
211 |
+
#, php-format
|
212 |
+
msgid "Role %s is created successfully"
|
213 |
+
msgstr "Rol %s s'ha creat correctament"
|
214 |
+
|
215 |
+
# @ ure
|
216 |
+
#: ../includes/ure-lib.php:597
|
217 |
+
msgid "Error encountered during role delete operation"
|
218 |
+
msgstr "Error trobat durant l'eliminació del Rol"
|
219 |
+
|
220 |
+
# @ ure
|
221 |
+
#: ../includes/ure-lib.php:599
|
222 |
+
#, php-format
|
223 |
+
msgid "Role %s is deleted successfully"
|
224 |
+
msgstr "Rol %s s'elimina amb èxit"
|
225 |
+
|
226 |
+
# @ ure
|
227 |
+
#: ../includes/ure-lib.php:619
|
228 |
+
msgid "Error encountered during default role change operation"
|
229 |
+
msgstr "Error trobat durant el canvi de Rol per defecte"
|
230 |
+
|
231 |
+
# @ ure
|
232 |
+
#: ../includes/ure-lib.php:625
|
233 |
+
#, php-format
|
234 |
+
msgid "Default role for new users is set to %s successfully"
|
235 |
+
msgstr "Rol predeterminat per a nous usuaris està establert en %s amb èxit"
|
236 |
+
|
237 |
+
# @ ure
|
238 |
+
#: ../includes/ure-lib.php:652
|
239 |
+
msgid "Editor"
|
240 |
+
msgstr "Editor"
|
241 |
+
|
242 |
+
# @ ure
|
243 |
+
#: ../includes/ure-lib.php:653
|
244 |
+
msgid "Author"
|
245 |
+
msgstr "Autor"
|
246 |
+
|
247 |
+
# @ ure
|
248 |
+
#: ../includes/ure-lib.php:654
|
249 |
+
msgid "Contributor"
|
250 |
+
msgstr "Col·laborador"
|
251 |
+
|
252 |
+
# @ ure
|
253 |
+
#: ../includes/ure-lib.php:655
|
254 |
+
msgid "Subscriber"
|
255 |
+
msgstr "Subscriptor"
|
256 |
+
|
257 |
+
# @ ure
|
258 |
+
#: ../includes/ure-lib.php:657
|
259 |
+
msgid "Switch themes"
|
260 |
+
msgstr "Canviar plantilles"
|
261 |
+
|
262 |
+
# @ ure
|
263 |
+
#: ../includes/ure-lib.php:658
|
264 |
+
msgid "Edit themes"
|
265 |
+
msgstr "Editar plantilles"
|
266 |
+
|
267 |
+
# @ ure
|
268 |
+
#: ../includes/ure-lib.php:659
|
269 |
+
msgid "Activate plugins"
|
270 |
+
msgstr "Activar connectors"
|
271 |
+
|
272 |
+
# @ ure
|
273 |
+
#: ../includes/ure-lib.php:660
|
274 |
+
msgid "Edit plugins"
|
275 |
+
msgstr "Editar connectors"
|
276 |
+
|
277 |
+
# @ ure
|
278 |
+
#: ../includes/ure-lib.php:661
|
279 |
+
msgid "Edit users"
|
280 |
+
msgstr "Editar usuaris"
|
281 |
+
|
282 |
+
# @ ure
|
283 |
+
#: ../includes/ure-lib.php:662
|
284 |
+
msgid "Edit files"
|
285 |
+
msgstr "Editar arxius"
|
286 |
+
|
287 |
+
# @ ure
|
288 |
+
#: ../includes/ure-lib.php:663
|
289 |
+
msgid "Manage options"
|
290 |
+
msgstr "Administrar opcions"
|
291 |
+
|
292 |
+
# @ ure
|
293 |
+
#: ../includes/ure-lib.php:664
|
294 |
+
msgid "Moderate comments"
|
295 |
+
msgstr "Moderar comentaris"
|
296 |
+
|
297 |
+
# @ ure
|
298 |
+
#: ../includes/ure-lib.php:665
|
299 |
+
msgid "Manage categories"
|
300 |
+
msgstr "Administrar categories"
|
301 |
+
|
302 |
+
# @ ure
|
303 |
+
#: ../includes/ure-lib.php:666
|
304 |
+
msgid "Manage links"
|
305 |
+
msgstr "Administrar enllaços"
|
306 |
+
|
307 |
+
# @ ure
|
308 |
+
#: ../includes/ure-lib.php:667
|
309 |
+
msgid "Upload files"
|
310 |
+
msgstr "Pujar arxius"
|
311 |
+
|
312 |
+
# @ ure
|
313 |
+
#: ../includes/ure-lib.php:668
|
314 |
+
msgid "Import"
|
315 |
+
msgstr "Importar"
|
316 |
+
|
317 |
+
# @ ure
|
318 |
+
#: ../includes/ure-lib.php:669
|
319 |
+
msgid "Unfiltered html"
|
320 |
+
msgstr "Ometre Filtrat d'HTML"
|
321 |
+
|
322 |
+
# @ ure
|
323 |
+
#: ../includes/ure-lib.php:670
|
324 |
+
msgid "Edit posts"
|
325 |
+
msgstr "Editar missatges"
|
326 |
+
|
327 |
+
# @ ure
|
328 |
+
#: ../includes/ure-lib.php:671
|
329 |
+
msgid "Edit others posts"
|
330 |
+
msgstr "Editar missatges de altres"
|
331 |
+
|
332 |
+
# @ ure
|
333 |
+
#: ../includes/ure-lib.php:672
|
334 |
+
msgid "Edit published posts"
|
335 |
+
msgstr "Editar els missatges publicats"
|
336 |
+
|
337 |
+
# @ ure
|
338 |
+
#: ../includes/ure-lib.php:673
|
339 |
+
msgid "Publish posts"
|
340 |
+
msgstr "Publicar missatges"
|
341 |
+
|
342 |
+
# @ ure
|
343 |
+
#: ../includes/ure-lib.php:674
|
344 |
+
msgid "Edit pages"
|
345 |
+
msgstr "Editar pàgines"
|
346 |
+
|
347 |
+
# @ ure
|
348 |
+
#: ../includes/ure-lib.php:675
|
349 |
+
msgid "Read"
|
350 |
+
msgstr "Llegir"
|
351 |
+
|
352 |
+
# @ ure
|
353 |
+
#: ../includes/ure-lib.php:676
|
354 |
+
msgid "Level 10"
|
355 |
+
msgstr "Nivell 10"
|
356 |
+
|
357 |
+
# @ ure
|
358 |
+
#: ../includes/ure-lib.php:677
|
359 |
+
msgid "Level 9"
|
360 |
+
msgstr "Nivell 9"
|
361 |
+
|
362 |
+
# @ ure
|
363 |
+
#: ../includes/ure-lib.php:678
|
364 |
+
msgid "Level 8"
|
365 |
+
msgstr "Nivell 8"
|
366 |
+
|
367 |
+
# @ ure
|
368 |
+
#: ../includes/ure-lib.php:679
|
369 |
+
msgid "Level 7"
|
370 |
+
msgstr "Nivell 7"
|
371 |
+
|
372 |
+
# @ ure
|
373 |
+
#: ../includes/ure-lib.php:680
|
374 |
+
msgid "Level 6"
|
375 |
+
msgstr "Nivell 6"
|
376 |
+
|
377 |
+
# @ ure
|
378 |
+
#: ../includes/ure-lib.php:681
|
379 |
+
msgid "Level 5"
|
380 |
+
msgstr "Nivell 5"
|
381 |
+
|
382 |
+
# @ ure
|
383 |
+
#: ../includes/ure-lib.php:682
|
384 |
+
msgid "Level 4"
|
385 |
+
msgstr "Nivell 4"
|
386 |
+
|
387 |
+
# @ ure
|
388 |
+
#: ../includes/ure-lib.php:683
|
389 |
+
msgid "Level 3"
|
390 |
+
msgstr "Nivell 3"
|
391 |
+
|
392 |
+
# @ ure
|
393 |
+
#: ../includes/ure-lib.php:684
|
394 |
+
msgid "Level 2"
|
395 |
+
msgstr "Nivell 2"
|
396 |
+
|
397 |
+
# @ ure
|
398 |
+
#: ../includes/ure-lib.php:685
|
399 |
+
msgid "Level 1"
|
400 |
+
msgstr "Nivell 1"
|
401 |
+
|
402 |
+
# @ ure
|
403 |
+
#: ../includes/ure-lib.php:686
|
404 |
+
msgid "Level 0"
|
405 |
+
msgstr "Nivell 0"
|
406 |
+
|
407 |
+
# @ ure
|
408 |
+
#: ../includes/ure-lib.php:687
|
409 |
+
msgid "Edit others pages"
|
410 |
+
msgstr "Editar pàgines de altres"
|
411 |
+
|
412 |
+
# @ ure
|
413 |
+
#: ../includes/ure-lib.php:688
|
414 |
+
msgid "Edit published pages"
|
415 |
+
msgstr "Editar pàgines publicades"
|
416 |
+
|
417 |
+
# @ ure
|
418 |
+
#: ../includes/ure-lib.php:689
|
419 |
+
msgid "Publish pages"
|
420 |
+
msgstr "Publicar pàgines"
|
421 |
+
|
422 |
+
# @ ure
|
423 |
+
#: ../includes/ure-lib.php:690
|
424 |
+
msgid "Delete pages"
|
425 |
+
msgstr "Eliminar pàgines"
|
426 |
+
|
427 |
+
# ure
|
428 |
+
#: ../includes/ure-lib.php:691
|
429 |
+
msgid "Delete others pages"
|
430 |
+
msgstr "Eliminar pàgines de altres"
|
431 |
+
|
432 |
+
# @ ure
|
433 |
+
#: ../includes/ure-lib.php:692
|
434 |
+
msgid "Delete published pages"
|
435 |
+
msgstr "Eliminar pàgines publicades"
|
436 |
+
|
437 |
+
# ure
|
438 |
+
#: ../includes/ure-lib.php:693
|
439 |
+
msgid "Delete posts"
|
440 |
+
msgstr "Eliminar missatges"
|
441 |
+
|
442 |
+
# @ ure
|
443 |
+
#: ../includes/ure-lib.php:694
|
444 |
+
msgid "Delete others posts"
|
445 |
+
msgstr "Eliminar missatges de altres"
|
446 |
+
|
447 |
+
# ure
|
448 |
+
#: ../includes/ure-lib.php:695
|
449 |
+
msgid "Delete published posts"
|
450 |
+
msgstr "Eliminar missatges publicats"
|
451 |
+
|
452 |
+
# ure
|
453 |
+
#: ../includes/ure-lib.php:696
|
454 |
+
msgid "Delete private posts"
|
455 |
+
msgstr "Eliminar missatges privats"
|
456 |
+
|
457 |
+
# @ ure
|
458 |
+
#: ../includes/ure-lib.php:697
|
459 |
+
msgid "Edit private posts"
|
460 |
+
msgstr "Editar missatges privats"
|
461 |
+
|
462 |
+
# @ ure
|
463 |
+
#: ../includes/ure-lib.php:698
|
464 |
+
msgid "Read private posts"
|
465 |
+
msgstr "Llegir missatges privats"
|
466 |
+
|
467 |
+
# @ ure
|
468 |
+
#: ../includes/ure-lib.php:699
|
469 |
+
msgid "Delete private pages"
|
470 |
+
msgstr "Eliminar pàgines privades"
|
471 |
+
|
472 |
+
# @ ure
|
473 |
+
#: ../includes/ure-lib.php:700
|
474 |
+
msgid "Edit private pages"
|
475 |
+
msgstr "Editar pàgines privades"
|
476 |
+
|
477 |
+
# @ ure
|
478 |
+
#: ../includes/ure-lib.php:701
|
479 |
+
msgid "Read private pages"
|
480 |
+
msgstr "Llegir pàgines privades"
|
481 |
+
|
482 |
+
# @ ure
|
483 |
+
#: ../includes/ure-lib.php:702
|
484 |
+
msgid "Delete users"
|
485 |
+
msgstr "Eliminar usuaris"
|
486 |
+
|
487 |
+
# @ ure
|
488 |
+
#: ../includes/ure-lib.php:703
|
489 |
+
msgid "Create users"
|
490 |
+
msgstr "Crear usuaris"
|
491 |
+
|
492 |
+
# @ ure
|
493 |
+
#: ../includes/ure-lib.php:704
|
494 |
+
msgid "Unfiltered upload"
|
495 |
+
msgstr "Sense filtre de càrrega"
|
496 |
+
|
497 |
+
# @ ure
|
498 |
+
#: ../includes/ure-lib.php:705
|
499 |
+
msgid "Edit dashboard"
|
500 |
+
msgstr "Editar taulell"
|
501 |
+
|
502 |
+
# @ ure
|
503 |
+
#: ../includes/ure-lib.php:706
|
504 |
+
msgid "Update plugins"
|
505 |
+
msgstr "Actualitzar connectors"
|
506 |
+
|
507 |
+
# @ ure
|
508 |
+
#: ../includes/ure-lib.php:707
|
509 |
+
msgid "Delete plugins"
|
510 |
+
msgstr "Eliminar connectors"
|
511 |
+
|
512 |
+
# @ ure
|
513 |
+
#: ../includes/ure-lib.php:708
|
514 |
+
msgid "Install plugins"
|
515 |
+
msgstr "Instal·lar connectors"
|
516 |
+
|
517 |
+
# @ ure
|
518 |
+
#: ../includes/ure-lib.php:709
|
519 |
+
msgid "Update themes"
|
520 |
+
msgstr "Actualitzar plantilles"
|
521 |
+
|
522 |
+
# @ ure
|
523 |
+
#: ../includes/ure-lib.php:710
|
524 |
+
msgid "Install themes"
|
525 |
+
msgstr "Instal·lar plantilles"
|
526 |
+
|
527 |
+
# @ ure
|
528 |
+
#: ../includes/ure-lib.php:711
|
529 |
+
msgid "Update core"
|
530 |
+
msgstr "Actualitzar nucli"
|
531 |
+
|
532 |
+
# @ ure
|
533 |
+
#: ../includes/ure-lib.php:712
|
534 |
+
msgid "List users"
|
535 |
+
msgstr "Llistar usuaris"
|
536 |
+
|
537 |
+
# @ ure
|
538 |
+
#: ../includes/ure-lib.php:713
|
539 |
+
msgid "Remove users"
|
540 |
+
msgstr "Eliminar usuaris"
|
541 |
+
|
542 |
+
# @ ure
|
543 |
+
#: ../includes/ure-lib.php:714
|
544 |
+
msgid "Add users"
|
545 |
+
msgstr "Afegir usuaris"
|
546 |
+
|
547 |
+
# @ ure
|
548 |
+
#: ../includes/ure-lib.php:715
|
549 |
+
msgid "Promote users"
|
550 |
+
msgstr "Promoure usuaris"
|
551 |
+
|
552 |
+
# @ ure
|
553 |
+
#: ../includes/ure-lib.php:716
|
554 |
+
msgid "Edit theme options"
|
555 |
+
msgstr "Editar opcions de plantilla"
|
556 |
+
|
557 |
+
# @ ure
|
558 |
+
#: ../includes/ure-lib.php:717
|
559 |
+
msgid "Delete themes"
|
560 |
+
msgstr "Eliminar plantilles"
|
561 |
+
|
562 |
+
# @ ure
|
563 |
+
#: ../includes/ure-lib.php:718
|
564 |
+
msgid "Export"
|
565 |
+
msgstr "Exportar"
|
566 |
+
|
567 |
+
# @ ure
|
568 |
+
#: ../includes/ure-lib.php:834
|
569 |
+
msgid "Error: Capability name must contain latin characters and digits only!"
|
570 |
+
msgstr "Error: el nom del Privilegi només ha de contenir caràcters llatins i dígits."
|
571 |
+
|
572 |
+
# @ ure
|
573 |
+
#: ../includes/ure-lib.php:846
|
574 |
+
#, php-format
|
575 |
+
msgid "Capability %s is added successfully"
|
576 |
+
msgstr "Privilegi %s s'ha afegit correctament"
|
577 |
+
|
578 |
+
# @ ure
|
579 |
+
#: ../includes/ure-lib.php:848
|
580 |
+
#, php-format
|
581 |
+
msgid "Capability %s exists already"
|
582 |
+
msgstr "Ja existeix el privilegi %s"
|
583 |
+
|
584 |
+
# @ ure
|
585 |
+
#: ../includes/ure-lib.php:997
|
586 |
+
#, php-format
|
587 |
+
msgid "Error! You do not have permission to delete this capability: %s!"
|
588 |
+
msgstr "¡Error! No tens permisos per esborrar aquest privilegi: %s !"
|
589 |
+
|
590 |
+
# @ ure
|
591 |
+
#: ../includes/ure-lib.php:1016
|
592 |
+
#, php-format
|
593 |
+
msgid "Capability %s is removed successfully"
|
594 |
+
msgstr "El privilegi %s s'ha eliminat amb èxit"
|
595 |
+
|
596 |
+
# @ ure
|
597 |
+
#: ../includes/ure-lib.php:1083
|
598 |
+
msgid "Help"
|
599 |
+
msgstr "Ajuda"
|
600 |
+
|
601 |
+
# @ ure
|
602 |
+
#: ../includes/ure-role-edit.php:29
|
603 |
+
msgid "None"
|
604 |
+
msgstr "Cap"
|
605 |
+
|
606 |
+
# @ ure
|
607 |
+
#: ../includes/ure-role-edit.php:67
|
608 |
+
msgid "Select Role and change its capabilities list"
|
609 |
+
msgstr "Selecciona el Rol per canviar la seva llista de privilegis"
|
610 |
+
|
611 |
+
# @ ure
|
612 |
+
#: ../includes/ure-role-edit.php:69
|
613 |
+
#: ../includes/ure-role-edit.php:166
|
614 |
+
msgid "Select Role:"
|
615 |
+
msgstr "Selecciona el Rol:"
|
616 |
+
|
617 |
+
# @ ure
|
618 |
+
#: ../includes/ure-role-edit.php:79
|
619 |
+
#: ../includes/ure-user-edit.php:38
|
620 |
+
msgid "Show capabilities in human readable form"
|
621 |
+
msgstr "Mostra privilegis de forma llegible"
|
622 |
+
|
623 |
+
# @ ure
|
624 |
+
#: ../includes/ure-role-edit.php:88
|
625 |
+
#: ../includes/ure-user-edit.php:47
|
626 |
+
msgid "Show deprecated capabilities"
|
627 |
+
msgstr "Mostrar privilegis obsolets"
|
628 |
+
|
629 |
+
# @ default
|
630 |
+
#: ../includes/ure-role-edit.php:92
|
631 |
+
msgid "If checked, then apply action to ALL sites of this Network"
|
632 |
+
msgstr "Si està marcat s'aplica l'acció a TOTS els llocs d'aquesta xarxa"
|
633 |
+
|
634 |
+
# @ ure
|
635 |
+
#: ../includes/ure-role-edit.php:102
|
636 |
+
msgid "Apply to All Sites"
|
637 |
+
msgstr "Aplicar a tot arreu"
|
638 |
+
|
639 |
+
# @ ure
|
640 |
+
#: ../includes/ure-role-edit.php:109
|
641 |
+
#: ../includes/ure-user-edit.php:88
|
642 |
+
msgid "Core capabilities:"
|
643 |
+
msgstr "Privilegis"
|
644 |
+
|
645 |
+
# @ ure
|
646 |
+
#: ../includes/ure-role-edit.php:124
|
647 |
+
#: ../includes/ure-user-edit.php:103
|
648 |
+
msgid "Custom capabilities:"
|
649 |
+
msgstr "Privilegis personalitzats"
|
650 |
+
|
651 |
+
#: ../includes/ure-role-edit.php:155
|
652 |
+
msgid "Role name (ID): "
|
653 |
+
msgstr "Nom de rol (ID):"
|
654 |
+
|
655 |
+
#: ../includes/ure-role-edit.php:157
|
656 |
+
msgid "Display Role Name: "
|
657 |
+
msgstr "Visualització de nom de rol:"
|
658 |
+
|
659 |
+
# @ ure
|
660 |
+
#: ../includes/ure-role-edit.php:159
|
661 |
+
msgid "Make copy of: "
|
662 |
+
msgstr "Fer còpia de:"
|
663 |
+
|
664 |
+
# @ ure
|
665 |
+
#: ../includes/ure-role-edit.php:181
|
666 |
+
msgid "Delete:"
|
667 |
+
msgstr "Eliminar:"
|
668 |
+
|
669 |
+
#: ../includes/ure-role-edit.php:188
|
670 |
+
msgid "Capability name (ID): "
|
671 |
+
msgstr "Nom provolegi (ID):"
|
672 |
+
|
673 |
+
# @ ure
|
674 |
+
#: ../includes/ure-user-edit.php:22
|
675 |
+
msgid "Change capabilities for user"
|
676 |
+
msgstr "Canviar privilegis d'usuari"
|
677 |
+
|
678 |
+
#: ../includes/ure-user-edit.php:52
|
679 |
+
msgid "Primary Role:"
|
680 |
+
msgstr "Rol principal:"
|
681 |
+
|
682 |
+
#: ../includes/ure-user-edit.php:62
|
683 |
+
msgid "bbPress Role:"
|
684 |
+
msgstr "Rol bbPress:"
|
685 |
+
|
686 |
+
# @ ure
|
687 |
+
#: ../includes/ure-user-edit.php:72
|
688 |
+
msgid "Other Roles:"
|
689 |
+
msgstr "Altres rols:"
|
690 |
+
|
691 |
+
# @ ure
|
692 |
+
#: ../includes/ure-options.php:65
|
693 |
+
msgid "User Roles are restored to WordPress default values. "
|
694 |
+
msgstr "Els rols d'usuari es restableixen als valors predeterminats de WordPress."
|
695 |
+
|
696 |
+
# @ ure
|
697 |
+
#: ../includes/ure-options.php:136
|
698 |
+
msgid "Error: "
|
699 |
+
msgstr "Error:"
|
700 |
+
|
701 |
+
# @ ure
|
702 |
+
#: ../includes/ure-options.php:136
|
703 |
+
#: ../includes/ure-options.php:156
|
704 |
+
msgid "Role"
|
705 |
+
msgstr "Rol"
|
706 |
+
|
707 |
+
# @ ure
|
708 |
+
#: ../includes/ure-options.php:136
|
709 |
+
msgid "does not exist"
|
710 |
+
msgstr "no existeix"
|
711 |
+
|
712 |
+
# @ ure
|
713 |
+
#: ../includes/ure-options.php:156
|
714 |
+
msgid "is updated successfully"
|
715 |
+
msgstr "s'actualitzat correctament"
|
716 |
+
|
717 |
+
# @ ure
|
718 |
+
#: ../includes/ure-options.php:161
|
719 |
+
#: ../includes/ure-options.php:174
|
720 |
+
msgid "Error occured during role update"
|
721 |
+
msgstr "Error trobat durant l'actualització del rol"
|
722 |
+
|
723 |
+
# @ ure
|
724 |
+
#: ../includes/ure-options.php:169
|
725 |
+
msgid "User"
|
726 |
+
msgstr "Usuari"
|
727 |
+
|
728 |
+
# @ ure
|
729 |
+
#: ../includes/ure-options.php:169
|
730 |
+
msgid "capabilities are updated successfully"
|
731 |
+
msgstr "privilegis s'han actualitzat amb èxit"
|
732 |
+
|
733 |
+
# @ ure
|
734 |
+
#: ../includes/ure-options.php:206
|
735 |
+
msgid "About this Plugin:"
|
736 |
+
msgstr "Sobre aquest connector:"
|
737 |
+
|
738 |
+
# @ ure
|
739 |
+
#: ../includes/ure-options.php:207
|
740 |
+
msgid "Author's website"
|
741 |
+
msgstr "Lloc web del autor"
|
742 |
+
|
743 |
+
# @ ure
|
744 |
+
#: ../includes/ure-options.php:208
|
745 |
+
msgid "Plugin webpage"
|
746 |
+
msgstr "Pàgina web del connector"
|
747 |
+
|
748 |
+
# @ ure
|
749 |
+
#: ../includes/ure-options.php:210
|
750 |
+
msgid "FAQ"
|
751 |
+
msgstr "FAQ"
|
752 |
+
|
lang/ure-ru_RU.mo
CHANGED
Binary file
|
lang/ure-ru_RU.po
CHANGED
@@ -2,7 +2,7 @@ msgid ""
|
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: User Role Editor v.2.0\n"
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: 2013-
|
6 |
"PO-Revision-Date: \n"
|
7 |
"Last-Translator: Vladimir Garagulya <vladimir@shinephp.com>\n"
|
8 |
"Language-Team: ShinePHP.com <vladimir@shinephp.com>\n"
|
@@ -17,617 +17,621 @@ msgstr ""
|
|
17 |
"X-Poedit-Basepath: .\n"
|
18 |
"X-Poedit-SearchPath-0: ..\n"
|
19 |
|
20 |
-
#: ../user-role-editor.php:
|
21 |
-
|
22 |
-
|
23 |
-
msgstr "Редактор ролей пользователей требует PHP 5.0 или выше."
|
24 |
|
25 |
-
#: ../user-role-editor.php:
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
#: ../user-role-editor.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
msgid "Only"
|
32 |
msgstr "Только"
|
33 |
|
34 |
-
#: ../user-role-editor.php:
|
35 |
msgid "is allowed to use"
|
36 |
msgstr "разрешено использовать"
|
37 |
|
38 |
-
#: ../user-role-editor.php:
|
39 |
-
#: ../user-role-editor.php:312
|
40 |
-
#: ../user-role-editor.php:368
|
41 |
-
msgid "User Role Editor"
|
42 |
-
msgstr "Редактор ролей пользователей"
|
43 |
-
|
44 |
-
#: ../user-role-editor.php:106
|
45 |
-
#, fuzzy, php-format
|
46 |
-
msgid "User Role Editor requires WordPress %s or newer."
|
47 |
-
msgstr "Редактор ролей пользователей требует WordPress 3.0 или выше."
|
48 |
-
|
49 |
-
#: ../user-role-editor.php:139
|
50 |
msgid "Select All"
|
51 |
msgstr "Выбрать Все:"
|
52 |
|
53 |
-
#: ../user-role-editor.php:
|
54 |
msgid "Unselect All"
|
55 |
msgstr "Исключить все"
|
56 |
|
57 |
-
#: ../user-role-editor.php:
|
58 |
msgid "Reverse"
|
59 |
msgstr "Обратить"
|
60 |
|
61 |
-
#: ../user-role-editor.php:
|
62 |
msgid "Update"
|
63 |
msgstr "Сохранить"
|
64 |
|
65 |
-
#: ../user-role-editor.php:
|
66 |
-
#, fuzzy
|
67 |
msgid "Please confirm permissions update"
|
68 |
msgstr "Пожалуйста, подтвердите продолжение "
|
69 |
|
70 |
-
#: ../user-role-editor.php:
|
71 |
msgid "Add New Role"
|
72 |
msgstr "Добавить новую Роль"
|
73 |
|
74 |
-
#: ../user-role-editor.php:
|
75 |
-
#, fuzzy
|
76 |
msgid " Role name (ID) can not be empty!"
|
77 |
-
msgstr "
|
78 |
|
79 |
-
#: ../user-role-editor.php:
|
80 |
-
#, fuzzy
|
81 |
msgid " Role name (ID) must contain latin characters, digits, hyphens or underscore only!"
|
82 |
-
msgstr "Ошибка:
|
83 |
|
84 |
-
#: ../user-role-editor.php:
|
85 |
-
#, fuzzy
|
86 |
msgid "Add Role"
|
87 |
msgstr "Добавить новую Роль"
|
88 |
|
89 |
-
#: ../user-role-editor.php:
|
90 |
msgid "Delete Role"
|
91 |
msgstr "Удалить Роль"
|
92 |
|
93 |
-
#: ../user-role-editor.php:
|
94 |
msgid "Cancel"
|
95 |
msgstr "Отмена"
|
96 |
|
97 |
-
#: ../user-role-editor.php:
|
98 |
-
#, fuzzy
|
99 |
msgid "Add Capability"
|
100 |
msgstr "Добавить новую Возможность"
|
101 |
|
102 |
-
#: ../user-role-editor.php:
|
103 |
-
#: ../user-role-editor.php:
|
104 |
-
#, fuzzy
|
105 |
msgid "Delete Capability"
|
106 |
msgstr "Удалить Возможность"
|
107 |
|
108 |
-
#: ../user-role-editor.php:
|
109 |
msgid "Reset"
|
110 |
msgstr "Сброс"
|
111 |
|
112 |
-
#: ../user-role-editor.php:
|
113 |
msgid "Reset Roles to WordPress defaults. Be careful, all changes made by you or plugins will be lost. Some plugins, e.g. S2Member, WooCommerce reactivation could be needed. Continue?"
|
114 |
-
msgstr ""
|
115 |
|
116 |
-
#: ../user-role-editor.php:
|
117 |
-
#, fuzzy
|
118 |
msgid "Default Role"
|
119 |
-
msgstr "
|
120 |
|
121 |
-
#: ../user-role-editor.php:
|
122 |
-
#, fuzzy
|
123 |
msgid "Set New Default Role"
|
124 |
-
msgstr "Установить
|
125 |
|
126 |
-
#: ../user-role-editor.php:
|
127 |
msgid "Warning! Be careful - removing critical capability could crash some plugin or other custom code"
|
128 |
msgstr "Внимание! Будьте осторожны - удаление критичной возможности может привести к прекращеню работы одного из плагинов или другого кода."
|
129 |
|
130 |
-
#: ../user-role-editor.php:
|
131 |
-
#, fuzzy
|
132 |
msgid " Capability name (ID) can not be empty!"
|
133 |
-
msgstr "
|
134 |
|
135 |
-
#: ../user-role-editor.php:
|
136 |
-
#, fuzzy
|
137 |
msgid " Capability name (ID) must contain latin characters, digits, hyphens or underscore only!"
|
138 |
-
msgstr "Ошибка:
|
139 |
-
|
140 |
-
#: ../user-role-editor.php:284
|
141 |
-
msgid "Settings"
|
142 |
-
msgstr "Установки"
|
143 |
-
|
144 |
-
#: ../user-role-editor.php:294
|
145 |
-
#: ../includes/ure-options.php:209
|
146 |
-
msgid "Changelog"
|
147 |
-
msgstr "Журнал изменений"
|
148 |
-
|
149 |
-
#: ../user-role-editor.php:342
|
150 |
-
msgid "Capabilities"
|
151 |
-
msgstr "Возможности"
|
152 |
|
153 |
-
#: ../user-role-editor.php:
|
154 |
-
#: ../user-role-editor.php:
|
155 |
-
#, fuzzy
|
156 |
msgid "Other Roles"
|
157 |
-
msgstr "
|
158 |
|
159 |
-
#: ../user-role-editor.php:
|
160 |
-
#, fuzzy
|
161 |
msgid "Edit"
|
162 |
msgstr "Редактор"
|
163 |
|
164 |
-
#: ../includes/ure-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
msgid "Error is occur. Please check the log file."
|
166 |
msgstr "Произошла ошибка. Проверьте лог-файл."
|
167 |
|
168 |
-
#: ../includes/ure-lib.php:
|
169 |
-
msgid "Backup record is created for the current role capabilities"
|
170 |
-
msgstr "Для текущего распределения возможностей по ролям создана резервная копия"
|
171 |
-
|
172 |
-
#: ../includes/ure-lib.php:481
|
173 |
-
#, fuzzy
|
174 |
msgid "Error: Role ID must contain latin characters, digits, hyphens or underscore only!"
|
175 |
-
msgstr "Ошибка:
|
176 |
|
177 |
-
#: ../includes/ure-lib.php:
|
178 |
#, php-format
|
179 |
msgid "Role %s exists already"
|
180 |
msgstr "Роль %s уже существует"
|
181 |
|
182 |
-
#: ../includes/ure-lib.php:
|
183 |
msgid "Error is encountered during new role create operation"
|
184 |
msgstr "Произошла ошибка при создании новой роли"
|
185 |
|
186 |
-
#: ../includes/ure-lib.php:
|
187 |
#, php-format
|
188 |
msgid "Role %s is created successfully"
|
189 |
msgstr "Роль %s создана успешно"
|
190 |
|
191 |
-
#: ../includes/ure-lib.php:
|
192 |
msgid "Error encountered during role delete operation"
|
193 |
msgstr "Произошла ошибка при удалении роли"
|
194 |
|
195 |
-
#: ../includes/ure-lib.php:
|
196 |
#, php-format
|
197 |
msgid "Role %s is deleted successfully"
|
198 |
msgstr "Роль %s удалена успешно"
|
199 |
|
200 |
-
#: ../includes/ure-lib.php:
|
201 |
msgid "Error encountered during default role change operation"
|
202 |
msgstr "Произошла ошибка при изменении роли по-умолчанию"
|
203 |
|
204 |
-
#: ../includes/ure-lib.php:
|
205 |
#, php-format
|
206 |
msgid "Default role for new users is set to %s successfully"
|
207 |
msgstr "Роль по-умолчанию для новых пользователй изменена на %s успешно."
|
208 |
|
209 |
-
#: ../includes/ure-lib.php:
|
210 |
msgid "Editor"
|
211 |
msgstr "Редактор"
|
212 |
|
213 |
-
#: ../includes/ure-lib.php:
|
214 |
msgid "Author"
|
215 |
msgstr "Автор"
|
216 |
|
217 |
-
#: ../includes/ure-lib.php:
|
218 |
msgid "Contributor"
|
219 |
msgstr "Участник"
|
220 |
|
221 |
-
#: ../includes/ure-lib.php:
|
222 |
msgid "Subscriber"
|
223 |
msgstr "Подписчик"
|
224 |
|
225 |
-
#: ../includes/ure-lib.php:
|
226 |
msgid "Switch themes"
|
227 |
msgstr "Менять темы"
|
228 |
|
229 |
-
#: ../includes/ure-lib.php:
|
230 |
msgid "Edit themes"
|
231 |
msgstr "Изменять темы"
|
232 |
|
233 |
-
#: ../includes/ure-lib.php:
|
234 |
msgid "Activate plugins"
|
235 |
msgstr "Активировать плагины"
|
236 |
|
237 |
-
#: ../includes/ure-lib.php:
|
238 |
msgid "Edit plugins"
|
239 |
msgstr "Редактировать плагины"
|
240 |
|
241 |
-
#: ../includes/ure-lib.php:
|
242 |
msgid "Edit users"
|
243 |
msgstr "Изменять пользователей"
|
244 |
|
245 |
-
#: ../includes/ure-lib.php:
|
246 |
msgid "Edit files"
|
247 |
msgstr "Изменять файлы"
|
248 |
|
249 |
-
#: ../includes/ure-lib.php:
|
250 |
msgid "Manage options"
|
251 |
msgstr "Управлять установками"
|
252 |
|
253 |
-
#: ../includes/ure-lib.php:
|
254 |
msgid "Moderate comments"
|
255 |
msgstr "Модерировать комментарии"
|
256 |
|
257 |
-
#: ../includes/ure-lib.php:
|
258 |
msgid "Manage categories"
|
259 |
msgstr "Управлять категориями"
|
260 |
|
261 |
-
#: ../includes/ure-lib.php:
|
262 |
msgid "Manage links"
|
263 |
msgstr "Управлять ссылками"
|
264 |
|
265 |
-
#: ../includes/ure-lib.php:
|
266 |
msgid "Upload files"
|
267 |
msgstr "Загружать файлы"
|
268 |
|
269 |
-
#: ../includes/ure-lib.php:
|
270 |
msgid "Import"
|
271 |
msgstr "Импорт"
|
272 |
|
273 |
-
#: ../includes/ure-lib.php:
|
274 |
msgid "Unfiltered html"
|
275 |
msgstr "html без фильтра"
|
276 |
|
277 |
-
#: ../includes/ure-lib.php:
|
278 |
msgid "Edit posts"
|
279 |
msgstr "Изменять статьи"
|
280 |
|
281 |
-
#: ../includes/ure-lib.php:
|
282 |
msgid "Edit others posts"
|
283 |
msgstr "Изменять чужие статьи"
|
284 |
|
285 |
-
#: ../includes/ure-lib.php:
|
286 |
msgid "Edit published posts"
|
287 |
msgstr "Редактировать опубликованные статьи"
|
288 |
|
289 |
-
#: ../includes/ure-lib.php:
|
290 |
msgid "Publish posts"
|
291 |
msgstr "Публиковать статьи"
|
292 |
|
293 |
-
#: ../includes/ure-lib.php:
|
294 |
msgid "Edit pages"
|
295 |
msgstr "Изменять страницы"
|
296 |
|
297 |
-
#: ../includes/ure-lib.php:
|
298 |
msgid "Read"
|
299 |
msgstr "Чтение"
|
300 |
|
301 |
-
#: ../includes/ure-lib.php:
|
302 |
msgid "Level 10"
|
303 |
msgstr "Уровень 10"
|
304 |
|
305 |
-
#: ../includes/ure-lib.php:
|
306 |
msgid "Level 9"
|
307 |
msgstr "Уровень 9"
|
308 |
|
309 |
-
#: ../includes/ure-lib.php:
|
310 |
msgid "Level 8"
|
311 |
msgstr "Уровень 9"
|
312 |
|
313 |
-
#: ../includes/ure-lib.php:
|
314 |
msgid "Level 7"
|
315 |
msgstr "Уровень 7"
|
316 |
|
317 |
-
#: ../includes/ure-lib.php:
|
318 |
msgid "Level 6"
|
319 |
msgstr "Уровень 6"
|
320 |
|
321 |
-
#: ../includes/ure-lib.php:
|
322 |
msgid "Level 5"
|
323 |
msgstr "Уровень 5"
|
324 |
|
325 |
-
#: ../includes/ure-lib.php:
|
326 |
msgid "Level 4"
|
327 |
msgstr "Уровень 4"
|
328 |
|
329 |
-
#: ../includes/ure-lib.php:
|
330 |
msgid "Level 3"
|
331 |
msgstr "Уровень 3"
|
332 |
|
333 |
-
#: ../includes/ure-lib.php:
|
334 |
msgid "Level 2"
|
335 |
msgstr "Уровень 2"
|
336 |
|
337 |
-
#: ../includes/ure-lib.php:
|
338 |
msgid "Level 1"
|
339 |
msgstr "Уровень 1"
|
340 |
|
341 |
-
#: ../includes/ure-lib.php:
|
342 |
msgid "Level 0"
|
343 |
msgstr "Уровень 0"
|
344 |
|
345 |
-
#: ../includes/ure-lib.php:
|
346 |
msgid "Edit others pages"
|
347 |
msgstr "Редактировать чужие страницы"
|
348 |
|
349 |
-
#: ../includes/ure-lib.php:
|
350 |
msgid "Edit published pages"
|
351 |
msgstr "Редактировать опубликованные страницы"
|
352 |
|
353 |
-
#: ../includes/ure-lib.php:
|
354 |
msgid "Publish pages"
|
355 |
msgstr "Публиковать страницы"
|
356 |
|
357 |
-
#: ../includes/ure-lib.php:
|
358 |
msgid "Delete pages"
|
359 |
msgstr "Удалять страницы"
|
360 |
|
361 |
-
#: ../includes/ure-lib.php:
|
362 |
msgid "Delete others pages"
|
363 |
msgstr "Удалить чужие страницы"
|
364 |
|
365 |
-
#: ../includes/ure-lib.php:
|
366 |
msgid "Delete published pages"
|
367 |
msgstr "Удалять опубликованные страницы"
|
368 |
|
369 |
-
#: ../includes/ure-lib.php:
|
370 |
msgid "Delete posts"
|
371 |
msgstr "Удалять статьи"
|
372 |
|
373 |
-
#: ../includes/ure-lib.php:
|
374 |
msgid "Delete others posts"
|
375 |
msgstr "Удалять чужие статьи"
|
376 |
|
377 |
-
#: ../includes/ure-lib.php:
|
378 |
msgid "Delete published posts"
|
379 |
msgstr "Удалять опубликованные статьи"
|
380 |
|
381 |
-
#: ../includes/ure-lib.php:
|
382 |
msgid "Delete private posts"
|
383 |
msgstr "Удалять частные статьи"
|
384 |
|
385 |
-
#: ../includes/ure-lib.php:
|
386 |
msgid "Edit private posts"
|
387 |
msgstr "Редактировать частные статьи"
|
388 |
|
389 |
-
#: ../includes/ure-lib.php:
|
390 |
msgid "Read private posts"
|
391 |
msgstr "Читать частные статьи"
|
392 |
|
393 |
-
#: ../includes/ure-lib.php:
|
394 |
msgid "Delete private pages"
|
395 |
msgstr "Удалять частные страницы"
|
396 |
|
397 |
-
#: ../includes/ure-lib.php:
|
398 |
msgid "Edit private pages"
|
399 |
msgstr "Редактировать частные страницы"
|
400 |
|
401 |
-
#: ../includes/ure-lib.php:
|
402 |
msgid "Read private pages"
|
403 |
msgstr "Читать частные страницы"
|
404 |
|
405 |
-
#: ../includes/ure-lib.php:
|
406 |
msgid "Delete users"
|
407 |
msgstr "Удалять пользователей"
|
408 |
|
409 |
-
#: ../includes/ure-lib.php:
|
410 |
msgid "Create users"
|
411 |
msgstr "Создавать пользователей"
|
412 |
|
413 |
-
#: ../includes/ure-lib.php:
|
414 |
msgid "Unfiltered upload"
|
415 |
msgstr "Загрузка без фильтра"
|
416 |
|
417 |
-
#: ../includes/ure-lib.php:
|
418 |
msgid "Edit dashboard"
|
419 |
msgstr "Изменять панель администратора"
|
420 |
|
421 |
-
#: ../includes/ure-lib.php:
|
422 |
msgid "Update plugins"
|
423 |
msgstr "Обновлять плагины"
|
424 |
|
425 |
-
#: ../includes/ure-lib.php:
|
426 |
msgid "Delete plugins"
|
427 |
msgstr "Удалять плагины"
|
428 |
|
429 |
-
#: ../includes/ure-lib.php:
|
430 |
msgid "Install plugins"
|
431 |
msgstr "Устанавливать плагины"
|
432 |
|
433 |
-
#: ../includes/ure-lib.php:
|
434 |
msgid "Update themes"
|
435 |
msgstr "Обновлять темы"
|
436 |
|
437 |
-
#: ../includes/ure-lib.php:
|
438 |
msgid "Install themes"
|
439 |
msgstr "Устанавливать темы"
|
440 |
|
441 |
-
#: ../includes/ure-lib.php:
|
442 |
msgid "Update core"
|
443 |
msgstr "Обновлять ядро"
|
444 |
|
445 |
-
#: ../includes/ure-lib.php:
|
446 |
msgid "List users"
|
447 |
msgstr "Список пользователей"
|
448 |
|
449 |
-
#: ../includes/ure-lib.php:
|
450 |
msgid "Remove users"
|
451 |
msgstr "Удалять пользователей"
|
452 |
|
453 |
-
#: ../includes/ure-lib.php:
|
454 |
msgid "Add users"
|
455 |
msgstr "Добавлять пользователей"
|
456 |
|
457 |
-
#: ../includes/ure-lib.php:
|
458 |
msgid "Promote users"
|
459 |
msgstr "Продвигать пользователей"
|
460 |
|
461 |
-
#: ../includes/ure-lib.php:
|
462 |
msgid "Edit theme options"
|
463 |
msgstr "Изменять настройки темы"
|
464 |
|
465 |
-
#: ../includes/ure-lib.php:
|
466 |
msgid "Delete themes"
|
467 |
msgstr "Удалять темы"
|
468 |
|
469 |
-
#: ../includes/ure-lib.php:
|
470 |
msgid "Export"
|
471 |
msgstr "Экспорт"
|
472 |
|
473 |
-
#: ../includes/ure-lib.php:
|
474 |
msgid "Error: Capability name must contain latin characters and digits only!"
|
475 |
msgstr "Ошибка: Имя должно содержать только латинские буквы и цифры"
|
476 |
|
477 |
-
#: ../includes/ure-lib.php:
|
478 |
#, php-format
|
479 |
msgid "Capability %s is added successfully"
|
480 |
msgstr "Возможность %s добавлена успешно"
|
481 |
|
482 |
-
#: ../includes/ure-lib.php:
|
483 |
#, php-format
|
484 |
msgid "Capability %s exists already"
|
485 |
msgstr "Возможность %s уже существует"
|
486 |
|
487 |
-
#: ../includes/ure-lib.php:
|
488 |
#, php-format
|
489 |
msgid "Error! You do not have permission to delete this capability: %s!"
|
490 |
msgstr "Ошибка! Вам запрещено удалять эту возможность: %s!"
|
491 |
|
492 |
-
#: ../includes/ure-lib.php:
|
493 |
#, php-format
|
494 |
msgid "Capability %s is removed successfully"
|
495 |
msgstr "Возможность %s удалена успешно"
|
496 |
|
497 |
-
#: ../includes/ure-lib.php:
|
498 |
-
msgid "
|
499 |
-
msgstr "
|
500 |
-
|
501 |
-
#: ../includes/ure-role-edit.php:29
|
502 |
-
msgid "None"
|
503 |
-
msgstr "Нет"
|
504 |
-
|
505 |
-
#: ../includes/ure-role-edit.php:67
|
506 |
-
msgid "Select Role and change its capabilities list"
|
507 |
-
msgstr "Выбери Роль и измени список разрешённых операций"
|
508 |
-
|
509 |
-
#: ../includes/ure-role-edit.php:69
|
510 |
-
#: ../includes/ure-role-edit.php:166
|
511 |
-
msgid "Select Role:"
|
512 |
-
msgstr "Выбери Роль:"
|
513 |
-
|
514 |
-
#: ../includes/ure-role-edit.php:79
|
515 |
-
#: ../includes/ure-user-edit.php:38
|
516 |
-
msgid "Show capabilities in human readable form"
|
517 |
-
msgstr "Показ возможностей в читабельной форме"
|
518 |
-
|
519 |
-
#: ../includes/ure-role-edit.php:88
|
520 |
-
#: ../includes/ure-user-edit.php:47
|
521 |
-
msgid "Show deprecated capabilities"
|
522 |
-
msgstr "Показать устаревшие разрешения"
|
523 |
-
|
524 |
-
#: ../includes/ure-role-edit.php:92
|
525 |
-
msgid "If checked, then apply action to ALL sites of this Network"
|
526 |
-
msgstr "Если включено, применить ко всем сайтам этой Сети"
|
527 |
-
|
528 |
-
#: ../includes/ure-role-edit.php:102
|
529 |
-
msgid "Apply to All Sites"
|
530 |
-
msgstr "Применить ко всем сайтам"
|
531 |
-
|
532 |
-
#: ../includes/ure-role-edit.php:109
|
533 |
-
#: ../includes/ure-user-edit.php:88
|
534 |
-
msgid "Core capabilities:"
|
535 |
-
msgstr "Возможности ядра:"
|
536 |
-
|
537 |
-
#: ../includes/ure-role-edit.php:124
|
538 |
-
#: ../includes/ure-user-edit.php:103
|
539 |
-
msgid "Custom capabilities:"
|
540 |
-
msgstr "Дополнительные возможности :"
|
541 |
-
|
542 |
-
#: ../includes/ure-role-edit.php:155
|
543 |
-
msgid "Role name (ID): "
|
544 |
-
msgstr ""
|
545 |
|
546 |
-
#: ../includes/ure-
|
547 |
-
msgid "
|
548 |
-
msgstr ""
|
549 |
|
550 |
-
#: ../includes/ure-
|
551 |
-
msgid "
|
552 |
-
msgstr "
|
553 |
|
554 |
-
#: ../includes/ure-
|
555 |
-
|
556 |
-
|
557 |
-
msgstr "Удалить"
|
558 |
|
559 |
-
#: ../includes/ure-
|
560 |
-
msgid "
|
561 |
-
msgstr ""
|
562 |
|
563 |
-
#: ../includes/ure-user-edit.php:
|
564 |
msgid "Change capabilities for user"
|
565 |
msgstr "Изменить возможности для пользователя"
|
566 |
|
567 |
-
#: ../includes/ure-user-edit.php:
|
568 |
msgid "Primary Role:"
|
569 |
-
msgstr ""
|
570 |
|
571 |
-
#: ../includes/ure-user-edit.php:
|
572 |
msgid "bbPress Role:"
|
573 |
-
msgstr ""
|
574 |
|
575 |
-
#: ../includes/ure-user-edit.php:
|
576 |
-
#, fuzzy
|
577 |
msgid "Other Roles:"
|
578 |
-
msgstr "
|
579 |
-
|
580 |
-
#: ../includes/ure-options.php:65
|
581 |
-
#, fuzzy
|
582 |
-
msgid "User Roles are restored to WordPress default values. "
|
583 |
-
msgstr "Роли восстановлены из резервной копии"
|
584 |
-
|
585 |
-
#: ../includes/ure-options.php:136
|
586 |
-
msgid "Error: "
|
587 |
-
msgstr "Ошибка:"
|
588 |
|
589 |
-
|
590 |
-
|
591 |
-
msgid "Role"
|
592 |
-
msgstr "Роль"
|
593 |
|
594 |
-
|
595 |
-
|
596 |
-
msgstr "не существует"
|
597 |
|
598 |
-
|
599 |
-
|
600 |
-
msgstr "изменена успешно"
|
601 |
|
602 |
-
|
603 |
-
|
604 |
-
#, fuzzy
|
605 |
-
msgid "Error occured during role update"
|
606 |
-
msgstr "Произошла ошибка при удалении роли"
|
607 |
|
608 |
-
|
609 |
-
|
610 |
-
msgstr "Пользователь"
|
611 |
|
612 |
-
|
613 |
-
|
614 |
-
msgstr "возможности изменены успешно"
|
615 |
|
616 |
-
|
617 |
-
msgid "
|
618 |
-
msgstr "
|
619 |
|
620 |
-
|
621 |
-
|
622 |
-
msgstr "Вебсайт автора"
|
623 |
|
624 |
-
|
625 |
-
msgid "
|
626 |
-
msgstr "
|
627 |
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
|
632 |
#~ msgid "Database operation error. Check log file."
|
633 |
#~ msgstr "Ошибка работы с базой данных. Проверьте лог-файл."
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: User Role Editor v.2.0\n"
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2013-06-30 12:46+0700\n"
|
6 |
"PO-Revision-Date: \n"
|
7 |
"Last-Translator: Vladimir Garagulya <vladimir@shinephp.com>\n"
|
8 |
"Language-Team: ShinePHP.com <vladimir@shinephp.com>\n"
|
17 |
"X-Poedit-Basepath: .\n"
|
18 |
"X-Poedit-SearchPath-0: ..\n"
|
19 |
|
20 |
+
#: ../includes/class-user-role-editor.php:229
|
21 |
+
msgid "Capabilities"
|
22 |
+
msgstr "Возможности"
|
|
|
23 |
|
24 |
+
#: ../includes/class-user-role-editor.php:321
|
25 |
+
msgid "Settings"
|
26 |
+
msgstr "Установки"
|
27 |
+
|
28 |
+
#: ../includes/class-user-role-editor.php:334
|
29 |
+
#: ../includes/class-ure-lib.php:1803
|
30 |
+
msgid "Changelog"
|
31 |
+
msgstr "Журнал изменений"
|
32 |
|
33 |
+
#: ../includes/class-user-role-editor.php:348
|
34 |
+
#: ../includes/class-user-role-editor.php:466
|
35 |
+
#: ../includes/class-ure-lib.php:162
|
36 |
+
msgid "User Role Editor"
|
37 |
+
msgstr "Редактор ролей пользователей"
|
38 |
+
|
39 |
+
#: ../includes/class-user-role-editor.php:379
|
40 |
msgid "Only"
|
41 |
msgstr "Только"
|
42 |
|
43 |
+
#: ../includes/class-user-role-editor.php:379
|
44 |
msgid "is allowed to use"
|
45 |
msgstr "разрешено использовать"
|
46 |
|
47 |
+
#: ../includes/class-user-role-editor.php:423
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
msgid "Select All"
|
49 |
msgstr "Выбрать Все:"
|
50 |
|
51 |
+
#: ../includes/class-user-role-editor.php:424
|
52 |
msgid "Unselect All"
|
53 |
msgstr "Исключить все"
|
54 |
|
55 |
+
#: ../includes/class-user-role-editor.php:425
|
56 |
msgid "Reverse"
|
57 |
msgstr "Обратить"
|
58 |
|
59 |
+
#: ../includes/class-user-role-editor.php:426
|
60 |
msgid "Update"
|
61 |
msgstr "Сохранить"
|
62 |
|
63 |
+
#: ../includes/class-user-role-editor.php:427
|
|
|
64 |
msgid "Please confirm permissions update"
|
65 |
msgstr "Пожалуйста, подтвердите продолжение "
|
66 |
|
67 |
+
#: ../includes/class-user-role-editor.php:428
|
68 |
msgid "Add New Role"
|
69 |
msgstr "Добавить новую Роль"
|
70 |
|
71 |
+
#: ../includes/class-user-role-editor.php:429
|
|
|
72 |
msgid " Role name (ID) can not be empty!"
|
73 |
+
msgstr "Идентификатор роли (ID) не может быть пустым!"
|
74 |
|
75 |
+
#: ../includes/class-user-role-editor.php:430
|
|
|
76 |
msgid " Role name (ID) must contain latin characters, digits, hyphens or underscore only!"
|
77 |
+
msgstr "Ошибка: идентификатор роли может содержать только латинские буквы, цифры, тире и знак подчеркивания"
|
78 |
|
79 |
+
#: ../includes/class-user-role-editor.php:431
|
|
|
80 |
msgid "Add Role"
|
81 |
msgstr "Добавить новую Роль"
|
82 |
|
83 |
+
#: ../includes/class-user-role-editor.php:432
|
84 |
msgid "Delete Role"
|
85 |
msgstr "Удалить Роль"
|
86 |
|
87 |
+
#: ../includes/class-user-role-editor.php:433
|
88 |
msgid "Cancel"
|
89 |
msgstr "Отмена"
|
90 |
|
91 |
+
#: ../includes/class-user-role-editor.php:434
|
|
|
92 |
msgid "Add Capability"
|
93 |
msgstr "Добавить новую Возможность"
|
94 |
|
95 |
+
#: ../includes/class-user-role-editor.php:435
|
96 |
+
#: ../includes/class-user-role-editor.php:440
|
|
|
97 |
msgid "Delete Capability"
|
98 |
msgstr "Удалить Возможность"
|
99 |
|
100 |
+
#: ../includes/class-user-role-editor.php:436
|
101 |
msgid "Reset"
|
102 |
msgstr "Сброс"
|
103 |
|
104 |
+
#: ../includes/class-user-role-editor.php:437
|
105 |
msgid "Reset Roles to WordPress defaults. Be careful, all changes made by you or plugins will be lost. Some plugins, e.g. S2Member, WooCommerce reactivation could be needed. Continue?"
|
106 |
+
msgstr "Вернуть роли в начальное состояние. Будьте осторожны, все изменения в ролях, сделанные темой и плагинами, будут потеряны, необходимо будет активировать заново некоторые плагины, например S2Member, WooCommerce. Продолжить?"
|
107 |
|
108 |
+
#: ../includes/class-user-role-editor.php:438
|
|
|
109 |
msgid "Default Role"
|
110 |
+
msgstr "Роль по-умолчанию"
|
111 |
|
112 |
+
#: ../includes/class-user-role-editor.php:439
|
|
|
113 |
msgid "Set New Default Role"
|
114 |
+
msgstr "Установить новую роль по-умолчанию"
|
115 |
|
116 |
+
#: ../includes/class-user-role-editor.php:441
|
117 |
msgid "Warning! Be careful - removing critical capability could crash some plugin or other custom code"
|
118 |
msgstr "Внимание! Будьте осторожны - удаление критичной возможности может привести к прекращеню работы одного из плагинов или другого кода."
|
119 |
|
120 |
+
#: ../includes/class-user-role-editor.php:442
|
|
|
121 |
msgid " Capability name (ID) can not be empty!"
|
122 |
+
msgstr "Идентификатор возможности (ID) не может быть пустым!"
|
123 |
|
124 |
+
#: ../includes/class-user-role-editor.php:443
|
|
|
125 |
msgid " Capability name (ID) must contain latin characters, digits, hyphens or underscore only!"
|
126 |
+
msgstr "Ошибка: Наименование возможности должно содержать только латинские буквы и цифры, знаки подчеркивания"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
+
#: ../includes/class-user-role-editor.php:469
|
129 |
+
#: ../includes/class-user-role-editor.php:504
|
|
|
130 |
msgid "Other Roles"
|
131 |
+
msgstr "Другие Роли"
|
132 |
|
133 |
+
#: ../includes/class-user-role-editor.php:479
|
|
|
134 |
msgid "Edit"
|
135 |
msgstr "Редактор"
|
136 |
|
137 |
+
#: ../includes/ure-role-edit.php:17
|
138 |
+
msgid "Select Role and change its capabilities list"
|
139 |
+
msgstr "Выбери Роль и измени список разрешённых операций"
|
140 |
+
|
141 |
+
#: ../includes/ure-role-edit.php:19
|
142 |
+
#: ../includes/class-ure-lib.php:123
|
143 |
+
msgid "Select Role:"
|
144 |
+
msgstr "Выбери Роль:"
|
145 |
+
|
146 |
+
#: ../includes/ure-role-edit.php:30
|
147 |
+
#: ../includes/ure-user-edit.php:47
|
148 |
+
msgid "Show capabilities in human readable form"
|
149 |
+
msgstr "Показ возможностей в читабельной форме"
|
150 |
+
|
151 |
+
#: ../includes/ure-role-edit.php:40
|
152 |
+
#: ../includes/ure-user-edit.php:57
|
153 |
+
msgid "Show deprecated capabilities"
|
154 |
+
msgstr "Показать устаревшие разрешения"
|
155 |
+
|
156 |
+
#: ../includes/ure-role-edit.php:44
|
157 |
+
msgid "If checked, then apply action to ALL sites of this Network"
|
158 |
+
msgstr "Если включено, применить ко всем сайтам этой Сети"
|
159 |
+
|
160 |
+
#: ../includes/ure-role-edit.php:56
|
161 |
+
msgid "Apply to All Sites"
|
162 |
+
msgstr "Применить ко всем сайтам"
|
163 |
+
|
164 |
+
#: ../includes/ure-role-edit.php:63
|
165 |
+
#: ../includes/ure-user-edit.php:100
|
166 |
+
msgid "Core capabilities:"
|
167 |
+
msgstr "Возможности ядра:"
|
168 |
+
|
169 |
+
#: ../includes/ure-role-edit.php:78
|
170 |
+
#: ../includes/ure-user-edit.php:115
|
171 |
+
msgid "Custom capabilities:"
|
172 |
+
msgstr "Дополнительные возможности :"
|
173 |
+
|
174 |
+
#: ../includes/class-ure-lib.php:80
|
175 |
+
msgid "Error: wrong request"
|
176 |
+
msgstr "Ошибка: неверный запрос"
|
177 |
+
|
178 |
+
#: ../includes/class-ure-lib.php:112
|
179 |
+
msgid "Role name (ID): "
|
180 |
+
msgstr "Идентификатор роли (ID):"
|
181 |
+
|
182 |
+
#: ../includes/class-ure-lib.php:114
|
183 |
+
msgid "Display Role Name: "
|
184 |
+
msgstr "Наименование роли:"
|
185 |
+
|
186 |
+
#: ../includes/class-ure-lib.php:116
|
187 |
+
msgid "Make copy of: "
|
188 |
+
msgstr "Создать копию из:"
|
189 |
+
|
190 |
+
#: ../includes/class-ure-lib.php:138
|
191 |
+
msgid "Delete:"
|
192 |
+
msgstr "Удалить"
|
193 |
+
|
194 |
+
#: ../includes/class-ure-lib.php:145
|
195 |
+
msgid "Capability name (ID): "
|
196 |
+
msgstr "Идентификатор возможности (ID):"
|
197 |
+
|
198 |
+
#: ../includes/class-ure-lib.php:229
|
199 |
+
msgid "Error: "
|
200 |
+
msgstr "Ошибка:"
|
201 |
+
|
202 |
+
#: ../includes/class-ure-lib.php:229
|
203 |
+
#: ../includes/class-ure-lib.php:272
|
204 |
+
msgid "Role"
|
205 |
+
msgstr "Роль"
|
206 |
+
|
207 |
+
#: ../includes/class-ure-lib.php:229
|
208 |
+
msgid "does not exist"
|
209 |
+
msgstr "не существует"
|
210 |
+
|
211 |
+
#: ../includes/class-ure-lib.php:273
|
212 |
+
msgid "is updated successfully"
|
213 |
+
msgstr "изменена успешно"
|
214 |
+
|
215 |
+
#: ../includes/class-ure-lib.php:278
|
216 |
+
msgid "Error occured during role update"
|
217 |
+
msgstr "При изменении роли произошла ошибка"
|
218 |
+
|
219 |
+
#: ../includes/class-ure-lib.php:286
|
220 |
+
msgid "User"
|
221 |
+
msgstr "Пользователь"
|
222 |
+
|
223 |
+
#: ../includes/class-ure-lib.php:287
|
224 |
+
msgid "capabilities are updated successfully"
|
225 |
+
msgstr "возможности изменены успешно"
|
226 |
+
|
227 |
+
#: ../includes/class-ure-lib.php:292
|
228 |
+
msgid "Error occured during user update"
|
229 |
+
msgstr "При изменении прав пользователя произошла ошибка "
|
230 |
+
|
231 |
+
#: ../includes/class-ure-lib.php:343
|
232 |
+
msgid "User Roles are restored to WordPress default values. "
|
233 |
+
msgstr "Роли возвращены к начальному состоянию"
|
234 |
+
|
235 |
+
#: ../includes/class-ure-lib.php:1101
|
236 |
+
msgid "Help"
|
237 |
+
msgstr "Помощь"
|
238 |
+
|
239 |
+
#: ../includes/class-ure-lib.php:1356
|
240 |
msgid "Error is occur. Please check the log file."
|
241 |
msgstr "Произошла ошибка. Проверьте лог-файл."
|
242 |
|
243 |
+
#: ../includes/class-ure-lib.php:1381
|
|
|
|
|
|
|
|
|
|
|
244 |
msgid "Error: Role ID must contain latin characters, digits, hyphens or underscore only!"
|
245 |
+
msgstr "Ошибка: идентификатор роли (ID) должен содержать только латинские буквы, цифры, знак подчеркивания и дефис."
|
246 |
|
247 |
+
#: ../includes/class-ure-lib.php:1396
|
248 |
#, php-format
|
249 |
msgid "Role %s exists already"
|
250 |
msgstr "Роль %s уже существует"
|
251 |
|
252 |
+
#: ../includes/class-ure-lib.php:1411
|
253 |
msgid "Error is encountered during new role create operation"
|
254 |
msgstr "Произошла ошибка при создании новой роли"
|
255 |
|
256 |
+
#: ../includes/class-ure-lib.php:1413
|
257 |
#, php-format
|
258 |
msgid "Role %s is created successfully"
|
259 |
msgstr "Роль %s создана успешно"
|
260 |
|
261 |
+
#: ../includes/class-ure-lib.php:1442
|
262 |
msgid "Error encountered during role delete operation"
|
263 |
msgstr "Произошла ошибка при удалении роли"
|
264 |
|
265 |
+
#: ../includes/class-ure-lib.php:1444
|
266 |
#, php-format
|
267 |
msgid "Role %s is deleted successfully"
|
268 |
msgstr "Роль %s удалена успешно"
|
269 |
|
270 |
+
#: ../includes/class-ure-lib.php:1469
|
271 |
msgid "Error encountered during default role change operation"
|
272 |
msgstr "Произошла ошибка при изменении роли по-умолчанию"
|
273 |
|
274 |
+
#: ../includes/class-ure-lib.php:1475
|
275 |
#, php-format
|
276 |
msgid "Default role for new users is set to %s successfully"
|
277 |
msgstr "Роль по-умолчанию для новых пользователй изменена на %s успешно."
|
278 |
|
279 |
+
#: ../includes/class-ure-lib.php:1494
|
280 |
msgid "Editor"
|
281 |
msgstr "Редактор"
|
282 |
|
283 |
+
#: ../includes/class-ure-lib.php:1495
|
284 |
msgid "Author"
|
285 |
msgstr "Автор"
|
286 |
|
287 |
+
#: ../includes/class-ure-lib.php:1496
|
288 |
msgid "Contributor"
|
289 |
msgstr "Участник"
|
290 |
|
291 |
+
#: ../includes/class-ure-lib.php:1497
|
292 |
msgid "Subscriber"
|
293 |
msgstr "Подписчик"
|
294 |
|
295 |
+
#: ../includes/class-ure-lib.php:1499
|
296 |
msgid "Switch themes"
|
297 |
msgstr "Менять темы"
|
298 |
|
299 |
+
#: ../includes/class-ure-lib.php:1500
|
300 |
msgid "Edit themes"
|
301 |
msgstr "Изменять темы"
|
302 |
|
303 |
+
#: ../includes/class-ure-lib.php:1501
|
304 |
msgid "Activate plugins"
|
305 |
msgstr "Активировать плагины"
|
306 |
|
307 |
+
#: ../includes/class-ure-lib.php:1502
|
308 |
msgid "Edit plugins"
|
309 |
msgstr "Редактировать плагины"
|
310 |
|
311 |
+
#: ../includes/class-ure-lib.php:1503
|
312 |
msgid "Edit users"
|
313 |
msgstr "Изменять пользователей"
|
314 |
|
315 |
+
#: ../includes/class-ure-lib.php:1504
|
316 |
msgid "Edit files"
|
317 |
msgstr "Изменять файлы"
|
318 |
|
319 |
+
#: ../includes/class-ure-lib.php:1505
|
320 |
msgid "Manage options"
|
321 |
msgstr "Управлять установками"
|
322 |
|
323 |
+
#: ../includes/class-ure-lib.php:1506
|
324 |
msgid "Moderate comments"
|
325 |
msgstr "Модерировать комментарии"
|
326 |
|
327 |
+
#: ../includes/class-ure-lib.php:1507
|
328 |
msgid "Manage categories"
|
329 |
msgstr "Управлять категориями"
|
330 |
|
331 |
+
#: ../includes/class-ure-lib.php:1508
|
332 |
msgid "Manage links"
|
333 |
msgstr "Управлять ссылками"
|
334 |
|
335 |
+
#: ../includes/class-ure-lib.php:1509
|
336 |
msgid "Upload files"
|
337 |
msgstr "Загружать файлы"
|
338 |
|
339 |
+
#: ../includes/class-ure-lib.php:1510
|
340 |
msgid "Import"
|
341 |
msgstr "Импорт"
|
342 |
|
343 |
+
#: ../includes/class-ure-lib.php:1511
|
344 |
msgid "Unfiltered html"
|
345 |
msgstr "html без фильтра"
|
346 |
|
347 |
+
#: ../includes/class-ure-lib.php:1512
|
348 |
msgid "Edit posts"
|
349 |
msgstr "Изменять статьи"
|
350 |
|
351 |
+
#: ../includes/class-ure-lib.php:1513
|
352 |
msgid "Edit others posts"
|
353 |
msgstr "Изменять чужие статьи"
|
354 |
|
355 |
+
#: ../includes/class-ure-lib.php:1514
|
356 |
msgid "Edit published posts"
|
357 |
msgstr "Редактировать опубликованные статьи"
|
358 |
|
359 |
+
#: ../includes/class-ure-lib.php:1515
|
360 |
msgid "Publish posts"
|
361 |
msgstr "Публиковать статьи"
|
362 |
|
363 |
+
#: ../includes/class-ure-lib.php:1516
|
364 |
msgid "Edit pages"
|
365 |
msgstr "Изменять страницы"
|
366 |
|
367 |
+
#: ../includes/class-ure-lib.php:1517
|
368 |
msgid "Read"
|
369 |
msgstr "Чтение"
|
370 |
|
371 |
+
#: ../includes/class-ure-lib.php:1518
|
372 |
msgid "Level 10"
|
373 |
msgstr "Уровень 10"
|
374 |
|
375 |
+
#: ../includes/class-ure-lib.php:1519
|
376 |
msgid "Level 9"
|
377 |
msgstr "Уровень 9"
|
378 |
|
379 |
+
#: ../includes/class-ure-lib.php:1520
|
380 |
msgid "Level 8"
|
381 |
msgstr "Уровень 9"
|
382 |
|
383 |
+
#: ../includes/class-ure-lib.php:1521
|
384 |
msgid "Level 7"
|
385 |
msgstr "Уровень 7"
|
386 |
|
387 |
+
#: ../includes/class-ure-lib.php:1522
|
388 |
msgid "Level 6"
|
389 |
msgstr "Уровень 6"
|
390 |
|
391 |
+
#: ../includes/class-ure-lib.php:1523
|
392 |
msgid "Level 5"
|
393 |
msgstr "Уровень 5"
|
394 |
|
395 |
+
#: ../includes/class-ure-lib.php:1524
|
396 |
msgid "Level 4"
|
397 |
msgstr "Уровень 4"
|
398 |
|
399 |
+
#: ../includes/class-ure-lib.php:1525
|
400 |
msgid "Level 3"
|
401 |
msgstr "Уровень 3"
|
402 |
|
403 |
+
#: ../includes/class-ure-lib.php:1526
|
404 |
msgid "Level 2"
|
405 |
msgstr "Уровень 2"
|
406 |
|
407 |
+
#: ../includes/class-ure-lib.php:1527
|
408 |
msgid "Level 1"
|
409 |
msgstr "Уровень 1"
|
410 |
|
411 |
+
#: ../includes/class-ure-lib.php:1528
|
412 |
msgid "Level 0"
|
413 |
msgstr "Уровень 0"
|
414 |
|
415 |
+
#: ../includes/class-ure-lib.php:1529
|
416 |
msgid "Edit others pages"
|
417 |
msgstr "Редактировать чужие страницы"
|
418 |
|
419 |
+
#: ../includes/class-ure-lib.php:1530
|
420 |
msgid "Edit published pages"
|
421 |
msgstr "Редактировать опубликованные страницы"
|
422 |
|
423 |
+
#: ../includes/class-ure-lib.php:1531
|
424 |
msgid "Publish pages"
|
425 |
msgstr "Публиковать страницы"
|
426 |
|
427 |
+
#: ../includes/class-ure-lib.php:1532
|
428 |
msgid "Delete pages"
|
429 |
msgstr "Удалять страницы"
|
430 |
|
431 |
+
#: ../includes/class-ure-lib.php:1533
|
432 |
msgid "Delete others pages"
|
433 |
msgstr "Удалить чужие страницы"
|
434 |
|
435 |
+
#: ../includes/class-ure-lib.php:1534
|
436 |
msgid "Delete published pages"
|
437 |
msgstr "Удалять опубликованные страницы"
|
438 |
|
439 |
+
#: ../includes/class-ure-lib.php:1535
|
440 |
msgid "Delete posts"
|
441 |
msgstr "Удалять статьи"
|
442 |
|
443 |
+
#: ../includes/class-ure-lib.php:1536
|
444 |
msgid "Delete others posts"
|
445 |
msgstr "Удалять чужие статьи"
|
446 |
|
447 |
+
#: ../includes/class-ure-lib.php:1537
|
448 |
msgid "Delete published posts"
|
449 |
msgstr "Удалять опубликованные статьи"
|
450 |
|
451 |
+
#: ../includes/class-ure-lib.php:1538
|
452 |
msgid "Delete private posts"
|
453 |
msgstr "Удалять частные статьи"
|
454 |
|
455 |
+
#: ../includes/class-ure-lib.php:1539
|
456 |
msgid "Edit private posts"
|
457 |
msgstr "Редактировать частные статьи"
|
458 |
|
459 |
+
#: ../includes/class-ure-lib.php:1540
|
460 |
msgid "Read private posts"
|
461 |
msgstr "Читать частные статьи"
|
462 |
|
463 |
+
#: ../includes/class-ure-lib.php:1541
|
464 |
msgid "Delete private pages"
|
465 |
msgstr "Удалять частные страницы"
|
466 |
|
467 |
+
#: ../includes/class-ure-lib.php:1542
|
468 |
msgid "Edit private pages"
|
469 |
msgstr "Редактировать частные страницы"
|
470 |
|
471 |
+
#: ../includes/class-ure-lib.php:1543
|
472 |
msgid "Read private pages"
|
473 |
msgstr "Читать частные страницы"
|
474 |
|
475 |
+
#: ../includes/class-ure-lib.php:1544
|
476 |
msgid "Delete users"
|
477 |
msgstr "Удалять пользователей"
|
478 |
|
479 |
+
#: ../includes/class-ure-lib.php:1545
|
480 |
msgid "Create users"
|
481 |
msgstr "Создавать пользователей"
|
482 |
|
483 |
+
#: ../includes/class-ure-lib.php:1546
|
484 |
msgid "Unfiltered upload"
|
485 |
msgstr "Загрузка без фильтра"
|
486 |
|
487 |
+
#: ../includes/class-ure-lib.php:1547
|
488 |
msgid "Edit dashboard"
|
489 |
msgstr "Изменять панель администратора"
|
490 |
|
491 |
+
#: ../includes/class-ure-lib.php:1548
|
492 |
msgid "Update plugins"
|
493 |
msgstr "Обновлять плагины"
|
494 |
|
495 |
+
#: ../includes/class-ure-lib.php:1549
|
496 |
msgid "Delete plugins"
|
497 |
msgstr "Удалять плагины"
|
498 |
|
499 |
+
#: ../includes/class-ure-lib.php:1550
|
500 |
msgid "Install plugins"
|
501 |
msgstr "Устанавливать плагины"
|
502 |
|
503 |
+
#: ../includes/class-ure-lib.php:1551
|
504 |
msgid "Update themes"
|
505 |
msgstr "Обновлять темы"
|
506 |
|
507 |
+
#: ../includes/class-ure-lib.php:1552
|
508 |
msgid "Install themes"
|
509 |
msgstr "Устанавливать темы"
|
510 |
|
511 |
+
#: ../includes/class-ure-lib.php:1553
|
512 |
msgid "Update core"
|
513 |
msgstr "Обновлять ядро"
|
514 |
|
515 |
+
#: ../includes/class-ure-lib.php:1554
|
516 |
msgid "List users"
|
517 |
msgstr "Список пользователей"
|
518 |
|
519 |
+
#: ../includes/class-ure-lib.php:1555
|
520 |
msgid "Remove users"
|
521 |
msgstr "Удалять пользователей"
|
522 |
|
523 |
+
#: ../includes/class-ure-lib.php:1556
|
524 |
msgid "Add users"
|
525 |
msgstr "Добавлять пользователей"
|
526 |
|
527 |
+
#: ../includes/class-ure-lib.php:1557
|
528 |
msgid "Promote users"
|
529 |
msgstr "Продвигать пользователей"
|
530 |
|
531 |
+
#: ../includes/class-ure-lib.php:1558
|
532 |
msgid "Edit theme options"
|
533 |
msgstr "Изменять настройки темы"
|
534 |
|
535 |
+
#: ../includes/class-ure-lib.php:1559
|
536 |
msgid "Delete themes"
|
537 |
msgstr "Удалять темы"
|
538 |
|
539 |
+
#: ../includes/class-ure-lib.php:1560
|
540 |
msgid "Export"
|
541 |
msgstr "Экспорт"
|
542 |
|
543 |
+
#: ../includes/class-ure-lib.php:1643
|
544 |
msgid "Error: Capability name must contain latin characters and digits only!"
|
545 |
msgstr "Ошибка: Имя должно содержать только латинские буквы и цифры"
|
546 |
|
547 |
+
#: ../includes/class-ure-lib.php:1656
|
548 |
#, php-format
|
549 |
msgid "Capability %s is added successfully"
|
550 |
msgstr "Возможность %s добавлена успешно"
|
551 |
|
552 |
+
#: ../includes/class-ure-lib.php:1658
|
553 |
#, php-format
|
554 |
msgid "Capability %s exists already"
|
555 |
msgstr "Возможность %s уже существует"
|
556 |
|
557 |
+
#: ../includes/class-ure-lib.php:1683
|
558 |
#, php-format
|
559 |
msgid "Error! You do not have permission to delete this capability: %s!"
|
560 |
msgstr "Ошибка! Вам запрещено удалять эту возможность: %s!"
|
561 |
|
562 |
+
#: ../includes/class-ure-lib.php:1702
|
563 |
#, php-format
|
564 |
msgid "Capability %s is removed successfully"
|
565 |
msgstr "Возможность %s удалена успешно"
|
566 |
|
567 |
+
#: ../includes/class-ure-lib.php:1799
|
568 |
+
msgid "About this Plugin:"
|
569 |
+
msgstr "Об этом плагине"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
570 |
|
571 |
+
#: ../includes/class-ure-lib.php:1801
|
572 |
+
msgid "Author's website"
|
573 |
+
msgstr "Вебсайт автора"
|
574 |
|
575 |
+
#: ../includes/class-ure-lib.php:1802
|
576 |
+
msgid "Plugin webpage"
|
577 |
+
msgstr "Страница плагина"
|
578 |
|
579 |
+
#: ../includes/class-ure-lib.php:1804
|
580 |
+
msgid "FAQ"
|
581 |
+
msgstr "Часто задаваемые вопросы"
|
|
|
582 |
|
583 |
+
#: ../includes/class-ure-lib.php:1844
|
584 |
+
msgid "None"
|
585 |
+
msgstr "Нет"
|
586 |
|
587 |
+
#: ../includes/ure-user-edit.php:30
|
588 |
msgid "Change capabilities for user"
|
589 |
msgstr "Изменить возможности для пользователя"
|
590 |
|
591 |
+
#: ../includes/ure-user-edit.php:62
|
592 |
msgid "Primary Role:"
|
593 |
+
msgstr "Первичаная роль:"
|
594 |
|
595 |
+
#: ../includes/ure-user-edit.php:72
|
596 |
msgid "bbPress Role:"
|
597 |
+
msgstr "Роль bbPress:"
|
598 |
|
599 |
+
#: ../includes/ure-user-edit.php:82
|
|
|
600 |
msgid "Other Roles:"
|
601 |
+
msgstr "Другие Роли:"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
602 |
|
603 |
+
#~ msgid "Import Roles"
|
604 |
+
#~ msgstr "Импорт Ролей"
|
|
|
|
|
605 |
|
606 |
+
#~ msgid "Select file with roles data"
|
607 |
+
#~ msgstr "Выберите файл, с данными роли"
|
|
|
608 |
|
609 |
+
#~ msgid "Select file with roles: "
|
610 |
+
#~ msgstr "Выбери файл с ролями:"
|
|
|
611 |
|
612 |
+
#~ msgid "File upload error. Try again later"
|
613 |
+
#~ msgstr "Ошибка загрузки файла. Попробуйте ещё раз позже"
|
|
|
|
|
|
|
614 |
|
615 |
+
#~ msgid "Roles are imported successfully"
|
616 |
+
#~ msgstr "Роли импортированы успешно"
|
|
|
617 |
|
618 |
+
#~ msgid "Roles import is failed"
|
619 |
+
#~ msgstr "При импорте ролей произошла ошибка"
|
|
|
620 |
|
621 |
+
#, fuzzy
|
622 |
+
#~ msgid "User Role Editor requires PHP %s or newer."
|
623 |
+
#~ msgstr "Редактор ролей пользователей требует PHP 5.0 или выше."
|
624 |
|
625 |
+
#~ msgid "Please update!"
|
626 |
+
#~ msgstr "Пожалуйста, обновите!"
|
|
|
627 |
|
628 |
+
#, fuzzy
|
629 |
+
#~ msgid "User Role Editor requires WordPress %s or newer."
|
630 |
+
#~ msgstr "Редактор ролей пользователей требует WordPress 3.0 или выше."
|
631 |
|
632 |
+
#~ msgid "Backup record is created for the current role capabilities"
|
633 |
+
#~ msgstr ""
|
634 |
+
#~ "Для текущего распределения возможностей по ролям создана резервная копия"
|
635 |
|
636 |
#~ msgid "Database operation error. Check log file."
|
637 |
#~ msgstr "Ошибка работы с базой данных. Проверьте лог-файл."
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: shinephp
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=vladimir%40shinephp%2ecom&lc=RU&item_name=ShinePHP%2ecom&item_number=User%20Role%20Editor%20WordPress%20plugin¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
|
4 |
Tags: user, role, editor, security, access, permission, capability
|
5 |
Requires at least: 3.2
|
6 |
-
Tested up to: 3.
|
7 |
Stable tag: trunk
|
8 |
|
9 |
User Role Editor WordPress plugin makes the role capabilities changing easy. You can change any standard WordPress user role.
|
@@ -19,7 +19,12 @@ Capabilities could be assigned on per user basis. Multiple roles could be assign
|
|
19 |
You can add new capabilities and remove unnecessary capabilities which could be left from uninstalled plugins.
|
20 |
Multi-site support is provided.
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
To read more about 'User Role Editor' visit [this page](http://www.shinephp.com/user-role-editor-wordpress-plugin/) at [shinephp.com](http://shinephp.com)
|
25 |
|
@@ -36,8 +41,8 @@ Installation procedure:
|
|
36 |
4. Go to the "Users"-"User Role Editor" menu item and change your WordPress standard roles capabilities according to your needs.
|
37 |
|
38 |
== Frequently Asked Questions ==
|
39 |
-
- Does it work with WordPress
|
40 |
-
Yes, it works with WordPress
|
41 |
To update selected role globally for the Network you should turn on the "Apply to All Sites" checkbox. You should have superadmin privileges to use User Role Editor under WordPress multi-site.
|
42 |
|
43 |
To read full FAQ section visit [this page](http://www.shinephp.com/user-role-editor-wordpress-plugin/#faq) at [shinephp.com](shinephp.com).
|
@@ -58,6 +63,7 @@ To read more about 'User Role Editor' visit [this page](http://www.shinephp.com/
|
|
58 |
|
59 |
|
60 |
= Translations =
|
|
|
61 |
* Turkish: [Muhammed YILDIRIM](http://ben.muhammed.im)
|
62 |
*
|
63 |
*---------------------------------------------------------------
|
@@ -70,6 +76,12 @@ Share with me new ideas about plugin further development and link to your site w
|
|
70 |
|
71 |
|
72 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
= 3.14.1 =
|
74 |
* 24.05.2013
|
75 |
* Bug, which prevented the correct use of WordPress nonces on some installations (Windows), is fixed;
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=vladimir%40shinephp%2ecom&lc=RU&item_name=ShinePHP%2ecom&item_number=User%20Role%20Editor%20WordPress%20plugin¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
|
4 |
Tags: user, role, editor, security, access, permission, capability
|
5 |
Requires at least: 3.2
|
6 |
+
Tested up to: 3.5.2
|
7 |
Stable tag: trunk
|
8 |
|
9 |
User Role Editor WordPress plugin makes the role capabilities changing easy. You can change any standard WordPress user role.
|
19 |
You can add new capabilities and remove unnecessary capabilities which could be left from uninstalled plugins.
|
20 |
Multi-site support is provided.
|
21 |
|
22 |
+
Do you need more functionality with quality support in real time? Do you not like advertisement at User Role Editor pages?
|
23 |
+
Buy [Pro version](htpp://role-editor.com).
|
24 |
+
Pro version is advertisement free. Pro version includes the "Export/Import" module. You can export user roles to the local file and import them then
|
25 |
+
to any WordPress site or other sites of the multi-site WordPress network. More functionality modules will follow for Pro version.
|
26 |
+
|
27 |
+
To subscribe for Premium support only visit [role-editor.com](htpp://role-editor.com). Premium support is provided by User Role Editor plugin author Vladimir Garagulya. You will get an answer on your question not once a week or never, but in 24 hours.
|
28 |
|
29 |
To read more about 'User Role Editor' visit [this page](http://www.shinephp.com/user-role-editor-wordpress-plugin/) at [shinephp.com](http://shinephp.com)
|
30 |
|
41 |
4. Go to the "Users"-"User Role Editor" menu item and change your WordPress standard roles capabilities according to your needs.
|
42 |
|
43 |
== Frequently Asked Questions ==
|
44 |
+
- Does it work with WordPress in multi-site environment?
|
45 |
+
Yes, it works with WordPress multi-site. By default plugin works for every blog from your multi-site network as for locally installed blog.
|
46 |
To update selected role globally for the Network you should turn on the "Apply to All Sites" checkbox. You should have superadmin privileges to use User Role Editor under WordPress multi-site.
|
47 |
|
48 |
To read full FAQ section visit [this page](http://www.shinephp.com/user-role-editor-wordpress-plugin/#faq) at [shinephp.com](shinephp.com).
|
63 |
|
64 |
|
65 |
= Translations =
|
66 |
+
* Catalan: [Efraim Bayarri](http://replicantsfactory.com/)
|
67 |
* Turkish: [Muhammed YILDIRIM](http://ben.muhammed.im)
|
68 |
*
|
69 |
*---------------------------------------------------------------
|
76 |
|
77 |
|
78 |
== Changelog ==
|
79 |
+
= 4.0 =
|
80 |
+
* 30.06.2013
|
81 |
+
* Pro version only: added 'Export/Import' functionality to 'export' all user roles to the local file and 'import' them then to other WordPress blog or other sites of muliti-site WordPress network, or just restore roles to previous state after playing with them with test purpose.
|
82 |
+
* Added integration with the Gravity Forms plugin. User Role Editor shows Gravity Forms user capabilities at the custom capabilities section.
|
83 |
+
* Code is fully restructured and encapsulated to PHP classes. Internal global variables are not in use anymore.
|
84 |
+
|
85 |
= 3.14.1 =
|
86 |
* 24.05.2013
|
87 |
* Bug, which prevented the correct use of WordPress nonces on some installations (Windows), is fixed;
|
user-role-editor.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: User Role Editor
|
4 |
-
Plugin URI: http://
|
5 |
-
Description:
|
6 |
-
Version:
|
7 |
Author: Vladimir Garagulya
|
8 |
Author URI: http://www.shinephp.com
|
9 |
Text Domain: ure
|
@@ -12,535 +12,45 @@ Domain Path: /lang/
|
|
12 |
|
13 |
/*
|
14 |
Copyright 2010-2013 Vladimir Garagulya (email: vladimir@shinephp.com)
|
15 |
-
|
16 |
-
This program is free software; you can redistribute it and/or modify
|
17 |
-
it under the terms of the GNU General Public License as published by
|
18 |
-
the Free Software Foundation; either version 2 of the License, or
|
19 |
-
(at your option) any later version.
|
20 |
-
|
21 |
-
This program is distributed in the hope that it will be useful,
|
22 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
-
GNU General Public License for more details.
|
25 |
-
|
26 |
*/
|
27 |
|
28 |
if (!function_exists("get_option")) {
|
|
|
29 |
die; // Silence is golden, direct call is prohibited
|
30 |
}
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
$exit_msg = sprintf( __( 'User Role Editor requires PHP %s or newer.', 'ure' ), $ure_php_version) .
|
35 |
-
'<a href="http://codex.wordpress.org/Upgrading_WordPress"> ' . __( 'Please update!', 'ure' ) . '</a>';
|
36 |
-
wp_die($exit_msg);
|
37 |
-
}
|
38 |
-
|
39 |
-
|
40 |
-
define('URE_PLUGIN_URL', plugin_dir_url(__FILE__) );
|
41 |
-
define('URE_PLUGIN_DIR', plugin_dir_path(__FILE__) );
|
42 |
-
define('URE_WP_ADMIN_URL', admin_url());
|
43 |
-
define('URE_ERROR', 'Error is encountered');
|
44 |
-
define('URE_SPACE_REPLACER', '_URE-SR_');
|
45 |
-
define('URE_PARENT', 'users.php');
|
46 |
-
define('URE_KEY_CAPABILITY', 'administrator');
|
47 |
-
|
48 |
-
require_once(URE_PLUGIN_DIR. 'includes/ure-lib.php');
|
49 |
-
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Load URE plugin translation files - linked to the 'plugins_loaded' action
|
53 |
-
*
|
54 |
-
*/
|
55 |
-
function ure_load_translation() {
|
56 |
-
|
57 |
-
load_plugin_textdomain( 'ure', '', dirname( plugin_basename( __FILE__ ) ) .'/lang' );
|
58 |
-
|
59 |
-
}
|
60 |
-
// end of ure_load_translation()
|
61 |
-
|
62 |
-
|
63 |
-
function ure_optionsPage() {
|
64 |
-
|
65 |
-
global $wpdb, $wp_roles, $current_user, $ure_OptionsTable, $ure_roles, $ure_capabilitiesToSave, $ure_toldAboutBackup,
|
66 |
-
$ure_currentRole, $ure_currentRoleName, $ure_apply_to_all, $ure_fullCapabilities,
|
67 |
-
$ure_show_deprecated_caps, $ure_caps_readable, $ure_userToEdit;
|
68 |
-
|
69 |
-
if (!empty($current_user)) {
|
70 |
-
$user_id = $current_user->ID;
|
71 |
-
} else {
|
72 |
-
$user_id = false;
|
73 |
-
}
|
74 |
-
if (!ure_is_admin($user_id)) {
|
75 |
-
if (is_multisite()) {
|
76 |
-
$admin = 'SuperAdministrator';
|
77 |
-
} else {
|
78 |
-
$admin = 'Administrator';
|
79 |
-
}
|
80 |
-
die(__('Only','ure').' '.$admin.' '.__('is allowed to use','ure').' '.'User Role Editor');
|
81 |
-
}
|
82 |
-
|
83 |
-
require_once(URE_PLUGIN_DIR .'includes/ure-class-advertisement.php');
|
84 |
-
?>
|
85 |
-
|
86 |
-
<div class="wrap">
|
87 |
-
<div class="icon32" id="icon-options-general"><br/></div>
|
88 |
-
<h2><?php _e('User Role Editor', 'ure'); ?></h2>
|
89 |
-
<?php
|
90 |
-
require_once(URE_PLUGIN_DIR .'includes/ure-options.php');
|
91 |
-
?>
|
92 |
-
</div>
|
93 |
-
<?php
|
94 |
-
|
95 |
-
}
|
96 |
-
// end of ure_optionsPage()
|
97 |
-
|
98 |
-
|
99 |
-
// Install plugin
|
100 |
-
function ure_install() {
|
101 |
-
|
102 |
-
global $wp_version, $ure_admin_notice_text;
|
103 |
-
|
104 |
-
if ( empty($wp_version) ) {
|
105 |
-
require( ABSPATH . WPINC . '/version.php' );
|
106 |
-
}
|
107 |
-
|
108 |
-
if (version_compare( $wp_version, '3.2', '<' ) ) {
|
109 |
-
die( sprintf( __( 'User Role Editor requires WordPress %s or newer.', 'ure' ), $wp_version ) .
|
110 |
-
'<a href="http://codex.wordpress.org/Upgrading_WordPress"> ' . __('Please update!', 'ure') . '</a>' );
|
111 |
-
}
|
112 |
-
|
113 |
-
add_option('ure_caps_readable', 0);
|
114 |
-
add_option('ure_show_deprecated_caps', 1);
|
115 |
-
|
116 |
-
}
|
117 |
-
// end of ure_install()
|
118 |
-
|
119 |
-
|
120 |
-
function ure_exclude_admin_role($roles) {
|
121 |
-
|
122 |
-
if (isset($roles['administrator'])){
|
123 |
-
unset( $roles['administrator'] );
|
124 |
-
}
|
125 |
-
|
126 |
-
return $roles;
|
127 |
-
|
128 |
-
}
|
129 |
-
// end of exclude_admin_role()
|
130 |
-
|
131 |
-
|
132 |
-
function ure_admin_load_js($hook_suffix){
|
133 |
-
|
134 |
-
if ($hook_suffix==='users_page_user-role-editor') {
|
135 |
-
wp_enqueue_script('jquery-ui-dialog', false, array('jquery-ui-core','jquery-ui-button', 'jquery') );
|
136 |
-
wp_register_script( 'ure-js', plugins_url( '/js/ure-js.js', __FILE__ ) );
|
137 |
-
wp_enqueue_script ( 'ure-js' );
|
138 |
-
wp_localize_script( 'ure-js', 'ure_data', array(
|
139 |
-
'wp_nonce' => wp_create_nonce('user-role-editor'),
|
140 |
-
'page_url' => URE_WP_ADMIN_URL . URE_PARENT .'?page=user-role-editor.php',
|
141 |
-
'is_multisite' => is_multisite() ? 1 : 0,
|
142 |
-
'select_all' => __('Select All', 'ure'),
|
143 |
-
'unselect_all' => __('Unselect All', 'ure'),
|
144 |
-
'reverse' => __('Reverse', 'ure'),
|
145 |
-
'update' => __('Update', 'ure'),
|
146 |
-
'confirm_submit' => __('Please confirm permissions update', 'ure'),
|
147 |
-
'add_new_role_title' => __('Add New Role', 'ure'),
|
148 |
-
'role_name_required' => __(' Role name (ID) can not be empty!', 'ure'),
|
149 |
-
'role_name_valid_chars' => __(' Role name (ID) must contain latin characters, digits, hyphens or underscore only!', 'ure'),
|
150 |
-
'add_role' => __('Add Role', 'ure'),
|
151 |
-
'delete_role' => __('Delete Role', 'ure'),
|
152 |
-
'cancel' => __('Cancel', 'ure'),
|
153 |
-
'add_capability' => __('Add Capability', 'ure'),
|
154 |
-
'delete_capability' => __('Delete Capability', 'ure'),
|
155 |
-
'reset' => __('Reset', 'ure'),
|
156 |
-
'reset_warning' => __('Reset Roles to WordPress defaults. Be careful, all changes made by you or plugins will be lost. Some plugins, e.g. S2Member, WooCommerce reactivation could be needed. Continue?', 'ure'),
|
157 |
-
'default_role' => __('Default Role', 'ure'),
|
158 |
-
'set_new_default_role' => __('Set New Default Role', 'ure'),
|
159 |
-
'delete_capability' => __('Delete Capability', 'ure'),
|
160 |
-
'delete_capability_warning' => __('Warning! Be careful - removing critical capability could crash some plugin or other custom code', 'ure'),
|
161 |
-
'capability_name_required' => __(' Capability name (ID) can not be empty!', 'ure'),
|
162 |
-
'capability_name_valid_chars' => __(' Capability name (ID) must contain latin characters, digits, hyphens or underscore only!', 'ure'),
|
163 |
-
) );
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
}
|
168 |
-
// end of ure_admin_load_js()
|
169 |
-
|
170 |
-
|
171 |
-
// We have two vulnerable queries id users admin interface which should be processed
|
172 |
-
// 1st: http://blogdomain.com/wp-admin/user-edit.php?user_id=ID&wp_http_referer=%2Fwp-admin%2Fusers.php
|
173 |
-
// 2nd: http://blogdomain.com/wp-admin/users.php?action=delete&user=ID&_wpnonce=ab34225a78
|
174 |
-
// If put Administrator user ID into such request, user with lower capabilities (if he has 'edit_users')
|
175 |
-
// can edit, delete admin record
|
176 |
-
// This function removes 'edit_users', 'delete_users' capability from current user capabilities
|
177 |
-
// if request has admin user ID in it
|
178 |
-
function ure_not_edit_admin($allcaps, $caps, $name) {
|
179 |
-
|
180 |
-
global $ure_userToCheck;
|
181 |
-
|
182 |
-
$userKeys = array('user_id', 'user');
|
183 |
-
foreach ($userKeys as $userKey) {
|
184 |
-
$accessDeny = false;
|
185 |
-
if (isset($_GET[$userKey])) {
|
186 |
-
$ure_UserId = $_GET[$userKey];
|
187 |
-
if ($ure_UserId==1) { // built-in WordPress Admin
|
188 |
-
$accessDeny = true;
|
189 |
-
} else {
|
190 |
-
if (!isset($ure_userToCheck[$ure_UserId])) {
|
191 |
-
// check if user_id has Administrator role
|
192 |
-
$accessDeny = ure_has_administrator_role($ure_UserId);
|
193 |
-
} else {
|
194 |
-
// user_id was checked already, get result from cash
|
195 |
-
$accessDeny = $ure_userToCheck[$ure_UserId];
|
196 |
-
}
|
197 |
-
}
|
198 |
-
if ($accessDeny) {
|
199 |
-
unset($allcaps['edit_users']);
|
200 |
-
unset($allcaps['delete_users']);
|
201 |
-
}
|
202 |
-
break;
|
203 |
-
}
|
204 |
-
}
|
205 |
-
|
206 |
-
return $allcaps;
|
207 |
-
}
|
208 |
-
// end of ure_not_edit_admin()
|
209 |
-
|
210 |
-
|
211 |
-
// add where criteria to exclude users with 'Administrator' role from users list
|
212 |
-
function ure_exclude_administrators($user_query) {
|
213 |
-
|
214 |
-
global $wpdb;
|
215 |
-
|
216 |
-
$result = false;
|
217 |
-
$links_to_block = array('profile.php', 'users.php');
|
218 |
-
foreach ( $links_to_block as $key => $value ) {
|
219 |
-
$result = stripos($_SERVER['REQUEST_URI'], $value);
|
220 |
-
if ( $result !== false ) {
|
221 |
-
break;
|
222 |
-
}
|
223 |
-
}
|
224 |
-
|
225 |
-
if ( $result===false ) {
|
226 |
-
return;
|
227 |
-
}
|
228 |
-
|
229 |
-
|
230 |
-
// get user_id of users with 'Administrator' role
|
231 |
-
$tableName = (!is_multisite() && defined('CUSTOM_USER_META_TABLE')) ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
|
232 |
-
$meta_key = $wpdb->prefix.'capabilities';
|
233 |
-
$admin_role_key = '%"administrator"%';
|
234 |
-
$query = "select user_id
|
235 |
-
from $tableName
|
236 |
-
where meta_key='$meta_key' and meta_value like '$admin_role_key'";
|
237 |
-
$ids_arr = $wpdb->get_col($query);
|
238 |
-
if (is_array($ids_arr) && count($ids_arr)>0) {
|
239 |
-
$ids = implode(',', $ids_arr);
|
240 |
-
$user_query->query_where .= " AND ($wpdb->users.ID NOT IN ($ids))";
|
241 |
-
}
|
242 |
-
|
243 |
-
}
|
244 |
-
// end of ure_exclude_administrators()
|
245 |
-
|
246 |
-
|
247 |
-
function exclude_admins_view($views) {
|
248 |
-
|
249 |
-
unset($views['administrator']);
|
250 |
-
|
251 |
-
return $views;
|
252 |
-
}
|
253 |
-
// end of exclude_admins_view()
|
254 |
-
|
255 |
-
|
256 |
-
function ure_init() {
|
257 |
-
|
258 |
-
global $current_user;
|
259 |
-
|
260 |
-
if (!empty($current_user->ID)) {
|
261 |
-
$user_id = $current_user->ID;
|
262 |
-
} else {
|
263 |
-
$user_id = 0;
|
264 |
-
}
|
265 |
-
|
266 |
-
add_action('admin_enqueue_scripts' , 'ure_admin_load_js' );
|
267 |
-
|
268 |
-
// these filters and actions should prevent editing users with administrator role
|
269 |
-
// by other users with URE_KEY_CAPABILITY capability
|
270 |
-
if (!ure_is_admin($user_id)) {
|
271 |
-
// Exclude administrator role from edit list.
|
272 |
-
add_filter('editable_roles', 'ure_exclude_admin_role');
|
273 |
-
// prohibit any actions with user who has Administrator role
|
274 |
-
add_filter('user_has_cap', 'ure_not_edit_admin', 10, 3);
|
275 |
-
// exclude users with 'Administrator' role from users list
|
276 |
-
add_action('pre_user_query', 'ure_exclude_administrators');
|
277 |
-
// do not show 'Administrator (n)' view above users list
|
278 |
-
add_filter('views_users', 'exclude_admins_view');
|
279 |
-
}
|
280 |
-
|
281 |
-
}
|
282 |
-
// end of ure_init()
|
283 |
-
|
284 |
-
|
285 |
-
function ure_plugin_action_links($links, $file) {
|
286 |
-
if ($file == plugin_basename(dirname(__FILE__).'/user-role-editor.php')){
|
287 |
-
$settings_link = "<a href='".URE_PARENT."?page=user-role-editor.php'>".__('Settings','ure')."</a>";
|
288 |
-
array_unshift( $links, $settings_link );
|
289 |
-
}
|
290 |
-
return $links;
|
291 |
-
}
|
292 |
-
// end of ure_plugin_action_links
|
293 |
-
|
294 |
-
|
295 |
-
function ure_plugin_row_meta($links, $file) {
|
296 |
-
if ($file == plugin_basename(dirname(__FILE__).'/user-role_editor.php')){
|
297 |
-
$links[] = '<a target="_blank" href="http://www.shinephp.com/user-role-editor-wordpress-plugin/#changelog">'.__('Changelog', 'ure').'</a>';
|
298 |
-
}
|
299 |
-
return $links;
|
300 |
-
} // end of ure_plugin_row_meta
|
301 |
-
|
302 |
-
|
303 |
-
function ure_settings_menu() {
|
304 |
-
|
305 |
-
if (function_exists('add_submenu_page')) {
|
306 |
-
if (!is_multisite()) {
|
307 |
-
$keyCapability = URE_KEY_CAPABILITY;
|
308 |
-
} else {
|
309 |
-
if (defined('URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE') && URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE==1) {
|
310 |
-
$keyCapability = URE_KEY_CAPABILITY;
|
311 |
-
} else {
|
312 |
-
$keyCapability = 'manage_network_users';
|
313 |
-
}
|
314 |
-
}
|
315 |
-
$ure_page = add_submenu_page('users.php', __('User Role Editor', 'ure'), __('User Role Editor', 'ure'), $keyCapability, basename(__FILE__), 'ure_optionsPage');
|
316 |
-
add_action("admin_print_styles-$ure_page", 'ure_admin_css_action');
|
317 |
-
}
|
318 |
-
|
319 |
-
}
|
320 |
-
// end of ure_settings_menu()
|
321 |
-
|
322 |
-
function ure_admin_css_action() {
|
323 |
-
|
324 |
-
wp_enqueue_style ( 'wp-jquery-ui-dialog');
|
325 |
-
wp_enqueue_style('ure_admin_css', URE_PLUGIN_URL .'css/ure-admin.css', array(), false, 'screen');
|
326 |
-
|
327 |
-
}
|
328 |
-
// end of ure_adminCssAction()
|
329 |
-
|
330 |
-
|
331 |
-
function ure_user_row($actions, $user) {
|
332 |
-
|
333 |
-
global $pagenow, $current_user;
|
334 |
-
|
335 |
-
if ($pagenow == 'users.php') {
|
336 |
-
if (is_super_admin() ||
|
337 |
-
(is_multisite() && defined('URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE') && URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE==1 && current_user_can('administrator'))) {
|
338 |
-
if (isset($user->caps['administrator'])) {
|
339 |
-
if ($current_user->ID!=$user->ID) {
|
340 |
-
unset($actions['edit']);
|
341 |
-
unset($actions['delete']);
|
342 |
-
unset($actions['remove']);
|
343 |
-
}
|
344 |
-
} else if ($current_user->has_cap(URE_KEY_CAPABILITY)) {
|
345 |
-
$actions['capabilities'] = '<a href="' . wp_nonce_url("users.php?page=user-role-editor.php&object=user&user_id={$user->ID}", "ure_user_{$user->ID}") . '">' . __('Capabilities', 'ure') . '</a>';
|
346 |
-
}
|
347 |
-
}
|
348 |
-
}
|
349 |
-
|
350 |
-
return $actions;
|
351 |
-
}
|
352 |
-
// end of ure_user_row()
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
function ure_edit_user_profile($user) {
|
359 |
-
|
360 |
-
global $current_user, $wp_roles;
|
361 |
-
|
362 |
-
$result = stripos($_SERVER['REQUEST_URI'], 'network/user-edit.php');
|
363 |
-
if ($result!==false) { // exit, this code just for single site user profile only, not for network admin center
|
364 |
-
return;
|
365 |
-
}
|
366 |
-
if (!ure_is_admin($current_user->ID)) {
|
367 |
-
return;
|
368 |
-
}
|
369 |
-
|
370 |
-
?>
|
371 |
-
<h3><?php _e('User Role Editor', 'ure'); ?></h3>
|
372 |
-
<table class="form-table">
|
373 |
-
<tr>
|
374 |
-
<th scope="row"><?php _e( 'Other Roles', 'ure' ); ?></th>
|
375 |
-
<td>
|
376 |
-
<?php
|
377 |
-
$roles = ure_other_user_roles($user);
|
378 |
-
if (is_array($roles) && count($roles)>0) {
|
379 |
-
foreach($roles as $role) {
|
380 |
-
echo '<input type="hidden" name="ure_other_roles[]" value="'.$role.'" />' ;
|
381 |
-
}
|
382 |
-
}
|
383 |
-
$output = ure_other_user_roles_text($roles);
|
384 |
-
echo $output. ' >> <a href="' . wp_nonce_url("users.php?page=user-role-editor.php&object=user&user_id={$user->ID}", "ure_user_{$user->ID}") . '">' . __('Edit', 'ure') . '</a>';
|
385 |
-
?>
|
386 |
-
</td>
|
387 |
-
</tr>
|
388 |
-
</table>
|
389 |
-
<?php
|
390 |
-
/*
|
391 |
-
<script type="text/javascript">
|
392 |
-
jQuery('#role').attr('disabled', 'disabled');
|
393 |
-
</script>
|
394 |
-
*/
|
395 |
-
?>
|
396 |
-
<?php
|
397 |
-
|
398 |
-
}
|
399 |
-
// end of ure_edit_user_profile()
|
400 |
-
|
401 |
-
|
402 |
-
/**
|
403 |
-
* add 'Other Roles' column to WordPress users list table
|
404 |
-
*
|
405 |
-
* @param array $columns WordPress users list table columns list
|
406 |
-
* @return array
|
407 |
-
*/
|
408 |
-
function ure_user_role_column($columns = array()) {
|
409 |
-
|
410 |
-
$columns['ure_roles'] = __('Other Roles', 'ure');
|
411 |
-
|
412 |
-
return $columns;
|
413 |
-
}
|
414 |
-
// end of ure_user_column()
|
415 |
-
|
416 |
-
|
417 |
-
/**
|
418 |
-
* Return user's roles list for display in the WordPress Users list table
|
419 |
-
*
|
420 |
-
* @param string $retval
|
421 |
-
* @param string $column_name
|
422 |
-
* @param int $user_id
|
423 |
-
*
|
424 |
-
* @return string all user roles
|
425 |
-
*/
|
426 |
-
function ure_user_role_row($retval = '', $column_name = '', $user_id = 0) {
|
427 |
-
|
428 |
-
// Only looking for User Role Editor other user roles column
|
429 |
-
if ('ure_roles' == $column_name) {
|
430 |
-
$user = get_userdata( $user_id );
|
431 |
-
// Get the users roles
|
432 |
-
$roles = ure_other_user_roles( $user );
|
433 |
-
$retval = ure_other_user_roles_text( $roles );
|
434 |
-
|
435 |
-
}
|
436 |
-
|
437 |
-
|
438 |
-
// Pass retval through
|
439 |
-
return $retval;
|
440 |
}
|
441 |
-
// end of ure_user_role_row()
|
442 |
-
|
443 |
|
444 |
|
445 |
-
|
|
|
|
|
|
|
446 |
|
447 |
-
|
448 |
-
function duplicate_roles_for_new_blog($blog_id, $user_id) {
|
449 |
-
global $wpdb, $wp_roles;
|
450 |
-
|
451 |
-
// get Id of 1st (main) blog
|
452 |
-
$blogIds = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs order by blog_id asc");
|
453 |
-
if (!isset($blogIds[0])) {
|
454 |
-
return;
|
455 |
-
}
|
456 |
-
$current_blog = $wpdb->blogid;
|
457 |
-
switch_to_blog($blogIds[0]);
|
458 |
-
$main_roles = new WP_Roles(); // get roles from primary blog
|
459 |
-
$default_role = get_option('default_role'); // get default role from primary blog
|
460 |
-
switch_to_blog($blog_id); // switch to the new created blog
|
461 |
-
$main_roles->use_db = false; // do not touch DB
|
462 |
-
$main_roles->add_cap('administrator', 'dummy_123456'); // just to save current roles into new blog
|
463 |
-
$main_roles->role_key = $wp_roles->role_key;
|
464 |
-
$main_roles->use_db = true; // save roles into new blog DB
|
465 |
-
$main_roles->remove_cap('administrator', 'dummy_123456'); // remove unneeded dummy capability
|
466 |
-
update_option('default_role', $default_role); // set default role for new blog as it set for primary one
|
467 |
-
switch_to_blog($current_blog); // return to blog where we were at the begin
|
468 |
-
}
|
469 |
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
* @param type array $plugins plugins list
|
476 |
-
* @return type array $plugins updated plugins list
|
477 |
-
*/
|
478 |
-
function ure_exclude_from_plugins_list($plugins) {
|
479 |
-
|
480 |
-
// if multi-site, then allow plugin activation for network superadmins and, if that's specially defined, - for single site administrators too
|
481 |
-
if (is_super_admin() || (defined('URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE') && URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE==1)) {
|
482 |
-
return $plugins;
|
483 |
-
}
|
484 |
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
}
|
491 |
-
}
|
492 |
|
493 |
-
|
494 |
-
|
495 |
-
// end of ure_exclude_from_plugins_list()
|
496 |
-
|
497 |
-
add_filter( 'all_plugins', 'ure_exclude_from_plugins_list' );
|
498 |
-
|
499 |
-
} // if (function_exists('is_multisite')
|
500 |
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
if ( !current_user_can('edit_user', $user_id) ) {
|
506 |
-
return;
|
507 |
-
}
|
508 |
-
$user = get_userdata($user_id);
|
509 |
-
|
510 |
-
if (isset($_POST['ure_other_roles'])) {
|
511 |
-
$new_roles = array_intersect($user->roles, $_POST['ure_other_roles']);
|
512 |
-
$skip_roles = array();
|
513 |
-
foreach($new_roles as $role) {
|
514 |
-
$skip_roles['$role'] = 1;
|
515 |
-
}
|
516 |
-
unset($new_roles);
|
517 |
-
foreach($_POST['ure_other_roles'] as $role) {
|
518 |
-
if (!isset($skip_roles[$role])) {
|
519 |
-
$user->add_role($role);
|
520 |
-
}
|
521 |
-
}
|
522 |
-
}
|
523 |
-
|
524 |
}
|
525 |
-
// ure_update_user_profile()
|
526 |
|
|
|
527 |
|
528 |
-
if (is_admin()) {
|
529 |
-
// activation action
|
530 |
-
register_activation_hook(__FILE__, "ure_install");
|
531 |
-
/* Add the translation function after the plugins loaded hook. */
|
532 |
-
add_action( 'plugins_loaded', 'ure_load_translation' );
|
533 |
-
add_action( 'admin_init', 'ure_init' );
|
534 |
-
// add a Settings link in the installed plugins page
|
535 |
-
add_filter( 'plugin_action_links', 'ure_plugin_action_links', 10, 2 );
|
536 |
-
add_filter( 'plugin_row_meta', 'ure_plugin_row_meta', 10, 2 );
|
537 |
-
add_action( 'admin_menu', 'ure_settings_menu' );
|
538 |
-
add_action( 'user_row_actions', 'ure_user_row', 10, 2 );
|
539 |
-
add_action( 'edit_user_profile', 'ure_edit_user_profile');
|
540 |
-
add_filter( 'manage_users_columns', 'ure_user_role_column', 10, 5 );
|
541 |
-
add_filter( 'manage_users_custom_column', 'ure_user_role_row', 10, 3 );
|
542 |
-
add_action( 'profile_update', 'ure_user_profile_update', 10 );
|
543 |
-
|
544 |
-
}
|
545 |
|
546 |
-
?>
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: User Role Editor
|
4 |
+
Plugin URI: http://role-editor.com
|
5 |
+
Description: Change/add/delete WordPress user roles and capabilities.
|
6 |
+
Version: 4.0
|
7 |
Author: Vladimir Garagulya
|
8 |
Author URI: http://www.shinephp.com
|
9 |
Text Domain: ure
|
12 |
|
13 |
/*
|
14 |
Copyright 2010-2013 Vladimir Garagulya (email: vladimir@shinephp.com)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
|
17 |
if (!function_exists("get_option")) {
|
18 |
+
header('HTTP/1.0 403 Forbidden');
|
19 |
die; // Silence is golden, direct call is prohibited
|
20 |
}
|
21 |
|
22 |
+
if (!is_admin()) { // plugin works at Admin back-end only
|
23 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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_DIR.'includes/class-garvs-wp-lib.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
+
// check PHP version
|
35 |
+
$ure_required_php_version = '5.2.4';
|
36 |
+
$exit_msg = sprintf( 'User Role Editor requires PHP %s or newer.', $ure_required_php_version ) .
|
37 |
+
'<a href="http://wordpress.org/about/requirements/"> ' . 'Please update!' . '</a>';
|
38 |
+
Garvs_WP_Lib::check_version( PHP_VERSION, $ure_required_php_version, $exit_msg, __FILE__ );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
+
// check WP version
|
41 |
+
$ure_required_wp_version = '3.5';
|
42 |
+
$exit_msg = sprintf( 'User Role Editor requires WordPress %s or newer.', $ure_required_wp_version ) .
|
43 |
+
'<a href="http://codex.wordpress.org/Upgrading_WordPress"> ' . 'Please update!' . '</a>';
|
44 |
+
Garvs_WP_Lib::check_version(get_bloginfo('version'), $ure_required_wp_version, $exit_msg, __FILE__ );
|
|
|
|
|
45 |
|
46 |
+
require_once(URE_PLUGIN_DIR .'includes/define-constants.php');
|
47 |
+
require_once(URE_PLUGIN_DIR .'includes/misc-support-stuff.php');
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
if (!class_exists('User_Role_Editor')) {
|
50 |
+
require_once( URE_PLUGIN_DIR .'includes/class-ure-lib.php');
|
51 |
+
require_once( URE_PLUGIN_DIR .'includes/class-user-role-editor.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
|
|
53 |
|
54 |
+
new User_Role_Editor();
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
|