From e0f6e9952871e32a97cf0a30efec7e3eda572e5e Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 2 Sep 2006 15:29:52 +0000 Subject: [PATCH] fixed frontpagesettings, install is not useing admin/site.php anymore --- admin/index.php | 42 ++++++++++++++++++++++++++++++++++++++---- admin/settings.php | 11 ++++++++++- lib/adminlib.php | 13 ++++++++++--- user/edit.php | 3 ++- 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/admin/index.php b/admin/index.php index 45d619bf9b..4daa3d6d03 100644 --- a/admin/index.php +++ b/admin/index.php @@ -163,7 +163,6 @@ 'changepassword' => '', 'enrol' => 'manual', 'enrol_plugins_enabled' => 'manual', - 'frontpage' => 1, 'guestloginbutton' => 1, 'style' => 'default', 'template' => 'default', @@ -319,9 +318,40 @@ /// 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 @@ -349,7 +379,7 @@ /// Set up the admin user - if (!$CFG->rolesactive) { + if (empty($CFG->rolesactive)) { redirect("user.php"); } @@ -360,6 +390,10 @@ 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 diff --git a/admin/settings.php b/admin/settings.php index 77bc65afff..4302f14ab4 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -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') . '
' . $errors); } @@ -84,6 +92,7 @@ echo ''; echo '
'; echo ''; echo ''; +echo ''; print_simple_box_start('','100%','',5,'generalbox',''); echo $root->output_html(); diff --git a/lib/adminlib.php b/lib/adminlib.php index 8e91b6ae1b..e7803527c7 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -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))) { diff --git a/user/edit.php b/user/edit.php index 4b7233104f..89fd7cd6f8 100644 --- a/user/edit.php +++ b/user/edit.php @@ -260,7 +260,8 @@ } 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 -- 2.39.5