]> git.mjollnir.org Git - moodle.git/commitdiff
Categories upgrade. Admin can now create/edit/delete categories, and
authormartin <martin>
Mon, 9 Sep 2002 11:48:11 +0000 (11:48 +0000)
committermartin <martin>
Mon, 9 Sep 2002 11:48:11 +0000 (11:48 +0000)
these are diesplayed wherever courses are listed

CHANGES
admin/index.php
admin/site.php
course/categories.php [new file with mode: 0644]
course/index.php
course/lib.php
index.php
lang/en/moodle.php
version.php

diff --git a/CHANGES b/CHANGES
index 016af2fe9ba6c86beaf4f5db1e336438b6d58a34..3ce57a233670b030d390558d4dbcea9c1c80d3b0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,183 @@
+2002-09-09 Monday 00:13  martin
+
+       * lib/weblib.php: 
+       
+       Added height and width to smiley icons, to make emails look better
+       in circumstances where external images are blocked (eg some webmail
+       programs like squirrelmail).
+
+2002-09-09 Monday 00:04  martin
+
+       * mod/forum/lib.php: 
+       
+       Added an "unsubscribe" link to emails
+
+2002-09-08 Sunday 23:39  martin
+
+       * mod/forum/lib.php: 
+       
+       Fixed a bug.  When replying to an email copy, you would be
+       forwarded to the login screen to login first.  However, this was
+       being saved as the place to go back to after replying.
+       
+       I added a check for this so now it behaves as you'd expect.
+
+2002-09-08 Sunday 17:47  martin
+
+       * mod/choice/mod.html: 
+       
+       Text window a bit bigger
+
+2002-09-08 Sunday 17:42  martin
+
+       * lang/en/choice.php, mod/choice/lib.php, mod/choice/mod.html,
+       mod/choice/report.php, mod/choice/version.php,
+       mod/choice/view.html, mod/choice/view.php: 
+       
+       Choices now support up to 6 choices.   Backward compatible to
+       2-choice format.
+
+2002-09-08 Sunday 17:41  martin
+
+       * course/: social.php, topics.php, weeks.php: 
+       
+       Tip over 'Edit profile' is the user's name
+
+2002-09-08 Sunday 17:22  martin
+
+       * lang/en/help/choice/options.html: 
+       
+       Help for choices
+
+2002-09-08 Sunday 13:29  martin
+
+       * course/: social.php, topics.php, weeks.php: 
+       
+       Clarified the "participants" link ...
+
+2002-09-08 Sunday 13:23  martin
+
+       * course/view.php: 
+       
+       Link at bottom now goes to site home, not this page
+
+2002-09-08 Sunday 13:15  martin
+
+       * course/teachers.php, lang/en/help/teachers.html: 
+       
+       Added documentation to the teachers page.
+
+2002-09-08 Sunday 13:15  martin
+
+       * lib/moodlelib.php: 
+       
+       Improved print_table() a bit (can now specify column widths)
+
+2002-09-08 Sunday 11:34  martin
+
+       * course/teachers.php: 
+       
+       Need this file to go with the previous changes!
+
+2002-09-08 Sunday 11:34  martin
+
+       * lang/en/moodle.php, user/index.php, user/lib.php: 
+       
+       Changes to improve display of teachers
+
+2002-09-08 Sunday 11:24  martin
+
+       * version.php, course/edit.html, course/edit.php, course/lib.php,
+       course/social.php, course/topics.php, course/weeks.php,
+       lang/en/moodle.php, lib/moodlelib.php, lib/db/mysql.sql,
+       user/index.php: 
+       
+       Changes to allow much better control over what "teachers" are
+       called in a course.  Firstly, the course settings page now allows
+       the teachers to specify the word they want to use in place of
+       "teachers" and "students" as well as "teacher" and "student". 
+       Secondly, a new teacher admin tool allows any teacher to modify the
+       order and displayed role of teachers in that course.  This affects
+       the display on the course listings, the participants page and so
+       on.
+
+2002-09-07 Saturday 22:57  martin
+
+       * admin/lang.php, lang/en/moodle.php, lib/moodlelib.php: 
+       
+       Improvements to the language checker.  As well as checking for
+       missing strings, you can now see the current language compared
+       side-by-side with English.
+
+2002-09-07 Saturday 22:56  martin
+
+       * admin/index.php: 
+       
+       Add a link if a "manage database" directory exists
+
+2002-09-07 Saturday 13:01  martin
+
+       * mod/newmodule_template.zip: 
+       
+       Slight update to README
+
+2002-09-07 Saturday 11:54  martin
+
+       * mod/newmodule_template.zip: 
+       
+       Added a README that explains the process
+
+2002-09-07 Saturday 11:31  martin
+
+       * mod/: README, newmodule_template.zip: 
+       
+       Added a template for new modules that contains the bare
+       necessities.
+
+2002-09-06 Friday 23:17  martin
+
+       * version.php: 
+       
+       Checking in the current release number for CVS users
+
+2002-09-06 Friday 23:10  martin
+
+       * user/view.php: 
+       
+       Don't try and print the last access date if it doesn't exist
+
+2002-09-06 Friday 22:06  martin
+
+       * version.php, admin/index.php, lib/moodlelib.php: 
+       
+       Added a new $release variable that shows the user-friendly version
+       number
+
+2002-09-06 Friday 22:05  martin
+
+       * lib/setup.php: 
+       
+       Cleaned up a bit
+
+2002-09-06 Friday 01:31  martin
+
+       * user/edit.php: 
+       
+       Fixed bug in password checking for new admin user ...
+
+2002-09-05 Thursday 20:29  martin
+
+       * UPGRADING.txt: 
+       
+       Updated the info to mention that the upgrading only works if you
+       are logged in as the *administrator* and visit the site home page.
+
+2002-09-05 Thursday 20:25  martin
+
+       * CHANGES: 
+       
+       CHANGES UP TO 1.0.3.1
+
 2002-09-05 Thursday 20:24  martin
 
        * version.php: 
