exit;
} else {
- // Inform block it's about to be deleted
- if (file_exists("$CFG->dirroot/blocks/$block->name/block_$block->name.php")) {
- $blockobject = block_instance($block->name);
- if ($blockobject) {
- $blockobject->before_delete(); //only if we can create instance, block might have been already removed
- }
- }
-
- // First delete instances and then block
- $instances = $DB->get_records('block_instances', array('blockname' => $block->name));
- if(!empty($instances)) {
- foreach($instances as $instance) {
- blocks_delete_instance($instance);
- }
- }
-
- // Delete block
- $DB->delete_records('block', array('id'=>$block->id));
-
- drop_plugin_tables($block->name, "$CFG->dirroot/blocks/$block->name/db/install.xml", false); // old obsoleted table names
- drop_plugin_tables('block_'.$block->name, "$CFG->dirroot/blocks/$block->name/db/install.xml", false);
-
- // Delete the capabilities that were defined by this block
- capabilities_cleanup('block/'.$block->name);
-
- // Remove event handlers and dequeue pending events
- events_uninstall('block/'.$block->name);
+ uninstall_plugin('block', $block->name);
$a->block = $strblockname;
$a->directory = $CFG->dirroot.'/blocks/'.$block->name;
$CFG->libdir = "$CFG->dirroot/lib";
$CFG->wwwroot = "http://localhost";
$CFG->httpswwwroot = $CFG->wwwroot;
-$CFG->dataroot = str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata');
-$CFG->tempdir = $CFG->dataroot.'/temp';
-$CFG->cachedir = $CFG->dataroot.'/temp';
$CFG->docroot = 'http://docs.moodle.org';
$CFG->running_installer = true;
$CFG->early_install_lang = true;
'chmod' => '2777',
'lang' => $CFG->lang,
'wwwroot' => '',
- 'dataroot' => $CFG->dataroot,
+ 'dataroot' => str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata'),
'dbtype' => $defaultdb,
'dbhost' => 'localhost',
'dbname' => 'moodle',
$chmod = octdec(clean_param($options['chmod'], PARAM_INT));
if ($interactive) {
cli_separator();
- cli_heading('Data directories permission'); // todo localize
+ cli_heading(get_string('datarootpermission', 'install'));
$prompt = get_string('clitypevaluedefault', 'admin', decoct($chmod));
$error = '';
do {
//We need dataroot before lang download
-if (!empty($options['dataroot'])) {
- $CFG->dataroot = $options['dataroot'];
+$dataroot = clean_param($options['dataroot'], PARAM_PATH);
+if ($dataroot !== $options['dataroot']) {
+ $a = (object)array('option' => 'dataroot', 'value' => $options['dataroot']);
+ cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
}
+$CFG->dataroot = $dataroot;
if ($interactive) {
cli_separator();
$i=0;
cli_error(get_string('pathserrcreatedataroot', 'install', $a));
}
}
+$CFG->tempdir = $CFG->dataroot.'/temp';
+$CFG->cachedir = $CFG->dataroot.'/cache';
// download required lang packs
if ($CFG->lang !== 'en') {
--- /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/>.
+
+/**
+ * @package core
+ * @subpackage cli
+ * @copyright 2011 David Mudrak <david@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+define('CLI_SCRIPT', true);
+
+require(dirname(dirname(dirname(__FILE__))).'/config.php');
+require_once($CFG->libdir.'/clilib.php');
+
+list($options, $unrecognized) = cli_get_params(array('help' => false), array('h' => 'help'));
+
+if ($unrecognized) {
+ $unrecognized = implode("\n ", $unrecognized);
+ cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2);
+}
+
+if ($options['help']) {
+ $help =
+"Invalidates all Moodle internal caches
+
+Options:
+-h, --help Print out this help
+
+Example:
+\$sudo -u www-data /usr/bin/php admin/cli/purge_caches.php
+";
+
+ echo $help;
+ exit(0);
+}
+
+purge_all_caches();
+
+exit(0);
\ No newline at end of file
'admin-*' => get_string('page-admin-x', 'pagetype'),
$pagetype => get_string('page-admin-current', 'pagetype')
);
+ // Add the missing * (any page) option for them. MDL-30340
+ // TODO: These pages are really 'pagetype-varying' - MDL-30564 -
+ // and some day we should stop behaving that way, so proper pagetypes
+ // can be specified for it (like course-category-* or so).
+ // Luckly... the option we are introducing '*' is independent
+ // of that varying behavior, so will work.
+ if ($pagetype == 'admin-course-category') {
+ $array += array(
+ '*' => get_string('page-x', 'pagetype')
+ );
+ }
return $array;
-}
\ No newline at end of file
+}
6 => get_string('saturday', 'calendar')
)));
$temp->add(new admin_setting_special_calendar_weekend());
- $temp->add(new admin_setting_configtext('calendar_lookahead',get_string('configlookahead','admin'),get_string('helpupcominglookahead', 'admin'),21,PARAM_INT));
- $temp->add(new admin_setting_configtext('calendar_maxevents',get_string('configmaxevents','admin'),get_string('helpupcomingmaxevents', 'admin'),10,PARAM_INT));
+ $options = array();
+ for ($i=1; $i<=99; $i++) {
+ $options[$i] = $i;
+ }
+ $temp->add(new admin_setting_configselect('calendar_lookahead',get_string('configlookahead','admin'),get_string('helpupcominglookahead', 'admin'),21,$options));
+ $options = array();
+ for ($i=1; $i<=20; $i++) {
+ $options[$i] = $i;
+ }
+ $temp->add(new admin_setting_configselect('calendar_maxevents',get_string('configmaxevents','admin'),get_string('helpupcomingmaxevents', 'admin'),10,$options));
$temp->add(new admin_setting_configcheckbox('enablecalendarexport', get_string('enablecalendarexport', 'admin'), get_string('configenablecalendarexport','admin'), 1));
$temp->add(new admin_setting_configtext('calendar_exportsalt', get_string('calendarexportsalt','admin'), get_string('configcalendarexportsalt', 'admin'), random_string(60)));
$ADMIN->add('appearance', $temp);
$defaultuserid = 0;
}
+ $restorersnewrole = $creatornewroles;
+ $restorersnewrole[0] = get_string('none');
+
$temp->add(new admin_setting_configselect('notloggedinroleid', get_string('notloggedinroleid', 'admin'),
get_string('confignotloggedinroleid', 'admin'), $defaultguestid, ($guestroles + $otherroles)));
$temp->add(new admin_setting_configselect('guestroleid', get_string('guestroleid', 'admin'),
get_string('configdefaultuserroleid', 'admin'), $defaultuserid, ($userroles + $otherroles)));
$temp->add(new admin_setting_configselect('creatornewroleid', get_string('creatornewroleid', 'admin'),
get_string('creatornewroleid_help', 'admin'), $defaultteacherid, $creatornewroles));
+ $temp->add(new admin_setting_configselect('restorernewroleid', get_string('restorernewroleid', 'admin'),
+ get_string('restorernewroleid_help', 'admin'), $defaultteacherid, $restorersnewrole));
// release memory
unset($otherroles);
unset($guestroles);
unset($userroles);
unset($creatornewroles);
+ unset($restorersnewrole);
}
$temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
+ * Version information
+ *
* @package tool
* @subpackage customlang
* @copyright 2010 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
admin_externalpage_setup('toollangimport');
-if (!empty($CFG->skiplangupgrade)) {
- echo $OUTPUT->header();
- echo $OUTPUT->box(get_string('langimportdisabled', 'tool_langimport'));
- echo $OUTPUT->footer();
- die;
+if (empty($CFG->langotherroot)) {
+ throw new moodle_exception('missingcfglangotherroot', 'tool_langimport');
}
$mode = optional_param('mode', 0, PARAM_INT); // action
$pack = optional_param_array('pack', array(), PARAM_SAFEDIR); // pack to install
$uninstalllang = optional_param('uninstalllang', '', PARAM_LANG); // installed pack to uninstall
$confirm = optional_param('confirm', 0, PARAM_BOOL); // uninstallation confirmation
+$purgecaches = optional_param('purgecaches', false, PARAM_BOOL); // explicit caches reset
+
+if ($purgecaches) {
+ require_sesskey();
+ get_string_manager()->reset_caches();
+ redirect($PAGE->url);
+}
+
+if (!empty($CFG->skiplangupgrade)) {
+ echo $OUTPUT->header();
+ echo $OUTPUT->box(get_string('langimportdisabled', 'tool_langimport'));
+ echo $OUTPUT->single_button(new moodle_url($PAGE->url, array('purgecaches' => 1)), get_string('purgestringcaches', 'tool_langimport'));
+ echo $OUTPUT->footer();
+ die;
+}
define('INSTALLATION_OF_SELECTED_LANG', 2);
define('DELETION_OF_SELECTED_LANG', 4);
$string['install'] = 'Install selected language pack';
$string['installedlangs'] = 'Installed language packs';
$string['langimport'] = 'Language import utility';
-$string['langimportdisabled'] = 'Language import feature has been disabled. You have to update your language packs manually at the file-system level.';
+$string['langimportdisabled'] = 'Language import feature has been disabled. You have to update your language packs manually at the file-system level. Do not forget to purge string caches after you do so.';
$string['langpackinstalled'] = 'Language pack {$a} was successfully installed';
$string['langpackremoved'] = 'Language pack was uninstalled';
$string['langpackupdateskipped'] = 'Update of {$a} language pack skipped';
$string['langpackuptodate'] = 'Language pack {$a} is up-to-date';
$string['langupdatecomplete'] = 'Language pack update completed';
+$string['missingcfglangotherroot'] = 'Missing configuration value $CFG->langotherroot';
$string['missinglangparent'] = 'Missing parent language <em>{$a->parent}</em> of <em>{$a->lang}</em>.';
$string['nolangupdateneeded'] = 'All your language packs are up to date, no update is needed';
$string['pluginname'] = 'Language packs';
+$string['purgestringcaches'] = 'Purge string caches';
$string['remotelangnotavailable'] = 'Because Moodle can not connect to download.moodle.org, we are unable to do language pack installation automatically. Please download the appropriate zip file(s) from http://download.moodle.org, copy them to your {$a} directory and unzip them manually.';
$string['uninstall'] = 'Uninstall selected language pack';
$string['uninstallconfirm'] = 'You are about to completely uninstall language pack {$a}, are you sure?';
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500;
$plugin->requires = 2011092100;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500;
$plugin->requires = 2011092100;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500;
$plugin->requires = 2011092100;
*
* @package tool
* @subpackage unittest
- * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
- * @author N.D.Freear@open.ac.uk, T.J.Hunt@open.ac.uk
+ * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+defined('MOODLE_INTERNAL') || die();
+
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
$plugin->component = 'tool_unittest'; // Full name of the plugin (used for diagnostics)
* @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;
+
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
--- /dev/null
+This files describes API changes in /admin/tool/* - plugins,
+information provided here is intended especially for developers.
+
+
+=== 2.2 ===
+
+API changes:
+* new admin tool plugin type introduced
+
+
+How to migrate existing admin reports:
+# move all files to new /admin/tool/yourplugin/ location
+# update all links to admin tools /$CFG->admin/report/ to /$CFG->admin/tool/
+# add language pack with at least 'pluginname' string
+# update all language strings (use 'tool_yourplugin' instead of 'report_yourplugin') - use AMOS hints in commit message
+# update all capability names
+# create db/install.php migration script - delete old settings and capabilities (see converted plugins for examples)
+# grep the plugin codebase and look for any remaining 'coursereport' occurrences
+# update CSS selectors
+
+See http://docs.moodle.org/dev/Admin_tools for more details and explanation.
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
$string['duplicate'] = 'Duplicate';
$string['duplicatefieldname'] = 'Another field with that name exists';
$string['duplicatekeyname'] = 'Another key with that name exists';
+$string['duplicatetablename'] = 'Another table with that name exists';
$string['edit'] = 'Edit';
$string['edit_field'] = 'Edit field';
$string['edit_field_save'] = 'Save field';
$string['index'] = 'Index';
$string['indexes'] = 'Indexes';
$string['integerincorrectlength'] = 'Incorrect length for integer field';
+$string['incorrecttablename'] = 'Incorrect table name';
$string['key'] = 'Key';
$string['keys'] = 'Keys';
$string['listreservedwords'] = 'List of Reserved Words<br />(used to keep <a href="http://docs.moodle.org/en/XMLDB_reserved_words" target="_blank">XMLDB_reserved_words</a> updated)';
$string['selectonefieldkeyindex'] = 'Please select one field/key/index from the list to view the PHP code';
$string['selecttable'] = 'Select table:';
$string['table'] = 'Table';
+$string['tablenameempty'] = 'The table name cannot be empty';
$string['tables'] = 'Tables';
$string['textincorrectlength'] = 'Incorrect length for text field';
$string['unload'] = 'Unload';
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+
+defined('MOODLE_INTERNAL') || die();
$plugin->version = 2011092500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2011092100; // Requires this Moodle version
get_string('restrictedusers', 'webservice'));
$mform->addHelpButton('restrictedusers', 'restrictedusers', 'webservice');
+ //can users download files
+ $mform->addElement('advcheckbox', 'downloadfiles', get_string('downloadfiles', 'webservice'));
+ $mform->setAdvanced('downloadfiles');
+ $mform->addHelpButton('downloadfiles', 'downloadfiles', 'webservice');
+
/// needed to select automatically the 'No required capability" option
$currentcapabilityexist = false;
if (empty($service->requiredcapability)) {
<?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/>.
-$plugin->version = 2010072600;
+/**
+ * Version details
+ *
+ * @package auth
+ * @subpackage cas
+ * @author Martin Dougiamas
+ * @author Jerome GUTIERREZ
+ * @author Iñaky Arenaza
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_cas'; // Full name of the plugin (used for diagnostics)
<?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/>.
-$plugin->version = 2009112400;
+/**
+ * Version details
+ *
+ * @package auth
+ * @subpackage db
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_db'; // Full name of the plugin (used for diagnostics)
--- /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/>.
+
+/**
+ * Version details
+ *
+ * @package auth
+ * @subpackage email
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_email'; // Full name of the plugin (used for diagnostics)
<?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/>.
-$plugin->version = 2009112400;
+/**
+ * Version details
+ *
+ * @package auth
+ * @subpackage fc
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_fc'; // Full name of the plugin (used for diagnostics)
<?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/>.
-$plugin->version = 2009112400;
+/**
+ * Version details
+ *
+ * @package auth
+ * @subpackage imap
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_imap'; // Full name of the plugin (used for diagnostics)
<?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/>.
-$plugin->version = 2010072600;
+/**
+ * Version details
+ *
+ * @package auth
+ * @subpackage ldap
+ * @author Martin Dougiamas
+ * @author Iñaky Arenaza
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_ldap'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2011022700;
-$plugin->component = 'auth_manual';
\ No newline at end of file
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_manual'; // Full name of the plugin (used for diagnostics)
// If hostid hasn't been specified, try getting it using wwwroot
if (!$hostid) {
+ $hostwwwroot = trim($hostwwwroot);
+ $hostwwwroot = rtrim($hostwwwroot, '/');
+
+ // ensure the wwwroot starts with a http or https prefix
+ if (strtolower(substr($hostwwwroot, 0, 4)) != 'http') {
+ $hostwwwroot = 'http://'.$hostwwwroot;
+ }
$hostid = $DB->get_field('mnet_host', 'id', array('wwwroot' => $hostwwwroot));
}
<?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/>.
-$plugin->version = 2010071300;
+/**
+ * Manual authentication plugin version information
+ *
+ * @package auth
+ * @subpackage mnet
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_mnet'; // Full name of the plugin (used for diagnostics)
<?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/>.
-$plugin->version = 2009112400;
+/**
+ * Version information
+ *
+ * @package auth
+ * @subpackage nntp
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_nntp'; // Full name of the plugin (used for diagnostics)
--- /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/>.
+
+/**
+ * Version information
+ *
+ * @package auth
+ * @subpackage nologin
+ * @copyright 2011 Petr Skoda (http://skodak.org)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_nologin'; // Full name of the plugin (used for diagnostics)
--- /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/>.
+
+/**
+ * Version information
+ *
+ * @package auth
+ * @subpackage none
+ * @copyright 2011 Petr Skoda (http://skodak.org)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_none'; // Full name of the plugin (used for diagnostics)
<?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/>.
-$plugin->version = 2009112400;
+/**
+ * Version information
+ *
+ * @package auth
+ * @subpackage pam
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_pam'; // Full name of the plugin (used for diagnostics)
<?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/>.
-$plugin->version = 2009112400;
+/**
+ * Version information
+ *
+ * @package auth
+ * @subpackage pop3
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_pop3'; // Full name of the plugin (used for diagnostics)
<?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/>.
-$plugin->version = 2009112400;
+/**
+ * Version information
+ *
+ * @package auth
+ * @subpackage radius
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_radius'; // Full name of the plugin (used for diagnostics)
<?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/>.
-$plugin->version = 2009112400;
+/**
+ * Version information
+ *
+ * @package auth
+ * @subpackage shibboleth
+ * @author Martin Dougiamas
+ * @author Lukas Haemmerle
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_shibboleth'; // Full name of the plugin (used for diagnostics)
--- /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/>.
+
+/**
+ * Version information
+ *
+ * @package auth
+ * @subpackage webservice
+ * @copyright 2011 Petr Skoda (http://skodak.org)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'auth_webservice'; // Full name of the plugin (used for diagnostics)
}
private function create_node_course_modules_mod_resource ($sheet_mod_resource, $instance) {
+ global $CFG;
+
+ require_once($CFG->libdir.'/validateurlsyntax.php');
$link = '';
$mod_alltext = '';
if (!empty($resource)) {
$xpath = cc2moodle::newx_path($resource, cc2moodle::getresourcens());
- $resource = $xpath->query('/wl:webLink/wl:url/@href');
+ $resource = $xpath->query('//url/@href');
if ($resource->length > 0) {
- $link = $resource->item(0)->nodeValue;
+ $rawlink = $resource->item(0)->nodeValue;
+ if (!validateUrlSyntax($rawlink, 's+')) {
+ $changed = rawurldecode($rawlink);
+ if (validateUrlSyntax($changed, 's+')) {
+ $link = $changed;
+ } else {
+ $link = 'http://invalidurldetected/';
+ }
+ } else {
+ $link = $rawlink;
+ }
}
}
}
$mod_options = 'objectframe';
$mod_reference = $link;
//detected if we are dealing with html file
- if (!empty($link) && ($instance['common_cartriedge_type'] == cc112moodle::CC_TYPE_WEBCONTENT)) {
+ if (!empty($link) && ($instance['common_cartriedge_type'] == cc2moodle::CC_TYPE_WEBCONTENT)) {
$ext = strtolower(pathinfo($link, PATHINFO_EXTENSION));
if (in_array($ext, array('html', 'htm', 'xhtml'))) {
$mod_type = 'html';
}
private function create_node_course_modules_mod_resource ($sheet_mod_resource, $instance) {
+ global $CFG;
+
+ require_once($CFG->libdir.'/validateurlsyntax.php');
$link = '';
$mod_alltext = '';
$xpath = cc112moodle::newx_path($resource, cc112moodle::$resourcens);
$resource = $xpath->query('/wl:webLink/wl:url/@href');
if ($resource->length > 0) {
- $link = $resource->item(0)->nodeValue;
+ $rawlink = $resource->item(0)->nodeValue;
+ if (!validateUrlSyntax($rawlink, 's+')) {
+ $changed = rawurldecode($rawlink);
+ if (validateUrlSyntax($changed, 's+')) {
+ $link = $changed;
+ } else {
+ $link = 'http://invalidurldetected/';
+ }
+ } else {
+ $link = $rawlink;
+ }
}
}
}
<!-- LanguageId -->
<xs:complexType name="LanguageId">
<xs:simpleContent>
- <xs:extension base="xs:language">
+ <xs:extension base="xs:token">
<xs:attributeGroup ref="ex:customAttributes"/>
</xs:extension>
</xs:simpleContent>
<xs:complexType name="LangString">
<xs:simpleContent>
<xs:extension base="CharacterString">
- <xs:attribute name="language" type="xs:language"/>
+ <xs:attribute name="language" type="xs:token"/>
<xs:attributeGroup ref="ex:customAttributes"/>
</xs:extension>
</xs:simpleContent>
<!-- LanguageId -->
<xs:complexType name="LanguageId">
<xs:simpleContent>
- <xs:extension base="xs:language">
+ <xs:extension base="xs:token">
<xs:attributeGroup ref="ex:customAttributes" />
</xs:extension>
</xs:simpleContent>
<xs:complexType name="LangString">
<xs:simpleContent>
<xs:extension base="CharacterString">
- <xs:attribute name="language" type="xs:language" />
+ <xs:attribute name="language" type="xs:token" />
<xs:attributeGroup ref="ex:customAttributes" />
</xs:extension>
</xs:simpleContent>
<!-- LanguageId -->
<xs:complexType name="LanguageId">
<xs:simpleContent>
- <xs:extension base="xs:language">
+ <xs:extension base="xs:token">
<xs:attributeGroup ref="ex:customAttributes"/>
</xs:extension>
</xs:simpleContent>
<!-- LanguageId -->
<xs:complexType name="LanguageId">
<xs:simpleContent>
- <xs:extension base="xs:language">
+ <xs:extension base="xs:token">
<xs:attributeGroup ref="ex:customAttributes" />
</xs:extension>
</xs:simpleContent>
<xs:complexType name="LangString">
<xs:simpleContent>
<xs:extension base="CharacterString">
- <xs:attribute name="language" type="xs:language" />
+ <xs:attribute name="language" type="xs:token" />
<xs:attributeGroup ref="ex:customAttributes" />
</xs:extension>
</xs:simpleContent>
<xs:element ref="mat_extension" minOccurs="0" maxOccurs="0" />
</xs:choice>
</xs:sequence>
- <xs:attribute name="attribute3" type="xs:language" />
+ <xs:attribute name="attribute3" type="xs:token" />
</xs:complexType>
<!-- ********* -->
<!-- ** and ** -->
<xs:attribute name="charset" type="xs:string" default="ascii-us" />
<xs:attribute name="uri" type="xs:string" />
<xs:attribute ref="xml:space" default="default" />
- <xs:attribute name="attribute11" type="xs:language" />
+ <xs:attribute name="attribute11" type="xs:token" />
<xs:attribute name="entityref" type="xs:ENTITY" use="prohibited" />
<xs:attribute name="width" type="xs:string" />
<xs:attribute name="height" type="xs:string" />
<xs:element name="altmaterial" type="altmaterialType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="label" type="string256" />
- <xs:attribute name="attribute5" type="xs:language" />
+ <xs:attribute name="attribute5" type="xs:token" />
</xs:complexType>
<!-- ****************** -->
<!-- ** material_ref ** -->
<xs:attribute name="charset" type="xs:string" default="ascii-us" />
<xs:attribute name="uri" type="xs:string" />
<xs:attribute ref="xml:space" default="default" />
- <xs:attribute name="attribute11" type="xs:language" />
+ <xs:attribute name="attribute11" type="xs:token" />
<xs:attribute name="entityref" type="xs:ENTITY" use="prohibited" />
<xs:attribute name="width" type="xs:string" />
<xs:attribute name="height" type="xs:string" />
</xs:choice>
</xs:sequence>
<xs:attribute name="label" type="xs:string" />
- <xs:attribute name="attribute5" type="xs:language" />
+ <xs:attribute name="attribute5" type="xs:token" />
<xs:attribute name="y0" type="xs:string" />
<xs:attribute name="x0" type="xs:string" />
<xs:attribute name="width" type="xs:string" />
</xs:sequence>
<xs:attribute name="ident" type="xs:string" use="required" />
<xs:attribute name="title" type="xs:string" />
- <xs:attribute name="attribute7" type="xs:language" />
+ <xs:attribute name="attribute7" type="xs:token" />
</xs:complexType>
<!-- ******************** -->
<!-- ** sectioncontrol ** -->
the empty string.</xs:documentation>
</xs:annotation>
<xs:simpleType>
- <xs:union memberTypes="xs:language">
+ <xs:union memberTypes="xs:token">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="" />
</xs:documentation>
</xs:annotation>
<xs:simpleType>
- <xs:union memberTypes="xs:language">
+ <xs:union memberTypes="xs:token">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value=""/>
the empty string.</xs:documentation>
</xs:annotation>
<xs:simpleType>
- <xs:union memberTypes="xs:language">
+ <xs:union memberTypes="xs:token">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="" />
$user->set_source_sql('SELECT u.*, c.id AS contextid, m.wwwroot AS mnethosturl
FROM {user} u
JOIN {backup_ids_temp} bi ON bi.itemid = u.id
- JOIN {context} c ON c.instanceid = u.id
+ LEFT JOIN {context} c ON c.instanceid = u.id AND c.contextlevel = ' . CONTEXT_USER . '
LEFT JOIN {mnet_host} m ON m.id = u.mnethostid
WHERE bi.backupid = ?
- AND bi.itemname = ?
- AND c.contextlevel = ?', array(
+ AND bi.itemname = ?', array(
backup_helper::is_sqlparam($this->get_backupid()),
- backup_helper::is_sqlparam('userfinal'),
- backup_helper::is_sqlparam(CONTEXT_USER)));
+ backup_helper::is_sqlparam('userfinal')));
// All the rest on information is only added if we arent
// in an anonymized backup
'backupid' => $this->get_backupid(), 'itemname' => 'userfinal'));
foreach ($rs as $record) {
$userid = $record->itemid;
- $userctxid = get_context_instance(CONTEXT_USER, $userid)->id;
+ $userctx = get_context_instance(CONTEXT_USER, $userid);
+ if (!$userctx) {
+ continue; // User has not context, sure it's a deleted user, so cannot have files
+ }
// Proceed with every user filearea
foreach ($fileareas as $filearea) {
// We don't need to specify itemid ($userid - 5th param) as far as by
// context we can get all the associated files. See MDL-22092
- backup_structure_dbops::annotate_files($this->get_backupid(), $userctxid, 'user', $filearea, null);
+ backup_structure_dbops::annotate_files($this->get_backupid(), $userctx->id, 'user', $filearea, null);
}
}
$rs->close();
$startdate->set_ui(new backup_setting_ui_dateselector($startdate, get_string('setting_course_startdate', 'backup')));
$this->add_setting($startdate);
+ $keep_enrols = new restore_course_generic_setting('keep_roles_and_enrolments', base_setting::IS_BOOLEAN, false);
+ $keep_enrols->set_ui(new backup_setting_ui_select($keep_enrols, $keep_enrols->get_name(), array(1=>get_string('yes'), 0=>get_string('no'))));
+ $keep_enrols->get_ui()->set_label(get_string('setting_keep_roles_and_enrolments', 'backup'));
+ if ($this->get_target() != backup::TARGET_CURRENT_DELETING and $this->get_target() != backup::TARGET_EXISTING_DELETING) {
+ $keep_enrols->set_value(false);
+ $keep_enrols->set_status(backup_setting::LOCKED_BY_CONFIG);
+ $keep_enrols->set_visibility(backup_setting::HIDDEN);
+ }
+ $this->add_setting($keep_enrols);
+
+ $keep_groups = new restore_course_generic_setting('keep_groups_and_groupings', base_setting::IS_BOOLEAN, false);
+ $keep_groups->set_ui(new backup_setting_ui_select($keep_groups, $keep_groups->get_name(), array(1=>get_string('yes'), 0=>get_string('no'))));
+ $keep_groups->get_ui()->set_label(get_string('setting_keep_groups_and_groupings', 'backup'));
+ if ($this->get_target() != backup::TARGET_CURRENT_DELETING and $this->get_target() != backup::TARGET_EXISTING_DELETING) {
+ $keep_groups->set_value(false);
+ $keep_groups->set_status(backup_setting::LOCKED_BY_CONFIG);
+ $keep_groups->set_visibility(backup_setting::HIDDEN);
+ }
+ $this->add_setting($keep_groups);
+
// Define overwrite_conf to decide if course configuration will be restored over existing one
$overwrite = new restore_course_overwrite_conf_setting('overwrite_conf', base_setting::IS_BOOLEAN, false);
$overwrite->set_ui(new backup_setting_ui_select($overwrite, $overwrite->get_name(), array(1=>get_string('yes'), 0=>get_string('no'))));
// Conditionally create the temp table (can exist from prechecks) and delete old stuff
$this->add_step(new restore_create_and_clean_temp_stuff('create_and_clean_temp_stuff'));
+ // Now make sure the user that is running the restore can actually access the course
+ // before executing any other step (potentially performing permission checks)
+ $this->add_step(new restore_fix_restorer_access_step('fix_restorer_access'));
+
// If we haven't preloaded information, load all the included inforef records to temp_ids table
$this->add_step(new restore_load_included_inforef_records('load_inforef_records'));
$data->groupingid = $this->get_new_parentid('grouping'); // Use new parentid
$data->groupid = $this->get_mappingid('group', $data->groupid); // Get from mappings
- $DB->insert_record('groupings_groups', $data); // No need to set this mapping (no child info nor files)
+
+ $params = array();
+ $params['groupingid'] = $data->groupingid;
+ $params['groupid'] = $data->groupid;
+
+ if (!$DB->record_exists('groupings_groups', $params)) {
+ $DB->insert_record('groupings_groups', $data); // No need to set this mapping (no child info nor files)
+ }
}
protected function after_execute() {
global $CFG, $DB;
$data = (object)$data;
- $oldid = $data->id; // We'll need this later
$fullname = $this->get_setting_value('course_fullname');
$shortname = $this->get_setting_value('course_shortname');
$data->id = $this->get_courseid();
$data->fullname = $fullname;
$data->shortname= $shortname;
- $data->idnumber = '';
+
+ $context = get_context_instance_by_id($this->task->get_contextid());
+ if (has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid())) {
+ $data->idnumber = '';
+ } else {
+ unset($data->idnumber);
+ }
// Only restrict modules if original course was and target site too for new courses
$data->restrictmodules = $data->restrictmodules && !empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor == 'all';
}
+/**
+ * Make sure the user restoring the course can actually access it.
+ */
+class restore_fix_restorer_access_step extends restore_execution_step {
+ protected function define_execution() {
+ global $CFG, $DB;
+
+ if (!$userid = $this->task->get_userid()) {
+ return;
+ }
+
+ if (empty($CFG->restorernewroleid)) {
+ // Bad luck, no fallback role for restorers specified
+ return;
+ }
+
+ $courseid = $this->get_courseid();
+ $context = context_course::instance($courseid);
+
+ if (is_enrolled($context, $userid, 'moodle/course:update', true) or is_viewing($context, $userid, 'moodle/course:update')) {
+ // Current user may access the course (admin, category manager or restored teacher enrolment usually)
+ return;
+ }
+
+ // Try to add role only - we do not need enrolment if user has moodle/course:view or is already enrolled
+ role_assign($CFG->restorernewroleid, $userid, $context);
+
+ if (is_enrolled($context, $userid, 'moodle/course:update', true) or is_viewing($context, $userid, 'moodle/course:update')) {
+ // Extra role is enough, yay!
+ return;
+ }
+
+ // The last chance is to create manual enrol if it does not exist and and try to enrol the current user,
+ // hopefully admin selected suitable $CFG->restorernewroleid ...
+ if (!enrol_is_enabled('manual')) {
+ return;
+ }
+ if (!$enrol = enrol_get_plugin('manual')) {
+ return;
+ }
+ if (!$DB->record_exists('enrol', array('enrol'=>'manual', 'courseid'=>$courseid))) {
+ $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
+ $fields = array('status'=>ENROL_INSTANCE_ENABLED, 'enrolperiod'=>$enrol->get_config('enrolperiod', 0), 'roleid'=>$enrol->get_config('roleid', 0));
+ $enrol->add_instance($course, $fields);
+ }
+
+ enrol_try_internal_enrol($courseid, $userid);
+ }
+}
+
+
/**
* This structure steps restores the filters and their configs
*/
$newitemid = $this->get_mappingid(restore_gradingform_plugin::itemid_mapping($areaname), $data->itemid);
$oldid = $data->id;
- $data->formid = $newformid;
+ $data->definitionid = $newformid;
$data->raterid = $this->get_mappingid('user', $data->raterid);
$data->itemid = $newitemid;
* - Activity includes completion info (file_exists)
*/
class restore_userscompletion_structure_step extends restore_structure_step {
- private $done = array();
-
/**
* To conditionally decide if this step must be executed
* Note the "settings" conditions are evaluated in the
$data->userid = $this->get_mappingid('user', $data->userid);
$data->timemodified = $this->apply_date_offset($data->timemodified);
+ // Find the existing record
+ $existing = $DB->get_record('course_modules_completion', array(
+ 'coursemoduleid' => $data->coursemoduleid,
+ 'userid' => $data->userid), 'id, timemodified');
// Check we didn't already insert one for this cmid and userid
// (there aren't supposed to be duplicates in that field, but
// it was possible until MDL-28021 was fixed).
- $key = $data->coursemoduleid . ',' . $data->userid;
- if (array_key_exists($key, $this->done)) {
- // Find the existing record
- $existing = $DB->get_record('course_modules_completion', array(
- 'coursemoduleid' => $data->coursemoduleid,
- 'userid' => $data->userid), 'id, timemodified');
+ if ($existing) {
// Update it to these new values, but only if the time is newer
if ($existing->timemodified < $data->timemodified) {
$data->id = $existing->id;
} else {
// Normal entry where it doesn't exist already
$DB->insert_record('course_modules_completion', $data);
- // Remember this entry
- $this->done[$key] = true;
}
}
-
- protected function after_execute() {
- // This gets called once per activity (according to my testing).
- // Clearing the array isn't strictly required, but avoids using
- // unnecessary memory.
- $this->done = array();
- }
}
/**
$restore->execute();
} catch(Exception $e) {
$restore->cleanup();
- throw new moodle_exception((string)$e);
+ throw $e;
}
} else {
$restore->save_controller();
$newuserid = $DB->insert_record('user', $user);
self::set_backup_ids_record($restoreid, 'user', $recuser->itemid, $newuserid);
// Let's create the user context and annotate it (we need it for sure at least for files)
- $newuserctxid = get_context_instance(CONTEXT_USER, $newuserid)->id;
- self::set_backup_ids_record($restoreid, 'context', $recuser->parentitemid, $newuserctxid);
-
- // Process custom fields
- if (isset($user->custom_fields)) { // if present in backup
- foreach($user->custom_fields['custom_field'] as $udata) {
- $udata = (object)$udata;
- // If the profile field has data and the profile shortname-datatype is defined in server
- if ($udata->field_data) {
- if ($field = $DB->get_record('user_info_field', array('shortname'=>$udata->field_name, 'datatype'=>$udata->field_type))) {
- /// Insert the user_custom_profile_field
- $rec = new stdClass();
- $rec->userid = $newuserid;
- $rec->fieldid = $field->id;
- $rec->data = $udata->field_data;
- $DB->insert_record('user_info_data', $rec);
+ // but for deleted users that don't have a context anymore (MDL-30192). We are done for them
+ // and nothing else (custom fields, prefs, tags, files...) will be created.
+ if (empty($user->deleted)) {
+ $newuserctxid = $user->deleted ? 0 : get_context_instance(CONTEXT_USER, $newuserid)->id;
+ self::set_backup_ids_record($restoreid, 'context', $recuser->parentitemid, $newuserctxid);
+
+ // Process custom fields
+ if (isset($user->custom_fields)) { // if present in backup
+ foreach($user->custom_fields['custom_field'] as $udata) {
+ $udata = (object)$udata;
+ // If the profile field has data and the profile shortname-datatype is defined in server
+ if ($udata->field_data) {
+ if ($field = $DB->get_record('user_info_field', array('shortname'=>$udata->field_name, 'datatype'=>$udata->field_type))) {
+ /// Insert the user_custom_profile_field
+ $rec = new stdClass();
+ $rec->userid = $newuserid;
+ $rec->fieldid = $field->id;
+ $rec->data = $udata->field_data;
+ $DB->insert_record('user_info_data', $rec);
+ }
}
}
}
- }
- // Process tags
- if (!empty($CFG->usetags) && isset($user->tags)) { // if enabled in server and present in backup
- $tags = array();
- foreach($user->tags['tag'] as $usertag) {
- $usertag = (object)$usertag;
- $tags[] = $usertag->rawname;
+ // Process tags
+ if (!empty($CFG->usetags) && isset($user->tags)) { // if enabled in server and present in backup
+ $tags = array();
+ foreach($user->tags['tag'] as $usertag) {
+ $usertag = (object)$usertag;
+ $tags[] = $usertag->rawname;
+ }
+ tag_set('user', $newuserid, $tags);
}
- tag_set('user', $newuserid, $tags);
- }
- // Process preferences
- if (isset($user->preferences)) { // if present in backup
- foreach($user->preferences['preference'] as $preference) {
- $preference = (object)$preference;
- // Prepare the record and insert it
- $preference->userid = $newuserid;
- $status = $DB->insert_record('user_preferences', $preference);
+ // Process preferences
+ if (isset($user->preferences)) { // if present in backup
+ foreach($user->preferences['preference'] as $preference) {
+ $preference = (object)$preference;
+ // Prepare the record and insert it
+ $preference->userid = $newuserid;
+ $status = $DB->insert_record('user_preferences', $preference);
+ }
}
- }
- // Create user files in pool (profile, icon, private) by context
- restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'icon', $recuser->parentitemid, $userid);
- restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'profile', $recuser->parentitemid, $userid);
- if ($userfiles) { // private files only if enabled in settings
- restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'private', $recuser->parentitemid, $userid);
- }
+ // Create user files in pool (profile, icon, private) by context
+ restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'icon', $recuser->parentitemid, $userid);
+ restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'profile', $recuser->parentitemid, $userid);
+ if ($userfiles) { // private files only if enabled in settings
+ restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'private', $recuser->parentitemid, $userid);
+ }
+ }
}
$rs->close();
}
// With problems of type error, throw exception, shouldn't happen if prechecks were originally
// executed, so be radical here.
if (array_key_exists('errors', $problems)) {
- throw new restore_dbops_exception('restore_problems_processing_questions', null, implode(', ', $problems));
+ throw new restore_dbops_exception('restore_problems_processing_questions', null, implode(', ', $problems['errors']));
}
}
/**
* Deletes all of the content associated with the given course (courseid)
* @param int $courseid
+ * @param array $options
* @return bool True for success
*/
- public static function delete_course_content($courseid) {
- return remove_course_contents($courseid, false);
+ public static function delete_course_content($courseid, array $options = null) {
+ return remove_course_contents($courseid, false, $options);
}
}
$html .= $this->output->heading(get_string('restoretonewcourse', 'backup'), 2, array('class'=>'header'));
$html .= $this->backup_detail_input(get_string('restoretonewcourse', 'backup'), 'radio', 'target', backup::TARGET_NEW_COURSE, array('checked'=>'checked'));
$html .= $this->backup_detail_pair(get_string('selectacategory', 'backup'), $this->render($categories));
- $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('continue'), 'class'=>'newcoursecontinue')));
+ $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('continue'))));
$html .= html_writer::end_tag('div');
$html .= html_writer::end_tag('form');
- $config = new stdClass;
- $config->title = get_string('confirmnewcoursecontinue', 'backup');
- $config->question = get_string('confirmnewcoursecontinuequestion', 'backup');
- $config->yesLabel = get_string('continue');
- $config->noLabel = get_string('cancel');
- $PAGE->requires->yui_module('moodle-backup-confirmcancel', 'M.core_backup.watch_newcoursecontinue_buttons', array($config));
}
if ($wholecourse && !empty($currentcourse)) {
throw new restore_ui_exception('restoreuifinalisedbeforeexecute');
}
if ($this->controller->get_target() == backup::TARGET_CURRENT_DELETING || $this->controller->get_target() == backup::TARGET_EXISTING_DELETING) {
- restore_dbops::delete_course_content($this->controller->get_courseid());
+ $options = array();
+ $options['keep_roles_and_enrolments'] = $this->get_setting_value('keep_roles_and_enrolments');
+ $options['keep_groups_and_groupings'] = $this->get_setting_value('keep_groups_and_groupings');
+ restore_dbops::delete_course_content($this->controller->get_courseid(), $options);
}
$this->controller->execute_plan();
$this->progress = self::PROGRESS_EXECUTED;
});
}
-M.core_backup.watch_newcoursecontinue_buttons = function(config) {
- Y.all('.newcoursecontinue').each(function(){
- this._confirmationListener = this._confirmationListener || this.on('click', function(e){
- // Prevent the default event (sumbit) from firing
- e.preventDefault();
- // Create the confirm box
- var confirm = new M.core.confirm(config);
- // If the user clicks yes
- confirm.on('complete-yes', function(e){
- // Detach the listener for the confirm box so it doesn't fire again.
- this._confirmationListener.detach();
- // Simulate the original cancel button click
- this.simulate('click');
- }, this);
- // Show the confirm box
- confirm.show();
- }, this);
- });
-}
-
}, '@VERSION@', {'requires':['base','node','node-event-simulate','moodle-enrol-notification']});
\ No newline at end of file
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
-$plugin->version = 2007101509;
+/**
+ * Version details
+ *
+ * @package block
+ * @subpackage activity_modules
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'block_activity_modules'; // Full name of the plugin (used for diagnostics)