Commit 446357e5 authored by Andrew Robert Nicols's avatar Andrew Robert Nicols Committed by Richard Mansfield
Browse files

User Interface to allow users to enable/disable email.


Signed-off-by: default avatarAndrew Robert Nicols <andrew.nicols@luns.net.uk>
parent 1c704583
......@@ -61,6 +61,10 @@ foreach ($activitytypes as $type) {
else {
$section = 'activity';
}
if ($dv == 'email' && !isset($maildisabledmsg) && get_account_preference($USER->get('id'),'maildisabled')) {
$SESSION->add_error_msg(get_string('maildisableddescription', 'account', get_config('wwwroot') . 'account/'), false);
$maildisabledmsg = true;
}
$elements['activity_'.$type->id] = array(
'defaultvalue' => $dv,
'type' => 'select',
......
......@@ -111,6 +111,17 @@ $elements['wysiwyg'] = array(
),
'help' => true,
);
$elements['maildisabled'] = array(
'type' => 'radio',
'defaultvalue' => get_account_preference($USER->get('id'), 'maildisabled'),
'title' => get_string('email'),
'separator' => '<br>',
'options' => array(
0 => get_string('enabled', 'account'),
1 => get_string('disabled', 'account'),
),
'help' => true,
);
$elements['messages'] = array(
'type' => 'radio',
'defaultvalue' => $prefs->messages,
......@@ -214,6 +225,16 @@ function accountprefs_submit(Pieform $form, $values) {
// use this as looping through values is not safe.
$expectedprefs = expected_account_preferences();
if ($values['maildisabled'] == 0 && get_account_preference($USER->get('id'), 'maildisabled') == 1) {
// Reset the sent and bounce counts otherwise mail will be disabled
// on the next send attempt
$u = new StdClass;
$u->email = $USER->get('email');
$u->id = $USER->get('id');
update_bounce_count($u,true);
update_send_count($u,true);
}
foreach (array_keys($expectedprefs) as $pref) {
if (isset($values[$pref])) {
$USER->set_account_preference($pref, $values[$pref]);
......
......@@ -131,6 +131,9 @@ if ($items['firstname']) {
}
$items['maildisabled']['ignore'] = !get_account_preference($USER->get('id'),'maildisabled');
$items['maildisabled']['value'] = get_string('maildisableddescription', 'account', get_config('wwwroot') . 'account/');
// build form elements
$elements = array(
'topsubmit' => array(
......@@ -148,7 +151,7 @@ $elements = array(
'type' => 'fieldset',
'legend' => get_string('contact', 'artefact.internal'),
'class' => $fieldset != 'contact' ? 'collapsed' : '',
'elements' => get_desired_fields($items, array('email', 'officialwebsite', 'personalwebsite', 'blogaddress', 'address', 'town', 'city', 'country', 'homenumber', 'businessnumber', 'mobilenumber', 'faxnumber'), 'contact'),
'elements' => get_desired_fields($items, array('email', 'maildisabled', 'officialwebsite', 'personalwebsite', 'blogaddress', 'address', 'town', 'city', 'country', 'homenumber', 'businessnumber', 'mobilenumber', 'faxnumber'), 'contact'),
),
'messaging' => array(
'type' => 'fieldset',
......@@ -225,6 +228,7 @@ function profileform_validate(Pieform $form, $values) {
}
}
}
}
function profileform_submit(Pieform $form, $values) {
......@@ -363,6 +367,9 @@ function profileform_submit(Pieform $form, $values) {
$USER->commit();
}
}
else if ($element == 'maildisabled') {
continue;
}
else {
if (!isset($profilefields[$element]) || $values[$element] != $profilefields[$element]) {
$classname = generate_artefact_class_name($element);
......
......@@ -55,6 +55,7 @@ $string['studentid'] = 'Student ID';
$string['preferredname'] = 'Preferred Name';
$string['introduction'] = 'Introduction';
$string['email'] = 'Email Address';
$string['maildisabled'] = ' ';
$string['officialwebsite'] = 'Official Website Address';
$string['personalwebsite'] = 'Personal Website Address';
$string['blogaddress'] = 'Blog Address';
......
......@@ -342,6 +342,7 @@ class ArtefactTypeProfile extends ArtefactType {
'jabberusername' => 'text',
'occupation' => 'text',
'industry' => 'text',
'maildisabled' => 'html',
);
}
......
......@@ -45,6 +45,8 @@ $string['updatedfriendcontrolsetting'] = 'Updated friends control';
$string['wysiwygdescr'] = 'HTML editor';
$string['on'] = 'On';
$string['off'] = 'Off';
$string['disabled'] = 'Disabled';
$string['enabled'] = 'Enabled';
$string['messagesdescr'] = 'Messages from other users';
$string['messagesnobody'] = 'Do not allow anyone to send me messages';
......@@ -61,6 +63,13 @@ $string['tagssideblockmaxtagsdescription'] = 'Maximum number of tags to display
$string['prefssaved'] = 'Preferences saved';
$string['prefsnotsaved'] = 'Failed to save your Preferences!';
$string['maildisabled'] = 'E-mail disabled';
$string['maildisabledbounce'] =<<< EOF
Sending of e-mail to your e-mail address has been disabled as too many messages have been returned to the server.
Please check that your e-mail account is working as expected before you re-enable e-mail on the account preferences at %s.
EOF;
$string['maildisableddescription'] = 'Sending of email to your account has been disabled. You may <a href="%s">re-enable your email</a> from the account preferences page.';
$string['deleteaccount'] = 'Delete Account';
$string['deleteaccountdescription'] = 'If you delete your account, your profile information and your Views will no longer be visible to other users. The content of any forum posts you have written will still be visible, but the author\'s name will no longer be displayed.';
$string['accountdeleted'] = 'Your account has been deleted.';
......
<h3>Email</h3>
<p>Use this setting to stop Mahara from sending you email.</p>
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