]> git.mjollnir.org Git - moodle.git/commitdiff
Another big checkin.
authormoodler <moodler>
Thu, 7 Aug 2003 16:01:31 +0000 (16:01 +0000)
committermoodler <moodler>
Thu, 7 Aug 2003 16:01:31 +0000 (16:01 +0000)
This includes some significant cleanups to the new course categories
system.  The basic idea is that the categories/course browser is now
unified under one system, and admin features related to that have
all been moved into the browser (as little icons).

I'm much happier with this as a foundation that can scale and be
built upon.

Still to go:

  - searching
  - paging
  - polishing

Also in here are a lot of little cleanups around the place, such as
the initial setup process.

22 files changed:
admin/config.php
admin/index.php
admin/site.html
admin/site.php
admin/teacher.php
course/categories.php [deleted file]
course/category.php
course/edit.html
course/edit.php
course/index.php
course/lib.php
lang/en/docs/release.html
lang/en/forum.php
lang/en/moodle.php
lib/datalib.php
lib/db/mysql.php
lib/db/mysql.sql
lib/db/postgres7.php
lib/db/postgres7.sql
lib/weblib.php
user/edit.php
version.php

index 05197f75bccf1beeeb9c141ac6755df90d89afa4..d84f911fb7a3469a120839bb8212e80f60e647c3 100644 (file)
@@ -71,7 +71,7 @@
     } else {
         print_header();
         print_heading($strconfigvariables);
-        print_simple_box(get_string("configintro"), "center");
+        print_simple_box(get_string("configintro"), "center", "50%");
         echo "<br />";
     }
 
index 7fd01bdc45f2561d01732cec9e6404f776cf45b7..4eeb9585313e6015bbc33455c1075a20a3593f2f 100644 (file)
                if (file_exists("$CFG->dirroot/admin/$CFG->dbtype")) {
             $table->data[0][0] .= "<p><a href=\"$CFG->dbtype/frame.php\">".get_string("managedatabase")."</a></p>";
                }
-               $table->data[0][1] = "<p><a href=\"../course/edit.php\">".get_string("addnewcourse")."</a></p>".
-                         "<p><a href=\"teacher.php\">".get_string("assignteachers")."</a></p>".
-                         "<p><a href=\"../course/delete.php\">".get_string("deletecourse")."</a></p>".
-                         "<p><a href=\"../course/categories.php\">".get_string("categories")."</a></p>";
-        $table->data[0][1] .= "<p><a href=\"../backup/backup.php\">".get_string("coursebackup")."</a></p>";
+               $table->data[0][1] = "<p><a href=\"../course/index.php?edit=on\">".get_string("coursemanagement")."</a></p>".
+                             "<p><a href=\"../course/edit.php\">".get_string("addnewcourse")."</a></p>";
         $table->data[0][1] .= "<p><a href=\"../files/index.php?id=$site->id\">".get_string("courserestore")."</a></p>";
         if ($CFG->auth == "email" || $CFG->auth == "none" || $CFG->auth == "manual") {
                    $table->data[0][2] = "<p><a href=\"user.php?newuser=true\">".get_string("addnewuser")."</a></p>";
index a013c479153bee0503737e1a5eb87a80f08836c4..2c4dadcc305da3fe62f0bc92c08602f612d3c164 100644 (file)
         </td>
 </tr>
 <tr valign=top>
-       <td><p><?php print_string("wordforteacher") ?>:</td>
+       <td align=right><p><?php print_string("wordforteacher") ?>:</td>
        <td><input type="text" name="teacher" maxlength="100" size=25 value="<?php p($form->teacher) ?>">
        (<?php print_string("wordforteachereg") ?>) 
     <?php if (isset($err["teacher"])) formerr($err["teacher"]); ?>
        </td>
 </tr>
 <tr valign=top>
-       <td><p><?php print_string("wordforteachers") ?>:</td>
+       <td align=right><p><?php print_string("wordforteachers") ?>:</td>
        <td><input type="text" name="teachers" maxlength="100" size=25 value="<?php p($form->teachers) ?>">
        (<?php print_string("wordforteacherseg") ?>)
     <?php if (isset($err["teachers"])) formerr($err["teachers"]); ?>
        </td>
 </tr>
 <tr valign=top>
-       <td><p><?php print_string("wordforstudent") ?>:</td>
+       <td align=right><p><?php print_string("wordforstudent") ?>:</td>
        <td><input type="text" name="student" maxlength="100" size=25 value="<?php p($form->student) ?>">
        (<?php print_string("wordforstudenteg") ?>) 
     <?php if (isset($err["student"])) formerr($err["student"]); ?>
        </td>
 </tr>
 <tr valign=top>
-       <td><p><?php print_string("wordforstudents") ?>:</td>
+       <td align=right><p><?php print_string("wordforstudents") ?>:</td>
        <td><input type="text" name="students" maxlength="100" size=25 value="<?php p($form->students) ?>">
        (<?php print_string("wordforstudentseg") ?>) 
     <?php if (isset($err["students"])) formerr($err["students"]); ?>
index b2c4ec9c41d5b4b14f6cb27908a3ab076658a9b3..93ea4fc40f908d1b75a308d6b7e421be2b156661 100644 (file)
@@ -31,7 +31,7 @@
                 if ($newid = insert_record("course", $form)) {
                     $cat->name = get_string("miscellaneous");
                     if (insert_record("course_categories", $cat)) {
-                        redirect("$CFG->wwwroot/", get_string("changessaved"));
+                        redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"));
                     } else {
                         error("Serious Error! Could not set up a default course category!");
                     }
         $form->id = "";
         $form->category = 0;
         $form->format = "social";
-        $form->newsitems = 0;
+        $form->teacher = get_string("defaultcourseteacher");
+        $form->teachers = get_string("defaultcourseteachers");
+        $form->student = get_string("defaultcoursestudent");
+        $form->students = get_string("defaultcoursestudents");
         $firsttime = true;
     }
 
@@ -87,7 +90,7 @@
     if ($firsttime) {
         print_header();
         print_heading($strsitesettings);
-        print_simple_box(get_string("configintrosite"), "center");
+        print_simple_box(get_string("configintrosite"), "center", "50%");
         echo "<br />";
     } else {
         print_header("$site->shortname: $strsitesettings", "$site->fullname",
@@ -115,9 +118,6 @@ function validate_form(&$form, &$err) {
     if (empty($form->shortname))
         $err["shortname"] = get_string("missingshortsitename");
 
-    if (empty($form->summary))
-        $err["summary"] = get_string("missingsitedescription");
-
     return;
 }
 
index 2c4482671c7b4ad3451321011420e44f3eaa89f8..f2bb4e498cf2dc4d4aae806256f9bfa68d075d17 100644 (file)
@@ -5,7 +5,7 @@
 
     define("MAX_USERS_PER_PAGE", 30);
 
-    optional_variable($id);         // course id
+    require_variable($id);         // course id
     optional_variable($add, "");
     optional_variable($remove, "");
     optional_variable($search, ""); // search string
@@ -21,6 +21,7 @@
     }
 
     $strassignteachers = get_string("assignteachers");
+    $strcourses = get_string("courses");
     $stradministration = get_string("administration");
     $strexistingteachers   = get_string("existingteachers");
     $strnoexistingteachers = get_string("noexistingteachers");
     }
 
 
-    if (!$id) {
-           print_header("$site->shortname: $strassignteachers", "$site->fullname", 
-                     "<a href=\"index.php\">$stradministration</a> -> $strassignteachers");
-        
-        $isadmin = isadmin(); /// cache value
-        $courses = get_courses();
-
-               print_heading(get_string("choosecourse"));
-               print_simple_box_start("center");
-        
-        if (!empty($courses)) {
-                   foreach ($courses as $course) {
-                       if ($isadmin or isteacher($course->id, $USER->id)){
-                               echo "<a href=\"teacher.php?id=$course->id\">$course->fullname ($course->shortname)</a><br>\n";
-                                   $coursesfound = TRUE;
-                           }
-                   }   
-        }
-               
-        print_simple_box_end();
-        
-        if ($coursesfound == FALSE) {         
-            print_heading(get_string("nocoursesyet"));
-            print_continue("../$CFG->admin/index.php");
-        }
-
-        print_footer();
-        exit;
-    }
-
     if (! $course = get_record("course", "id", $id)) {
         error("Course ID was incorrect (can't find it)");
     }
@@ -77,8 +48,9 @@
 
        print_header("$site->shortname: $course->shortname: $strassignteachers", 
                  "$site->fullname", 
-                 "<a href=\"index.php\">$stradministration</a> -> 
-                  <a href=\"teacher.php\">$strassignteachers</a> -> $course->shortname", "");
+                 "<a href=\"../course/index.php\">$strcourses</a> -> ".
+                 "<a href=\"../course/view.php?id=$course->id\">$course->fullname</a> -> ".
+                 "$strassignteachers", "");
 
     print_heading("<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname ($course->shortname)</a>");
 
         $teacherarray = array();
         foreach ($teachers as $teacher) {
             $teacherarray[] = $teacher->id;
-            echo "<p align=right>$teacher->firstname $teacher->lastname, $teacher->email &nbsp;&nbsp; <a href=\"teacher.php?id=$course->id&remove=$teacher->id\" title=\"$strremoveteacher\"><img src=\"../pix/t/right.gif\" border=0></a></p>";
+            echo "<p align=right>$teacher->firstname $teacher->lastname, $teacher->email &nbsp;";
+            print_user_picture($teacher->id, $site->id, $teacher->picture, false, false, false);
+            echo "&nbsp;&nbsp;<a href=\"teacher.php?id=$course->id&remove=$teacher->id\" title=\"$strremoveteacher\"><img src=\"../pix/t/right.gif\" border=0></a></p>";
         }
         $teacherlist = implode(",",$teacherarray);
         unset($teacherarray);
         foreach ($users as $user) {
             echo "<p align=left><a href=\"{$_SERVER['PHP_SELF']}?id=$course->id&add=$user->id\"".
                    "title=\"$straddteacher\"><img src=\"../pix/t/left.gif\"".
-                   "border=0></a>&nbsp;&nbsp;$user->firstname $user->lastname, $user->email";
+                   "border=0></a>&nbsp;&nbsp;";
+            print_user_picture($user->id, $site->id, $user->picture, false, false, false);
+            echo "&nbsp;$user->firstname $user->lastname, $user->email";
         }
     }
 
