]> git.mjollnir.org Git - moodle.git/commitdiff
course request: MDL-9854 major cleanup to the course request code.
authortjhunt <tjhunt>
Fri, 5 Dec 2008 08:56:54 +0000 (08:56 +0000)
committertjhunt <tjhunt>
Fri, 5 Dec 2008 08:56:54 +0000 (08:56 +0000)
* Rewrite all the forms to use formslib and improve usability.
* Put the place where admins need to go to process approvals in the admin menu.
* Show the request course/pending requests button on the page for the category that requested courses get added to.

admin/settings/courses.php
course/category.php
course/index.php
course/lib.php
course/pending-reject.html [deleted file]
course/pending.php
course/request.php
course/request_form.php
lang/en_utf8/error.php
lang/en_utf8/moodle.php
theme/standard/styles_layout.css

index d0d7013c46406d52bb34cee05f5fb369c3709bca..74f28e6f1f03897fae19cd59427564909f94df9f 100644 (file)
@@ -5,7 +5,8 @@
 if ($hassiteconfig
  or has_capability('moodle/site:backup', $systemcontext)
  or has_capability('moodle/category:manage', $systemcontext)
- or has_capability('moodle/course:create', $systemcontext)) { // speedup for non-admins, add all caps used on this page
+ or has_capability('moodle/course:create', $systemcontext)
+ or has_capability('moodle/site:approvecourse', $systemcontext)) { // speedup for non-admins, add all caps used on this page
 
     $ADMIN->add('courses', new admin_externalpage('coursemgmt', get_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/index.php?categoryedit=on',
             array('moodle/category:manage', 'moodle/course:create')));
@@ -123,6 +124,12 @@ if ($hassiteconfig
     $temp->add(new admin_settings_coursecat_select('defaultrequestcategory', get_string('defaultrequestcategory', 'admin'), get_string('configdefaultrequestcategory', 'admin'), 1));
     $ADMIN->add('courses', $temp);
 
+/// Pending course requests.
+    if (!empty($CFG->enablecourserequests)) {
+        $ADMIN->add('courses', new admin_externalpage('coursespending', get_string('pendingrequests'),
+                $CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
+    }
+
 /// "backups" settingpage
     if (!empty($CFG->backup_version)) {
         $temp = new admin_settingpage('backups', get_string('backups','admin'), 'moodle/site:backup');
index 8bcbfd5acf5f9b58d0d4eaf15295530b7b03cc24..cfc5ae860a485abbaa66c1fac9fe163bb514906f 100644 (file)
         $options['category'] = $category->id;
         print_single_button('edit.php', $options, get_string('addnewcourse'), 'get');
     }
+
+    if (!empty($CFG->enablecourserequests) && $category->id == $CFG->enablecourserequests) {
+        print_course_request_buttons(get_context_instance(CONTEXT_SYSTEM));
+    }
     echo '</div>';
 
     print_course_search();
index 8ca6f2594030f3a62a4f9ab7160612047017f332..65d6bd65d806c960feca81c2cc1b648d360f77c0 100644 (file)
         }
 
         echo '<div class="buttons">';
-        if ($CFG->enablecourserequests and isloggedin() and !isguest() and !has_capability('moodle/course:create', $systemcontext)) {
-        /// Print link to request a new course
-            print_single_button('request.php', NULL, get_string('courserequest'), 'get');
-        }
         if (has_capability('moodle/course:create', $systemcontext)) {
         /// Print link to create a new course
         /// Get the 1st available category
             $options = array('category' => $CFG->defaultrequestcategory);
             print_single_button('edit.php', $options, get_string('addnewcourse'), 'get');
         }
-        if (has_capability('moodle/site:approvecourse', $systemcontext) and !empty($CFG->enablecourserequests)) {
-            print_single_button('pending.php',NULL, get_string('coursespending'),'get');
-        }
+        print_course_request_buttons($systemcontext);
         echo '</div>';
         print_footer();
         exit;
         print_single_button('editcategory.php', $options, get_string('addnewcategory'), 'get');
     }
 
-    if (has_capability('moodle/site:approvecourse', $systemcontext)  and !empty($CFG->enablecourserequests)) {
-        print_single_button('pending.php',NULL, get_string('coursespending'), 'get');
-    }
+    print_course_request_buttons($systemcontext);
     // admin page does not allow custom buttons in the navigation bar
     echo '<div class="singlebutton">';
     echo update_category_button();
index f4fb9792f591a1d793087dbcf930862ff51640af..7985947184c6a3d2b8bd38940ef467abfdde0c99 100644 (file)
@@ -1966,6 +1966,26 @@ function print_category_info($category, $depth, $showcourses = false) {
     echo '</table>';
 }
 
+/**
+ * Print the buttons relating to course requests.
+ *
+ * @param object $systemcontext the system context.
+ */
+function print_course_request_buttons($systemcontext) {
+    global $CFG, $DB;
+    if (empty($CFG->enablecourserequests)) {
+        return;
+    }
+    if (isloggedin() && !isguestuser() && !has_capability('moodle/course:create', $systemcontext)) {
+    /// Print a button to request a new course
+        print_single_button('request.php', NULL, get_string('requestcourse'), 'get');
+    }
+    /// Print a button to manage pending requests
+    if (has_capability('moodle/site:approvecourse', $systemcontext)) {
+        print_single_button('pending.php', NULL, get_string('coursespending'), 'get', '_self', false, '', !$DB->record_exists('course_request', array()));
+    }
+}
+
 /**
  * Prints the turn editing on/off button on course/index.php or course/category.php.
  *
diff --git a/course/pending-reject.html b/course/pending-reject.html
deleted file mode 100644 (file)
index 5f60042..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<form action="pending.php" method="post" id="reject">
-<input type="hidden" name="reject" value="<?php p($reject->id); ?>" />
-<textarea name="rejectnotice" rows="10" cols="50"></textarea><br />
-<input type="submit" value="<?php print_string("savechanges");?>" />
-<input type="button" value="<?php print_string("cancel"); ?>"  onClick="window.location='pending.php';" />
-<input type="hidden" name="sesskey" value="<?php echo sesskey();?>" />
-</form>
\ No newline at end of file
index 15f010fa7d51f4c65838fba438e4cfc95f824588..2f0ef7cdb74cb7f1a16317f0465a13b99ee27752 100644 (file)
 <?php  // $Id$
-       // allow the administrators to look through a list of course requests and either approve them or reject them.
 
-    require_once('../config.php');
-    require_once($CFG->libdir.'/pagelib.php');
-    require_once($CFG->libdir.'/blocklib.php');
-    require_once('lib.php');
-    require_once($CFG->libdir.'/eventslib.php');
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// NOTICE OF COPYRIGHT                                                   //
+//                                                                       //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//          http://moodle.org                                            //
+//                                                                       //
+// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
+//                                                                       //
+// This program is free software; you can redistribute it and/or modify  //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation; either version 2 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// This program is distributed in the hope that it will be useful,       //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details:                          //
+//                                                                       //
+//          http://www.gnu.org/copyleft/gpl.html                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
 
-    require_login();
+/**
+ * Allow the administrator to look through a list of course requests and approve or reject them.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package course
+ *//** */
+
+    require_once(dirname(__FILE__) . '/../config.php');
+    require_once($CFG->libdir . '/pagelib.php');
+    require_once($CFG->libdir . '/blocklib.php');
+    require_once($CFG->libdir . '/adminlib.php');
+    require_once($CFG->dirroot . '/course/lib.php');
+    require_once($CFG->dirroot . '/course/request_form.php');
 
+    require_login();
     require_capability('moodle/site:approvecourse', get_context_instance(CONTEXT_SYSTEM));
 
-    $approve      = optional_param('approve', 0, PARAM_INT);
-    $reject       = optional_param('reject', 0, PARAM_INT);
-    $rejectnotice = optional_param('rejectnotice', '', PARAM_CLEANHTML);
+    $approve = optional_param('approve', 0, PARAM_INT);
+    $reject = optional_param('reject', 0, PARAM_INT);
 
+    $baseurl = $CFG->wwwroot . '/course/pending.php';
+    admin_externalpage_setup('coursespending');
+
+/// Process approval of a course.
     if (!empty($approve) and confirm_sesskey()) {
-        if ($course = $DB->get_record("course_request", array("id"=>$approve))) {
-
-            $category = get_course_category($CFG->defaultrequestcategory);
-
-            $course->category = $CFG->defaultrequestcategory;
-            $course->sortorder = $category->sortorder; // place as the first in category 
-            $course->requested = 1;
-            unset($course->reason);
-            unset($course->id);
-            $teacherid = $course->requester;
-            unset($course->requester);
-            if (!empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor != 'none' && !empty($CFG->restrictbydefault)) {
-                $course->restrictmodules = 1;
-            }
-            if ($courseid = $DB->insert_record("course",$course)) {
-                $page = page_create_object(PAGE_COURSE_VIEW, $courseid);
-                blocks_repopulate_page($page); // Return value not checked because you can always edit later
-                $context = get_context_instance(CONTEXT_COURSE, $courseid);
-                role_assign($CFG->creatornewroleid, $teacherid, 0, $context->id); // assing teacher role
-                $course->id = $courseid;
-                if (!empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor != 'none' && !empty($CFG->restrictbydefault)) { // if we're all or requested we're ok.
-                    $allowedmods = explode(',',$CFG->defaultallowedmodules);
-                    update_restricted_mods($course,$allowedmods);
-                }
-                $DB->delete_records('course_request', array('id'=>$approve));
-                $success = 1;
-                fix_course_sortorder();
-            }
-            if (!empty($success)) {
-                $user = $DB->get_record('user', array('id'=>$teacherid));
-                $a->name = $course->fullname;
-                $a->url = $CFG->wwwroot.'/course/view.php?id='.$courseid;
-
-                $eventdata = new object();
-                $eventdata->modulename        = 'moodle';
-                $eventdata->userfrom          = $USER;
-                $eventdata->userto            = $user;
-                $eventdata->subject           = get_string('courseapprovedsubject');
-                $eventdata->fullmessage       = get_string('courseapprovedemail','moodle',$a);
-                $eventdata->fullmessageformat = FORMAT_PLAIN;
-                $eventdata->fullmessagehtml   = '';
-                $eventdata->smallmessage      = '';                        
-                events_trigger('message_send', $eventdata);
-
-                redirect($CFG->wwwroot.'/course/edit.php?id='.$courseid);
-                exit;
-            }
-            else {
-                print_error('courseapprovedfailed');
-                exit;
+    /// Load the request.
+        if (!$course = $DB->get_record('course_request', array('id' => $approve))) {
+            print_error('unknowncourserequest');
+        }
+
+    /// Get the category courses are added to.
+        $category = get_course_category($CFG->defaultrequestcategory);
+
+    /// Build up a course record based on the request.
+        $course->category = $category->id;
+        $course->sortorder = $category->sortorder; // place as the first in category 
+        $course->requested = 1;
+        unset($course->reason);
+        unset($course->id);
+        $teacherid = $course->requester;
+        unset($course->requester);
+        if (!empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor != 'none' && !empty($CFG->restrictbydefault)) {
+            $course->restrictmodules = 1;
+        }
+
+    /// Insert the record.
+        if ($courseid = $DB->insert_record("course",$course)) {
+            $page = page_create_object(PAGE_COURSE_VIEW, $courseid);
+            blocks_repopulate_page($page); // Return value not checked because you can always edit later
+            $context = get_context_instance(CONTEXT_COURSE, $courseid);
+            role_assign($CFG->creatornewroleid, $teacherid, 0, $context->id); // assing teacher role
+            $course->id = $courseid;
+            if (!empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor != 'none' && !empty($CFG->restrictbydefault)) { // if we're all or requested we're ok.
+                $allowedmods = explode(',',$CFG->defaultallowedmodules);
+                update_restricted_mods($course,$allowedmods);
             }
+            $DB->delete_records('course_request', array('id'=>$approve));
+            $success = 1;
+            fix_course_sortorder();
+        }
+        if (!empty($success)) {
+            $user = $DB->get_record('user', array('id' => $teacherid));
+            $a->name = $course->fullname;
+            $a->url = $CFG->wwwroot.'/course/view.php?id=' . $courseid;
+            $eventdata = new object();
+            $eventdata->modulename        = 'moodle';
+            $eventdata->component         = 'course';
+            $eventdata->name              = 'courserequestapproved';
+            $eventdata->userfrom          = $USER;
+            $eventdata->userto            = $user;
+            $eventdata->subject           = get_string('courseapprovedsubject');
+            $eventdata->fullmessage       = get_string('courseapprovedemail2', 'moodle', $a);
+            $eventdata->fullmessageformat = FORMAT_PLAIN;
+            $eventdata->fullmessagehtml   = '';
+            $eventdata->smallmessage      = '';
+            events_trigger('message_send', $eventdata);
+
+            redirect($CFG->wwwroot.'/course/edit.php?id=' . $courseid);
+        } else {
+            print_error('courseapprovedfailed');
         }
     }
 
-    $strtitle = get_string('coursespending');
-    $strheading = get_string(((!empty($reject)) ? 'coursereject' : 'coursespending'));
+/// Process rejection of a course.
+    if (!empty($reject)) {
+    /// Load the request.
+        if (!$course = $DB->get_record('course_request', array('id' => $reject))) {
+            print_error('unknowncourserequest');
+        }
 
-    print_header($strtitle,$strheading,build_navigation(array(array('name'=>$strheading,'link'=>'','type'=>'misc'))));
+    /// Prepare the form.
+        $rejectform = new reject_request_form($baseurl);
+        $default = new stdClass();
+        $default->reject = $reject;
+        $rejectform->set_data($default);
 
-    if (!empty($reject) and confirm_sesskey()) {
-        if ($reject = $DB->get_record("course_request", array("id"=>$reject))) {
-            if (empty($rejectnotice)) {
-                //  display a form for writing a reason
-                print_simple_box_start('center');
-                print_string('courserejectreason');
-                include('pending-reject.html');
-                print_simple_box_end();
-            }
-            else {
-                $user = $DB->get_record("user", array("id"=>$reject->requester));
-                
-                $eventdata = new object();
-                $eventdata->modulename        = 'moodle';
-                $eventdata->userfrom          = $USER;
-                $eventdata->userto            = $user;
-                $eventdata->subject           = get_string('courserejectsubject');
-                $eventdata->fullmessage       = get_string('courserejectemail','moodle',$rejectnotice);
-                $eventdata->fullmessageformat = FORMAT_PLAIN;
-                $eventdata->fullmessagehtml   = '';
-                $eventdata->smallmessage      = '';                        
-                events_trigger('message_send', $eventdata);
-            
-                $DB->delete_records("course_request", array("id"=>$reject->id));
-                notice(get_string('courserejected'),'pending.php');
-            }
+    /// Standard form processing if statement.
+        if ($rejectform->is_cancelled()){
+            redirect($baseurl);
+    
+        } else if ($data = $rejectform->get_data()) {
+        /// Send an email to the requester.
+            $user = $DB->get_record('user', array('id' => $course->requester));
+            $eventdata = new object();
+            $eventdata->modulename        = 'moodle';
+            $eventdata->component         = 'course';
+            $eventdata->name              = 'courserequestrejected';
+            $eventdata->userfrom          = $USER;
+            $eventdata->userto            = $user;
+            $eventdata->subject           = get_string('courserejectsubject');
+            $eventdata->fullmessage       = get_string('courserejectemail', 'moodle', $data->rejectnotice);
+            $eventdata->fullmessageformat = FORMAT_PLAIN;
+            $eventdata->fullmessagehtml   = '';
+            $eventdata->smallmessage      = '';
+            events_trigger('message_send', $eventdata);
+
+        /// Delete the request
+            $DB->delete_records('course_request', array('id' => $course->id));
+
+        /// Redirect back to the course listing.
+            redirect($baseurl, get_string('courserejected'));
         }
-    } else if ($pending = $DB->get_records("course_request")) {
-        // loop through
-        $table->cellpadding = 4;
-        $table->cellspacing = 3;
-        $table->align = array('center','center','center','center','center','center','center');
-        $table->head = array('&nbsp;',get_string('shortnamecourse'),get_string('fullnamecourse'),get_string('requestedby'),get_string('summary'),
-                               get_string('requestreason'),'');
+
+    /// 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 = $DB->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('&nbsp;', get_string('shortname'), get_string('fullname'),
+                get_string('requestedby'), get_string('summary'), get_string('requestreason'), get_string('action'));
         $strrequireskey = get_string('requireskey');
+
+    /// Loop over requested courses.
         foreach ($pending as $course) {
             $requester = $DB->get_record('user', array('id'=>$course->requester));
-            // check here for shortname collisions and warn about them.
-            if ($match = $DB->get_record("course", array("shortname"=>$course->shortname))) {
+            $row = array();
+
+        /// Check here for shortname collisions and warn about them.
+            if ($DB->record_exists('course', array('shortname' => $course->shortname))) {
                 $course->shortname .= ' [*]';
                 $collision = 1;
             }
-            //do not output raw html from request, quote html entities using s()!!
-            $table->data[] = array(((!empty($course->password)) ?
-                                    '<img hspace="1" alt="'.$strrequireskey.'" class="icon" src="'.$CFG->pixpath.'/i/key.gif" />' : ''),
-                                   format_string($course->shortname),format_string($course->fullname),fullname($requester),
-                                   format_string($course->summary),format_string($course->reason),
-                                   '<a href="pending.php?approve='.$course->id.'&amp;sesskey='.sesskey().'">'.get_string('approve').'</a> | '
-                                   .'<a href="pending.php?reject='.$course->id.'&amp;sesskey='.sesskey().'">'.get_string('reject').'</a>');
+
+        /// Show an enrolment key icon in the first column if applicable.
+            if (!empty($course->password)) {
+                $row[] = '<img hspace="1" alt="'.$strrequireskey.'" class="icon" src="'.$CFG->pixpath.'/i/key.gif" />';
+            } else {
+                $row[] = '';
+            }
+
+        /// Info in the other columns.
+            $row[] = format_string($course->shortname);
+            $row[] = format_string($course->fullname);
+            $row[] = fullname($requester);
+            $row[] = format_string($course->summary);
+            $row[] = format_string($course->reason);
+            $row[] = print_single_button($baseurl, array('approve' => $course->id, 'sesskey' => sesskey()), get_string('approve'), 'get', '', true) .
+                    print_single_button($baseurl, array('reject' => $course->id), get_string('rejectdots'), 'get', '', true);
+
+        /// Add the row to the table.
+            $table->data[] = $row;
         }
+
+    /// Display the table.
         print_table($table);
+
+    /// Message about name collisions, if necessary.
         if (!empty($collision)) {
             print_string('shortnamecollisionwarning');
         }
-    } else {
-        notice(get_string('nopendingcourses'));
-        // no pending messages.
     }
 
-print_footer();
-
-
+/// Finish off the page.
+    print_single_button($CFG->wwwroot . '/course/index.php', array(), get_string('backtocourselisting'));
+    admin_externalpage_print_footer();
 ?>
index 9c3ead040ce469e7bbeeb3ea0f42ea4267995362..36a706823d2cc5f67382ab5cc08677dccb3239f2 100644 (file)
@@ -1,52 +1,73 @@
 <?php  // $Id$
 
-    /// this allows a student to request a course be created for them.
-
-    require_once('../config.php');
-    require_once('request_form.php');
-
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// NOTICE OF COPYRIGHT                                                   //
+//                                                                       //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//          http://moodle.org                                            //
+//                                                                       //
+// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
+//                                                                       //
+// This program is free software; you can redistribute it and/or modify  //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation; either version 2 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// This program is distributed in the hope that it will be useful,       //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details:                          //
+//                                                                       //
+//          http://www.gnu.org/copyleft/gpl.html                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+/**
+ * Allows a user to request a course be created for them.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package course
+ *//** */
+
+    require_once(dirname(__FILE__) . '/../config.php');
+    require_once($CFG->dirroot . '/course/request_form.php');
+
+/// Where we came from. Used in a number of redirects.
+    $returnurl = $CFG->wwwroot . '/course/index.php';
+
+/// Check permissions.
     require_login();
-
-    if (isguest()) {
-        print_error("noguest");
+    if (isguestuser()) {
+        print_error('guestsarenotallowed', '', $returnurl);
     }
-
     if (empty($CFG->enablecourserequests)) {
-        print_error('courserequestdisabled');
+        print_error('courserequestdisabled', '', $returnurl);
     }
 
-    $requestform = new course_request_form();
-
-    $strtitle = get_string('courserequest');
-    $navlinks = array();
-    $navlinks[] = array('name' => $strtitle, 'link' => null, 'type' => 'misc');
-    $navigation = build_navigation($navlinks);
-
-    print_header($strtitle, $strtitle, $navigation, $requestform->focus());
-
-    print_simple_box_start('center');
-    print_string('courserequestintro');
-    print_simple_box_end();
-
+/// Set up the form.
+    $requestform = new course_request_form($CFG->wwwroot . '/course/request.php');
 
+/// Standard form processing if statement.
     if ($requestform->is_cancelled()){
+        redirect($returnurl);
 
-        redirect($CFG->wwwroot);
-
-    }elseif ($data = $requestform->get_data()) {
+    } else if ($data = $requestform->get_data()) {
+    /// Record the request.
         $data->requester = $USER->id;
-
-        if ($DB->insert_record('course_request', $data)) {
-            notice(get_string('courserequestsuccess'));
-        } else {
-            notice(get_string('courserequestfailed'));
+        if (!$DB->insert_record('course_request', $data)) {
+            print_error('errorsavingrequest', '', $returnurl);
         }
 
-    } else {
-
-        $requestform->display();
+    /// and redirect back to the course listing.
+        notice(get_string('courserequestsuccess'), $returnurl);
     }
 
+/// Show the request form.
+    $strtitle = get_string('courserequest');
+    print_header($strtitle, $strtitle, build_navigation($strtitle), $requestform->focus());
+    print_heading($strtitle);
+    $requestform->display();
     print_footer();
 
-?>
+?>
\ No newline at end of file
index a7637ac3a1a17b9eb310302bdded3b0f8b08616f..ad2782576b4efc48944a80a408f6ccbae5c3c144 100644 (file)
@@ -1,34 +1,73 @@
 <?php  // $Id$
 
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// NOTICE OF COPYRIGHT                                                   //
+//                                                                       //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//          http://moodle.org                                            //
+//                                                                       //
+// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
+//                                                                       //
+// This program is free software; you can redistribute it and/or modify  //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation; either version 2 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// This program is distributed in the hope that it will be useful,       //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details:                          //
+//                                                                       //
+//          http://www.gnu.org/copyleft/gpl.html                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+/**
+ * Forms associated with requesting courses, and having requests approved.
+ * Note that several related forms are defined in this one file.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package course
+ *//** */
+
 require_once($CFG->libdir.'/formslib.php');
 
+/**
+ * A form for a user to request a course.
+ */
 class course_request_form extends moodleform {
     function definition() {
         $mform =& $this->_form;
 
-        $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"');
+        $mform->addElement('header','coursedetails', get_string('courserequestdetails'));
+
+        $mform->addElement('text', 'fullname', get_string('fullname'), 'maxlength="254" size="50"');
+        $mform->setHelpButton('fullname', array('coursefullname', get_string('fullname')), true);
         $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
-        $mform->setType('fullname', PARAM_TEXT);
+        $mform->setType('fullname', PARAM_MULTILANG);
 
-        $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"');
+        $mform->addElement('text', 'shortname', get_string('shortname'), 'maxlength="100" size="20"');
+        $mform->setHelpButton('shortname', array('courseshortname', get_string('shortname')), true);
         $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
-        $mform->setType('shortname', PARAM_TEXT);
+        $mform->setType('shortname', PARAM_MULTILANG);
 
         $mform->addElement('htmleditor', 'summary', get_string('summary'), array('rows'=>'15', 'cols'=>'50'));
-        $mform->addRule('summary', get_string('missingsummary'), 'required', null, 'client');
+        $mform->setHelpButton('summary', array('text2', get_string('helptext')), true);
         $mform->setType('summary', PARAM_RAW);
-        $mform->setHelpButton('summary', array('text2', get_string('helptext')));
 
+        $mform->addElement('passwordunmask', 'password', get_string('enrolmentkey'), 'size="25"');
+        $mform->setHelpButton('password', array('enrolmentkey', get_string('enrolmentkey')), true);
+        $mform->setDefault('password', '');
+        $mform->setType('password', PARAM_RAW);
 
-        $mform->addElement('textarea', 'reason', get_string('courserequestreason'), array('rows'=>'15', 'cols'=>'50'));
+        $mform->addElement('header','requestreason', get_string('courserequestreason'));
+
+        $mform->addElement('textarea', 'reason', get_string('courserequestsupport'), array('rows'=>'15', 'cols'=>'50'));
         $mform->addRule('reason', get_string('missingreqreason'), 'required', null, 'client');
         $mform->setType('reason', PARAM_TEXT);
 
-        $mform->addElement('text', 'password', get_string('enrolmentkey'), 'size="25"');
-        $mform->setType('password', PARAM_RAW);
-
-
-        $this->add_action_buttons();
+        $this->add_action_buttons(true, get_string('requestcourse'));
     }
 
     function validation($data, $files) {
@@ -51,27 +90,42 @@ class course_request_form extends moodleform {
         }
 
         if (!empty($foundcourses)) {
-
-            if (!empty($foundcourses)) {
-                foreach ($foundcourses as $foundcourse) {
-                    if (isset($foundcourse->requester) && $foundcourse->requester) {
-                        $pending = 1;
-                        $foundcoursenames[] = $foundcourse->fullname.' [*]';
-                    } else {
-                        $foundcoursenames[] = $foundcourse->fullname;
-                    }
+            foreach ($foundcourses as $foundcourse) {
+                if (!empty($foundcourse->requester)) {
+                    $pending = 1;
+                    $foundcoursenames[] = $foundcourse->fullname.' [*]';
+                } else {
+                    $foundcoursenames[] = $foundcourse->fullname;
                 }
-                $foundcoursenamestring = implode(',', $foundcoursenames);
+            }
+            $foundcoursenamestring = implode(',', $foundcoursenames);
 
-                $errors['shortname'] = get_string('shortnametaken', '', $foundcoursenamestring);
-                if (!empty($pending)) {
-                    $errors['shortname'] .= get_string('starpending');
-                }
+            $errors['shortname'] = get_string('shortnametaken', '', $foundcoursenamestring);
+            if (!empty($pending)) {
+                $errors['shortname'] .= get_string('starpending');
             }
         }
 
         return $errors;
     }
+}
+
+/**
+ * A form for an administrator to reject a course request.
+ */
+class reject_request_form extends moodleform {
+    function definition() {
+        $mform =& $this->_form;
 
+        $mform->addElement('hidden', 'reject', 0);
+
+        $mform->addElement('header','coursedetails', get_string('coursereasonforrejecting'));
+
+        $mform->addElement('textarea', 'rejectnotice', get_string('coursereasonforrejectingemail'), array('rows'=>'15', 'cols'=>'50'));
+        $mform->addRule('rejectnotice', get_string('missingreqreason'), 'required', null, 'client');
+        $mform->setType('rejectnotice', PARAM_TEXT);
+
+        $this->add_action_buttons(true, get_string('reject'));
+    }
 }
 ?>
index 42fa1fe70dc4c7a1bdd5b56d74974a1535522f25..b046643ea194ed7ec2085dc27945fe14a9f20c12 100644 (file)
@@ -211,6 +211,7 @@ $string['errorcreatingfile'] = 'Error creating file \"$a\"';
 $string['errorcreatingrole'] = 'Error creating role';
 $string['erroronline'] = 'Error on line $a';
 $string['errorreadingfile'] = 'Error reading file \"$a\"';
+$string['errorsavingrequest'] = 'An error occurred when trying to save your request.';
 $string['errorunzippingfiles'] = 'Error unzipping files';
 $string['errorupdatingcoursevisibility'] = 'Error updating the course visibility';
 $string['errorsettinguserpref'] = 'Error setting user preference';
@@ -233,8 +234,9 @@ $string['groupnotaddederror'] = 'Group \"$a\" not added';
 $string['groupunknown'] = 'Group $a not associated to specified course';
 $string['guestnocomment'] = 'Guests are not allowed to post comments!';
 $string['guestnoeditprofile'] = 'The guest user cannot edit their profile';
-$string['guestnorate'] = 'Guests are not allowed to rate entries';
 $string['guestnoeditprofileother'] = 'The guest user profile cannot be edited';
+$string['guestnorate'] = 'Guests are not allowed to rate entries';
+$string['guestsarenotallowed'] = 'The guest user is not allowed to do this';
 $string['hashpoolproblem'] = 'Incorrect pool file content $a.';
 $string['invalidaction'] = 'Invalid action parameter';
 $string['invalidactivityid'] = 'Invalid Activity ID';
@@ -418,6 +420,7 @@ $string['unknowcontext'] = 'This is an unknown context ($a) in get_child_context
 $string['unknowformat'] = 'Format not known ($a)';
 $string['unknowncourse'] = 'Unknown course named \"$a\"';
 $string['unknowncourseidnumber'] = 'Unknown Course ID \"$a\"';
+$string['unknowncourserequest'] = 'Unknown course request';
 $string['unknownhelp'] = 'Unknown help topic $a';
 $string['unknowngroup'] = 'Unknown group \"$a\"';
 $string['unknownrole'] = 'Unknown role \"$a\"';
index c5a36578a0b2ecb4891737c904871558a9ceb0af..24ddeac9f1915f6ace2f2e776a89be3a5a6ebd97 100644 (file)
@@ -137,6 +137,7 @@ $string['availablecourses'] = 'Available Courses';
 $string['backtoparticipants'] = 'Back to participants list';
 $string['back'] = 'Back';
 $string['backto'] = 'Back to $a';
+$string['backtocourselisting'] = 'Back to course listing';
 $string['backup'] = 'Backup';
 $string['backupactivehelp'] = 'Choose whether or not to do automated backups.';
 $string['backupcancelled'] = 'Backup Cancelled';
@@ -304,6 +305,8 @@ $string['coursemessage'] = 'Message course users';
 $string['coursenotaccessible'] = 'This course does not allow public access';
 $string['courseoverview'] = 'Course overview';
 $string['courseoverviewgraph'] = 'Course overview graph';
+$string['coursereasonforrejecting'] = 'Your reasons for rejecting this request';
+$string['coursereasonforrejectingemail'] = 'This will be emailed to the requester';
 $string['coursereject'] = 'Reject a course request';
 $string['courserejected'] = 'Course has been rejected and the requester has been notified.';
 $string['courserejectemail'] = 'Sorry, but the course you requested has been rejected. Here is the reason provided:
@@ -313,10 +316,12 @@ $string['courserejectreason'] = 'Outline your reasons for rejecting this course<
 $string['courserejectsubject'] = 'Your course has been rejected';
 $string['coursereports'] = 'Course reports';
 $string['courserequest'] = 'Course request';
+$string['courserequestdetails'] = 'Details of the course you are requesting';
 $string['courserequestfailed'] = 'For some reason, your course request could not be saved';
 $string['courserequestintro'] = 'Use this form to request a course to be created for you.<br />Try and fill in as much information as you can to allow<br />the administrators to understand your reasons for wanting this course.';
 $string['courserequestreason'] = 'Reasons for wanting this course';
 $string['courserequestsuccess'] = 'Successfully saved your course request. Expect an email within a few days with the outcome';
+$string['courserequestsupport'] = 'Supporting information to help the administrator evaluate this request';
 $string['courserestore'] = 'Course restore';
 $string['courses'] = 'Courses';
 $string['coursescategory'] = 'Courses in the same category';
@@ -1206,6 +1211,7 @@ $string['payments'] = 'Payments';
 $string['paymentsorry'] = 'Thank you for your payment!  Unfortunately your payment has not yet been fully processed, and you are not yet registered to enter the course \"$a->fullname\".  Please try continuing to the course in a few seconds, but if you continue to have trouble then please alert the $a->teacher or the site administrator';
 $string['paymentthanks'] = 'Thank you for your payment!  You are now enrolled in your course:<br />\"$a\"';
 $string['people'] = 'People';
+$string['pendingrequests'] = 'Pending requests';
 $string['periodending'] = 'Period ending ($a)';
 $string['personal'] = 'Personal';
 $string['personalprofile'] = 'Personal profile';
@@ -1278,6 +1284,7 @@ $string['registrationno'] = 'No, I do not want to receive email';
 $string['registrationsend'] = 'Send registration information to moodle.org';
 $string['registrationyes'] = 'Yes, please notify me about important issues';
 $string['reject'] = 'Reject';
+$string['rejectdots'] = 'Reject...';
 $string['reload'] = 'Reload';
 $string['remoteappuser'] = 'Remote $a User';
 $string['remove'] = 'Remove';
index c3fe009c6ec1aca7aa90d8d25df2a6b7514e7500..64da00c54c800aa6ed5594677d55ff7b5b8cfe26 100644 (file)
@@ -2300,7 +2300,21 @@ body#course-info .generalbox.info {
 #my-index .name {
   margin-left: 5px;
 }
-
+#course-pending .pendingcourserequests {
+  margin-bottom: 1em;
+}
+#course-pending .pendingcourserequests .singlebutton {
+  display: inline;
+}
+#course-pending .pendingcourserequests .cell {
+  padding: 0 5px;
+}
+#course-pending .pendingcourserequests .cell.c6 {
+  white-space: nowrap;
+}
+#course-pending .singlebutton {
+  text-align: center;
+}
 .categorylist {
   width: 90%;
   margin-left: auto;