'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
$PAGE->init_full($section);
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
+$return = optional_param('return','', PARAM_ALPHA);
if (!isset($USER->adminediting)) {
$USER->adminediting = false;
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);
}
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();
}
-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' : '');
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() {
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))) {
}
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