Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Categories upgrade. Admin can now create/edit/delete categories, and

these are diesplayed wherever courses are listed
  • Loading branch information...
commit ba2e5d7347c1150576c1fd91f3f5cfee2b088c8f 1 parent 7aa0bb8
martin authored
180 CHANGES
... ... @@ -1,3 +1,183 @@
  1 +2002-09-09 Monday 00:13 martin
  2 +
  3 + * lib/weblib.php:
  4 +
  5 + Added height and width to smiley icons, to make emails look better
  6 + in circumstances where external images are blocked (eg some webmail
  7 + programs like squirrelmail).
  8 +
  9 +2002-09-09 Monday 00:04 martin
  10 +
  11 + * mod/forum/lib.php:
  12 +
  13 + Added an "unsubscribe" link to emails
  14 +
  15 +2002-09-08 Sunday 23:39 martin
  16 +
  17 + * mod/forum/lib.php:
  18 +
  19 + Fixed a bug. When replying to an email copy, you would be
  20 + forwarded to the login screen to login first. However, this was
  21 + being saved as the place to go back to after replying.
  22 +
  23 + I added a check for this so now it behaves as you'd expect.
  24 +
  25 +2002-09-08 Sunday 17:47 martin
  26 +
  27 + * mod/choice/mod.html:
  28 +
  29 + Text window a bit bigger
  30 +
  31 +2002-09-08 Sunday 17:42 martin
  32 +
  33 + * lang/en/choice.php, mod/choice/lib.php, mod/choice/mod.html,
  34 + mod/choice/report.php, mod/choice/version.php,
  35 + mod/choice/view.html, mod/choice/view.php:
  36 +
  37 + Choices now support up to 6 choices. Backward compatible to
  38 + 2-choice format.
  39 +
  40 +2002-09-08 Sunday 17:41 martin
  41 +
  42 + * course/: social.php, topics.php, weeks.php:
  43 +
  44 + Tip over 'Edit profile' is the user's name
  45 +
  46 +2002-09-08 Sunday 17:22 martin
  47 +
  48 + * lang/en/help/choice/options.html:
  49 +
  50 + Help for choices
  51 +
  52 +2002-09-08 Sunday 13:29 martin
  53 +
  54 + * course/: social.php, topics.php, weeks.php:
  55 +
  56 + Clarified the "participants" link ...
  57 +
  58 +2002-09-08 Sunday 13:23 martin
  59 +
  60 + * course/view.php:
  61 +
  62 + Link at bottom now goes to site home, not this page
  63 +
  64 +2002-09-08 Sunday 13:15 martin
  65 +
  66 + * course/teachers.php, lang/en/help/teachers.html:
  67 +
  68 + Added documentation to the teachers page.
  69 +
  70 +2002-09-08 Sunday 13:15 martin
  71 +
  72 + * lib/moodlelib.php:
  73 +
  74 + Improved print_table() a bit (can now specify column widths)
  75 +
  76 +2002-09-08 Sunday 11:34 martin
  77 +
  78 + * course/teachers.php:
  79 +
  80 + Need this file to go with the previous changes!
  81 +
  82 +2002-09-08 Sunday 11:34 martin
  83 +
  84 + * lang/en/moodle.php, user/index.php, user/lib.php:
  85 +
  86 + Changes to improve display of teachers
  87 +
  88 +2002-09-08 Sunday 11:24 martin
  89 +
  90 + * version.php, course/edit.html, course/edit.php, course/lib.php,
  91 + course/social.php, course/topics.php, course/weeks.php,
  92 + lang/en/moodle.php, lib/moodlelib.php, lib/db/mysql.sql,
  93 + user/index.php:
  94 +
  95 + Changes to allow much better control over what "teachers" are
  96 + called in a course. Firstly, the course settings page now allows
  97 + the teachers to specify the word they want to use in place of
  98 + "teachers" and "students" as well as "teacher" and "student".
  99 + Secondly, a new teacher admin tool allows any teacher to modify the
  100 + order and displayed role of teachers in that course. This affects
  101 + the display on the course listings, the participants page and so
  102 + on.
  103 +
  104 +2002-09-07 Saturday 22:57 martin
  105 +
  106 + * admin/lang.php, lang/en/moodle.php, lib/moodlelib.php:
  107 +
  108 + Improvements to the language checker. As well as checking for
  109 + missing strings, you can now see the current language compared
  110 + side-by-side with English.
  111 +
  112 +2002-09-07 Saturday 22:56 martin
  113 +
  114 + * admin/index.php:
  115 +
  116 + Add a link if a "manage database" directory exists
  117 +
  118 +2002-09-07 Saturday 13:01 martin
  119 +
  120 + * mod/newmodule_template.zip:
  121 +
  122 + Slight update to README
  123 +
  124 +2002-09-07 Saturday 11:54 martin
  125 +
  126 + * mod/newmodule_template.zip:
  127 +
  128 + Added a README that explains the process
  129 +
  130 +2002-09-07 Saturday 11:31 martin
  131 +
  132 + * mod/: README, newmodule_template.zip:
  133 +
  134 + Added a template for new modules that contains the bare
  135 + necessities.
  136 +
  137 +2002-09-06 Friday 23:17 martin
  138 +
  139 + * version.php:
  140 +
  141 + Checking in the current release number for CVS users
  142 +
  143 +2002-09-06 Friday 23:10 martin
  144 +
  145 + * user/view.php:
  146 +
  147 + Don't try and print the last access date if it doesn't exist
  148 +
  149 +2002-09-06 Friday 22:06 martin
  150 +
  151 + * version.php, admin/index.php, lib/moodlelib.php:
  152 +
  153 + Added a new $release variable that shows the user-friendly version
  154 + number
  155 +
  156 +2002-09-06 Friday 22:05 martin
  157 +
  158 + * lib/setup.php:
  159 +
  160 + Cleaned up a bit
  161 +
  162 +2002-09-06 Friday 01:31 martin
  163 +
  164 + * user/edit.php:
  165 +
  166 + Fixed bug in password checking for new admin user ...
  167 +
  168 +2002-09-05 Thursday 20:29 martin
  169 +
  170 + * UPGRADING.txt:
  171 +
  172 + Updated the info to mention that the upgrading only works if you
  173 + are logged in as the *administrator* and visit the site home page.
  174 +
  175 +2002-09-05 Thursday 20:25 martin
  176 +
  177 + * CHANGES:
  178 +
  179 + CHANGES UP TO 1.0.3.1
  180 +
