Commit 2d86fd5b authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Make forum post delay configurable by admin

parent 30c93b88
......@@ -81,6 +81,12 @@ function xmldb_interaction_forum_upgrade($oldversion=0) {
}
}
if ($oldversion < 2009081700) {
if (!get_record('interaction_config', 'plugin', 'forum', 'field', 'postdelay')) {
insert_record('interaction_config', (object) array('plugin' => 'forum', 'field' => 'postdelay', 'value' => 30));
}
}
return true;
}
......
......@@ -105,6 +105,8 @@ $string['Order'] = 'Order';
$string['orderdescription'] = 'Choose where you want the forum to be ordered compared to the other forums';
$string['Post'] = 'Post';
$string['postbyuserwasdeleted'] = 'A post by %s was deleted';
$string['postdelay'] = 'Post Delay';
$string['postdelaydescription'] = 'The minimum time (in minutes) that must pass before a new post can be mailed out to forum subscribers. The author of a post may make edits during this time.';
$string['postedin'] = '%s posted in %s';
$string['Poster'] = 'Poster';
$string['postreply'] = 'Post reply';
......
......@@ -317,7 +317,7 @@ class PluginInteractionForum extends PluginInteraction {
/**
* Process new forum posts.
*
* @param array $postnow An array of post ids to be sent immediately. If null, send all posts older than 30 mins.
* @param array $postnow An array of post ids to be sent immediately. If null, send all posts older than postdelay.
*/
public static function interaction_forum_new_post($postnow=null) {
if (is_array($postnow) && !empty($postnow)) {
......@@ -326,7 +326,7 @@ class PluginInteractionForum extends PluginInteraction {
}
else {
$currenttime = time();
$minpostdelay = $currenttime - 30 * 60;
$minpostdelay = $currenttime - get_config_plugin('interaction', 'forum', 'postdelay') * 60;
$values = array(db_format_timestamp($minpostdelay));
$postswhere = 'ctime < ?';
}
......@@ -399,6 +399,35 @@ class PluginInteractionForum extends PluginInteraction {
public static function generate_unsubscribe_key() {
return dechex(mt_rand());
}
public static function has_config() {
return true;
}
public static function get_config_options() {
$postdelay = get_config_plugin('interaction', 'forum', 'postdelay');
if (!is_numeric($postdelay)) {
$postdelay = 30;
}
return array(
'elements' => array(
'postdelay' => array(
'title' => get_string('postdelay', 'interaction.forum'),
'description' => get_string('postdelaydescription', 'interaction.forum'),
'type' => 'text',
'rules' => array('integer' => true, 'minvalue' => 0, 'maxvalue' => 10000000),
'defaultvalue' => (int) $postdelay,
),
),
'renderer' => 'table'
);
}
public static function save_config_options($values) {
set_config_plugin('interaction', 'forum', 'postdelay', $values['postdelay']);
}
}
class InteractionForumInstance extends InteractionInstance {
......@@ -562,7 +591,7 @@ function user_can_edit_post($poster, $posttime, $userid=null) {
global $USER;
$userid = $USER->get('id');
}
return $poster == $userid && $posttime > (time() - 30 * 60);
return $poster == $userid && $posttime > (time() - get_config_plugin('interaction', 'forum', 'postdelay') * 60);
}
/**
......
......@@ -24,7 +24,7 @@
*
*/
$config->version = 2009062300;
$config->version = 2009081700;
$config->release = '1.2.0';
?>
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