Commit 0819608a authored by Nigel McNie's avatar Nigel McNie

Added the ability to unset your default profile icon. Fixes #1774.

parent a4dc1aed
......@@ -96,6 +96,7 @@ $string['emailingfailed'] = 'Profile saved, but emails were not sent to: %s';
$string['editprofile'] = 'Edit Profile';
$string['profileicons'] = 'Profile Icons';
$string['Default'] = 'Default';
$string['deleteselectedicons'] = 'Delete selected icons';
$string['profileicon'] = 'Profile Icon';
$string['noimagesfound'] = 'No images found';
$string['uploadedprofileiconsuccessfully'] = 'Uploaded new profile icon successfully';
......@@ -104,12 +105,16 @@ $string['profileiconsdefaultsetsuccessfully'] = 'Default profile icon set succes
$string['profileiconsdeletedsuccessfully'] = 'Profile icon(s) deleted successfully';
$string['profileiconsnoneselected'] = 'No profile icons were selected to be deleted';
$string['onlyfiveprofileicons'] = 'You may upload only five profile icons';
$string['or'] = 'or';
$string['profileiconuploadexceedsquota'] = 'Uploading this profile icon would exceed your disk quota. Try deleting some files you have uploaded';
$string['profileiconimagetoobig'] = 'The image you uploaded was too big (%sx%s pixels). It must not be larger than %sx%s pixels';
$string['uploadingfile'] = 'uploading file...';
$string['uploadprofileicon'] = 'Upload Profile Icon';
$string['profileiconsiconsizenotice'] = 'You may upload up to <strong>five</strong> profile icons here, and choose one to be displayed as your default icon at any one time. Your icons must be between 16x16 and %sx%s pixels';
$string['setdefault'] = 'Set Default';
$string['Title'] = 'Title';
$string['usenodefault'] = 'Use no default';
$string['usingnodefaultprofileicon'] = 'Now using no default profile icon';
$string['Created'] = 'Created';
$string['Description'] = 'Description';
......
......@@ -55,12 +55,16 @@ $settingsform = new Pieform(array(
'elements' => array(
'default' => array(
'type' => 'submit',
'value' => get_string('Default', 'artefact.internal')
'value' => get_string('Default', 'artefact.internal'),
),
'delete' => array(
'type' => 'submit',
'value' => get_string('Delete', 'artefact.internal')
)
'value' => get_string('Delete', 'artefact.internal'),
),
'unsetdefault' => array(
'type' => 'submit',
'value' => get_string('usenodefault', 'artefact.internal'),
),
)
));
......@@ -244,15 +248,8 @@ function settings_submit_delete(Pieform $form, $values) {
owner = ? AND
id IN($icons)", array($USER->id));
// Make sure a default is still set if possible. This behaviour will
// change later, see bug #1774
if (in_array($USER->get('profileicon'), explode(',', $icons))) {
if ($ids = get_records_select_array('artefact', "owner = ? AND artefacttype = 'profileicon'", array($USER->get('id')), '', 'id')) {
$USER->profileicon = $ids[0]->id;
}
else {
$USER->profileicon = null;
}
$USER->profileicon = null;
}
db_commit();
......@@ -274,6 +271,13 @@ function settings_submit_delete(Pieform $form, $values) {
redirect('/artefact/internal/profileicons.php');
}
function settings_submit_unsetdefault(Pieform $form, $values) {
global $USER, $SESSION;
$USER->profileicon = null;
$USER->commit();
$SESSION->add_info_msg(get_string('usingnodefaultprofileicon', 'artefact.internal'));
}
$smarty->assign('uploadform', $uploadform);
// This is a rare case where we don't actually care about the form, because
// it only contains submit buttons (which we can just write as HTML), and
......
......@@ -18,8 +18,8 @@
<tfoot>
<td></td>
<td></td>
<td><input id="settings_default" type="submit" class="submit" name="default" value="{str tag="default"}" tabindex="2"></td>
<td><input id="settings_delete" type="submit" class="submit" name="delete" value="{str tag="delete"}" tabindex="2"></td>
<td><input id="settings_default" type="submit" class="submit" name="default" value="{str tag="setdefault" section=artefact.internal}" tabindex="2"> {str tag="or" section="artefact.internal"} <input type="submit" class="submit" name="unsetdefault" value="{str tag="usenodefault" section="artefact.internal}" tabindex="2"></td>
<td><input id="settings_delete" type="submit" class="submit" name="delete" value="{str tag="deleteselectedicons" section=artefact.internal}" tabindex="2"></td>
</tfoot>
</table>
<input type="hidden" name="pieform_settings" value="">
......
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