Skip to content

Commit

Permalink
Merge branch 'MDL-61208-master' of git://github.com/farhan6318/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Apr 11, 2018
2 parents 8badf71 + fe5b5be commit 2b118a9
Show file tree
Hide file tree
Showing 32 changed files with 738 additions and 77 deletions.
63 changes: 63 additions & 0 deletions enrol/category/classes/task/enrol_category_sync.php
Original file line number Diff line number Diff line change
@@ -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/>.

/**
* Syncing enrolments task.
*
* @package enrol_category
* @author Farhan Karmali <[email protected]>
* @copyright Farhan Karmali
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace enrol_category\task;

defined('MOODLE_INTERNAL') || die();

/**
* Syncing enrolments task.
*
* @package enrol_category
* @author Farhan Karmali <[email protected]>
* @copyright Farhan Karmali
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class enrol_category_sync extends \core\task\scheduled_task {

/**
* Name for this task.
*
* @return string
*/
public function get_name() {
return get_string('enrolcategorysynctask', 'enrol_category');
}

/**
* Run task for syncing category enrolments.
*/
public function execute() {
global $CFG;

if (!enrol_is_enabled('category')) {
return;
}

require_once("$CFG->dirroot/enrol/category/locallib.php");
$trace = new null_progress_trace();
enrol_category_sync_full($trace);
}
}
39 changes: 39 additions & 0 deletions enrol/category/db/tasks.php
Original file line number Diff line number Diff line change
@@ -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 enrol_category.
* @author Farhan Karmali <[email protected]>
* @copyright Farhan Karmali
* @package enrol_category
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$tasks = array(
array(
'classname' => '\enrol_category\task\enrol_category_sync',
'blocking' => 0,
'minute' => '*',
'hour' => '*',
'day' => '*',
'month' => '*',
'dayofweek' => '*',
'disabled' => 0
)
);

1 change: 1 addition & 0 deletions enrol/category/lang/en/enrol_category.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@

$string['category:config'] = 'Configure category enrol instances';
$string['category:synchronised'] = 'Role assignments synchronised to course enrolment';
$string['enrolcategorysynctask'] = 'Category enrolment sync task';
$string['pluginname'] = 'Category enrolments';
$string['pluginname_desc'] = 'The category enrolments plugin synchronises any role assignments in the category context for roles with the capability enrol/category:synchronised allowed.';
16 changes: 0 additions & 16 deletions enrol/category/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,6 @@ public function get_newinstance_link($courseid) {
return null;
}

/**
* Called for all enabled enrol plugins that returned true from is_cron_required().
* @return void
*/
public function cron() {
global $CFG;

if (!enrol_is_enabled('category')) {
return;
}

require_once("$CFG->dirroot/enrol/category/locallib.php");
$trace = new null_progress_trace();
enrol_category_sync_full($trace);
}

/**
* Called after updating/inserting course.
*
Expand Down
3 changes: 1 addition & 2 deletions enrol/category/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2017111300; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2018040900; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2017110800; // Requires this Moodle version
$plugin->component = 'enrol_category'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 60;
60 changes: 60 additions & 0 deletions enrol/cohort/classes/task/enrol_cohort_sync.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?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/>.

/**
* Syncing enrolments task.
*
* @package enrol_cohort
* @author Farhan Karmali <[email protected]>
* @copyright Farhan Karmali
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace enrol_cohort\task;

defined('MOODLE_INTERNAL') || die();

/**
* Syncing enrolments task.
*
* @package enrol_cohort
* @author Farhan Karmali <[email protected]>
* @copyright Farhan Karmali
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class enrol_cohort_sync extends \core\task\scheduled_task {

/**
* Name for this task.
*
* @return string
*/
public function get_name() {
return get_string('enrolcohortsynctask', 'enrol_cohort');
}

