$default = new stdClass(); $default->reject = $course->id; $rejectform->set_data($default); /// Standard form processing if statement. if ($rejectform->is_cancelled()) { redirect($baseurl); } else { if ($data = $rejectform->get_data()) { /// Reject the request $course->reject($data->rejectnotice); /// Redirect back to the course listing. redirect($baseurl, get_string('courserejected')); } } /// Display the form for giving a reason for rejecting the request. echo $OUTPUT->header($rejectform->focus()); $rejectform->display(); echo $OUTPUT->footer(); exit; } /// Print a list of all the pending requests. echo $OUTPUT->header(); $pending = $DB->get_records('course_request'); if (empty($pending)) { echo $OUTPUT->heading(get_string('nopendingcourses')); } else { echo $OUTPUT->heading(get_string('coursespending')); /// Build a table of all the requests. $table = new html_table(); $table->attributes['class'] = 'pendingcourserequests generaltable'; $table->align = array('center', 'center', 'center', 'center', 'center', 'center');
/// Standard form processing if statement. if ($rejectform->is_cancelled()) { redirect($baseurl); } else { if ($data = $rejectform->get_data()) { /// Send an email to the requester. $user = get_record('user', 'id', $course->requester); email_to_user($user, $USER, get_string('courserejectsubject'), get_string('courserejectemail', '', $data->rejectnotice)); /// Delete the request delete_records('course_request', 'id', $course->id); /// Redirect back to the course listing. redirect($baseurl, get_string('courserejected')); } } /// Display the form for giving a reason for rejecting the request. admin_externalpage_print_header($rejectform->focus()); $rejectform->display(); admin_externalpage_print_footer(); exit; } /// Print a list of all the pending requests. admin_externalpage_print_header(); $pending = get_records('course_request'); if (empty($pending)) { print_heading(get_string('nopendingcourses')); } else { print_heading(get_string('coursespending')); /// Build a table of all the requests. $table->class = 'pendingcourserequests generaltable'; $table->align = array('center', 'center', 'center', 'center', 'center', 'center', 'center'); $table->head = array(' ', get_string('shortname'), get_string('fullname'), get_string('requestedby'), get_string('summary'), get_string('requestreason'), get_string('action'));