Commit 6fe530c0 authored by Richard Mansfield's avatar Richard Mansfield

Add an option to stop users from editing their profile urls

Bug #1006634, part 1

Some sites may wish to enforce a policy to leave profile urls as close
as possible to usernames.

Change-Id: I6931a34baaca91b19f2c3696c3440bc033b663af
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 801d39cc
......@@ -85,7 +85,7 @@ if ($authobj->authname == 'internal') {
);
}
if (get_config('cleanurls')) {
if (get_config('cleanurls') && get_config('cleanurlusereditable')) {
$elements['changeprofileurl'] = array(
'value' => '<tr><td colspan="2"><h3>' . get_string('changeprofileurl', 'account') . '</h3></td></tr>'
);
......@@ -164,7 +164,7 @@ function accountprefs_validate(Pieform $form, $values) {
}
}
if (get_config('cleanurls') && $values['urlid'] != $USER->get('urlid')) {
if (isset($values['urlid']) && get_config('cleanurls') && $values['urlid'] != $USER->get('urlid')) {
if (strlen($values['urlid']) < 3) {
$form->set_error('urlid', get_string('rule.minlength.minlength', 'pieforms', 3));
}
......
......@@ -302,3 +302,6 @@ $cfg->cleanurlinvalidcharacters = '/[^a-zA-Z0-9]+/';
// A pattern to validate user-editable fields for use in clean urls. If a user enters a string that
// doesn't match this, it's an error.
$cfg->cleanurlvalidate = '/^[a-z0-9-]*$/';
// Setting this to false will remove the "Change profile URL" option from the settings page.
$cfg->cleanurlusereditable = true;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment