mirror of https://github.com/BOINC/boinc.git
Merge pull request #2725 from drshawnkwang/drupal_feature-ignorepath-adminlist
Drupal: Add admin ability to customize the list of ignored paths.
This commit is contained in:
commit
734a0a3bb4
|
@ -325,6 +325,7 @@ function boincuser_admin_scheduler_submit($form, &$form_state) {
|
|||
* Drupal-BOINC Web site related options.
|
||||
*/
|
||||
function boincuser_admin_weboptions(&$form_state) {
|
||||
global $base_url;
|
||||
$form = array();
|
||||
|
||||
//form defaults
|
||||
|
@ -336,6 +337,7 @@ function boincuser_admin_weboptions(&$form_state) {
|
|||
'boinc_weboptions_agreequestion' => variable_get('boinc_weboptions_agreequestion', 'Do you agree with the above terms of use?'),
|
||||
'boinc_weboptions_registrationtitle2' => variable_get('boinc_weboptions_registrationtitle2', 'Fill in your name, email, and choose a secure passphrase.'),
|
||||
'boinc_weboptions_existinguser_tou' => variable_get('boinc_weboptions_existinguser_tou', FALSE),
|
||||
'boinc_weboptions_pathstoignore' => variable_get('boinc_weboptions_pathstoignore', "moderation\ncontent/moderation\nprivacy"),
|
||||
'boinc_weboptions_accountfinish' => variable_get('boinc_weboptions_accountfinish', ''),
|
||||
'boinc_weboptions_moderationpage' => variable_get('boinc_weboptions_moderationpage', ''),
|
||||
'boinc_weboptions_rulespolicies' => variable_get('boinc_weboptions_rulespolicies', ''),
|
||||
|
@ -399,6 +401,17 @@ function boincuser_admin_weboptions(&$form_state) {
|
|||
'#description' => t('If TRUE, existing users are forced to agree to a terms of use (if present) when the login and the system has detected they have not agreed. Otherwise they may login as normal. This option has no affect on whether or not new users must agree to the terms of use.'),
|
||||
);
|
||||
|
||||
$form['boinc_weboptions_pathstoignore'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Paths to ignore the Terms of Use page'),
|
||||
'#default_value' => $default['boinc_weboptions_pathstoignore'],
|
||||
'#cols' => 60,
|
||||
'#rows' => 8,
|
||||
'#description' => t('A list of Drupal URLs/paths to ignore for Terms of Use (ToU). If the option above \'Are existing users forced to agree to the Terms of Use?\' is activated, then some paths need to be ignored when checking if a user has agreed to the ToU. A good example is the logout path, "logout", or else users will not be able to logout!
|
||||
<p>There is a default list of paths that must be ignored or else the site will not function. They are not included in this box. Here you may provide additional paths to be ignored, for example the privacy policy page may be accessible so that users may read it before agreeing to the site\'s ToU.
|
||||
<p>Paths should be entered one per line. All paths should be <em>lower-case</em> and should not include a leading \'/\'. Example: account/info/edit will allow the user to visit ' . $base_url . '/account/info/edit without first agreeing to the ToU. Regexp are allowed. Example: account/* will allow the user to visit any path starting with ' . $base_url . '/account/.'),
|
||||
);
|
||||
|
||||
$form['pathtitle'] = array(
|
||||
'#value' => '<h3>Path Options</h3>',
|
||||
);
|
||||
|
@ -442,7 +455,7 @@ function boincuser_admin_weboptions(&$form_state) {
|
|||
'#rows' => 7,
|
||||
'#description' => t('Username blacklist: List of names that users will not be able to choose as their BOINC username. This will only affect Web registration and when a user changes their name using the Web site. Names should be entered one per line.<p>All names should be <em>lower-case</em>. The comparison made is case-insensitive.<p>If you wish to <em>disable</em> this feature, remove all names from this textbox; the blacklist will be empty.'),
|
||||
);
|
||||
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
|
|
|
@ -259,23 +259,31 @@ function boincuser_init() {
|
|||
$path = drupal_get_path_alias($_GET['q']);
|
||||
|
||||
// Any paths that should NOT be redirected go here.
|
||||
// @todo - replace this static array with one that allows
|
||||
// admins to specify custom paths (patterns) to ignore.
|
||||
$paths_to_ignore = array(
|
||||
// The site will not function correctly if these are not exempt!
|
||||
$paths0 = array(
|
||||
'user/termsofuse',
|
||||
'logout',
|
||||
'privacy',
|
||||
'moderation',
|
||||
'account/info/edit',
|
||||
'user/' . $user->uid . '/edit',
|
||||
'user/' . $user->uid . '/recoveremail/*',
|
||||
'recover_email.php',
|
||||
);
|
||||
if (module_exists('boincuser_delete')) {
|
||||
$paths_to_ignore[] = 'user/' . $user->uid . '/delete';
|
||||
$paths_to_ignore[] = 'user/' . $user->uid . '/deleteconfirm/*';
|
||||
$paths_to_ignore[] = 'user/' . $user->uid . '/odeleteconfirm/*';
|
||||
$paths0[] = 'user/' . $user->uid . '/delete';
|
||||
$paths0[] = 'user/' . $user->uid . '/deleteconfirm/*';
|
||||
$paths0[] = 'user/' . $user->uid . '/odeleteconfirm/*';
|
||||
}
|
||||
|
||||
// Paths added by the admin
|
||||
$paths1 = preg_split('/\r\n|\r|\n/', variable_get('boinc_weboptions_pathstoignore', "moderation\ncontent/moderation\nprivacy"));
|
||||
$paths2 = array();
|
||||
if (is_array($paths1)) {
|
||||
$paths2 = array_map('strtolower', $paths1);
|
||||
}
|
||||
|
||||
// paths to ignore
|
||||
$paths_to_ignore = array_unique( array_merge($paths0, $paths2) );
|
||||
|
||||
if (!_boincuser_ignore_paths($path, $paths_to_ignore)) {
|
||||
drupal_goto('user/termsofuse');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue