Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/enrol.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00026 require_once('../config.php');
00027 require_once($CFG->libdir.'/adminlib.php');
00028 
00029 $action  = required_param('action', PARAM_ACTION);
00030 $enrol   = required_param('enrol', PARAM_PLUGIN);
00031 $confirm = optional_param('confirm', 0, PARAM_BOOL);
00032 
00033 $PAGE->set_url('/admin/enrol.php');
00034 $PAGE->set_context(context_system::instance());
00035 
00036 require_login();
00037 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
00038 require_sesskey();
00039 
00040 $enabled = enrol_get_plugins(true);
00041 $all     = enrol_get_plugins(false);
00042 
00043 $return = new moodle_url('/admin/settings.php', array('section'=>'manageenrols'));
00044 
00045 $syscontext = context_system::instance();
00046 
00047 switch ($action) {
00048     case 'disable':
00049         unset($enabled[$enrol]);
00050         set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
00051         $syscontext->mark_dirty(); // resets all enrol caches
00052         break;
00053 
00054     case 'enable':
00055         if (!isset($all[$enrol])) {
00056             break;
00057         }
00058         $enabled = array_keys($enabled);
00059         $enabled[] = $enrol;
00060         set_config('enrol_plugins_enabled', implode(',', $enabled));
00061         $syscontext->mark_dirty(); // resets all enrol caches
00062         break;
00063 
00064     case 'up':
00065         if (!isset($enabled[$enrol])) {
00066             break;
00067         }
00068         $enabled = array_keys($enabled);
00069         $enabled = array_flip($enabled);
00070         $current = $enabled[$enrol];
00071         if ($current == 0) {
00072             break; //already at the top
00073         }
00074         $enabled = array_flip($enabled);
00075         $enabled[$current] = $enabled[$current - 1];
00076         $enabled[$current - 1] = $enrol;
00077         set_config('enrol_plugins_enabled', implode(',', $enabled));
00078         break;
00079 
00080     case 'down':
00081         if (!isset($enabled[$enrol])) {
00082             break;
00083         }
00084         $enabled = array_keys($enabled);
00085         $enabled = array_flip($enabled);
00086         $current = $enabled[$enrol];
00087         if ($current == count($enabled) - 1) {
00088             break; //already at the end
00089         }
00090         $enabled = array_flip($enabled);
00091         $enabled[$current] = $enabled[$current + 1];
00092         $enabled[$current + 1] = $enrol;
00093         set_config('enrol_plugins_enabled', implode(',', $enabled));
00094         break;
00095 
00096     case 'uninstall':
00097         echo $OUTPUT->header();
00098         echo $OUTPUT->heading(get_string('enrolments', 'enrol'));
00099 
00100         if (get_string_manager()->string_exists('pluginname', 'enrol_'.$enrol)) {
00101             $strplugin = get_string('pluginname', 'enrol_'.$enrol);
00102         } else {
00103             $strplugin = $enrol;
00104         }
00105 
00106         if (!$confirm) {
00107             $uurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1));
00108             echo $OUTPUT->confirm(get_string('uninstallconfirm', 'enrol', $strplugin), $uurl, $return);
00109             echo $OUTPUT->footer();
00110             exit;
00111 
00112         } else {  // Delete everything!!
00113             uninstall_plugin('enrol', $enrol);
00114             $syscontext->mark_dirty(); // resets all enrol caches
00115 
00116             $a = new stdClass();
00117             $a->plugin = $strplugin;
00118             $a->directory = "$CFG->dirroot/enrol/$enrol";
00119             echo $OUTPUT->notification(get_string('uninstalldeletefiles', 'enrol', $a), 'notifysuccess');
00120             echo $OUTPUT->continue_button($return);
00121             echo $OUTPUT->footer();
00122             exit;
00123         }
00124 }
00125 
00126 
00127 redirect($return);
 All Data Structures Namespaces Files Functions Variables Enumerations