MDL-61960 blocks: Standard block plugins use legacy cron

This commit is contained in:
Farhan Karmali 2018-05-29 01:29:12 +05:30
parent 0180369b27
commit fad9dc9290
11 changed files with 272 additions and 104 deletions

View file

@ -228,16 +228,6 @@ class block_recent_activity extends block_base {
return array('all' => true, 'my' => false, 'tag' => false);
}
/**
* Remove old entries from table block_recent_activity
*/
public function cron() {
global $DB;
// Those entries will never be displayed as RECENT anyway.
$DB->delete_records_select('block_recent_activity', 'timecreated < ?',
array(time() - COURSE_MAX_RECENT_PERIOD));
}
/**
* Migrates entries from table {log} into {block_recent_activity}
*

View file

@ -0,0 +1,58 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Task for updating RSS feeds for rss client block
*
* @package block_recent_activity
* @author Farhan Karmali <farhan6318@gmail.com>
* @copyright Farhan Karmali 2018
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_recent_activity\task;
defined('MOODLE_INTERNAL') || die();
/**
* Task for updating RSS feeds for rss client block
*
* @package block_recent_activity
* @author Farhan Karmali <farhan6318@gmail.com>
* @copyright Farhan Karmali 2018
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cleanup extends \core\task\scheduled_task {
/**
* Name for this task.
*
* @return string
*/
public function get_name() {
return get_string('cleanuptask', 'block_recent_activity');
}
/**
* Remove old entries from table block_recent_activity
*/
public function execute() {
global $DB;
// Those entries will never be displayed as RECENT anyway.
$DB->delete_records_select('block_recent_activity', 'timecreated < ?',
array(time() - COURSE_MAX_RECENT_PERIOD));
}
}

View file

@ -0,0 +1,39 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Task definition for block_recent_activity.
* @author Farhan Karmali <farhan6318@gmail.com>
* @copyright Farhan Karmali 2018
* @package block_recent_activity
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$tasks = array(
array(
'classname' => '\block_recent_activity\task\cleanup',
'blocking' => 0,
'minute' => 'R',
'hour' => 'R',
'day' => '*',
'month' => '*',
'dayofweek' => '*',
'disabled' => 0
)
);

View file

@ -23,6 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['cleanuptask'] = 'Cleanup task for recent activity block';
$string['pluginname'] = 'Recent activity';
$string['privacy:metadata'] = 'The recent activity block contains a cache of data stored elsewhere in Moodle.';
$string['privacy:metadata:block_recent_activity'] = 'Temporary log of recent teacher activity. Removed after two days';

View file

@ -24,7 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018051400; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2018052900; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2018050800; // Requires this Moodle version
$plugin->component = 'block_recent_activity'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 24*3600; // Cron interval 1 day.