message MDL-24771 another big commit of messaging fixes
This commit is contained in:
+12
-8
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20101020" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20101026" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -579,9 +579,11 @@
|
||||
<FIELD NAME="fullmessage" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="subject" NEXT="fullmessageformat"/>
|
||||
<FIELD NAME="fullmessageformat" TYPE="int" LENGTH="4" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the full message" PREVIOUS="fullmessage" NEXT="fullmessagehtml"/>
|
||||
<FIELD NAME="fullmessagehtml" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="html format of message" PREVIOUS="fullmessageformat" NEXT="smallmessage"/>
|
||||
<FIELD NAME="smallmessage" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="Smal version of message (eg sms)" PREVIOUS="fullmessagehtml" NEXT="timecreated"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="smallmessage" NEXT="notification"/>
|
||||
<FIELD NAME="notification" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated"/>
|
||||
<FIELD NAME="smallmessage" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="Smal version of message (eg sms)" PREVIOUS="fullmessagehtml" NEXT="notification"/>
|
||||
<FIELD NAME="notification" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="smallmessage" NEXT="contexturl"/>
|
||||
<FIELD NAME="contexturl" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="If this message is a notification of an event contexturl should contain a link to view this event. For example if its a notification of a forum post contexturl should contain a link to the forum post." PREVIOUS="notification" NEXT="contexturlname"/>
|
||||
<FIELD NAME="contexturlname" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="Display text for the contexturl" PREVIOUS="contexturl" NEXT="timecreated"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="contexturlname"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
@@ -600,10 +602,12 @@
|
||||
<FIELD NAME="fullmessage" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="subject" NEXT="fullmessageformat"/>
|
||||
<FIELD NAME="fullmessageformat" TYPE="int" LENGTH="4" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of the full message" PREVIOUS="fullmessage" NEXT="fullmessagehtml"/>
|
||||
<FIELD NAME="fullmessagehtml" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" COMMENT="html format of message" PREVIOUS="fullmessageformat" NEXT="smallmessage"/>
|
||||
<FIELD NAME="smallmessage" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="Smal version of message (eg sms)" PREVIOUS="fullmessagehtml" NEXT="timecreated"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="smallmessage" NEXT="timeread"/>
|
||||
<FIELD NAME="timeread" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated" NEXT="notification"/>
|
||||
<FIELD NAME="notification" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timeread"/>
|
||||
<FIELD NAME="smallmessage" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="Smal version of message (eg sms)" PREVIOUS="fullmessagehtml" NEXT="notification"/>
|
||||
<FIELD NAME="notification" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="smallmessage" NEXT="contexturl"/>
|
||||
<FIELD NAME="contexturl" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="If this message is a notification of an event contexturl should contain a link to view this event. For example if its a notification of a forum post contexturl should contain a link to the forum post." PREVIOUS="notification" NEXT="contexturlname"/>
|
||||
<FIELD NAME="contexturlname" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="Display text for the contexturl" PREVIOUS="contexturl" NEXT="timecreated"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="contexturlname" NEXT="timeread"/>
|
||||
<FIELD NAME="timeread" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
|
||||
+15
-11
@@ -5318,20 +5318,24 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
}
|
||||
|
||||
//MDL-24771
|
||||
if ($oldversion < 2010102500) {
|
||||
$field = new xmldb_field('notification', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0);
|
||||
if ($oldversion < 2010102600) {
|
||||
|
||||
$table = new xmldb_table('message');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
$fieldnotification = new xmldb_field('notification', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'smallmessage');
|
||||
$fieldcontexturl = new xmldb_field('contexturl', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'notification');
|
||||
$fieldcontexturlname = new xmldb_field('contexturlname', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'contexturl');
|
||||
$fieldstoadd = array($fieldnotification, $fieldcontexturl, $fieldcontexturlname);
|
||||
|
||||
$tablestomodify = array(new xmldb_table('message'), new xmldb_table('message_read'));
|
||||
|
||||
foreach($tablestomodify as $table) {
|
||||
foreach($fieldstoadd as $field) {
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$table = new xmldb_table('message_read');
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
upgrade_main_savepoint(true, 2010102500);
|
||||
upgrade_main_savepoint(true, 2010102600);
|
||||
}
|
||||
|
||||
// MDL-24694 needs increasing size of user_preferences.name(varchar[50]) field due to
|
||||
|
||||
@@ -40,6 +40,8 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* fullmessageformat - the format if the full message (FORMAT_MOODLE, FORMAT_HTML, ..)
|
||||
* fullmessagehtml - the full version (the message processor will choose with one to use)
|
||||
* smallmessage - the small version of the message
|
||||
* contexturl - if this is a notification then you can specify a url to view the event. For example the forum post the user is being notified of.
|
||||
* contexturlname - the display text for contexturl
|
||||
*
|
||||
* @param object $eventdata information about the message (modulename, userfrom, userto, ...)
|
||||
* @return boolean success
|
||||
@@ -83,6 +85,18 @@ function message_send($eventdata) {
|
||||
$savemessage->notification = 0;
|
||||
}
|
||||
|
||||
if (!empty($eventdata->contexturl)) {
|
||||
$savemessage->contexturl = $eventdata->contexturl;
|
||||
} else {
|
||||
$savemessage->contexturl = null;
|
||||
}
|
||||
|
||||
if (!empty($eventdata->contexturlname)) {
|
||||
$savemessage->contexturlname = $eventdata->contexturlname;
|
||||
} else {
|
||||
$savemessage->contexturlname = null;
|
||||
}
|
||||
|
||||
$savemessage->timecreated = time();
|
||||
|
||||
// Find out what processors are defined currently
|
||||
|
||||
+13
-1
@@ -1521,10 +1521,22 @@ function message_format_message(&$message, &$user, $format='', $keywords='', $cl
|
||||
$messagetext = format_text($message->fullmessage, $message->fullmessageformat, $options);
|
||||
}
|
||||
|
||||
if (!empty($message->contexturl)) {
|
||||
$displaytext = null;
|
||||
if (!empty($message->contexturlname)) {
|
||||
$displaytext= $message->contexturlname;
|
||||
} else {
|
||||
$displaytext= $message->contexturl;
|
||||
}
|
||||
$messagetext .= html_writer::start_tag('div',array('class'=>'messagecontext'));
|
||||
$messagetext .= get_string('view').': '.html_writer::tag('a', $displaytext, array('href' => $message->contexturl));
|
||||
$messagetext .= html_writer::end_tag('div');
|
||||
}
|
||||
|
||||
if ($keywords) {
|
||||
$messagetext = highlight($keywords, $messagetext);
|
||||
}
|
||||
//return '<div class="message '.$class.'"><a name="m'.$message->id.'"></a><span class="author">'.s(fullname($user)).'</span> <span class="time">['.$time.']</span>: <span class="content">'.$messagetext.'</span></div>';
|
||||
|
||||
return '<div class="message '.$class.'"><a name="m'.$message->id.'"></a> <span class="time">'.$time.'</span>: <span class="content">'.$messagetext.'</span></div>';
|
||||
}
|
||||
|
||||
|
||||
@@ -336,7 +336,7 @@ $string['seeallposts'] = 'See all posts made by this user';
|
||||
$string['shortpost'] = 'Short post';
|
||||
$string['showsubscribers'] = 'Show/edit current subscribers';
|
||||
$string['singleforum'] = 'A single simple discussion';
|
||||
$string['smallmessage'] = '{$a->user} posted in {$a->forumname}<br />View discussion: {$a->replylink}';
|
||||
$string['smallmessage'] = '{$a->user} posted in {$a->forumname}';
|
||||
$string['startedby'] = 'Started by';
|
||||
$string['subject'] = 'Subject';
|
||||
$string['subscribe'] = 'Subscribe to this forum';
|
||||
|
||||
+5
-3
@@ -635,14 +635,16 @@ function forum_cron() {
|
||||
$eventdata->fullmessage = $posttext;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = $posthtml;
|
||||
$eventdata->notification = 1;
|
||||
|
||||
$smallmessagestrings = new stdClass();
|
||||
$smallmessagestrings->user = fullname($userfrom);
|
||||
$smallmessagestrings->forumname = "{$course->shortname}->".format_string($forum->name,true);
|
||||
$smallmessagestrings->replylink = "<a href='{$CFG->wwwroot}/mod/forum/discuss.php?d={$discussion->id}#p{$post->id}'>{$discussion->name}</a>";
|
||||
$smallmessagestrings->forumname = "{$course->shortname}: ".format_string($forum->name,true).": ".$discussion->name;
|
||||
$smallmessagestrings->message = $post->message;
|
||||
$eventdata->smallmessage = get_string('smallmessage', 'forum', $smallmessagestrings);
|
||||
$eventdata->notification = 1;
|
||||
|
||||
$eventdata->contexturl = "{$CFG->wwwroot}/mod/forum/discuss.php?d={$discussion->id}#p{$post->id}";
|
||||
$eventdata->contexturlname = $discussion->name;
|
||||
|
||||
$mailresult = message_send($eventdata);
|
||||
if (!$mailresult){
|
||||
|
||||
Reference in New Issue
Block a user