|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00027 defined('MOODLE_INTERNAL') || die(); 00028 00034 class enrol_category_plugin extends enrol_plugin { 00035 00042 public function instance_deleteable($instance) { 00043 global $DB; 00044 00045 if (!enrol_is_enabled('category')) { 00046 return true; 00047 } 00048 // allow delete only when no synced users here 00049 return !$DB->record_exists('user_enrolments', array('enrolid'=>$instance->id)); 00050 } 00051 00057 public function get_newinstance_link($courseid) { 00058 // instances are added automatically as necessary 00059 return NULL; 00060 } 00061 00066 public function cron() { 00067 global $CFG; 00068 00069 if (!enrol_is_enabled('category')) { 00070 return; 00071 } 00072 00073 require_once("$CFG->dirroot/enrol/category/locallib.php"); 00074 enrol_category_sync_full(); 00075 } 00076 00085 public function course_updated($inserted, $course, $data) { 00086 global $CFG; 00087 00088 if (!enrol_is_enabled('category')) { 00089 return; 00090 } 00091 00092 // sync category enrols 00093 require_once("$CFG->dirroot/enrol/category/locallib.php"); 00094 enrol_category_sync_course($course); 00095 } 00096 } 00097 00098