index 8c5b0d9c6f1f984f58b8d58a5f409d03ac8665ec..ba1d561b4a9957c1e3bc042500691e929e53e0ef 100644 (file)
     }
     $table->data[0][1] = "<P><A HREF=\"../course/edit.php\">".get_string("addnewcourse")."</A></P>".
                          "<P><A HREF=\"../course/teacher.php\">".get_string("assignteachers")."</A></P>".
-                         "<P><A HREF=\"../course/delete.php\">".get_string("deletecourse")."</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][2] = "<P><A HREF=\"user.php?newuser=true\">".get_string("addnewuser")."</A></P>".
                          "<P><A HREF=\"user.php\">".get_string("edituser")."</A></P>";
 
index 057565453d0d11cc418e88a41915a2325c44e166..b0f774798c719440112f83f1989a0caefa734aaf 100644 (file)
 
             if ($form->id) {
                 if (update_record("course", $form)) {
-                           redirect("$CFG->wwwroot/admin/index.php", "Changes saved");
+                           redirect("$CFG->wwwroot/admin/index.php", get_string("changessaved"));
                 } else {
                     error("Serious Error! Could not update the site record! (id = $form->id)");
                 }
             } else {
                 if ($newid = insert_record("course", $form)) {
-                    $cat->name = "General";
+                    $cat->name = get_string("miscellaneous");
                     if (insert_record("course_categories", $cat)) {
-                               redirect("$CFG->wwwroot/admin/index.php", "Changes saved", "1");
+                               redirect("$CFG->wwwroot/admin/index.php", get_string("changessaved"), "1");
                     } else {
-                        error("Serious Error! Could not set up the default categories!");
+                        error("Serious Error! Could not set up a default course category!");
                     }
                 } else {
                     error("Serious Error! Could not set up the site!");
diff --git a/course/categories.php b/course/categories.php
new file mode 100644 (file)
index 0000000..53018d1
--- /dev/null
@@ -0,0 +1,122 @@
+<?PHP // $Id$
+      // Allows the admin to create, delete and rename course categories
+
+       require("../config.php");
+       require("lib.php");
+
+    if (!isadmin()) {
+        error("Only administrators can use this course!");
+    }
+
+    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");
+    $stradd = get_string("add");
+
+       print_header("$site->fullname: $strcategories", "$site->fullname", 
+                 "<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> -> $strcategories");
+
+    print_heading($strcategories);
+
+/// If data submitted, then process and store.
+
+       if (match_referer() && isset($HTTP_POST_VARS)) {
+
+        $categories = array();
+
+        // Peel out all the data from variable names.
+        foreach ($HTTP_POST_VARS as $key => $val) {
+            if ($key == "new" and $val != "") {
+                $cat->name = $val;
+                if (!insert_record("course_categories", $cat)) {
+                    error("Could not insert the new category '$val'");
+                } else {
+                    notify(get_string("categoryadded", "", $val));
+                }
+            
+            } else {
+                $cat->id  = substr($key,1);
+                $cat->name = $val;
+                if (!update_record("course_categories", $cat)) {
+                    error("Could not update the category '$val'");
+                }
+            }
+        }
+       }
+
+
+/// Get the existing categories
+    if (!$categories = get_all_categories()) {
+        // Try and make one
+        $cat->name = get_string("miscellaneous");
+        if ($cat->id = insert_record("course_categories", $cat)) {
+            $categories[$cat->id] = $cat;
+        } else {
+            error("Serious error: Could not create a default category!");
+        }
+    }
+
+/// Delete category if the user wants to delete it
+    if (isset($delete)) {
+        if (delete_records("course_categories", "id", $delete)) {
+            notify(get_string("categorydeleted", "", $categories[$delete]->name));
+            unset($categories[$delete]);
+        } else {
+            error("An error occurred while trying to delete a category");
+        }
+    }
+
+/// Find lowest ID category - this is the default category
+    $default = 99999;
+    foreach ($categories as $category) {
+        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_records_sql("SELECT * FROM course WHERE category > 0")) {
+        foreach ($courses as $course) {
+            if (!isset( $categories[$course->category] )) {
+                set_field("course", "category", $default, "id", $course->id);
+            }
+        }
+    }
+
+
+/// Print the table of all categories
+    $table->head  = array ($strcategory, $strcourses, $strdelete);
+    $table->align = array ("LEFT", "CENTER", "CENTER");
+    $table->size = array ("50", "20", "20");
+    $table->width = 100;
+
+    echo "<FORM ACTION=categories.php METHOD=post>";
+    foreach ($categories as $category) {
+        $count = count_records("course", "category", $category->id);
+        if ($category->id == $default) { 
+            $delete = "";  // Can't delete default category
+        } else {
+            $delete = "<A HREF=\"categories.php?delete=$category->id\">$strdelete</A>";
+        }
+        $table->data[] = array ("<INPUT TYPE=text NAME=\"c$category->id\" VALUE=\"$category->name\" SIZE=30>",
+                                "$count", $delete);
+    }
+    $table->data[] = array ("<INPUT TYPE=text NAME=\"new\" VALUE=\"\" SIZE=30>", "", "$stradd");
+    print_table($table);
+    echo "<CENTER><BR><INPUT TYPE=submit VALUE=\"".get_string("savechanges")."\"> ";
+    echo "</CENTER>";
+    echo "</FORM>";
+
+    print_footer();
+
+?>
index 5b3cdb3bd2cef16ca957f3e3b3a6454d6e60a578..76675a7c3730aaa8331f4bcf2b7836e260531664 100644 (file)
@@ -4,15 +4,41 @@
     require("../config.php");
     require("lib.php");
 
-    $title = get_string("courses");
-
-    print_header($title, $title, $title, "");
-
-    optional_variable($cat, 1);
-
-    echo "<TABLE WIDTH=80% ALIGN=CENTER><TR><TD>";
-
-    print_all_courses($cat);
+    optional_variable($category, 0);
+
+    $strcourses = get_string("courses");
+
+    if (!$categories = get_all_categories()) {
+        error("Could not find any course categories!");
+    }
+
+    if (isset($categories[$category])) {
+        $thiscatname = $categories[$category]->name;
+        $navigation = "<A HREF=\"index.php\">$strcourses</A> -> $thiscatname";
+    } else {
+        $navigation = $strcourses;
+    }
+    print_header($strcourses, $strcourses, $navigation);
+
+    $showcategories = (count($categories) > 1);
+    if ($showcategories) {
+        echo "<TABLE WIDTH=\"100%\" CELLPADDING=10 BORDER=0>";
+        echo "<TR><TD WIDTH=180 VALIGN=TOP>";
+        print_simple_box(get_string("categories"), "CENTER", 180, $THEME->cellheading);
+        print_course_categories($categories, $category, 180);
+        echo "</TD><TD WIDTH=\"100%\" VALIGN=TOP>";
+    } else {
+        echo "<TABLE WIDTH=80% ALIGN=CENTER><TR><TD VALIGN=top>";
+        $category="all";
+    }
+
+    if ($category) {
+        if ($category != "all") {
+            print_simple_box($categories[$category]->name, "CENTER", "100%", $THEME->cellheading);
+            echo "<BR>";
+        }
+        print_all_courses($category);
+    }
 
     echo "</TD></TR></TABLE>";
 
index 148e01c7a93a05217a75b3af71be06dbc74ccc55..9b31878cf265963360d7b23f2be1c233343d3f11 100644 (file)
@@ -172,10 +172,16 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
 }
 
 
-function print_all_courses($cat=1, $style="full", $maxcount=999) {
+function print_all_courses($category="all", $style="full", $maxcount=999) {
     global $CFG;
 
-    if ($courses = get_records("course", "category", $cat, "fullname ASC")) {
+    if ($category == "all") {
+        $courses = get_records_sql("SELECT * FROM course WHERE category > 0 ORDER BY fullname ASC");
+    } else {
+        $courses = get_records("course", "category", $category, "fullname ASC");
+    }
+
+    if ($courses) {
         if ($style == "minimal") {
             $count = 0;
             $icon  = "<IMG SRC=\"pix/i/course.gif\" HEIGHT=16 WIDTH=16 ALT=\"".get_string("course")."\">";
@@ -459,6 +465,10 @@ function get_all_sections($courseid) {
                             ORDER BY section");
 }
 
+function get_all_categories() {
+    return get_records_sql("SELECT * FROM course_categories ORDER by name");
+}
+
 function print_section($courseid, $section, $mods, $modnamesused, $absolute=false, $width="100%") {
     global $CFG;
 
@@ -521,6 +531,8 @@ function print_admin_links ($siteid, $width=180) {
     $modicon[]=$icon;
     $moddata[]="<A HREF=\"$CFG->wwwroot/course/edit.php\">".get_string("addnewcourse")."</A>";
     $modicon[]=$icon;
+    $moddata[]="<A HREF=\"$CFG->wwwroot/course/categories.php\">".get_string("categories")."</A>";
+    $modicon[]=$icon;
     $moddata[]="<A HREF=\"$CFG->wwwroot/course/teacher.php\">".get_string("assignteachers")."</A>";
     $modicon[]=$icon;
     $moddata[]="<A HREF=\"$CFG->wwwroot/course/delete.php\">".get_string("deletecourse")."</A>";
@@ -570,6 +582,20 @@ function print_course_admin_links($course, $width=180) {
     print_side_block("", $admindata, "", $adminicon, $width);
 }
 
+function print_course_categories($categories, $selected="none", $width=180) {
+    global $CFG, $THEME;
+
+    foreach ($categories as $cat) {
+        $caticon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/course.gif\" HEIGHT=16 WIDTH=16>";
+        if ($cat->id == $selected) {
+            $catdata[]="$cat->name";
+        } else {
+            $catdata[]="<A HREF=\"$CFG->wwwroot/course/index.php?category=$cat->id\">$cat->name</A>";
+        }
+    }
+    $showall = "<P><A HREF=\"$CFG->wwwroot/course/index.php?category=all\">".get_string("fulllistofcourses")."</A>...";
+    print_side_block("", $catdata, $showall, $caticon, $width);
+}
 
 function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
     global $CFG;
index 9b9b54e5dc54734f9e06328c3ebbe62f80e32ba1..0303e12b991b2df1b5d618222b83133f153b9ca5 100644 (file)
--- a/index.php
+++ b/index.php
          }
 
          if ($site->newsitems > 0 ) {
-             print_simple_box(get_string("courses"), "CENTER", $side, "$THEME->cellheading");
-             print_all_courses($cat=1, "minimal", 10);
+             $categories = get_all_categories();
+             if (count($categories) > 1) {
+                 print_simple_box(get_string("categories"), "CENTER", $side, "$THEME->cellheading");
+                 print_course_categories($categories, "none", $side);
+             } else {
+                 print_simple_box(get_string("courses"), "CENTER", $side, "$THEME->cellheading");
+                 $category = array_shift($categories);
+                 print_all_courses($category->id, "minimal", 10);
+             }
          } 
          print_spacer(1,$side);
      }
@@ -78,7 +85,7 @@
      if ($site->newsitems == 0 ) {
          print_simple_box(get_string("availablecourses"), "CENTER", "100%", "$THEME->cellheading");
          print_spacer(8,1);
-         print_all_courses();
+         print_all_courses("all");
 
      } else {
          if (! $newsforum = forum_get_course_forum($site->id, "news")) {
index ae9defebc6c056a8c3810ce3d3a1887cc7a971d4..3f8e07a7a4e4858b2e2acd197fbc4691025b0d99 100644 (file)
@@ -28,7 +28,10 @@ $string[answer] = "Answer";
 $string[assignteachers] = "Assign teachers";
 $string[availablecourses] = "Available Courses";
 $string[cancel] = "Cancel";
+$string[categories] = "Course categories";
 $string[category] = "Category";
+$string[categoryadded] = "The category '\$a' was added";
+$string[categorydeleted] = "The category '\$a' was deleted";
 $string[changepassword] = "Change password";
 $string[changedpassword] = "Changed password";
 $string[changessaved] = "Changes saved";
@@ -140,7 +143,7 @@ $string[formattopics] = "Topics format";
 $string[formatweeks] = "Weekly format";
 $string[frontpagedescription] = "Front page description";
 $string[frontpageformat] = "Front page format";
-$string[fulllistofcourses] = "Full list of courses";
+$string[fulllistofcourses] = "Show all courses";
 $string[fullprofile] = "Full profile";
 $string[fullname] = "Full name";
 $string[fullsitename] = "Full site name";
@@ -220,6 +223,7 @@ $string[markthistopic] = "Mark this topic as the current topic";
 $string[maximumchars] = "Maximum of \$a characters";
 $string[maximumgrade] = "Maximum grade";
 $string[maxsize] = "Max size: \$a";
+$string[miscellaneous] = "Miscellaneous";  // Default course category
 $string[missingcategory] = "You need to choose a category";
 $string[missingcity] = "Missing city/town";
 $string[missingcountry] = "Missing country";
@@ -350,6 +354,7 @@ $string[showonlytopic] = "Show only topic \$a";
 $string[showonlyweek] = "Show only week \$a";
 $string[showtheselogs] = "Show these logs";
 $string[socialheadline] = "Social forum - latest topics";
+$string[showallcourses] = "Show all courses";
 $string[site] = "Site";
 $string[sites] = "Sites";
 $string[sitelogs] = "Site logs";
index ecde90fb6712cd64d999079833afeb87d8698d2a..809b48dbdbf73ca4062be729fb622561247daf26 100644 (file)
 // If there's something it cannot do itself, it 
 // will tell you what you need to do.
 
-$version = 2002090800;   // The current version is a date (YYYYMMDDXX) where 
+$version = 2002090900;   // The current version is a date (YYYYMMDDXX) where 
                          //    XX is a number that increments during the day
 
-$release = "1.0.4 beta";      // For humans only, not used for the upgrade process
+$release = "1.0.4";      // For humans only, not used for the upgrade process
 
 function upgrade_moodle($oldversion=0) {