diff --git a/mod/forum/classes/task/cron_task.php b/mod/forum/classes/task/cron_task.php new file mode 100644 index 0000000000000..f232c622c8b4c --- /dev/null +++ b/mod/forum/classes/task/cron_task.php @@ -0,0 +1,48 @@ +. + +/** + * A scheduled task for forum cron. + * + * @todo MDL-44734 This job will be split up properly. + * + * @package mod_forum + * @copyright 2014 Dan Poltawski + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +namespace mod_forum\task; + +class cron_task extends \core\task\scheduled_task { + + /** + * Get a descriptive name for this task (shown to admins). + * + * @return string + */ + public function get_name() { + return get_string('crontask', 'mod_forum'); + } + + /** + * Run forum cron. + */ + public function execute() { + global $CFG; + require_once($CFG->dirroot . '/mod/forum/lib.php'); + forum_cron(); + } + +} diff --git a/mod/forum/db/tasks.php b/mod/forum/db/tasks.php new file mode 100644 index 0000000000000..03ad9e0f6cec8 --- /dev/null +++ b/mod/forum/db/tasks.php @@ -0,0 +1,38 @@ +. + +/** + * Definition of Forum scheduled tasks. + * + * @package mod_forum + * @category task + * @copyright 2014 Dan Poltawski + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$tasks = array( + array( + 'classname' => 'mod_forum\task\cron_task', + 'blocking' => 0, + 'minute' => '*', + 'hour' => '*', + 'day' => '*', + 'month' => '*', + 'dayofweek' => '*' + ) +); diff --git a/mod/forum/lang/en/forum.php b/mod/forum/lang/en/forum.php index 1c6804fde81fd..4eed8db7d4908 100644 --- a/mod/forum/lang/en/forum.php +++ b/mod/forum/lang/en/forum.php @@ -110,6 +110,7 @@ $string['couldnotadd'] = 'Could not add your post due to an unknown error'; $string['couldnotdeletereplies'] = 'Sorry, that cannot be deleted as people have already responded to it'; $string['couldnotupdate'] = 'Could not update your post due to an unknown error'; +$string['crontask'] = 'Forum mailings and maintenance jobs'; $string['delete'] = 'Delete'; $string['deleteddiscussion'] = 'The discussion topic has been deleted'; $string['deletedpost'] = 'The post has been deleted'; diff --git a/mod/forum/lib.php b/mod/forum/lib.php index bc9e144df1d87..5fdada988862a 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -434,18 +434,15 @@ function forum_cron_minimise_user_record(stdClass $user) { } /** - * Function to be run periodically according to the moodle cron + * Function to be run periodically according to the scheduled task. + * * Finds all posts that have yet to be mailed out, and mails them - * out to all subscribers + * out to all subscribers as well as other maintance tasks. * - * @global object - * @global object - * @global object - * @uses CONTEXT_MODULE - * @uses CONTEXT_COURSE - * @uses SITEID - * @uses FORMAT_PLAIN - * @return void + * NOTE: Since 2.7.2 this function is run by scheduled task rather + * than standard cron. + * + * @todo MDL-44734 The function will be split up into seperate tasks. */ function forum_cron() { global $CFG, $USER, $DB; diff --git a/mod/forum/version.php b/mod/forum/version.php index 12037b7178394..b554c767dbebe 100644 --- a/mod/forum/version.php +++ b/mod/forum/version.php @@ -24,7 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2014081900; // The current module version (Date: YYYYMMDDXX) +$plugin->version = 2014082100; // The current module version (Date: YYYYMMDDXX) $plugin->requires = 2014050800; // Requires this Moodle version $plugin->component = 'mod_forum'; // Full name of the plugin (used for diagnostics) -$plugin->cron = 60;