]> git.mjollnir.org Git - moodle.git/commitdiff
Dropping the use of MOODLE_PAGE_COURSE <gasp>!
authordefacer <defacer>
Mon, 31 Jan 2005 02:18:15 +0000 (02:18 +0000)
committerdefacer <defacer>
Mon, 31 Jan 2005 02:18:15 +0000 (02:18 +0000)
The new constant is PAGE_COURSE_VIEW, and it's more streamlined with the
new CSS-related ids for 1.5. There are great possibilities for the future
here, so we 're getting ready.

On the other hand, this has to be the ugliest hack I 've ever inflicted
on any program (look at pagelib.php). Thankfully it will only stay for just
a little while.

14 files changed:
admin/site.php
backup/backuplib.php
backup/restorelib.php
blocks/course_summary/block_course_summary.php
blocks/db/mysql.php
blocks/db/postgres7.php
blocks/quiz_results/block_quiz_results.php
blocks/quiz_results/config_instance.html
blocks/rss_client/block_rss_client.php
course/edit.php
course/view.php
index.php
lib/blocklib.php
lib/pagelib.php

index a0959c009df24a13934a1d87e68048ab640374a4..1b3e34615a6fdfade8c812602ff497c01da93e03 100644 (file)
@@ -41,7 +41,7 @@
                 if ($newid = insert_record('course', $form)) {
 
                     // Site created, add blocks for it
-                    $page = page_create_object(MOODLE_PAGE_COURSE, $newid);
+                    $page = page_create_object(PAGE_COURSE_VIEW, $newid);
                     blocks_repopulate_page($page); // Return value not checked because you can always edit later
 
                     $cat->name = get_string('miscellaneous');
index 5b36dc9b26d64ddff42056aec1a1de5ab871ae03..7187f65dd301898758442f613e12f9d2c39c235a 100644 (file)
         // Read all of the block table
         $blocks = blocks_get_record();
 
-        $page = page_create_object(MOODLE_PAGE_COURSE, $preferences->backup_course);
+        $page = page_create_object(PAGE_COURSE_VIEW, $preferences->backup_course);
 
         if ($instances = blocks_get_by_page($page)) {
             //Blocks open tag
index 5ff936b7ba033d9b0e393a9227c88a3f957f04bc..616e227eb30299e59ef8660b0f5b60d68ffd1e5e 100644 (file)
 
         $status = true;
 
-        delete_records('block_instance', 'pageid', $restore->course_id, 'pagetype', MOODLE_PAGE_COURSE);
+        delete_records('block_instance', 'pageid', $restore->course_id, 'pagetype', PAGE_COURSE_VIEW);
         if (empty($backup_block_format)) {     // This is a backup from Moodle < 1.5
             if (empty($blockinfo)) {
                 echo ' (pre 1.3)';                                 //debug
                 // Looks like it's from Moodle < 1.3. Let's give the course default blocks...
-                $newpage = page_create_object(MOODLE_PAGE_COURSE, $restore->course_id);
+                $newpage = page_create_object(PAGE_COURSE_VIEW, $restore->course_id);
                 blocks_repopulate_page($newpage);
             } else {
                 echo ' (1.3-1.4)';                                 //debug
                         }
                         $blockinstance->blockid  = $blockrecords[$blockname]->id;
                         $blockinstance->pageid   = $restore->course_id;
-                        $blockinstance->pagetype = MOODLE_PAGE_COURSE;
+                        $blockinstance->pagetype = PAGE_COURSE_VIEW;
                         $blockinstance->position = $blockposition;
                         $blockinstance->weight   = $blockweight;
                         if(!$status = insert_record('block_instance', $blockinstance)) {
index d0b20a25812247434624d187a40bdd9cb196dedb..fc4ed93f0c0641fb1bc69aebe7b117dc5452fd8d 100644 (file)
@@ -8,7 +8,7 @@ class block_course_summary extends block_base {
     }
 
     function specialization() {
-        if($this->instance->pagetype == MOODLE_PAGE_COURSE && $this->instance->pageid != SITEID) {
+        if($this->instance->pagetype == PAGE_COURSE_VIEW && $this->instance->pageid != SITEID) {
             $this->title = get_string('coursesummary', 'block_course_summary');
         }
     }
index 2123123d98fb08bdcf6eabd97c44b4b2dd687b95..efa69b947f93a1a3aa10d0e6074ec1bf6d6a2f14 100644 (file)
@@ -93,7 +93,7 @@ global $CFG;
                         $instance = new stdClass;
                         $instance->blockid    = abs($blk);
                         $instance->pageid     = $thiscourse->id;
-                        $instance->pagetype   = MOODLE_PAGE_COURSE;
+                        $instance->pagetype   = PAGE_COURSE_VIEW;
                         $instance->position   = BLOCK_POS_LEFT;
                         $instance->weight     = $weight;
                         $instance->visible    = ($blk > 0) ? 1 : 0;
@@ -107,7 +107,7 @@ global $CFG;
                         $instance = new stdClass;
                         $instance->blockid    = abs($blk);
                         $instance->pageid     = $thiscourse->id;
-                        $instance->pagetype   = MOODLE_PAGE_COURSE;
+                        $instance->pagetype   = PAGE_COURSE_VIEW;
                         $instance->position   = BLOCK_POS_RIGHT;
                         $instance->weight     = $weight;
                         $instance->visible    = ($blk > 0) ? 1 : 0;
index ec0acfac97d7c74b5f6c636c99ce8e98fadad870..bb730778c367fc5e06352ef2691ff38b2664f447 100644 (file)
@@ -91,7 +91,7 @@ global $CFG;
                         $instance = new stdClass;
                         $instance->blockid    = abs($blk);
                         $instance->pageid     = $thiscourse->id;
-                        $instance->pagetype   = MOODLE_PAGE_COURSE;
+                        $instance->pagetype   = PAGE_COURSE_VIEW;
                         $instance->position   = BLOCK_POS_LEFT;
                         $instance->weight     = $weight;
                         $instance->visible    = ($blk > 0) ? 1 : 0;
@@ -105,7 +105,7 @@ global $CFG;
                         $instance = new stdClass;
                         $instance->blockid    = abs($blk);
                         $instance->pageid     = $thiscourse->id;
-                        $instance->pagetype   = MOODLE_PAGE_COURSE;
+                        $instance->pagetype   = PAGE_COURSE_VIEW;
                         $instance->position   = BLOCK_POS_RIGHT;
                         $instance->weight     = $weight;
                         $instance->visible    = ($blk > 0) ? 1 : 0;
index dc11b116fd42f91db2c032944309f9468521a5ad..4804811856b95f826f47f486c21bef3b960dacb4 100644 (file)
@@ -26,7 +26,7 @@ class block_quiz_results extends block_base {
         $this->content->text = '';
         $this->content->footer = '';
 
-        if($this->instance->pagetype == MOODLE_PAGE_COURSE) {
+        if($this->instance->pagetype == PAGE_COURSE_VIEW) {
             // We need to see if we are monitoring a quiz 
             $quizid   = empty($this->config->quizid) ? 0 : $this->config->quizid;
             $courseid = $this->instance->pageid;
index 14d8f876384ff4b654b59e8ace0fbace76b4653e..264f936f8eca849d5b72b0f893673089d57fca15 100644 (file)
@@ -1,5 +1,5 @@
 <table cellpadding="9" cellspacing="0">
-<?php if($this->instance->pagetype == MOODLE_PAGE_COURSE) { ?>
+<?php if($this->instance->pagetype == PAGE_COURSE_VIEW) { ?>
 <tr valign="top">
     <td align="right">
         <?php print_string('config_select_quiz', 'block_quiz_results') ?>
@@ -21,7 +21,7 @@
         ?>
     </td>
 </tr>
-<?php } // end if($this->instance->pagetype == MOODLE_PAGE_COURSE) ?>
+<?php } // end if($this->instance->pagetype == PAGE_COURSE_VIEW) ?>
 <tr valign="top">
     <td align="right">
         <?php print_string('config_show_best', 'block_quiz_results') ?>
index f783f9a3d0cfcae45d064c6ce3a07223e2dad3c8..67df87edd5e2e1aeb2a125e1aeebc81f2f64cc74 100644 (file)
@@ -70,7 +70,7 @@ class block_rss_client extends block_base {
 
         $isteacher = false;
         $courseid = '';
-        if ($this->instance->pagetype == MOODLE_PAGE_COURSE) {
+        if ($this->instance->pagetype == PAGE_COURSE_VIEW) {
             $isteacher = isteacher($this->instance->pageid);
             $courseid = $this->instance->pageid;
         }
index 02a85642624ad0a64f295dd0a868935d30b435a5..c305a091cbaeb229f02a72ac16f55f408cf22c7a 100644 (file)
@@ -70,7 +70,7 @@
 
             if (!empty($course)) {
                 // Test for and remove blocks which aren't appropriate anymore
-                $page = page_create_object(MOODLE_PAGE_COURSE, $course->id);
+                $page = page_create_object(PAGE_COURSE_VIEW, $course->id);
                 blocks_remove_inappropriate($page);
 
                 // Update with the new data
@@ -91,7 +91,7 @@
                 if ($newcourseid = insert_record('course', $form)) {  // Set up new course
                     
                     // Setup the blocks
-                    $page = page_create_object(MOODLE_PAGE_COURSE, $newcourseid);
+                    $page = page_create_object(PAGE_COURSE_VIEW, $newcourseid);
                     blocks_repopulate_page($page); // Return value not checked because you can always edit later
 
                     $section = NULL;
index 58bd86073d6ec84ba77525b4d20893afc156d9fe..759b63747287e145687e45fc1acac7d5ffa1130e 100644 (file)
@@ -37,7 +37,7 @@
         $course->format = 'weeks';  // Default format is weeks
     }
 
-    $PAGE = page_create_object(MOODLE_PAGE_COURSE, $course->id);
+    $PAGE = page_create_object(PAGE_COURSE_VIEW, $course->id);
     $pageblocks = blocks_get_by_page($PAGE);
 
     if (!isset($USER->editing)) {
index 82b5161f5f6111c81d427907ad3e29e99f39fd57..48dfcfa8480b6e694959a3f307185762cd5b50f0 100644 (file)
--- a/index.php
+++ b/index.php
@@ -56,7 +56,7 @@
         $langmenu = popup_form ($CFG->wwwroot .'/index.php?lang=', $langs, 'chooselang', $currlang, '', '', '', true);
     }
 
-    $PAGE = page_create_object(MOODLE_PAGE_COURSE, SITEID);
+    $PAGE = page_create_object(PAGE_COURSE_VIEW, SITEID);
 
     $editing = $PAGE->user_is_editing();
 
index 2a8d2f3ccc9c4c36b425de4ee0bb858c190a03e4..3938d9b7166622716d384e600bf53bebe4ad536e 100644 (file)
@@ -854,14 +854,14 @@ function upgrade_blocks_plugins($continueto) {
         //Iterate over each course
         if ($courses = get_records('course')) {
             foreach ($courses as $course) {
-                $page = page_create_object(MOODLE_PAGE_COURSE, $course->id);
+                $page = page_create_object(PAGE_COURSE_VIEW, $course->id);
                 blocks_repopulate_page($page);
             }
         }
     }
 
     if (!empty($CFG->siteblocksadded)) {     /// This is a once-off hack to make a proper upgrade
-        $page = page_create_object(MOODLE_PAGE_COURSE, SITEID);
+        $page = page_create_object(PAGE_COURSE_VIEW, SITEID);
         blocks_repopulate_page($page);
         delete_records('config', 'name', 'siteblocksadded');
     }
index 1c30ed9349da30b52fb40133c7eb2089d5778380..b65afbb52fd2df96b71ac50c63e13118bc1bb864 100644 (file)
  * @package pages
  */
 
+
+// Start of dirty compatibility hack -- this will be here for a couple of weeks
+if(record_exists('block_instance', 'pagetype', 'course')) {
+    execute_sql('UPDATE '.$GLOBALS['CFG']->prefix.'block_instance SET pagetype = \'course-view\' WHERE pagetype = \'course\'', false);
+}
+// End of dirty compatibility hack -- remove this before 1.5 goes gold
+
 /// Constants
 
 /**
  * Definition of course page type.
  */
-define('MOODLE_PAGE_COURSE',    'course');
+define('PAGE_COURSE_VIEW', 'course-view');
 
 /**
  * Factory function page_create_object(). Called with a pagetype identifier and possibly with
@@ -59,7 +66,7 @@ function page_map_class($type, $classname = NULL) {
     
     if ($mappings === NULL) {
         $mappings = array(
-            MOODLE_PAGE_COURSE => 'page_course'
+            PAGE_COURSE_VIEW => 'page_course'
         );
     }
 
@@ -385,11 +392,11 @@ class page_course extends page_base {
     // This is hardwired here so the factory function page_create_object() can be sure there was no mistake.
     // Also, it doubles as a way to let others inquire about our type.
     function get_type() {
-        return MOODLE_PAGE_COURSE;
+        return PAGE_COURSE_VIEW;
     }
 
-    // This is like the "category" of a page of this "type". For example, if the type is MOODLE_PAGE_COURSE
-    // the format_name is the actual name of the course format. If the type were MOODLE_PAGE_ACTIVITY, then
+    // This is like the "category" of a page of this "type". For example, if the type is PAGE_COURSE_VIEW
+    // the format_name is the actual name of the course format. If the type were PAGE_ACTIVITY_VIEW, then
     // the format_name might be that activity's name etc.
     function get_format_name() {
         $this->init_full();