mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Merge branch 'wip-MDL-41384-master' of git://github.com/marinaglancy/moodle
This commit is contained in:
commit
845e11407f
@ -45,8 +45,11 @@ if ($id) {
|
|||||||
print_error('cannoteditsiteform');
|
print_error('cannoteditsiteform');
|
||||||
}
|
}
|
||||||
|
|
||||||
$course = course_get_format($id)->get_course();
|
// Login to the course and retrieve also all fields defined by course format.
|
||||||
|
$course = get_course($id);
|
||||||
require_login($course);
|
require_login($course);
|
||||||
|
$course = course_get_format($course)->get_course();
|
||||||
|
|
||||||
$category = $DB->get_record('course_categories', array('id'=>$course->category), '*', MUST_EXIST);
|
$category = $DB->get_record('course_categories', array('id'=>$course->category), '*', MUST_EXIST);
|
||||||
$coursecontext = context_course::instance($course->id);
|
$coursecontext = context_course::instance($course->id);
|
||||||
require_capability('moodle/course:update', $coursecontext);
|
require_capability('moodle/course:update', $coursecontext);
|
||||||
|
@ -237,14 +237,21 @@ abstract class format_base {
|
|||||||
if ($this->course === false) {
|
if ($this->course === false) {
|
||||||
$this->course = get_course($this->courseid);
|
$this->course = get_course($this->courseid);
|
||||||
$options = $this->get_format_options();
|
$options = $this->get_format_options();
|
||||||
|
$dbcoursecolumns = null;
|
||||||
foreach ($options as $optionname => $optionvalue) {
|
foreach ($options as $optionname => $optionvalue) {
|
||||||
if (!isset($this->course->$optionname)) {
|
if (isset($this->course->$optionname)) {
|
||||||
$this->course->$optionname = $optionvalue;
|
// Course format options must not have the same names as existing columns in db table "course".
|
||||||
} else {
|
if (!isset($dbcoursecolumns)) {
|
||||||
debugging('The option name '.$optionname.' in course format '.$this->format.
|
$dbcoursecolumns = $DB->get_columns('course');
|
||||||
' is invalid because the field with the same name exists in {course} table',
|
}
|
||||||
DEBUG_DEVELOPER);
|
if (isset($dbcoursecolumns[$optionname])) {
|
||||||
|
debugging('The option name '.$optionname.' in course format '.$this->format.
|
||||||
|
' is invalid because the field with the same name exists in {course} table',
|
||||||
|
DEBUG_DEVELOPER);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$this->course->$optionname = $optionvalue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->course;
|
return $this->course;
|
||||||
|
@ -85,7 +85,7 @@ defined('MOODLE_INTERNAL') || die();
|
|||||||
* @return bool always true
|
* @return bool always true
|
||||||
*/
|
*/
|
||||||
function xmldb_main_upgrade($oldversion) {
|
function xmldb_main_upgrade($oldversion) {
|
||||||
global $CFG, $USER, $DB, $OUTPUT, $SITE;
|
global $CFG, $USER, $DB, $OUTPUT, $SITE, $COURSE;
|
||||||
|
|
||||||
require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions
|
require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions
|
||||||
|
|
||||||
@ -316,6 +316,10 @@ function xmldb_main_upgrade($oldversion) {
|
|||||||
$dbman->drop_field($table, $field);
|
$dbman->drop_field($table, $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||||
|
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||||
|
$COURSE = clone($SITE);
|
||||||
|
|
||||||
upgrade_main_savepoint(true, 2012031500.02);
|
upgrade_main_savepoint(true, 2012031500.02);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,6 +451,10 @@ function xmldb_main_upgrade($oldversion) {
|
|||||||
$dbman->add_field($table, $field);
|
$dbman->add_field($table, $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||||
|
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||||
|
$COURSE = clone($SITE);
|
||||||
|
|
||||||
// Main savepoint reached
|
// Main savepoint reached
|
||||||
upgrade_main_savepoint(true, 2012050300.03);
|
upgrade_main_savepoint(true, 2012050300.03);
|
||||||
}
|
}
|
||||||
@ -563,6 +571,10 @@ function xmldb_main_upgrade($oldversion) {
|
|||||||
$dbman->add_field($table, $field);
|
$dbman->add_field($table, $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||||
|
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||||
|
$COURSE = clone($SITE);
|
||||||
|
|
||||||
// Add course_sections_availability to add completion & grade availability conditions
|
// Add course_sections_availability to add completion & grade availability conditions
|
||||||
$table = new xmldb_table('course_sections_availability');
|
$table = new xmldb_table('course_sections_availability');
|
||||||
|
|
||||||
@ -1334,6 +1346,10 @@ function xmldb_main_upgrade($oldversion) {
|
|||||||
// Launch change of type for field format
|
// Launch change of type for field format
|
||||||
$dbman->change_field_type($table, $field);
|
$dbman->change_field_type($table, $field);
|
||||||
|
|
||||||
|
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||||
|
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||||
|
$COURSE = clone($SITE);
|
||||||
|
|
||||||
// Main savepoint reached
|
// Main savepoint reached
|
||||||
upgrade_main_savepoint(true, 2012110200.00);
|
upgrade_main_savepoint(true, 2012110200.00);
|
||||||
}
|
}
|
||||||
@ -1386,6 +1402,10 @@ function xmldb_main_upgrade($oldversion) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||||
|
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||||
|
$COURSE = clone($SITE);
|
||||||
|
|
||||||
// Main savepoint reached
|
// Main savepoint reached
|
||||||
upgrade_main_savepoint(true, 2012110201.00);
|
upgrade_main_savepoint(true, 2012110201.00);
|
||||||
}
|
}
|
||||||
@ -1501,6 +1521,7 @@ function xmldb_main_upgrade($oldversion) {
|
|||||||
if ($SITE->format !== 'site') {
|
if ($SITE->format !== 'site') {
|
||||||
$DB->set_field('course', 'format', 'site', array('id' => $SITE->id));
|
$DB->set_field('course', 'format', 'site', array('id' => $SITE->id));
|
||||||
$SITE->format = 'site';
|
$SITE->format = 'site';
|
||||||
|
$COURSE->format = 'site';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main savepoint reached
|
// Main savepoint reached
|
||||||
@ -1989,6 +2010,10 @@ function xmldb_main_upgrade($oldversion) {
|
|||||||
$dbman->drop_field($table, $field);
|
$dbman->drop_field($table, $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||||
|
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||||
|
$COURSE = clone($SITE);
|
||||||
|
|
||||||
// Main savepoint reached.
|
// Main savepoint reached.
|
||||||
upgrade_main_savepoint(true, 2013040300.01);
|
upgrade_main_savepoint(true, 2013040300.01);
|
||||||
}
|
}
|
||||||
@ -2376,6 +2401,10 @@ function xmldb_main_upgrade($oldversion) {
|
|||||||
$dbman->add_field($table, $field);
|
$dbman->add_field($table, $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||||
|
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||||
|
$COURSE = clone($SITE);
|
||||||
|
|
||||||
// Define field calendartype to be added to user.
|
// Define field calendartype to be added to user.
|
||||||
$table = new xmldb_table('user');
|
$table = new xmldb_table('user');
|
||||||
$field = new xmldb_field('calendartype', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, 'gregorian');
|
$field = new xmldb_field('calendartype', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, 'gregorian');
|
||||||
@ -2400,6 +2429,10 @@ function xmldb_main_upgrade($oldversion) {
|
|||||||
$dbman->add_field($table, $field);
|
$dbman->add_field($table, $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||||
|
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||||
|
$COURSE = clone($SITE);
|
||||||
|
|
||||||
// Main savepoint reached.
|
// Main savepoint reached.
|
||||||
upgrade_main_savepoint(true, 2013091000.02);
|
upgrade_main_savepoint(true, 2013091000.02);
|
||||||
}
|
}
|
||||||
@ -2423,6 +2456,10 @@ function xmldb_main_upgrade($oldversion) {
|
|||||||
$dbman->drop_field($table, $field);
|
$dbman->drop_field($table, $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Since structure of 'course' table has changed we need to re-read $SITE from DB.
|
||||||
|
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||||
|
$COURSE = clone($SITE);
|
||||||
|
|
||||||
// Main savepoint reached.
|
// Main savepoint reached.
|
||||||
upgrade_main_savepoint(true, 2013091000.03);
|
upgrade_main_savepoint(true, 2013091000.03);
|
||||||
}
|
}
|
||||||
|
@ -1503,7 +1503,7 @@ function install_core($version, $verbose) {
|
|||||||
* @return void, may throw exception
|
* @return void, may throw exception
|
||||||
*/
|
*/
|
||||||
function upgrade_core($version, $verbose) {
|
function upgrade_core($version, $verbose) {
|
||||||
global $CFG;
|
global $CFG, $SITE, $DB, $COURSE;
|
||||||
|
|
||||||
raise_memory_limit(MEMORY_EXTRA);
|
raise_memory_limit(MEMORY_EXTRA);
|
||||||
|
|
||||||
@ -1534,6 +1534,10 @@ function upgrade_core($version, $verbose) {
|
|||||||
upgrade_main_savepoint($result, $version, false);
|
upgrade_main_savepoint($result, $version, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In case structure of 'course' table has been changed and we forgot to update $SITE, re-read it from db.
|
||||||
|
$SITE = $DB->get_record('course', array('id' => $SITE->id));
|
||||||
|
$COURSE = clone($SITE);
|
||||||
|
|
||||||
// perform all other component upgrade routines
|
// perform all other component upgrade routines
|
||||||
update_capabilities('moodle');
|
update_capabilities('moodle');
|
||||||
log_update_descriptions('moodle');
|
log_update_descriptions('moodle');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user