diff -r -u -N ./admin/roles/tabs.php ./admin/roles/tabs.php
--- ./admin/roles/tabs.php	2008-12-31 21:31:17.000000000 -0800
+++ ./admin/roles/tabs.php	2008-12-31 21:32:04.000000000 -0800
@@ -162,6 +162,12 @@
                 }
             }
             break;
+        
+        case CONTEXT_PAGE:
+            if ($page = get_record('page', 'id', $context->instanceid)) {
+                print_header($page->fullname, $page->fullname, build_navigation(array()));
+            }
+            break;
 
         default:
             print_error('unknowncontext');
diff -r -u -N ./lang/en_utf8/page.php ./lang/en_utf8/page.php
--- ./lang/en_utf8/page.php	1969-12-31 16:00:00.000000000 -0800
+++ ./lang/en_utf8/page.php	2008-03-26 16:05:38.000000000 -0700
@@ -0,0 +1,12 @@
+<?php
+
+$string['addnewpage'] = 'Add a new page';
+$string['deletepage'] = 'Delete a page';
+$string['deletepagecheck'] = 'Are you absolutely sure you want to completely delete this page and all the data it contains?';
+$string['editpagesettings'] = 'Edit page settings';
+$string['fulllistofpages'] = 'All pages';
+$string['page'] = 'Page';
+$string['pages'] = 'Pages';
+$string['pagemgmt'] = 'Add/edit pages';
+
+?>
diff -r -u -N ./lib/accesslib.php ./lib/accesslib.php
--- ./lib/accesslib.php	2008-12-31 20:49:30.000000000 -0800
+++ ./lib/accesslib.php	2008-12-31 21:24:23.000000000 -0800
@@ -146,6 +146,7 @@
 define('CONTEXT_GROUP', 60);
 define('CONTEXT_MODULE', 70);
 define('CONTEXT_BLOCK', 80);
+define('CONTEXT_PAGE', 90);
 
 // capability risks - see http://docs.moodle.org/en/Development:Hardening_new_Roles_system
 define('RISK_MANAGETRUST', 0x0001);
@@ -2124,6 +2125,9 @@
                 } else if ($parent = get_context_instance(CONTEXT_COURSE, $bi->pageid)) {
                     $basepath  = $parent->path;
                     $basedepth = $parent->depth;
+                } else if ($parent = get_context_instance(CONTEXT_PAGE, $bi->pageid)) {
+                    $basepath  = $parent->path;
+                    $basedepth = $parent->depth;
                 } else {
                     // parent course does not exist - course blocks can not exist without a course
                     $error_message = 'parent course does not exist - course blocks can not exist without a course';
@@ -2138,6 +2142,9 @@
         case CONTEXT_USER:
             // default to basepath
             break;
+        case CONTEXT_PAGE:
+            // default to basepath
+            break;
     }
 
     // if grandparents unknown, maybe rebuild_context_path() will solve it later
@@ -2330,6 +2337,17 @@
         $DB->execute($sql);
 
     }
+    
+    if (empty($contextlevel) or $contextlevel == CONTEXT_PAGE) {
+        $sql = "INSERT INTO {$CFG->prefix}context (contextlevel, instanceid)
+                SELECT ".CONTEXT_PAGE.", p.id
+                  FROM  {page} p
+                 WHERE NOT EXISTS (SELECT 'x'
+                                     FROM {$CFG->prefix}context cx
+                                    WHERE u.id = cx.instanceid AND cx.contextlevel=".CONTEXT_PAGE.")";
+        execute_sql($sql, $feedback);
+
+    }
 
     if ($buildpaths) {
         build_context_path(false);
@@ -2385,6 +2403,13 @@
                 LEFT OUTER JOIN {groups} t
                      ON c.instanceid = t.id
                WHERE t.id IS NULL AND c.contextlevel = ".CONTEXT_GROUP."
+            UNION
+              SELECT c.contextlevel,
+                     c.instanceid
+                FROM {context} c
+                LEFT OUTER JOIN {page} t
+                     ON c.instanceid = t.id
+               WHERE t.id IS NULL AND c.contextlevel = ".CONTEXT_PAGE."
            ";
     if ($rs = $DB->get_recordset_sql($sql)) {
         $DB->begin_sql();
@@ -2462,7 +2487,7 @@
 function get_context_instance($contextlevel, $instance=0) {
 
     global $context_cache, $context_cache_id, $DB;
-    static $allowed_contexts = array(CONTEXT_SYSTEM, CONTEXT_USER, CONTEXT_COURSECAT, CONTEXT_COURSE, CONTEXT_GROUP, CONTEXT_MODULE, CONTEXT_BLOCK);
+    static $allowed_contexts = array(CONTEXT_SYSTEM, CONTEXT_USER, CONTEXT_COURSECAT, CONTEXT_COURSE, CONTEXT_GROUP, CONTEXT_MODULE, CONTEXT_BLOCK, CONTEXT_PAGE);
 
     if ($contextlevel === 'clearcache') {
         // TODO: Remove for v2.0
@@ -3404,7 +3429,8 @@
             CONTEXT_COURSECAT => get_string('category'),
             CONTEXT_COURSE => get_string('course'),
             CONTEXT_MODULE => get_string('activitymodule'),
-            CONTEXT_BLOCK => get_string('block')
+            CONTEXT_BLOCK => get_string('block'),
+            CONTEXT_PAGE => get_string('page')
         );
     }
     return $strcontextlevels[$contextlevel];
@@ -3501,6 +3527,12 @@
                 }
             }
             break;
