<?php
-
-///////////////////////////////////////////////////////////////////////////
-// //
-// NOTICE OF COPYRIGHT //
-// //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //
-// http://moodle.org //
-// //
-// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
-// //
-// This program 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 2 of the License, or //
-// (at your option) any later version. //
-// //
-// This program 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: //
-// //
-// http://www.gnu.org/copyleft/gpl.html //
-// //
-///////////////////////////////////////////////////////////////////////////
+// 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/>.
/**
- * Processes actions from the admin_setting_managefilters object (defined in
- * adminlib.php).
+ * Filter management page.
*
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package administration
- *//** */
-
- require_once(dirname(__FILE__) . '/../config.php');
- require_once($CFG->libdir . '/adminlib.php');
-
- $action = optional_param('action', '', PARAM_ALPHANUMEXT);
- $filterpath = optional_param('filterpath', '', PARAM_SAFEDIR);
-
- require_login();
- $systemcontext = context_system::instance();
- require_capability('moodle/site:config', $systemcontext);
-
- $returnurl = "$CFG->wwwroot/$CFG->admin/filters.php";
- admin_externalpage_setup('managefilters');
-
- $filters = filter_get_global_states();
-
- // In case any new filters have been installed, but not put in the table yet.
- $fitlernames = filter_get_all_installed();
- $newfilters = $fitlernames;
- foreach ($filters as $filter => $notused) {
- unset($newfilters[$filter]);
+ * @package core
+ * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once(dirname(__FILE__) . '/../config.php');
+require_once($CFG->libdir . '/adminlib.php');
+
+$action = optional_param('action', '', PARAM_ALPHA);
+$filterpath = optional_param('filterpath', '', PARAM_PLUGIN);
+
+require_login();
+$systemcontext = context_system::instance();
+require_capability('moodle/site:config', $systemcontext);
+
+admin_externalpage_setup('managefilters');
+
+// Clean up bogus filter states first.
+$plugininfos = core_plugin_manager::instance()->get_plugins_of_type('filter');
+$filters = array();
+$states = filter_get_global_states();
+foreach ($states as $state) {
+ if (!isset($plugininfos[$state->filter]) and !get_config('filter_'.$state->filter, 'version')) {
+ // Purge messy leftovers after incorrectly uninstalled plugins and unfinished installs.
+ $DB->delete_records('filter_active', array('filter' => $state->filter));
+ $DB->delete_records('filter_config', array('filter' => $state->filter));
+ error_log('Deleted bogus "filter_'.$state->filter.'" states and config data.');
+ } else {
+ $filters[$state->filter] = $state;
}
+}
-/// Process actions ============================================================
-
- if ($action) {
- if ($action !== 'delete' and !isset($filters[$filterpath]) and !isset($newfilters[$filterpath])) {
- throw new moodle_exception('filternotinstalled', 'error', $returnurl, $filterpath);
- }
-
- if (!confirm_sesskey()) {
- redirect($returnurl);
+// Add properly installed and upgraded filters to the global states table.
+foreach ($plugininfos as $filter => $info) {
+ if (isset($filters[$filter])) {
+ continue;
+ }
+ /** @var \core\plugininfo\base $info */
+ if ($info->is_installed_and_upgraded()) {
+ filter_set_global_state($filter, TEXTFILTER_DISABLED);
+ $states = filter_get_global_states();
+ foreach ($states as $state) {
+ if ($state->filter === $filter) {
+ $filters[$filter] = $state;
+ break;
+ }
}
}
+}
+
+if ($action) {
+ require_sesskey();
+}
- switch ($action) {
+// Process actions.
+switch ($action) {
case 'setstate':
- if ($newstate = optional_param('newstate', '', PARAM_INT)) {
+ if (isset($filters[$filterpath]) and $newstate = optional_param('newstate', '', PARAM_INT)) {
filter_set_global_state($filterpath, $newstate);
if ($newstate == TEXTFILTER_DISABLED) {
filter_set_applies_to_strings($filterpath, false);
}
- unset($newfilters[$filterpath]);
}
break;
case 'setapplyto':
- $applytostrings = optional_param('stringstoo', false, PARAM_BOOL);
- filter_set_applies_to_strings($filterpath, $applytostrings);
+ if (isset($filters[$filterpath])) {
+ $applytostrings = optional_param('stringstoo', false, PARAM_BOOL);
+ filter_set_applies_to_strings($filterpath, $applytostrings);
+ }
break;
case 'down':
filter_set_global_state($filterpath, $filters[$filterpath]->active, -1);
}
break;
- }
-
- // Add any missing filters to the DB table.
- foreach ($newfilters as $filter => $notused) {
- filter_set_global_state($filter, TEXTFILTER_DISABLED);
- }
+}
- // Reset caches and return
- if ($action) {
- core_plugin_manager::reset_caches();
- reset_text_filters_cache();
- redirect($returnurl);
- }
+// Reset caches and return.
+if ($action) {
+ reset_text_filters_cache();
+ core_plugin_manager::reset_caches();
+ redirect(new moodle_url('/admin/filters.php'));
+}
-/// End of process actions =====================================================
-
-/// Print the page heading.
- echo $OUTPUT->header();
- echo $OUTPUT->heading(get_string('filtersettings', 'admin'));
-
- $activechoices = array(
- TEXTFILTER_DISABLED => get_string('disabled', 'filters'),
- TEXTFILTER_OFF => get_string('offbutavailable', 'filters'),
- TEXTFILTER_ON => get_string('on', 'filters'),
- );
- $applytochoices = array(
- 0 => get_string('content', 'filters'),
- 1 => get_string('contentandheadings', 'filters'),
- );
-
- $filters = filter_get_global_states();
-
- // In case any new filters have been installed, but not put in the table yet.
- $filternames = filter_get_all_installed();
- $newfilters = $filternames;
- foreach ($filters as $filter => $notused) {
- unset($newfilters[$filter]);
- }
- $stringfilters = filter_get_string_filters();
-
- $table = new html_table();
- $table->head = array(get_string('filter'), get_string('isactive', 'filters'),
- get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('uninstallplugin', 'core_admin'));
- $table->colclasses = array ('leftalign', 'leftalign', 'centeralign', 'leftalign', 'leftalign', 'leftalign');
- $table->attributes['class'] = 'admintable generaltable';
- $table->id = 'filterssetting';
- $table->data = array();
-
- $lastactive = null;
- foreach ($filters as $filter => $filterinfo) {
- if ($filterinfo->active != TEXTFILTER_DISABLED) {
- $lastactive = $filter;
- }
+// Print the page heading.
+echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('filtersettings', 'admin'));
+
+$states = filter_get_global_states();
+$stringfilters = filter_get_string_filters();
+
+$table = new html_table();
+$table->head = array(get_string('filter'), get_string('isactive', 'filters'),
+ get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('uninstallplugin', 'core_admin'));
+$table->colclasses = array ('leftalign', 'leftalign', 'centeralign', 'leftalign', 'leftalign', 'leftalign');
+$table->attributes['class'] = 'admintable generaltable';
+$table->id = 'filterssetting';
+$table->data = array();
+
+$lastactive = null;
+foreach ($states as $state) {
+ if ($state->active != TEXTFILTER_DISABLED) {
+ $lastactive = $state->filter;
}
+}
- // iterate through filters adding to display table
- $firstrow = true;
- foreach ($filters as $filter => $filterinfo) {
- $applytostrings = isset($stringfilters[$filter]) && $filterinfo->active != TEXTFILTER_DISABLED;
- $row = get_table_row($filterinfo, $firstrow, $filter == $lastactive, $applytostrings);
- $table->data[] = $row;
- if ($filterinfo->active == TEXTFILTER_DISABLED) {
- $table->rowclasses[] = 'dimmed_text';
- } else {
- $table->rowclasses[] = '';
- }
- $firstrow = false;
+// Iterate through filters adding to display table.
+$firstrow = true;
+foreach ($states as $state) {
+ $filter = $state->filter;
+ if (!isset($plugininfos[$filter])) {
+ continue;
}
- foreach ($newfilters as $filter => $filtername) {
- $filterinfo = new stdClass;
- $filterinfo->filter = $filter;
- $filterinfo->active = TEXTFILTER_DISABLED;
- $row = get_table_row($filterinfo, false, false, false);
- $table->data[] = $row;
+ $plugininfo = $plugininfos[$filter];
+ $applytostrings = isset($stringfilters[$filter]) && $state->active != TEXTFILTER_DISABLED;
+ $row = get_table_row($plugininfo, $state, $firstrow, $filter == $lastactive, $applytostrings);
+ $table->data[] = $row;
+ if ($state->active == TEXTFILTER_DISABLED) {
$table->rowclasses[] = 'dimmed_text';
+ } else {
+ $table->rowclasses[] = '';
}
+ $firstrow = false;
+}
- echo html_writer::table($table);
- echo '<p class="filtersettingnote">' . get_string('filterallwarning', 'filters') . '</p>';
- echo $OUTPUT->footer();
+echo html_writer::table($table);
+echo '<p class="filtersettingnote">' . get_string('filterallwarning', 'filters') . '</p>';
+echo $OUTPUT->footer();
+die;
-/// Display helper functions ===================================================
+/**
+ * Return action URL.
+ *
+ * @param string $filterpath
+ * @param string $action
+ * @return moodle_url
+ */
function filters_action_url($filterpath, $action) {
if ($action === 'delete') {
return core_plugin_manager::instance()->get_uninstall_url('filter_'.$filterpath, 'manage');
return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action));
}
-function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings) {
- global $CFG, $OUTPUT, $activechoices, $applytochoices, $filternames; //TODO: this is sloppy coding style!!
+/**
+ * Construct table record.
+ *
+ * @param \core\plugininfo\filter $plugininfo
+ * @param stdClass $state
+ * @param bool $isfirstrow
+ * @param bool $islastactive
+ * @param bool $applytostrings
+ * @return array data
+ */
+function get_table_row(\core\plugininfo\filter $plugininfo, $state, $isfirstrow, $islastactive, $applytostrings) {
+ global $OUTPUT;
$row = array();
- $filter = $filterinfo->filter;
+ $filter = $state->filter;
+ $active = $plugininfo->is_installed_and_upgraded();
+
+ static $activechoices;
+ static $applytochoices;
+ if (!isset($activechoices)) {
+ $activechoices = array(
+ TEXTFILTER_DISABLED => get_string('disabled', 'core_filters'),
+ TEXTFILTER_OFF => get_string('offbutavailable', 'core_filters'),
+ TEXTFILTER_ON => get_string('on', 'core_filters'),
+ );
+ $applytochoices = array(
+ 0 => get_string('content', 'core_filters'),
+ 1 => get_string('contentandheadings', 'core_filters'),
+ );
+ }
- // Filter name
- if (!empty($filternames[$filter])) {
- $row[] = $filternames[$filter];
- } else {
- $row[] = '<span class="error">' . get_string('filemissing', '', $filter) . '</span>';
+ // Filter name.
+ $displayname = $plugininfo->displayname;
+ if (!$plugininfo->rootdir) {
+ $displayname = '<span class="error">' . $displayname . ' - ' . get_string('status_missing', 'core_plugin') . '</span>';
+ } else if (!$active) {
+ $displayname = '<span class="error">' . $displayname . ' - ' . get_string('error') . '</span>';
}
+ $row[] = $displayname;
- // Disable/off/on
- $select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $filterinfo->active, null, 'active' . $filter);
+ // Disable/off/on.
+ $select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $state->active, null, 'active' . $filter);
$select->set_label(get_string('isactive', 'filters'), array('class' => 'accesshide'));
$row[] = $OUTPUT->render($select);
- // Re-order
+ // Re-order.
$updown = '';
$spacer = '<img src="' . $OUTPUT->pix_url('spacer') . '" class="iconsmall" alt="" />';
- if ($filterinfo->active != TEXTFILTER_DISABLED) {
+ if ($state->active != TEXTFILTER_DISABLED) {
if (!$isfirstrow) {
$updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), new pix_icon('t/up', get_string('up'), '', array('class' => 'iconsmall')));
} else {
// Apply to strings.
$select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . $filter);
$select->set_label(get_string('applyto', 'filters'), array('class' => 'accesshide'));
- $select->disabled = $filterinfo->active == TEXTFILTER_DISABLED;
+ $select->disabled = ($state->active == TEXTFILTER_DISABLED);
$row[] = $OUTPUT->render($select);
- // Settings link, if required
- if (filter_has_global_settings($filter)) {
- $row[] = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=filtersetting' . $filter . '">' . get_string('settings') . '</a>';
+ // Settings link, if required.
+ if ($active and filter_has_global_settings($filter)) {
+ $row[] = html_writer::link(new moodle_url('/admin/settings.php', array('section'=>'filtersetting'.$filter)), get_string('settings'));
} else {
$row[] = '';
}
- // Delete
- $row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('uninstallplugin', 'core_admin') . '</a>';
+ // Uninstall.
+ $row[] = html_writer::link(filters_action_url($filter, 'delete'), get_string('uninstallplugin', 'core_admin'));
return $row;
}
$temp->add(new admin_setting_configcheckbox('enabletgzbackups',
new lang_string('enabletgzbackups', 'admin'),
new lang_string('enabletgzbackups_desc', 'admin'), 0));
+ $temp->add(new admin_setting_php_extension_enabled('zlibenabled',
+ get_string('zlibenabled', 'admin'),
+ get_string('enabletgzbackups_nozlib', 'admin'), 'zlib'));
$ADMIN->add('experimental', $temp);
// The argument should be converted to an xpath literal.
$label = $this->getSession()->getSelectorsHandler()->xpathLiteral($label);
- $fieldxpath = "//*[self::input | self::textarea | self::select][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]" .
- "[@id=//label[contains(normalize-space(.), $label)]/@for]";
- $fieldnode = $this->find('xpath', $fieldxpath, $exception);
- $formfieldtypenode = $this->find('xpath', $fieldxpath . "/ancestor::div[@class='form-setting']" .
- "/child::div[contains(concat(' ', @class, ' '), ' form-')]/child::*/parent::div");
+ // Single element settings.
+ try {
+ $fieldxpath = "//*[self::input | self::textarea | self::select][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]" .
+ "[@id=//label[contains(normalize-space(.), $label)]/@for]";
+ $fieldnode = $this->find('xpath', $fieldxpath, $exception);
+
+ $formfieldtypenode = $this->find('xpath', $fieldxpath . "/ancestor::div[@class='form-setting']" .
+ "/child::div[contains(concat(' ', @class, ' '), ' form-')]/child::*/parent::div");
+
+ } catch (ElementNotFoundException $e) {
+
+ // Multi element settings, interacting only the first one.
+ $fieldxpath = "//descendant::label[.= $label]/ancestor::div[contains(concat(' ', normalize-space(@class), ' '), ' form-item ')]" .
+ "/descendant::div[@class='form-group']/descendant::*[self::input | self::textarea | self::select][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]";
+ $fieldnode = $this->find('xpath', $fieldxpath);
+
+ // It is the same one that contains the type.
+ $formfieldtypenode = $fieldnode;
+ }
// Getting the class which contains the field type.
$classes = explode(' ', $formfieldtypenode->getAttribute('class'));
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100;
-$plugin->requires = 2013050100;
+$plugin->version = 2013110500;
+$plugin->requires = 2013110500;
$plugin->component = 'tool_assignmentupgrade';
-$plugin->dependencies = array('mod_assign' => 2013050100);
+$plugin->dependencies = array('mod_assign' => 2013110500);
$string['stepsdefinitionsfilters'] = 'Steps definitions';
$string['stepsdefinitionstype'] = 'Type';
$string['theninfo'] = 'Then. Checkings to ensure the outcomes are the expected ones';
-$string['unknownexceptioninfo'] = 'There was a problem with Selenium or the browser, try to upgrade Selenium to the latest version. Error: ';
+$string['unknownexceptioninfo'] = 'There was a problem with Selenium or your browser. Please ensure you are using the latest version of Selenium. Error:';
$string['viewsteps'] = 'Filter';
$string['wheninfo'] = 'When. Actions that provokes an event';
$string['wrongbehatsetup'] = 'Something is wrong with behat setup, ensure:<ul>
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013101700;
-$plugin->requires = 2013050100; // Requires Moodle 2.5.
+$plugin->version = 2013110500;
+$plugin->requires = 2013110500; // Requires Moodle 2.5.
$plugin->component = 'tool_behat';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2013050100; // Requires this Moodle version.
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2013110500; // Requires this Moodle version.
$plugin->component = 'tool_capability'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100;
-$plugin->requires = 2013050100;
+$plugin->version = 2013110500;
+$plugin->requires = 2013110500;
$plugin->component = 'tool_customlang'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2013050100; // Requires this Moodle version.
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2013110500; // Requires this Moodle version.
$plugin->component = 'tool_dbtransfer'; // Full name of the plugin (used for diagnostics).
$number = self::$parampages[$this->size];
$this->log('createpages', $number, true);
for ($i = 0; $i < $number; $i++) {
- $record = array('course' => $this->course->id);
+ $record = array('course' => $this->course);
$options = array('section' => $this->get_target_section());
$pagegenerator->create_instance($record, $options);
$this->dot($i, $number);
// Create resource with default textfile only.
$resourcegenerator = $this->generator->get_plugin_generator('mod_resource');
- $record = array('course' => $this->course->id,
+ $record = array('course' => $this->course,
'name' => get_string('smallfiles', 'tool_generator'));
$options = array('section' => 0);
$resource = $resourcegenerator->create_instance($record, $options);
$resourcegenerator = $this->generator->get_plugin_generator('mod_resource');
for ($i = 0; $i < $count; $i++) {
// Create resource.
- $record = array('course' => $this->course->id,
+ $record = array('course' => $this->course,
'name' => get_string('bigfile', 'tool_generator', $i));
$options = array('section' => $this->get_target_section());
$resource = $resourcegenerator->create_instance($record, $options);
// Create empty forum.
$forumgenerator = $this->generator->get_plugin_generator('mod_forum');
- $record = array('course' => $this->course->id,
+ $record = array('course' => $this->course,
'name' => get_string('pluginname', 'forum'));
$options = array('section' => 0);
$forum = $forumgenerator->create_instance($record, $options);
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013091201;
-$plugin->requires = 2013090200;
+$plugin->version = 2013110500;
+$plugin->requires = 2013110500;
$plugin->component = 'tool_generator';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'tool_health'; // Full name of the plugin (used for diagnostics)
$plugin->maturity = MATURITY_ALPHA; // this version's maturity level
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'tool_innodb'; // Full name of the plugin (used for diagnostics)
$fp = get_file_packer('application/zip');
$files = $fp->extract_to_pathname($zipfilepath, $targetdir);
- if ($files) {
- if (!empty($rootdir)) {
- $files = $this->rename_extracted_rootdir($targetdir, $rootdir, $files);
- }
- return $files;
-
- } else {
+ if (!$files) {
return array();
}
+
+ if (!empty($rootdir)) {
+ $files = $this->rename_extracted_rootdir($targetdir, $rootdir, $files);
+ }
+
+ // Sometimes zip may not contain all parent directories, add them to make it consistent.
+ foreach ($files as $path => $status) {
+ if ($status !== true) {
+ continue;
+ }
+ $parts = explode('/', trim($path, '/'));
+ while (array_pop($parts)) {
+ if (empty($parts)) {
+ break;
+ }
+ $dir = implode('/', $parts).'/';
+ if (!isset($files[$dir])) {
+ $files[$dir] = true;
+ }
+ }
+ }
+
+ return $files;
}
/**
$this->assertEquals(1, preg_match('~^site=(.+)$~', $query, $matches));
$site = rawurldecode($matches[1]);
$site = json_decode(base64_decode($site), true);
- $this->assertEquals('array', gettype($site));
+ $this->assertInternalType('array', $site);
$this->assertEquals(3, count($site));
$this->assertSame('Nasty site', $site['fullname']);
$this->assertSame('file:///etc/passwd', $site['url']);
$installer = tool_installaddon_installer::instance();
$files = $installer->extract_installfromzip_file($sourcedir.'/testinvalidroot.zip', $contentsdir, 'fixed_root');
- $this->assertEquals('array', gettype($files));
- $this->assertEquals(4, count($files));
+ $this->assertInternalType('array', $files);
+ $this->assertCount(4, $files);
$this->assertSame(true, $files['fixed_root/']);
$this->assertSame(true, $files['fixed_root/lang/']);
$this->assertSame(true, $files['fixed_root/lang/en/']);
* @copyright 2013 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class tool_installaddon_validator_test extends basic_testcase {
+class tool_installaddon_validator_testcase extends basic_testcase {
public function test_validate_files_layout() {
$fixtures = dirname(__FILE__).'/fixtures';
$this->assertEquals('foobar', $validator->get_rootdir());
$this->assertTrue($this->has_message($validator->get_messages(), $validator::INFO, 'rootdir', 'foobar'));
$versionphpinfo = $validator->get_versionphp_info();
- $this->assertEquals('array', gettype($versionphpinfo));
- $this->assertEquals(4, count($versionphpinfo));
+ $this->assertInternalType('array', $versionphpinfo);
+ $this->assertCount(4, $versionphpinfo);
$this->assertEquals(2013031900, $versionphpinfo['version']);
$this->assertEquals(2013031200, $versionphpinfo['requires']);
$this->assertEquals('local_foobar', $versionphpinfo['component']);
$this->assertEquals('testable_tool_installaddon_validator', get_class($validator));
$info = $validator->testable_parse_version_php($fixtures.'/version1.php');
- $this->assertEquals('array', gettype($info));
- $this->assertEquals(7, count($info));
+ $this->assertInternalType('array', $info);
+ $this->assertCount(7, $info);
$this->assertEquals('block_foobar', $info['plugin->component']); // Later in the file.
$this->assertEquals('2013010100', $info['plugin->version']); // Numeric wins over strings.
$this->assertEquals('2012122401', $info['plugin->requires']); // Commented.
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'tool_installaddon';
-$plugin->version = 2013050100;
-$plugin->requires = 2013050100;
+$plugin->version = 2013110500;
+$plugin->requires = 2013110500;
$plugin->maturity = MATURITY_STABLE;
$string['pluginname'] = 'Language packs';
$string['purgestringcaches'] = 'Purge string caches';
$string['remotelangnotavailable'] = 'Because Moodle cannot connect to download.moodle.org, it is not possible for language packs to be installed automatically. Please download the appropriate ZIP file(s) from <a href="http://download.moodle.org/langpack/">download.moodle.org/langpack</a>, copy them to your {$a} directory and unzip them manually.';
-$string['uninstall'] = 'Uninstall selected language pack(s)';
+$string['uninstall'] = 'Uninstall selected language pack';
$string['uninstallconfirm'] = 'You are about to completely uninstall language pack {$a}, are you sure?';
$string['updatelangs'] = 'Update all installed language packs';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'tool_langimport'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'tool_multilangupgrade'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'tool_phpunit'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050200; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'tool_profiling'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100;
-$plugin->requires = 2013050100;
+$plugin->version = 2013110500;
+$plugin->requires = 2013110500;
$plugin->component = 'tool_qeupgradehelper'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'tool_replace'; // Full name of the plugin (used for diagnostics)
$plugin->maturity = MATURITY_ALPHA; // this version's maturity level
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100;
-$plugin->requires = 2013050100;
+$plugin->version = 2013110500;
+$plugin->requires = 2013110500;
$plugin->component = 'tool_spamcleaner'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100;
-$plugin->requires = 2013050100;
+$plugin->version = 2013110500;
+$plugin->requires = 2013110500;
$plugin->component = 'tool_timezoneimport'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'tool_unsuproles'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013070200; // The current plugin version (Date: YYYYMMDDXX).
-$plugin->requires = 2013062100; // Requires this Moodle version.
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->requires = 2013110500; // Requires this Moodle version.
$plugin->component = 'tool_uploadcourse'; // Full name of the plugin (used for diagnostics).
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013061400; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'tool_uploaduser'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'tool_xmldb'; // Full name of the plugin (used for diagnostics)
echo $OUTPUT->heading('<a href="'.$securewwwroot.'/user/editadvanced.php?id=-1">'.get_string('addnewuser').'</a>');
}
if (!empty($table)) {
+ echo html_writer::start_tag('div', array('class'=>'no-overflow'));
echo html_writer::table($table);
+ echo html_writer::end_tag('div');
echo $OUTPUT->paging_bar($usercount, $page, $perpage, $baseurl);
if (has_capability('moodle/user:create', $sitecontext)) {
echo $OUTPUT->heading('<a href="'.$securewwwroot.'/user/editadvanced.php?id=-1">'.get_string('addnewuser').'</a>');
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013091700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_cas'; // Full name of the plugin (used for diagnostics)
-$plugin->dependencies = array('auth_ldap' => 2013052100);
+$plugin->dependencies = array('auth_ldap' => 2013110500);
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_db'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_email'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_fc'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_imap'; // Full name of the plugin (used for diagnostics)
$this->resetAfterTest();
- $this->setAdminUser();
-
- $user = clone($USER);
-
- // The USER variable no longer stores the password hash, so set it here.
- $user->password = 'password';
+ $this->assertFalse(isloggedin());
+ $user = $DB->get_record('user', array('username'=>'admin'));
// Note: we are just going to trigger the function that calls the event,
// not actually perform a LDAP login, for the sake of sanity.
$events = $sink->get_events();
$sink->close();
- // Unset the password now.
- unset($user->password);
-
- // Get the user from the DB and set the expected variables.
- $dbuser = $DB->get_record('user', array('id' => $user->id), '*', MUST_EXIST);
- $user->firstaccess = (int) $dbuser->firstaccess;
- $user->lastaccess = (int) $dbuser->lastaccess;
- $user->currentlogin = (int) $dbuser->currentlogin;
- $user->sesskey = sesskey();
- $user->lastcourseaccess = array();
- $user->currentcourseaccess = array();
- $user->groupmember = array();
- $user->profile = array();
- $user->preference = array(
- '_lastloaded' => time()
- );
-
// Check that the event is valid.
$this->assertCount(2, $events);
$event = $events[0];
$this->assertEquals('user', $event->objecttable);
$this->assertEquals('2', $event->objectid);
$this->assertEquals(context_system::instance()->id, $event->contextid);
- $this->assertEquals($user, $event->get_record_snapshot('user', 2));
$expectedlog = array(SITEID, 'user', 'login', 'view.php?id=' . $USER->id . '&course=' . SITEID, $user->id,
0, $user->id);
$this->assertEventLegacyLogData($expectedlog, $event);
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013052100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_ldap'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_manual'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_mnet'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_nntp'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_nologin'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_none'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_pam'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_pop3'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_radius'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_shibboleth'; // Full name of the plugin (used for diagnostics)
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2013050100; // Requires this Moodle version
+$plugin->version = 2013110500; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'auth_webservice'; // Full name of the plugin (used for diagnostics)
const OPERATION_RESTORE ='restore';// We are performing one restore
// Version (to keep CFG->backup_version (and release) updated automatically)
- const VERSION = 2013050100;
+ const VERSION = 2013110500;
const RELEASE = '2.6';
}
public static function set_state_running($running = true) {
if ($running === true) {
if (self::get_automated_backup_state() === self::STATE_RUNNING) {
- throw new backup_exception('backup_automated_already_running');
+ throw new backup_helper_exception('backup_automated_already_running');
}
set_config('backup_auto_running', '1', 'backup');
} else {
Background:
Given the following "courses" exists:
- | fullname | shortname | category |
- | Course 1 | C1 | 0 |
+ | fullname | shortname | category | numsections |
+ | Course 1 | C1 | 0 | 10 |
+ | Course 2 | C2 | 0 | 2 |
+ And the following "activities" exists:
+ | activity | course | idnumber | name | intro | section |
+ | assign | C2 | assign1 | Test assign | Assign description | 1 |
+ | data | C2 | data1 | Test data | Database description | 2 |
And I log in as "admin"
@javascript
And I click on "Continue" "button" in the ".bcs-current-course" "css_element"
And "//div[contains(concat(' ', normalize-space(@class), ' '), ' fitem ')][contains(., 'Include calendar events')]/descendant::img" "xpath_element" should exists
And I check "Include course logs"
- And I press "Cancel"
- And I click on "Cancel" "button" in the "Cancel backup" "dialogue"
+ And I press "Next"
+
+ @javascript
+ Scenario: Backup a course without blocks
+ When I backup "Course 1" course using this options:
+ | id_setting_root_blocks | 0 |
+ Then I should see "Course backup area"
+
+ @javascript
+ Scenario: Backup selecting just one section
+ When I backup "Course 2" course using this options:
+ | Filename | test_backup.mbz |
+ | setting_section_section_2_userinfo | 0 |
+ | setting_section_section_2_included | 0 |
+ | setting_section_section_4_userinfo | 0 |
+ | setting_section_section_4_included | 0 |
+ Then I should see "Course backup area"
+ And I click on "Restore" "link" in the "test_backup.mbz" "table_row"
+ And I should not see "Section 2"
+ And I press "Continue"
+ And I click on "Continue" "button" in the ".bcs-current-course" "css_element"
+ And I press "Next"
+ And I should see "Test assign"
+ And I should not see "Test data"
And I add a "Database" to section "1" and I fill the form with:
| Name | Test database name |
| Description | Test database description |
- And I click on "Actions" "link" in the "Test database name" activity
+ And I open "Test database name" actions menu
When I click on "Duplicate" "link" in the "Test database name" activity
- And I press "Continue"
- And I press "Edit the new copy"
+ And I open "Test database name" actions menu
+ And I click on "Edit settings" "link" in the "Test database name" activity
+ And I fill the moodle form with:
+ | Name | Original database name |
+ And I press "Save and return to course"
+ And I open "Test database name" actions menu
+ And I click on "Edit settings" "link" in the "Test database name" activity
And I fill the moodle form with:
| Name | Duplicated database name |
| Description | Duplicated database description |
And I press "Save and return to course"
- Then I should see "Test database name" in the "#section-1" "css_element"
+ Then I should see "Original database name" in the "#section-1" "css_element"
And I should see "Duplicated database name" in the "#section-1" "css_element"
- And "Test database name" "link" should appear before "Duplicated database name" "link"
+ And "Original database name" "link" should appear before "Duplicated database name" "link"
| fullname | shortname | category | format | numsections | coursedisplay |
| Course 1 | C1 | 0 | topics | 15 | 1 |
| Course 2 | C2 | 0 | topics | 5 | 0 |
+ | Course 3 | C3 | 0 | topics | 2 | 0 |
+ And the following "activities" exists:
+ | activity | course | idnumber | name | intro | section |
+ | assign | C3 | assign1 | Test assign name | Assign description | 1 |
+ | data | C3 | data1 | Test database name | Database description | 2 |
And I log in as "admin"
And I follow "Course 1"
And I turn editing mode on
Then I should see "Course 1 restored in a new course"
And I should see "Community finder" in the "Community finder" "block"
And I should see "Test forum name"
- And I follow "Edit settings"
+ And I click on "Edit settings" "link" in the "Administration" "block"
And I expand all fieldsets
And the "id_format" field should match "Topics format" value
And the "Number of sections" field should match "15" value
@javascript
Scenario: Restore a backup into the same course
- When I backup "Course 1" course using this options:
+ When I backup "Course 3" course using this options:
| Filename | test_backup.mbz |
- And I merge "test_backup.mbz" backup into the current course using this options:
+ And I restore "test_backup.mbz" backup into "Course 2" course using this options:
+ | setting_section_section_3_included | 0 |
+ | setting_section_section_3_userinfo | 0 |
| setting_section_section_5_included | 0 |
| setting_section_section_5_userinfo | 0 |
- Then I should see "Course 1"
- And I should not see "Section 3"
- And I should see "Community finder" in the "Community finder" "block"
- And I should see "Test forum name"
+ Then I should see "Course 2"
+ And I should see "Test assign name"
+ And I should not see "Test database name"
@javascript
Scenario: Restore a backup into the same course removing it's contents before that
When I restore "test_backup.mbz" backup int