3 require_once("../config.php");
5 if ($site = get_site()) {
7 error("You need to be admin to edit this page");
9 $site->format
= "social"; // override
12 /// If data submitted, then process and store.
14 if ($form = data_submitted()) {
16 validate_form($form, $err);
18 if (count($err) == 0) {
20 set_config("frontpage", $form->frontpage
);
22 $form->timemodified
= time();
25 if (update_record("course", $form)) {
26 redirect("$CFG->wwwroot/", get_string("changessaved"));
28 error("Serious Error! Could not update the site record! (id = $form->id)");
31 if ($newid = insert_record("course", $form)) {
32 $cat->name
= get_string("miscellaneous");
33 if (insert_record("course_categories", $cat)) {
34 redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1);
36 error("Serious Error! Could not set up a default course category!");
39 error("Serious Error! Could not set up the site!");
45 foreach ($err as $key => $value) {
51 /// Otherwise fill and print the form.
53 if ($site and empty($form)) {
58 $form->shortname
= "";
63 $form->format
= "social";
64 $form->teacher
= get_string("defaultcourseteacher");
65 $form->teachers
= get_string("defaultcourseteachers");
66 $form->student
= get_string("defaultcoursestudent");
67 $form->students
= get_string("defaultcoursestudents");
71 if (isset($CFG->frontpage
)) {
72 $form->frontpage
= $CFG->frontpage
;
75 if ($form->newsitems
> 0) {
80 set_config("frontpage", $form->frontpage
);
84 $focus = "form.fullname";
87 $stradmin = get_string("administration");
88 $strconfiguration = get_string("configuration");
89 $strsitesettings = get_string("sitesettings");
93 print_heading($strsitesettings);
94 print_simple_box(get_string("configintrosite"), "center", "50%");
97 print_header("$site->shortname: $strsitesettings", "$site->fullname",
98 "<a href=\"index.php\">$stradmin</a> -> ".
99 "<a href=\"configure.php\">$strconfiguration</a> -> $strsitesettings", "$focus");
100 print_heading($strsitesettings);
103 $defaultformat = FORMAT_HTML
;
104 if ($usehtmleditor = can_use_richtext_editor()) {
105 $onsubmit = "onsubmit=\"copyrichtext(form.summary);\"";
110 print_simple_box_start("center", "", "$THEME->cellheading");
111 include("site.html");
112 print_simple_box_end();
120 /// Functions /////////////////////////////////////////////////////////////////
122 function validate_form(&$form, &$err) {
124 if (empty($form->fullname
))
125 $err["fullname"] = get_string("missingsitename");
127 if (empty($form->shortname
))
128 $err["shortname"] = get_string("missingshortsitename");