Merged Patrick's mailnow patch. This allows admin users the ability to override maxediting time and have forum posts mailed out immediately.
This commit is contained in:
@@ -85,6 +85,7 @@ $string['introsocial'] = 'An open forum for chatting about anything you want to'
|
||||
$string['introteacher'] = 'A forum for teacher-only notes and discussion';
|
||||
$string['lastpost'] = 'Last post';
|
||||
$string['learningforums'] = 'Learning forums';
|
||||
$string['mailnow'] = 'Mail now';
|
||||
$string['markalldread'] = 'Mark all posts in this discussion read.';
|
||||
$string['markallread'] = 'Mark all posts in this forum read.';
|
||||
$string['markread'] = 'Mark read';
|
||||
@@ -142,6 +143,7 @@ $string['postincontext'] = 'See this post in context';
|
||||
$string['postmailinfo'] = 'This is a copy of a message posted on the $a website.
|
||||
|
||||
To add your reply via the website, click on this link:';
|
||||
$string['postmailnow'] = '<p>This post will be mailed out immediately to all forum subscribers.</p>';
|
||||
$string['postrating1'] = 'Mostly Separate Knowing';
|
||||
$string['postrating2'] = 'Separate and Connected';
|
||||
$string['postrating3'] = 'Mostly Connected Knowing';
|
||||
|
||||
@@ -268,6 +268,7 @@
|
||||
fwrite ($bf,full_tag("FORMAT",8,false,$for_pos->format));
|
||||
fwrite ($bf,full_tag("ATTACHMENT",8,false,$for_pos->attachment));
|
||||
fwrite ($bf,full_tag("TOTALSCORE",8,false,$for_pos->totalscore));
|
||||
fwrite ($bf,full_tag("MAILNOW",8,false,$for_pos->mailnow));
|
||||
//Now print ratings to xml
|
||||
$status = backup_forum_ratings($bf,$preferences,$for_pos->id);
|
||||
|
||||
|
||||
@@ -220,6 +220,10 @@ function forum_upgrade($oldversion) {
|
||||
table_column('forum','','blockperiod');
|
||||
}
|
||||
|
||||
if ($oldversion < 2006011700) {
|
||||
table_column('forum_posts','','mailnow','integer');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ CREATE TABLE prefix_forum_posts (
|
||||
format tinyint(2) NOT NULL default '0',
|
||||
attachment VARCHAR(100) NOT NULL default '',
|
||||
totalscore tinyint(4) NOT NULL default '0',
|
||||
mailnow int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (id),
|
||||
KEY prefix_forum_posts_parent_idx (parent),
|
||||
KEY prefix_forum_posts_discussion_idx (discussion),
|
||||
|
||||
@@ -166,6 +166,10 @@ function forum_upgrade($oldversion) {
|
||||
table_column('forum','','blockperiod');
|
||||
}
|
||||
|
||||
if ($oldversion < 2006011700) {
|
||||
table_column('forum_posts','','mailnow','integer');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ CREATE TABLE prefix_forum_posts (
|
||||
message text NOT NULL default '',
|
||||
format integer NOT NULL default '0',
|
||||
attachment VARCHAR(100) NOT NULL default '',
|
||||
totalscore integer NOT NULL default '0'
|
||||
totalscore integer NOT NULL default '0',
|
||||
mailnow integer NOT NULL default '0'
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_forum_posts_discussion_idx ON prefix_forum_posts (discussion);
|
||||
|
||||
+4
-2
@@ -115,6 +115,7 @@ function forum_add_instance($forum) {
|
||||
$discussion->intro = $forum->intro;
|
||||
$discussion->assessed = $forum->assessed;
|
||||
$discussion->format = $forum->format;
|
||||
$discussion->mailnow = false;
|
||||
|
||||
if (! forum_add_discussion($discussion, $discussion->intro)) {
|
||||
error('Could not add the discussion for this forum');
|
||||
@@ -1205,7 +1206,7 @@ function forum_get_unmailed_posts($starttime, $endtime) {
|
||||
{$CFG->prefix}forum_discussions d
|
||||
WHERE p.mailed = 0
|
||||
AND (p.created >= '$starttime' OR d.timestart > 0)
|
||||
AND p.created < '$endtime'
|
||||
AND (p.created < '$endtime' OR p.mailnow = 1)
|
||||
AND p.discussion = d.id
|
||||
AND ((d.timestart = 0 OR d.timestart <= '$now')
|
||||
AND (d.timeend = 0 OR d.timeend > '$now'))
|
||||
@@ -1233,7 +1234,7 @@ function forum_mark_old_posts_as_mailed($endtime) {
|
||||
}
|
||||
return execute_sql("UPDATE {$CFG->prefix}forum_posts
|
||||
SET mailed = '1'
|
||||
WHERE id NOT IN (".implode(',',$delayed_ids).") AND created < '$endtime' AND mailed ='0'");
|
||||
WHERE id NOT IN (".implode(',',$delayed_ids).") AND (created < '$endtime' OR mailnow = 1) AND mailed ='0'");
|
||||
}
|
||||
|
||||
function forum_get_user_posts($forumid, $userid) {
|
||||
@@ -2517,6 +2518,7 @@ function forum_add_discussion($discussion,&$message) {
|
||||
$post->forum = $discussion->forum;
|
||||
$post->course = $discussion->course;
|
||||
$post->format = $discussion->format;
|
||||
$post->mailnow = $discussion->mailnow;
|
||||
|
||||
if (! $post->id = insert_record("forum_posts", $post) ) {
|
||||
return 0;
|
||||
|
||||
@@ -102,6 +102,17 @@ if (!isset($discussion->timeend)) {
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if (isadmin() && empty($post->id)) { ?>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><b><?php print_string("mailnow", "forum") ?>:</b></td>
|
||||
<td><?php print_checkbox('mailnow', '1', !empty($post->mailnow)); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if ($forum->type == 'news' && !$post->parent) { // This is the first post of a discussion in news forum ?>
|
||||
|
||||
<tr valign="top">
|
||||
|
||||
@@ -165,6 +165,11 @@
|
||||
$timemessage = 4;
|
||||
}
|
||||
|
||||
if ($post->mailnow) {
|
||||
$message .= get_string("postmailnow", "forum");
|
||||
$timemessage = 4;
|
||||
}
|
||||
|
||||
redirect(forum_go_back_to("discuss.php?d=$post->discussion#$post->id"), $message.$subscribemessage, $timemessage);
|
||||
|
||||
} else {
|
||||
@@ -173,6 +178,7 @@
|
||||
exit;
|
||||
|
||||
} else { // Adding a new discussion
|
||||
$post->mailnow = empty($post->mailnow) ? 0 : 1;
|
||||
$discussion = $post;
|
||||
$discussion->name = $post->subject;
|
||||
$discussion->intro = $post->message;
|
||||
@@ -206,6 +212,11 @@
|
||||
}
|
||||
$message .= '<br />'.get_string("postadded", "forum", format_time($CFG->maxeditingtime));
|
||||
|
||||
if ($post->mailnow) {
|
||||
$message .= get_string("postmailnow", "forum");
|
||||
$timemessage = 4;
|
||||
}
|
||||
|
||||
if ($subscribemessage = forum_post_subscription($discussion)) {
|
||||
$timemessage = 4;
|
||||
}
|
||||
|
||||
@@ -402,6 +402,7 @@
|
||||
$post->format = backup_todb($pos_info['#']['FORMAT']['0']['#']);
|
||||
$post->attachment = backup_todb($pos_info['#']['ATTACHMENT']['0']['#']);
|
||||
$post->totalscore = backup_todb($pos_info['#']['TOTALSCORE']['0']['#']);
|
||||
$post->mailnow = backup_todb($pos_info['#']['MAILNOW']['0']['#']);
|
||||
|
||||
//We have to recode the userid field
|
||||
$user = backup_getid($restore->backup_unique_code,"user",$post->userid);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// This fragment is called by /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2006011601;
|
||||
$module->version = 2006011700;
|
||||
$module->requires = 2005031000; // Requires this Moodle version
|
||||
$module->cron = 60;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user