. /** * Category enrolment plugin. * * @package enrol * @subpackage category * @copyright 2010 Petr Skoda {@link http://skodak.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * category enrolment plugin implementation. * @author Petr Skoda * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class enrol_category_plugin extends enrol_plugin { /** * Is it possible to delete enrol instance via standard UI? * * @param object $instance * @return bool */ public function instance_deleteable($instance) { global $DB; if (!enrol_is_enabled('category')) { return true; } // allow delete only when no synced users here return !$DB->record_exists('user_enrolments', array('enrolid'=>$instance->id)); } /** * Returns link to page which may be used to add new instance of enrolment plugin in course. * @param int $courseid * @return moodle_url page url */ public function get_newinstance_link($courseid) { // instances are added automatically as necessary 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"); enrol_category_sync_full(); } /** * Called after updating/inserting course. * * @param bool $inserted true if course just inserted * @param object $course * @param object $data form data * @return void */ public function course_updated($inserted, $course, $data) { global $CFG; if (!enrol_is_enabled('category')) { return; } // sync category enrols require_once("$CFG->dirroot/enrol/category/locallib.php"); enrol_category_sync_course($course); } }