diff --git a/course/categories.php b/course/categories.php
deleted file mode 100644 (file)
index 668466d..0000000
+++ /dev/null
@@ -1,318 +0,0 @@
-<?PHP // $Id$
-      // Allows the admin to create, delete and rename course categories
-
-       require_once("../config.php");
-       require_once("lib.php");
-
-    require_login();
-
-    if (!isadmin()) {
-        error("Only administrators can use this page!");
-    }
-
-    if (!$site = get_site()) {
-        error("Site isn't defined!");
-    }
-
-
-/// Print headings
-
-    $stradministration = get_string("administration");
-    $strcategories = get_string("categories");
-    $strcategory = get_string("category");
-    $strcourses = get_string("courses");
-    $stredit = get_string("edit");
-    $strdelete = get_string("delete");
-    $straction = get_string("action");
-    $straddnewcategory = get_string("addnewcategory");
-
-       print_header("$site->shortname: $strcategories", "$site->fullname", 
-                 "<A HREF=\"../$CFG->admin/index.php\">$stradministration</A> -> $strcategories",
-                 "addform.addcategory");
-
-
-/// If data for a new category was submitted, then add it
-    if ($form = data_submitted()) {
-        if (!empty($form->addcategory)) {
-            unset($newcategory);
-            $newcategory->name = $form->addcategory;
-            $newcategory->sortorder = 999;
-            if (!insert_record("course_categories", $newcategory)) {
-                notify("Could not insert the new category '$newcategory->name'");
-            } else {
-                notify(get_string("categoryadded", "", $newcategory->name));
-            }
-        }
-    }
-
-
-/// Delete a category if necessary
-
-    if (isset($delete)) {
-        if ($tempcat = get_record("course_categories", "id", $delete)) {
-            if (delete_records("course_categories", "id", $tempcat->id)) {
-                notify(get_string("categorydeleted", "", $tempcat->name));
-            }
-            if ($children = get_records("course_categories", "parent", $tempcat->id)) {
-                foreach ($children as $childcat) {
-                    if (! set_field("course_categories", "parent", $tempcat->parent, "id", $childcat->id)) {
-                        notify("Could not update a child category!");
-                    }
-                }
-            }
-        }
-    }
-
-
-/// Create a default category if necessary
-    if (!$categories = get_categories()) {    /// No category yet!
-        // Try and make one
-        unset($tempcat);
-        $tempcat->name = get_string("miscellaneous");
-        if (!$tempcat->id = insert_record("course_categories", $tempcat)) {
-            error("Serious error: Could not create a default category!");
-        }
-    }
-
-
-/// Move a category to a new parent if required
-
-    if (isset($move) and isset($moveto)) {
-        if ($tempcat = get_record("course_categories", "id", $move)) {
-            if ($tempcat->parent != $moveto) {
-                if (! set_field("course_categories", "parent", $moveto, "id", $tempcat->id)) {
-                    notify("Could not update that category!");
-                }
-            }
-        }
-    }
-
-
-/// Hide or show a category 
-    if (isset($hide) or isset($show)) {
-        if (isset($hide)) {
-            $tempcat = get_record("course_categories", "id", $hide);
-            $visible = 0;
-        } else {
-            $tempcat = get_record("course_categories", "id", $show);
-            $visible = 1;
-        }
-        if ($tempcat) {
-            if (! set_field("course_categories", "visible", $visible, "id", $tempcat->id)) {
-                notify("Could not update that category!");
-            }
-            if (! set_field("course", "visible", $visible, "category", $tempcat->id)) {
-                notify("Could not hide/show any courses in this category !");
-            }
-        }
-    }
-
-
-/// Move a category up or down
-
-    if (isset($moveup) or isset($movedown)) {
-        
-        $swapcategory = NULL;
-        $movecategory = NULL;
-
-        if (isset($moveup)) {
-            if ($movecategory = get_record("course_categories", "id", $moveup)) {
-                $categories = get_categories("$movecategory->parent");
-
-                foreach ($categories as $category) {
-                    if ($category->id == $movecategory->id) {
-                        break;
-                    }
-                    $swapcategory = $category;
-                }
-            }
-        }
-        if (isset($movedown)) {
-            if ($movecategory = get_record("course_categories", "id", $movedown)) {
-                $categories = get_categories("$movecategory->parent");
-
-                $choosenext = false;
-                foreach ($categories as $category) {
-                    if ($choosenext) {
-                        $swapcategory = $category;
-                        break;
-                    }
-                    if ($category->id == $movecategory->id) {
-                        $choosenext = true;
-                    }
-                }
-            }
-        }
-        if ($swapcategory and $movecategory) {        // Renumber everything for robustness
-            $count=0;
-            foreach ($categories as $category) {
-                $count++;
-                if ($category->id == $swapcategory->id) {
-                    $category = $movecategory;
-                } else if ($category->id == $movecategory->id) {
-                    $category = $swapcategory;
-                }
-                if (! set_field("course_categories", "sortorder", $count, "id", $category->id)) {
-                    notify("Could not update that category!");
-                }
-            }
-        }
-    }
-
-/// Find the default category (the one with the lowest ID)
-    $categories = get_categories();
-    $default = 99999;
-    foreach ($categories as $category) {
-        fix_category_courses($category->id);
-        if ($category->id < $default) {
-            $default = $category->id;
-        }
-    }
-
-/// Find any orphan courses that don't yet have a valid category and set to default
-    if ($courses = get_courses()) {
-        foreach ($courses as $course) {
-            if (!isset( $categories[$course->category] )) {
-                set_field("course", "category", $default, "id", $course->id);
-            }
-        }
-    }
-
-/// Print form for creating new categories
-
-    print_simple_box_start("center");
-    echo "<center>";
-    echo "<form name=\"addform\" action=\"categories.php\" method=\"post\">";
-    echo "<input type=\"text\" size=55 name=\"addcategory\">";
-    echo "<input type=\"submit\" value=\"$straddnewcategory\">";
-    echo "</form>";
-    echo "</center>";
-    print_simple_box_end();
-
-    echo "<br />";
-
-
-/// Print out the categories with all the knobs
-
-    $strcategories = get_string("categories");
-    $strmovecategoryto = get_string("movecategoryto");
-    $stredit = get_string("edit");
-
-    $displaylist = array();
-    $parentlist = array();
-
-    $displaylist[0] = get_string("top");
-    make_categories_list($displaylist, $parentlist, "");
-
-    echo "<table align=\"center\" border=0 cellspacing=2 cellpadding=5 class=\"generalbox\"><tr>";
-    echo "<th>$strcategories</th>";
-    echo "<th>$stredit</th>";
-    echo "<th>$strmovecategoryto</th>";
-
-    print_category_edit(NULL, $displaylist, $parentlist);
-
-    echo "</table>";
-
-
-    print_footer();
-
-
-
-function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $up=false, $down=false) {
-/// Recursive function to print all the categories ready for editing
-
-    global $THEME, $CFG;
-
-    static $str = '';
-    static $pixpath = '';
-    
-    if (empty($str)) {
-        $str->delete   = get_string("delete");
-        $str->moveup   = get_string("moveup");
-        $str->movedown = get_string("movedown");
-        $str->edit     = get_string("editthiscategory");
-        $str->hide     = get_string("hide");
-        $str->show     = get_string("show");
-    }
-    
-    if (empty($pixpath)) {
-        if (empty($THEME->custompix)) {
-            $pixpath = "$CFG->wwwroot/pix";
-        } else {
-            $pixpath = "$CFG->wwwroot/theme/$CFG->theme/pix";
-        }
-    }
-
-    if ($category) {
-        echo "<tr><td align=\"left\" nowrap=\"nowrap\" bgcolor=\"$THEME->cellcontent\">";
-        echo "<p>";
-        for ($i=0; $i<$depth;$i++) {
-            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
-        }
-        $linkcss = $category->visible ? "" : " class=\"dimmed\" ";
-        echo "<a $linkcss title=\"$str->edit\" href=\"category.php?id=$category->id\">$category->name</a>";
-        echo "</p>";
-        echo "</td>";
-
-        echo "<td nowrap=\"nowrap\">";    /// Print little icons
-
-        if (!empty($category->visible)) {
-            echo "<a title=\"$str->hide\" href=\"categories.php?hide=$category->id\"><img".
-                 " src=\"$pixpath/t/hide.gif\" height=11 width=11 border=0></a> ";
-        } else {
-            echo "<a title=\"$str->show\" href=\"categories.php?show=$category->id\"><img".
-                 " src=\"$pixpath/t/show.gif\" height=11 width=11 border=0></a> ";
-        }
-
-        echo "<a title=\"$str->delete\" href=\"categories.php?delete=$category->id\"><img".
-             " src=\"$pixpath/t/delete.gif\" height=11 width=11 border=0></a> ";
-
-        //echo "<a title=\"$str->update\" href=\"category.php?id=$category->id\"><img".
-        //     " src=\"$pixpath/t/edit.gif\" height=11 width=11 border=0></a> ";
-
-        if ($up) {
-            echo "<a title=\"$str->moveup\" href=\"categories.php?moveup=$category->id\"><img".
-                 " src=\"$pixpath/t/up.gif\" height=11 width=11 border=0></a> ";
-        }
-        if ($down) {
-            echo "<a title=\"$str->movedown\" href=\"categories.php?movedown=$category->id\"><img".
-                 " src=\"$pixpath/t/down.gif\" height=11 width=11 border=0></a> ";
-        }
-        echo "</td>";
-
-        echo "<td align=\"left\" width=\"0\">";
-        $tempdisplaylist = $displaylist;
-        unset($tempdisplaylist[$category->id]);
-        foreach ($parentslist as $key => $parents) {
-            if (in_array($category->id, $parents)) {
-                unset($tempdisplaylist[$key]);
-            }
-        }
-        popup_form ("categories.php?move=$category->id&moveto=", $tempdisplaylist, "moveform$category->id", "$category->parent", "", "", "", false);
-        echo "</td>";
-        echo "</tr>";
-    } else {
-        $category->id = "0";
-    }
-
-    if ($categories = get_categories($category->id)) {   // Print all the children recursively
-        $countcats = count($categories);
-        $count = 0;
-        $first = true;
-        $last = false;
-        foreach ($categories as $cat) {
-            $count++;
-            if ($count == $countcats) {
-                $last = true;
-            }
-            $up = $first ? false : true;
-            $down = $last ? false : true;
-            $first = false;
-
-            print_category_edit($cat, $displaylist, $parentslist, $depth+1, $up, $down);         
-        }
-    }
-}
-
-
-?>
index 35a6d680447be5fbfa27b6ad7d42d3025cbf11e6..2ef167a139a5906a4d780dc6bee399a1b407e227 100644 (file)
@@ -1,16 +1,13 @@
 <?PHP // $Id$
-      // Allows the admin to edit a category, and rearrange courses
+      // Displays the top level category or all courses
+      // In editing mode, allows the admin to edit a category, 
+      // and rearrange courses
 
        require_once("../config.php");
        require_once("lib.php");
 
     require_variable($id);    // Category id
 
-    require_login();
-
-    if (!isadmin()) {
-        error("Only administrators can use this page!");
-    }
 
     if (!$site = get_site()) {
         error("Site isn't defined!");
         error("Category not known!");
     }
 
