Permalink
Browse files

Merge remote branch 'origin/master' into rubric

Conflicts:
	lib/db/upgrade.php
	version.php
  • Loading branch information...
2 parents 8b9ada5 + 3a81b37 commit 01609c9ad94e5757cef2afc1ed637863cff83762 @mudrd8mz mudrd8mz committed Oct 24, 2011
Showing 466 changed files with 13,137 additions and 7,764 deletions.
View
@@ -442,4 +442,118 @@
</PHP_SETTING>
</PHP_SETTINGS>
</MOODLE>
+ <MOODLE version="2.2" requires="1.9">
+ <UNICODE level="required">
+ <FEEDBACK>
+ <ON_ERROR message="unicoderequired" />
+ </FEEDBACK>
+ </UNICODE>
+ <DATABASE level="required">
+ <VENDOR name="mysql" version="5.0.25">
+ <FEEDBACK>
+ <ON_ERROR message="mysql416required" />
+ </FEEDBACK>
+ </VENDOR>
+ <VENDOR name="postgres" version="8.3" />
+ <VENDOR name="mssql" version="9.0" />
+ <VENDOR name="odbc_mssql" version="9.0" />
+ <VENDOR name="mssql_n" version="9.0" />
+ <VENDOR name="oracle" version="10.2" />
+ <VENDOR name="sqlite" version="2.0" />
+ </DATABASE>
+ <PHP version="5.3.2" level="required">
+ </PHP>
+ <PHP_EXTENSIONS>
+ <PHP_EXTENSION name="iconv" level="required">
+ <FEEDBACK>
+ <ON_CHECK message="iconvrequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="mbstring" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="mbstringrecommended" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="curl" level="required">
+ <FEEDBACK>
+ <ON_CHECK message="curlrequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="openssl" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="opensslrecommended" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="tokenizer" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="tokenizerrecommended" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="xmlrpc" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="xmlrpcrecommended" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="soap" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="soaprecommended" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="ctype" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="ctyperequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="zip" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="ziprequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="gd" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="gdrecommended" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="simplexml" level="required">
+ <FEEDBACK>
+ <ON_CHECK message="simplexmlrequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="spl" level="required">
+ <FEEDBACK>
+ <ON_CHECK message="splrequired" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="pcre" level="required">
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="dom" level="required">
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="xml" level="required">
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="intl" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="intlrecommended" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="json" level="required">
+ </PHP_EXTENSION>
+ </PHP_EXTENSIONS>
+ <PHP_SETTINGS>
+ <PHP_SETTING name="memory_limit" value="40M" level="required">
+ <FEEDBACK>
+ <ON_ERROR message="settingmemorylimit" />
+ </FEEDBACK>
+ </PHP_SETTING>
+ <PHP_SETTING name="safe_mode" value="0" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="settingsafemode" />
+ </FEEDBACK>
+ </PHP_SETTING>
+ <PHP_SETTING name="file_uploads" value="1" level="optional">
+ <FEEDBACK>
+ <ON_CHECK message="settingfileuploads" />
+ </FEEDBACK>
+ </PHP_SETTING>
+ </PHP_SETTINGS>
+ </MOODLE>
</COMPATIBILITY_MATRIX>
@@ -65,13 +65,15 @@
// Get the question counts, and all the context information, for each
// context. That is, rows of these results can be used as $context objects.
+ $ctxpreload = context_helper::get_preload_record_columns_sql('con');
+ $ctxgroupby = implode(',', array_keys(context_helper::get_preload_record_columns('con')));
$counts = $DB->get_records_sql("
- SELECT qc.contextid, count(1) as numquestions, sum(hidden) as numhidden, con.id, con.contextlevel, con.instanceid, con.path, con.depth
+ SELECT qc.contextid, count(1) as numquestions, sum(hidden) as numhidden, $ctxpreload
FROM {question} q
JOIN {question_categories} qc ON q.category = qc.id
JOIN {context} con ON con.id = qc.contextid
$sqlqtypetest
- GROUP BY contextid, con.id, con.contextlevel, con.instanceid, con.path, con.depth
+ GROUP BY qc.contextid, $ctxgroupby
ORDER BY numquestions DESC, numhidden ASC, con.contextlevel ASC, con.id ASC", $params);
// Print the report heading.
@@ -94,8 +96,10 @@
$totalhidden = 0;
foreach ($counts as $count) {
// Work out a link for editing questions in this context.
- $contextname = print_context_name($count);
- $url = question_edit_url($count);
+ context_helper::preload_from_record($count);
+ $context = context::instance_by_id($count->contextid);
+ $contextname = $context->get_context_name();
+ $url = question_edit_url($context);
if ($url) {
$contextname = '<a href="' . $url . '" title="' .
get_string('editquestionshere', 'report_questioninstances') .
@@ -96,7 +96,8 @@
/// Put the contexts into a tree structure.
foreach ($contexts as $conid => $con) {
- $parentcontextid = get_parent_contextid($con);
+ $context = context::instance_by_id($conid);
+ $parentcontextid = get_parent_contextid($context);
if ($parentcontextid) {
$contexts[$parentcontextid]->children[] = $conid;
}
@@ -156,13 +157,13 @@ function print_report_tree($contextid, $contexts, $systemcontext, $fullname) {
}
// Pull the current context into an array for convinience.
- $context = $contexts[$contextid];
+ $context = context::instance_by_id($contextid);
// Print the context name.
- echo $OUTPUT->heading(print_context_name($contexts[$contextid]), 4, 'contextname');
+ echo $OUTPUT->heading($context->get_context_name(), 4, 'contextname');
// If there are any role assignments here, print them.
- foreach ($context->roleassignments as $ra) {
+ foreach ($contexts[$contextid]->roleassignments as $ra) {
$value = $ra->contextid . ',' . $ra->roleid;
$inputid = 'unassign' . $value;
@@ -118,8 +118,11 @@
$ADMIN->add('appearance', $temp);
// coursecontact is the person responsible for course - usually manages enrolments, receives notification, etc.
- $temp = new admin_settingpage('coursecontact', get_string('coursecontact', 'admin'));
+ $temp = new admin_settingpage('coursecontact', get_string('courses'));
$temp->add(new admin_setting_special_coursecontact());
+ $temp->add(new admin_setting_configcheckbox('courselistshortnames',
+ get_string('courselistshortnames', 'admin'),
+ get_string('courselistshortnames_desc', 'admin'), 0));
$ADMIN->add('appearance', $temp);
$temp = new admin_settingpage('ajax', get_string('ajaxuse'));
@@ -26,7 +26,7 @@
$temp->add(new admin_setting_configcheckbox('xmlstrictheaders', get_string('xmlstrictheaders', 'admin'), get_string('configxmlstrictheaders', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('debugsmtp', get_string('debugsmtp', 'admin'), get_string('configdebugsmtp', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('perfdebug', get_string('perfdebug', 'admin'), get_string('configperfdebug', 'admin'), '7', '15', '7'));
- $temp->add(new admin_setting_configcheckbox('debugstringids', get_string('debugstringids', 'admin'), get_string('configdebugstringids', 'admin'), 0));
+ $temp->add(new admin_setting_configcheckbox('debugstringids', get_string('debugstringids', 'admin'), get_string('debugstringids_desc', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('debugvalidators', get_string('debugvalidators', 'admin'), get_string('configdebugvalidators', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('debugpageinfo', get_string('debugpageinfo', 'admin'), get_string('configdebugpageinfo', 'admin'), 0));
$ADMIN->add('development', $temp);
@@ -138,7 +138,8 @@
// Put the contexts into a tree structure.
foreach ($contexts as $conid => $con) {
- $parentcontextid = get_parent_contextid($con);
+ $context = context::instance_by_id($conid);
+ $parentcontextid = get_parent_contextid($context);
if ($parentcontextid) {
$contexts[$parentcontextid]->children[] = $conid;
}
@@ -196,7 +197,8 @@ function print_report_tree($contextid, $contexts, $allroles) {
$url = "$CFG->wwwroot/$CFG->admin/roles/override.php?contextid=$contextid";
$title = get_string('changeoverrides', 'tool_capability');
}
- echo '<h3><a href="' . $url . '" title="' . $title . '">', print_context_name($contexts[$contextid]), '</a></h3>';
+ $context = context::instance_by_id($contextid);
+ echo '<h3><a href="' . $url . '" title="' . $title . '">', $context->get_context_name(), '</a></h3>';
// If there are any role overrides here, print them.
if (!empty($contexts[$contextid]->rolecapabilities)) {
@@ -746,6 +746,52 @@ protected function revert_global_user_id() {
}
/**
+ * Recreates the system context record in the 'context' table
+ *
+ * Once we have switched to test db, if we have recreated the
+ * context table and it's empty, it may be necessary to manually
+ * create the system context record if unittests are going to
+ * play with contexts.
+ *
+ * This is needed because the context_system::instance() method
+ * is exceptional and always requires the record to exist, never
+ * creating it :-( No problem for other contexts.
+ *
+ * Altenatively one complete install can be done, like
+ * {@see accesslib_test::test_everything_in_accesslib} does, but that's
+ * to much for some tests not requiring all the roles/caps/friends
+ * to be present.
+ *
+ * Ideally some day we'll move a lot of these UnitTests to a complete
+ * cloned installation with real data to play with. That day this
+ * won't be necessary anymore.
+ */
+ protected function create_system_context_record() {
+ global $DB;
+
+ // If, for any reason, the record exists, do nothing
+ if ($DB->record_exists('context', array('contextlevel'=>CONTEXT_SYSTEM))) {
+ return;
+ }
+
+ $record = new stdClass();
+ $record->contextlevel = CONTEXT_SYSTEM;
+ $record->instanceid = 0;
+ $record->depth = 1;
+ $record->path = null;
+ if (defined('SYSCONTEXTID')) {
+ $record->id = SYSCONTEXTID;
+ $DB->import_record('context', $record);
+ $DB->get_manager()->reset_sequence('context');
+ } else {
+ $record->id = $DB->insert_record('context', $record);
+ }
+ // fix path
+ $record->path = '/'.$record->id;
+ $DB->set_field('context', 'path', $record->path, array('id' => $record->id));
+ }
+
+ /**
* Check that the user has not forgotten to clean anything up, and if they
* have, display a rude message and clean it up for them.
*/
@@ -39,7 +39,9 @@
if ($shibbolethauth->user_login($frm->username, $frm->password)) {
- $USER = authenticate_user_login($frm->username, $frm->password);
+ $user = authenticate_user_login($frm->username, $frm->password);
+ enrol_check_plugins($user);
+ session_set_user($user);
$USER->loggedin = true;
$USER->site = $CFG->wwwroot; // for added security, store the site in the
@@ -75,9 +77,6 @@
}
}
- enrol_check_plugins($USER);
- load_all_capabilities(); /// This is what lets the user do anything on the site :-)
-
redirect($urltogo);
exit;
View
@@ -0,0 +1,10 @@
+This files describes API changes in /auth/* - plugins,
+information provided here is intended especially for developers.
+
+=== 2.2 ===
+
+required changes in code:
+* the correct sequence to set up global $USER is:
+ $user = get_complete_user_data('username', $username); // or $user = authenticate_user_login()
+ enrol_check_plugins($user);
+ session_set_user($user);
View
@@ -143,9 +143,9 @@
if ($CFG->useblogassociations && ($blogassociations = $DB->get_records('blog_association', array('blogid' => $entry->id)))) {
foreach ($blogassociations as $assocrec) {
- $contextrec = $DB->get_record('context', array('id' => $assocrec->contextid));
+ $context = get_context_instance_by_id($assocrec->contextid);
- switch ($contextrec->contextlevel) {
+ switch ($context->contextlevel) {
case CONTEXT_COURSE:
$entry->courseassoc = $assocrec->contextid;
break;
View
@@ -95,7 +95,7 @@ function definition() {
$a->modname = $mod->name;
$context = get_context_instance(CONTEXT_MODULE, $modid);
} else {
- $context = $DB->get_record('context', array('id' => $entry->modassoc));
+ $context = get_context_instance_by_id($entry->modassoc);
$cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
$a = new stdClass();
$a->modtype = $DB->get_field('modules', 'name', array('id' => $cm->module));
@@ -134,7 +134,7 @@ function validation($data, $files) {
// validate course association
if (!empty($data['courseassoc']) && has_capability('moodle/blog:associatecourse', $sitecontext)) {
- $coursecontext = $DB->get_record('context', array('id' => $data['courseassoc'], 'contextlevel' => CONTEXT_COURSE));
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $data['courseassoc']);
if ($coursecontext) {
if (!is_enrolled($coursecontext) and !is_viewing($coursecontext)) {
@@ -149,12 +149,12 @@ function validation($data, $files) {
if (!empty($data['modassoc'])) {
$modcontextid = $data['modassoc'];
- $modcontext = $DB->get_record('context', array('id' => $modcontextid, 'contextlevel' => CONTEXT_MODULE));
+ $modcontext = get_context_instance(CONTEXT_MODULE, $modcontextid);
if ($modcontext) {
// get context of the mod's course
$path = explode('/', $modcontext->path);
- $coursecontext = $DB->get_record('context', array('id' => $path[(count($path) - 2)]));
+ $coursecontext = get_context_instance_by_id($path[(count($path) - 2)]);
// ensure only one course is associated
if (!empty($data['courseassoc'])) {
View
@@ -247,10 +247,10 @@ public function print_html($return=false) {
// First find and show the associated course
foreach ($blogassociations as $assocrec) {
- $contextrec = $DB->get_record('context', array('id' => $assocrec->contextid));
- if ($contextrec->contextlevel == CONTEXT_COURSE) {
- $assocurl = new moodle_url('/course/view.php', array('id' => $contextrec->instanceid));
- $text = $DB->get_field('course', 'shortname', array('id' => $contextrec->instanceid)); //TODO: performance!!!!
+ $context = get_context_instance_by_id($assocrec->contextid);
+ if ($context->contextlevel == CONTEXT_COURSE) {
+ $assocurl = new moodle_url('/course/view.php', array('id' => $context->instanceid));
+ $text = $DB->get_field('course', 'shortname', array('id' => $context->instanceid)); //TODO: performance!!!!
$assocstr .= $OUTPUT->action_icon($assocurl, new pix_icon('i/course', $text), null, array(), true);
$hascourseassocs = true;
$assoctype = get_string('course');
@@ -259,15 +259,15 @@ public function print_html($return=false) {
// Now show mod association
foreach ($blogassociations as $assocrec) {
- $contextrec = $DB->get_record('context', array('id' => $assocrec->contextid));
+ $context = get_context_instance_by_id($assocrec->contextid);
- if ($contextrec->contextlevel == CONTEXT_MODULE) {
+ if ($context->contextlevel == CONTEXT_MODULE) {
if ($hascourseassocs) {
$assocstr .= ', ';
$hascourseassocs = false;
}
- $modinfo = $DB->get_record('course_modules', array('id' => $contextrec->instanceid));
+ $modinfo = $DB->get_record('course_modules', array('id' => $context->instanceid));
$modname = $DB->get_field('modules', 'name', array('id' => $modinfo->module));
$assocurl = new moodle_url('/mod/'.$modname.'/view.php', array('id' => $modinfo->id));
Oops, something went wrong. Retry.

0 comments on commit 01609c9

Please sign in to comment.