moodle/admin/site.php
moodler 1f33691c86 Cleaned up the initial setup process. It looks a bit smoother now.
Hopefully this is also the end of the occasional errors we keep
hearing about to do with never getting to setup the admin user.
(I think admin/site.php had a redirect that didn't always work).

The setup process is now much better at "trapping" you until it's all done.
2003-05-06 15:58:20 +00:00

107 lines
2.9 KiB
PHP

<?PHP // $Id$
require_once("../config.php");
if ($site = get_site()) {
if (!isadmin()) {
error("You need to be admin to edit this page");
}
$site->format = "social"; // override
}
/// If data submitted, then process and store.
if ($form = data_submitted()) {
validate_form($form, $err);
if (count($err) == 0) {
$form->timemodified = time();
if ($form->id) {
if (update_record("course", $form)) {
redirect("$CFG->wwwroot/admin/index.php", get_string("changessaved"));
} else {
error("Serious Error! Could not update the site record! (id = $form->id)");
}
} else {
if ($newid = insert_record("course", $form)) {
$cat->name = get_string("miscellaneous");
if (insert_record("course_categories", $cat)) {
redirect("$CFG->wwwroot/admin/index.php", get_string("changessaved"));
} else {
error("Serious Error! Could not set up a default course category!");
}
} else {
error("Serious Error! Could not set up the site!");
}
}
die;
} else {
foreach ($err as $key => $value) {
$focus = "form.$key";
}
}
}
/// Otherwise fill and print the form.
if ($site and empty($form)) {
$form = $site;
$firsttime = false;
} else {
$form->category = 0;
$form->format = "social";
$form->newsitems = 0;
$firsttime = true;
}
if (empty($focus)) {
$focus = "form.fullname";
}
$stradmin = get_string("administration");
$strsitesettings = get_string("sitesettings");
if ($firsttime) {
print_header();
print_heading($strsitesettings);
print_simple_box(get_string("configintrosite"), "center");
echo "<br />";
} else {
print_header("$site->shortname: $strsitesettings", "$site->fullname",
"<A HREF=\"index.php\">$stradmin</A> -> $strsitesettings", "$focus");
print_heading($strsitesettings);
}
print_simple_box_start("center", "", "$THEME->cellheading");
include("site.html");
print_simple_box_end();
if (!$firsttime) {
print_footer();
}
exit;
/// Functions /////////////////////////////////////////////////////////////////
function validate_form(&$form, &$err) {
if (empty($form->fullname))
$err["fullname"] = get_string("missingsitename");
if (empty($form->shortname))
$err["shortname"] = get_string("missingshortsitename");
if (empty($form->summary))
$err["summary"] = get_string("missingsitedescription");
return;
}
?>