+    if (iscreator()) {
+        if (isset($_GET['edit'])) {
+            if ($edit == "on") {
+                $USER->editing = true;
+            } else if ($edit == "off") {
+                $USER->editing = false;
+            }
+        }
+        $updatebutton = update_category_button($category->id);
 
-/// Print headings
-
-    $stradministration = get_string("administration");
-    $strcategories = get_string("categories");
-    $strcategories = get_string("categories");
-    $strcategory = get_string("category");
-    $strcourses = get_string("courses");
+        $creatorediting = !empty($USER->editing);
+        $adminediting = (isadmin() and $creatorediting);
 
-       print_header("$site->shortname: $strcategory", "$site->fullname", 
-                 "<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
-                 "<a href=\"categories.php\">$strcategories</a> -> $strcategory");
+    } else {
+        $updatebutton = "";
+        $adminediting = false;
+    }
 
 
-/// Rename the category
+/// Rename the category if requested
 
     if (!empty($rename)) {
         $category->name = $rename;
         if (! set_field("course_categories", "name", $category->name, "id", $category->id)) {
             notify("An error occurred while renaming the category");
-        } else { 
-            notify("The category was renamed");
         }
     }
 
+
+/// Print headings
+
+    $numcategories = count_records("course_categories");
+
+    $stradministration = get_string("administration");
+    $strcategories = get_string("categories");
+    $strcategory = get_string("category");
+    $strcourses = get_string("courses");
+    $strcoursemanagement = get_string("coursemanagement");
+
+    if ($creatorediting) {
+        if ($adminediting) {
+               print_header("$site->shortname: $category->name", "$site->fullname", 
+                         "<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
+                         "<a href=\"index.php\">$strcoursemanagement</a> -> $category->name",
+                         "", "", true, $updatebutton);
+        } else {
+               print_header("$site->shortname: $category->name", "$site->fullname", 
+                         "<a href=\"index.php\">$strcourses</a> -> $category->name", "", "", true, $updatebutton);
+        }
+    } else {
+           print_header("$site->shortname: $category->name", "$site->fullname", 
+                     "<a href=\"index.php\">$strcourses</a> -> $category->name", "", "", true, $updatebutton);
+    }
+
+
 /// Print the category selector
 
     $displaylist = array();
     echo "</td></tr></table><br />";
 
 
-/// Move a specified course to a new category 
-
-    if (isset($move) and isset($moveto)) {
-        if (! $course  = get_record("course", "id", $move)) {
-            notify("Error finding the course");
-        } else if (! $destcategory = get_record("course_categories", "id", $moveto)) {
-            notify("Error finding the category");
-        } else {
-            if (!set_field("course", "category", $destcategory->id, "id", $course->id)) {
-                notify("An error occurred - course not moved!");
-            }
-            fix_category_courses($destcategory->id);
-            fix_category_courses($category->id);
-            $category = get_record("course_categories", "id", $category->id);
-        }
-    }
+/// Editing functions
 
