Merged block upgrade fix from stable
This commit is contained in:
@@ -37,6 +37,7 @@ global $CFG;
|
||||
COMMENT = 'To register and update all the available blocks'");
|
||||
}
|
||||
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ global $CFG;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
+14
-9
@@ -9,6 +9,11 @@ define('BLOCK_MOVE_RIGHT', 0x02);
|
||||
define('BLOCK_MOVE_UP', 0x04);
|
||||
define('BLOCK_MOVE_DOWN', 0x08);
|
||||
|
||||
define('BLOCKS_DEFAULT_SITE', 'site_main_menu,admin,course_list:course_summary,calendar_month');
|
||||
define('BLOCKS_DEFAULT_SOCIAL', 'participants,search_forums,calendar_month,calendar_upcoming,social_activities,recent_activity,admin,course_list');
|
||||
define('BLOCKS_DEFAULT_TOPICS', 'participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity');
|
||||
define('BLOCKS_DEFAULT_WEEKS', 'participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity');
|
||||
|
||||
function block_formats_to_array($formatstring) {
|
||||
$retval = array();
|
||||
|
||||
@@ -691,13 +696,8 @@ function upgrade_blocks_plugins($continueto) {
|
||||
//Iterate over each course
|
||||
if ($courses = get_records("course")) {
|
||||
foreach ($courses as $course) {
|
||||
//Dependig of the format, insert some values
|
||||
if ($course->format == "social") {
|
||||
$blockinfo = blocks_get_default_blocks ($course->id, "participants,search_forums,calendar_month,calendar_upcoming,social_activities,recent_activity,admin,course_list");
|
||||
} else {
|
||||
//For topics and weeks formats (default built in the function)
|
||||
$blockinfo = blocks_get_default_blocks($course->id);
|
||||
}
|
||||
//Depending of the format, insert some values
|
||||
$blockinfo = blocks_get_default_blocks ($course->id, constant('BLOCKS_DEFAULT_'.strtoupper($course->format)));
|
||||
if ($CFG->debug) {
|
||||
echo 'Updating blockinfo for course: '.$course->shortname.'('.$blockinfo.')<br>';
|
||||
}
|
||||
@@ -705,6 +705,11 @@ function upgrade_blocks_plugins($continueto) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($CFG->siteblocksadded)) { /// This is a once-off hack to make a proper upgrade
|
||||
blocks_get_default_blocks(SITEID, BLOCKS_DEFAULT_SITE); // Add blockinfo to the site course
|
||||
delete_records('config', 'name', 'siteblocksadded');
|
||||
}
|
||||
|
||||
if (!empty($updated_blocks)) {
|
||||
print_continue($continueto);
|
||||
die;
|
||||
@@ -833,7 +838,7 @@ function block_get_name_by_id ($blockid) {
|
||||
//will be converted to their blockids equivalent. If a course is specified
|
||||
//then the function will update the field too!
|
||||
|
||||
function blocks_get_default_blocks ($courseid = NULL, $blocknames="") {
|
||||
function blocks_get_default_blocks ($courseid = NULL, $blocknames = '') {
|
||||
|
||||
global $CFG;
|
||||
|
||||
@@ -841,7 +846,7 @@ function blocks_get_default_blocks ($courseid = NULL, $blocknames="") {
|
||||
if (!empty($CFG->defaultblocks)) {
|
||||
$blocknames = $CFG->defaultblocks;
|
||||
} else {
|
||||
$blocknames = "participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity";
|
||||
$blocknames = BLOCKS_DEFAULT_WEEKS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-4
@@ -762,10 +762,7 @@ function main_upgrade($oldversion=0) {
|
||||
}
|
||||
|
||||
if ($oldversion < 2004052800) { /// First version tagged "1.4 development", version.php 1.227
|
||||
// Add blockinfo to the site course
|
||||
require_once($CFG->dirroot.'/lib/blocklib.php');
|
||||
$site = get_site();
|
||||
blocks_get_default_blocks($site->id, BLOCK_SITE_DEFAULT);
|
||||
set_config('siteblocksadded', true); /// This will be used later by the block upgrade
|
||||
}
|
||||
|
||||
if ($oldversion < 2004053000) { /// set defaults for site course
|
||||
|
||||
@@ -504,10 +504,7 @@ function main_upgrade($oldversion=0) {
|
||||
}
|
||||
|
||||
if ($oldversion < 2004052800) { /// First version tagged "1.4 development", version.php 1.227
|
||||
// Add blockinfo to the site course
|
||||
require_once($CFG->dirroot.'/lib/blocklib.php');
|
||||
$site = get_site();
|
||||
blocks_get_default_blocks($site->id, BLOCK_SITE_DEFAULT);
|
||||
set_config('siteblocksadded', true); /// This will be used later by the block upgrade
|
||||
}
|
||||
|
||||
if ($oldversion < 2004053000) { /// set defaults for site course
|
||||
|
||||
Reference in New Issue
Block a user