mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
Merge branch 'MDL-57913_auth_db_sync_task_master' of git://github.com/gthomas2/moodle
This commit is contained in:
commit
eb6f04732a
63
auth/db/classes/task/sync_users.php
Normal file
63
auth/db/classes/task/sync_users.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 users task
|
||||
* @package auth_db
|
||||
* @author Guy Thomas <gthomas@moodlerooms.com>
|
||||
* @copyright Copyright (c) 2017 Blackboard Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace auth_db\task;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Sync users task class
|
||||
* @package auth_db
|
||||
* @author Guy Thomas <gthomas@moodlerooms.com>
|
||||
* @copyright Copyright (c) 2017 Blackboard Inc.
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class sync_users extends \core\task\scheduled_task {
|
||||
|
||||
/**
|
||||
* Name for this task.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_name() {
|
||||
return get_string('auth_dbsyncuserstask', 'auth_db');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run task for synchronising users.
|
||||
*/
|
||||
public function execute() {
|
||||
if (!is_enabled_auth('db')) {
|
||||
mtrace('auth_db plugin is disabled, synchronisation stopped', 2);
|
||||
return;
|
||||
}
|
||||
|
||||
$dbauth = get_auth_plugin('db');
|
||||
$config = get_config('auth/db');
|
||||
$trace = new \text_progress_trace();
|
||||
$update = !empty($config->updateusers);
|
||||
$dbauth->sync_users($trace, $update);
|
||||
}
|
||||
|
||||
}
|
@ -81,6 +81,14 @@ if (!is_enabled_auth('db')) {
|
||||
cli_error('auth_db plugin is disabled, synchronisation stopped', 2);
|
||||
}
|
||||
|
||||
cli_problem('[AUTH DB] The sync users cron has been deprecated. Please use the scheduled task instead.');
|
||||
|
||||
// Abort execution of the CLI script if the \auth_db\task\sync_users is enabled.
|
||||
$task = \core\task\manager::get_scheduled_task('auth_db\task\sync_users');
|
||||
if (!$task->get_disabled()) {
|
||||
cli_error('[AUTH DB] The scheduled task sync_users is enabled, the cron execution has been aborted.');
|
||||
}
|
||||
|
||||
if (empty($options['verbose'])) {
|
||||
$trace = new null_progress_trace();
|
||||
} else {
|
||||
|
@ -46,6 +46,9 @@
|
||||
if (!isset($config->removeuser)) {
|
||||
$config->removeuser = AUTH_REMOVEUSER_KEEP;
|
||||
}
|
||||
if (!isset($config->updateusers)) {
|
||||
$config->updateusers = 0;
|
||||
}
|
||||
|
||||
$yesno = array( get_string('no'), get_string('yes') );
|
||||
|
||||
@ -268,6 +271,16 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><label for="menuupdateusers"><?php print_string('auth_dbupdateusers', 'auth_db') ?></label></td>
|
||||
<td>
|
||||
<?php echo html_writer::select($yesno, 'updateusers', $config->updateusers, false); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('auth_dbupdateusers_description','auth_db') ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
print_auth_lock_options($this->authtype, $user_fields, get_string('auth_dbextrafields', 'auth_db'), true, true, $this->get_custom_user_profile_fields());
|
||||
|
38
auth/db/db/tasks.php
Normal file
38
auth/db/db/tasks.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?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 auth_db.
|
||||
* @author Guy Thomas <gthomas@moodlerooms.com>
|
||||
* @copyright Copyright (c) 2017 Blackboard Inc.
|
||||
* @package auth_db
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$tasks = array(
|
||||
array(
|
||||
'classname' => '\auth_db\task\sync_users',
|
||||
'blocking' => 0,
|
||||
'minute' => 'R',
|
||||
'hour' => 'R',
|
||||
'day' => '*',
|
||||
'month' => '*',
|
||||
'dayofweek' => '*',
|
||||
'disabled' => 1
|
||||
)
|
||||
);
|
@ -56,10 +56,13 @@ $string['auth_dbsuspenduser'] = 'Suspended user {$a->name} id {$a->id}';
|
||||
$string['auth_dbsuspendusererror'] = 'Error suspending user {$a}';
|
||||
$string['auth_dbsybasequoting'] = 'Use sybase quotes';
|
||||
$string['auth_dbsybasequotinghelp'] = 'Sybase style single quote escaping - needed for Oracle, MS SQL and some other databases. Do not use for MySQL!';
|
||||
$string['auth_dbsyncuserstask'] = 'Synchronise users task';
|
||||
$string['auth_dbtable'] = 'Name of the table in the database';
|
||||
$string['auth_dbtable_key'] = 'Table';
|
||||
$string['auth_dbtype'] = 'The database type (See the <a href="http://phplens.com/adodb/supported.databases.html" target="_blank">ADOdb documentation</a> for details)';
|
||||
$string['auth_dbtype_key'] = 'Database';
|
||||
$string['auth_dbupdateusers'] = 'Update users';
|
||||
$string['auth_dbupdateusers_description'] = 'As well as inserting new users, update existing users.';
|
||||
$string['auth_dbupdatinguser'] = 'Updating user {$a->name} id {$a->id}';
|
||||
$string['auth_dbuser'] = 'Username with read access to the database';
|
||||
$string['auth_dbuser_key'] = 'DB user';
|
||||
|
@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2017022200; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2016112900; // Requires this Moodle version
|
||||
$plugin->component = 'auth_db'; // Full name of the plugin (used for diagnostics)
|
||||
|
Loading…
x
Reference in New Issue
Block a user