fixed frontpagesettings, install is not useing admin/site.php anymore

This commit is contained in:
skodak 2006-09-02 15:29:52 +00:00
parent a4b473f452
commit e0f6e99528
4 changed files with 60 additions and 9 deletions

View File

@ -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

View 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();

View 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))) {

View File

@ -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