]> git.mjollnir.org Git - moodle.git/commitdiff
Get only courses made transactions. This lessens the course list; Merged from 17stable.
authorethem <ethem>
Mon, 30 Oct 2006 08:33:00 +0000 (08:33 +0000)
committerethem <ethem>
Mon, 30 Oct 2006 08:33:00 +0000 (08:33 +0000)
enrol/authorize/locallib.php

index ca7aea1ac3fd81fab4d9f04f479c7846d6746400..4dee694fbd2be96199c2137e5248d08635532f80 100644 (file)
@@ -18,7 +18,7 @@ define('ORDER_VOID',    'void');
  */
 function authorize_print_orders($courseid, $userid)
 {
-    global $CFG, $USER;
+    global $CFG, $USER, $SITE;
     global $strs, $authstrs;
     require_once($CFG->libdir.'/tablelib.php');
 
@@ -44,19 +44,16 @@ function authorize_print_orders($courseid, $userid)
                         AN_STATUS_TEST => $authstrs->tested
     );
 
-    $sql = "SELECT id, fullname FROM {$CFG->prefix}course ";
+    $sql = "SELECT c.id, c.fullname FROM {$CFG->prefix}course c INNER JOIN {$CFG->prefix}enrol_authorize e ON c.id = e.courseid ";
     if ($CFG->enrol == 'authorize') { // default enrolment plugin
-        $sql .= "WHERE (enrol IS NULL) OR (enrol='') OR (enrol = 'authorize') ";
+        $sql .= "WHERE (c.enrol IS NULL) OR (c.enrol='') OR (c.enrol = 'authorize') ";
     }
     else {
-        $sql .= "WHERE (enrol = 'authorize') ";
+        $sql .= "WHERE (c.enrol = 'authorize') ";
     }
-    $sql .= "ORDER BY sortorder, fullname";
-    if ($courses = get_records_sql($sql)) {
-        $popupcrs = array();
-        foreach ($courses as $crs) {
-            $popupcrs[$crs->id] = $crs->fullname;
-        }
+    $sql .= "ORDER BY c.sortorder, c.fullname";
+    if ($popupcrs = get_records_sql_menu($sql)) {
+        $popupcrs[$SITE->id] = $SITE->fullname;
         echo "<table border='0' width='100%' cellspacing=0 cellpadding=3 class='generaltable generalbox'>";
         echo "<tr>";
         echo "<td width='5%'>$strs->status: </td><td width='10%'>";popup_form($baseurl.'&amp;course='.$courseid.'&amp;status=',$statusmenu,'statusmenu',$status,'','','',false);echo"</td>\n";