forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-21782 reworked enrolment framework, the core infrastructure is in…
… place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week AMOS START MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self] MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self] MOV [enrolstartdate,core],[enrolstartdate,enrol_self] MOV [enrolenddate,core],[enrolenddate,enrol_self] CPY [welcometocourse,core],[welcometocourse,enrol_self] CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self] MOV [notenrollable,core],[notenrollable,core_enrol] MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self] MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self] MOV [coursemanager,core_admin],[coursecontact,core_admin] MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin] MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual] MOV [enrolme,core],[enrolme,core_enrol] MOV [unenrol,core],[unenrol,core_enrol] MOV [unenrolme,core],[unenrolme,core_enrol] MOV [enrolmentnew,core],[enrolmentnew,core_enrol] MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol] MOV [enrolments,core],[enrolments,core_enrol] MOV [enrolperiod,core],[enrolperiod,core_enrol] MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol] AMOS END
- Loading branch information
Showing
225 changed files
with
11,021 additions
and
7,605 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,141 +1,120 @@ | ||
<?php | ||
// enrol.php - allows admin to edit all enrollment variables | ||
// Yes, enrol is correct English spelling. | ||
|
||
require_once('../config.php'); | ||
require_once($CFG->libdir.'/adminlib.php'); | ||
|
||
$enrol = optional_param('enrol', $CFG->enrol, PARAM_SAFEDIR); | ||
$savesettings = optional_param('savesettings', 0, PARAM_BOOL); | ||
|
||
admin_externalpage_setup('enrolment'); | ||
|
||
if (!isset($CFG->sendcoursewelcomemessage)) { | ||
set_config('sendcoursewelcomemessage', 1); | ||
} | ||
|
||
|
||
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class | ||
|
||
/// Save settings | ||
|
||
if ($frm = data_submitted() and !$savesettings) { | ||
if (!confirm_sesskey()) { | ||
print_error('confirmsesskeybad', 'error'); | ||
// 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/>. | ||
|
||
/** | ||
* Enrol config manipulation script. | ||
* | ||
* @package core | ||
* @subpackage enrol | ||
* @copyright 2010 Petr Skoda {@link http://skodak.org} | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
require_once('../config.php'); | ||
require_once($CFG->libdir.'/adminlib.php'); | ||
|
||
$action = required_param('action', PARAM_ACTION); | ||
$enrol = required_param('enrol', PARAM_SAFEDIR); | ||
$confirm = optional_param('confirm', 0, PARAM_BOOL); | ||
|
||
$PAGE->set_url('/admin/enrol.php'); | ||
|
||
require_login(); | ||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); | ||
require_sesskey(); | ||
|
||
$enabled = enrol_get_plugins(true); | ||
$all = enrol_get_plugins(false); | ||
|
||
$return = new moodle_url('/admin/settings.php', array('section'=>'manageenrols')); | ||
|
||
switch ($action) { | ||
case 'disable': | ||
unset($enabled[$enrol]); | ||
set_config('enrol_plugins_enabled', implode(',', array_keys($enabled))); | ||
break; | ||
|
||
case 'enable': | ||
if (!isset($all[$enrol])) { | ||
break; | ||
} | ||
if (empty($frm->enable)) { | ||
$frm->enable = array(); | ||
$enabled = array_keys($enabled); | ||
$enabled[] = $enrol; | ||
set_config('enrol_plugins_enabled', implode(',', $enabled)); | ||
break; | ||
|
||
case 'up': | ||
if (!isset($enabled[$enrol])) { | ||
break; | ||
} | ||
if (empty($frm->default)) { | ||
$frm->default = ''; | ||
} | ||
if ($frm->default && $frm->default != 'manual' && !in_array($frm->default, $frm->enable)) { | ||
$frm->enable[] = $frm->default; | ||
} | ||
asort($frm->enable); | ||
$frm->enable = array_merge(array('manual'), $frm->enable); // make sure manual plugin is called first | ||
set_config('enrol_plugins_enabled', implode(',', $frm->enable)); | ||
set_config('enrol', $frm->default); | ||
redirect("enrol.php", get_string("changessaved"), 1); | ||
|
||
} else if ($frm = data_submitted() and $savesettings) { | ||
if (!confirm_sesskey()) { | ||
print_error('confirmsesskeybad', 'error'); | ||
} | ||
set_config('sendcoursewelcomemessage', required_param('sendcoursewelcomemessage', PARAM_BOOL)); | ||
} | ||
|
||
/// Print the form | ||
|
||
$str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit')); | ||
|
||
echo $OUTPUT->header(); | ||
|
||
$modules = get_plugin_list('enrol'); | ||
$options = array(); | ||
foreach ($modules as $module => $moduledir) { | ||
$options[$module] = get_string("enrolname", "enrol_$module"); | ||
} | ||
asort($options); | ||
|
||
echo $OUTPUT->box(get_string('configenrolmentplugins', 'admin')); | ||
|
||
echo "<form id=\"enrolmenu\" method=\"post\" action=\"enrol.php\">"; | ||
echo "<div>"; | ||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />"; | ||
|
||
$table = new html_table(); | ||
$table->head = array(get_string('name'), get_string('enable'), get_string('default'), $str->settings); | ||
$table->align = array('left', 'center', 'center', 'center'); | ||
$table->size = array('60%', '', '', '15%'); | ||
$table->attributes['class'] = 'generaltable enrolplugintable'; | ||
$table->data = array(); | ||
|
||
$enabledplugins = explode(',', $CFG->enrol_plugins_enabled); | ||
foreach ($modules as $module => $moduledir) { | ||
|
||
// skip if directory is empty | ||
if (!file_exists("$moduledir/enrol.php")) { | ||
continue; | ||
$enabled = array_keys($enabled); | ||
$enabled = array_flip($enabled); | ||
$current = $enabled[$enrol]; | ||
if ($current == 0) { | ||
break; //already at the top | ||
} | ||
|
||
$name = get_string("enrolname", "enrol_$module"); | ||
$plugin = enrolment_factory::factory($module); | ||
$enable = '<input type="checkbox" name="enable[]" value="'.$module.'"'; | ||
if (in_array($module, $enabledplugins)) { | ||
$enable .= ' checked="checked"'; | ||
$enabled = array_flip($enabled); | ||
$enabled[$current] = $enabled[$current - 1]; | ||
$enabled[$current - 1] = $enrol; | ||
set_config('enrol_plugins_enabled', implode(',', $enabled)); | ||
break; | ||
|
||
case 'down': | ||
if (!isset($enabled[$enrol])) { | ||
break; | ||
} | ||
if ($module == 'manual') { | ||
$enable .= ' disabled="disabled"'; | ||
$enabled = array_keys($enabled); | ||
$enabled = array_flip($enabled); | ||
$current = $enabled[$enrol]; | ||
if ($current == count($enabled) - 1) { | ||
break; //already at the end | ||
} | ||
$enable .= ' />'; | ||
if (method_exists($plugin, 'print_entry')) { | ||
$default = '<input type="radio" name="default" value="'.$module.'"'; | ||
if ($CFG->enrol == $module) { | ||
$default .= ' checked="checked"'; | ||
} | ||
$default .= ' />'; | ||
$enabled = array_flip($enabled); | ||
$enabled[$current] = $enabled[$current + 1]; | ||
$enabled[$current + 1] = $enrol; | ||
set_config('enrol_plugins_enabled', implode(',', $enabled)); | ||
break; | ||
|
||
case 'uninstall': | ||
echo $OUTPUT->header(); | ||
echo $OUTPUT->heading(get_string('enrolments', 'enrol')); | ||
|
||
if (get_string_manager()->string_exists('pluginname', 'enrol_'.$enrol)) { | ||
$strplugin = get_string('pluginname', 'enrol_'.$enrol); | ||
} else { | ||
$default = ''; | ||
$strplugin = $enrol; | ||
} | ||
$table->data[$name] = array($name, $enable, $default, | ||
'<a href="enrol_config.php?enrol='.$module.'">'.$str->edit.'</a>'); | ||
} | ||
asort($table->data); | ||
|
||
echo html_writer::table($table); | ||
|
||
echo "<div style=\"text-align:center\"><input type=\"submit\" value=\"".get_string("savechanges")."\" /></div>\n"; | ||
echo "</div>"; | ||
echo "</form>"; | ||
|
||
echo '<hr />'; | ||
|
||
$yesnooptions = array(0=>get_string('no'), 1=>get_string('yes')); | ||
|
||
echo '<form id="adminsettings" method="post" action="enrol.php">'; | ||
echo '<div class="settingsform clearfix">'; | ||
echo $OUTPUT->heading(get_string('commonsettings', 'admin')); | ||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />'; | ||
echo '<input type="hidden" name="savesettings" value="1" />'; | ||
echo '<fieldset>'; | ||
echo '<div class="form-item clearfix" id="admin-sendcoursewelcomemessage">'; | ||
|
||
echo '<div class="form-label"><label for = "menusendcoursewelcomemessage">' . get_string('sendcoursewelcomemessage', 'admin'); | ||
echo '<span class="form-shortname">sendcoursewelcomemessage</span>'; | ||
echo '</label></div>'; | ||
echo '<div class="form-setting"><div class="form-checkbox defaultsnext">'; | ||
echo html_writer::select($yesnooptions, 'sendcoursewelcomemessage', $CFG->sendcoursewelcomemessage, false); | ||
echo '</div><div class="form-defaultinfo">'.get_string('defaultsettinginfo', 'admin', get_string('yes')).'</div></div>'; | ||
echo '<div class="form-description">' . get_string('configsendcoursewelcomemessage', 'admin') . '</div>'; | ||
echo '</div>'; | ||
|
||
echo '</fieldset>'; | ||
|
||
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges', 'admin').'" /></div>'; | ||
echo '</div>'; | ||
echo '</form>'; | ||
|
||
echo $OUTPUT->footer(); | ||
if (!$confirm) { | ||
$uurl = new moodle_url('/admin/enrol.php', array('action'=>'uninstall', 'enrol'=>$enrol, 'sesskey'=>sesskey(), 'confirm'=>1)); | ||
echo $OUTPUT->confirm(get_string('uninstallconfirm', 'enrol', $strplugin), $uurl, $return); | ||
echo $OUTPUT->footer(); | ||
exit; | ||
|
||
} else { // Delete everything!! | ||
uninstall_plugin('enrol', $enrol); | ||
|
||
$a->plugin = $strplugin; | ||
$a->directory = "$CFG->dirroot/enrol/$enrol"; | ||
echo $OUTPUT->notification(get_string('uninstalldeletefiles', 'enrol', $a), 'notifysuccess'); | ||
echo $OUTPUT->continue_button($return); | ||
echo $OUTPUT->footer(); | ||
exit; | ||
} | ||
} | ||
|
||
|
||
redirect($return); |
Oops, something went wrong.