+    if ($adminediting) {
 
-/// Hide or show a course 
+    /// Move a specified course to a new category 
 
-    if (isset($hide) or isset($show)) {
-        if (isset($hide)) {
-            $course = get_record("course", "id", $hide);
-            $visible = 0;
-        } else {
-            $course = get_record("course", "id", $show);
-            $visible = 1;
-        }
-        if ($course) {
-            if (! set_field("course", "visible", $visible, "id", $course->id)) {
-                notify("Could not update that course!");
+        if (isset($move) and isset($moveto)) {
+            if (! $course  = get_record("course", "id", $move)) {
+                notify("Error finding the course");
+            } else if (! $destcategory = get_record("course_categories", "id", $moveto)) {
+                notify("Error finding the category");
+            } else {
+                if (!set_field("course", "category", $destcategory->id, "id", $course->id)) {
+                    notify("An error occurred - course not moved!");
+                }
+                fix_course_sortorder($destcategory->id);
+                fix_course_sortorder($category->id);
+                $category = get_record("course_categories", "id", $category->id);
             }
         }
-    }
 
 
-/// Move a course up or down
+    /// Hide or show a course 
+    
+        if (isset($hide) or isset($show)) {
+            if (isset($hide)) {
+                $course = get_record("course", "id", $hide);
+                $visible = 0;
+            } else {
+                $course = get_record("course", "id", $show);
+                $visible = 1;
+            }
+            if ($course) {
+                if (! set_field("course", "visible", $visible, "id", $course->id)) {
+                    notify("Could not update that course!");
+                }
+            }
+        }
 
-    if (isset($moveup) or isset($movedown)) {
 
+    /// Move a course up or down
 
-        $movecourse = isset($moveup) ? $moveup : $movedown;
+        if (isset($moveup) or isset($movedown)) {
 
-        fix_category_courses($category->id);
-        if (!$category = get_record("course_categories", "id", $category->id)) {  // Fresh copy
-            error("Category not known!");
-        }
+            $movecourse = NULL;
+            $swapcourse = NULL;
 
-        $courses = explode(',', $category->courseorder);
-        $key = array_search($movecourse, $courses);
-        if ($key === NULL or $key === false) {
-            notify("Could not find that course in the category list!");
+            $courses = get_courses($category->id);
 
-        } else {
             if (isset($moveup)) {
-                $swapkey = $key-1;
-            } else {
-                $swapkey = $key+1;
+                if ($movecourse = get_record("course", "id", $moveup)) {
+                    foreach ($courses as $course) {
+                        if ($course->id == $movecourse->id) {
+                            break;
+                        }
+                        $swapcourse = $course;
+                    }
+                }
             }
-            $courses[$key] = $courses[$swapkey];
-            $courses[$swapkey] = $movecourse;
-            $category->courseorder = implode(",", $courses);
-
-            if (! set_field("course_categories", "courseorder", $category->courseorder, "id", $category->id)) {
-                notify("Database error while trying to update the category!");
+            if (isset($movedown)) {
+                if ($movecourse = get_record("course", "id", $movedown)) {
+                    $choosenext = false;
+                    foreach ($courses as $course) {
+                        if ($choosenext) {
+                            $swapcourse = $course;
+                            break;
+                        }
+                        if ($course->id == $movecourse->id) {
+                            $choosenext = true;
+                        }
+                    }
+                }
+            }
+            if ($swapcourse and $movecourse) {        // Renumber everything for robustness
+                $count=0;
+                foreach ($courses as $course) {
+                    $count++;
+                    if ($course->id == $swapcourse->id) {
+                        $course = $movecourse;
+                    } else if ($course->id == $movecourse->id) {
+                        $course = $swapcourse;
+                    }
+                    if (! set_field("course", "sortorder", $count, "id", $course->id)) {
+                        notify("Could not update that course!");
+                    }
+                }
             }
         }
-    }
+
+        fix_course_sortorder($category->id);
+
+    } // End of editing stuff
 
     
-/// Print out the courses with all the knobs
+/// Print out all the courses
 
-    fix_category_courses($category->id);
 
-    if (!$courses = get_courses($category)) {
+    if (!$courses = get_courses($category->id)) {
         print_heading(get_string("nocoursesyet"));
 
     } else {
 
-        $strcourses = get_string("courses");
+        $strcourses  = get_string("courses");
         $strmovecourseto = get_string("movecourseto");
-        $stredit = get_string("edit");
+        $stredit     = get_string("edit");
         $strdelete   = get_string("delete");
+        $strbackup   = get_string("backup");
         $strmoveup   = get_string("moveup");
         $strmovedown = get_string("movedown");
         $strupdate   = get_string("update");
         $strhide     = get_string("hide");
         $strshow     = get_string("show");
+        $strassignteachers     = get_string("assignteachers");
 
         if (empty($THEME->custompix)) {
             $pixpath = "$CFG->wwwroot/pix";
         } else {
             $pixpath = "$CFG->wwwroot/theme/$CFG->theme/pix";
         }
+
     
-        echo "<table align=\"center\" border=0 cellspacing=2 cellpadding=5 class=\"generalbox\"><tr>";
+        echo "<table align=\"center\" border=0 cellspacing=2 cellpadding=4 class=\"generalbox\"><tr>";
         echo "<th>$strcourses</th>";
-        echo "<th>$stredit</th>";
-        echo "<th>$strmovecourseto</th></tr>";
+        if ($creatorediting) {
+            echo "<th>$stredit</th>";
+            if ($adminediting) {
+                echo "<th>$strmovecourseto</th>";
+            }
+        }
+        echo "</tr>";
+
 
         $numcourses = count($courses);
         $count = 0;
             $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
             echo "<tr>";
             echo "<td><a $linkcss href=\"view.php?id=$course->id\">$course->fullname</a></td>";
-            echo "<td>";
-            if (!empty($course->visible)) {
-                echo "<a title=\"$strhide\" href=\"category.php?id=$category->id&hide=$course->id\"><img".
-                     " src=\"$pixpath/t/hide.gif\" height=11 width=11 border=0></a> ";
-            } else {
-                echo "<a title=\"$strshow\" href=\"category.php?id=$category->id&show=$course->id\"><img".
-                     " src=\"$pixpath/t/show.gif\" height=11 width=11 border=0></a> ";
-            }
-            echo "<a title=\"$strdelete\" href=\"delete.php?id=$course->id\"><img".
-                 " src=\"$pixpath/t/delete.gif\" height=11 width=11 border=0></a> ";
+            if ($creatorediting) {
+                echo "<td>";
+                echo "<a title=\"$strassignteachers\" href=\"$CFG->wwwroot/$CFG->admin/teacher.php?id=$course->id\"><img".
+                     " src=\"$pixpath/t/user.gif\" height=11 width=11 border=0></a> ";
+                if ($adminediting) {
+                    echo "<a title=\"$strdelete\" href=\"delete.php?id=$course->id\"><img".
+                         " src=\"$pixpath/t/delete.gif\" height=11 width=11 border=0></a> ";
+                    if (!empty($course->visible)) {
+                        echo "<a title=\"$strhide\" href=\"category.php?id=$category->id&hide=$course->id\"><img".
+                             " src=\"$pixpath/t/hide.gif\" height=11 width=11 border=0></a> ";
+                    } else {
+                        echo "<a title=\"$strshow\" href=\"category.php?id=$category->id&show=$course->id\"><img".
+                             " src=\"$pixpath/t/show.gif\" height=11 width=11 border=0></a> ";
+                    }
     
-            if ($up) {
-                echo "<a title=\"$strmoveup\" href=\"category.php?id=$category->id&moveup=$course->id\"><img".
-                     " src=\"$pixpath/t/up.gif\" height=11 width=11 border=0></a> ";
-            }
-
-            if ($down) {
-                echo "<a title=\"$strmovedown\" href=\"category.php?id=$category->id&movedown=$course->id\"><img".
-                     " src=\"$pixpath/t/down.gif\" height=11 width=11 border=0></a> ";
+                    echo "<a title=\"$strbackup\" href=\"../backup/backup.php?id=$course->id\"><img".
+                         " src=\"$pixpath/t/backup.gif\" height=11 width=11 border=0></a> ";
+    
+            
+                    if ($up) {
+                        echo "<a title=\"$strmoveup\" href=\"category.php?id=$category->id&moveup=$course->id\"><img".
+                             " src=\"$pixpath/t/up.gif\" height=11 width=11 border=0></a> ";
+                    }
+        
+                    if ($down) {
+                        echo "<a title=\"$strmovedown\" href=\"category.php?id=$category->id&movedown=$course->id\"><img".
+                             " src=\"$pixpath/t/down.gif\" height=11 width=11 border=0></a> ";
+                    }
+                }
+    
+                echo "</td>";
+                echo "<td>";
+                popup_form ("category.php?id=$category->id&move=$course->id&moveto=", $displaylist, 
+                            "moveform$course->id", "$course->category", "", "", "", false);
+                echo "</td>";
             }
-
-            echo "</td>";
-            echo "<td>";
-            popup_form ("category.php?id=$category->id&move=$course->id&moveto=", $displaylist, 
-                        "moveform$course->id", "$course->category", "", "", "", false);
-            echo "</td>";
             echo "</tr>";
         }
     
         echo "</table>";
         echo "<br />";
     }
-    
-/// Print form to rename the category
 
-    $strrename= get_string("rename");
+    if ($adminediting) {
+    /// First print form to rename the category
+        $strrename= get_string("rename");
+        print_simple_box_start("center");
+        echo "<center>";
+        echo "<form name=\"renameform\" action=\"category.php\" method=\"post\">";
+        echo "<input type=\"hidden\" name=\"id\" value=\"$category->id\">";
+        echo "<input type=\"text\" size=30 name=\"rename\" value=\"$category->name\">";
+        echo "<input type=\"submit\" value=\"$strrename\">";
+        echo "</form>";
+        echo "</center>";
+        print_simple_box_end();
+        echo "<br />";
+    }
 
-    print_simple_box_start("center");
-    echo "<center>";
-    echo "<form name=\"renameform\" action=\"category.php\" method=\"post\">";
-    echo "<input type=\"hidden\" name=\"id\" value=\"$category->id\">";
-    echo "<input type=\"text\" size=55 name=\"rename\" value=\"$category->name\">";
-    echo "<input type=\"submit\" value=\"$strrename\">";
-    echo "</form>";
-    echo "</center>";
-    print_simple_box_end();
 
+    
     print_footer();
 
 ?>
index 979876d7911acaf4a633f61b6e30de80189ff7fa..53fc0e4c50d6ba85520b0ad65048744de72024c7 100644 (file)
@@ -1,5 +1,16 @@
 <FORM METHOD="post" action="edit.php" NAME="form">
 <table cellpadding=9 cellspacing=0 >
+<tr valign=top>
+       <td><P><? print_string("category") ?>:</td>
+       <td><? 
+           $displaylist = array();
+           $parentlist = array();
+           make_categories_list($displaylist, $parentlist);
+           choose_from_menu($displaylist, "category", "$form->category", "");
+           helpbutton("coursecategory", get_string("category"));
+        ?>
+       </td>
+</tr>
 <tr valign=top>
        <td><P><? print_string("fullname") ?>:</td>
        <td><input type="text" name="fullname" maxlength="254" size=50 value="<? p($form->fullname) ?>">
     helpbutton("guestaccess", get_string("opentoguests")); ?>
        </td>
 </tr>
-<tr valign=top>
-       <td><P><? print_string("category") ?>:</td>
-       <td><? 
-           $displaylist = array();
-           $parentlist = array();
-           make_categories_list($displaylist, $parentlist);
-           choose_from_menu($displaylist, "category", "$form->category", "");
-           helpbutton("coursecategory", get_string("category"));
-        ?>
-       </td>
-</tr>
 <tr valign=top>
        <td><P><? print_string("format") ?>:</td>
        <td><? 
index 36c5cb32487ebeb3db0661140b10eb303d5676ca..2a2df70752a234da4a445840dcfe4d2b684c7fef 100644 (file)
@@ -44,7 +44,7 @@
 
             $form->timemodified = time();
 
-            fix_category_courses($form->category);
+            fix_course_sortorder($form->category);
 
             if (!empty($course)) {
                 if (update_record("course", $form)) {
index 946772e3fe445a04d024bd46733c66019e8ea3f6..5cb57118bd35b131f444a046bd066b770dae6223 100644 (file)
 <?PHP // $Id$
-      // Display list of all courses
+      // For most people, just lists the course categories
+      // Allows the admin to create, delete and rename course categories
 
-    require_once("../config.php");
-    require_once("lib.php");
+       require_once("../config.php");
+       require_once("lib.php");
 
-    optional_variable($category, "0");
 
-    $strcourses = get_string("courses");
+    if (!$site = get_site()) {
+        error("Site isn't defined!");
+    }
+
+    if (isadmin()) {
+        if (isset($_GET['edit'])) {
+            if ($edit == "on") {
+                $USER->editing = true;
+            } else if ($edit == "off") {
+                $USER->editing = false;
+            }
+        }
+    }
+
+    $adminediting = (isadmin() and !empty($USER->editing));
+
+
+/// Unless it's an editing admin, just print the regular listing of courses/categories
+
+    if (!$adminediting) {
+        $countcategories = count_records("course_categories");
+
+        if ($countcategories > 1) {
+            $strcourses = get_string("courses");
+            print_header($strcourses, $strcourses, $strcourses, "", "", true, update_categories_button());
+            print_heading(get_string("categories"));
+            print_simple_box_start("center", "50%");
+            print_whole_category_list();
+            print_simple_box_end();
+        } else {
+            $strfulllistofcourses = get_string("fulllistofcourses");
+            print_header("$site->shortname: $strfulllistofcourses", $strfulllistofcourses, $strfulllistofcourses);
+            print_courses(0, "80%");
+        }
+    
+        print_footer();
+        exit;
+    }
+
+/// From now on is all the admin functions
+
+    require_login();
+
+    if (!isadmin()) {
+        error("Only administrators can use this page!");
+    }
+
+/// Print headings
+
+    $stradministration = get_string("administration");
     $strcategories = get_string("categories");
-    $strmycourses = get_string("mycourses");
-    $strfulllistofcourses = get_string("fulllistofcourses");
+    $strcategory = get_string("category");
+    $strcourses = get_string("courses");
+    $strcoursemanagement = get_string("coursemanagement");
+    $stredit = get_string("edit");
+    $strdelete = get_string("delete");
+    $straction = get_string("action");
+    $straddnewcategory = get_string("addnewcategory");
 
-    if ($category = get_record("course_categories", "id", $category)) {
-        print_header($strcourses, $strcourses, "<a href=\"index.php\">$strcourses</a> -> $category->name",
-                     "", "", true, update_category_button($category->id));
+       print_header("$site->shortname: $strcategories", "$site->fullname", 
+                 "<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strcoursemanagement",
+                 "addform.addcategory", "", true, update_categories_button());
 
-    } else {
-        print_header($strcourses, $strcourses, $strcourses);
-        $category->id = 0;
+    print_heading($strcategories);
+
+
+/// If data for a new category was submitted, then add it
+    if ($form = data_submitted()) {
+        if (!empty($form->addcategory)) {
+            unset($newcategory);
+            $newcategory->name = $form->addcategory;
+            $newcategory->sortorder = 999;
+            if (!insert_record("course_categories", $newcategory)) {
+                notify("Could not insert the new category '$newcategory->name'");
+            } else {
+                notify(get_string("categoryadded", "", $newcategory->name));
+            }
+        }
+    }
+
+
+/// Delete a category if necessary
+
+    if (isset($delete)) {
+        if ($tempcat = get_record("course_categories", "id", $delete)) {
+            if (delete_records("course_categories", "id", $tempcat->id)) {
+                notify(get_string("categorydeleted", "", $tempcat->name));
+            }
+            if ($children = get_records("course_categories", "parent", $tempcat->id)) {
+                foreach ($children as $childcat) {
+                    if (! set_field("course_categories", "parent", $tempcat->parent, "id", $childcat->id)) {
+                        notify("Could not update a child category!");
+                    }
+                }
+            }
+        }
     }
 
 
-/// Print the category selector
+/// Create a default category if necessary
+    if (!$categories = get_categories()) {    /// No category yet!
+        // Try and make one
+        unset($tempcat);
+        $tempcat->name = get_string("miscellaneous");
+        if (!$tempcat->id = insert_record("course_categories", $tempcat)) {
+            error("Serious error: Could not create a default category!");
+        }
+    }
+
+
+/// Move a category to a new parent if required
+
+    if (isset($move) and isset($moveto)) {
+        if ($tempcat = get_record("course_categories", "id", $move)) {
+            if ($tempcat->parent != $moveto) {
+                if (! set_field("course_categories", "parent", $moveto, "id", $tempcat->id)) {
+                    notify("Could not update that category!");
+                }
+            }
+        }
+    }
+
+
+/// Hide or show a category 
+    if (isset($hide) or isset($show)) {
+        if (isset($hide)) {
+            $tempcat = get_record("course_categories", "id", $hide);
+            $visible = 0;
+        } else {
+            $tempcat = get_record("course_categories", "id", $show);
+            $visible = 1;
+        }
+        if ($tempcat) {
+            if (! set_field("course_categories", "visible", $visible, "id", $tempcat->id)) {
+                notify("Could not update that category!");
+            }
+            if (! set_field("course", "visible", $visible, "category", $tempcat->id)) {
+                notify("Could not hide/show any courses in this category !");
+            }
+        }
+    }
+
+
+/// Move a category up or down
+
+    if (isset($moveup) or isset($movedown)) {
+        
+        $swapcategory = NULL;
+        $movecategory = NULL;
+
+        if (isset($moveup)) {
+            if ($movecategory = get_record("course_categories", "id", $moveup)) {
+                $categories = get_categories("$movecategory->parent");
+
+                foreach ($categories as $category) {
+                    if ($category->id == $movecategory->id) {
+                        break;
+                    }
+                    $swapcategory = $category;
+                }
+            }
+        }
+        if (isset($movedown)) {
+            if ($movecategory = get_record("course_categories", "id", $movedown)) {
+                $categories = get_categories("$movecategory->parent");
 
+                $choosenext = false;
+                foreach ($categories as $category) {
+                    if ($choosenext) {
+                        $swapcategory = $category;
+                        break;
+                    }
+                    if ($category->id == $movecategory->id) {
+                        $choosenext = true;
+                    }
+                }
+            }
+        }
+        if ($swapcategory and $movecategory) {        // Renumber everything for robustness
+            $count=0;
+            foreach ($categories as $category) {
+                $count++;
+                if ($category->id == $swapcategory->id) {
+                    $category = $movecategory;
+                } else if ($category->id == $movecategory->id) {
+                    $category = $swapcategory;
+                }
+                if (! set_field("course_categories", "sortorder", $count, "id", $category->id)) {
+                    notify("Could not update that category!");
+                }
+            }
+        }
+    }
+
+/// Find the default category (the one with the lowest ID)
     $categories = get_categories();
-    $multicategories = count($categories) > 1;
+    $default = 99999;
+    foreach ($categories as $category) {
+        fix_course_sortorder($category->id);
+        if ($category->id < $default) {
+            $default = $category->id;
+        }
+    }
+
+/// Find any orphan courses that don't yet have a valid category and set to default
+    if ($courses = get_courses()) {
+        foreach ($courses as $course) {
+            if ($course->category and !isset( $categories[$course->category] )) {
+                set_field("course", "category", $default, "id", $course->id);
+            }
+        }
+    }
+
+/// Print form for creating new categories
+
+    print_simple_box_start("center");
+    echo "<center>";
+    echo "<form name=\"addform\" action=\"index.php\" method=\"post\">";
+    echo "<input type=\"text\" size=55 name=\"addcategory\">";
+    echo "<input type=\"submit\" value=\"$straddnewcategory\">";
+    echo "</form>";
+    echo "</center>";
+    print_simple_box_end();
+
+    echo "<br />";
+
+
+/// Print out the categories with all the knobs
+
+    $strcategories = get_string("categories");
+    $strcourses = get_string("courses");
+    $strmovecategoryto = get_string("movecategoryto");
+    $stredit = get_string("edit");
+
+    $displaylist = array();
+    $parentlist = array();
+
+    $displaylist[0] = get_string("top");
+    make_categories_list($displaylist, $parentlist, "");
+
+    echo "<table align=\"center\" border=0 cellspacing=2 cellpadding=5 class=\"generalbox\"><tr>";
+    echo "<th>$strcategories</th>";
+    echo "<th>$strcourses</th>";
+    echo "<th>$stredit</th>";
+    echo "<th>$strmovecategoryto</th>";
+
+    print_category_edit(NULL, $displaylist, $parentlist);
+
+    echo "</table>";
+
 
-    if (count($categories) > 1) {
-        $parentlist = array();
-        $displaylist = array();
-        $displaylist["0"] = $strfulllistofcourses;
-        make_categories_list($displaylist, $parentlist, "");
+    print_footer();
+
+
+
+function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $up=false, $down=false) {
+/// Recursive function to print all the categories ready for editing
+
+    global $THEME, $CFG;
+
+    static $str = '';
+    static $pixpath = '';
+    
+    if (empty($str)) {
+        $str->delete   = get_string("delete");
+        $str->moveup   = get_string("moveup");
+        $str->movedown = get_string("movedown");
+        $str->edit     = get_string("editthiscategory");
+        $str->hide     = get_string("hide");
+        $str->show     = get_string("show");
+    }
     
-        echo "<table align=center><tr><td>";
-        popup_form("index.php?category=", $displaylist, "switchcategory", "$category->id", "", "", "", false);
-        echo "</td></tr></table><br />";
+    if (empty($pixpath)) {
+        if (empty($THEME->custompix)) {
+            $pixpath = "$CFG->wwwroot/pix";
+        } else {
+            $pixpath = "$CFG->wwwroot/theme/$CFG->theme/pix";
+        }
     }
 
-    if (empty($category->id)) {
-        print_courses(0, "80%");
+    if ($category) {
+        echo "<tr><td align=\"left\" nowrap=\"nowrap\" bgcolor=\"$THEME->cellcontent\">";
+        echo "<p>";
+        for ($i=0; $i<$depth;$i++) {
+            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
+        }
+        $linkcss = $category->visible ? "" : " class=\"dimmed\" ";
+        echo "<a $linkcss title=\"$str->edit\" href=\"category.php?id=$category->id&edit=on\">$category->name</a>";
+        echo "</p>";
+        echo "</td>";
+
+        echo "<td align=\"right\">";    /// Print little icons
+        echo count_records("course", "category", $category->id);
+        echo "</td>";
+
+        echo "<td nowrap=\"nowrap\">";    /// Print little icons
+
+        echo "<a title=\"$str->delete\" href=\"index.php?delete=$category->id\"><img".
+             " src=\"$pixpath/t/delete.gif\" height=11 width=11 border=0></a> ";
+
+        if (!empty($category->visible)) {
+            echo "<a title=\"$str->hide\" href=\"index.php?hide=$category->id\"><img".
+                 " src=\"$pixpath/t/hide.gif\" height=11 width=11 border=0></a> ";
+        } else {
+            echo "<a title=\"$str->show\" href=\"index.php?show=$category->id\"><img".
+                 " src=\"$pixpath/t/show.gif\" height=11 width=11 border=0></a> ";
+        }
+
+        if ($up) {
+            echo "<a title=\"$str->moveup\" href=\"index.php?moveup=$category->id\"><img".
+                 " src=\"$pixpath/t/up.gif\" height=11 width=11 border=0></a> ";
+        }
+        if ($down) {
+            echo "<a title=\"$str->movedown\" href=\"index.php?movedown=$category->id\"><img".
+                 " src=\"$pixpath/t/down.gif\" height=11 width=11 border=0></a> ";
+        }
+        echo "</td>";
+
+        echo "<td align=\"left\" width=\"0\">";
+        $tempdisplaylist = $displaylist;
+        unset($tempdisplaylist[$category->id]);
+        foreach ($parentslist as $key => $parents) {
+            if (in_array($category->id, $parents)) {
+                unset($tempdisplaylist[$key]);
+            }
+        }
+        popup_form ("index.php?move=$category->id&moveto=", $tempdisplaylist, "moveform$category->id", "$category->parent", "", "", "", false);
+        echo "</td>";
+        echo "</tr>";
     } else {
-        print_courses($category, "80%");
+        $category->id = "0";
     }
 
-    print_footer();
+    if ($categories = get_categories($category->id)) {   // Print all the children recursively
+        $countcats = count($categories);
+        $count = 0;
+        $first = true;
+        $last = false;
+        foreach ($categories as $cat) {
+            $count++;
+            if ($count == $countcats) {
+                $last = true;
+            }
+            $up = $first ? false : true;
+            $down = $last ? false : true;
+            $first = false;
 
-?>
+            print_category_edit($cat, $displaylist, $parentslist, $depth+1, $up, $down);         
+        }
+    }
+}
 
 
+?>
index ab1c8e7b2a47a2a4a85b6be6e8b13bb6217ead90..e7c52c3aaf7c88779d56be1ba7bc1c84a0a43d4a 100644 (file)
@@ -713,19 +713,13 @@ function print_admin_links ($siteid, $width=180) {
                $modicon[]="";
     }
     if (iscreator()) {
-           $moddata[]="<a href=\"$CFG->wwwroot/course/edit.php\">".get_string("addnewcourse")."</a>";
+           $moddata[]="<a href=\"$CFG->wwwroot/course/index.php\">".get_string("coursemanagement")."</a>";
                $modicon[]=$icon;
-               $moddata[]="<a href=\"$CFG->wwwroot/$CFG->admin/teacher.php\">".get_string("assignteachers")."</a>";
+           $moddata[]="<a href=\"$CFG->wwwroot/course/edit.php\">".get_string("addnewcourse")."</a>";
                $modicon[]=$icon;
         $fulladmin = "";
     }
     if (isadmin()) {
-           $moddata[]="<a href=\"$CFG->wwwroot/course/categories.php\">".get_string("categories")."</a>";
-               $modicon[]=$icon;
-               $moddata[]="<a href=\"$CFG->wwwroot/course/delete.php\">".get_string("deletecourse")."</a>";
-               $modicon[]=$icon;
-               $moddata[]="<a href=\"$CFG->wwwroot/backup/backup.php\">".get_string("coursebackup")."</a>";
-               $modicon[]=$icon;
                $moddata[]="<a href=\"$CFG->wwwroot/files/index.php?id=$siteid\">".get_string("courserestore")."</a>";
                $modicon[]=$icon;
                $moddata[]="<hr>";
@@ -853,14 +847,15 @@ function print_whole_category_list($category=NULL, $displaylist=NULL, $parentsli
 
     if ($category) {
         if ($category->visible or isadmin()) {
-            print_category_box($category, $depth);
+            print_category_info($category, $depth);
         } else {
             return;  // Don't bother printing children of invisible categories
         }
         
     } else {
-        print_simple_box_start("center", "100%");
         $category->id = "0";
+        echo "<table width=\"100%\" class=\"categorybox\">";
+        $toplevel = true;
     }
 
     if ($categories = get_categories($category->id)) {   // Print all the children recursively
@@ -881,14 +876,15 @@ function print_whole_category_list($category=NULL, $displaylist=NULL, $parentsli
         }
     }
 
-    if ($category->id == "0") {
-        print_simple_box_end();
+    if (isset($toplevel)) {
+        echo "</table>";
     }
 }
 
 
-function print_category_box($category, $depth) {
-/// Prints the category box in indented fashion
+function print_category_info($category, $depth) {
+/// Prints the category info in indented fashion
+/// This function is only used by print_whole_category_list() above
 
     global $CFG;
 
@@ -901,23 +897,21 @@ function print_category_box($category, $depth) {
         $pixpath = "$CFG->wwwroot/theme/$CFG->theme/pix";
     }
 
-    $size = $depth * 40;
-
     $catlinkcss = $category->visible ? "" : " class=\"dimmed\" ";
 
-    echo "<table class=\"categorybox\">";
     echo "<tr>";
-    echo "<td width=\"$size\">";
-    echo print_spacer(1, $size);
-    echo "<td width=\"100%\">";
-    echo "<font size=+1><a $catlinkcss href=\"$CFG->wwwroot/course/index.php?category=$category->id\">$category->name</a></font>";
-    echo "<br />";
-    //echo "<font size=+1>$category->name</font>";
+    echo "<td valign=\"top\">";
+    for ($i=0; $i<$depth;$i++) {
+        echo "<ul style=\"margin-bottom: 0\">";
+    }
+    echo "<font size=+1><a $catlinkcss ".
+         "href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a></font>";
+
     if ($CFG->frontpage == FRONTPAGECOURSELIST) {
-        if ($courses = get_courses($category)) {
+        if ($courses = get_courses($category->id)) {
             foreach ($courses as $course) {
                 $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
-                echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
+                echo "<ul>";
                 echo "<a $linkcss href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a>";
                 echo "&nbsp;&nbsp;";
                 unset($courses[$key]);
@@ -929,14 +923,26 @@ function print_category_box($category, $depth) {
                     echo "<a title=\"$strrequireskey\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
                     echo "<img alt=\"\" height=16 width=16 border=0 src=\"$pixpath/i/key.gif\"></a>";
                 }
-                echo "<br />";
+                echo "</ul>";
             }
         }
+        for ($i=0; $i<$depth;$i++) {
+            echo "</ul>";
+        }
+        echo "</td>";
+        echo "</tr>";
+    } else {
+        for ($i=0; $i<$depth;$i++) {
+            echo "</ul>";
+        }
+        echo "</td>";
+        echo "<td valign=\"top\">";
+        if ($count = count_records("course", "category", $category->id)) {
+            echo $count;
+        }
+        echo "</td>";
+        echo "</tr>";
     }
-    echo "</td>";
-    echo "</tr>";
-    echo "</table>";
-
 }
 
 function print_courses_sideblock($category=0, $width="100%") {
@@ -954,12 +960,13 @@ function print_courses_sideblock($category=0, $width="100%") {
     if (count($categories) > 1) {     // Just print top level category links
         foreach ($categories as $category) {
             $linkcss = $category->visible ? "" : " class=\"dimmed\" ";
-            $moddata[]="<a $linkcss href=\"$CFG->wwwroot/course/index.php?category=$category->id\">$category->name</a>";
+            $moddata[]="<a $linkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a>";
             $modicon[]=$icon;
         }
     } else {                          // Just print course names of single category
         $category = array_shift($categories);
-        $courses = get_courses($category);
+        $courses = get_courses($category->id);
+
         if ($courses) {
             foreach ($courses as $course) {
                 $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
@@ -988,14 +995,14 @@ function print_courses($category, $width="100%") {
         $categories = get_categories(0);  // Parent = 0   ie top-level categories only
         if (count($categories) == 1) {
             $category   = array_shift($categories);
-            $courses    = get_courses($category);
+            $courses    = get_courses($category->id);
         } else {
-            $courses    = get_courses(0);
+            $courses    = get_courses("all");
         }
         unset($categories);
     } else {
         $categories = get_categories($category->id);  // sub categories
-        $courses    = get_courses($category);
+        $courses    = get_courses($category->id);
     }
 
     if ($categories) {
index 317a7c23e4524274fe858ff21e8f3d43bb03cbe3..22a0a6edd0d6c2cd54b58767490cfd7ff813cfb7 100644 (file)
@@ -24,7 +24,7 @@
     <LI>Languages can now have a parent language</LI>
     <LI>Web links can be in pop-up windows</LI>
     <LI>Courses can be hidden from students)</LI>
-    <LI>Improved course browser (handles large numbers of courses) (tbd)</LI>
+    <LI>Improved course browser (handles large numbers of courses)</LI>
     <LI>Consistent grading scheme throughout all modules (tbd)</LI>
     <LI>Better control over peer-grading in forums (tbd)</LI>
     <LI>Ability to add text between activities in course display (tbd)</LI>
 
 <HR>
 
-<H3> New in Moodle 1.0.8.1 (12th January, 2003) :</H3>
-<UL><DL>
-<DT> No new features, just bug fixes:</DT>
-<DD>
-   <LI> Fixed one-in-a-million bug with email confirmations 
-   <LI> Quiz feedback text can be styled
-   <LI> Deals better with a new module that is not readable
-   <LI> Fixed bug when setting times for assignments, quizzes when the teacher is in a different timezone to the server
-   <LI> Fixed listing of calendar months on some servers
-   <LI> Richtext editor now works properly in choice module
-   <LI> More robust when looking for some environment variables
-   <LI> Installer checks that sessions directory is writeable
-   <LI> Added a small test program to test sessions support
-</DD>
-</DL></UL>
-
-<HR>
-
-
-<H3> New in Moodle 1.0.8 (6th January, 2003) :</H3>
-<UL><DL>
-<DT> Databases</DT>
-<DD> Moodle now has complete native support support for <B>PostgreSQL 7</B> databases (thanks 
-     to Mary Hunter for the SQL files and other ideas!).
-     Moodle also now supports table prefixes, which means you can install 
-     Moodle into any database, even if it already contains tables from 
-     other web applications.
-     A number of other changes have also been made to the code structure that will 
-     make it fairly easy now to add full support for other database types.</DD>
-
-<DT> Languages </DT>
-<DD> <B><U>Six</U> new languages have been added!</B>  Chinese (from Zhang Dexuan), 
-     Arabic (from Ahmed Nabil), Turkish (from M. Cüneyt Birkök), Swedish (from Set Lonnert),
-     Thai (from Wim Singhanart) and Dutch (from Hans Zwart and Jacob Romeyn).  Many thanks 
-     to all these hard-working people!  Most other languages have also had updates and fixes since 1.0.7.
-     The language editor has been improved slightly, making it easier to see
-     new strings and empty strings that need translating.  The main documentation manual is 
-     also now able to be localised and will appear in the current language if 
-     translated versions exist.</DD>
-
-<DT> Layout</DT>
-<DD> A number of small improvements have been made in the layout of many pages (such 
-     as the forum posting screen) to make them clearer, neater and smaller.  Almost all text entry screens
-     now have specific help items alongside them (depending on the pedagogical 
-     focus). The forums now have a quick search form available on every page.</DD>
-
-<DT> Themes </DT>
-<DD> Theme support of CSS has been extended to give theme makers more control 
-     over more of the Moodle web site. A variety of new themes has been added
-     to the distribution.</DD>
-
-<DT> Resources</DT>
-<DD> A new type of resource has been added, called "Program", which allows 
-     Moodle to cooperate with external web applications by passing information
-     about the current user and session to them.
-     Uploaded HTML files can now be edited using the WYSIWYG HTML editor. </DD>
-
-<DT> Choices</DT>
-<DD> Results can now be "published" (either with names or anonymously) so that 
-     everyone can see the statistics.  Choice text can be edited using HTML editor.</DD>
-
-<DT> Grades</DT>
-<DD> Students can now see all their own grades for a course on one page, accessible
-     from the course home page.</DD>
-
-<DT> Quizzes</DT>
-<DD> Students can now review all their past quiz attempts, but only if the quiz has been closed, 
-     and if the teacher allows it.</DD>
-
-<DT> Authorisation </DT>
-<DD> The database module now supports databases that contain md5-encrypted passwords, 
-     which means it should now be compatible with systems like PostNuke. When using 
-     external authorisation students are now forced to fully fill-out their information
-     before they can enter any course.  An ADOdb bug was also causing some mischief 
-     when the external database type was the same as the Moodle database.  
-     Overall it's now quite usable.</DD>
-
-<DT> Administration </DT>
-<DD> The admin can now assign other people to also be admins.  The interface to the 
-     Database Manager has been cleaned up, and it now always uses the same
-     language as the current Moodle language (see separate download for <A HREF="http://moodle.com/mod/resource/view.php?id=8">moodle-1.0.8-mysql-admin.zip</A>).</DD>
-
-<DT> Debugging mode </DT>
-<DD> Admins/developers can use a "debugging mode" which prints more information 
-     and warning messages about unset variables and so on - making it easier to 
-     find bugs.  To make this work a LOT of cleaning up has been done on existing 
-     Moodle code to make it more robust.</DD>
-
-<DT> Other things</DT>
-<DD> 
-     <LI> Unpacked template module is ignored by Moodle.
-     <LI> A default country can be set by the admin
-     <LI> View source button in Richtext editor was missing with some languages
-     <LI> A bug affecting grades page on some installations was fixed.
-     <LI> File upload problems on 4.3.0 have been fixed.
-     <LI> Some minor problems with the display of logs has been fixed.
-     <LI> Improved GD detection that works with PHP 4.3.0
-     <LI> If GD is not present then Moodle is now more usable (just less capable)
-     <LI> A bug causing the wrong display of the date has been fixed.
-     <LI> Usernames can now contain "." and "-" characters.
-     <LI> Cookies now use table prefixes for unique naming, so that many 
-          different moodle sites can be run on the same web site and database.
-     <LI> Site news forum heading can now be changed (edit the forum).
-     <LI> Improved code for gathering form input
-     <LI> The buggy_referrer variable is fixed and now works as expected
-     <LI> Some small performance improvements here and there
-     <LI> Other improvements I probably forgot to add here
-     <LI> Many little code clean-ups.
-</DD>
-
-</DL></UL>
-
-
-<HR>
-<H3>  New in Moodle 1.0.7 (10th December, 2002):   </H3>
-<UL><DL>
-<DT> Simpler version numbers!</DT>
-<DD> The four-digit version numbers were getting a bit ridiculous (too complex), 
-     so I've switched back to simpler 3-digit numbers.  The first digit is the 
-     major structural version, the second digit is for decent-sized upgrades
-     and the third digit is for minor upgrades.</DD>
-
-<DT> Languages</DT>
-<DD> Two completely new languages have been added: Indonesian (from Arfan Hidayat) 
-     and Japanese (from Mitsuhiro Yoshida).  A US English version was added too.
-     Most other languages contain some updates.  All languages now contain locale 
-     information, which means that when a user changes the language all the dates 
-     will display properly too.</DD>
-
-<DT> Database access</DT>
-<DD> ADOdb was upgraded to 2.50 which should fix some problems with very 
-     new versions of PHP (4.3.0).</DD>
-
-<DT> Layout improvements</DT>
-<DD> Cleaned up the display of "side boxes" and added CSS style control over 
-     more elements on the site and course pages.  You may need to upgrade
-     your custom themes to get the full effect.  Changes are in styles.php, 
-     config.php and one line in header.html.
-
-     <P>The interface when 
-     courses are on front page and there is more than one category has 
-     been improved (no longer just shows short course names).</P>
-     
-     </DD>
-
-<DT> Class interface</DT>
-<DD> A wrapper file provides a class interface to main Moodle library 
-     (for external programs interfacing to Moodle) - moodle/lib/makeclass.php</DD>
-
-<DT> Small improvements and bug fixes</DT>
-<DD>
-     <LI> Quizzes now have a confirmation dialog when submitting an attempt
-     <LI> Courses now default to having "show recent activity" on (again).
-     <LI> Abolished leading zeroes in dates (introduced in last release)
-     <LI> Some formatting fixes for Japanese and old Netscape browsers
-     <LI> Teacher can allow larger assignments to be uploaded
-     <LI> Change password button on user page now always functions like the one on login page
-     <LI> Forum search now searches subjects as well as messages
-     <LI> Various HTML fixes
-     <LI> Fixes to grades display when there are no grades, also no forum ratings
-     <LI> Slashes in requested filenames are now stripped
-     <LI> Updates to the documentation
-</DD>
-
-
-</DL></UL>
-
-
-
-<HR>
-<H3>  New in Moodle 1.0.6.4 (24th November, 2002) : </H3>
-<UL><DL>
-
-<DT> Authentication</DT>
-<DD> Moodle now features seven different authentication mechanisms,
-     making it possible to hook Moodle up to nearly any external list
-     of users!</P>
-     <P>New methods just added include IMAP, POP3 and NNTP servers (including
-     those using SSL or certificate-based authentication), and also 
-     authentication against user-specified fields in ANY 
-     external database table.</P>
-     <P>The login page can now be partially customised 
-     by the admin with personalised instructions, and the guest login can be 
-     hidden if desired.  </P>
-     <P>"Mappings" can be defined so that other fields (such as email, firstname,
-     lastname, department, language etc) can also be copied from LDAP or an 
-     external database when accounts are first used.</P>
-     
-     <P>Finally, Moodle now sports a cool 
-     new admin GUI for configuring all of this, so it should be pretty 
-     easy now to set up external authentication.
-     Many thanks to contributor Petri Asikainen for helping with the admin GUI.</P></DD>
-
-<DT> Languages</DT>
-<DD> Complete new Norwegian translation (from Jøran Sørbø), and updates for several others.</DD>
-
-<DT> Assignments</DT>
-<DD> Students can now resubmit assignments after grading if the teacher allows it</DD>
-
-<DT> Contributed code</DT>
-<DD> Standalone user-contributed code is now distributed under the /contrib directory.  This directory
-     could get quite large, and the quality/security of it has usually not been checked by me,
-     and so this code is not included in the standard releases and nightlies.  However, people
-     who are interested in it can access it via CVS (or see <A HREF="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/moodle/moodle/contrib/">CVS web view</A>).  As these new features become polished or if demand grows for them,
-     then I'll integrate them into the main Moodle distribution.
-     <BR><BR>
-     The first contributor is Holger Schadeck (compuproggy), who has written some <A HREF="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/moodle/moodle/contrib/compuproggy/">interesting code</A>   to help with translating all the Moodle help files.  Check it out!</DD>
-
-<DT> Bug fixes</DT>
-<DD>
-     <LI> Day value in dates (eg forum posts, weekly listing) are 
-          now displayed correctly on Windows servers.
-     <LI> config-dist.php and README.txt is now in DOS format to make it easier for Windows users to get started (Unix users shouldn't be affected).
-     <LI> Added a workaround (and new config switch in config-dist.php) for 
-          some systems which have buggy referer variables.  This should help 
-          those people getting "stuck" on a form during setup.
-     <LI> Logout now sends you to the home page and clears the session completely.
-     <LI> Timezones now range between -13 to 13 hours (for daylight saving).
-     <LI> Character set in email now matches current language.
-     <LI> User pictures are now uploaded even if other fields have errors.
-     <LI> Full-size user pictures on user profile page no longer clickable.
-     <LI> Long user listing now has a small notice at the bottom about automatic unenrolment
-     <LI> Unenrol and change password buttons are hidden for guest student
-     <LI> Fixed occasional case where submitted assignments were sometimes having their owner changed.
-     <LI> User log graphs are now faster, cleaner and translatable.
-     <LI> Fixed HTML display errors with courses in category boxes on front page.
-     <LI> Admin and guest accounts now always work, even with external authentication activated.
-     <LI> Slightly more security when writing/reading files (now checks for embedded scripting).
-     <LI> The same user can now be deleted more than once (create, delete, recreate, delete caused error).
-     <LI> Language editor now works with multibyte languages (Thanks, Mits)
-</DD>
-
-</DL></UL>
-
-
-<HR>
-<H3>  New in Moodle 1.0.6.3 (14th November, 2002) :   </H3>
-<UL><DL>
-
-<DT> Bug fix for no-name forums.</DT>
-<DD> New sites created with 1.0.6.2 had some forums appearing with no names
-     (for example the News forum on the home page).
-     A workaround is to add a new activity to that section (all the names 
-     will be refreshed), but this release will fix it too. </DD>
-
-<DT> New languages!</DT>
-<DD> Catalan and Spanish (Spain) translations have arrived!</DD>
-
-<DT> Some display improvements for old Netscape browsers (headers and quizzes)</DT>
-
-<DT> Guest language now ALWAYS the same as the current site language</DT>
-
-<DT> "Recent Activity" can now be disabled completely if desired </DT>
-
-<DT> For very large classes (larger than 500) participant list is not displayed</DT>
-
-</DL></UL>
-
-<HR>
-
-<H3>  New in Moodle 1.0.6.2 (11th November, 2002) :   </H3>
-<UL><DL>
-<DT> Course formatting improvements </DT>
-<DD> The weekly and topic formats now have an extra "general" area up 
-     the top where "general" activities are listed - these are things 
-     that apply throughout the course, not just to one particular topic
-     or week.  This general area is not shown if it is completely empty.</DD>
-
-<DT> Popup "jump" menu. </DT>
-<DD> You can now jump from one activity directly to any other using a 
-     popup menu in the upper-right corner of the page</DD>
-
-<DT> Speed improvements </DT>
-<DD> Course activity details are now cached for each course, which 
-     greatly reduces the amount of database access required to display
-     the course page.  On heavily accessed systems this should improve speed.</DD>
-
-<DT> Languages </DT>
-<DD> Surveys are now completely translatable.</DD>
-
-<DT> Admin improvements </DT>
-<DD> Paging was added to the user admin page, so that the admin can now 
-     browse large numbers of users.  </DD>
-
-<DT> Fixes and tweaks </DT>
-<DD> Various other small improvements to formatting</DD>
-</DL></UL>
-
-
-<HR>
-
-<H3>  New in Moodle 1.0.6.1 (6th November, 2002) :   </H3>
-<UL><DL>
-<DT> New assignment type: offline assignments </DT>
-<DD> In addition to "upload a file" assignments, you can now have "offline" 
-     assignments.  These don't require the student to do anything online.
-     They are useful for grading activities that are not on in Moodle, and a
-     also useful for adding "manual" columns to the grade page.</DD>
-
-<DT> Languages </DT>
-<DD> Spanish (Mexican) has been added to the distribution.  Other languages have various improvements.</DD>
-
-<DT> SMTP authentication </DT>
-<DD> SMTP mail now supports SMTP username and password if needed</DD>
-
-<DT> Documentation </DT>
-<DD> Some parts rewritten, and documentation cleaned up (upgrade info now part of main docs)</DD>
-
-<DT> Other fixes </DT>
-<UL><LI>Better checking on teachers using "loginas" to stop them roaming other courses as a student
-         <LI>While using "loginas", teachers can return to their own identity using a link in the footer
-         <LI>Some strings fixed in assignments, journals, and forums.
-         <LI>Guest language is now the same as the site
-         <LI>etc
-     </UL></DD>
-     
-</DL></UL>
-
-
-<HR>
-<H3>  New in Moodle 1.0.6 (26th October, 2002) :   </H3>
-
-<UL><DL>
-<DT> New feature - WYSIWYG Text editing! </DT>
-<DD> A WYSIWYG text editor has been added to many of the forms in Moodle.  These are currently 
-     only visible when using Microsoft Internet Explorer 5.5 or later - other browsers see the 
-     normal forms exactly as before.</DD>
-
-<DT> New feature - Quiz module! </DT>
-<DD> Finally, the most requested new module is here!  Multiple choice, short answer, and true-false
-     questions with automatic marking, multiple attempts, teacher regrading and many other features.
-     Questions are stored in a categorised database, and may be "published" to other courses.</DD>
-
-<DT> New feature - Grade manager! </DT>
-<DD> A new tool has been added for teachers to see all grades for a course on one page.
-     You can also download/export grades as a tab-separated text file or an Excel
-     Spreadsheet.  In future more features will be added to this page like sorting, manual 
-     columns and calculations, but it's still pretty useful right now.</DD>
-
-<DT> New feature - LDAP authentication! </DT>
-<DD> Moodle can now authenticate against external directories that use the 
-     LDAP protocol (including Novell etc).  Many thanks to Petri Asikainen for
-     developing this authentication plug-in!</DD>
-
-<DT> New feature - New smilies </DT>
-<DD> Many new smilies have been added, and are now also accessible using a GUI in the text editor.</DD>
-
-<DT> Improved text editing </DT>
-<DD> You can now include all major HTML tags in all texts.  This is now safe because 
-     of newly added functionality that strips all Javascript and faulty tags from texts 
-     before they can cause security or display problems.</DD>
-
-<DT> Languages </DT>
-<DD> German and Italian have been added!  Many thanks to the translators (see the credits).</DD>
-
-<DT> Reading module => Resource module </DT>
-<DD> After much thought and a vote of support (21 "yes" to 6 "no") on the "Using Moodle" 
-     web site I changed the name of the "reading" module to "resource" (at the code level
-     and also the language packs).  It was better to do this earlier than later.
-     This more generic name will be more meaningful to more people and opens the way to 
-     some real development on a resource library.
-     But I don't want to ever change a module name again!  :-)
-     If you have any hard-coded URLs pointing to readings that you don't want to break,
-     you can add a line like this to your Apache httpd.conf to redirect them:
-     <P><CODE>Redirect /mod/reading http://yourserver.com/mod/resource</CODE></P>
-     <FONT COLOR=RED>Note: if upgrading to 1.0.6 you may have some "reading" errors in "Recent activity" ... logging
-     out and then logging in again will fix this</FONT></DD>
-
-<DT> Other additions </DT>
-<DD> An admin script to totally delete the Moodle data directory has been included (admin/delete.php)
-     for people who need to tear down a Moodle installation but don't have root access on their
-     server.</DD>
-
-<DT> Miscellaneous </DT>
-<DD> Many small improvements have been made to the interface, and many small bugs have been fixed.
-     Some examples: 
-     <UL>
-     <LI> Big "Edit this page" buttons at the top of pages (replacing the tiny icon)
-     <LI> LDAP authentication module (thanks to Petri)
-     <LI> Authentication from external sources can now import any fields
-     <LI> Student assignment list now shows submission status properly
-     <LI> Default language for users is now the site language
-     <LI> Users have a 'Change Password' button on their profile page
-     <LI> Journals that need teacher feedback are highlighted
-     <LI> More documentation and more context help buttons
-     <LI> Database-specific upgrade code
-     <LI> Uses character-set codes to make the browser do the right thing 
-     <LI> User's name in footer is now a link
-     <LI> News and social forums are now editable
-     <LI> Forums that don't allow posting don't have uneccessary "discuss" links 
-     <LI> Improved algorithm for shortening posts in forum listings
-     <LI> Choice module now allows up to six choices
-     </UL>
-</DD>
-</DL></UL>
 
-<P>Older releases can be seen in the <A HREF="http://moodle.com/mod/forum/view.php?f=1">Moodle.com announcement forum</A>.
+<P>Older releases can be seen in the <A HREF="http://moodle.org/mod/forum/view.php?f=1">Moodle.org announcement forum</A>.
 
 
 <P>&nbsp;</P>
index 6a2818746a0e0f3462e2f2d46a2d5308413b3688..6e06a449c6f21b74c5f1b22af27d960908d80716 100644 (file)
@@ -6,6 +6,7 @@ $string['modulenameplural'] = "Forums";
 #------------------------------------------------------------
 
 $string['addanewdiscussion'] = "Add a new discussion topic";
+$string['addanewtopic'] = "Add a new topic";
 $string['allowchoice'] = "Allow everyone to choose";
 $string['allowdiscussions'] = "Can a \$a post to this forum?";
 $string['allowratings'] = "Allow posts to be rated?";
@@ -63,6 +64,7 @@ $string['nameteacher'] = "Teacher forum";
 $string['newforumposts'] = "New forum posts";
 $string['nodiscussions'] = "There are no discussion topics yet in this forum";
 $string['noguestpost'] = "Sorry, guests are not allowed to post";
+$string['nonews'] = "No news has been posted yet";
 $string['noposts'] = "No posts";
 $string['nopostscontaining'] = "No posts containing '\$a' were found";
 $string['nosubscribers'] = "There are no subscribers yet for this forum";
index 163477f5f78f4be3677d59eb804c2745fbfe3056..6cedc8f9d049144f9e8794255eb39913624e9379 100644 (file)
@@ -129,6 +129,7 @@ $string['coursecreators'] = "Course Creators";
 $string['courseinfo'] = "Course info";
 $string['coursefiles'] = "Course Files";
 $string['courseformats'] = "Course formats";
+$string['coursemanagement'] = "Course Management";
 $string['courserestore'] = "Course Restore";
 $string['courses'] = "Courses";
 $string['courseupdates'] = "Course updates";
index c06a04252367092571a1f3503a5032f882d89aed..9ffb472058697d6b64b2a755ad320f8eb2feeb7a 100644 (file)
@@ -838,26 +838,13 @@ function get_site () {
     }
 }
 
-
-function get_courses($category=0, $sort="fullname ASC") {
+function get_courses($categoryid="all", $sort="sortorder ASC", $fields="*") {
 /// Returns list of courses, for whole site, or category
 
-    if ($category === 0) {         // Return all courses, except site
-        $courses = get_records_select("course", "category > 0", $sort);
-
-    } else if ($category === -1) { // Return all courses, even the site
-        $courses = get_records("course", "", "", $sort);
-
-    } else {                       // $category is an object
-        $courses = get_records("course", "category", $category->id);
-        if ($courses) {      // Reorder them
-            $courselist = explode(',', $category->courseorder);
-            $outcourses = array();
-            foreach ($courselist as $courseid) {
-                $outcourses[] = $courses[$courseid];
-            }
-            $courses = $outcourses;
-        }
+    if ($categoryid == "all") {
+        $courses = get_records("course", "", "", $sort, $fields);
+    } else {
+        $courses = get_records("course", "category", "$categoryid", $sort, $fields);
     }
 
     if ($courses) {  /// Remove unavailable courses from the list
@@ -872,6 +859,7 @@ function get_courses($category=0, $sort="fullname ASC") {
     return $courses;
 }
 
+
 function get_my_courses($userid, $sort="c.fullname ASC") {
     global $CFG;
 
@@ -887,6 +875,8 @@ function get_my_courses($userid, $sort="c.fullname ASC") {
 
 
 function get_categories($parent="none", $sort="sortorder ASC") {
+/// Returns a sorted list of categories
+
     if ($parent == "none") {
         $categories = get_records("course_categories", "", "", $sort);
     } else {
@@ -905,43 +895,30 @@ function get_categories($parent="none", $sort="sortorder ASC") {
     return $categories;
 }
 
-function fix_category_courses($categoryid) {
-/// Given a category, this function makes sure the courseorder 
+
+function fix_course_sortorder($categoryid) {
+/// Given a category object, this function makes sure the courseorder 
 /// variable reflects the real world.
 
-    if (!$category = get_record("course_categories", "id", $categoryid)) {
-        return false;
+    if (!$courses = get_records("course", "category", "$categoryid", "sortorder ASC", "id, sortorder")) {
+        return true;
     }
 
-    $catcourseschanged = false;
-
-    if (trim($category->courseorder)) {
-        $catcourses = explode(',', $category->courseorder);
-    } else {
-        $catcourses = array();
-    }
-    $courses = get_records("course", "category", $category->id);
+    $count = 0;
+    $modified = false;
 
-    if ($catcourses) {
-        foreach ($catcourses as $key => $catcourse) {  // Look for missing courses
-            if (!isset($courses[$catcourse])) {
-                $catcourseschanged = true;
-                unset($catcourses[$key]);
-            }
-        }
-    }
-    if ($courses) {
-        foreach ($courses as $course) {
-            if (!in_array($course->id, $catcourses)) {
-                $catcourseschanged = true;
-                $catcourses[] = $course->id;
-            }
+    foreach ($courses as $course) {
+        if ($course->sortorder != $count) {
+            set_field("course", "sortorder", $count, "id", $course->id);
+            $modified = true;
         }
+        $count++;
     }
-    if ($catcourseschanged) {
-        $category->courseorder = implode(',', $catcourses);
-        return set_field("course_categories", "courseorder", $category->courseorder, "id", $category->id);
+
+    if ($modified) {
+        set_field("course_categories", "timemodified", time(), "id", $categoryid);
     }
+
     return true;
 }
 
index a2058df9b6c626d3593bc3daabde0b6a6de43416..dca38c03436a3da36530ecd7cdfae37b9cd8b6c6 100644 (file)
@@ -422,6 +422,20 @@ function main_upgrade($oldversion=0) {
         table_column("course_categories", "", "timemodified", "integer", "10", "unsigned");
     }
 
+    if ($oldversion < 2003080400) {
+        table_column("course_categories", "courseorder", "courseorder", "integer", "10", "unsigned");
+        table_column("course", "", "sortorder", "integer", "10", "unsigned", "0", "", "category");
+    }
+
+    if ($oldversion < 2003080700) {
+        notify("Cleaning up categories and course ordering...");
+        if ($categories = get_categories()) {
+            foreach ($categories as $category) {
+                fix_course_sortorder($category->id);
+            }
+        }
+    }
+
     return $result;
 
 }
index 66c0a33bd811474f821cc418cb90ebdc43b0c62e..7b2dd896ab292e66408a0d38a8648ba95acf55dd 100644 (file)
@@ -30,6 +30,7 @@ CREATE TABLE `prefix_config` (
 CREATE TABLE `prefix_course` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `category` int(10) unsigned NOT NULL default '0',
+  `sortorder` int(10) unsigned NOT NULL default '0',
   `password` varchar(50) NOT NULL default '',
   `fullname` varchar(254) NOT NULL default '',
   `shortname` varchar(15) NOT NULL default '',
@@ -63,7 +64,7 @@ CREATE TABLE `prefix_course_categories` (
   `description` text NOT NULL,
   `parent` int(10) unsigned NOT NULL default '0',
   `sortorder` int(10) unsigned NOT NULL default '0',
-  `courseorder` text NOT NULL,
+  `courseorder` int(10) unsigned NOT NULL default '0',
   `visible` tinyint(1) NOT NULL default '1',
   `timemodified` int(10) unsigned NOT NULL default '0',
   PRIMARY KEY  (`id`),
index 8e3c95986c5b842bc945ab4d6ab882dbf868d304..fe560589a1e08316f918532a2bd72f2cc7511f21 100644 (file)
@@ -193,6 +193,21 @@ function main_upgrade($oldversion=0) {
         table_column("course_categories", "", "timemodified", "integer", "10", "unsigned");
     }
 
+    if ($oldversion < 2003080400) {
+        notice("If the following command fails you may want to change the type manually, from TEXT to INTEGER.  Moodle should keep working even if you don't.");
+        table_column("course_categories", "courseorder", "courseorder", "integer", "10", "unsigned");
+        table_column("course", "", "sortorder", "integer", "10", "unsigned", "0", "", "category");
+    }
+
+    if ($oldversion < 2003080700) {
+        notify("Cleaning up categories and course ordering...");
+        if ($categories = get_categories()) {
+            foreach ($categories as $category) {
+                fix_course_sortorder($category->id);
+            }
+        }
+    }
+
     return $result;
 }
 ?>    
index 3a8630f108d065b2697a8d4ac2a7963039e0f20c..39ef50efe90dcfefb7362e9e0679289c4d6b1668 100644 (file)
@@ -8,6 +8,7 @@ CREATE TABLE prefix_config (
 CREATE TABLE prefix_course (
    id SERIAL PRIMARY KEY,
    category integer NOT NULL default '0',
+   sortorder integer NOT NULL default '0',
    password varchar(50) NOT NULL default '',
    fullname varchar(254) NOT NULL default '',
    shortname varchar(15) NOT NULL default '',
@@ -34,7 +35,7 @@ CREATE TABLE prefix_course_categories (
    description text NOT NULL default '',
    parent integer NOT NULL default '0',
    sortorder integer NOT NULL default '0',
-   courseorder text NOT NULL default '',
+   courseorder integer NOT NULL default '0',
    visible integer NOT NULL default '1',
    timemodified` integer NOT NULL default '0'
 );
index 0121cd3dbbb5c1f71020cce86bfae2b9a5f762b5..5bed9f254448322ec7778a2377144b2a96a38bb1 100644 (file)
@@ -1080,13 +1080,38 @@ function update_module_button($moduleid, $courseid, $string) {
 }
 
 function update_category_button($categoryid) {
-// Prints the editing button on a module "view" page
-    global $CFG;
+// Prints the editing button on a category page
+    global $CFG, $USER;
 
-    if (isadmin()) {
-        $string = get_string("editthiscategory");
+    if (iscreator()) {
+        if (!empty($USER->editing)) {
+            $string = get_string("turneditingoff");
+            $edit = "off";
+        } else {
+            $string = get_string("turneditingon");
+            $edit = "on";
+        }
         return "<form target=_parent method=get action=\"$CFG->wwwroot/course/category.php\">".
                "<input type=hidden name=id value=\"$categoryid\">".
+               "<input type=hidden name=edit value=\"$edit\">".
+               "<input type=submit value=\"$string\"></form>";
+    }
+}
+
+function update_categories_button() {
+// Prints the editing button on categories listing
+    global $CFG, $USER;
+
+    if (isadmin()) {
+        if (!empty($USER->editing)) {
+            $string = get_string("turneditingoff");
+            $edit = "off";
+        } else {
+            $string = get_string("turneditingon");
+            $edit = "on";
+        }
+        return "<form target=_parent method=get action=\"$CFG->wwwroot/course/index.php\">".
+               "<input type=hidden name=edit value=\"$edit\">".
                "<input type=submit value=\"$string\"></form>";
     }
 }
index 42d994d8a407e1cd1252ece5a4ecf25e2c3fe9ba..149b796802180d25d0651893e4ba51486f1e14ec 100644 (file)
     print_heading( get_string("userprofilefor", "", "$userfullname") );
 
     if (isset($USER->newadminuser)) {
-        print_simple_box(get_string("configintroadmin"), "center");
+        print_simple_box(get_string("configintroadmin"), "center", "50%");
         echo "<br />";
     }
 
index 91d71a7e75d5eef641b141152ef484edc15e6772..16554dd8feca56460ebaabfdce8af8f803e643c8 100644 (file)
@@ -5,7 +5,7 @@
 // database to determine whether upgrades should
 // be performed (see lib/db/*.php)
 
-$version = 2003073000;   // The current version is a date (YYYYMMDDXX)
+$version = 2003080700;   // The current version is a date (YYYYMMDDXX)
 
 $release = "1.1 development";  // User-friendly version number