Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/moodle/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Mar 30, 2012
2 parents 0f9b0bc + a280078 commit 404238a
Show file tree
Hide file tree
Showing 534 changed files with 12,636 additions and 8,087 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ CVS
/.project /.project
/.buildpath /.buildpath
/.cache /.cache
/phpunit.xml
3 changes: 3 additions & 0 deletions admin/cron.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
@header('Content-Type: text/plain; charset=utf-8'); @header('Content-Type: text/plain; charset=utf-8');
} }


// we do not want html markup in emulated CLI
@ini_set('html_errors', 'off');

// execute the cron // execute the cron
cron_run(); cron_run();


Expand Down
4 changes: 3 additions & 1 deletion admin/index.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
} }


if (empty($confirmupgrade)) { if (empty($confirmupgrade)) {
$a = new stdClass();
$a->oldversion = "$CFG->release ($CFG->version)"; $a->oldversion = "$CFG->release ($CFG->version)";
$a->newversion = "$release ($version)"; $a->newversion = "$release ($version)";
$strdatabasechecking = get_string('databasechecking', '', $a); $strdatabasechecking = get_string('databasechecking', '', $a);
Expand Down Expand Up @@ -307,7 +308,8 @@
} }


// at this stage there can be only one admin unless more were added by install - users may change username, so do not rely on that // at this stage there can be only one admin unless more were added by install - users may change username, so do not rely on that
$adminuser = get_complete_user_data('id', reset(explode(',', $CFG->siteadmins))); $adminids = explode(',', $CFG->siteadmins);
$adminuser = get_complete_user_data('id', reset($adminids));


if ($adminuser->password === 'adminsetuppending') { if ($adminuser->password === 'adminsetuppending') {
// prevent installation hijacking // prevent installation hijacking
Expand Down
6 changes: 3 additions & 3 deletions admin/mnet/peer_forms.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ function definition() {


if ($mnet_peer && !empty($mnet_peer->deleted)) { if ($mnet_peer && !empty($mnet_peer->deleted)) {
$radioarray = array(); $radioarray = array();
$radioarray[] = MoodleQuickForm::createElement('static', 'deletedinfo', '', $radioarray[] = $mform->createElement('static', 'deletedinfo', '',
$OUTPUT->container(get_string('deletedhostinfo', 'mnet'), 'deletedhostinfo')); $OUTPUT->container(get_string('deletedhostinfo', 'mnet'), 'deletedhostinfo'));
$radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('yes'), 1); $radioarray[] = $mform->createElement('radio', 'deleted', '', get_string('yes'), 1);
$radioarray[] = MoodleQuickForm::createElement('radio', 'deleted', '', get_string('no'), 0); $radioarray[] = $mform->createElement('radio', 'deleted', '', get_string('no'), 0);
$mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' ', ' '), false); $mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' ', ' '), false);
} else { } else {
$mform->addElement('hidden', 'deleted'); $mform->addElement('hidden', 'deleted');
Expand Down
4 changes: 3 additions & 1 deletion admin/roles/override.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@


// security first // security first
require_login($course, false, $cm); require_login($course, false, $cm);
$safeoverridesonly = false;
if (!has_capability('moodle/role:override', $context)) { if (!has_capability('moodle/role:override', $context)) {
require_capability('moodle/role:safeoverride', $context); require_capability('moodle/role:safeoverride', $context);
$safeoverridesonly = true;
} }
$PAGE->set_url($url); $PAGE->set_url($url);
$PAGE->set_context($context); $PAGE->set_context($context);
Expand Down Expand Up @@ -119,7 +121,7 @@
} }


// If we are actually overriding a role, create the table object, and save changes if appropriate. // If we are actually overriding a role, create the table object, and save changes if appropriate.
$overridestable = new override_permissions_table_advanced($context, $roleid, false); $overridestable = new override_permissions_table_advanced($context, $roleid, $safeoverridesonly);
$overridestable->read_submitted_permissions(); $overridestable->read_submitted_permissions();


