]> git.mjollnir.org Git - moodle.git/commitdiff
Merged block upgrade fix from stable
authormoodler <moodler>
Mon, 30 Aug 2004 16:26:00 +0000 (16:26 +0000)
committermoodler <moodler>
Mon, 30 Aug 2004 16:26:00 +0000 (16:26 +0000)
blocks/db/mysql.php
blocks/db/postgres7.php
lib/blocklib.php
lib/db/mysql.php
lib/db/postgres7.php

index fff5cb2ae9b21359d80633ffa77b9104ec6ca4b2..cdf3efb2b430579346f68a2fccbe3cd607dcee6b 100644 (file)
@@ -37,6 +37,7 @@ global $CFG;
                      COMMENT = 'To register and update all the available blocks'");
     }
 
+
     //Finally, return result
     return $result;
 }
index ecfa8e681565792de3e16a150a5f9a2725769f8e..174fcb194c1481e41ec9eed2bad803df9ca68920 100644 (file)
@@ -39,6 +39,7 @@ global $CFG;
 
     }
 
+
     //Finally, return result
     return $result;
 }
index 50318b94ea9fdbfaf1b12fa6868e20aa414a153b..f0fc6180b7da905eb4a6261400d05925f1051596 100644 (file)
@@ -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;
         }
     }
 
index 22f59e4b9f4de7c3675271cda7338d3b5ad0d2b4..4147c5e1660a38bb08e9044d95c142d0760107a0 100644 (file)
@@ -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
index 17a9595901db7d146d56c70f98250cf7f42f8460..ed2b431da598f55df3718769c0a360cccbcdc590 100644 (file)
@@ -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