messaging MDL-22320 removed a bunch of redundant settings and made a few other bug fixes to messaging

This commit is contained in:
Andrew Davis 2010-06-29 03:01:14 +00:00
parent 6413bae786
commit 65c7853e1c
3 changed files with 13 additions and 90 deletions

View File

@ -73,6 +73,11 @@ function message_print_contact_selector($countunreadtotal, $usergroup, $user1, $
$usergroup = VIEW_CONTACTS;
}
//if they have no blocked users and they've requested blocked users switch them over to contacts
if (count($blockedusers)==0 && $usergroup==VIEW_BLOCKED) {
$usergroup = VIEW_CONTACTS;
}
$onlyactivecourses = true;
$courses = enrol_get_users_courses($user1->id, $onlyactivecourses);
$coursecontexts = message_get_course_contexts($courses);//we need one of these again so holding on to them
@ -303,9 +308,9 @@ function message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $
echo '<div class="heading">';
print_string('contactlistempty', 'message');
echo '</div>';
echo '<div class="note">';
print_string('addsomecontacts', 'message', message_remove_url_params($PAGE->url).'?tab=search');
echo '</div>';
//echo '<div class="note">';
//print_string('addsomecontacts', 'message', message_remove_url_params($PAGE->url).'?tab=search');
//echo '</div>';
}
echo '<table id="message_contacts" class="boxaligncenter" cellspacing="2" cellpadding="0" border="0">';
@ -385,24 +390,15 @@ function message_print_contacts($onlinecontacts, $offlinecontacts, $strangers, $
function message_print_usergroup_selector($usergroup, &$courses, &$coursecontexts, $countunreadtotal, $countblocked, $strunreadmessages) {
$strblockedusers = null;
$options = array();
if ($countunreadtotal>0) { //if there are unread messages
$options = array(VIEW_UNREAD_MESSAGES=>$strunreadmessages);
} else {
//if 0 unread messages and they've requested unread messages then show contacts
if ($usergroup==VIEW_UNREAD_MESSAGES) {
$usergroup = VIEW_CONTACTS;
}
$options[VIEW_UNREAD_MESSAGES] = $strunreadmessages;
}
if ($countblocked>0) {
$strblockedusers = get_string('blockedusers','message', $countblocked);
$options = array(VIEW_BLOCKED=>$strblockedusers);
} else {
//if 0 blocked users and they've requested blocked users then show contacts
if ($usergroup==VIEW_BLOCKED) {
$usergroup = VIEW_CONTACTS;
}
$options[VIEW_BLOCKED] = $strblockedusers;
}
$strcontacts = get_string('mycontacts', 'message');
@ -580,32 +576,16 @@ function message_print_settings() {
if ($frm = data_submitted() and confirm_sesskey()) {
$pref = array();
$pref['message_showmessagewindow'] = (isset($frm->showmessagewindow)) ? '1' : '0';
$pref['message_beepnewmessage'] = (isset($frm->beepnewmessage)) ? '1' : '0';
$pref['message_blocknoncontacts'] = (isset($frm->blocknoncontacts)) ? '1' : '0';
$pref['message_usehtmleditor'] = (isset($frm->usehtmleditor)) ? '1' : '0';
$pref['message_noframesjs'] = (isset($frm->noframesjs)) ? '1' : '0';
$pref['message_emailmessages'] = (isset($frm->emailmessages)) ? '1' : '0';
$pref['message_emailtimenosee'] = ((int)$frm->emailtimenosee > 0) ? (int)$frm->emailtimenosee : '10';
$pref['message_emailaddress'] = (!empty($frm->emailaddress)) ? $frm->emailaddress : $USER->email;
$pref['message_emailformat'] = (isset($frm->emailformat)) ? $frm->emailformat : FORMAT_PLAIN;
set_user_preferences($pref);
redirect(message_remove_url_params($PAGE->url), get_string('settingssaved', 'message'), 1);
}
$cbshowmessagewindow = (get_user_preferences('message_showmessagewindow', 1) == '1') ? 'checked="checked"' : '';
$cbbeepnewmessage = (get_user_preferences('message_beepnewmessage', 0) == '1') ? 'checked="checked"' : '';
$cbblocknoncontacts = (get_user_preferences('message_blocknoncontacts', 0) == '1') ? 'checked="checked"' : '';
$cbusehtmleditor = (get_user_preferences('message_usehtmleditor', 0) == '1') ? 'checked="checked"' : '';
$cbnoframesjs = (get_user_preferences('message_noframesjs', 0) == '1') ? 'checked="checked"' : '';
$cbemailmessages = (get_user_preferences('message_emailmessages', 1) == '1') ? 'checked="checked"' : '';
$txemailaddress = get_user_preferences('message_emailaddress', $USER->email);
$txemailtimenosee = get_user_preferences('message_emailtimenosee', 10);
$format_select = html_writer::select(array(FORMAT_PLAIN => get_string('formatplain'),
FORMAT_HTML => get_string('formathtml')),
'emailformat', get_user_preferences('message_emailformat', FORMAT_PLAIN));
include('settings.html');
}

View File

@ -53,44 +53,22 @@ class message_output_popup extends message_output{
function config_form($preferences) {
return '<table>'.
'<tr><td align="right">'.get_string('showmessagewindow', 'message').':</td><td><input type="checkbox" name="showmessagewindow" '.($preferences->showmessagewindow==1?" checked=\"checked\"":"").' /></td></tr>'.
'<tr><td align="right">'.get_string('blocknoncontacts', 'message').':</td><td><input type="checkbox" name="blocknoncontacts" '.($preferences->blocknoncontacts==1?" checked=\"checked\"":"").' /></td></tr>'.
'<tr><td align="right">'.get_string('beepnewmessage', 'message').':</td><td><input type="checkbox" name="beepnewmessage" '.($preferences->beepnewmessage==1?" checked=\"checked\"":"").' /></td></tr>'.
'<tr><td align="right">'.get_string('htmleditor').':</td><td><input type="checkbox" name="usehtmleditor" '.($preferences->usehtmleditor==1?" checked=\"checked\"":"").' /></td></tr>'.
'<tr><td align="right">'.get_string('noframesjs', 'message').':</td><td><input type="checkbox" name="noframesjs" '.($preferences->noframesjs==1?" checked=\"checked\"":"").' /></td></tr>'.
'<tr><td align="right">'.get_string('emailmessages', 'message').':</td><td><input type="checkbox" name="emailmessages" '.($preferences->emailmessages==1?" checked=\"checked\"":"").' /></td></tr>'.
'<tr><td align="right">'.get_string('formorethan', 'message').':</td><td><input type="text" name="emailtimenosee" id="emailtimenosee" size="2" value="'.$preferences->emailtimenosee.'" /> '.get_string('mins').'</td></tr>'.
'<tr><td align="right">'.get_string('email').':</td><td><input type="text" name="emailaddress" id="emailaddress" size="20" value="'.$preferences->emailaddress.'" /></td></tr>'.
'<tr><td align="right">'.get_string('format').':</td><td>'.$preferences->formatselect.'</td></tr>'.
'</table>';
}
public function process_form($form, &$preferences) {
$preferences['message_showmessagewindow'] = !empty($form->showmessagewindow)?1:0;
$preferences['message_blocknoncontacts'] = !empty($form->blocknoncontacts)?1:0;
$preferences['message_beepnewmessage'] = !empty($form->beepnewmessage)?1:0;
$preferences['message_usehtmleditor'] = !empty($form->usehtmleditor)?1:0;
$preferences['message_noframesjs'] = !empty($form->noframesjs)?1:0;
$preferences['message_emailmessages'] = !empty($form->emailmessages)?1:0;
$preferences['message_emailtimenosee'] = $form->emailtimenosee;
$preferences['message_emailaddress'] = $form->emailaddress;
$preferences['message_emailformat'] = $form->emailformat;
return true;
}
public function load_data(&$preferences, $userid) {
global $USER;
$preferences->showmessagewindow = get_user_preferences( 'message_showmessagewindow', 1, $userid);
$preferences->blocknoncontacts = get_user_preferences( 'message_blocknoncontacts', '', $userid);
$preferences->beepnewmessage = get_user_preferences( 'message_beepnewmessage', '', $userid);
$preferences->usehtmleditor = get_user_preferences( 'message_usehtmleditor', '', $userid);
$preferences->noframesjs = get_user_preferences( 'message_noframesjs', '', $userid);
$preferences->emailmessages = get_user_preferences( 'message_emailmessages', 1, $userid);
$preferences->emailtimenosee = get_user_preferences( 'message_emailtimenosee', 10, $userid);
$preferences->emailaddress = get_user_preferences( 'message_emailaddress', $USER->email, $userid);
$preferences->formatselect = html_writer::select(array(FORMAT_PLAIN => get_string('formatplain'),
FORMAT_HTML => get_string('formathtml')),
'emailformat', get_user_preferences('message_emailformat', FORMAT_PLAIN));
return true;
}

View File

@ -7,10 +7,6 @@
<table cellpadding="5" class="message_form boxaligncenter">
<tr valign="top">
<td align="right"><input type="checkbox" name="showmessagewindow" id="showmessagewindow" <?php echo $cbshowmessagewindow ?> /></td>
<td colspan="2"><label for="showmessagewindow"><?php print_string('showmessagewindow', 'message') ?></label></td>
</tr>
<tr valign="top">
<td align="right"><input type="checkbox" name="blocknoncontacts" id="blocknoncontacts" <?php echo $cbblocknoncontacts ?> /></td>
<td colspan="2"><label for="blocknoncontacts"><?php print_string('blocknoncontacts', 'message') ?></label></td>
@ -18,38 +14,7 @@
<tr valign="top">
<td align="right"><input type="checkbox" name="beepnewmessage" id="beepnewmessage" <?php echo $cbbeepnewmessage ?> /></td>
<td colspan="2"><label for="beepnewmessage"><?php print_string('beepnewmessage', 'message') ?></label></td>
</tr>
<tr valign="top">
<td align="right"><input type="checkbox" name="usehtmleditor" id="usehtmleditor" <?php echo $cbusehtmleditor ?> /></td>
<td colspan="2"><label for="usehtmleditor"><?php print_string('htmleditor') ?></label></td>
</tr>
<tr valign="top">
<td align="right"><input type="checkbox" name="noframesjs" id="noframesjs" <?php echo $cbnoframesjs ?> /></td>
<td colspan="2"><label for="noframesjs"><?php print_string('noframesjs', 'message') ?></label></td>
</tr>
<tr valign="top">
<td><input type="checkbox" name="emailmessages" id="emailmessages" <?php echo $cbemailmessages ?> /></td>
<td colspan="2"><label for="emailmessages"><?php print_string('emailmessages', 'message') ?></label></td>
</tr>
<tr valign="top">
<td>&nbsp;</td>
<td align="right"><label for="emailtimenosee"><?php print_string('formorethan', 'message') ?></label></td>
<td><input type="text" name="emailtimenosee" id="emailtimenosee" size="2" value="<?php p($txemailtimenosee) ?>" /> <?php print_string('mins') ?></td>
</tr>
<tr valign="top">
<td>&nbsp;</td>
<td align="right"><label for="emailaddress"><?php print_string('email') ?></label></td>
<td><input type="text" name="emailaddress" id="emailaddress" size="20" value="<?php p($txemailaddress) ?>" /></td>
</tr>
<tr valign="top">
<td>&nbsp;</td>
<td align="right"><label for="menuemailformat"><?php print_string('format') ?></label></td>
<td><?php echo $format_select ?>
</td>
</tr>
</tr>
<tr valign="top">
<td colspan="3" align="center"><br /><input type="submit" value="<?php print_string('savemysettings', 'message') ?>" /></td>