if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) { if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
Expand Down
1 change: 1 addition & 0 deletions admin/settings/appearance.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
); );
$temp->add(new admin_setting_configselect('defaulthomepage', new lang_string('defaulthomepage', 'admin'), new lang_string('configdefaulthomepage', 'admin'), HOMEPAGE_SITE, $choices)); $temp->add(new admin_setting_configselect('defaulthomepage', new lang_string('defaulthomepage', 'admin'), new lang_string('configdefaulthomepage', 'admin'), HOMEPAGE_SITE, $choices));
$temp->add(new admin_setting_configcheckbox('navshowcategories', new lang_string('navshowcategories', 'admin'), new lang_string('confignavshowcategories', 'admin'), 1)); $temp->add(new admin_setting_configcheckbox('navshowcategories', new lang_string('navshowcategories', 'admin'), new lang_string('confignavshowcategories', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('navshowmycoursecategories', new lang_string('navshowmycoursecategories', 'admin'), new lang_string('navshowmycoursecategories_help', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('navshowallcourses', new lang_string('navshowallcourses', 'admin'), new lang_string('confignavshowallcourses', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('navshowallcourses', new lang_string('navshowallcourses', 'admin'), new lang_string('confignavshowallcourses', 'admin'), 0));
$temp->add(new admin_setting_configtext('navcourselimit',new lang_string('navcourselimit','admin'),new lang_string('confignavcourselimit', 'admin'),20,PARAM_INT)); $temp->add(new admin_setting_configtext('navcourselimit',new lang_string('navcourselimit','admin'),new lang_string('confignavcourselimit', 'admin'),20,PARAM_INT));
$temp->add(new admin_setting_configcheckbox('navlinkcoursesections', new lang_string('navlinkcoursesections', 'admin'), new lang_string('navlinkcoursesections_help', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('navlinkcoursesections', new lang_string('navlinkcoursesections', 'admin'), new lang_string('navlinkcoursesections_help', 'admin'), 0));
Expand Down
14 changes: 7 additions & 7 deletions admin/settings/plugins.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -477,6 +477,13 @@
$ADMIN->add('reportplugins', $page); $ADMIN->add('reportplugins', $page);
} }


/// Add all admin tools
if ($hassiteconfig) {
$ADMIN->add('modules', new admin_category('tools', new lang_string('tools', 'admin')));
$ADMIN->add('tools', new admin_externalpage('managetools', new lang_string('toolsmanage', 'admin'),
$CFG->wwwroot . '/' . $CFG->admin . '/tools.php'));
}

// Now add various admin tools // Now add various admin tools
foreach (get_plugin_list('tool') as $plugin => $plugindir) { foreach (get_plugin_list('tool') as $plugin => $plugindir) {
$settings_path = "$plugindir/settings.php"; $settings_path = "$plugindir/settings.php";
Expand All @@ -485,13 +492,6 @@
} }
} }


/// Add all admin tools
if ($hassiteconfig) {
$ADMIN->add('modules', new admin_category('tools', new lang_string('tools', 'admin')));
$ADMIN->add('tools', new admin_externalpage('managetools', new lang_string('toolsmanage', 'admin'),
$CFG->wwwroot . '/' . $CFG->admin . '/tools.php'));
}

/// Add all local plugins - must be always last! /// Add all local plugins - must be always last!
if ($hassiteconfig) { if ($hassiteconfig) {
$ADMIN->add('modules', new admin_category('localplugins', new lang_string('localplugins'))); $ADMIN->add('modules', new admin_category('localplugins', new lang_string('localplugins')));
Expand Down
13 changes: 0 additions & 13 deletions admin/settings/security.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -86,19 +86,6 @@
$ADMIN->add('security', $temp); $ADMIN->add('security', $temp);




// "modulesecurity" settingpage
$temp = new admin_settingpage('modulesecurity', new lang_string('modulesecurity', 'admin'));
$temp->add(new admin_setting_configselect('restrictmodulesfor', new lang_string('restrictmodulesfor', 'admin'), new lang_string('configrestrictmodulesfor', 'admin'), 'none', array('none' => new lang_string('nocourses'),
'all' => new lang_string('fulllistofcourses'),
'requested' => new lang_string('requestedcourses'))));
$temp->add(new admin_setting_configcheckbox('restrictbydefault', new lang_string('restrictbydefault', 'admin'), new lang_string('configrestrictbydefault', 'admin'), 0));
$temp->add(new admin_setting_configmultiselect_modules('defaultallowedmodules',
new lang_string('defaultallowedmodules', 'admin'),
new lang_string('configdefaultallowedmodules', 'admin')));
$ADMIN->add('security', $temp);



// "notifications" settingpage // "notifications" settingpage
$temp = new admin_settingpage('notifications', new lang_string('notifications', 'admin')); $temp = new admin_settingpage('notifications', new lang_string('notifications', 'admin'));
$temp->add(new admin_setting_configselect('displayloginfailures', new lang_string('displayloginfailures', 'admin'), new lang_string('configdisplayloginfailures', 'admin'), '', array('' => new lang_string('nobody'), $temp->add(new admin_setting_configselect('displayloginfailures', new lang_string('displayloginfailures', 'admin'), new lang_string('configdisplayloginfailures', 'admin'), '', array('' => new lang_string('nobody'),
Expand Down
93 changes: 93 additions & 0 deletions admin/tool/phpunit/cli/util.php
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,93 @@
<?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/>.

/**
* PHPUnit related utilities.
*
* Exit codes:
* 0 - success
* 1 - general error
* 130 - coding error
* 131 - configuration problem
* 133 - drop existing data before installing
*
* @package tool_phpunit
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define('PHPUNIT_CLI_UTIL', true);

require(__DIR__ . '/../../../../lib/phpunit/bootstrap.php');
require_once($CFG->libdir.'/phpunit/lib.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/upgradelib.php');
require_once($CFG->libdir.'/clilib.php');
require_once($CFG->libdir.'/pluginlib.php');
require_once($CFG->libdir.'/installlib.php');

// now get cli options
list($options, $unrecognized) = cli_get_params(
array(
'drop' => false,
'install' => false,
'buildconfig' => false,
'help' => false,
),
array(
'h' => 'help'
)
);

if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}

$drop = $options['drop'];
$install = $options['install'];
$buildconfig = $options['buildconfig'];

if ($options['help'] or (!$drop and !$install and !$buildconfig)) {
$help = "Various PHPUnit utility functions
Options:
--drop Drop database and dataroot
--install Install database
--buildconfig Build /phpunit.xml from /phpunit.xml.dist that includes suites for all plugins and core
-h, --help Print out this help
Example:
\$/usr/bin/php lib/phpunit/tool.php
";
echo $help;
die;
}

if ($buildconfig) {
phpunit_util::build_config_file();
exit(0);

} else if ($drop) {
phpunit_util::drop_site();
// note: we must stop here because $CFG is messed up and we can not reinstall, sorry
exit(0);

} else if ($install) {
phpunit_util::install_site();
exit(0);
}
40 changes: 40 additions & 0 deletions admin/tool/phpunit/index.php
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,40 @@
<?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/>.

/**
* PHPUnit info
*
* @package tool_phpunit
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define('NO_OUTPUT_BUFFERING', true);

require(dirname(__FILE__) . '/../../../config.php');
require_once($CFG->libdir.'/adminlib.php');

admin_externalpage_setup('toolphpunit');

echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('pluginname', 'tool_phpunit'));
echo $OUTPUT->box_start();

$info = file_get_contents("$CFG->libdir/phpunit/readme.md");
echo markdown_to_html($info);

echo $OUTPUT->box_end();
echo $OUTPUT->footer();
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,24 +15,11 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.


/** /**
* Popup message processor - lib file * Strings for component 'tool_phpunit'
* *
* @package message_popup * @package tool_phpunit
* @copyright 2008 Luis Rodrigues * @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */


/** $string['pluginname'] = 'PHPUnit tests';
* Register the popup message processor
*/
function popup_install(){
global $DB;

$result = true;

$provider = new stdClass();
$provider->name = 'popup';
$DB->insert_record('message_processors', $provider);
return $result;
}

20 changes: 6 additions & 14 deletions message/output/email/lib.php → admin/tool/phpunit/settings.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,22 +15,14 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.


/** /**
* Email message processor library file * PHPunit integration
* *
* @package message_email * @package tool_phpunit
* @copyright 2008 Luis Rodrigues and Martin Dougiamas * @copyright 2012 Petr Skoda {@link http://skodak.org}
* @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
*/ */


/**
* Register the processor
*/
function email_install(){
global $DB;
$result = true;


$provider = new stdClass(); defined('MOODLE_INTERNAL') || die;
$provider->name = 'email';
$DB->insert_record('message_processors', $provider); $ADMIN->add('development', new admin_externalpage('toolphpunit', get_string('pluginname', 'tool_phpunit'), "$CFG->wwwroot/$CFG->admin/tool/phpunit/index.php"));
return $result;
}
30 changes: 30 additions & 0 deletions admin/tool/phpunit/version.php
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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 info
*
* @package tool_phpunit
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2012030800; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2012030100; // Requires this Moodle version
$plugin->component = 'tool_phpunit'; // Full name of the plugin (used for diagnostics)

5 changes: 5 additions & 0 deletions admin/tool/unittest/dbtest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@


require(dirname(__FILE__) . '/../../../config.php'); require(dirname(__FILE__) . '/../../../config.php');
require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/adminlib.php');

// unfortunately outdated SimpleTest is not E_STRICT compatible
$CFG->debug = ($CFG->debug & ~E_STRICT);
error_reporting($CFG->debug);

require_once('simpletestlib.php'); require_once('simpletestlib.php');
require_once('simpletestcoveragelib.php'); require_once('simpletestcoveragelib.php');
require_once('ex_simple_test.php'); require_once('ex_simple_test.php');
Expand Down
12 changes: 7 additions & 5 deletions admin/tool/unittest/index.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@


require(dirname(__FILE__) . '/../../../config.php'); require(dirname(__FILE__) . '/../../../config.php');
require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/adminlib.php');
require_once('simpletestlib.php');
require_once('simpletestcoveragelib.php');
require_once('ex_simple_test.php');
require_once('ex_reporter.php');


// Always run the unit tests in developer debug mode. // Always run the unit tests in developer debug mode.
$CFG->debug = DEBUG_DEVELOPER; // unfortunately outdated SimpleTest is not E_STRICT compatible
$CFG->debug = (DEBUG_DEVELOPER & ~E_STRICT);
error_reporting($CFG->debug); error_reporting($CFG->debug);
raise_memory_limit(MEMORY_EXTRA); raise_memory_limit(MEMORY_EXTRA);


require_once('simpletestlib.php');
require_once('simpletestcoveragelib.php');
require_once('ex_simple_test.php');
require_once('ex_reporter.php');

// page parameters // page parameters
$path = optional_param('path', null, PARAM_PATH); $path = optional_param('path', null, PARAM_PATH);
$showpasses = optional_param('showpasses', false, PARAM_BOOL); $showpasses = optional_param('showpasses', false, PARAM_BOOL);
Expand Down
Loading

0 comments on commit 404238a

Please sign in to comment.