Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/course/pending.php
Go to the documentation of this file.
00001 <?php
00002 
00004 //                                                                       //
00005 // NOTICE OF COPYRIGHT                                                   //
00006 //                                                                       //
00007 // Moodle - Modular Object-Oriented Dynamic Learning Environment         //
00008 //          http://moodle.org                                            //
00009 //                                                                       //
00010 // Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
00011 //                                                                       //
00012 // This program is free software; you can redistribute it and/or modify  //
00013 // it under the terms of the GNU General Public License as published by  //
00014 // the Free Software Foundation; either version 2 of the License, or     //
00015 // (at your option) any later version.                                   //
00016 //                                                                       //
00017 // This program is distributed in the hope that it will be useful,       //
00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of        //
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
00020 // GNU General Public License for more details:                          //
00021 //                                                                       //
00022 //          http://www.gnu.org/copyleft/gpl.html                         //
00023 //                                                                       //
00025 
00033 require_once(dirname(__FILE__) . '/../config.php');
00034 require_once($CFG->libdir . '/adminlib.php');
00035 require_once($CFG->dirroot . '/course/lib.php');
00036 require_once($CFG->dirroot . '/course/request_form.php');
00037 
00038 require_login();
00039 require_capability('moodle/site:approvecourse', get_context_instance(CONTEXT_SYSTEM));
00040 
00041 $approve = optional_param('approve', 0, PARAM_INT);
00042 $reject = optional_param('reject', 0, PARAM_INT);
00043 
00044 $baseurl = $CFG->wwwroot . '/course/pending.php';
00045 admin_externalpage_setup('coursespending');
00046 
00048 if (!empty($approve) and confirm_sesskey()) {
00050     $course = new course_request($approve);
00051     $courseid = $course->approve();
00052 
00053     if ($courseid !== false) {
00054         redirect($CFG->wwwroot.'/course/edit.php?id=' . $courseid);
00055     } else {
00056         print_error('courseapprovedfailed');
00057     }
00058 }
00059 
00061 if (!empty($reject)) {
00062     // Load the request.
00063     $course = new course_request($reject);
00064 
00065     // Prepare the form.
00066     $rejectform = new reject_request_form($baseurl);
00067     $default = new stdClass();
00068     $default->reject = $course->id;
00069     $rejectform->set_data($default);
00070 
00072     if ($rejectform->is_cancelled()){
00073         redirect($baseurl);
00074 
00075     } else if ($data = $rejectform->get_data()) {
00076 
00078         $course->reject($data->rejectnotice);
00079 
00081         redirect($baseurl, get_string('courserejected'));
00082     }
00083 
00085     echo $OUTPUT->header($rejectform->focus());
00086     $rejectform->display();
00087     echo $OUTPUT->footer();
00088     exit;
00089 }
00090 
00092 echo $OUTPUT->header();
00093 
00094 $pending = $DB->get_records('course_request');
00095 if (empty($pending)) {
00096     echo $OUTPUT->heading(get_string('nopendingcourses'));
00097 } else {
00098     echo $OUTPUT->heading(get_string('coursespending'));
00099 
00101     $table = new html_table();
00102     $table->attributes['class'] = 'pendingcourserequests generaltable';
00103     $table->align = array('center', 'center', 'center', 'center', 'center', 'center');
00104     $table->head = array(get_string('shortnamecourse'), get_string('fullnamecourse'),
00105             get_string('requestedby'), get_string('summary'), get_string('requestreason'), get_string('action'));
00106 
00107     foreach ($pending as $course) {
00108         $course = new course_request($course);
00109 
00110         // Check here for shortname collisions and warn about them.
00111         $course->check_shortname_collision();
00112 
00113         $row = array();
00114         $row[] = format_string($course->shortname);
00115         $row[] = format_string($course->fullname);
00116         $row[] = fullname($course->get_requester());
00117         $row[] = $course->summary;
00118         $row[] = format_string($course->reason);
00119         $row[] = $OUTPUT->single_button(new moodle_url($baseurl, array('approve' => $course->id, 'sesskey' => sesskey())), get_string('approve'), 'get') .
00120                  $OUTPUT->single_button(new moodle_url($baseurl, array('reject' => $course->id)), get_string('rejectdots'), 'get');
00121 
00123         $table->data[] = $row;
00124     }
00125 
00127     echo html_writer::table($table);
00128 
00130     if (!empty($collision)) {
00131         print_string('shortnamecollisionwarning');
00132     }
00133 }
00134 
00136 echo $OUTPUT->single_button($CFG->wwwroot . '/course/index.php', get_string('backtocourselisting'));
00137 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations