$erroritem->on = ''; $errors[] = $erroritem; get_slot_data($form); $form->what = 'doaddupdateslot'; $form->studentid = optional_param('studentid', '', PARAM_INT); if (!empty($form->studentid)) { $form->appointments = unserialize(stripslashes(optional_param('appointments', '', PARAM_RAW))); unset($form->appointments[$form->studentid]); } $form->availableslots = scheduler_get_available_slots($form->studentid, $scheduler->id); $form->slotid = optional_param('slotid', -1, PARAM_INT); break; case 'doaddappointed': unset($erroritem); $erroritem->message = get_string('dontforgetsaveadvice', 'scheduler'); $erroritem->on = ''; $errors[] = $erroritem; get_slot_data($form); $form->what = 'doaddupdateslot'; $form->appointments = unserialize(stripslashes(required_param('appointments', PARAM_RAW))); $form->slotid = optional_param('slotid', -1, PARAM_INT); $form->studentid = $appointment->studentid = required_param('studenttoadd', PARAM_INT); $form->availableslots = scheduler_get_available_slots($form->studentid, $scheduler->id); $appointment->attended = optional_param('attended', 0, PARAM_INT); $appointment->appointmentnote = optional_param('appointmentnote', '', PARAM_TEXT); $appointment->grade = optional_param('grade', 0, PARAM_CLEAN); $appointment->timecreated = time(); $appointment->timemodified = time(); $form->appointments[$appointment->studentid] = $appointment; break; }
*/ if (!defined('MOODLE_INTERNAL')) { die('Direct access to this script is forbidden.'); /// It must be included from view.php in mod/scheduler } // We first have to check whether some action needs to be performed switch ($action) { /************************************ creates or updates a slot ***********************************************/ /* * If fails, should reenter within the form signalling error cause */ case 'doaddupdateslot': // get expected parameters $slotid = optional_param('slotid', '', PARAM_INT); // get standard slot parms get_slot_data($data); $appointments = unserialize(stripslashes(optional_param('appointments', '', PARAM_RAW))); $errors = array(); // Avoid slots starting in the past (too far) if ($data->starttime < time() - DAYSECS * 10) { $erroritem->message = get_string('startpast', 'scheduler'); $erroritem->on = 'rangestart'; $errors[] = $erroritem; } if ($data->exclusivity > 0 and count($appointments) > $data->exclusivity) { unset($erroritem); $erroritem->message = get_string('exclusivityoverload', 'scheduler'); $erroritem->on = 'exclusivity'; $errors[] = $erroritem; } if ($data->teacherid == 0) {