mirror of
https://github.com/moodle/moodle.git
synced 2025-04-11 19:42:35 +02:00
Merge branch 'MDL-59986-master' of https://github.com/danielneis/moodle
This commit is contained in:
commit
e69017267f
63
enrol/database/classes/task/sync_enrolments.php
Normal file
63
enrol/database/classes/task/sync_enrolments.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Sync enrolments task
|
||||
* @package enrol_database
|
||||
* @copyright 2018 Daniel Neis Araujo <danielneis@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace enrol_database\task;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Class sync_enrolments
|
||||
* @package enrol_database
|
||||
* @copyright 2018 Daniel Neis Araujo <danielneis@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class sync_enrolments extends \core\task\scheduled_task {
|
||||
|
||||
/**
|
||||
* Name for this task.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_name() {
|
||||
return get_string('syncenrolmentstask', 'enrol_database');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run task for synchronising users.
|
||||
*/
|
||||
public function execute() {
|
||||
|
||||
$trace = new \text_progress_trace();
|
||||
|
||||
if (!enrol_is_enabled('database')) {
|
||||
$trace->output('Plugin not enabled');
|
||||
return;
|
||||
}
|
||||
|
||||
$enrol = enrol_get_plugin('database');
|
||||
|
||||
// Update enrolments -- these handlers should autocreate courses if required.
|
||||
$enrol->sync_courses($trace);
|
||||
$enrol->sync_enrolments($trace);
|
||||
}
|
||||
}
|
@ -26,6 +26,8 @@
|
||||
* - you need to change the "www-data" to match the apache user account
|
||||
* - use "su" if "sudo" not available
|
||||
*
|
||||
* @deprecated since Moodle 3.7 MDL-59986 - please do not use this CLI script any more, use scheduled task instead.
|
||||
* @todo MDL-63266 This will be deleted in Moodle 4.1.
|
||||
* @package enrol_database
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
@ -65,6 +67,14 @@ Sample cron entry:
|
||||
die;
|
||||
}
|
||||
|
||||
cli_problem('[ENROL DATABASE] The sync enrolments cron script has been deprecated. Please use the scheduled task instead.');
|
||||
|
||||
// Abort execution of the CLI script if the enrol_database\task\sync_enrolments is enabled.
|
||||
$task = \core\task\manager::get_scheduled_task('enrol_database\task\sync_enrolments');
|
||||
if (!$task->get_disabled()) {
|
||||
cli_error('[ENROL DATABASE] The scheduled task sync_enrolments is enabled, the cron execution has been aborted.');
|
||||
}
|
||||
|
||||
if (!enrol_is_enabled('database')) {
|
||||
cli_error('enrol_database plugin is disabled, synchronisation stopped', 2);
|
||||
}
|
||||
|
37
enrol/database/db/tasks.php
Normal file
37
enrol/database/db/tasks.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?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 enrol_database.
|
||||
* @package enrol_database
|
||||
* @copyright 2018 Daniel Neis Araujo <danielneis@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$tasks = array(
|
||||
array(
|
||||
'classname' => '\enrol_database\task\sync_enrolments',
|
||||
'blocking' => 0,
|
||||
'minute' => 'R',
|
||||
'hour' => 'R',
|
||||
'day' => '*',
|
||||
'month' => '*',
|
||||
'dayofweek' => '*',
|
||||
'disabled' => 1
|
||||
)
|
||||
);
|
@ -70,6 +70,7 @@ $string['settingsheaderdb'] = 'External database connection';
|
||||
$string['settingsheaderlocal'] = 'Local field mapping';
|
||||
$string['settingsheaderremote'] = 'Remote enrolment sync';
|
||||
$string['settingsheadernewcourses'] = 'Creation of new courses';
|
||||
$string['syncenrolmentstask'] = 'Synchronise external database enrolments task';
|
||||
$string['remoteuserfield_desc'] = 'The name of the field in the remote table that we are using to match entries in the user table.';
|
||||
$string['templatecourse'] = 'New course template';
|
||||
$string['templatecourse_desc'] = 'Optional: auto-created courses can copy their settings from a template course. Type here the shortname of the template course.';
|
||||
|
4
enrol/database/upgrade.txt
Normal file
4
enrol/database/upgrade.txt
Normal file
@ -0,0 +1,4 @@
|
||||
This files describes API changes in the enrol_database code.
|
||||
|
||||
=== 3.7 ===
|
||||
* enrol/database/cli/sync.php script has been deprecated in favour of enrol_database\task\sync_enrolments task.
|
@ -24,7 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2018120300; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2018122000; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2018112800; // Requires this Moodle version
|
||||
$plugin->component = 'enrol_database'; // Full name of the plugin (used for diagnostics)
|
||||
//TODO: should we add cron sync?
|
||||
|
Loading…
x
Reference in New Issue
Block a user