mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Merge branch 'MDL-64884-master' of git://github.com/lameze/moodle
This commit is contained in:
commit
f9aeebd18e
@ -737,25 +737,6 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||
return array('code' => 1, 'message' => $returnString, 'last log id' => $remoteclient->last_log_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cron function will be called automatically by cron.php every 5 minutes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function cron() {
|
||||
global $DB;
|
||||
|
||||
// run the keepalive client
|
||||
$this->keepalive_client();
|
||||
|
||||
$random100 = rand(0,100);
|
||||
if ($random100 < 10) { // Approximately 10% of the time.
|
||||
// nuke olden sessions
|
||||
$longtime = time() - (1 * 3600 * 24);
|
||||
$DB->delete_records_select('mnet_session', "expires < ?", array($longtime));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup any remote mnet_sessions, kill the local mnet_session data
|
||||
*
|
||||
|
52
auth/mnet/classes/task/cron_task.php
Normal file
52
auth/mnet/classes/task/cron_task.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?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 auth_mnet\task;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* A schedule task for mnet cron.
|
||||
*
|
||||
* @package auth_mnet
|
||||
* @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', 'auth_mnet');
|
||||
}
|
||||
/**
|
||||
* Run auth mnet cron.
|
||||
*/
|
||||
public function execute() {
|
||||
global $DB, $CFG;
|
||||
|
||||
require_once($CFG->dirroot . '/auth/mnet/auth.php');
|
||||
$mnetplugin = new \auth_plugin_mnet();
|
||||
$mnetplugin->keepalive_client();
|
||||
|
||||
$random100 = rand(0,100);
|
||||
if ($random100 < 10) {
|
||||
$longtime = time() - DAYSECS;
|
||||
$DB->delete_records_select('mnet_session', "expires < ?", [$longtime]);
|
||||
}
|
||||
}
|
||||
}
|
34
auth/mnet/db/tasks.php
Normal file
34
auth/mnet/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 chat scheduled tasks.
|
||||
*
|
||||
* @package auth_mnet
|
||||
* @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' => '\auth_mnet\task\cron_task',
|
||||
'blocking' => 0,
|
||||
'minute' => '*',
|
||||
'hour' => '*',
|
||||
'day' => '*',
|
||||
'month' => '*',
|
||||
'dayofweek' => '*'
|
||||
)
|
||||
);
|
@ -28,6 +28,7 @@ $string['auth_mnet_roamin'] = 'These host\'s users can roam in to your site';
|
||||
$string['auth_mnet_roamout'] = 'Your users can roam out to these hosts';
|
||||
$string['auth_mnet_rpc_negotiation_timeout'] = 'The timeout in seconds for authentication over the XMLRPC transport.';
|
||||
$string['auto_add_remote_users'] = 'Auto add remote users';
|
||||
$string['crontask'] = 'Background processing for MNET authentication';
|
||||
$string['rpc_negotiation_timeout'] = 'RPC negotiation timeout';
|
||||
$string['sso_idp_description'] = 'Publish this service to allow your users to roam to the {$a} site without having to re-login there. <ul><li><em>Dependency</em>: You must also <strong>subscribe</strong> to the SSO (Service Provider) service on {$a}.</li></ul><br />Subscribe to this service to allow authenticated users from {$a} to access your site without having to re-login. <ul><li><em>Dependency</em>: You must also <strong>publish</strong> the SSO (Service Provider) service to {$a}.</li></ul><br />';
|
||||
$string['sso_idp_name'] = 'SSO (Identity Provider)';
|
||||
|
@ -24,6 +24,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 = 'auth_mnet'; // Full name of the plugin (used for diagnostics)
|
||||
|
Loading…
x
Reference in New Issue
Block a user