Commit a3c602c8 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Update profile sideblock on username change

parent 9bafc473
...@@ -205,13 +205,17 @@ function accountprefs_submit(Pieform $form, $values) { ...@@ -205,13 +205,17 @@ function accountprefs_submit(Pieform $form, $values) {
} }
} }
$returndata = array();
if (isset($values['username']) && $values['username'] != $USER->get('username')) { if (isset($values['username']) && $values['username'] != $USER->get('username')) {
$USER->username = $values['username']; $USER->username = $values['username'];
$USER->commit(); $USER->commit();
$returndata['username'] = $values['username'];
} }
db_commit(); db_commit();
$form->json_reply(PIEFORM_OK, get_string('prefssaved', 'account')); $returndata['message'] = get_string('prefssaved', 'account');
$form->json_reply(PIEFORM_OK, $returndata);
} }
...@@ -227,7 +231,12 @@ function clearPasswords(form, data) { ...@@ -227,7 +231,12 @@ function clearPasswords(form, data) {
$('accountprefs_password1').value = ''; $('accountprefs_password1').value = '';
$('accountprefs_password2').value = ''; $('accountprefs_password2').value = '';
} }
}"); if (data.username) {
var username = getFirstElementByTagAndClassName('a', null, 'profile-sideblock-username');
replaceChildNodes(username, data.username);
}
}
");
$smarty->assign('heading', get_string('preferences')); $smarty->assign('heading', get_string('preferences'));
$smarty->display('account/index.tpl'); $smarty->display('account/index.tpl');
......
<h3><a href="{$WWWROOT}user/view.php?id={$data.id}">{$data.myname|escape}</a> <span class="s">(<a href="{$WWWROOT}user/view.php?id={$data.id}">{$data.username|escape}</a>)</span></h3> <h3><a href="{$WWWROOT}user/view.php?id={$data.id}">{$data.myname|escape}</a> <span class="s" id="profile-sideblock-username">(<a href="{$WWWROOT}user/view.php?id={$data.id}">{$data.username|escape}</a>)</span></h3>
<div class="fr"><a href="{$WWWROOT}user/view.php?id={$data.id}"><div class="center" style="width: 50px; height: 50px;"><img src="{$WWWROOT}thumb.php?type=profileiconbyid&amp;maxwidth=50&amp;maxheight=50&amp;id={$data.profileicon}" alt=""></div></a></div> <div class="fr"><a href="{$WWWROOT}user/view.php?id={$data.id}"><div class="center" style="width: 50px; height: 50px;"><img src="{$WWWROOT}thumb.php?type=profileiconbyid&amp;maxwidth=50&amp;maxheight=50&amp;id={$data.profileicon}" alt=""></div></a></div>
{if $data.mnetloggedinfrom}<p>{$data.mnetloggedinfrom}</p>{/if} {if $data.mnetloggedinfrom}<p>{$data.mnetloggedinfrom}</p>{/if}
<ul class="sidebar-ul-title"> <ul class="sidebar-ul-title">
......
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