1 181 2002-09-05 Thursday 20:24 martin
2 182
3 183 * version.php:
3  admin/index.php
@@ -207,7 +207,8 @@
207 207 }
208 208 $table->data[0][1] = "<P><A HREF=\"../course/edit.php\">".get_string("addnewcourse")."</A></P>".
209 209 "<P><A HREF=\"../course/teacher.php\">".get_string("assignteachers")."</A></P>".
210   - "<P><A HREF=\"../course/delete.php\">".get_string("deletecourse")."</A></P>";
  210 + "<P><A HREF=\"../course/delete.php\">".get_string("deletecourse")."</A></P>".
  211 + "<P><A HREF=\"../course/categories.php\">".get_string("categories")."</A></P>";
211 212 $table->data[0][2] = "<P><A HREF=\"user.php?newuser=true\">".get_string("addnewuser")."</A></P>".
212 213 "<P><A HREF=\"user.php\">".get_string("edituser")."</A></P>";
213 214
8 admin/site.php
@@ -23,17 +23,17 @@
23 23
24 24 if ($form->id) {
25 25 if (update_record("course", $form)) {
26   - redirect("$CFG->wwwroot/admin/index.php", "Changes saved");
  26 + redirect("$CFG->wwwroot/admin/index.php", get_string("changessaved"));
27 27 } else {
28 28 error("Serious Error! Could not update the site record! (id = $form->id)");
29 29 }
30 30 } else {
31 31 if ($newid = insert_record("course", $form)) {
32   - $cat->name = "General";
  32 + $cat->name = get_string("miscellaneous");
33 33 if (insert_record("course_categories", $cat)) {
34   - redirect("$CFG->wwwroot/admin/index.php", "Changes saved", "1");
  34 + redirect("$CFG->wwwroot/admin/index.php", get_string("changessaved"), "1");
35 35 } else {
36   - error("Serious Error! Could not set up the default categories!");
  36 + error("Serious Error! Could not set up a default course category!");
37 37 }
38 38 } else {
39 39 error("Serious Error! Could not set up the site!");
122 course/categories.php
... ... @@ -0,0 +1,122 @@
  1 +<?PHP // $Id$
  2 + // Allows the admin to create, delete and rename course categories
  3 +
  4 + require("../config.php");
  5 + require("lib.php");
  6 +
  7 + if (!isadmin()) {
  8 + error("Only administrators can use this course!");
  9 + }
  10 +
  11 + if (!$site = get_site()) {
  12 + error("Site isn't defined!");
  13 + }
  14 +
  15 +
  16 +/// Print headings
  17 +
  18 + $stradministration = get_string("administration");
  19 + $strcategories = get_string("categories");
  20 + $strcategory = get_string("category");
  21 + $strcourses = get_string("courses");
  22 + $stredit = get_string("edit");
  23 + $strdelete = get_string("delete");
  24 + $stradd = get_string("add");
  25 +
  26 + print_header("$site->fullname: $strcategories", "$site->fullname",
  27 + "<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> -> $strcategories");
  28 +
  29 + print_heading($strcategories);
  30 +
  31 +/// If data submitted, then process and store.
  32 +
  33 + if (match_referer() && isset($HTTP_POST_VARS)) {
  34 +
  35 + $categories = array();
  36 +
  37 + // Peel out all the data from variable names.
  38 + foreach ($HTTP_POST_VARS as $key => $val) {
  39 + if ($key == "new" and $val != "") {
  40 + $cat->name = $val;
  41 + if (!insert_record("course_categories", $cat)) {
  42 + error("Could not insert the new category '$val'");
  43 + } else {
  44 + notify(get_string("categoryadded", "", $val));
  45 + }
  46 +
  47 + } else {
  48 + $cat->id = substr($key,1);
  49 + $cat->name = $val;
  50 + if (!update_record("course_categories", $cat)) {
  51 + error("Could not update the category '$val'");
  52 + }
  53 + }
  54 + }
  55 + }
  56 +
  57 +
  58 +/// Get the existing categories
  59 + if (!$categories = get_all_categories()) {
  60 + // Try and make one
  61 + $cat->name = get_string("miscellaneous");
  62 + if ($cat->id = insert_record("course_categories", $cat)) {
  63 + $categories[$cat->id] = $cat;
  64 + } else {
  65 + error("Serious error: Could not create a default category!");
  66 + }
  67 + }
  68 +
  69 +/// Delete category if the user wants to delete it
  70 + if (isset($delete)) {
  71 + if (delete_records("course_categories", "id", $delete)) {
  72 + notify(get_string("categorydeleted", "", $categories[$delete]->name));
  73 + unset($categories[$delete]);
  74 + } else {
  75 + error("An error occurred while trying to delete a category");
  76 + }
  77 + }
  78 +
  79 +/// Find lowest ID category - this is the default category
  80 + $default = 99999;
  81 + foreach ($categories as $category) {
  82 + if ($category->id < $default) {
  83 + $default = $category->id;
  84 + }
  85 + }
  86 +
  87 +/// Find any orphan courses that don't yet have a valid category and set to default
  88 + if ($courses = get_records_sql("SELECT * FROM course WHERE category > 0")) {
  89 + foreach ($courses as $course) {
  90 + if (!isset( $categories[$course->category] )) {
  91 + set_field("course", "category", $default, "id", $course->id);
  92 + }
  93 + }
  94 + }
  95 +
  96 +
  97 +/// Print the table of all categories
  98 + $table->head = array ($strcategory, $strcourses, $strdelete);
  99 + $table->align = array ("LEFT", "CENTER", "CENTER");
  100 + $table->size = array ("50", "20", "20");
  101 + $table->width = 100;
  102 +
  103 + echo "<FORM ACTION=categories.php METHOD=post>";
  104 + foreach ($categories as $category) {
  105 + $count = count_records("course", "category", $category->id);
  106 + if ($category->id == $default) {
  107 + $delete = ""; // Can't delete default category
  108 + } else {
  109 + $delete = "<A HREF=\"categories.php?delete=$category->id\">$strdelete</A>";
  110 + }
  111 + $table->data[] = array ("<INPUT TYPE=text NAME=\"c$category->id\" VALUE=\"$category->name\" SIZE=30>",
  112 + "$count", $delete);
  113 + }
  114 + $table->data[] = array ("<INPUT TYPE=text NAME=\"new\" VALUE=\"\" SIZE=30>", "", "$stradd");
  115 + print_table($table);
  116 + echo "<CENTER><BR><INPUT TYPE=submit VALUE=\"".get_string("savechanges")."\"> ";
  117 + echo "</CENTER>";
  118 + echo "</FORM>";
  119 +
  120 + print_footer();
  121 +
  122 +?>
44 course/index.php
@@ -4,15 +4,41 @@
4 4 require("../config.php");
5 5 require("lib.php");
6 6
7   - $title = get_string("courses");
8   -
9   - print_header($title, $title, $title, "");
10   -
11   - optional_variable($cat, 1);
12   -
13   - echo "<TABLE WIDTH=80% ALIGN=CENTER><TR><TD>";
14   -
15   - print_all_courses($cat);
  7 + optional_variable($category, 0);
  8 +
  9 + $strcourses = get_string("courses");
  10 +
  11 + if (!$categories = get_all_categories()) {
  12 + error("Could not find any course categories!");
  13 + }
  14 +
  15 + if (isset($categories[$category])) {
  16 + $thiscatname = $categories[$category]->name;
  17 + $navigation = "<A HREF=\"index.php\">$strcourses</A> -> $thiscatname";
  18 + } else {
  19 + $navigation = $strcourses;
  20 + }
  21 + print_header($strcourses, $strcourses, $navigation);
  22 +
  23 + $showcategories = (count($categories) > 1);
  24 + if ($showcategories) {
  25 + echo "<TABLE WIDTH=\"100%\" CELLPADDING=10 BORDER=0>";
  26 + echo "<TR><TD WIDTH=180 VALIGN=TOP>";
  27 + print_simple_box(get_string("categories"), "CENTER", 180, $THEME->cellheading);
  28 + print_course_categories($categories, $category, 180);
  29 + echo "</TD><TD WIDTH=\"100%\" VALIGN=TOP>";
  30 + } else {
  31 + echo "<TABLE WIDTH=80% ALIGN=CENTER><TR><TD VALIGN=top>";
  32 + $category="all";
  33 + }
  34 +
  35 + if ($category) {
  36 + if ($category != "all") {
  37 + print_simple_box($categories[$category]->name, "CENTER", "100%", $THEME->cellheading);
  38 + echo "<BR>";
  39 + }
  40 + print_all_courses($category);
  41 + }
16 42
17 43 echo "</TD></TR></TABLE>";
18 44
30 course/lib.php
@@ -172,10 +172,16 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
172 172 }
173 173
174 174
175   -function print_all_courses($cat=1, $style="full", $maxcount=999) {
  175 +function print_all_courses($category="all", $style="full", $maxcount=999) {
176 176 global $CFG;
177 177
178   - if ($courses = get_records("course", "category", $cat, "fullname ASC")) {
  178 + if ($category == "all") {
  179 + $courses = get_records_sql("SELECT * FROM course WHERE category > 0 ORDER BY fullname ASC");
  180 + } else {
  181 + $courses = get_records("course", "category", $category, "fullname ASC");
  182 + }
  183 +
  184 + if ($courses) {
179 185 if ($style == "minimal") {
180 186 $count = 0;
181 187 $icon = "<IMG SRC=\"pix/i/course.gif\" HEIGHT=16 WIDTH=16 ALT=\"".get_string("course")."\">";
@@ -459,6 +465,10 @@ function get_all_sections($courseid) {
459 465 ORDER BY section");
460 466 }
461 467
  468 +function get_all_categories() {
  469 + return get_records_sql("SELECT * FROM course_categories ORDER by name");
  470 +}
  471 +
462 472 function print_section($courseid, $section, $mods, $modnamesused, $absolute=false, $width="100%") {
463 473 global $CFG;
464 474
@@ -521,6 +531,8 @@ function print_admin_links ($siteid, $width=180) {
521 531 $modicon[]=$icon;
522 532 $moddata[]="<A HREF=\"$CFG->wwwroot/course/edit.php\">".get_string("addnewcourse")."</A>";
523 533 $modicon[]=$icon;
  534 + $moddata[]="<A HREF=\"$CFG->wwwroot/course/categories.php\">".get_string("categories")."</A>";
  535 + $modicon[]=$icon;
524 536 $moddata[]="<A HREF=\"$CFG->wwwroot/course/teacher.php\">".get_string("assignteachers")."</A>";
525 537 $modicon[]=$icon;
526 538 $moddata[]="<A HREF=\"$CFG->wwwroot/course/delete.php\">".get_string("deletecourse")."</A>";
@@ -570,6 +582,20 @@ function print_course_admin_links($course, $width=180) {
570 582 print_side_block("", $admindata, "", $adminicon, $width);
571 583 }
572 584
  585 +function print_course_categories($categories, $selected="none", $width=180) {
  586 + global $CFG, $THEME;
  587 +
  588 + foreach ($categories as $cat) {
  589 + $caticon[]="<IMG SRC=\"$CFG->wwwroot/pix/i/course.gif\" HEIGHT=16 WIDTH=16>";
  590 + if ($cat->id == $selected) {
  591 + $catdata[]="$cat->name";
  592 + } else {
  593 + $catdata[]="<A HREF=\"$CFG->wwwroot/course/index.php?category=$cat->id\">$cat->name</A>";
  594 + }
  595 + }
  596 + $showall = "<P><A HREF=\"$CFG->wwwroot/course/index.php?category=all\">".get_string("fulllistofcourses")."</A>...";
  597 + print_side_block("", $catdata, $showall, $caticon, $width);
  598 +}
573 599
574 600 function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
575 601 global $CFG;
13 index.php
@@ -57,8 +57,15 @@
57 57 }
58 58
59 59 if ($site->newsitems > 0 ) {
60   - print_simple_box(get_string("courses"), "CENTER", $side, "$THEME->cellheading");
61   - print_all_courses($cat=1, "minimal", 10);
  60 + $categories = get_all_categories();
  61 + if (count($categories) > 1) {
  62 + print_simple_box(get_string("categories"), "CENTER", $side, "$THEME->cellheading");
  63 + print_course_categories($categories, "none", $side);
  64 + } else {
  65 + print_simple_box(get_string("courses"), "CENTER", $side, "$THEME->cellheading");
  66 + $category = array_shift($categories);
  67 + print_all_courses($category->id, "minimal", 10);
  68 + }
62 69 }
63 70 print_spacer(1,$side);
64 71 }
@@ -78,7 +85,7 @@
78 85 if ($site->newsitems == 0 ) {
79 86 print_simple_box(get_string("availablecourses"), "CENTER", "100%", "$THEME->cellheading");
80 87 print_spacer(8,1);
81   - print_all_courses();
  88 + print_all_courses("all");
82 89
83 90 } else {
84 91 if (! $newsforum = forum_get_course_forum($site->id, "news")) {
7 lang/en/moodle.php
@@ -28,7 +28,10 @@
28 28 $string[assignteachers] = "Assign teachers";
29 29 $string[availablecourses] = "Available Courses";
30 30 $string[cancel] = "Cancel";
  31 +$string[categories] = "Course categories";
31 32 $string[category] = "Category";
  33 +$string[categoryadded] = "The category '\$a' was added";
  34 +$string[categorydeleted] = "The category '\$a' was deleted";
32 35 $string[changepassword] = "Change password";
33 36 $string[changedpassword] = "Changed password";
34 37 $string[changessaved] = "Changes saved";
@@ -140,7 +143,7 @@
140 143 $string[formatweeks] = "Weekly format";
141 144 $string[frontpagedescription] = "Front page description";
142 145 $string[frontpageformat] = "Front page format";
143   -$string[fulllistofcourses] = "Full list of courses";
  146 +$string[fulllistofcourses] = "Show all courses";
144 147 $string[fullprofile] = "Full profile";
145 148 $string[fullname] = "Full name";
146 149 $string[fullsitename] = "Full site name";
@@ -220,6 +223,7 @@
220 223 $string[maximumchars] = "Maximum of \$a characters";
221 224 $string[maximumgrade] = "Maximum grade";
222 225 $string[maxsize] = "Max size: \$a";
  226 +$string[miscellaneous] = "Miscellaneous"; // Default course category
223 227 $string[missingcategory] = "You need to choose a category";
224 228 $string[missingcity] = "Missing city/town";
225 229 $string[missingcountry] = "Missing country";
@@ -350,6 +354,7 @@
350 354 $string[showonlyweek] = "Show only week \$a";
351 355 $string[showtheselogs] = "Show these logs";
352 356 $string[socialheadline] = "Social forum - latest topics";
  357 +$string[showallcourses] = "Show all courses";
353 358 $string[site] = "Site";
354 359 $string[sites] = "Sites";
355 360 $string[sitelogs] = "Site logs";
4 version.php
@@ -18,10 +18,10 @@
18 18 // If there's something it cannot do itself, it
19 19 // will tell you what you need to do.
20 20
21   -$version = 2002090800; // The current version is a date (YYYYMMDDXX) where
  21 +$version = 2002090900; // The current version is a date (YYYYMMDDXX) where
22 22 // XX is a number that increments during the day
23 23
24   -$release = "1.0.4 beta"; // For humans only, not used for the upgrade process
  24 +$release = "1.0.4"; // For humans only, not used for the upgrade process
25 25
26 26 function upgrade_moodle($oldversion=0) {
27 27

0 comments on commit ba2e5d7

Please sign in to comment.
Something went wrong with that request. Please try again.