function profile_edit_category($id, $redirect) { global $CFG; require_once 'index_category_form.php'; $categoryform = new category_form(); if ($category = get_record('user_info_category', 'id', $id)) { $categoryform->set_data($category); } if ($categoryform->is_cancelled()) { redirect($redirect); } else { if ($data = $categoryform->get_data()) { if (empty($data->id)) { unset($data->id); $data->sortorder = count_records('user_info_category') + 1; if (!insert_record('user_info_category', $data, false)) { error('There was a problem adding the record to the database'); } } else { if (!update_record('user_info_category', $data)) { error('There was a problem updating the record in the database'); } } profile_reorder_categories(); redirect($redirect); } if (empty($id)) { $strheading = get_string('profilecreatenewcategory', 'admin'); } else { $strheading = get_string('profileeditcategory', 'admin', format_string($category->name)); } /// Print the page admin_externalpage_print_header(); print_heading($strheading); $categoryform->display(); admin_externalpage_print_footer(); die; } }
function profile_edit_category($id, $redirect) { global $CFG, $DB, $OUTPUT; require_once 'index_category_form.php'; $categoryform = new category_form(); if ($category = $DB->get_record('user_info_category', array('id' => $id))) { $categoryform->set_data($category); } if ($categoryform->is_cancelled()) { redirect($redirect); } else { if ($data = $categoryform->get_data()) { if (empty($data->id)) { unset($data->id); $data->sortorder = $DB->count_records('user_info_category') + 1; $DB->insert_record('user_info_category', $data, false); } else { $DB->update_record('user_info_category', $data); } profile_reorder_categories(); redirect($redirect); } if (empty($id)) { $strheading = get_string('profilecreatenewcategory', 'admin'); } else { $strheading = get_string('profileeditcategory', 'admin', format_string($category->name)); } /// Print the page echo $OUTPUT->header(); echo $OUTPUT->heading($strheading); $categoryform->display(); echo $OUTPUT->footer(); die; } }
// User categories for FORM. $categoryparameters = array($USER->id, $courseid); $categoryform = new category_form(null, $categoryparameters); echo $OUTPUT->header(); // Data of the current course. $currentcategory = $DB->get_record('course_categories', array('id' => $COURSE->category), 'name'); $curretcourse = $COURSE->shortname; // Case first entry to page if ($selectedcategory == "NULL" && $selectedcourse == "NULL") { $selectedcategory = $currentcategory->name; $selectedcourse = $curretcourse; } // Category and course select echo html_writer::div('<h2>' . get_string('filters', 'mod_emarking') . '</h2>'); $categoryform->display(); if ($categorydata = $categoryform->get_data()) { $selectedcategory = $categorydata->category; } if ($selectedcategory != 'NULL') { $courseparameters = array($USER->id, $selectedcategory, $courseid); $courseform = new courses_form(null, $courseparameters); $courseform->display(); } if ($coursedata = $courseform->get_data()) { $selectedcategory = $coursedata->category; $selectedcourse = $coursedata->courses; } echo $OUTPUT->tabtree(emarking_cycle_tabs($selectedcourse, $selectedcategory, $course), $currenttab); $summarychartdata = json_encode([[0, 0]]); // If you are in the summary tab. if ($currenttab == 0) {