Commit 61c9b6eb authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Display locked email as uneditable on Edit profile page (bug #917935)

The 'emaillist' pieform element doesn't appear greyed out or
uneditable when it's disabled.  This means that when the email address
field is locked in institution settings, or because the email address
is imported from Moodle, users may still try to add new addresses
without receiving a useful error message.

When displaying this element on the Edit Profile page, the help item
is hidden whenever the element is locked, because it refers to buttons
and links that don't appear in the form.

Change-Id: Ia9a149e9110932ebac9202a1691d29799d327dc2
Signed-off-by: default avatarRichard Mansfield <>
parent 506c004a
......@@ -134,6 +134,9 @@ foreach ( $element_list as $element => $type ) {
if (isset($lockedfields[$element]) && !$USER->get('admin')) {
$items[$element]['disabled'] = true;
if ($element == 'email') {
$items[$element]['help'] = false;
......@@ -71,6 +71,7 @@ function pieform_element_emaillist(Pieform $form, $element) {
$smarty->assign('name', $element['name']);
$smarty->assign('addbuttonstr', get_string('addbutton', 'artefact.internal'));
$smarty->assign('validationemailstr', json_encode(get_string('validationemailwillbesent', 'artefact.internal')));
$smarty->assign('disabled', !empty($element['disabled']));
return $smarty->fetch('form/emaillist.tpl');
{{if $disabled}}
{{foreach from=$validated item=email}}
<div class="validated">
<input disabled {{if $email == $default}} checked{{/if}} type="radio" name="{{$name}}_locked" value="{{$email}}">
<input type="hidden" name="{{$name}}_valid[]" value="{{$email}}">
{{if $email == $default}}<input type="hidden" name="{{$name}}_selected" value="{{$email}}">{{/if}}
{{foreach from=$unvalidated item=email}}
<div class="unvalidated">{{$email}}</div>
<input type="hidden" name="{{$name}}_invalid[]" value="{{$email}}">
<script type="text/javascript">
var {{$name}}_newrefinput = null;
var {{$name}}_newref = null;
......@@ -79,3 +95,4 @@
<a href="" onclick="{{$name}}_new(); return false;">{{str tag="addemail"}}</a>
Supports Markdown
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