+        
+        case CONTEXT_PAGE:
+            if($page = get_record('page', 'id', $context->instanceid)) {
+                $name = format_string($page->fullname);
+            }
+            break;
 
         default:
             print_error('unknowncontext');
@@ -3549,6 +3581,10 @@
                 $url = $CFG->wwwroot . '/mod/' . $modname . '/view.php?id=' . $context->instanceid;
             }
             break;
+        
+        case CONTEXT_PAGE:
+            $url = $CFG->wwwroot . '/page/view.php?id=' . $context->instanceid;
+            break;
 
         case CONTEXT_SYSTEM:
         case CONTEXT_GROUP:
@@ -3634,6 +3670,12 @@
                       FROM {capabilities}
                      WHERE contextlevel IN (".CONTEXT_COURSE.",".CONTEXT_MODULE.",".CONTEXT_BLOCK.")";
         break;
+        
+        case CONTEXT_PAGE: // page context and below
+            $SQL = "SELECT *
+                      FROM {capabilities}
+                     WHERE contextlevel IN (".CONTEXT_PAGE.",".CONTEXT_BLOCK.")";
+        break;
 
         case CONTEXT_MODULE: // mod caps
             $cm = $DB->get_record('course_modules', array('id'=>$context->instanceid));
@@ -3809,6 +3851,7 @@
             LEFT JOIN {course} c ON ctx.contextlevel = 50 AND c.id = ctx.instanceid
             LEFT JOIN {course_modules} cm ON ctx.contextlevel = 70 AND cm.id = ctx.instanceid
             LEFT JOIN {block_instance} bi ON ctx.contextlevel = 80 AND bi.id = ctx.instanceid
+            LEFT JOIN {page} p ON ctx.contextlevel = 90 AND p.id = ctx.instanceid
             $select
             ORDER BY ctx.contextlevel, bi.position, COALESCE(cat.sortorder, c.sortorder, cm.section, bi.weight), u.lastname, u.firstname, cm.id
             ", $params);
@@ -3921,6 +3964,24 @@
 
             return $DB->get_records_sql($sql);
         break;
+        
+        case CONTEXT_PAGE:
+            // Find
+            // - blocks assigned to the page explicitly - easy
+            $sql = " SELECT ctx.*
+                     FROM {$CFG->prefix}context ctx
+                     WHERE ctx.path LIKE '{$context->path}/%'
+                           AND ctx.contextlevel IN (".CONTEXT_BLOCK.")
+            ";
+            $rs  = get_recordset_sql($sql);
+            $records = array();
+            while ($rec = rs_fetch_next_record($rs)) {
+                $records[$rec->id] = $rec;
+                $context_cache[$rec->contextlevel][$rec->instanceid] = $rec;
+            }
+            rs_close($rs);
+            return $records;
+        break;
 
         default:
             print_error('unknowcontext', '', '', $context->contextlevel);
@@ -4098,6 +4159,10 @@
                 $string = get_string('blockname', 'block_'.basename($component));
             }
         break;
+        
+        case CONTEXT_PAGE:
+            $string = get_string('page');
+        break;
 
         default:
             print_error('unknowncontext');
diff -r -u -N ./lib/db/access.php ./lib/db/access.php
--- ./lib/db/access.php	2009-01-04 22:05:09.000000000 -0800
+++ ./lib/db/access.php	2009-02-28 18:16:19.000000000 -0800
@@ -1314,7 +1314,70 @@
             'editingteacher' => CAP_ALLOW,
             'coursecreator' => CAP_ALLOW
         )
-    )
+    ),
+
+    
+    /***************************
+     **   Page System Roles   **
+     ***************************/
+    
+    'moodle/page:view' => array(
+
+        'riskbitmask' => RISK_PERSONAL,
+
+        'captype' => 'read',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'legacy' => array(
+            'guest' => CAP_ALLOW,
+            'user' => CAP_ALLOW,
+            'student' => CAP_ALLOW,
+            'teacher' => CAP_ALLOW,
+            'editingteacher' => CAP_ALLOW,
+            'coursecreator' => CAP_ALLOW,
+            'admin' => CAP_ALLOW
+        )
+    ),
+    
+    'moodle/page:create' => array(
+
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'legacy' => array(
+            'admin' => CAP_ALLOW
+        )
+    ),
+
+    'moodle/page:delete' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'legacy' => array(
+            'admin' => CAP_ALLOW
+        )
+    ),
+
+    'moodle/page:update' => array(
+
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'legacy' => array(
+            'admin' => CAP_ALLOW
+        )
+    ),
+    
+    'moodle/page:visibility' => array(
+
+        'riskbitmask' => RISK_SPAM | RISK_PERSONAL,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'legacy' => array(
+            'admin' => CAP_ALLOW
+        )
+    ),
 );
 
 
diff -r -u -N ./lib/db/install.xml ./lib/db/install.xml
--- ./lib/db/install.xml	2009-01-04 22:05:29.000000000 -0800
+++ ./lib/db/install.xml	2009-01-04 22:08:37.000000000 -0800
@@ -245,6 +245,24 @@
         <INDEX NAME="module" UNIQUE="false" FIELDS="module" PREVIOUS="course"/>
       </INDEXES>
     </TABLE>
