if ($mform->is_submitted()) { // check the validation rules if ($mform->is_validated()) { //get the form data submitted $formdata = $mform->get_data(); //only try to change the icon if a file was submitted if ($mform->get_file_content('binary_icon') != false) { $formdata->binary_icon = $mform->get_file_content('binary_icon'); } else { $formdata->binary_icon = ''; } $formdata->maxedit = empty($formdata->maxedit) ? 0 : $formdata->maxedit; $formdata->comments = empty($formdata->comments) ? 0 : $formdata->comments; $formdata->frequency = empty($formdata->frequency) ? 0 : $formdata->frequency; // process the data $success = $mform->process_data($formdata); //if saving the data was not successful if (!$success) { //print an error message print_error(get_string("reportcreationerror", 'block_ilp'), 'block_ilp'); } //if the report_id has not already been set $report_id = empty($report_id) ? $success : $report_id; //decide whether the user has chosen to save and exit or save or display if (isset($formdata->saveanddisplaybutton)) { $return_url = $CFG->wwwroot . '/blocks/ilp/actions/edit_prompt.php?report_id=' . $report_id; redirect($return_url, get_string("reportcreationsuc", 'block_ilp'), ILP_REDIRECT_DELAY); } } } //set the page title
protected function create_report($name, $description) { //does this report exist already ? //@todo return 0 if report already exists if ($this->report_already_exists($name)) { return 0; } global $USER; //$name .= "-" . date( 'Hms' ); $formdata = new stdClass(); $formdata->id = 0; $formdata->creator_id = $USER->id; $formdata->name = $name; $formdata->description = $description; $formdata->status = 1; $course_id = 0; //not necessary for report creation, so just a dummy value $mform = new edit_report_mform($course_id, null); $report_id = $mform->process_data($formdata); return $report_id; }