| 1 |
<?php |
| 2 |
/** |
| 3 |
* Authorizer |
| 4 |
* |
| 5 |
* @license GPL-2.0+ |
| 6 |
* @link https://github.com/uhm-coe/authorizer |
| 7 |
* @package authorizer |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace Authorizer; |
| 11 |
|
| 12 |
use Authorizer\Helper; |
| 13 |
use Authorizer\Options; |
| 14 |
use Authorizer\Options\Access_Lists; |
| 15 |
use Authorizer\Options\Login_Access; |
| 16 |
use Authorizer\Options\Public_Access; |
| 17 |
use Authorizer\Options\External; |
| 18 |
use Authorizer\Options\External\Google; |
| 19 |
use Authorizer\Options\External\Cas; |
| 20 |
use Authorizer\Options\External\Ldap; |
| 21 |
use Authorizer\Options\Advanced; |
| 22 |
|
| 23 |
/** |
| 24 |
* Contains functions for creating the Authorizer Settings page and adding it to |
| 25 |
* the WordPress Dashboard menu. |
| 26 |
*/ |
| 27 |
class Admin_Page extends Static_Instance { |
| 28 |
|
| 29 |
/** |
| 30 |
* Add help documentation to the options page. |
| 31 |
* |
| 32 |
* Action: load-settings_page_authorizer > admin_head |
| 33 |
*/ |
| 34 |
public function admin_head() { |
| 35 |
$screen = get_current_screen(); |
| 36 |
|
| 37 |
// Add help tab for Access Lists Settings. |
| 38 |
$help_auth_settings_access_lists_content = ' |
| 39 |
<p>' . __( "<strong>Pending Users</strong>: Pending users are users who have successfully logged in to the site, but who haven't yet been approved (or blocked) by you.", 'authorizer' ) . '</p> |
| 40 |
<p>' . __( '<strong>Approved Users</strong>: Approved users have access to the site once they successfully log in.', 'authorizer' ) . '</p> |
| 41 |
<p>' . __( '<strong>Blocked Users</strong>: Blocked users will receive an error message when they try to visit the site after authenticating.', 'authorizer' ) . '</p> |
| 42 |
<p>' . __( 'Users in the <strong>Pending</strong> list appear automatically after a new user tries to log in from the configured external authentication service. You can add users to the <strong>Approved</strong> or <strong>Blocked</strong> lists by typing them in manually, or by clicking the <em>Approve</em> or <em>Block</em> buttons next to a user in the <strong>Pending</strong> list.', 'authorizer' ) . '</p> |
| 43 |
'; |
| 44 |
$screen->add_help_tab( |
| 45 |
array( |
| 46 |
'id' => 'help_auth_settings_access_lists_content', |
| 47 |
'title' => __( 'Access Lists', 'authorizer' ), |
| 48 |
'content' => $help_auth_settings_access_lists_content, |
| 49 |
) |
| 50 |
); |
| 51 |
|
| 52 |
// Add help tab for Login Access Settings. |
| 53 |
$help_auth_settings_access_login_content = ' |
| 54 |
<p>' . __( "<strong>Who can log in to the site?</strong>: Choose the level of access restriction you'd like to use on your site here. You can leave the site open to anyone with a WordPress account or an account on an external service like Google, CAS, or LDAP, or restrict it to WordPress users and only the external users that you specify via the <em>Access Lists</em>.", 'authorizer' ) . '</p> |
| 55 |
<p>' . __( "<strong>Which role should receive email notifications about pending users?</strong>: If you've restricted access to <strong>approved users</strong>, you can determine which WordPress users will receive a notification email everytime a new external user successfully logs in and is added to the pending list. All users of the specified role will receive an email, and the external user will get a message (specified below) telling them their access is pending approval.", 'authorizer' ) . '</p> |
| 56 |
<p>' . __( '<strong>What message should pending users see after attempting to log in?</strong>: Here you can specify the exact message a new external user will see once they try to log in to the site for the first time.', 'authorizer' ) . '</p> |
| 57 |
'; |
| 58 |
$screen->add_help_tab( |
| 59 |
array( |
| 60 |
'id' => 'help_auth_settings_access_login_content', |
| 61 |
'title' => __( 'Login Access', 'authorizer' ), |
| 62 |
'content' => $help_auth_settings_access_login_content, |
| 63 |
) |
| 64 |
); |
| 65 |
|
| 66 |
// Add help tab for Public Access Settings. |
| 67 |
$help_auth_settings_access_public_content = ' |
| 68 |
<p>' . __( "<strong>Who can view the site?</strong>: You can restrict the site's visibility by only allowing logged in users to see pages. If you do so, you can customize the specifics about the site's privacy using the settings below.", 'authorizer' ) . '</p> |
| 69 |
<p>' . __( "<strong>What pages (if any) should be available to everyone?</strong>: If you'd like to declare certain pages on your site as always public (such as the course syllabus, introduction, or calendar), specify those pages here. These pages will always be available no matter what access restrictions exist.", 'authorizer' ) . '</p> |
| 70 |
<p>' . __( '<strong>What happens to people without access when they visit a <em>private</em> page?</strong>: Choose the response anonymous users receive when visiting the site. You can choose between immediately taking them to the <strong>login screen</strong>, or simply showing them a <strong>message</strong>.', 'authorizer' ) . '</p> |
| 71 |
<p>' . __( '<strong>What happens to people without access when they visit a <em>public</em> page?</strong>: Choose the response anonymous users receive when visiting a page on the site marked as public. You can choose between showing them the page without any message, or showing them a the page with a message above the content.', 'authorizer' ) . '</p> |
| 72 |
<p>' . __( '<strong>What message should people without access see?</strong>: If you chose to show new users a <strong>message</strong> above, type that message here.', 'authorizer' ) . '</p> |
| 73 |
'; |
| 74 |
$screen->add_help_tab( |
| 75 |
array( |
| 76 |
'id' => 'help_auth_settings_access_public_content', |
| 77 |
'title' => __( 'Public Access', 'authorizer' ), |
| 78 |
'content' => $help_auth_settings_access_public_content, |
| 79 |
) |
| 80 |
); |
| 81 |
|
| 82 |
// Add help tab for External Service (CAS, LDAP) Settings. |
| 83 |
$help_auth_settings_external_content = ' |
| 84 |
<p>' . __( "<strong>Type of external service to authenticate against</strong>: Choose which authentication service type you will be using. You'll have to fill out different fields below depending on which service you choose.", 'authorizer' ) . '</p> |
| 85 |
<p>' . __( '<strong>Enable Google Logins</strong>: Choose if you want to allow users to log in with their Google Account credentials. You will need to enter your API Client ID and Secret to enable Google Logins.', 'authorizer' ) . '</p> |
| 86 |
<p>' . __( '<strong>Enable CAS Logins</strong>: Choose if you want to allow users to log in with via CAS (Central Authentication Service). You will need to enter details about your CAS server (host, port, and path) to enable CAS Logins.', 'authorizer' ) . '</p> |
| 87 |
<p>' . __( '<strong>Enable LDAP Logins</strong>: Choose if you want to allow users to log in with their LDAP (Lightweight Directory Access Protocol) credentials. You will need to enter details about your LDAP server (host, port, search base, uid attribute, directory user, directory user password, and whether to use TLS) to enable Google Logins.', 'authorizer' ) . '</p> |
| 88 |
<p>' . __( '<strong>Default role for new CAS users</strong>: Specify which role new external users will get by default. Be sure to choose a role with limited permissions!', 'authorizer' ) . '</p> |
| 89 |
<p><strong><em>' . __( 'If you enable Google logins:', 'authorizer' ) . '</em></strong></p> |
| 90 |
<ul> |
| 91 |
<li>' . __( "<strong>Google Client ID</strong>: You can generate this ID by creating a new Project in the <a href='https://cloud.google.com/console'>Google Developers Console</a>. A Client ID typically looks something like this: 1234567890123-kdjr85yt6vjr6d8g7dhr8g7d6durjf7g.apps.googleusercontent.com", 'authorizer' ) . '</li> |
| 92 |
<li>' . __( "<strong>Google Client Secret</strong>: You can generate this secret by creating a new Project in the <a href='https://cloud.google.com/console'>Google Developers Console</a>. A Client Secret typically looks something like this: sDNgX5_pr_5bly-frKmvp8jT", 'authorizer' ) . '</li> |
| 93 |
</ul> |
| 94 |
<p><strong><em>' . __( 'If you enable CAS logins:', 'authorizer' ) . '</em></strong></p> |
| 95 |
<ul> |
| 96 |
<li>' . __( '<strong>CAS server hostname</strong>: Enter the hostname of the CAS server you authenticate against (e.g., authn.example.edu).', 'authorizer' ) . '</li> |
| 97 |
<li>' . __( '<strong>CAS server port</strong>: Enter the port on the CAS server to connect to (e.g., 443).', 'authorizer' ) . '</li> |
| 98 |
<li>' . __( '<strong>CAS server path/context</strong>: Enter the path to the login endpoint on the CAS server (e.g., /cas).', 'authorizer' ) . '</li> |
| 99 |
<li>' . __( "<strong>CAS attribute containing first name</strong>: Enter the CAS attribute that has the user's first name. When this user first logs in, their WordPress account will have their first name retrieved from CAS and added to their WordPress profile.", 'authorizer' ) . '</li> |
| 100 |
<li>' . __( "<strong>CAS attribute containing last name</strong>: Enter the CAS attribute that has the user's last name. When this user first logs in, their WordPress account will have their last name retrieved from CAS and added to their WordPress profile.", 'authorizer' ) . '</li> |
| 101 |
<li>' . __( '<strong>CAS attribute update</strong>: Select whether the first and last names retrieved from CAS should overwrite any value the user has entered in the first and last name fields in their WordPress profile. If this is not set, this only happens the first time they log in.', 'authorizer' ) . '</li> |
| 102 |
</ul> |
| 103 |
<p><strong><em>' . __( 'If you enable LDAP logins:', 'authorizer' ) . '</em></strong></p> |
| 104 |
<ul> |
| 105 |
<li>' . __( '<strong>LDAP Host</strong>: Enter the URL of the LDAP server you authenticate against.', 'authorizer' ) . '</li> |
| 106 |
<li>' . __( '<strong>LDAP Port</strong>: Enter the port number that the LDAP server listens on.', 'authorizer' ) . '</li> |
| 107 |
<li>' . __( '<strong>LDAP Search Base</strong>: Enter the LDAP string that represents the search base, e.g., ou=people,dc=example,dc=edu', 'authorizer' ) . '</li> |
| 108 |
<li>' . __( '<strong>LDAP attribute containing username</strong>: Enter the name of the LDAP attribute that contains the usernames used by those attempting to log in. The plugin will search on this attribute to find the cn to bind against for login attempts.', 'authorizer' ) . '</li> |
| 109 |
<li>' . __( '<strong>LDAP Directory User</strong>: Enter the name of the LDAP user that has permissions to browse the directory.', 'authorizer' ) . '</li> |
| 110 |
<li>' . __( '<strong>LDAP Directory User Password</strong>: Enter the password for the LDAP user that has permission to browse the directory.', 'authorizer' ) . '</li> |
| 111 |
<li>' . __( '<strong>Use TLS</strong>: Select whether all communication with the LDAP server should be performed over a TLS-secured connection.', 'authorizer' ) . '</li> |
| 112 |
<li>' . __( "<strong>Custom lost password URL</strong>: The WordPress login page contains a link to recover a lost password. If you have external users who shouldn't change the password on their WordPress account, point them to the appropriate location to change the password on their external authentication service here.", 'authorizer' ) . '</li> |
| 113 |
<li>' . __( "<strong>LDAP attribute containing first name</strong>: Enter the LDAP attribute that has the user's first name. When this user first logs in, their WordPress account will have their first name retrieved from LDAP and added to their WordPress profile.", 'authorizer' ) . '</li> |
| 114 |
<li>' . __( "<strong>LDAP attribute containing last name</strong>: Enter the LDAP attribute that has the user's last name. When this user first logs in, their WordPress account will have their last name retrieved from LDAP and added to their WordPress profile.", 'authorizer' ) . '</li> |
| 115 |
<li>' . __( '<strong>LDAP attribute update</strong>: Select whether the first and last names retrieved from LDAP should overwrite any value the user has entered in the first and last name fields in their WordPress profile. If this is not set, this only happens the first time they log in.', 'authorizer' ) . '</li> |
| 116 |
</ul> |
| 117 |
'; |
| 118 |
$screen->add_help_tab( |
| 119 |
array( |
| 120 |
'id' => 'help_auth_settings_external_content', |
| 121 |
'title' => __( 'External Service', 'authorizer' ), |
| 122 |
'content' => $help_auth_settings_external_content, |
| 123 |
) |
| 124 |
); |
| 125 |
|
| 126 |
// Add help tab for Advanced Settings. |
| 127 |
$help_auth_settings_advanced_content = ' |
| 128 |
<p>' . __( '<strong>Limit invalid login attempts</strong>: Choose how soon (and for how long) to restrict access to individuals (or bots) making repeated invalid login attempts. You may set a shorter delay first, and then a longer delay after repeated invalid attempts; you may also set how much time must pass before the delays will be reset to normal.', 'authorizer' ) . '</p> |
| 129 |
<p>' . __( '<strong>Hide WordPress Logins</strong>: If you want to hide the WordPress username and password fields and the Log In button on the wp-login screen, enable this option. Note: You can always access the WordPress logins by adding external=wordpress to the wp-login URL, like so:', 'authorizer' ) . ' <a href="' . wp_login_url() . '?external=wordpress" target="_blank">' . wp_login_url() . '?external=wordpress</a>.</p> |
| 130 |
<p>' . __( "<strong>Custom WordPress login branding</strong>: If you'd like to use custom branding on the WordPress login page, select that here. You will need to use the `authorizer_add_branding_option` filter in your theme to add it. You can see an example theme that implements this filter in the plugin directory under sample-theme-add-branding.", 'authorizer' ) . '</p> |
| 131 |
'; |
| 132 |
$screen->add_help_tab( |
| 133 |
array( |
| 134 |
'id' => 'help_auth_settings_advanced_content', |
| 135 |
'title' => __( 'Advanced', 'authorizer' ), |
| 136 |
'content' => $help_auth_settings_advanced_content, |
| 137 |
) |
| 138 |
); |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
/** |
| 143 |
* Add notices to the top of the options page. |
| 144 |
* |
| 145 |
* Action: load-settings_page_authorizer > admin_notices |
| 146 |
* |
| 147 |
* Description: Check for invalid settings combinations and show a warning message, e.g.: |
| 148 |
* if ( cas url inaccessible ) : ?> |
| 149 |
* <div class='updated settings-error'><p>Can't reach CAS server.</p></div> |
| 150 |
* <?php endif; |
| 151 |
*/ |
| 152 |
public function admin_notices() { |
| 153 |
// Grab plugin settings. |
| 154 |
$options = Options::get_instance(); |
| 155 |
$auth_settings = $options->get_all( Helper::SINGLE_CONTEXT, 'allow override' ); |
| 156 |
|
| 157 |
if ( '1' === $auth_settings['cas'] ) : |
| 158 |
// Check if provided CAS URL is accessible. |
| 159 |
$protocol = in_array( strval( $auth_settings['cas_port'] ), array( '80', '8080' ), true ) ? 'http' : 'https'; |
| 160 |
$cas_url = $protocol . '://' . $auth_settings['cas_host'] . ':' . $auth_settings['cas_port'] . $auth_settings['cas_path']; |
| 161 |
$legacy_cas_url = trailingslashit( $cas_url ) . 'login'; // Check the specific CAS login endpoint (old; some servers don't register a ./login endpoint, use serviceValidate instead). |
| 162 |
$cas_url = trailingslashit( $cas_url ) . 'serviceValidate'; // Check the specific CAS login endpoint. |
| 163 |
if ( ! Helper::url_is_accessible( $cas_url ) && ! Helper::url_is_accessible( $legacy_cas_url ) ) : |
| 164 |
$authorizer_options_url = 'settings' === $auth_settings['advanced_admin_menu'] ? admin_url( 'options-general.php?page=authorizer' ) : admin_url( '?page=authorizer' ); |
| 165 |
?> |
| 166 |
<div class='notice notice-warning is-dismissible'> |
| 167 |
<p><?php esc_html_e( "Can't reach CAS server. Please provide", 'authorizer' ); ?> <a href='<?php echo esc_attr( $authorizer_options_url ); ?>&tab=external'><?php esc_html_e( 'accurate CAS settings', 'authorizer' ); ?></a> <?php esc_html_e( 'if you intend to use it.', 'authorizer' ); ?></p> |
| 168 |
</div> |
| 169 |
<?php |
| 170 |
endif; |
| 171 |
endif; |
| 172 |
} |
| 173 |
|
| 174 |
|
| 175 |
/** |
| 176 |
* Show custom admin notice. |
| 177 |
* |
| 178 |
* Note: currently unused, but if anywhere we: |
| 179 |
* add_option( 'auth_settings_advanced_admin_notice, 'Your message.' ); |
| 180 |
* It will display and then delete that message on the admin dashboard. |
| 181 |
* |
| 182 |
* Filter: admin_notices |
| 183 |
* filter: network_admin_notices |
| 184 |
*/ |
| 185 |
public function show_advanced_admin_notice() { |
| 186 |
$notice = get_option( 'auth_settings_advanced_admin_notice' ); |
| 187 |
delete_option( 'auth_settings_advanced_admin_notice' ); |
| 188 |
|
| 189 |
if ( $notice && strlen( $notice ) > 0 ) { |
| 190 |
?> |
| 191 |
<div class="error"> |
| 192 |
<p><?php echo wp_kses( $notice, Helper::$allowed_html ); ?></p> |
| 193 |
</div> |
| 194 |
<?php |
| 195 |
} |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
/** |
| 200 |
* Add a link to this plugin's settings page from the WordPress Plugins page. |
| 201 |
* Called from "plugin_action_links" filter in __construct() above. |
| 202 |
* |
| 203 |
* Filter: plugin_action_links_authorizer.php |
| 204 |
* |
| 205 |
* @param array $links Admin sidebar links. |
| 206 |
* @return array Admin sidebar links with Authorizer added. |
| 207 |
*/ |
| 208 |
public function plugin_settings_link( $links ) { |
| 209 |
$options = Options::get_instance(); |
| 210 |
$admin_menu = $options->get( 'advanced_admin_menu' ); |
| 211 |
$settings_url = 'settings' === $admin_menu ? admin_url( 'options-general.php?page=authorizer' ) : admin_url( 'admin.php?page=authorizer' ); |
| 212 |
array_unshift( $links, '<a href="' . $settings_url . '">' . __( 'Settings', 'authorizer' ) . '</a>' ); |
| 213 |
return $links; |
| 214 |
} |
| 215 |
|
| 216 |
|
| 217 |
/** |
| 218 |
* Add a link to this plugin's network settings page from the WordPress Plugins page. |
| 219 |
* Called from "network_admin_plugin_action_links" filter in __construct() above. |
| 220 |
* |
| 221 |
* Filter: network_admin_plugin_action_links_authorizer.php |
| 222 |
* |
| 223 |
* @param array $links Network admin sidebar links. |
| 224 |
* @return array Network admin sidebar links with Authorizer added. |
| 225 |
*/ |
| 226 |
public function network_admin_plugin_settings_link( $links ) { |
| 227 |
$settings_link = '<a href="admin.php?page=authorizer">' . __( 'Network Settings', 'authorizer' ) . '</a>'; |
| 228 |
array_unshift( $links, $settings_link ); |
| 229 |
return $links; |
| 230 |
} |
| 231 |
|
| 232 |
|
| 233 |
/** |
| 234 |
* Create sections and options. |
| 235 |
* |
| 236 |
* Action: admin_init |
| 237 |
*/ |
| 238 |
public function page_init() { |
| 239 |
/** |
| 240 |
* Create one setting that holds all the options (array). |
| 241 |
* |
| 242 |
* @see http://codex.wordpress.org/Function_Reference/register_setting |
| 243 |
* @see http://codex.wordpress.org/Function_Reference/add_settings_section |
| 244 |
* @see http://codex.wordpress.org/Function_Reference/add_settings_field |
| 245 |
*/ |
| 246 |
register_setting( |
| 247 |
'auth_settings_group', |
| 248 |
'auth_settings', |
| 249 |
array( Options::get_instance(), 'sanitize_options' ) |
| 250 |
); |
| 251 |
|
| 252 |
add_settings_section( |
| 253 |
'auth_settings_tabs', |
| 254 |
'', |
| 255 |
array( Options::get_instance(), 'print_section_info_tabs' ), |
| 256 |
'authorizer' |
| 257 |
); |
| 258 |
|
| 259 |
// Create Access Lists section. |
| 260 |
add_settings_section( |
| 261 |
'auth_settings_lists', |
| 262 |
'', |
| 263 |
array( Access_Lists::get_instance(), 'print_section_info_access_lists' ), |
| 264 |
'authorizer' |
| 265 |
); |
| 266 |
|
| 267 |
// Create Login Access section. |
| 268 |
add_settings_section( |
| 269 |
'auth_settings_access_login', |
| 270 |
'', |
| 271 |
array( Login_Access::get_instance(), 'print_section_info_access_login' ), |
| 272 |
'authorizer' |
| 273 |
); |
| 274 |
add_settings_field( |
| 275 |
'auth_settings_access_who_can_login', |
| 276 |
__( 'Who can log into the site?', 'authorizer' ), |
| 277 |
array( Login_Access::get_instance(), 'print_radio_auth_access_who_can_login' ), |
| 278 |
'authorizer', |
| 279 |
'auth_settings_access_login' |
| 280 |
); |
| 281 |
add_settings_field( |
| 282 |
'auth_settings_access_role_receive_pending_emails', |
| 283 |
__( 'Which role should receive email notifications about pending users?', 'authorizer' ), |
| 284 |
array( Login_Access::get_instance(), 'print_select_auth_access_role_receive_pending_emails' ), |
| 285 |
'authorizer', |
| 286 |
'auth_settings_access_login' |
| 287 |
); |
| 288 |
add_settings_field( |
| 289 |
'auth_settings_access_pending_redirect_to_message', |
| 290 |
__( 'What message should pending users see after attempting to log in?', 'authorizer' ), |
| 291 |
array( Login_Access::get_instance(), 'print_wysiwyg_auth_access_pending_redirect_to_message' ), |
| 292 |
'authorizer', |
| 293 |
'auth_settings_access_login' |
| 294 |
); |
| 295 |
add_settings_field( |
| 296 |
'auth_settings_access_blocked_redirect_to_message', |
| 297 |
__( 'What message should blocked users see after attempting to log in?', 'authorizer' ), |
| 298 |
array( Login_Access::get_instance(), 'print_wysiwyg_auth_access_blocked_redirect_to_message' ), |
| 299 |
'authorizer', |
| 300 |
'auth_settings_access_login' |
| 301 |
); |
| 302 |
add_settings_field( |
| 303 |
'auth_settings_access_should_email_approved_users', |
| 304 |
__( 'Send welcome email to new approved users?', 'authorizer' ), |
| 305 |
array( Login_Access::get_instance(), 'print_checkbox_auth_access_should_email_approved_users' ), |
| 306 |
'authorizer', |
| 307 |
'auth_settings_access_login' |
| 308 |
); |
| 309 |
add_settings_field( |
| 310 |
'auth_settings_access_email_approved_users_subject', |
| 311 |
__( 'Welcome email subject', 'authorizer' ), |
| 312 |
array( Login_Access::get_instance(), 'print_text_auth_access_email_approved_users_subject' ), |
| 313 |
'authorizer', |
| 314 |
'auth_settings_access_login' |
| 315 |
); |
| 316 |
add_settings_field( |
| 317 |
'auth_settings_access_email_approved_users_body', |
| 318 |
__( 'Welcome email body', 'authorizer' ), |
| 319 |
array( Login_Access::get_instance(), 'print_wysiwyg_auth_access_email_approved_users_body' ), |
| 320 |
'authorizer', |
| 321 |
'auth_settings_access_login' |
| 322 |
); |
| 323 |
|
| 324 |
// Create Public Access section. |
| 325 |
add_settings_section( |
| 326 |
'auth_settings_access_public', |
| 327 |
'', |
| 328 |
array( Public_Access::get_instance(), 'print_section_info_access_public' ), |
| 329 |
'authorizer' |
| 330 |
); |
| 331 |
add_settings_field( |
| 332 |
'auth_settings_access_who_can_view', |
| 333 |
__( 'Who can view the site?', 'authorizer' ), |
| 334 |
array( Public_Access::get_instance(), 'print_radio_auth_access_who_can_view' ), |
| 335 |
'authorizer', |
| 336 |
'auth_settings_access_public' |
| 337 |
); |
| 338 |
add_settings_field( |
| 339 |
'auth_settings_access_public_pages', |
| 340 |
__( 'What pages (if any) should be available to everyone?', 'authorizer' ), |
| 341 |
array( Public_Access::get_instance(), 'print_multiselect_auth_access_public_pages' ), |
| 342 |
'authorizer', |
| 343 |
'auth_settings_access_public' |
| 344 |
); |
| 345 |
add_settings_field( |
| 346 |
'auth_settings_access_redirect', |
| 347 |
__( 'What happens to people without access when they visit a private page?', 'authorizer' ), |
| 348 |
array( Public_Access::get_instance(), 'print_radio_auth_access_redirect' ), |
| 349 |
'authorizer', |
| 350 |
'auth_settings_access_public' |
| 351 |
); |
| 352 |
add_settings_field( |
| 353 |
'auth_settings_access_public_warning', |
| 354 |
__( 'What happens to people without access when they visit a public page?', 'authorizer' ), |
| 355 |
array( Public_Access::get_instance(), 'print_radio_auth_access_public_warning' ), |
| 356 |
'authorizer', |
| 357 |
'auth_settings_access_public' |
| 358 |
); |
| 359 |
add_settings_field( |
| 360 |
'auth_settings_access_redirect_to_message', |
| 361 |
__( 'What message should people without access see?', 'authorizer' ), |
| 362 |
array( Public_Access::get_instance(), 'print_wysiwyg_auth_access_redirect_to_message' ), |
| 363 |
'authorizer', |
| 364 |
'auth_settings_access_public' |
| 365 |
); |
| 366 |
|
| 367 |
// Create External Service Settings section. |
| 368 |
add_settings_section( |
| 369 |
'auth_settings_external', |
| 370 |
'', |
| 371 |
array( External::get_instance(), 'print_section_info_external' ), |
| 372 |
'authorizer' |
| 373 |
); |
| 374 |
add_settings_field( |
| 375 |
'auth_settings_access_default_role', |
| 376 |
__( 'Default role for new users', 'authorizer' ), |
| 377 |
array( External::get_instance(), 'print_select_auth_access_default_role' ), |
| 378 |
'authorizer', |
| 379 |
'auth_settings_external' |
| 380 |
); |
| 381 |
add_settings_field( |
| 382 |
'auth_settings_external_google', |
| 383 |
__( 'Google Logins', 'authorizer' ), |
| 384 |
array( Google::get_instance(), 'print_checkbox_auth_external_google' ), |
| 385 |
'authorizer', |
| 386 |
'auth_settings_external' |
| 387 |
); |
| 388 |
add_settings_field( |
| 389 |
'auth_settings_google_clientid', |
| 390 |
__( 'Google Client ID', 'authorizer' ), |
| 391 |
array( Google::get_instance(), 'print_text_google_clientid' ), |
| 392 |
'authorizer', |
| 393 |
'auth_settings_external' |
| 394 |
); |
| 395 |
add_settings_field( |
| 396 |
'auth_settings_google_clientsecret', |
| 397 |
__( 'Google Client Secret', 'authorizer' ), |
| 398 |
array( Google::get_instance(), 'print_text_google_clientsecret' ), |
| 399 |
'authorizer', |
| 400 |
'auth_settings_external' |
| 401 |
); |
| 402 |
add_settings_field( |
| 403 |
'auth_settings_google_hosteddomain', |
| 404 |
__( 'Google Hosted Domain', 'authorizer' ), |
| 405 |
array( Google::get_instance(), 'print_text_google_hosteddomain' ), |
| 406 |
'authorizer', |
| 407 |
'auth_settings_external' |
| 408 |
); |
| 409 |
add_settings_field( |
| 410 |
'auth_settings_external_cas', |
| 411 |
__( 'CAS Logins', 'authorizer' ), |
| 412 |
array( Cas::get_instance(), 'print_checkbox_auth_external_cas' ), |
| 413 |
'authorizer', |
| 414 |
'auth_settings_external' |
| 415 |
); |
| 416 |
add_settings_field( |
| 417 |
'auth_settings_cas_custom_label', |
| 418 |
__( 'CAS custom label', 'authorizer' ), |
| 419 |
array( Cas::get_instance(), 'print_text_cas_custom_label' ), |
| 420 |
'authorizer', |
| 421 |
'auth_settings_external' |
| 422 |
); |
| 423 |
add_settings_field( |
| 424 |
'auth_settings_cas_host', |
| 425 |
__( 'CAS server hostname', 'authorizer' ), |
| 426 |
array( Cas::get_instance(), 'print_text_cas_host' ), |
| 427 |
'authorizer', |
| 428 |
'auth_settings_external' |
| 429 |
); |
| 430 |
add_settings_field( |
| 431 |
'auth_settings_cas_port', |
| 432 |
__( 'CAS server port', 'authorizer' ), |
| 433 |
array( Cas::get_instance(), 'print_text_cas_port' ), |
| 434 |
'authorizer', |
| 435 |
'auth_settings_external' |
| 436 |
); |
| 437 |
add_settings_field( |
| 438 |
'auth_settings_cas_path', |
| 439 |
__( 'CAS server path/context', 'authorizer' ), |
| 440 |
array( Cas::get_instance(), 'print_text_cas_path' ), |
| 441 |
'authorizer', |
| 442 |
'auth_settings_external' |
| 443 |
); |
| 444 |
add_settings_field( |
| 445 |
'auth_settings_cas_version', |
| 446 |
'CAS server version', |
| 447 |
array( Cas::get_instance(), 'print_select_cas_version' ), |
| 448 |
'authorizer', |
| 449 |
'auth_settings_external' |
| 450 |
); |
| 451 |
add_settings_field( |
| 452 |
'auth_settings_cas_attr_email', |
| 453 |
__( 'CAS attribute containing email address', 'authorizer' ), |
| 454 |
array( Cas::get_instance(), 'print_text_cas_attr_email' ), |
| 455 |
'authorizer', |
| 456 |
'auth_settings_external' |
| 457 |
); |
| 458 |
add_settings_field( |
| 459 |
'auth_settings_cas_attr_first_name', |
| 460 |
__( 'CAS attribute containing first name', 'authorizer' ), |
| 461 |
array( Cas::get_instance(), 'print_text_cas_attr_first_name' ), |
| 462 |
'authorizer', |
| 463 |
'auth_settings_external' |
| 464 |
); |
| 465 |
add_settings_field( |
| 466 |
'auth_settings_cas_attr_last_name', |
| 467 |
__( 'CAS attribute containing last name', 'authorizer' ), |
| 468 |
array( Cas::get_instance(), 'print_text_cas_attr_last_name' ), |
| 469 |
'authorizer', |
| 470 |
'auth_settings_external' |
| 471 |
); |
| 472 |
add_settings_field( |
| 473 |
'auth_settings_cas_attr_update_on_login', |
| 474 |
__( 'CAS attribute update', 'authorizer' ), |
| 475 |
array( Cas::get_instance(), 'print_checkbox_cas_attr_update_on_login' ), |
| 476 |
'authorizer', |
| 477 |
'auth_settings_external' |
| 478 |
); |
| 479 |
add_settings_field( |
| 480 |
'auth_settings_cas_auto_login', |
| 481 |
__( 'CAS automatic login', 'authorizer' ), |
| 482 |
array( Cas::get_instance(), 'print_checkbox_cas_auto_login' ), |
| 483 |
'authorizer', |
| 484 |
'auth_settings_external' |
| 485 |
); |
| 486 |
add_settings_field( |
| 487 |
'auth_settings_cas_link_on_username', |
| 488 |
__( 'CAS users linked by username', 'authorizer' ), |
| 489 |
array( Cas::get_instance(), 'print_checkbox_cas_link_on_username' ), |
| 490 |
'authorizer', |
| 491 |
'auth_settings_external' |
| 492 |
); |
| 493 |
add_settings_field( |
| 494 |
'auth_settings_external_ldap', |
| 495 |
__( 'LDAP Logins', 'authorizer' ), |
| 496 |
array( Ldap::get_instance(), 'print_checkbox_auth_external_ldap' ), |
| 497 |
'authorizer', |
| 498 |
'auth_settings_external' |
| 499 |
); |
| 500 |
add_settings_field( |
| 501 |
'auth_settings_ldap_host', |
| 502 |
__( 'LDAP Host', 'authorizer' ), |
| 503 |
array( Ldap::get_instance(), 'print_text_ldap_host' ), |
| 504 |
'authorizer', |
| 505 |
'auth_settings_external' |
| 506 |
); |
| 507 |
add_settings_field( |
| 508 |
'auth_settings_ldap_port', |
| 509 |
__( 'LDAP Port', 'authorizer' ), |
| 510 |
array( Ldap::get_instance(), 'print_text_ldap_port' ), |
| 511 |
'authorizer', |
| 512 |
'auth_settings_external' |
| 513 |
); |
| 514 |
add_settings_field( |
| 515 |
'auth_settings_ldap_tls', |
| 516 |
__( 'Use TLS', 'authorizer' ), |
| 517 |
array( Ldap::get_instance(), 'print_checkbox_ldap_tls' ), |
| 518 |
'authorizer', |
| 519 |
'auth_settings_external' |
| 520 |
); |
| 521 |
add_settings_field( |
| 522 |
'auth_settings_ldap_search_base', |
| 523 |
__( 'LDAP Search Base', 'authorizer' ), |
| 524 |
array( Ldap::get_instance(), 'print_text_ldap_search_base' ), |
| 525 |
'authorizer', |
| 526 |
'auth_settings_external' |
| 527 |
); |
| 528 |
add_settings_field( |
| 529 |
'auth_settings_ldap_uid', |
| 530 |
__( 'LDAP attribute containing username', 'authorizer' ), |
| 531 |
array( Ldap::get_instance(), 'print_text_ldap_uid' ), |
| 532 |
'authorizer', |
| 533 |
'auth_settings_external' |
| 534 |
); |
| 535 |
add_settings_field( |
| 536 |
'auth_settings_ldap_attr_email', |
| 537 |
__( 'LDAP attribute containing email address', 'authorizer' ), |
| 538 |
array( Ldap::get_instance(), 'print_text_ldap_attr_email' ), |
| 539 |
'authorizer', |
| 540 |
'auth_settings_external' |
| 541 |
); |
| 542 |
add_settings_field( |
| 543 |
'auth_settings_ldap_user', |
| 544 |
__( 'LDAP Directory User', 'authorizer' ), |
| 545 |
array( Ldap::get_instance(), 'print_text_ldap_user' ), |
| 546 |
'authorizer', |
| 547 |
'auth_settings_external' |
| 548 |
); |
| 549 |
add_settings_field( |
| 550 |
'auth_settings_ldap_password', |
| 551 |
__( 'LDAP Directory User Password', 'authorizer' ), |
| 552 |
array( Ldap::get_instance(), 'print_password_ldap_password' ), |
| 553 |
'authorizer', |
| 554 |
'auth_settings_external' |
| 555 |
); |
| 556 |
add_settings_field( |
| 557 |
'auth_settings_ldap_lostpassword_url', |
| 558 |
__( 'Custom lost password URL', 'authorizer' ), |
| 559 |
array( Ldap::get_instance(), 'print_text_ldap_lostpassword_url' ), |
| 560 |
'authorizer', |
| 561 |
'auth_settings_external' |
| 562 |
); |
| 563 |
add_settings_field( |
| 564 |
'auth_settings_ldap_attr_first_name', |
| 565 |
__( 'LDAP attribute containing first name', 'authorizer' ), |
| 566 |
array( Ldap::get_instance(), 'print_text_ldap_attr_first_name' ), |
| 567 |
'authorizer', |
| 568 |
'auth_settings_external' |
| 569 |
); |
| 570 |
add_settings_field( |
| 571 |
'auth_settings_ldap_attr_last_name', |
| 572 |
__( 'LDAP attribute containing last name', 'authorizer' ), |
| 573 |
array( Ldap::get_instance(), 'print_text_ldap_attr_last_name' ), |
| 574 |
'authorizer', |
| 575 |
'auth_settings_external' |
| 576 |
); |
| 577 |
add_settings_field( |
| 578 |
'auth_settings_ldap_attr_update_on_login', |
| 579 |
__( 'LDAP attribute update', 'authorizer' ), |
| 580 |
array( Ldap::get_instance(), 'print_checkbox_ldap_attr_update_on_login' ), |
| 581 |
'authorizer', |
| 582 |
'auth_settings_external' |
| 583 |
); |
| 584 |
|
| 585 |
// Create Advanced Settings section. |
| 586 |
add_settings_section( |
| 587 |
'auth_settings_advanced', |
| 588 |
'', |
| 589 |
array( Advanced::get_instance(), 'print_section_info_advanced' ), |
| 590 |
'authorizer' |
| 591 |
); |
| 592 |
add_settings_field( |
| 593 |
'auth_settings_advanced_lockouts', |
| 594 |
__( 'Limit invalid login attempts', 'authorizer' ), |
| 595 |
array( Advanced::get_instance(), 'print_text_auth_advanced_lockouts' ), |
| 596 |
'authorizer', |
| 597 |
'auth_settings_advanced' |
| 598 |
); |
| 599 |
add_settings_field( |
| 600 |
'auth_settings_advanced_hide_wp_login', |
| 601 |
__( 'Hide WordPress Login', 'authorizer' ), |
| 602 |
array( Advanced::get_instance(), 'print_checkbox_auth_advanced_hide_wp_login' ), |
| 603 |
'authorizer', |
| 604 |
'auth_settings_advanced' |
| 605 |
); |
| 606 |
add_settings_field( |
| 607 |
'auth_settings_advanced_branding', |
| 608 |
__( 'Custom WordPress login branding', 'authorizer' ), |
| 609 |
array( Advanced::get_instance(), 'print_radio_auth_advanced_branding' ), |
| 610 |
'authorizer', |
| 611 |
'auth_settings_advanced' |
| 612 |
); |
| 613 |
add_settings_field( |
| 614 |
'auth_settings_advanced_admin_menu', |
| 615 |
__( 'Authorizer admin menu item location', 'authorizer' ), |
| 616 |
array( Advanced::get_instance(), 'print_radio_auth_advanced_admin_menu' ), |
| 617 |
'authorizer', |
| 618 |
'auth_settings_advanced' |
| 619 |
); |
| 620 |
add_settings_field( |
| 621 |
'auth_settings_advanced_usermeta', |
| 622 |
__( 'Show custom usermeta in user list', 'authorizer' ), |
| 623 |
array( Advanced::get_instance(), 'print_select_auth_advanced_usermeta' ), |
| 624 |
'authorizer', |
| 625 |
'auth_settings_advanced' |
| 626 |
); |
| 627 |
add_settings_field( |
| 628 |
'auth_settings_advanced_users_per_page', |
| 629 |
__( 'Number of users per page', 'authorizer' ), |
| 630 |
array( Advanced::get_instance(), 'print_text_auth_advanced_users_per_page' ), |
| 631 |
'authorizer', |
| 632 |
'auth_settings_advanced' |
| 633 |
); |
| 634 |
add_settings_field( |
| 635 |
'auth_settings_advanced_users_sort_by', |
| 636 |
__( 'Approved users sort method', 'authorizer' ), |
| 637 |
array( Advanced::get_instance(), 'print_select_auth_advanced_users_sort_by' ), |
| 638 |
'authorizer', |
| 639 |
'auth_settings_advanced' |
| 640 |
); |
| 641 |
add_settings_field( |
| 642 |
'auth_settings_advanced_users_sort_order', |
| 643 |
__( 'Approved users sort order', 'authorizer' ), |
| 644 |
array( Advanced::get_instance(), 'print_select_auth_advanced_users_sort_order' ), |
| 645 |
'authorizer', |
| 646 |
'auth_settings_advanced' |
| 647 |
); |
| 648 |
add_settings_field( |
| 649 |
'auth_settings_advanced_widget_enabled', |
| 650 |
__( 'Show dashboard widget to admin users', 'authorizer' ), |
| 651 |
array( Advanced::get_instance(), 'print_checkbox_auth_advanced_widget_enabled' ), |
| 652 |
'authorizer', |
| 653 |
'auth_settings_advanced' |
| 654 |
); |
| 655 |
// On multisite installs, add an option to override all multisite settings on individual sites. |
| 656 |
if ( is_multisite() ) { |
| 657 |
add_settings_field( |
| 658 |
'auth_settings_advanced_override_multisite', |
| 659 |
__( 'Override multisite options', 'authorizer' ), |
| 660 |
array( Advanced::get_instance(), 'print_checkbox_auth_advanced_override_multisite' ), |
| 661 |
'authorizer', |
| 662 |
'auth_settings_advanced' |
| 663 |
); |
| 664 |
} |
| 665 |
} |
| 666 |
|
| 667 |
|
| 668 |
/** |
| 669 |
* Output the HTML for the options page. |
| 670 |
*/ |
| 671 |
public function create_admin_page() { |
| 672 |
?> |
| 673 |
<div class="wrap"> |
| 674 |
<h2><?php esc_html_e( 'Authorizer Settings', 'authorizer' ); ?></h2> |
| 675 |
<form method="post" action="options.php" autocomplete="off"> |
| 676 |
<?php |
| 677 |
// This prints out all hidden settings fields. |
| 678 |
settings_fields( 'auth_settings_group' ); |
| 679 |
// This prints out all the sections. |
| 680 |
do_settings_sections( 'authorizer' ); |
| 681 |
submit_button(); |
| 682 |
?> |
| 683 |
</form> |
| 684 |
</div> |
| 685 |
<?php |
| 686 |
} |
| 687 |
|
| 688 |
|
| 689 |
/** |
| 690 |
* Output the HTML for the options page. |
| 691 |
*/ |
| 692 |
public function create_network_admin_page() { |
| 693 |
if ( ! current_user_can( 'manage_network_options' ) ) { |
| 694 |
wp_die( wp_kses( __( 'You do not have sufficient permissions to access this page.', 'authorizer' ), Helper::$allowed_html ) ); |
| 695 |
} |
| 696 |
$options = Options::get_instance(); |
| 697 |
$access_lists = Access_Lists::get_instance(); |
| 698 |
$login_access = Login_Access::get_instance(); |
| 699 |
$public_access = Public_Access::get_instance(); |
| 700 |
$external = External::get_instance(); |
| 701 |
$google = Google::get_instance(); |
| 702 |
$cas = Cas::get_instance(); |
| 703 |
$ldap = Ldap::get_instance(); |
| 704 |
$advanced = Advanced::get_instance(); |
| 705 |
$auth_settings = get_blog_option( get_network()->blog_id, 'auth_multisite_settings', array() ); |
| 706 |
?> |
| 707 |
<div class="wrap"> |
| 708 |
<form method="post" action="" autocomplete="off"> |
| 709 |
<h2><?php esc_html_e( 'Authorizer Settings', 'authorizer' ); ?></h2> |
| 710 |
<p><?php echo wp_kses( __( 'Most <strong>Authorizer</strong> settings are set in the individual sites, but you can specify a few options here that apply to <strong>all sites in the network</strong>. These settings will override settings in the individual sites.', 'authorizer' ), Helper::$allowed_html ); ?></p> |
| 711 |
|
| 712 |
<input type="checkbox" id="auth_settings_multisite_override" name="auth_settings[multisite_override]" value="1"<?php checked( 1 === intval( $auth_settings['multisite_override'] ) ); ?> /><label for="auth_settings_multisite_override"><?php esc_html_e( 'Override individual site settings with the settings below', 'authorizer' ); ?></label> |
| 713 |
|
| 714 |
<div id="auth_multisite_settings_disabled_overlay" style="display: none;"></div> |
| 715 |
|
| 716 |
<div class="wrap" id="auth_multisite_settings"> |
| 717 |
<?php $options->print_section_info_tabs( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?> |
| 718 |
|
| 719 |
<?php wp_nonce_field( 'save_auth_settings', 'nonce_save_auth_settings' ); ?> |
| 720 |
|
| 721 |
<?php // Custom access lists (for network, we only really want approved list, not pending or blocked). ?> |
| 722 |
<div id="section_info_access_lists" class="section_info"> |
| 723 |
<p><?php esc_html_e( 'Manage who has access to all sites in the network.', 'authorizer' ); ?></p> |
| 724 |
</div> |
| 725 |
<table class="form-table"><tbody> |
| 726 |
<tr> |
| 727 |
<th scope="row"><?php esc_html_e( 'Who can log in to sites in this network?', 'authorizer' ); ?></th> |
| 728 |
<td><?php $login_access->print_radio_auth_access_who_can_login( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 729 |
</tr> |
| 730 |
<tr> |
| 731 |
<th scope="row"><?php esc_html_e( 'Who can view sites in this network?', 'authorizer' ); ?></th> |
| 732 |
<td><?php $public_access->print_radio_auth_access_who_can_view( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 733 |
</tr> |
| 734 |
<tr> |
| 735 |
<th scope="row"><?php esc_html_e( 'Approved Users (All Sites)', 'authorizer' ); ?><br /><small><em><?php echo wp_kses( __( 'Note: these users will <strong>not</strong> receive welcome emails when approved. Only users approved from individual sites can receive these messages.', 'authorizer' ), Helper::$allowed_html ); ?></em></small></th> |
| 736 |
<td><?php $access_lists->print_combo_auth_access_users_approved( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 737 |
</tr> |
| 738 |
</tbody></table> |
| 739 |
|
| 740 |
<?php $external->print_section_info_external(); ?> |
| 741 |
<table class="form-table"><tbody> |
| 742 |
<tr> |
| 743 |
<th scope="row"><?php esc_html_e( 'Default role for new users', 'authorizer' ); ?></th> |
| 744 |
<td><?php $external->print_select_auth_access_default_role( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 745 |
</tr> |
| 746 |
<tr> |
| 747 |
<th scope="row"><?php esc_html_e( 'Google Logins', 'authorizer' ); ?></th> |
| 748 |
<td><?php $google->print_checkbox_auth_external_google( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 749 |
</tr> |
| 750 |
<tr> |
| 751 |
<th scope="row"><?php esc_html_e( 'Google Client ID', 'authorizer' ); ?></th> |
| 752 |
<td><?php $google->print_text_google_clientid( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 753 |
</tr> |
| 754 |
<tr> |
| 755 |
<th scope="row"><?php esc_html_e( 'Google Client Secret', 'authorizer' ); ?></th> |
| 756 |
<td><?php $google->print_text_google_clientsecret( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 757 |
</tr> |
| 758 |
<tr> |
| 759 |
<th scope="row"><?php esc_html_e( 'Google Hosted Domain', 'authorizer' ); ?></th> |
| 760 |
<td><?php $google->print_text_google_hosteddomain( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 761 |
</tr> |
| 762 |
<tr> |
| 763 |
<th scope="row"><?php esc_html_e( 'CAS Logins', 'authorizer' ); ?></th> |
| 764 |
<td><?php $cas->print_checkbox_auth_external_cas( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 765 |
</tr> |
| 766 |
<tr> |
| 767 |
<th scope="row"><?php esc_html_e( 'CAS Custom Label', 'authorizer' ); ?></th> |
| 768 |
<td><?php $cas->print_text_cas_custom_label( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 769 |
</tr> |
| 770 |
<tr> |
| 771 |
<th scope="row"><?php esc_html_e( 'CAS server hostname', 'authorizer' ); ?></th> |
| 772 |
<td><?php $cas->print_text_cas_host( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 773 |
</tr> |
| 774 |
<tr> |
| 775 |
<th scope="row"><?php esc_html_e( 'CAS server port', 'authorizer' ); ?></th> |
| 776 |
<td><?php $cas->print_text_cas_port( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 777 |
</tr> |
| 778 |
<tr> |
| 779 |
<th scope="row"><?php esc_html_e( 'CAS server path/context', 'authorizer' ); ?></th> |
| 780 |
<td><?php $cas->print_text_cas_path( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 781 |
</tr> |
| 782 |
<tr> |
| 783 |
<th scope="row"><?php esc_html_e( 'CAS server version', 'authorizer' ); ?></th> |
| 784 |
<td><?php $cas->print_select_cas_version( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 785 |
</tr> |
| 786 |
<tr> |
| 787 |
<th scope="row"><?php esc_html_e( 'CAS attribute containing email', 'authorizer' ); ?></th> |
| 788 |
<td><?php $cas->print_text_cas_attr_email( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 789 |
</tr> |
| 790 |
<tr> |
| 791 |
<th scope="row"><?php esc_html_e( 'CAS attribute containing first name', 'authorizer' ); ?></th> |
| 792 |
<td><?php $cas->print_text_cas_attr_first_name( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 793 |
</tr> |
| 794 |
<tr> |
| 795 |
<th scope="row"><?php esc_html_e( 'CAS attribute containing last name', 'authorizer' ); ?></th> |
| 796 |
<td><?php $cas->print_text_cas_attr_last_name( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 797 |
</tr> |
| 798 |
<tr> |
| 799 |
<th scope="row"><?php esc_html_e( 'CAS attribute update', 'authorizer' ); ?></th> |
| 800 |
<td><?php $cas->print_checkbox_cas_attr_update_on_login( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 801 |
</tr> |
| 802 |
<tr> |
| 803 |
<th scope="row"><?php esc_html_e( 'CAS automatic login', 'authorizer' ); ?></th> |
| 804 |
<td><?php $cas->print_checkbox_cas_auto_login( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 805 |
</tr> |
| 806 |
<tr> |
| 807 |
<th scope="row"><?php esc_html_e( 'CAS users linked by username', 'authorizer' ); ?></th> |
| 808 |
<td><?php $cas->print_checkbox_cas_link_on_username( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 809 |
</tr> |
| 810 |
<tr> |
| 811 |
<th scope="row"><?php esc_html_e( 'LDAP Logins', 'authorizer' ); ?></th> |
| 812 |
<td><?php $ldap->print_checkbox_auth_external_ldap( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 813 |
</tr> |
| 814 |
<tr> |
| 815 |
<th scope="row"><?php esc_html_e( 'LDAP Host', 'authorizer' ); ?></th> |
| 816 |
<td><?php $ldap->print_text_ldap_host( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 817 |
</tr> |
| 818 |
<tr> |
| 819 |
<th scope="row"><?php esc_html_e( 'LDAP Port', 'authorizer' ); ?></th> |
| 820 |
<td><?php $ldap->print_text_ldap_port( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 821 |
</tr> |
| 822 |
<tr> |
| 823 |
<th scope="row"><?php esc_html_e( 'Use TLS', 'authorizer' ); ?></th> |
| 824 |
<td><?php $ldap->print_checkbox_ldap_tls( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 825 |
</tr> |
| 826 |
<tr> |
| 827 |
<th scope="row"><?php esc_html_e( 'LDAP Search Base', 'authorizer' ); ?></th> |
| 828 |
<td><?php $ldap->print_text_ldap_search_base( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 829 |
</tr> |
| 830 |
<tr> |
| 831 |
<th scope="row"><?php esc_html_e( 'LDAP attribute containing username', 'authorizer' ); ?></th> |
| 832 |
<td><?php $ldap->print_text_ldap_uid( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 833 |
</tr> |
| 834 |
<tr> |
| 835 |
<th scope="row"><?php esc_html_e( 'LDAP attribute containing email', 'authorizer' ); ?></th> |
| 836 |
<td><?php $ldap->print_text_ldap_attr_email( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 837 |
</tr> |
| 838 |
<tr> |
| 839 |
<th scope="row"><?php esc_html_e( 'LDAP Directory User', 'authorizer' ); ?></th> |
| 840 |
<td><?php $ldap->print_text_ldap_user( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 841 |
</tr> |
| 842 |
<tr> |
| 843 |
<th scope="row"><?php esc_html_e( 'LDAP Directory User Password', 'authorizer' ); ?></th> |
| 844 |
<td><?php $ldap->print_password_ldap_password( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 845 |
</tr> |
| 846 |
<tr> |
| 847 |
<th scope="row"><?php esc_html_e( 'Custom lost password URL', 'authorizer' ); ?></th> |
| 848 |
<td><?php $ldap->print_text_ldap_lostpassword_url( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 849 |
</tr> |
| 850 |
<tr> |
| 851 |
<th scope="row"><?php esc_html_e( 'LDAP attribute containing first name', 'authorizer' ); ?></th> |
| 852 |
<td><?php $ldap->print_text_ldap_attr_first_name( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 853 |
</tr> |
| 854 |
<tr> |
| 855 |
<th scope="row"><?php esc_html_e( 'LDAP attribute containing last name', 'authorizer' ); ?></th> |
| 856 |
<td><?php $ldap->print_text_ldap_attr_last_name( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 857 |
</tr> |
| 858 |
<tr> |
| 859 |
<th scope="row"><?php esc_html_e( 'LDAP attribute update', 'authorizer' ); ?></th> |
| 860 |
<td><?php $ldap->print_checkbox_ldap_attr_update_on_login( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 861 |
</tr> |
| 862 |
</tbody></table> |
| 863 |
|
| 864 |
<?php $advanced->print_section_info_advanced(); ?> |
| 865 |
<table class="form-table"><tbody> |
| 866 |
<tr> |
| 867 |
<th scope="row"><?php esc_html_e( 'Limit invalid login attempts', 'authorizer' ); ?></th> |
| 868 |
<td><?php $advanced->print_text_auth_advanced_lockouts( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 869 |
</tr> |
| 870 |
<tr> |
| 871 |
<th scope="row"><?php esc_html_e( 'Hide WordPress Logins', 'authorizer' ); ?></th> |
| 872 |
<td><?php $advanced->print_checkbox_auth_advanced_hide_wp_login( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 873 |
</tr> |
| 874 |
<tr> |
| 875 |
<th scope="row"><?php esc_html_e( 'Number of users per page', 'authorizer' ); ?></th> |
| 876 |
<td><?php $advanced->print_text_auth_advanced_users_per_page( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 877 |
</tr> |
| 878 |
<tr> |
| 879 |
<th scope="row"><?php esc_html_e( 'Approved users sort method', 'authorizer' ); ?></th> |
| 880 |
<td><?php $advanced->print_select_auth_advanced_users_sort_by( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 881 |
</tr> |
| 882 |
<tr> |
| 883 |
<th scope="row"><?php esc_html_e( 'Approved users sort order', 'authorizer' ); ?></th> |
| 884 |
<td><?php $advanced->print_select_auth_advanced_users_sort_order( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 885 |
</tr> |
| 886 |
<tr> |
| 887 |
<th scope="row"><?php esc_html_e( 'Show Dashboard Widget', 'authorizer' ); ?></th> |
| 888 |
<td><?php $advanced->print_checkbox_auth_advanced_widget_enabled( array( 'context' => Helper::NETWORK_CONTEXT ) ); ?></td> |
| 889 |
</tr> |
| 890 |
</tbody></table> |
| 891 |
|
| 892 |
<br class="clear" /> |
| 893 |
</div> |
| 894 |
<input type="button" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'authorizer' ); ?>" onclick="saveAuthMultisiteSettings(this);" /> |
| 895 |
</form> |
| 896 |
</div> |
| 897 |
<?php |
| 898 |
} |
| 899 |
|
| 900 |
|
| 901 |
/** |
| 902 |
* Network Admin menu item |
| 903 |
* |
| 904 |
* Action: network_admin_menu |
| 905 |
* |
| 906 |
* @return void |
| 907 |
*/ |
| 908 |
public function network_admin_menu() { |
| 909 |
// @see http://codex.wordpress.org/Function_Reference/add_menu_page |
| 910 |
add_menu_page( |
| 911 |
'Authorizer', |
| 912 |
'Authorizer', |
| 913 |
'manage_network_options', |
| 914 |
'authorizer', |
| 915 |
array( self::get_instance(), 'create_network_admin_page' ), |
| 916 |
'dashicons-groups', |
| 917 |
89 // Position. |
| 918 |
); |
| 919 |
} |
| 920 |
|
| 921 |
|
| 922 |
/** |
| 923 |
* Create the options page under Dashboard > Settings. |
| 924 |
* |
| 925 |
* Action: admin_menu |
| 926 |
*/ |
| 927 |
public function add_plugin_page() { |
| 928 |
$options = Options::get_instance(); |
| 929 |
$admin_menu = $options->get( 'advanced_admin_menu' ); |
| 930 |
if ( 'settings' === $admin_menu ) { |
| 931 |
// @see http://codex.wordpress.org/Function_Reference/add_options_page |
| 932 |
add_options_page( |
| 933 |
'Authorizer', |
| 934 |
'Authorizer', |
| 935 |
'create_users', |
| 936 |
'authorizer', |
| 937 |
array( self::get_instance(), 'create_admin_page' ) |
| 938 |
); |
| 939 |
} else { |
| 940 |
// @see http://codex.wordpress.org/Function_Reference/add_menu_page |
| 941 |
add_menu_page( |
| 942 |
'Authorizer', |
| 943 |
'Authorizer', |
| 944 |
'create_users', |
| 945 |
'authorizer', |
| 946 |
array( self::get_instance(), 'create_admin_page' ), |
| 947 |
'dashicons-groups', |
| 948 |
'99.0018465' // position (decimal is to make overlap with other plugins less likely). |
| 949 |
); |
| 950 |
} |
| 951 |
} |
| 952 |
|
| 953 |
|
| 954 |
/** |
| 955 |
* Load external resources on this plugin's options page. |
| 956 |
* |
| 957 |
* Action: load-settings_page_authorizer |
| 958 |
* Action: load-toplevel_page_authorizer |
| 959 |
* Action: admin_head-index.php |
| 960 |
*/ |
| 961 |
public function load_options_page() { |
| 962 |
wp_enqueue_script( 'authorizer', plugins_url( 'js/authorizer.js', plugin_root() ), array( 'jquery-effects-shake' ), '2.9.11', true ); |
| 963 |
wp_localize_script( |
| 964 |
'authorizer', |
| 965 |
'authL10n', |
| 966 |
array( |
| 967 |
'baseurl' => get_bloginfo( 'url' ), |
| 968 |
'saved' => esc_html__( 'Saved', 'authorizer' ), |
| 969 |
'duplicate' => esc_html__( 'Duplicate', 'authorizer' ), |
| 970 |
'failed' => esc_html__( 'Failed', 'authorizer' ), |
| 971 |
'local_wordpress_user' => esc_html__( 'Local WordPress user', 'authorizer' ), |
| 972 |
'block_ban_user' => esc_html__( 'Block/Ban user', 'authorizer' ), |
| 973 |
'remove_user' => esc_html__( 'Remove user', 'authorizer' ), |
| 974 |
'no_users_in' => esc_html__( 'No users in', 'authorizer' ), |
| 975 |
'save_changes' => esc_html__( 'Save Changes', 'authorizer' ), |
| 976 |
'private_pages' => esc_html__( 'Private Pages', 'authorizer' ), |
| 977 |
'public_pages' => esc_html__( 'Public Pages', 'authorizer' ), |
| 978 |
'first_page' => esc_html__( 'First page' ), |
| 979 |
'previous_page' => esc_html__( 'Previous page' ), |
| 980 |
'next_page' => esc_html__( 'Next page' ), |
| 981 |
'last_page' => esc_html__( 'Last page' ), |
| 982 |
'is_network_admin' => is_network_admin() ? '1' : '0', |
| 983 |
) |
| 984 |
); |
| 985 |
|
| 986 |
wp_enqueue_script( 'jquery-autogrow-textarea', plugins_url( 'vendor/jquery.autogrow-textarea/jquery.autogrow-textarea.js', plugin_root() ), array( 'jquery' ), '2.7.0', true ); |
| 987 |
|
| 988 |
wp_enqueue_script( 'jquery.multi-select', plugins_url( 'vendor/jquery.multi-select/js/jquery.multi-select.js', plugin_root() ), array( 'jquery' ), '1.8', true ); |
| 989 |
|
| 990 |
wp_register_style( 'authorizer-css', plugins_url( 'css/authorizer.css', plugin_root() ), array(), '2.9.8' ); |
| 991 |
wp_enqueue_style( 'authorizer-css' ); |
| 992 |
|
| 993 |
wp_register_style( 'jquery-multi-select-css', plugins_url( 'vendor/jquery.multi-select/css/multi-select.css', plugin_root() ), array(), '1.8' ); |
| 994 |
wp_enqueue_style( 'jquery-multi-select-css' ); |
| 995 |
|
| 996 |
add_action( 'admin_notices', array( self::get_instance(), 'admin_notices' ) ); // Add any notices to the top of the options page. |
| 997 |
add_action( 'admin_head', array( self::get_instance(), 'admin_head' ) ); // Add help documentation to the options page. |
| 998 |
} |
| 999 |
|
| 1000 |
} |
| 1001 |
|