+    <TABLE NAME="page" COMMENT="Main Content Pages" PREVIOUS="course_allowed_modules" NEXT="event">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="fullname"/>
+        <FIELD NAME="fullname" TYPE="char" LENGTH="254" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="shortname"/>
+        <FIELD NAME="shortname" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="fullname" NEXT="content"/>
+        <FIELD NAME="content" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="shortname" NEXT="visible"/>
+        <FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="content" NEXT="lang"/>
+        <FIELD NAME="lang" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="visible" NEXT="theme"/>
+        <FIELD NAME="theme" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="lang" NEXT="timecreated"/>
+        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="theme" NEXT="timemodified"/>
+        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
+      </KEYS>
+      <INDEXES>
+      </INDEXES>
+    </TABLE>
     <TABLE NAME="event" COMMENT="For everything with a time associated to it" PREVIOUS="course_allowed_modules" NEXT="cache_filters">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="name"/>
@@ -2044,4 +2062,4 @@
       </SENTENCES>
     </STATEMENT>
   </STATEMENTS>
-</XMLDB>
\ No newline at end of file
+</XMLDB>
diff -r -u -N ./page/delete.php ./page/delete.php
--- ./page/delete.php	1969-12-31 16:00:00.000000000 -0800
+++ ./page/delete.php	2009-02-28 14:35:46.000000000 -0800
@@ -0,0 +1,94 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// NOTICE OF COPYRIGHT                                                   //
+//                                                                       //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//          http://moodle.com                                            //
+//                                                                       //
+// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
+//                                                                       //
+// This program is free software; you can redistribute it and/or modify  //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation; either version 2 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// This program is distributed in the hope that it will be useful,       //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details:                          //
+//                                                                       //
+//          http://www.gnu.org/copyleft/gpl.html                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+require_once("../config.php");
+require_once("lib.php");
+
+$id     = required_param('id', PARAM_INT);              // page id
+$delete = optional_param('delete', '', PARAM_ALPHANUM); // delete confirmation hash
+
+require_login();
+
+if (!can_delete_page($id)) {
+    error('You do not have the permission to delete this page.');
+}
+
+$strdeletecourse = get_string("deletepage", 'page');
+$stradministration = get_string("administration");
+$strpages = get_string("pages", 'page');
+
+if (! $page = get_record("page", "id", $id)) {
+    error("Page ID was incorrect (can't find it)");
+}
+
+$navlinks = array();
+
+if (! $delete) {
+    $strdeletecheck = get_string("deletecheck", "", $page->shortname);
+    $strdeletecoursecheck = get_string("deletepagecheck", 'page');
+
+    $navlinks[] = array('name' => $stradministration, 'link' => "../$CFG->admin/index.php", 'type' => 'misc');
+    $navlinks[] = array('name' => $strpages, 'link' => "index.php", 'type' => 'misc');
+    $navlinks[] = array('name' => $strdeletecheck, 'link' => null, 'type' => 'misc');
+    $navigation = build_navigation($navlinks);
+
+    print_header("$SITE->shortname: $strdeletecheck", $SITE->fullname, $navigation);
+
+    notice_yesno("$strdeletecoursecheck<br /><br />" . format_string($page->fullname) .
+                 " (" . format_string($page->shortname) . ")",
+                 "delete.php?id=$page->id&amp;delete=".md5($page->timemodified)."&amp;sesskey=$USER->sesskey", "index.php");
+
+    print_footer();
+    exit;
+}
+
+if ($delete != md5($page->timemodified)) {
+    error("The check variable was wrong - try again");
+}
+
+if (!confirm_sesskey()) {
+    error(get_string('confirmsesskeybad', 'error'));
+}
+
+// OK checks done, delete the course now.
+$strdeletingcourse = get_string("deletingcourse", "", format_string($page->shortname));
+
+$navlinks[] = array('name' => $stradministration, 'link' => "../$CFG->admin/index.php", 'type' => 'misc');
+$navlinks[] = array('name' => $strpages, 'link' => "index.php", 'type' => 'misc');
+$navlinks[] = array('name' => $strdeletingcourse, 'link' => null, 'type' => 'misc');
+$navigation = build_navigation($navlinks);
+
+print_header("$SITE->shortname: $strdeletingcourse", $SITE->fullname, $navigation);
+
+print_heading($strdeletingcourse);
+
+delete_page($page->id);
+
+print_heading( get_string("deletedcourse", "", format_string($page->shortname)) );
+
+print_continue("index.php");
+
+print_footer();
+
+?>
diff -r -u -N ./page/edit_form.php ./page/edit_form.php
--- ./page/edit_form.php	1969-12-31 16:00:00.000000000 -0800
+++ ./page/edit_form.php	2008-04-23 18:47:18.000000000 -0700
@@ -0,0 +1,88 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// NOTICE OF COPYRIGHT                                                   //
+//                                                                       //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//          http://moodle.com                                            //
+//                                                                       //
+// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
+//                                                                       //
+// This program is free software; you can redistribute it and/or modify  //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation; either version 2 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// This program is distributed in the hope that it will be useful,       //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details:                          //
+//                                                                       //
+//          http://www.gnu.org/copyleft/gpl.html                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+require_once($CFG->libdir.'/formslib.php');
+
+class page_edit_form extends moodleform {
+
+    function definition() {
+        global $USER, $CFG;
+
+        $mform    =& $this->_form;
+
+/// form definition with new course defaults
+//--------------------------------------------------------------------------------
+        $mform->addElement('header','general', get_string('general', 'form'));
+
+        $mform->addElement('text','fullname', get_string('fullname'),'maxlength="254" size="50"');
+        $mform->setHelpButton('fullname', array('coursefullname', get_string('fullname')), true);
+        $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
+        $mform->setType('fullname', PARAM_MULTILANG);
+
+        $mform->addElement('text','shortname', get_string('shortname'),'maxlength="100" size="20"');
+        $mform->setHelpButton('shortname', array('courseshortname', get_string('shortname')), true);
+        $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
+        $mform->setType('shortname', PARAM_MULTILANG);
+
+        $mform->addElement('htmleditor','content', get_string('summary'), array('rows'=> '10', 'cols'=>'65'));
+        $mform->setHelpButton('content', array('text', get_string('helptext')), true);
+        $mform->addRule('content', get_string('missingsummary'), 'required', null, 'client');
+        $mform->setType('content', PARAM_RAW);
+
+        if (!empty($CFG->allowcoursethemes)) {
+            $themes=array();
+            $themes[''] = get_string('forceno');
+            $themes += get_list_of_themes();
+            $mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
+        }
+
+//--------------------------------------------------------------------------------
+        $mform->addElement('header','', get_string('language'));
+
+        $languages=array();
+        $languages[''] = get_string('forceno');
+        $languages += get_list_of_languages();
+        $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages);
+//--------------------------------------------------------------------------------
+        $this->add_action_buttons();
+//--------------------------------------------------------------------------------
+        $mform->addElement('hidden', 'id', null);
+        $mform->setType('id', PARAM_INT);
+    }
+
+    function definition_after_data() {
+        global $CFG;
+
+        $mform =& $this->_form;
+    }
+        
+
+/// perform some extra moodle validation
+    function validation($data, $files) {
+        $errors = parent::validation($data, $files);
+
+        return $errors;
+    }
+}
+?>
diff -r -u -N ./page/edit.php ./page/edit.php
--- ./page/edit.php	1969-12-31 16:00:00.000000000 -0800
+++ ./page/edit.php	2009-02-28 14:36:11.000000000 -0800
@@ -0,0 +1,119 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// NOTICE OF COPYRIGHT                                                   //
+//                                                                       //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//          http://moodle.com                                            //
+//                                                                       //
+// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
+//                                                                       //
+// This program is free software; you can redistribute it and/or modify  //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation; either version 2 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// This program is distributed in the hope that it will be useful,       //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details:                          //
+//                                                                       //
+//          http://www.gnu.org/copyleft/gpl.html                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+require_once('../config.php');
+require_once($CFG->dirroot.'/enrol/enrol.class.php');
+require_once($CFG->libdir.'/blocklib.php');
+require_once('lib.php');
+require_once('pagelib.php');
+require_once('edit_form.php');
+
+$id = optional_param('id', 0, PARAM_INT);       // page id
+
+
+/// basic access control checks
+if ($id) { // editing course
+    if (!$page = get_record('page', 'id', $id)) {
+        error('Page ID was incorrect');
+    }
+    //require_login($page->id);
+    require_capability('moodle/page:update', get_context_instance(CONTEXT_PAGE, $page->id));
+
+} else { // creating new course in this category
+    $page = null;
+    require_login();
+
+    require_capability('moodle/page:create', get_context_instance(CONTEXT_SYSTEM));
+}
+
+
+/// first create the form
+$editform = new page_edit_form('edit.php');
+// now override defaults if course already exists
+if (!empty($page)) {
+    $editform->set_data($page);
+}
+if ($editform->is_cancelled()){
+    if (empty($page)) {
+        redirect($CFG->wwwroot);
+    } else {
+        redirect($CFG->wwwroot.'/page/view.php?id='.$page->id);
+    }
+
+} else if ($data = $editform->get_data()) {
+
+    $data->timemodified = time();
+
+    if (empty($page)) {
+        if (!$page = create_page($data)) {
+            print_error('coursenotcreated');
+        }
+        
+        redirect($CFG->wwwroot."/page/view.php?id=$page->id");
+
+    } else {
+        if (!update_page($data)) {
+            print_error('coursenotupdated');
+        }
+
+        redirect($CFG->wwwroot."/page/view.php?id=$page->id");
+    }
+}
+
+
+/// Print the form
+
+$site = get_site();
+
+$streditcoursesettings = get_string("editpagesettings", 'page');
+$straddnewcourse = get_string("addnewpage", 'page');
+$stradministration = get_string("administration");
+$navlinks = array();
+
+if (!empty($page)) {
+    $navlinks[] = array('name' => $streditcoursesettings,
+                        'link' => null,
+                        'type' => 'misc');
+    $title = $streditcoursesettings;
+    $fullname = $page->fullname;
+} else {
+    $navlinks[] = array('name' => $stradministration,
+                        'link' => "$CFG->wwwroot/$CFG->admin/index.php",
+                        'type' => 'misc');
+    $navlinks[] = array('name' => $straddnewcourse,
+                        'link' => null,
+                        'type' => 'misc');
+    $title = "$site->shortname: $straddnewcourse";
+    $fullname = $site->fullname;
+}
+
+$navigation = build_navigation($navlinks);
+print_header($title, $fullname, $navigation, $editform->focus());
+print_heading($streditcoursesettings);
+
+$editform->display();
+
+print_footer();
+
+?>
diff -r -u -N ./page/index.php ./page/index.php
--- ./page/index.php	1969-12-31 16:00:00.000000000 -0800
+++ ./page/index.php	2008-08-27 16:40:05.000000000 -0700
@@ -0,0 +1,130 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// NOTICE OF COPYRIGHT                                                   //
+//                                                                       //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//          http://moodle.com                                            //
+//                                                                       //
+// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
+//                                                                       //
+// This program is free software; you can redistribute it and/or modify  //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation; either version 2 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// This program is distributed in the hope that it will be useful,       //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details:                          //
+//                                                                       //
+//          http://www.gnu.org/copyleft/gpl.html                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+require_once("../config.php");
+require_once("lib.php");
+
+$context = get_context_instance(CONTEXT_SYSTEM);
+
+require_login();
+
+if (!has_capability('moodle/page:update', $context)) {
+    redirect($CFG->wwwroot.'/');
+    exit;
+}
+
+$stradministration = get_string('administration');
+$strpages = get_string('pages', 'page');
+$stredit = get_string('edit');
+$strdelete = get_string('delete');
+$straction = get_string('action');
+
+
+/// From now on is all the admin/course creator functions
+
+/// Print headings
+
+if (has_capability('moodle/site:config', $context)) {
+    require_once($CFG->libdir.'/adminlib.php');
+    admin_externalpage_setup('pagemgmt');
+    admin_externalpage_print_header();
+} else {
+    print_header("$site->shortname: $strpages", $strpages,
+        build_navigation(array()), '', '', true);
+}
+
+print_heading($strpages);
+
+echo '<table class="generalbox editpage boxaligncenter"><tr class="header">';
+echo '<th class="header" scope="col">&nbsp;</th>';
+echo '<th class="header" scope="col">'.$stredit.'</th>';
+echo '</tr>';
+
+print_pages_edit();
+
+echo '</table>';
+
+echo '<div class="buttons">';
+
+
+if (has_capability('moodle/page:create', $context)) {  
+    // print create course link to first category
+    print_single_button('edit.php', array(), get_string('addnewpage', 'page'), 'get');
+}
+
+// admin page does not allow custom buttons in the navigation bar
+//    echo '<div class="singlebutton">';
+//    echo update_categories_button();
+//    echo '</div></div>';
+
+print_footer();
+
+function print_pages_edit() 
+{
+/// Recursive function to print all the categories ready for editing
+
+global $CFG, $USER;
+
+static $str = '';
+
+if (empty($str)) {
+    $str->edit     = get_string('edit');
+    $str->delete   = get_string('delete');
+    $str->hide     = get_string('hide');
+    $str->show     = get_string('show');
+}
+
+$pages = get_records('page');
+
+foreach ($pages as $page) {
+    $page->context = get_context_instance(CONTEXT_PAGE, $page->id);
+    
+    echo '<tr><td align="left" class="name">';
+    $linkcss = $page->visible ? '' : ' class="dimmed" ';
+    echo "<a {$linkcss} title=\"{$str->edit}\" href=\"{$CFG->wwwroot}/page/view.php?id={$page->id}\">".format_string($page->fullname)."</a>\r\n";
+    echo '</td>';
+    
+    echo '<td class="icons">';    /// Print little icons
+    
+    if (has_capability('moodle/page:update', $page->context)) {
+        echo "<a title=\"{$str->edit}\" href=\"edit.php?id={$page->id}\"><img src=\"{$CFG->pixpath}/i/edit.gif\" alt=\"{$str->edit}\" /></a>\r\n";
+    }
+
+    if (has_capability('moodle/page:delete', $page->context)) {
+        echo "<a title=\"{$str->delete}\" href=\"delete.php?id={$page->id}\"><img src=\"{$CFG->pixpath}/i/delete.png\" alt=\"{$str->delete}\" /></a>\r\n";
+    }
+
+    if (has_capability('moodle/page:visibility', $page->context)) {
+        if (!empty($page->visible)) {
+            echo "<a title=\"{$str->hide}\" href=\"view.php?hide=1&id={$page->id}&sesskey=".sesskey()."\"><img src=\"{$CFG->pixpath}/i/hide.gif\" alt=\"{$str->hide}\" /></a>\r\n";
+        } else {
+            echo "<a title=\"{$str->show}\" href=\"view.php?show=1&id={$page->id}&sesskey=".sesskey()."\"><img src=\"{$CFG->pixpath}/i/show.gif\" alt=\"{$str->show}\" /></a>\r\n";
+        }
+    }
+    
+    echo '</td>';
+    echo '</tr>';
+}
+}
+?>
diff -r -u -N ./page/lib.php ./page/lib.php
--- ./page/lib.php	1969-12-31 16:00:00.000000000 -0800
+++ ./page/lib.php	2009-02-28 14:38:54.000000000 -0800
@@ -0,0 +1,269 @@
+<?php  
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// NOTICE OF COPYRIGHT                                                   //
+//                                                                       //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//          http://moodle.com                                            //
+//                                                                       //
+// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
+//                                                                       //
+// This program is free software; you can redistribute it and/or modify  //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation; either version 2 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// This program is distributed in the hope that it will be useful,       //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details:                          //
+//                                                                       //
+//          http://www.gnu.org/copyleft/gpl.html                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+require_once('../config.php');
+
+function print_page_overview($pages) {
+
+    global $CFG, $USER;
+
+    $htmlarray = array();
+    if ($modules = get_records('modules')) {
+        foreach ($modules as $mod) {
+            if (file_exists(dirname(dirname(__FILE__)).'/mod/'.$mod->name.'/lib.php')) {
+                include_once(dirname(dirname(__FILE__)).'/mod/'.$mod->name.'/lib.php');
+                $fname = $mod->name.'_print_overview';
+                if (function_exists($fname)) {
+                    $fname($pages,$htmlarray);
+                }
+            }
+        }
+    }
+    foreach ($pages as $page) {
+        print_simple_box_start('center', '100%', '', 5, "coursebox");
+        $linkcss = '';
+        if (empty($page->visible)) {
+            $linkcss = 'class="dimmed"';
+        }
+        print_heading('<a title="'. format_string($page->fullname).'" '.$linkcss.' href="'.$CFG->wwwroot.'/page/view.php?id='.$page->id.'">'. format_string($page->fullname).'</a>');
+        if (array_key_exists($page->id,$htmlarray)) {
+            foreach ($htmlarray[$course->id] as $modname => $html) {
+                echo $html;
+            }
+        }
+        print_simple_box_end();
+    }
+}
+
+function print_pages() {
+    global $CFG;
+
+    $pages = get_records('page');
+    
+    if ($pages) {
+        echo '<ul class="unlist">';
+        foreach ($pages as $page) {
+            if ($page->visible == 1
+                || has_capability('moodle/page:viewhiddenpages',$page->context)) {
+                echo '<li>';
+                print_page($page);
+                echo "</li>\n";
+            }
+        }
+        echo "</ul>\n";
+    } else {
+        print_heading(get_string("nopagesyet"));
+        $context = get_context_instance(CONTEXT_SYSTEM);
+        if (has_capability('moodle/page:create', $context)) {
+            echo '<div class="addpagebutton">';
+            print_single_button($CFG->wwwroot.'/page/edit.php', array(), get_string("addnewpage"));
+            echo '</div>';
+        }
+    }
+}
+
+function print_page($page) {
+
+    global $CFG, $USER;
+
+    if (isset($page->context)) {
+        $context = $page->context;
+    } else {
+        $context = get_context_instance(CONTEXT_PAGE, $page->id);
+    }
+
+    $linkcss = $page->visible ? '' : ' class="dimmed" ';
+
+    print_container_start(true, 'info name', '');
+    echo "<a {$linkcss} href=\"{$CFG->wwwroot}/page/view.php?id={$page->id}\">".format_string($page->fullname)."</a>\r\n";
+    print_container_end();
+}
+
+/**
+ * Can the current user delete this page?
+ * @param int $pageid
+ * @return boolean
+ */
+function can_delete_page($pageid) {
+
+    $context = get_context_instance(CONTEXT_PAGE, $pageid);
+
+    return ( has_capability('moodle/page:delete', $context));
+}
+
+
+/* 
+ * Create a page and either return a $page object or false
+ *
+ * @param object $data  - all the data needed for an entry in the 'page' table
+ */
+function create_page($data) {
+    global $CFG, $USER;
+
+    $data->timecreated = time();
+
+    if ($newpageid = insert_record('page', $data)) {  // Set up new course
+
+        $page = get_record('page', 'id', $newpageid);
+
+        // Setup the blocks
+        $blocks = page_create_object(PAGE_STATIC_VIEW, $page->id);
+        blocks_repopulate_page($blocks); // Return value not checked because you can always edit later
+
+        return $page;
+    } 
+
+    return false;   // error
+}
+
+function delete_page($pageid) {
+    global $CFG, $USER;
+
+    $context = get_context_instance(CONTEXT_PAGE, $pageid);
+
+    if(has_capability('moodle/page:delete', $context))
+    {
+        delete_records("page", "id", $pageid);
+
+        if ($blocks = get_records_sql("SELECT *
+                                   FROM {$CFG->prefix}block_instance
+                                   WHERE pagetype = '".PAGE_STATIC_VIEW."'
+                                   AND pageid = $pageid")) {
+            if (delete_records('block_instance', 'pagetype', PAGE_STATIC_VIEW, 'pageid', $pageid)) {
+
+                require_once($CFG->libdir.'/blocklib.php');
+                foreach ($blocks as $block) {  /// Delete any associated contexts for this block
+
+                    delete_context(CONTEXT_BLOCK, $block->id);
+
+                    // fix for MDL-7164
+                    // Get the block object and call instance_delete()
+                    if (!$record = blocks_get_record($block->blockid)) {
+                        continue;
+                    }
+                    if (!$obj = block_instance($record->name, $block)) {
+                        continue;
+                    }
+                    // Return value ignored, in core mods this does not do anything, but just in case
+                    // third party blocks might have stuff to clean up
+                    // we execute this anyway
+                    $obj->instance_delete();
+
+                }
+            }
+        }
+    }
+}
+
+
+/* 
+ * Update a page and return true or false
+ *
+ * @param object $data  - all the data needed for an entry in the 'page' table
+ */
+function update_page($data) {
+    global $USER, $CFG;
+
+    // Update with the new data
+    if (update_record('page', $data)) {
+
+        $page = get_record('page', 'id', $data->id);
+
+        // Test for and remove blocks which aren't appropriate anymore
+        $blocks = page_create_object(PAGE_STATIC_VIEW, $page->id);
+        blocks_remove_inappropriate($blocks);
+
+        // put custom role names into db
+        $context = get_context_instance(CONTEXT_PAGE, $page->id);
+        
+        foreach ($data as $dname => $dvalue) {
+          
+            // is this the right param?
+            $dvalue = clean_param($dvalue, PARAM_NOTAGS);
+
+            if (!strstr($dname, 'role_')) {
+                continue;
+            }  
+            
+            $dt = explode('_', $dname);
+            $roleid = $dt[1];
+            // make up our mind whether we want to delete, update or insert
+            
+            if (empty($dvalue)) {
+                
+                delete_records('role_names', 'contextid', $context->id, 'roleid', $roleid);
+            
+            } else if ($t = get_record('role_names', 'contextid', $context->id, 'roleid', $roleid)) {
+                
+                $t->text = $dvalue;
+                update_record('role_names', $t);    
+                       
+            } else {
+                
+                $t->contextid = $context->id;
+                $t->roleid = $roleid;
+                $t->text = $dvalue;
+                insert_record('role_names', $t);  
+            }
+            
+        }
+
+        return true;
+
+    }
+
+    return false;
+}
+
+function set_page_visible($id, $visibility) {
+/// For a given page, markes it visible or hidden
+
+    if (get_record("page", "id", $id)) {
+        set_field("page", "visible", "$visibility", "id", $id);
+    }
+}
+
+function update_page_button($pageid)
+{
+    global $CFG, $USER;
+
+    if (!empty($USER->editing)) {
+        $string = get_string('turneditingoff');
+        $edit = '0';
+    } else {
+        $string = get_string('turneditingon');
+        $edit = '1';
+    }
+    
+    $ret = "<form $CFG->frametarget method=\"get\" action=\"$CFG->wwwroot/page/view.php\">".
+            "<div>".
+            "<input type=\"hidden\" name=\"edit\" value=\"$edit\" />".
+            "<input type=\"hidden\" name=\"id\" value=\"$pageid\" />\r\n".
+            "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />".
+            "<input type=\"submit\" value=\"$string\" /></div></form>";
+    
+    return $ret;
+}
+
+?>
diff -r -u -N ./page/pagelib.php ./page/pagelib.php
--- ./page/pagelib.php	1969-12-31 16:00:00.000000000 -0800
+++ ./page/pagelib.php	2008-12-12 13:18:07.000000000 -0800
@@ -0,0 +1,172 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// NOTICE OF COPYRIGHT                                                   //
+//                                                                       //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//          http://moodle.com                                            //
+//                                                                       //
+// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
+//                                                                       //
+// This program is free software; you can redistribute it and/or modify  //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation; either version 2 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// This program is distributed in the hope that it will be useful,       //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details:                          //
+//                                                                       //
+//          http://www.gnu.org/copyleft/gpl.html                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+require_once($CFG->libdir.'/pagelib.php');
+require_once('lib.php');
+
+define('PAGE_STATIC_VIEW', 'page-view');
+define('PAGE_FORMAT', 'page');
+
+/**
+ * Class that allows for pages of content.
+ *
+ * @author Darryl Pogue
+ * @package pages
+ */
+class page_static extends page_base {
+    // Despite being named "static" the content is actually stored in the database
+
+    var $pagerecord = NULL;
+
+    function init_quick($data) {
+        parent::init_quick($data);
+    }
+
+    function init_full() {
+        if($this->full_init_done) {
+            return;
+        }
+        if (empty($this->id)) {
+            $this->id = 0; // avoid db errors
+        }
+        
+        $this->pagerecord = get_record('page', 'id', $this->id);
+
+        if(empty($this->pagerecord)) {
+            error('Cannot fully initialize page: invalid page id '. $this->id);
+        }
+
+        $this->context = get_context_instance(CONTEXT_PAGE, $this->id);
+        $this->childcontexts = get_child_contexts($this->context);
+        $this->full_init_done = true;
+    }
+
+    function user_allowed_editing() {
+        $this->init_full();
+
+        if (isset($this->_user_allowed_editing)) {
+            return $this->_user_allowed_editing;
+        }
+
+        if (has_capability('moodle/page:update', $this->context)) {
+            $this->_user_allowed_editing = true;
+            return true;
+        }
+
+        foreach ($this->childcontexts as $cc) {
+            if (($cc->contextlevel == CONTEXT_BLOCK &&
+                 has_capability('moodle/site:manageblocks', $cc))) {
+                $this->_user_allowed_editing = true;
+                return true;
+            }
+        }
+    }
+
+    function user_is_editing() {
+        return isediting();
+    }
+
+    function print_header($title, $morenavlinks=NULL, $meta='', $bodytags='', $extrabuttons='') {
+        global $USER, $CFG;
+
+        $this->init_full();
+        $replacements = array(
+            '%fullname%' => $this->pagerecord->fullname
+        );
+        foreach($replacements as $search => $replace) {
+            $title = str_replace($search, $replace, $title);
+        }
+    
+        $navlinks = array();
+        $navlinks[] = array('name' => $this->pagerecord->shortname, 'link' => '', 'type' => '');
+        
+        if(!empty($morenavlinks)) {
+            $navlinks = array_merge($navlinks, $morenavlinks);
+        }
+
+        $navigation = build_navigation($navlinks);
+
+        $buttons = '';
+        if ($this->user_allowed_editing()) {
+            $buttons .= update_page_button($this->pagerecord->id );
+        }
+        $buttons = empty($morenavlinks) ? $buttons : '&nbsp;';
+
+        if ($extrabuttons != '') {
+            $buttons = ($buttons == '&nbsp;') ? $extrabuttons : $buttons.$extrabuttons;
+        }
+
+        print_header($title, $this->pagerecord->fullname, $navigation,
+                     '', $meta, true, $buttons, user_login_string(1, $USER), false, $bodytags);
+    }
+
+    function get_type() {
+        return PAGE_STATIC_VIEW;
+    }
+
+    function get_format_name() {
+        return PAGE_STATIC_VIEW;
+    }
+
+    function url_get_path() {
+        global $CFG;
+
+        return $CFG->wwwroot .'/page/view.php';
+    }
+
+    function url_get_parameters() {
+        return array('id' => $this->id);
+    }
+
+    function blocks_get_positions() {
+        return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
+    }
+
+    function blocks_default_position() {
+        return BLOCK_POS_RIGHT;
+    }
+
+    function blocks_get_default() {
+        global $CFG;
+        
+        $this->init_full();
+
+        $blocknames = 'page_admin,site_news:login,messages,calendar_month';
+        
+        return $blocknames;
+    }
+
+    function blocks_move_position(&$instance, $move) {
+        if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
+            return BLOCK_POS_RIGHT;
+        } else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
+            return BLOCK_POS_LEFT;
+        }
+        return $instance->position;
+    }
+}
+
+page_map_class(PAGE_STATIC_VIEW, 'page_static');
+
+?>
diff -r -u -N ./page/view.php ./page/view.php
--- ./page/view.php	1969-12-31 16:00:00.000000000 -0800
+++ ./page/view.php	2009-02-28 14:43:58.000000000 -0800
@@ -0,0 +1,151 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// NOTICE OF COPYRIGHT                                                   //
+//                                                                       //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//          http://moodle.com                                            //
+//                                                                       //
+// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
+//                                                                       //
+// This program is free software; you can redistribute it and/or modify  //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation; either version 2 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// This program is distributed in the hope that it will be useful,       //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details:                          //
+//                                                                       //
+//          http://www.gnu.org/copyleft/gpl.html                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+require_once('../config.php');
+require_once('lib.php');
+require_once('pagelib.php');
+require_once($CFG->libdir.'/blocklib.php');
+require_once($CFG->libdir.'/ajax/ajaxlib.php');
+require_once($CFG->dirroot.'/mod/forum/lib.php');
+
+$id          = optional_param('id', 0, PARAM_INT);
+$name        = optional_param('name', '', PARAM_RAW);
+$edit        = optional_param('edit', -1, PARAM_BOOL);
+$hide        = optional_param('hide', 0, PARAM_INT);
+$show        = optional_param('show', 0, PARAM_INT);
+$idnumber    = optional_param('idnumber', '', PARAM_RAW);
+$section     = optional_param('section', 0, PARAM_INT);
+$move        = optional_param('move', 0, PARAM_INT);
+$marker      = optional_param('marker',-1 , PARAM_INT);
+$switchrole  = optional_param('switchrole',-1, PARAM_INT);
+
+if (empty($id)) {
+    error("Must specify id");
+}
+
+if (! ($page = get_record('page', 'id', $id)) ) {
+    error('Invalid page id');
+}
+
+if (!$context = get_context_instance(CONTEXT_PAGE, $page->id)) {
+    print_error('nocontext');
+}
+
+if (!has_capability('moodle/page:view', $context) or (!has_capability('moodle/page:visibility', $context) and $page->visible == 0)) {
+    redirect($CFG->wwwroot.'/index.php');
+}
+
+if(! empty($CFG->allowcoursethemes) ){
+    if(isset($page->theme)){
+        // specifying theme here saves us some dbqs
+        theme_setup($page->theme);
+    }
+}
+
+$PAGE = page_create_object(PAGE_STATIC_VIEW, $page->id);
+$pageblocks = blocks_setup($PAGE, BLOCKS_PINNED_BOTH);
+
+if (!isset($USER->editing)) {
+    $USER->editing = 0;
+}
+if ($PAGE->user_allowed_editing()) {
+    if (($edit == 1) and confirm_sesskey()) {
+        $USER->editing = 1;
+    } else if (($edit == 0) and confirm_sesskey()) {
+        $USER->editing = 0;
+        if(!empty($USER->activitycopy) && $USER->activitycopycourse == $course->id) {
+            $USER->activitycopy       = false;
+            $USER->activitycopycourse = NULL;
+        }
+    }
+
+    if ($hide && confirm_sesskey()) {
+        set_page_visible($page->id, '0');
+        redirect($CFG->wwwroot.'/page/index.php');
+    }
+
+    if ($show && confirm_sesskey()) {
+        set_page_visible($page->id, '1');
+        redirect($CFG->wwwroot.'/page/index.php');
+    }
+} else {
+    $USER->editing = 0;
+}
+
+$PAGE->print_header($SITE->fullname.': %fullname%', NULL, '', '');
+?>
+<table id="layout-table" summary="layout">
+  <tr>
+  <?php
+    $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
+    foreach ($lt as $column) {
+        switch ($column) {
+            case 'left':
+    if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
+        echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
+        print_container_start();
+        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
+        print_container_end();
+        echo '</td>';
+    }
+            break;
+            case 'middle':
+    echo '<td id="middle-column">'. skip_main_destination();
+
+    print_container_start();
+    print_box_start('staticpage');
+    print_heading($page->fullname, 'left', 1);
+    print_heading("<i>Last Updated: ".userdate($page->timemodified, get_string('strftimedate'))."</i>", 'left', 3);
+    echo "<p>".$page->content."</p>";
+    print_box_end();
+    print_container_end();
+
+    echo '</td>';
+            break;
+            case 'right':
+    // The right column
+    if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing || $PAGE->user_allowed_editing()) {
+        echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
+        print_container_start();
+        if ($PAGE->user_allowed_editing()) {
+            echo '<div style="text-align:center">'.update_course_icon($SITE->id).'</div>';
+            echo '<br />';
+        }
+        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
+        print_container_end();
+        echo '</td>';
+    }
+            break;
+        }
+    }
+?>
+
+  </tr>
+</table>
+
+
+<?php
+    print_footer('home');     // Please do not modify this line
+?>
+