/**
* Run task for syncing cohort enrolments.
*/
public function execute() {
global $CFG;

require_once("$CFG->dirroot/enrol/cohort/locallib.php");
$trace = new null_progress_trace();
enrol_cohort_sync($trace);
$trace->finished();
}
}
39 changes: 39 additions & 0 deletions enrol/cohort/db/tasks.php
Original file line number Diff line number Diff line change
@@ -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 enrol_cohort.
* @author Farhan Karmali <[email protected]>
* @copyright Farhan Karmali
* @package enrol_cohort
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$tasks = array(
array(
'classname' => '\enrol_cohort\task\enrol_cohort_sync',
'blocking' => 0,
'minute' => 'R',
'hour' => '*',
'day' => '*',
'month' => '*',
'dayofweek' => '*',
'disabled' => 0
)
);

1 change: 1 addition & 0 deletions enrol/cohort/lang/en/enrol_cohort.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
$string['cohort:config'] = 'Configure cohort instances';
$string['cohort:unenrol'] = 'Unenrol suspended users';
$string['defaultgroupnametext'] = '{$a->name} cohort {$a->increment}';
$string['enrolcohortsynctask'] = 'Cohort enrolment sync task';
$string['instanceexists'] = 'Cohort is already synchronised with selected role';
$string['pluginname'] = 'Cohort sync';
$string['pluginname_desc'] = 'Cohort enrolment plugin synchronises cohort members with course participants.';
Expand Down
13 changes: 0 additions & 13 deletions enrol/cohort/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,6 @@ public function update_instance($instance, $data) {
return $result;
}

/**
* Called for all enabled enrol plugins that returned true from is_cron_required().
* @return void
*/
public function cron() {
global $CFG;

require_once("$CFG->dirroot/enrol/cohort/locallib.php");
$trace = new null_progress_trace();
enrol_cohort_sync($trace);
$trace->finished();
}

/**
* Called after updating/inserting course.
*
Expand Down
3 changes: 1 addition & 2 deletions enrol/cohort/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2017111300; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2018040900; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2017110800; // Requires this Moodle version
$plugin->component = 'enrol_cohort'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 60*60; // run cron every hour by default, it is not out-of-sync often
58 changes: 58 additions & 0 deletions enrol/manual/classes/task/send_expiry_notifications.php
Original file line number Diff line number Diff line change
@@ -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/>.

/**
* The send expiry notifications task.
*
* @package enrol_manual
* @author Farhan Karmali <[email protected]>
* @copyright Farhan Karmali
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace enrol_manual\task;

defined('MOODLE_INTERNAL') || die();

/**
* The send expiry notifications task.
*
* @package enrol_manual
* @author Farhan Karmali <[email protected]>
* @copyright Farhan Karmali
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class send_expiry_notifications extends \core\task\scheduled_task {

/**
* Name for this task.
*
* @return string
*/
public function get_name() {
return get_string('sendexpirynotificationstask', 'enrol_manual');
}

/**
* Run task for sending expiry notifications.
*/
public function execute() {
$enrol = enrol_get_plugin('manual');
$trace = new \text_progress_trace();
$enrol->send_expiry_notifications($trace);
}

}
57 changes: 57 additions & 0 deletions enrol/manual/classes/task/sync_enrolments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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/>.

/**
* Syncing enrolments task.
*
* @package enrol_manual
* @author Farhan Karmali <[email protected]>
* @copyright Farhan Karmali
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace enrol_manual\task;

defined('MOODLE_INTERNAL') || die();

/**
* Syncing enrolments task.
*
* @package enrol_manual
* @author Farhan Karmali <[email protected]>
* @copyright Farhan Karmali
* @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_manual');
}

/**
* Run task for syncing enrolments.
*/
public function execute() {
$enrol = enrol_get_plugin('manual');
$trace = new \text_progress_trace();
$enrol->sync($trace);
}
}
Loading

0 comments on commit 2b118a9

Please sign in to comment.