<commit_before><?php // $Id$

    require_once("../config.php");

    if ($site = get_site()) {
        require_login();
        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()) {

        if (!empty($USER->id)) {             // Additional identity check
            if (!confirm_sesskey()) {
                error(get_string('confirmsesskeybad', 'error'));
            }
        }

        validate_form($form, $err);

        if (count($err) == 0) {

            set_config("frontpage", $form->frontpage);

            $form->timemodified = time();

            if ($form->id) {
                if (update_record("course", $form)) {
                    redirect("$CFG->wwwroot/", get_string("changessaved"));
                } else {
                    error("Serious Error! Could not update the site record! (id = $form->id)");
                }
            } else {
                // [pj] We are about to create the site, so let's add some blocks...
                // calendar_month is included as a Moodle feature advertisement ;-)
                require_once($CFG->dirroot.'/lib/blocklib.php');
                $form->blockinfo = blocks_get_default_blocks(NULL, BLOCKS_DEFAULT_SITE);

                if ($newid = insert_record("course", $form)) {
                    $cat->name = get_string("miscellaneous");
                    if (insert_record("course_categories", $cat)) {
                        redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1);
                    } 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;
        $course = $site;
        $firsttime = false;
    } else {
        $form->fullname = "";
        $form->shortname = "";
        $form->summary = "";
        $form->newsitems = 3;
        $form->numsections = 0;
        $form->id = "";
        $form->category = 0;
        $form->format = "social";
        $form->teacher = get_string("defaultcourseteacher");
        $form->teachers = get_string("defaultcourseteachers");
        $form->student = get_string("defaultcoursestudent");
        $form->students = get_string("defaultcoursestudents");
        $firsttime = true;
    }

    if (isset($CFG->frontpage)) {
        $form->frontpage = $CFG->frontpage;

    } else {
        if ($form->newsitems > 0) {
            $form->frontpage = 0;
        } else {
            $form->frontpage = 1;
        }
        set_config("frontpage", $form->frontpage);
    }

    if (empty($focus)) {
        $focus = "form.fullname";
    }

    $stradmin = get_string("administration");<commit_msg>Site can now have proper blocks on an install<commit_after><?php // $Id$

    require_once("../config.php");

    if ($site = get_site()) {
        require_login();
        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()) {

        if (!empty($USER->id)) {             // Additional identity check
            if (!confirm_sesskey()) {
                error(get_string('confirmsesskeybad', 'error'));
            }
        }

        validate_form($form, $err);

        if (count($err) == 0) {

            set_config("frontpage", $form->frontpage);

            $form->timemodified = time();

            if ($form->id) {
                if (update_record("course", $form)) {
                    redirect("$CFG->wwwroot/", get_string("changessaved"));
                } else {
                    error("Serious Error! Could not update the site record! (id = $form->id)");
                }
            } else {
                // [pj] We are about to create the site, so let's add some blocks...
                // calendar_month is included as a Moodle feature advertisement ;-)
                require_once($CFG->dirroot.'/lib/blocklib.php');
                $form->blockinfo = blocks_get_default_blocks(NULL, blocks_get_config_default('site'));

                if ($newid = insert_record("course", $form)) {
                    $cat->name = get_string("miscellaneous");
                    if (insert_record("course_categories", $cat)) {
                        redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1);
                    } 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;
        $course = $site;
        $firsttime = false;
    } else {
        $form->fullname = "";
        $form->shortname = "";
        $form->summary = "";
        $form->newsitems = 3;
        $form->numsections = 0;
        $form->id = "";
        $form->category = 0;
        $form->format = 'site';  // Only for this course
        $form->teacher = get_string("defaultcourseteacher");
        $form->teachers = get_string("defaultcourseteachers");
        $form->student = get_string("defaultcoursestudent");
        $form->students = get_string("defaultcoursestudents");
        $firsttime = true;
    }

    if (isset($CFG->frontpage)) {
        $form->frontpage = $CFG->frontpage;

    } else {
        if ($form->newsitems > 0) {
            $form->frontpage = 0;
        } else {
            $form->frontpage = 1;
        }
        set_config("frontpage", $form->frontpage);
    }

    if (empty($focus)) {
        $focus = "form.fullname";
    }

    $stradmin = get_string("administration");
{'fraction_non_alphanumeric': 0.14879377431906615, 'fraction_numerical': 0.002490272373540856, 'mean_word_length': 1.5984634047715325, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '175683', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1762, 'n_words': 399}