require_once($CFG->libdir.'/deprecatedlib.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/componentlib.class.php');
+require_once($CFG->dirroot.'/cache/lib.php');
require($CFG->dirroot.'/version.php');
$CFG->target_release = $release;
--- /dev/null
+<?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/>.
+
+/**
+ * Allows the admin to enable, disable and uninstall course formats
+ *
+ * @package core_admin
+ * @copyright 2012 Marina Glancy
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once('../config.php');
+require_once($CFG->libdir.'/adminlib.php');
+require_once($CFG->libdir.'/pluginlib.php');
+
+$action = required_param('action', PARAM_ALPHANUMEXT);
+$formatname = required_param('format', PARAM_PLUGIN);
+$confirm = optional_param('confirm', 0, PARAM_BOOL);
+
+$syscontext = context_system::instance();
+$PAGE->set_url('/admin/courseformats.php');
+$PAGE->set_context($syscontext);
+
+require_login();
+require_capability('moodle/site:config', $syscontext);
+require_sesskey();
+
+$return = new moodle_url('/admin/settings.php', array('section' => 'manageformats'));
+
+$allplugins = plugin_manager::instance()->get_plugins();
+$formatplugins = $allplugins['format'];
+$sortorder = array_flip(array_keys($formatplugins));
+
+if (!isset($formatplugins[$formatname])) {
+ print_error('courseformatnotfound', 'error', $return, $formatname);
+}
+
+switch ($action) {
+ case 'disable':
+ if ($formatplugins[$formatname]->is_enabled()) {
+ if (get_config('moodlecourse', 'format') === $formatname) {
+ print_error('cannotdisableformat', 'error', $return);
+ }
+ set_config('disabled', 1, 'format_'. $formatname);
+ }
+ break;
+ case 'enable':
+ if (!$formatplugins[$formatname]->is_enabled()) {
+ unset_config('disabled', 'format_'. $formatname);
+ }
+ break;
+ case 'up':
+ if ($sortorder[$formatname]) {
+ $currentindex = $sortorder[$formatname];
+ $seq = array_keys($formatplugins);
+ $seq[$currentindex] = $seq[$currentindex-1];
+ $seq[$currentindex-1] = $formatname;
+ set_config('format_plugins_sortorder', implode(',', $seq));
+ }
+ break;
+ case 'down':
+ if ($sortorder[$formatname] < count($sortorder)-1) {
+ $currentindex = $sortorder[$formatname];
+ $seq = array_keys($formatplugins);
+ $seq[$currentindex] = $seq[$currentindex+1];
+ $seq[$currentindex+1] = $formatname;
+ set_config('format_plugins_sortorder', implode(',', $seq));
+ }
+ break;
+ case 'uninstall':
+ echo $OUTPUT->header();
+ echo $OUTPUT->heading(get_string('courseformats', 'moodle'));
+
+ $coursecount = $DB->count_records('course', array('format' => $formatname));
+ if ($coursecount) {
+ // Check that default format is set. It will be used to convert courses
+ // using this format
+ $defaultformat = get_config('moodlecourse', 'format');
+ $defaultformat = $formatplugins[get_config('moodlecourse', 'format')];
+ if (!$defaultformat) {
+ echo $OUTPUT->error_text(get_string('defaultformatnotset', 'admin'));
+ echo $OUTPUT->footer();
+ exit;
+ }
+ }
+
+ $format = $formatplugins[$formatname];
+ $deleteurl = $format->get_uninstall_url();
+ if (!$deleteurl) {
+ // somebody was trying to cheat and type non-existing link
+ echo $OUTPUT->error_text(get_string('cannotuninstall', 'admin', $format->displayname));
+ echo $OUTPUT->footer();
+ exit;
+ }
+
+ if (!$confirm) {
+ if ($coursecount) {
+ $message = get_string('formatuninstallwithcourses', 'admin',
+ (object)array('count' => $coursecount, 'format' => $format->displayname,
+ 'defaultformat' => $defaultformat->displayname));
+ } else {
+ $message = get_string('formatuninstallconfirm', 'admin', $format->displayname);
+ }
+ $deleteurl->param('confirm', 1);
+ echo $OUTPUT->confirm($message, $deleteurl, $return);
+ } else {
+ $a = new stdClass();
+ $a->plugin = $format->displayname;
+ $a->directory = $format->rootdir;
+ uninstall_plugin('format', $formatname);
+ echo $OUTPUT->notification(get_string('formatuninstalled', 'admin', $a), 'notifysuccess');
+ echo $OUTPUT->continue_button($return);
+ }
+
+ echo $OUTPUT->footer();
+ exit;
+}
+redirect($return);
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/tablelib.php');
+$action = required_param('action', PARAM_ALPHANUMEXT);
+$editor = required_param('editor', PARAM_PLUGIN);
+$confirm = optional_param('confirm', 0, PARAM_BOOL);
+
+$PAGE->set_url('/admin/editors.php', array('action'=>$action, 'editor'=>$editor));
+$PAGE->set_context(context_system::instance());
+
require_login();
require_capability('moodle/site:config', context_system::instance());
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=manageeditors";
-$action = optional_param('action', '', PARAM_ALPHANUMEXT);
-$editor = optional_param('editor', '', PARAM_PLUGIN);
-
// get currently installed and enabled auth plugins
$available_editors = editors_get_available();
if (!empty($editor) and empty($available_editors[$editor])) {
}
}
break;
+
+ case 'uninstall':
+ if ($editor === 'textarea') {
+ redirect($returnurl);
+ }
+ if (get_string_manager()->string_exists('pluginname', 'editor_'.$editor)) {
+ $strplugin = get_string('pluginname', 'editor_'.$editor);
+ } else {
+ $strplugin = $editor;
+ }
+
+ $PAGE->set_title($strplugin);
+ echo $OUTPUT->header();
+
+ if (!$confirm) {
+ echo $OUTPUT->heading(get_string('editors', 'core_editor'));
+
+ $deleteurl = new moodle_url('/admin/editors.php', array('action'=>'uninstall', 'editor'=>$editor, 'sesskey'=>sesskey(), 'confirm'=>1));
+
+ echo $OUTPUT->confirm(get_string('editordeleteconfirm', 'core_editor', $strplugin),
+ $deleteurl, $returnurl);
+ echo $OUTPUT->footer();
+ die();
+
+ } else {
+ // Remove from enabled list.
+ $key = array_search($editor, $active_editors);
+ unset($active_editors[$key]);
+ set_config('texteditors', implode(',', $active_editors));
+
+ // Delete everything!!
+ uninstall_plugin('editor', $editor);
+
+ $a = new stdClass();
+ $a->name = $strplugin;
+ $a->directory = "$CFG->dirroot/lib/editor/$editor";
+ echo $OUTPUT->notification(get_string('plugindeletefiles', '', $a), 'notifysuccess');
+ echo $OUTPUT->continue_button($returnurl);
+ echo $OUTPUT->footer();
+ die();
+ }
+
default:
break;
}
$strplugin = $enrol;
}
- echo $PAGE->set_title($strplugin);
+ $PAGE->set_title($strplugin);
echo $OUTPUT->header();
if (!$confirm) {
}
$output = $PAGE->get_renderer('core', 'admin');
+
+ $deployer = available_update_deployer::instance();
+ if ($deployer->enabled()) {
+ $deployer->initialize($reloadurl, $reloadurl);
+
+ $deploydata = $deployer->submitted_data();
+ if (!empty($deploydata)) {
+ echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
+ die();
+ }
+ }
+
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
$version, $showallplugins, $reloadurl,
new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)));
$output = $PAGE->get_renderer('core', 'admin');
+ $deployer = available_update_deployer::instance();
+ if ($deployer->enabled()) {
+ $deployer->initialize($PAGE->url, $PAGE->url);
+
+ $deploydata = $deployer->submitted_data();
+ if (!empty($deploydata)) {
+ echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
+ die();
+ }
+ }
+
// check plugin dependencies first
$failed = array();
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
$dbproblems = $DB->diagnose();
$maintenancemode = !empty($CFG->maintenance_enabled);
+// Available updates for Moodle core
$updateschecker = available_update_checker::instance();
-$availableupdates = $updateschecker->get_update_info('core',
+$availableupdates = array();
+$availableupdates['core'] = $updateschecker->get_update_info('core',
array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds));
+
+// Available updates for contributed plugins
+$pluginman = plugin_manager::instance();
+foreach ($pluginman->get_plugins() as $plugintype => $plugintypeinstances) {
+ foreach ($plugintypeinstances as $pluginname => $plugininfo) {
+ if (!empty($plugininfo->availableupdates)) {
+ foreach ($plugininfo->availableupdates as $pluginavailableupdate) {
+ if ($pluginavailableupdate->version > $plugininfo->versiondisk) {
+ if (!isset($availableupdates[$plugintype.'_'.$pluginname])) {
+ $availableupdates[$plugintype.'_'.$pluginname] = array();
+ }
+ $availableupdates[$plugintype.'_'.$pluginname][] = $pluginavailableupdate;
+ }
+ }
+ }
+ }
+}
+
+// The timestamp of the most recent check for available updates
$availableupdatesfetch = $updateschecker->get_last_timefetched();
$buggyiconvnomb = (!function_exists('mb_convert_encoding') and @iconv('UTF-8', 'UTF-8//IGNORE', '100'.chr(130).'€') !== '100€');
if ($output) echo $OUTPUT->heading($fullname);
/// retrieve a list of sections beyond what is currently being shown
+ $courseformatoptions = course_get_format($course)->get_format_options();
+ if (!isset($courseformatoptions['numsections'])) {
+ // Course format does not use numsections
+ if ($output) {
+ echo 'No extra sections<br />';
+ }
+ continue;
+ }
$sql = "SELECT *
FROM {course_sections}
WHERE course=? AND section>?
ORDER BY section ASC";
- $params = array($course->id, $course->numsections);
+ $params = array($course->id, $courseformatoptions['numsections']);
if (!($xsections = $DB->get_records_sql($sql, $params))) {
if ($output) echo 'No extra sections<br />';
continue;
/// the journal update erroneously stored it in course_sections->section
$newsection = $xsection->section;
/// double check the new section
- if ($newsection > $course->numsections) {
+ if ($newsection > $courseformatoptions['numsections']) {
/// get the record for section 0 for this course
if (!($zerosection = $DB->get_record('course_sections', array('course'=>$course->id, 'section'=>'0')))) {
continue;
admin_externalpage_setup('pluginsoverview');
$fetchremote = optional_param('fetchremote', false, PARAM_BOOL);
+$updatesonly = optional_param('updatesonly', false, PARAM_BOOL);
+$contribonly = optional_param('contribonly', false, PARAM_BOOL);
$pluginman = plugin_manager::instance();
$checker = available_update_checker::instance();
+// Filtering options.
+$options = array(
+ 'updatesonly' => $updatesonly,
+ 'contribonly' => $contribonly,
+);
+
if ($fetchremote) {
require_sesskey();
$checker->fetch();
- redirect($PAGE->url);
+ redirect(new moodle_url($PAGE->url, $options));
}
$output = $PAGE->get_renderer('core', 'admin');
-echo $output->plugin_management_page($pluginman, $checker);
+
+$deployer = available_update_deployer::instance();
+if ($deployer->enabled()) {
+ $myurl = new moodle_url($PAGE->url, array('updatesonly' => $updatesonly, 'contribonly' => $contribonly));
+ $deployer->initialize($myurl, $myurl);
+
+ $deploydata = $deployer->submitted_data();
+ if (!empty($deploydata)) {
+ echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
+ die();
+ }
+}
+
+echo $output->plugin_management_page($pluginman, $checker, $options);
return $output;
}
+ /**
+ * Prints a page with a summary of plugin deployment to be confirmed.
+ *
+ * @param available_update_deployer $deployer
+ * @param array $data deployer's data package as returned by {@link available_update_deployer::submitted_data()}
+ * @return string
+ */
+ public function upgrade_plugin_confirm_deploy_page(available_update_deployer $deployer, array $data) {
+
+ if (!$deployer->initialized()) {
+ throw new coding_exception('Unable to render a page for non-initialized deployer.');
+ }
+
+ if (empty($data['updateinfo'])) {
+ throw new coding_exception('Missing required data component.');
+ }
+
+ $updateinfo = $data['updateinfo'];
+
+ $output = '';
+ $output .= $this->header();
+ $output .= $this->container_start('generalbox updateplugin', 'notice');
+
+ $a = new stdClass();
+ if (get_string_manager()->string_exists('pluginname', $updateinfo->component)) {
+ $a->name = get_string('pluginname', $updateinfo->component);
+ } else {
+ $a->name = $updateinfo->component;
+ }
+
+ if (isset($updateinfo->release)) {
+ $a->version = $updateinfo->release . ' (' . $updateinfo->version . ')';
+ } else {
+ $a->version = $updateinfo->version;
+ }
+ $a->url = $updateinfo->download;
+
+ $output .= $this->output->heading(get_string('updatepluginconfirm', 'core_plugin'));
+ $output .= $this->output->container(format_text(get_string('updatepluginconfirminfo', 'core_plugin', $a)), 'updatepluginconfirminfo');
+ $output .= $this->output->container(get_string('updatepluginconfirmwarning', 'core_plugin', 'updatepluginconfirmwarning'));
+
+ if ($repotype = $deployer->plugin_external_source($data['updateinfo'])) {
+ $output .= $this->output->container(get_string('updatepluginconfirmexternal', 'core_plugin', $repotype), 'updatepluginconfirmexternal');
+ }
+
+ $widget = $deployer->make_execution_widget($data['updateinfo']);
+ $output .= $this->output->render($widget);
+
+ $output .= $this->output->single_button($data['returnurl'], get_string('cancel', 'core'), 'get');
+
+ $output .= $this->container_end();
+ $output .= $this->footer();
+
+ return $output;
+ }
+
/**
* Display the admin notifications page.
* @param int $maturity
/**
* Display the plugin management page (admin/plugins.php).
*
+ * The filtering options array may contain following items:
+ * bool contribonly - show only contributed extensions
+ * bool updatesonly - show only plugins with an available update
+ *
* @param plugin_manager $pluginman
* @param available_update_checker $checker
+ * @param array $options filtering options
* @return string HTML to output.
*/
- public function plugin_management_page(plugin_manager $pluginman, available_update_checker $checker) {
+ public function plugin_management_page(plugin_manager $pluginman, available_update_checker $checker, array $options = array()) {
global $CFG;
$output = '';
$output .= $this->header();
$output .= $this->heading(get_string('pluginsoverview', 'core_admin'));
- $output .= $this->plugins_overview_panel($pluginman);
+ $output .= $this->plugins_overview_panel($pluginman, $options);
if (empty($CFG->disableupdatenotifications)) {
$output .= $this->container_start('checkforupdates');
- $output .= $this->single_button(new moodle_url($this->page->url, array('fetchremote' => 1)), get_string('checkforupdates', 'core_plugin'));
+ $output .= $this->single_button(
+ new moodle_url($this->page->url, array_merge($options, array('fetchremote' => 1))),
+ get_string('checkforupdates', 'core_plugin')
+ );
if ($timefetched = $checker->get_last_timefetched()) {
$output .= $this->container(get_string('checkforupdateslast', 'core_plugin',
userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'))));
$output .= $this->container_end();
}
- $output .= $this->box($this->plugins_control_panel($pluginman), 'generalbox');
+ $output .= $this->box($this->plugins_control_panel($pluginman, $options), 'generalbox');
$output .= $this->footer();
return $output;
}
/**
- * Displays the info about available Moodle updates
+ * Displays the info about available Moodle core and plugin updates
*
- * @param array|null $updates array of available_update_info objects or null
+ * The structure of the $updates param has changed since 2.4. It contains not only updates
+ * for the core itself, but also for all other installed plugins.
+ *
+ * @param array|null $updates array of (string)component => array of available_update_info objects or null
* @param int|null $fetch timestamp of the most recent updates fetch or null (unknown)
* @return string
*/
protected function available_updates($updates, $fetch) {
$updateinfo = $this->box_start('generalbox adminwarning availableupdatesinfo');
+ $someupdateavailable = false;
if (is_array($updates)) {
- $updateinfo .= $this->heading(get_string('updateavailable', 'core_admin'), 3);
- foreach ($updates as $update) {
- $updateinfo .= $this->moodle_available_update_info($update);
+ if (is_array($updates['core'])) {
+ $someupdateavailable = true;
+ $updateinfo .= $this->heading(get_string('updateavailable', 'core_admin'), 3);
+ foreach ($updates['core'] as $update) {
+ $updateinfo .= $this->moodle_available_update_info($update);
+ }
}
- } else {
+ unset($updates['core']);
+ // If something has left in the $updates array now, it is updates for plugins.
+ if (!empty($updates)) {
+ $someupdateavailable = true;
+ $updateinfo .= $this->heading(get_string('updateavailableforplugin', 'core_admin'), 3);
+ $pluginsoverviewurl = new moodle_url('/admin/plugins.php', array('updatesonly' => 1));
+ $updateinfo .= $this->container(get_string('pluginsoverviewsee', 'core_admin',
+ array('url' => $pluginsoverviewurl->out())));
+ }
+ }
+
+ if (!$someupdateavailable) {
$now = time();
if ($fetch and ($fetch <= $now) and ($now - $fetch < HOURSECS)) {
$updateinfo .= $this->heading(get_string('updateavailablenot', 'core_admin'), 3);
* Prints an overview about the plugins - number of installed, number of extensions etc.
*
* @param plugin_manager $pluginman provides information about the plugins
+ * @param array $options filtering options
* @return string as usually
*/
- public function plugins_overview_panel(plugin_manager $pluginman) {
+ public function plugins_overview_panel(plugin_manager $pluginman, array $options = array()) {
global $CFG;
$plugininfo = $pluginman->get_plugins();
}
$info = array();
+ $filter = array();
+ $somefilteractive = false;
$info[] = html_writer::tag('span', get_string('numtotal', 'core_plugin', $numtotal), array('class' => 'info total'));
$info[] = html_writer::tag('span', get_string('numdisabled', 'core_plugin', $numdisabled), array('class' => 'info disabled'));
$info[] = html_writer::tag('span', get_string('numextension', 'core_plugin', $numextension), array('class' => 'info extension'));
+ if ($numextension > 0) {
+ if (empty($options['contribonly'])) {
+ $filter[] = html_writer::link(
+ new moodle_url($this->page->url, array('contribonly' => 1)),
+ get_string('filtercontribonly', 'core_plugin'),
+ array('class' => 'filter-item show-contribonly')
+ );
+ } else {
+ $filter[] = html_writer::tag('span', get_string('filtercontribonlyactive', 'core_plugin'),
+ array('class' => 'filter-item active show-contribonly'));
+ $somefilteractive = true;
+ }
+ }
if ($numupdatable > 0) {
$info[] = html_writer::tag('span', get_string('numupdatable', 'core_plugin', $numupdatable), array('class' => 'info updatable'));
+ if (empty($options['updatesonly'])) {
+ $filter[] = html_writer::link(
+ new moodle_url($this->page->url, array('updatesonly' => 1)),
+ get_string('filterupdatesonly', 'core_plugin'),
+ array('class' => 'filter-item show-updatesonly')
+ );
+ } else {
+ $filter[] = html_writer::tag('span', get_string('filterupdatesonlyactive', 'core_plugin'),
+ array('class' => 'filter-item active show-updatesonly'));
+ $somefilteractive = true;
+ }
+ }
+ if ($somefilteractive) {
+ $filter[] = html_writer::link($this->page->url, get_string('filterall', 'core_plugin'), array('class' => 'filter-item show-all'));
}
- return $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '', 'plugins-overview-panel');
+ $output = $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '', 'plugins-overview-panel');
+
+ if (!empty($filter)) {
+ $output .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $filter), '', 'plugins-overview-filter');
+ }
+
+ return $output;
}
/**
* This default implementation renders all plugins into one big table.
*
* @param plugin_manager $pluginman provides information about the plugins.
+ * @param array $options filtering options
* @return string HTML code
*/
- public function plugins_control_panel(plugin_manager $pluginman) {
+ public function plugins_control_panel(plugin_manager $pluginman, array $options = array()) {
global $CFG;
$plugininfo = $pluginman->get_plugins();
+ // Filter the list of plugins according the options.
+ if (!empty($options['updatesonly'])) {
+ $updateable = array();
+ foreach ($plugininfo as $plugintype => $pluginnames) {
+ foreach ($pluginnames as $pluginname => $pluginfo) {
+ if (!empty($pluginfo->availableupdates)) {
+ foreach ($pluginfo->availableupdates as $pluginavailableupdate) {
+ if ($pluginavailableupdate->version > $pluginfo->versiondisk) {
+ $updateable[$plugintype][$pluginname] = $pluginfo;
+ }
+ }
+ }
+ }
+ }
+ $plugininfo = $updateable;
+ }
+
+ if (!empty($options['contribonly'])) {
+ $contribs = array();
+ foreach ($plugininfo as $plugintype => $pluginnames) {
+ foreach ($pluginnames as $pluginname => $pluginfo) {
+ if (!$pluginfo->is_standard()) {
+ $contribs[$plugintype][$pluginname] = $pluginfo;
+ }
+ }
+ }
+ $plugininfo = $contribs;
+ }
+
if (empty($plugininfo)) {
return '';
}
$availability = new html_table_cell('');
} else if ($isenabled) {
$row->attributes['class'] .= ' enabled';
- $icon = $this->output->pix_icon('i/hide', get_string('pluginenabled', 'core_plugin'));
- $availability = new html_table_cell($icon . ' ' . get_string('pluginenabled', 'core_plugin'));
+ $availability = new html_table_cell(get_string('pluginenabled', 'core_plugin'));
} else {
$row->attributes['class'] .= ' disabled';
- $icon = $this->output->pix_icon('i/show', get_string('plugindisabled', 'core_plugin'));
- $availability = new html_table_cell($icon . ' ' . get_string('plugindisabled', 'core_plugin'));
+ $availability = new html_table_cell(get_string('plugindisabled', 'core_plugin'));
}
$actions = array();
$box = $this->output->box_start($boxclasses);
$box .= html_writer::tag('div', get_string('updateavailable', 'core_plugin', $updateinfo->version), array('class' => 'version'));
$box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
+
+ $deployer = available_update_deployer::instance();
+ if ($deployer->initialized()) {
+ $impediments = $deployer->deployment_impediments($updateinfo);
+ if (empty($impediments)) {
+ $widget = $deployer->make_confirm_widget($updateinfo);
+ $box .= $this->output->render($widget);
+ } else if (isset($impediments['notwritable'])) {
+ $box .= $this->output->help_icon('notwritable', 'core_plugin', get_string('notwritable', 'core_plugin'));
+ }
+ }
+
$box .= $this->output->box_end();
return $box;
$contextname = print_context_name($context);
// Get the user_selector we will need.
-// Teachers within a course just get to see the same list of people they can
-// assign roles to. Admins (people with moodle/role:manage) can run this report for any user.
-$options = array('context' => $context, 'roleid' => 0);
-if (has_capability('moodle/role:manage', $context)) {
- $userselector = new potential_assignees_course_and_above('reportuser', $options);
-} else {
- $userselector = roles_get_potential_user_selector($context, 'reportuser', $options);
-}
-$userselector->set_multiselect(false);
-$userselector->set_rows(10);
+// Teachers within a course just get to see the same list of enrolled users.
+// Admins (people with moodle/role:manage) can run this report for any user.
+$options = array('accesscontext' => $context);
+$userselector = new role_check_users_selector('reportuser', $options);
+$userselector->set_rows(20);
// Work out an appropriate page title.
$title = get_string('checkpermissionsin', 'role', $contextname);
}
}
+/**
+ * User selector subclass for the selection of users in the check permissions page.
+ *
+ * @copyright 2012 Petr Skoda {@link http://skodak.org}
+ */
+class role_check_users_selector extends user_selector_base {
+ const MAX_ENROLLED_PER_PAGE = 100;
+ const MAX_POTENTIAL_PER_PAGE = 100;
+
+ /** @var bool limit listing of users to enrolled only */
+ var $onlyenrolled;
+
+ /**
+ * Constructor.
+ *
+ * @param string $name the control name/id for use in the HTML.
+ * @param array $options other options needed to construct this selector.
+ * You must be able to clone a userselector by doing new get_class($us)($us->get_name(), $us->get_options());
+ */
+ public function __construct($name, $options) {
+ if (!isset($options['multiselect'])) {
+ $options['multiselect'] = false;
+ }
+ parent::__construct($name, $options);
+
+ $coursecontext = $this->accesscontext->get_course_context(false);
+ if ($coursecontext and $coursecontext->id != SITEID and !has_capability('moodle/role:manage', $coursecontext)) {
+ // Prevent normal teachers from looking up all users.
+ $this->onlyenrolled = true;
+ } else {
+ $this->onlyenrolled = false;
+ }
+ }
+
+ public function find_users($search) {
+ global $DB;
+
+ list($wherecondition, $params) = $this->search_sql($search, 'u');
+
+ $fields = 'SELECT ' . $this->required_fields_sql('u');
+ $countfields = 'SELECT COUNT(1)';
+
+ $coursecontext = $this->accesscontext->get_course_context(false);
+
+ if ($coursecontext and $coursecontext != SITEID) {
+ $sql1 = " FROM {user} u
+ JOIN {user_enrolments} ue ON (ue.userid = u.id)
+ JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid1)
+ WHERE $wherecondition";
+ $params['courseid1'] = $coursecontext->instanceid;
+
+ if ($this->onlyenrolled) {
+ $sql2 = null;
+ } else {
+ $sql2 = " FROM {user} u
+ LEFT JOIN ({user_enrolments} ue
+ JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid2)) ON (ue.userid = u.id)
+ WHERE $wherecondition
+ AND ue.id IS NULL";
+ $params['courseid2'] = $coursecontext->instanceid;
+ }
+
+ } else {
+ if ($this->onlyenrolled) {
+ // Bad luck, current user may not view only enrolled users.
+ return array();
+ }
+ $sql1 = null;
+ $sql2 = " FROM {user} u
+ WHERE $wherecondition";
+ }
+
+ $params['contextid'] = $this->accesscontext->id;
+
+ list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
+ $order = ' ORDER BY ' . $sort;
+
+ $result = array();
+
+ if ($search) {
+ $groupname1 = get_string('enrolledusersmatching', 'enrol', $search);
+ $groupname2 = get_string('potusersmatching', 'role', $search);
+ } else {
+ $groupname1 = get_string('enrolledusers', 'enrol');
+ $groupname2 = get_string('potusers', 'role');
+ }
+
+ if ($sql1) {
+ $enrolleduserscount = $DB->count_records_sql($countfields . $sql1, $params);
+ if (!$this->is_validating() and $enrolleduserscount > $this::MAX_ENROLLED_PER_PAGE) {
+ $result[$groupname1] = array();
+ $toomany = $this->too_many_results($search, $enrolleduserscount);
+ $result[implode(' - ', array_keys($toomany))] = array();
+
+ } else {
+ $enrolledusers = $DB->get_records_sql($fields . $sql1 . $order, array_merge($params, $sortparams));
+ if ($enrolledusers) {
+ $result[$groupname1] = $enrolledusers;
+ }
+ }
+ if ($sql2) {
+ $result[''] = array();
+ }
+ }
+ if ($sql2) {
+ $otheruserscount = $DB->count_records_sql($countfields . $sql2, $params);
+ if (!$this->is_validating() and $otheruserscount > $this::MAX_POTENTIAL_PER_PAGE) {
+ $result[$groupname2] = array();
+ $toomany = $this->too_many_results($search, $otheruserscount);
+ $result[implode(' - ', array_keys($toomany))] = array();
+ } else {
+ $otherusers = $DB->get_records_sql($fields . $sql2 . $order, array_merge($params, $sortparams));
+ if ($otherusers) {
+ $result[$groupname2] = $otherusers;
+ }
+ }
+ }
+
+ return $result;
+ }
+
+ protected function get_options() {
+ global $CFG;
+ $options = parent::get_options();
+ $options['file'] = $CFG->admin . '/roles/lib.php';
+ return $options;
+ }
+}
+
/**
* User selector subclass for the list of potential users on the assign roles page,
* when we are assigning in a context at or above the course level. In this case we
/// NOTE: these settings must be applied after all other settings because they depend on them
///main course settings
$temp = new admin_settingpage('coursesettings', new lang_string('coursesettings'));
- $courseformats = get_plugin_list('format');
+ require_once($CFG->dirroot.'/course/lib.php');
+ $courseformats = get_sorted_course_formats(true);
$formcourseformats = array();
- foreach ($courseformats as $courseformat => $courseformatdir) {
+ foreach ($courseformats as $courseformat) {
$formcourseformats[$courseformat] = new lang_string('pluginname', "format_$courseformat");
}
$temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'), 'weeks',$formcourseformats));
// hidden script for converting journals to online assignments (or something like that) linked from elsewhere
$ADMIN->add('modsettings', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true));
+ // course formats
+ $ADMIN->add('modules', new admin_category('formatsettings', new lang_string('courseformats')));
+ $temp = new admin_settingpage('manageformats', new lang_string('manageformats', 'core_admin'));
+ $temp->add(new admin_setting_manageformats());
+ $ADMIN->add('formatsettings', $temp);
+ foreach ($allplugins['format'] as $format) {
+ $format->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
+ }
+
// blocks
$ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
$ADMIN->add('blocksettings', new admin_page_manageblocks());
/// Web services
$ADMIN->add('modules', new admin_category('webservicesettings', new lang_string('webservices', 'webservice')));
+ // Mobile
+ $temp = new admin_settingpage('mobile', new lang_string('mobile','admin'), 'moodle/site:config', false);
+ $enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
+ $enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
+ $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice',
+ new lang_string('enablemobilewebservice', 'admin'),
+ new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
+ $temp->add(new admin_setting_configtext('mobilecssurl', new lang_string('mobilecssurl', 'admin'), new lang_string('configmobilecssurl','admin'), '', PARAM_URL));
+ $ADMIN->add('webservicesettings', $temp);
/// overview page
$temp = new admin_settingpage('webservicesoverview', new lang_string('webservicesoverview', 'webservice'));
$temp->add(new admin_setting_webservicesoverview());
$ADMIN->add('webservicesettings', new admin_externalpage('webservicedocumentation', new lang_string('wsdocapi', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/documentation.php", 'moodle/site:config', false));
/// manage service
$temp = new admin_settingpage('externalservices', new lang_string('externalservices', 'webservice'));
- $enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
- $enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
- $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice', new lang_string('enablemobilewebservice', 'admin'), new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
+ $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice',
+ new lang_string('enablemobilewebservice', 'admin'),
+ new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
$temp->add(new admin_setting_heading('manageserviceshelpexplaination', new lang_string('information', 'webservice'), new lang_string('servicehelpexplanation', 'webservice')));
$temp->add(new admin_setting_manageexternalservices());
$ADMIN->add('webservicesettings', $temp);
// Question type settings
if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
+ if (!$hassiteconfig) {
+ require_once("$CFG->libdir/pluginlib.php");
+ $allplugins = plugin_manager::instance()->get_plugins();
+ }
// Question behaviour settings.
$ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
$ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours());
$temp = new admin_settingpage('updatenotifications', new lang_string('updatenotifications', 'core_admin'));
$temp->add(new admin_setting_configcheckbox('updateautocheck', new lang_string('updateautocheck', 'core_admin'),
new lang_string('updateautocheck_desc', 'core_admin'), 1));
+ if (empty($CFG->disableupdateautodeploy)) {
+ $temp->add(new admin_setting_configcheckbox('updateautodeploy', new lang_string('updateautodeploy', 'core_admin'),
+ new lang_string('updateautodeploy_desc', 'core_admin'), 0));
+ }
$temp->add(new admin_setting_configselect('updateminmaturity', new lang_string('updateminmaturity', 'core_admin'),
new lang_string('updateminmaturity_desc', 'core_admin'), MATURITY_STABLE,
array(
/**
* @author Martin Dougiamas
* @author Jerome GUTIERREZ
- * @author I�aki Arenaza
+ * @author Iñaki Arenaza
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package moodle multiauth
*
}
}
+ if (!ldap_paged_results_supported($this->config->ldap_version)) {
+ echo $OUTPUT->notification(get_string('pagedresultsnotsupp', 'auth_ldap'));
+ }
+
include($CFG->dirroot.'/auth/cas/config.html');
}
if (empty($config->ldapencoding)) {
$config->ldapencoding = 'utf-8';
}
+ if (!isset($config->pagesize)) {
+ $config->pagesize = LDAP_DEFAULT_PAGESIZE;
+ }
if (!isset($config->contexts)) {
$config->contexts = '';
}
// save LDAP settings
set_config('host_url', trim($config->host_url), $this->pluginconfig);
set_config('ldapencoding', trim($config->ldapencoding), $this->pluginconfig);
+ set_config('pagesize', (int)trim($config->pagesize), $this->pluginconfig);
set_config('contexts', trim($config->contexts), $this->pluginconfig);
set_config('user_type', textlib::strtolower(trim($config->user_type)), $this->pluginconfig);
set_config('user_attribute', textlib::strtolower(trim($config->user_attribute)), $this->pluginconfig);
if (empty($config->ldapencoding)) {
$config->ldapencoding = 'utf-8';
}
+if (!isset($config->pagesize)) {
+ $config->pagesize = LDAP_DEFAULT_PAGESIZE;
+}
if (!isset($config->contexts)) {
$config->contexts = '';
}
<?php print_string('auth_ldap_ldap_encoding', 'auth_ldap') ?>
</td>
</tr>
+<tr valign="top">
+ <td align="right">
+ <label for="pagesize"><?php print_string('pagesize_key', 'auth_ldap') ?></label>
+ </td>
+ <td>
+ <?php $disabled = (!ldap_paged_results_supported($config->ldap_version)) ? ' disabled="disabled"' : '' ; ?>
+ <input id="pagesize" name="pagesize" type="text" value="<?php echo $config->pagesize ?>" <?php echo $disabled ?>/>
+ <?php
+ if (isset($err['pagesize'])) { echo $OUTPUT->error_text($err['pagesize']); }
+ if ($disabled) {
+ // Don't loose the page size value (disabled fields are not submitted!)
+ ?>
+ <input id="pagesize" name="pagesize" type="hidden" value="<?php echo $config->pagesize ?>" />
+ <?php } ?>
+ </td>
+ <td>
+ <?php print_string('pagesize', 'auth_ldap') ?>
+ </td>
+</tr>
<tr>
<td colspan="2">
<h4><?php print_string('auth_ldap_bind_settings', 'auth_ldap') ?></h4>
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2012061700; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version = 2012110700; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2012061700; // Requires this Moodle version
$plugin->component = 'auth_cas'; // Full name of the plugin (used for diagnostics)
/**
* @author Martin Dougiamas
- * @author I�aki Arenaza
+ * @author Iñaki Arenaza
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package moodle multiauth
*
$ldapconnection = $this->ldap_connect();
if(!($user_dn = $this->ldap_find_userdn($ldapconnection, $extusername))) {
+ $this->ldap_close();
return false;
}
}
if (!$user_info_result = ldap_read($ldapconnection, $user_dn, '(objectClass=*)', $search_attribs)) {
+ $this->ldap_close();
return false; // error!
}
$user_entry = ldap_get_entries_moodle($ldapconnection, $user_info_result);
if (empty($user_entry)) {
+ $this->ldap_close();
return false; // entry not found
}
$contexts = explode(';', $this->config->contexts);
if (!empty($this->config->create_context)) {
- array_push($contexts, $this->config->create_context);
+ array_push($contexts, $this->config->create_context);
}
- $fresult = array();
+ $ldap_pagedresults = ldap_paged_results_supported($this->config->ldap_version);
+ $ldap_cookie = '';
foreach ($contexts as $context) {
$context = trim($context);
if (empty($context)) {
continue;
}
- if ($this->config->search_sub) {
- //use ldap_search to find first user from subtree
- $ldap_result = ldap_search($ldapconnection, $context,
- $filter,
- array($this->config->user_attribute));
- } else {
- //search only in this context
- $ldap_result = ldap_list($ldapconnection, $context,
- $filter,
- array($this->config->user_attribute));
- }
- if(!$ldap_result) {
- continue;
- }
+ do {
+ if ($ldap_pagedresults) {
+ ldap_control_paged_result($ldapconnection, $this->config->pagesize, true, $ldap_cookie);
+ }
+ if ($this->config->search_sub) {
+ // Use ldap_search to find first user from subtree.
+ $ldap_result = ldap_search($ldapconnection, $context, $filter, array($this->config->user_attribute));
+ } else {
+ // Search only in this context.
+ $ldap_result = ldap_list($ldapconnection, $context, $filter, array($this->config->user_attribute));
+ }
+ if(!$ldap_result) {
+ continue;
+ }
+ if ($ldap_pagedresults) {
+ ldap_control_paged_result_response($ldapconnection, $ldap_result, $ldap_cookie);
+ }
+ if ($entry = @ldap_first_entry($ldapconnection, $ldap_result)) {
+ do {
+ $value = ldap_get_values_len($ldapconnection, $entry, $this->config->user_attribute);
+ $value = textlib::convert($value[0], $this->config->ldapencoding, 'utf-8');
+ $this->ldap_bulk_insert($value);
+ } while ($entry = ldap_next_entry($ldapconnection, $entry));
+ }
+ unset($ldap_result); // Free mem.
+ } while ($ldap_pagedresults && !empty($ldap_cookie));
+ }
- if ($entry = @ldap_first_entry($ldapconnection, $ldap_result)) {
- do {
- $value = ldap_get_values_len($ldapconnection, $entry, $this->config->user_attribute);
- $value = textlib::convert($value[0], $this->config->ldapencoding, 'utf-8');
- $this->ldap_bulk_insert($value);
- } while ($entry = ldap_next_entry($ldapconnection, $entry));
- }
- unset($ldap_result); // free mem
+ // If LDAP paged results were used, the current connection must be completely
+ // closed and a new one created, to work without paged results from here on.
+ if ($ldap_pagedresults) {
+ $this->ldap_close(true);
+ $ldapconnection = $this->ldap_connect();
}
/// preserve our user database
$contexts = explode(';', $this->config->contexts);
if (!empty($this->config->create_context)) {
- array_push($contexts, $this->config->create_context);
+ array_push($contexts, $this->config->create_context);
}
+ $ldap_pagedresults = ldap_paged_results_supported($this->config->ldap_version);
foreach ($contexts as $context) {
$context = trim($context);
if (empty($context)) {
continue;
}
- if ($this->config->search_sub) {
- // Use ldap_search to find first user from subtree
- $ldap_result = ldap_search($ldapconnection, $context,
- $filter,
- array($this->config->user_attribute));
- } else {
- // Search only in this context
- $ldap_result = ldap_list($ldapconnection, $context,
- $filter,
- array($this->config->user_attribute));
- }
-
- if(!$ldap_result) {
- continue;
- }
-
- $users = ldap_get_entries_moodle($ldapconnection, $ldap_result);
-
- // Add found users to list
- for ($i = 0; $i < count($users); $i++) {
- $extuser = textlib::convert($users[$i][$this->config->user_attribute][0],
- $this->config->ldapencoding, 'utf-8');
- array_push($fresult, $extuser);
- }
+ do {
+ if ($ldap_pagedresults) {
+ ldap_control_paged_result($ldapconnection, $this->config->pagesize, true, $ldap_cookie);
+ }
+ if ($this->config->search_sub) {
+ // Use ldap_search to find first user from subtree.
+ $ldap_result = ldap_search($ldapconnection, $context, $filter, array($this->config->user_attribute));
+ } else {
+ // Search only in this context.
+ $ldap_result = ldap_list($ldapconnection, $context, $filter, array($this->config->user_attribute));
+ }
+ if(!$ldap_result) {
+ continue;
+ }
+ if ($ldap_pagedresults) {
+ ldap_control_paged_result_response($ldapconnection, $ldap_result, $ldap_cookie);
+ }
+ $users = ldap_get_entries_moodle($ldapconnection, $ldap_result);
+ // Add found users to list.
+ for ($i = 0; $i < count($users); $i++) {
+ $extuser = textlib::convert($users[$i][$this->config->user_attribute][0],
+ $this->config->ldapencoding, 'utf-8');
+ array_push($fresult, $extuser);
+ }
+ unset($ldap_result); // Free mem.
+ } while ($ldap_pagedresults && !empty($ldap_cookie));
}
- $this->ldap_close();
+ // If paged results were used, make sure the current connection is completely closed
+ $this->ldap_close($ldap_pagedresults);
return $fresult;
}
return;
}
+ if (!ldap_paged_results_supported($this->config->ldap_version)) {
+ echo $OUTPUT->notification(get_string('pagedresultsnotsupp', 'auth_ldap'));
+ }
+
include($CFG->dirroot.'/auth/ldap/config.html');
}
if (empty($config->ldapencoding)) {
$config->ldapencoding = 'utf-8';
}
+ if (!isset($config->pagesize)) {
+ $config->pagesize = LDAP_DEFAULT_PAGESIZE;
+ }
if (!isset($config->contexts)) {
$config->contexts = '';
}
// Save settings
set_config('host_url', trim($config->host_url), $this->pluginconfig);
set_config('ldapencoding', trim($config->ldapencoding), $this->pluginconfig);
+ set_config('pagesize', (int)trim($config->pagesize), $this->pluginconfig);
set_config('contexts', $config->contexts, $this->pluginconfig);
set_config('user_type', textlib::strtolower(trim($config->user_type)), $this->pluginconfig);
set_config('user_attribute', textlib::strtolower(trim($config->user_attribute)), $this->pluginconfig);
/**
* Disconnects from a LDAP server
*
+ * @param force boolean Forces closing the real connection to the LDAP server, ignoring any
+ * cached connections. This is needed when we've used paged results
+ * and want to use normal results again.
*/
- function ldap_close() {
+ function ldap_close($force=false) {
$this->ldapconns--;
- if($this->ldapconns == 0) {
+ if (($this->ldapconns == 0) || ($force)) {
+ $this->ldapconns = 0;
@ldap_close($this->ldapconnection);
unset($this->ldapconnection);
}
if (empty($config->ldapencoding)) {
$config->ldapencoding = 'utf-8';
}
+if (!isset($config->pagesize)) {
+ $config->pagesize = LDAP_DEFAULT_PAGESIZE;
+}
if (!isset($config->contexts)) {
$config->contexts = '';
}
<?php print_string('auth_ldap_ldap_encoding', 'auth_ldap') ?>
</td>
</tr>
+<tr valign="top">
+ <td align="right">
+ <label for="pagesize"><?php print_string('pagesize_key', 'auth_ldap') ?></label>
+ </td>
+ <td>
+ <?php $disabled = (!ldap_paged_results_supported($config->ldap_version)) ? ' disabled="disabled"' : '' ; ?>
+ <input id="pagesize" name="pagesize" type="text" value="<?php echo $config->pagesize ?>" <?php echo $disabled ?>/>
+ <?php
+ if (isset($err['pagesize'])) { echo $OUTPUT->error_text($err['pagesize']); }
+ if ($disabled) {
+ // Don't loose the page size value (disabled fields are not submitted!)
+ ?>
+ <input id="pagesize" name="pagesize" type="hidden" value="<?php echo $config->pagesize ?>" />
+ <?php } ?>
+
+ </td>
+ <td>
+ <?php print_string('pagesize', 'auth_ldap') ?>
+ </td>
+</tr>
<tr>
<td colspan="2">
<h4><?php print_string('auth_ldap_bind_settings', 'auth_ldap') ?></h4>
$string['ntlmsso_failed'] = 'Auto-login failed, try the normal login page...';
$string['ntlmsso_isdisabled'] = 'NTLM SSO is disabled.';
$string['ntlmsso_unknowntype'] = 'Unknown ntlmsso type!';
+$string['pagedresultsnotsupp'] = 'LDAP paged results not supported (either your PHP version lacks support or you have configured Moodle to use LDAP protocol version 2)';
+$string['pagesize'] = 'Make sure this value is smaller than your LDAP server result set size limit (the maximum number of entries that can be returned in a single query)';
+$string['pagesize_key'] = 'Page Size';
$string['pluginname'] = 'LDAP server';
$string['pluginnotenabled'] = 'Plugin not enabled!';
$string['renamingnotallowed'] = 'User renaming not allowed in LDAP';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2012061700; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version = 2012110700; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2012061700; // Requires this Moodle version
$plugin->component = 'auth_ldap'; // Full name of the plugin (used for diagnostics)
$extra = $DB->get_records_sql($sql);
$keys = array_keys($courses);
- $defaultrole = reset(get_archetype_roles('student'));
- //$defaultrole = get_default_course_role($ccache[$shortname]); //TODO: rewrite this completely, there is no default course role any more!!!
- foreach ($keys AS $id) {
- if ($courses[$id]->visible == 0) {
- unset($courses[$id]);
- continue;
+ $studentroles = get_archetype_roles('student');
+ if (!empty($studentroles)) {
+ $defaultrole = reset($studentroles);
+ //$defaultrole = get_default_course_role($ccache[$shortname]); //TODO: rewrite this completely, there is no default course role any more!!!
+ foreach ($keys AS $id) {
+ if ($courses[$id]->visible == 0) {
+ unset($courses[$id]);
+ continue;
+ }
+ $courses[$id]->cat_id = $courses[$id]->category;
+ $courses[$id]->defaultroleid = $defaultrole->id;
+ unset($courses[$id]->category);
+ unset($courses[$id]->visible);
+
+ $courses[$id]->cat_name = $extra[$id]->cat_name;
+ $courses[$id]->cat_description = $extra[$id]->cat_description;
+ $courses[$id]->defaultrolename = $defaultrole->name;
+ // coerce to array
+ $courses[$id] = (array)$courses[$id];
}
- $courses[$id]->cat_id = $courses[$id]->category;
- $courses[$id]->defaultroleid = $defaultrole->id;
- unset($courses[$id]->category);
- unset($courses[$id]->visible);
-
- $courses[$id]->cat_name = $extra[$id]->cat_name;
- $courses[$id]->cat_description = $extra[$id]->cat_description;
- $courses[$id]->defaultrolename = $defaultrole->name;
- // coerce to array
- $courses[$id] = (array)$courses[$id];
+ } else {
+ throw new moodle_exception('unknownrole', 'error', '', 'student');
}
} else {
// if the array is empty, send it anyway
// Check whether Shibboleth is configured properly
if (empty($pluginconfig->user_attribute)) {
- print_error('shib_not_set_up_error', 'auth');
+ print_error('shib_not_set_up_error', 'auth_shibboleth');
}
/// If we can find the Shibboleth attribute, save it in session and return to main login page
// If we can find any (user independent) Shibboleth attributes but no user
// attributes we probably didn't receive any user attributes
elseif (!empty($_SERVER['HTTP_SHIB_APPLICATION_ID']) || !empty($_SERVER['Shib-Application-ID'])) {
- print_error('shib_no_attributes_error', 'auth' , '', '\''.$pluginconfig->user_attribute.'\', \''.$pluginconfig->field_map_firstname.'\', \''.$pluginconfig->field_map_lastname.'\' and \''.$pluginconfig->field_map_email.'\'');
+ print_error('shib_no_attributes_erro