Beispiel #1
0
    public function definition() {
        global $USER, $CFG, $PAGE;
        $school = new school();
        $mform = $this->_form;
        $id = $this->_customdata['id'];
        $schools = $this->_customdata['tool'];
        $editoroptions = $this->_customdata['editoroptions'];
        if ($id < 0)
            $mform->addElement('header', 'settingsheader', get_string('createschool', 'local_collegestructure'));
        else
            $mform->addElement('header', 'settingsheader', get_string('editschool', 'local_collegestructure'));
        $tools = array();
        $hierarchy = new hierarchy();
        $items = $hierarchy->get_school_items(true);
        $parents = $hierarchy->get_school_parent($items, $schools->id);
        if (count($parents) <= 1) {
            $mform->addElement('hidden', 'parentid', 0);
            $mform->setType('parentid', PARAM_RAW);
        } else {
            $mform->addElement('select', 'parentid', get_string('parent', 'local_collegestructure'), $parents);
            $mform->setType('parentid', PARAM_RAW);
        }
        $mform->addHelpButton('parentid', 'parent', 'local_collegestructure');
        $mform->addElement('text', 'fullname', get_string('schoolname', 'local_collegestructure'), $tools);
        $mform->setType('fullname', PARAM_TEXT);
        $mform->addRule('fullname', get_string('missingschoolname', 'local_collegestructure'), 'required', null, 'client');

        $mform->addElement('editor', 'description', get_string('description', 'local_collegestructure'), null, $editoroptions);
        $mform->setType('description', PARAM_RAW);

        $selecttype = array();
        $selecttype['1'] = get_string('campus', 'local_collegestructure');
        $selecttype['2'] = get_string('university', 'local_collegestructure');
        $selecttype['3'] = get_string('location', 'local_collegestructure');
        $mform->addElement('select', 'type', get_string('type', 'local_collegestructure'), $selecttype);
        $mform->addHelpButton('type', 'type', 'local_collegestructure');
        $mform->setType('type', PARAM_RAW);
        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);
        $now = date("d-m-Y");
        $now = strtotime($now);
        $mform->addElement('hidden', 'timecreated', $now);
        $mform->setType('timecreated', PARAM_RAW);
        $mform->addElement('hidden', 'usermodified', $USER->id);
        $mform->setType('usermodified', PARAM_RAW);
        $themelist = $school->cobalt_get_theme_list();
        $mform->addElement('select', 'theme', get_string('theme', 'local_collegestructure'), $themelist);
        $mform->setType('theme', PARAM_RAW);
        $mform->addRule('theme', get_string('missingtheme', 'local_collegestructure'), 'required', null, 'client');
        $submit = ($id > 0) ? get_string('update_school', 'local_collegestructure') : get_string('create', 'local_collegestructure');
        $this->add_action_buttons('false', $submit);
    }