]> git.mjollnir.org Git - moodle.git/commitdiff
fixed frontpagesettings, install is not useing admin/site.php anymore
authorskodak <skodak>
Sat, 2 Sep 2006 15:29:52 +0000 (15:29 +0000)
committerskodak <skodak>
Sat, 2 Sep 2006 15:29:52 +0000 (15:29 +0000)
admin/index.php
admin/settings.php
lib/adminlib.php
user/edit.php

index 45d619bf9b7e4d2f93f7710ac5f862b82b087c8b..4daa3d6d03038d6ac546acffef68e9dfa9cd6835 100644 (file)
                                                    'changepassword' => '',
                                                    'enrol' => 'manual',
                                                    'enrol_plugins_enabled' => 'manual',
-                                                   'frontpage' => 1,
                                                    'guestloginbutton' => 1,
                                                    'style' => 'default',
                                                    'template' => 'default',
 /// just make sure upgrade logging is properly terminated
     upgrade_log_finish();
 
-/// Set up the overall site name etc.
+/// Set up the blank site - to be customized later at the end of install.
     if (! $site = get_site()) {
-        redirect("site.php");
+        // We are about to create the site "course"
+        require_once($CFG->dirroot.'/lib/blocklib.php');
+
+        $newsite = new Object();
+        $newsite->fullname = "";
+        $newsite->shortname = "";
+        $newsite->summary = "";
+        $newsite->newsitems = 3;
+        $newsite->numsections = 0;
+        $newsite->category = 0;
+        $newsite->format = 'site';  // Only for this course
+        $newsite->teacher = get_string("defaultcourseteacher");
+        $newsite->teachers = get_string("defaultcourseteachers");
+        $newsite->student = get_string("defaultcoursestudent");
+        $newsite->students = get_string("defaultcoursestudents");
+        $newsite->timemodified = time();
+
+        if ($newid = insert_record('course', $newsite)) {
+            // Site created, add blocks for it
+            $page = page_create_object(PAGE_COURSE_VIEW, $newid);
+            blocks_repopulate_page($page); // Return value not checked because you can always edit later
+
+            $cat = new Object();
+            $cat->name = get_string('miscellaneous');
+            if (insert_record('course_categories', $cat)) {
+                  print_continue("index.php");
+            } else {
+                 error("Serious Error! Could not set up a default course category!");
+            }
+        } else {
+            error("Serious Error! Could not set up the site!");
+        }
     }
 
 /// Define the unique site ID code if it isn't already
 
 
 /// Set up the admin user
-    if (!$CFG->rolesactive) {
+    if (empty($CFG->rolesactive)) {
         redirect("user.php");
     }
 
 
     require_capability('moodle/site:config', $context);
 
+/// check that site is properly customized
+    if (empty($site->shortname) or empty($site->shortname)) {
+        redirect('settings.php?section=frontpage&return=site');
+    }
 
 /// Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders
 
index 77bc65afffee8c930016b8c5031a4f8c013bf881..4302f14ab4adfba714d070d7fea8695600c67b78 100644 (file)
@@ -25,6 +25,7 @@ $section = optional_param('section', '', PARAM_ALPHAEXT);
 $PAGE->init_full($section);
 
 $adminediting = optional_param('adminedit', -1, PARAM_BOOL);
+$return       = optional_param('return','', PARAM_ALPHA);
    
 if (!isset($USER->adminediting)) {
     $USER->adminediting = false;
@@ -58,7 +59,14 @@ if ($data = data_submitted()) {
     if (confirm_sesskey()) {
         $errors = $root->write_settings((array)$data);
         if (empty($errors)) {
-            redirect("$CFG->wwwroot/admin/settings.php?section=" . $PAGE->section, get_string('changessaved'),1);
+            switch ($return) {
+                case 'site':
+                    redirect("$CFG->wwwroot/", get_string('changessaved'),1);
+                case 'admin':
+                    redirect("$CFG->wwwroot/admin/", get_string('changessaved'),1);
+                default:
+                    redirect("$CFG->wwwroot/admin/settings.php?section=" . $PAGE->section, get_string('changessaved'),1);
+            }
         } else {
             error(get_string('errorwithsettings', 'admin') . ' <br />' . $errors);
         }
@@ -84,6 +92,7 @@ echo '<td id="middle-column" width="*">';
 echo '<form action="settings.php" method="post" name="mainform">';
 echo '<input type="hidden" name="section" value="' . $PAGE->section . '" />';
 echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
+echo '<input type="hidden" name="return" value="' . $return . '" />';
 print_simple_box_start('','100%','',5,'generalbox','');
 
 echo $root->output_html();
index 8e91b6ae1be6fddff33727dcb7ed9de15370209f..e7803527c78fb5e57fbd9e5bf6491a19fce13804 100644 (file)
@@ -1411,9 +1411,9 @@ class admin_setting_sitesetselect extends admin_setting_configselect {
 }
 
 
-class admin_setting_special_frontpage extends admin_setting_configselect {
+class admin_setting_courselist_frontpage extends admin_setting_configselect {
 
-    function admin_setting_special_frontpage($loggedin = false) {
+    function admin_setting_courselist_frontpage($loggedin) {
         global $CFG;
         require_once($CFG->dirroot . '/course/lib.php');
         $name = 'frontpage' . ($loggedin ? 'loggedin' : '');
@@ -1427,7 +1427,12 @@ class admin_setting_special_frontpage extends admin_setting_configselect {
         if (count_records("course") > FRONTPAGECOURSELIMIT) {
             unset($choices[FRONTPAGECOURSELIST]);
         }
-        parent::admin_setting_configselect($name, $visiblename, $description, '', $choices);
+        if ($loggedin) {
+            $defaults = FRONTPAGECOURSELIST.',,,';
+        } else {
+            $defaults = FRONTPAGECATEGORYCOMBO.',,,';
+        }
+        parent::admin_setting_configselect($name, $visiblename, $description, $defaults, $choices);
     }
     
     function get_setting() {
@@ -1438,6 +1443,8 @@ class admin_setting_special_frontpage extends admin_setting_configselect {
     function write_setting($data) {
         if (empty($data)) {
             $data = array();
+        } if (!is_array($data)) {
+            $data = explode(',', $data);
         }
         foreach($data as $datum) {
             if (! in_array($datum, array_keys($this->choices))) {
index 4b7233104f694106b5f3cca55d12ec140e005b35..89fd7cd6f8f80a134f43edd7762ab24c239c084d 100644 (file)
                     }
                     if (isset($USER->newadminuser)) {
                         unset($USER->newadminuser);
-                        redirect("$CFG->wwwroot/", get_string('changessaved'));
+                        // redirect to admin/ to continue with installation
+                        redirect("$CFG->wwwroot/$CFG->admin/", get_string('changessaved'));
                     }
                     if (!empty($SESSION->wantsurl)) {  // User may have been forced to edit account, so let's 
                                                        // send them to where they wanted to go originally