mirror of
https://github.com/moodle/moodle.git
synced 2025-05-02 06:22:59 +02:00
MDL-64882 repository_dropbox: convert cron to schedule task
This commit is contained in:
parent
89d1238962
commit
d77c810627
49
repository/dropbox/classes/task/cron_task.php
Normal file
49
repository/dropbox/classes/task/cron_task.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?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/>.
|
||||
|
||||
namespace repository_dropbox\task;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* A schedule task for dropbox repository cron.
|
||||
*
|
||||
* @package repository_dropbox
|
||||
* @copyright 2019 Simey Lameze <simey@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
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', 'repository_dropbox');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run dropbox repository cron.
|
||||
*/
|
||||
public function execute() {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/repository/lib.php');
|
||||
|
||||
$instances = \repository::get_instances(['type' => 'dropbox']);
|
||||
foreach ($instances as $instance) {
|
||||
$instance->cron();
|
||||
}
|
||||
}
|
||||
}
|
34
repository/dropbox/db/tasks.php
Normal file
34
repository/dropbox/db/tasks.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?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/>.
|
||||
/**
|
||||
* Definition of dropbox repository scheduled tasks.
|
||||
*
|
||||
* @package repository_dropbox
|
||||
* @copyright 2019 Simey Lameze <simey@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
$tasks = array(
|
||||
array(
|
||||
'classname' => '\repository_dropbox\task\cron_task',
|
||||
'blocking' => 0,
|
||||
'minute' => '*',
|
||||
'hour' => '*',
|
||||
'day' => '*',
|
||||
'month' => '*',
|
||||
'dayofweek' => '*'
|
||||
)
|
||||
);
|
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
$string['configplugin'] = 'Dropbox configuration';
|
||||
$string['crontask'] = 'Background processing for dropbox repository';
|
||||
$string['notitle'] = 'notitle';
|
||||
$string['remember'] = 'Remember me';
|
||||
$string['pluginname'] = 'Dropbox';
|
||||
|
@ -25,6 +25,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2018120300; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2018120301; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2018112800; // Requires this Moodle version
|
||||
$plugin->component = 'repository_dropbox'; // Full name of the plugin (used for diagnostics)
|
||||
|
Loading…
x
Reference in New Issue
Block a user