Пример #1
0
$PAGE->set_url('/local/examtype/edit.php', array('id' => $id));

$PAGE->set_context($systemcontext);
if (!has_capability('local/examtype:manage', $systemcontext)) {
    print_error('You dont have permissions');
}
$returnurl = new moodle_url('/local/examtype/index.php', array('id' => $id));
$currenturl = "{$CFG->wwwroot}/local/examtype/index.php";
$strheading = get_string('addeditexamtype', 'local_examtype');
$instance = new cobalt_examtype();
// delete function 
if ($delete) {
    $PAGE->url->param('delete', 1);
    if ($confirm and confirm_sesskey()) {
        $result = $instance->examtype_delete_instance($id);
        $instance->success_error_msg($result, 'success_del_exam', 'error_del_exam', $currenturl, null);
        redirect($returnurl);
    }
    $strheading = get_string('deleteexamtype', 'local_examtype');
    $PAGE->navbar->add(get_string('manageexamtype', 'local_examtype'), new moodle_url('/local/examtype/index.php', array('id' => $id)));

    $PAGE->navbar->add($strheading);
    $PAGE->set_title($strheading);
    echo $OUTPUT->header();
    echo $OUTPUT->heading($strheading);
    if (!$exists = $DB->get_records('local_scheduledexams', array('examtype' => $id))) {
        $yesurl = new moodle_url('/local/examtype/edit.php', array('id' => $id, 'delete' => 1, 'confirm' => 1, 'sesskey' => sesskey()));
        $message = get_string('delconfirm', 'local_examtype');
        echo $OUTPUT->box_start('generalbox');
        echo $OUTPUT->confirm($message, $yesurl, $returnurl);
        echo $OUTPUT->box_end();