Example #1
0
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;
    }
}
Example #2
0
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;
    }
}
Example #3
0
// Capability access
if (!has_capability('mod/emarking:viewemarkingcycle', $context)) {
    print_error(get_string("notallowed", "mod_emarking"));
}
// URL for current page.
$url = new moodle_url("/mod/emarking/reports/cycle.php", array("course" => $course->id, "emarking" => $emarkingid));
//Page definition.
$PAGE->set_url($url);
$PAGE->set_context($context);
$PAGE->set_course($course);
$PAGE->set_title(get_string("emarking", "mod_emarking"));
$PAGE->set_pagelayout("incourse");
$PAGE->navbar->add(get_string("cycle", "mod_emarking"));
// 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;
}