Permalink
Browse files

MDL-10294, MDL-10028, changing messaging/bulk messaging system

  • Loading branch information...
toyomoyo
toyomoyo committed Nov 21, 2007
1 parent ad91f37 commit 5645145115a9773b06b7e219c76580a1b5906152
Showing with 59 additions and 28 deletions.
  1. +1 −0 lang/en_utf8/role.php
  2. +12 −0 lib/db/access.php
  3. +1 −0 message/discussion.php
  4. +24 −7 message/lib.php
  5. +13 −10 message/send.php
  6. +1 −3 user/index.php
  7. +5 −6 user/messageselect.php
  8. +1 −1 user/view.php
  9. +1 −1 version.php
View
@@ -112,6 +112,7 @@
$string['site:manageblocks'] = 'Manage site-level blocks';
$string['site:readallmessages'] = 'Read all messages on site';
$string['site:restore'] = 'Restore courses';
$string['site:sendmessage'] = 'Send messages to any user';
$string['site:trustcontent'] = 'Trust submitted content';
$string['site:uploadusers'] = 'Upload new users from file';
$string['site:viewfullnames'] = 'Always see full names of users';
View
@@ -120,6 +120,18 @@
'editingteacher' => CAP_ALLOW
)
),
'moodle/site:sendmessage' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'legacy' => array(
'admin' => CAP_ALLOW,
'user' => CAP_ALLOW
)
),
'moodle/site:approvecourse' => array(
View
@@ -46,6 +46,7 @@
scrolling="yes" marginwidth="10" marginheight="10" frameborder="0" />
<frame src="refresh.php?id=<?php p($user->id)?>&amp;name=<?php echo urlencode(fullname($user)) ?>" name="refresh"
scrolling="no" marginwidth="0" marginheight="0" frameborder="0" />
<frame src="send.php?id=<?php p($user->id)?>" name="send"
scrolling="no" marginwidth="2" marginheight="2" frameborder="0" />
</frameset>
View
@@ -113,9 +113,11 @@ function message_print_contacts() {
print_user_picture($contact->id, SITEID, $contact->picture, 20, false, true, 'userwindow');
echo '</td>';
echo '<td class="contact">';
link_to_popup_window("/message/discussion.php?id=$contact->id", "message_$contact->id",
$fullnamelink, 500, 500, get_string('sendmessageto', 'message', $fullname),
'menubar=0,location=0,status,scrollbars,resizable,width=500,height=500');
echo '</td>';
echo '<td class="link">'.$strcontact.'&nbsp;'.$strhistory.'</td>';
echo '</tr>';
@@ -148,8 +150,9 @@ function message_print_contacts() {
echo '</td>';
echo '<td class="contact">';
link_to_popup_window("/message/discussion.php?id=$contact->id", "message_$contact->id",
$fullnamelink, 500, 500, get_string('sendmessageto', 'message', $fullname),
'menubar=0,location=0,status,scrollbars,resizable,width=500,height=500');
$fullnamelink, 500, 500, get_string('sendmessageto', 'message', $fullname),
'menubar=0,location=0,status,scrollbars,resizable,width=500,height=500');
echo '</td>';
echo '<td class="link">'.$strcontact.'&nbsp;'.$strhistory.'</td>';
echo '</tr>';
@@ -180,9 +183,11 @@ function message_print_contacts() {
print_user_picture($messageuser->useridfrom, SITEID, $messageuser->picture, 20, false, true, 'userwindow');
echo '</td>';
echo '<td class="contact">';
link_to_popup_window("/message/discussion.php?id=$messageuser->useridfrom", "message_$messageuser->useridfrom",
$fullnamelink, 500, 500, get_string('sendmessageto', 'message', $fullname),
'menubar=0,location=0,status,scrollbars,resizable,width=500,height=500');
echo '</td>';
echo '<td class="link">&nbsp;'.$strcontact.'&nbsp;'.$strblock.'&nbsp;'.$strhistory.'</td>';
echo '</tr>';
@@ -396,6 +401,7 @@ function message_print_search_results($frm) {
link_to_popup_window("/message/discussion.php?id=$user->id", "message_$user->id", fullname($user),
500, 500, get_string('sendmessageto', 'message', fullname($user)),
'menubar=0,location=0,status,scrollbars,resizable,width=500,height=500');
echo '</td>';
echo '<td class="link">'.$strcontact.'</td>';
@@ -564,6 +570,7 @@ function message_print_user ($user=false, $iscontact=false, $isblocked=false) {
message_contact_link($user->id, 'block');
}
echo '<br />';
link_to_popup_window("/message/discussion.php?id=$user->id", "message_$user->id",
fullname($user), 400, 400, get_string('sendmessageto', 'message', fullname($user)),
'menubar=0,location=0,status,scrollbars,resizable,width=500,height=500');
@@ -987,22 +994,28 @@ function message_post_message($userfrom, $userto, $message, $format, $messagetyp
$savemessage->timecreated = time();
$savemessage->messagetype = 'direct';
if (!$savemessage->id = insert_record('message', $savemessage)) {
return false;
if ($CFG->messaging) {
if (!$savemessage->id = insert_record('message', $savemessage)) {
return false;
}
$emailforced = false;
} else { // $CFG->messaging is not on, we need to force sending of emails
$emailforced = true;
$savemessage->id = true;
}
/// Check to see if anything else needs to be done with it
$preference = (object)get_user_preferences(NULL, NULL, $userto->id);
if (!isset($preference->message_emailmessages) || $preference->message_emailmessages) { // Receiver wants mail forwarding
if ($emailforced || (!isset($preference->message_emailmessages) || $preference->message_emailmessages)) { // Receiver wants mail forwarding
if (!isset($preference->message_emailtimenosee)) {
$preference->message_emailtimenosee = 10;
}
if (!isset($preference->message_emailformat)) {
$preference->message_emailformat = FORMAT_HTML;
}
if ((time() - $userto->lastaccess) > ((int)$preference->message_emailtimenosee * 60)) { // Long enough
if ($emailforced || (time() - $userto->lastaccess) > ((int)$preference->message_emailtimenosee * 60)) { // Long enough
$message = stripslashes_safe($message);
$tagline = get_string('emailtagline', 'message', $SITE->shortname);
@@ -1014,14 +1027,18 @@ function message_post_message($userfrom, $userto, $message, $format, $messagetyp
if (isset($preference->message_emailformat) and $preference->message_emailformat == FORMAT_HTML) {
$messagehtml = format_text($message, $format);
$messagehtml .= '<hr /><p><a href="'.$CFG->wwwroot.'/message/index.php?popup=1">'.$tagline.'</a></p>';
// MDL-10294, do not print link if messaging is disabled
if ($CFG->messaging) {
$messagehtml .= '<hr /><p><a href="'.$CFG->wwwroot.'/message/index.php?popup=1">'.$tagline.'</a></p>';
}
} else {
$messagehtml = NULL;
}
if (!empty($preference->message_emailaddress)) {
$userto->email = $preference->message_emailaddress; // Use custom messaging address
}
email_to_user($userto, $userfrom, $messagesubject, $messagetext, $messagehtml);
debugging('Mail was sent', DEBUG_NORMAL);
echo "mail was sent";
View
@@ -1,17 +1,20 @@
<?php // $Id$
require('../config.php');
require('lib.php');
require('../config.php');
require('lib.php');
require_login();
require_login();
if (isguest()) {
redirect($CFG->wwwroot);
}
if (isguest()) {
redirect($CFG->wwwroot);
}
if (empty($CFG->messaging)) {
error("Messaging is disabled on this site");
}
if (has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTEM))) {
if (empty($CFG->messaging)) {
error("Messaging is disabled on this site");
}
/// Don't use print_header, for more speed
$stylesheetshtml = '';
@@ -115,5 +118,5 @@
echo "\n-->\n</script>\n\n";
echo '</body></html>';
}
?>
View
@@ -597,9 +597,7 @@ function checkchecked(form) {
echo '<input type="button" onclick="checknone()" value="'.get_string('deselectall').'" /> ';
$displaylist = array();
// fix for MDL-8885, only show this if user has capability
if (has_capability('moodle/site:readallmessages', $context) && !empty($CFG->messaging)) {
$displaylist['messageselect.php'] = get_string('messageselectadd');
}
$displaylist['messageselect.php'] = get_string('messageselectadd');
if ($course->enrolperiod) {
$displaylist['extendenrol.php'] = get_string('extendenrol');
}
View
@@ -17,12 +17,7 @@
}
require_login();
require_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_COURSE, $id));
// fix for MDL-10112
if (empty($CFG->messaging)) {
error("Messaging is disabled on this site");
}
require_capability('moodle/course:bulkmessaging', get_context_instance(CONTEXT_COURSE, $id));
if (empty($SESSION->emailto)) {
$SESSION->emailto = array();
@@ -67,6 +62,10 @@
print_header($strtitle,$strtitle,"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> -> <a href=\"index.php?id=$course->id\">".get_string("participants")."</a> -> ".$strtitle,$formstart);
// if messaging is disabled on site, we can still allow users with capabilities to send emails instead
if (empty($CFG->messaging)) {
notify("Messaging is disabled on this site, emails will be sent instead");
}
if ($count) {
if ($count == 1) {
View
@@ -419,7 +419,7 @@
echo '</form>';
}
if (!empty($CFG->messaging) and !isguest()) {
if (!empty($CFG->messaging) and !isguest() and has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTEM))) {
if (!empty($USER->id) and ($USER->id == $user->id)) {
if ($countmessages = count_records('message', 'useridto', $user->id)) {
$messagebuttonname = get_string("messages", "message")."($countmessages)";
View
@@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
$version = 2007021532; // YYYYMMDD = date of the 1.8 branch (don't change)
$version = 2007021533; // YYYYMMDD = date of the 1.8 branch (don't change)
// X = release number 1.8.[0,1,2,3...]
// Y = micro-increments between releases

0 comments on commit 5645145

Please sign in to comment.