public function definition() { global $USER, $cm, $context; $error = false; $mform =& $this->_form; $mform->addElement('hidden', 'post_form', 'assignteachers'); if (!($school = praxe_get_school($this->schoolid))) { print_error('notallowedaction', 'praxe'); } $mform->addElement('hidden', 'teacher_school', $this->schoolid); $mform->addElement('static', 'static1', get_string('school', 'praxe'), s($school->name)); $ext = praxe_get_cohort_members(PRAXE_COHORT_EXTTEACHERS); //get_users_by_capability($context, 'mod/praxe:beexternalteacher', 'u.id, u.firstname, u.lastname','lastname, firstname', null, null, null, null, null, false); if (is_array($ext) && count($ext)) { if (is_array($used_ext = praxe_get_ext_teachers_at_school(null, $this->schoolid))) { foreach ($used_ext as $t) { if (isset($ext[$t->teacherid])) { unset($ext[$t->teacherid]); } } } if (!count($ext)) { $this->error = get_string('no_teachers_available', 'praxe'); } else { $options = array(); foreach ($ext as $h) { $options[$h->id] = s($h->firstname) . " " . s($h->lastname); } $mform->addElement('select', 'ext_teacher', get_string('extteacher', 'praxe'), $options); } } else { $this->error = get_string('no_teachers_available', 'praxe'); } $this->add_action_buttons(true, get_string('submit')); }
function definition() { global $USER, $context, $DB; /// Adding fields $mform =& $this->_form; $mform->addElement('hidden', 'post_form', 'addlocation'); $school = praxe_get_school($this->schoolid); $mform->addElement('hidden', 'school', $school->id); $mform->addElement('static', 'static_school', get_string('school', 'praxe'), s($school->name)); $teachers = praxe_get_ext_teachers_at_school(null, $this->schoolid); //print_object($teachers); if (count($teachers)) { $options = array(0 => '---'); foreach ($teachers as $t) { $options[$t->ext_teacher_id] = s($t->firstname) . ' ' . s($t->lastname); } $mform->addElement('select', 'teacher', get_string('teacher', 'praxe'), $options); } else { $mform->addElement('static', 'static_teacher', get_string('extteacher', 'praxe'), get_string('no_teachers_available', 'praxe')); } if (!$this->error) { $result = $DB->get_records('praxe_studyfields', null, 'name, shortcut'); $options = array(); foreach ($result as $sf) { $options[$sf->id] = $sf->name . " (" . $sf->shortcut . ")"; } $mform->addElement('select', 'studyfield', get_string('studyfield', 'praxe'), $options); $options = array(PRAXE_ISCED_1 => PRAXE_ISCED_1_TEXT, PRAXE_ISCED_2 => PRAXE_ISCED_2_TEXT, PRAXE_ISCED_3 => PRAXE_ISCED_3_TEXT); $mform->addElement('select', 'isced', get_string('iscedlevel', 'praxe'), $options); $mform->addElement('text', 'subject', get_string('subject', 'praxe'), array('size' => '64')); $mform->setType('subject', PARAM_TEXT); $mform->addRule('subject', null, 'required', null, 'client'); $mform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $actualyear = (int) date('Y', time()); $options = array($actualyear => $actualyear, $actualyear + 1 => $actualyear + 1, $actualyear + 2 => $actualyear + 2); $mform->addElement('select', 'year', get_string('year', 'praxe'), $options); /// Adding the "term" select field to choose the summer term/winter term for current course $options = array(PRAXE_TERM_WS => PRAXE_TERM_WS_TEXT, PRAXE_TERM_SS => PRAXE_TERM_SS_TEXT); $mform->addElement('select', 'term', get_string('term', 'praxe'), $options); $act = $mform->addElement('selectyesno', 'active', get_string('active', 'praxe')); $mform->setDefault('active', 1); $this->add_action_buttons(true, get_string('submit')); } }
function praxe_view_editteacher() { global $DB, $tab, $CFG, $tab_modes, $context; switch ($tab) { case PRAXE_TAB_EDITTEACHER_HOME: $detail = optional_param('recordid', 0, PARAM_INT); require_once $CFG->dirroot . '/mod/praxe/view_extteacher.php'; if ($detail > 0 && ($record = praxe_get_record($detail))) { $schid = optional_param('scheduleid', 0, PARAM_INT); if ($schid > 0 && ($schedule = praxe_get_schedule($schid))) { $this->content .= praxe_view_extteacher::show_schedule_detail($schedule) . "<hr>"; } $this->content .= praxe_view_extteacher::show_record_detail($record); } else { $this->content .= self::show_all_students_records(); } break; case PRAXE_TAB_EDITTEACHER_ADDSCHOOL: require_capability('mod/praxe:manageallincourse', $context); require_once $CFG->dirroot . '/mod/praxe/c_addschool.php'; $this->form = new praxe_addschool(); break; case PRAXE_TAB_EDITTEACHER_SCHOOLS: require_once $CFG->dirroot . '/mod/praxe/view_headm.php'; $schoolid = optional_param('schoolid', 0, PARAM_INT); if ($schoolid == 0) { /// sorting list $sname = strtoupper(optional_param('sname', null, PARAM_ALPHA)); $stype = strtoupper(optional_param('stype', null, PARAM_ALPHA)); $sort = array(); $aSort = array(); if ($sname == 'ASC' || $sname == 'DESC') { $sort[] = 'name ' . $sname; $aSort['name'] = $sname; } if ($stype == 'ASC' || $stype == 'DESC') { $sort[] = 'type ' . $stype; $aSort['type'] = $stype; } $sort = count($sort) ? implode(', ', $sort) : ''; $schools = $DB->get_records('praxe_schools', array(), $sort); $this->content .= praxe_view_headm::show_schools($schools, array('mode' => $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_EDITSCHOOL]), $aSort); } else { $this->content .= praxe_view_headm::show_school($schoolid, array('mode' => $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_EDITSCHOOL])); } break; case PRAXE_TAB_EDITTEACHER_EDITSCHOOL: require_capability('mod/praxe:manageallincourse', $context); $schoolid = required_param('schoolid', PARAM_INT); if ($school = praxe_get_school($schoolid)) { require_once $CFG->dirroot . '/mod/praxe/c_addschool.php'; $this->form = new praxe_addschool(); $this->form->set_form_to_edit($school); } break; case PRAXE_TAB_EDITTEACHER_TEACHERS: $schoolid = optional_param('schoolid', 0, PARAM_INT); require_once $CFG->dirroot . '/mod/praxe/view_headm.php'; if ($schoolid > 0) { $this->content .= praxe_view_headm::school_teachers_by_schools(null, $schoolid); } else { $this->content .= praxe_view_headm::school_teachers_by_schools(); } break; case PRAXE_TAB_EDITTEACHER_ASSIGNTEACHERS: require_capability('mod/praxe:manageallincourse', $context); $schoolid = required_param('schoolid', PARAM_INT); require_once $CFG->dirroot . '/mod/praxe/c_assignteachers.php'; $this->form = new praxe_assignteachers($schoolid); break; case PRAXE_TAB_EDITTEACHER_LOCATIONS: $schoolid = optional_param('schoolid', 0, PARAM_INT); $locationid = optional_param('locationid', 0, PARAM_INT); $edit = optional_param('edit', null, PARAM_TEXT); $factual = optional_param('factualloc', 0, PARAM_INT); $fyear = optional_param('fyearloc', 0, PARAM_INT); /// edit location form /// if (!is_null($edit) && $locationid > 0) { if (!($loc = praxe_get_location($locationid))) { print_error('notallowedaction', 'praxe'); } require_once $CFG->dirroot . '/mod/praxe/c_addlocation.php'; $this->form = new praxe_addlocation($loc->school); $this->form->set_redirect_url(null, array('mode' => $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_LOCATIONS], 'schoolid' => $schoolid)); $this->form->set_form_to_edit($loc); } else { /// sorting list $sortFields = array('sschool', 'sstudyfield', 'sisced', 'syear', 'ssubject', 'sactive'); $aSort = array(); foreach ($sortFields as $f) { $s_[$f] = strtoupper(optional_param($f, null, PARAM_ALPHA)); if ($s_[$f] == 'ASC' || $s_[$f] == 'DESC') { $aSort[$f] = $s_[$f]; } else { $aSort[$f] = null; } } require_once $CFG->dirroot . '/mod/praxe/view_headm.php'; $params = array('edit' => 'true', 'mode' => $tab_modes['editteacher'][PRAXE_TAB_EDITTEACHER_LOCATIONS], 'schoolid' => $schoolid); $this->content .= praxe_view_headm::show_locations($schoolid, null, $params, $factual, $fyear, $aSort); } break; case PRAXE_TAB_EDITTEACHER_ADDLOCATION: require_capability('mod/praxe:manageallincourse', $context); $schoolid = required_param('schoolid', PARAM_INT); require_once $CFG->dirroot . '/mod/praxe/c_addlocation.php'; $this->form = new praxe_addlocation($schoolid); break; default: break; } }
if ($status >= PRAXE_STATUS_CONFIRMED) { $viewtabrows[] = new tabobject(PRAXE_TAB_STUDENT_SCHEDULE, $CFG->wwwroot . '/mod/praxe/view.php?id=' . $cm->id . '&mode=' . $tab_modes['student'][PRAXE_TAB_STUDENT_SCHEDULE], get_string('my_schedule', 'praxe')); if ($tab == PRAXE_TAB_STUDENT_SCHEDULE) { $activated[] = PRAXE_TAB_STUDENT_SCHEDULE; $subtabrows[] = new tabobject(PRAXE_TAB_STUDENT_ADDSCHEDULE, $CFG->wwwroot . '/mod/praxe/view.php?id=' . $cm->id . '&mode=' . $tab_modes['student'][PRAXE_TAB_STUDENT_ADDSCHEDULE], get_string('addtoschedule', 'praxe')); } } } break; case PRAXE_TAB_VIEW_HEADM: $viewtabrows[] = new tabobject(PRAXE_TAB_HEADM_HOME, $CFG->wwwroot . '/mod/praxe/view.php?id=' . $cm->id . '&mode=' . $tab_modes['headm'][PRAXE_TAB_HEADM_HOME], get_string('my_schools', 'praxe')); $viewtabrows[] = new tabobject(PRAXE_TAB_HEADM_ADDSCHOOL, $CFG->wwwroot . '/mod/praxe/view.php?id=' . $cm->id . '&mode=' . $tab_modes['headm'][PRAXE_TAB_HEADM_ADDSCHOOL], get_string('addschool', 'praxe')); $viewschool = optional_param('schoolid', null, PARAM_INT); /// schoolid is set and user is not headmaster of this school /// if (!empty($viewschool)) { $school = praxe_get_school($viewschool); if (!$school || $school->headmaster != $USER->id) { print_error('notallowedaction', 'praxe'); } } if ($tab == PRAXE_TAB_HEADM_HOME || !is_null($viewschool)) { $activated[] = PRAXE_TAB_HEADM_HOME; if ($schools = praxe_get_schools($USER->id)) { /// schoolid is not valid(for this user at least) or viewschool is null => set to default view of schools/// if (!array_key_exists($viewschool, $schools)) { $viewschool = 0; if ($mode != $tab_modes['headm'][PRAXE_TAB_HEADM_TEACHERS] && $mode != $tab_modes['headm'][PRAXE_TAB_HEADM_LOCATIONS]) { $tab = PRAXE_TAB_HEADM_HOME; $mode = $tab_modes['headm'][PRAXE_TAB_HEADM_HOME]; } }
/** * * @param int $schoolid * @param array $editlinkparams [optional] * @return string - table parsed by html_writer */ public static function show_school($schoolid, $editlinkparams = array()) { global $USER, $OUTPUT; if (!($school = praxe_get_school($schoolid))) { return null; } $table = new html_table(); $table->attributes['class'] = 'generaltable boxaligncenter'; $table->head = array(get_string('school_detail', 'praxe')); $table->headspan = array(2); $table->colclasses = array('praxe_cell right', 'praxe_cell left'); $table->data[] = array(get_string('schoolname', 'praxe'), s($school->name)); $table->data[] = array(get_string('schooltype', 'praxe'), praxe_get_schooltype_info($school->type)); $table->data[] = array(get_string('street', 'praxe'), s($school->street)); $table->data[] = array(get_string('city', 'praxe'), s($school->city)); $table->data[] = array(get_string('zipcode', 'praxe'), s($school->zip)); $table->data[] = array(get_string('phone', 'praxe'), s($school->phone)); $table->data[] = array(get_string('email', 'praxe'), s($school->email)); $table->data[] = array(get_string('website', 'praxe'), s($school->website)); if (!is_null($school->headmaster)) { $table->data[] = array(get_string('headmaster', 'praxe'), praxe_get_user_fullname($school->headmaster)); } $ret = ''; if (praxe_has_capability('editanyschool')) { //|| (praxe_has_capability('editownschool') AND isset($school->teachers[$USER->id]))) { $params = array("schoolid" => $schoolid, "detail" => 1); foreach ($editlinkparams as $name => $val) { $params[s($name)] = s($val); } $ret = $OUTPUT->single_button(praxe_get_base_url($params), get_string('editschool', 'praxe'), 'get', array('class' => 'praxe_button praxe_center')); } return html_writer::table($table) . $ret; }