Permalink
Browse files

OK, some massive changes with many files removed or changed.

Basically the changes are:

 - I've merged the 'discuss' module into the forum module
   which makes the interface MUCH clearer for everyone
 - I've added a new 'single' forum type that replicates
   what the old discuss course modules used to look like.
 - I've got rid of the "discussion" forum type - it will
   still exist in upgraded courses but as a normal forum.
 - the 'discuss' module is completely deleted - gone.
 - the 'chat' module is completely deleted - gone.
 - The upgrading system has been improved, and all code
   is stored in version.php.
 - I've put in upgrading commands to do the best I can
   (right now) to upgrade courses that used the discuss
   module.  It should mostly work, just leaving some
   "orphan" coursemodules on you course front page.  You
   can easily delete these using the little 'x'.
   I may have forgotten something  - I've only tested on
   my testing server and I'm about to test on my production
   server to see how it goes.
 - Forums have a lot of little new features and fixes.  The
   main one is the subscription process.  Teachers can 'force'
   subscriptions on any forum.  This disallows everyone from
   choosing their own mail subscription - it's just on.
 - The assignment module is half-finished and not working yet

I've still some massive changes to do, mostly involving making
all the lib.php function names more standardised, so consider
this is an interim checkin to do some tests.
  • Loading branch information...
1 parent 0a786ca commit 501cdbd8bb8ef9583b7d19892ef5adc87d7ff536 martin committed Jul 31, 2002
View
@@ -12,9 +12,12 @@
print_header("Setting up database", "Setting up database", "Setting up databases for the first time", "");
if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
+ $db->debug = true;
if (modify_database("$CFG->libdir/db/$CFG->dbtype.sql")) {
+ $db->debug = false;
notify("Main databases set up successfully");
} else {
+ $db->debug = false;
error("Error: Main databases NOT set up successfully");
}
} else {
@@ -32,7 +35,9 @@
if ($dversion = get_field("config", "value", "name", "version")) {
if ($version > $dversion) { // upgrade
notify("Upgrading databases from version $dversion to $version...");
+ $db->debug=true;
if (upgrade_moodle($dversion)) {
+ $db->debug=false;
if (set_field("config", "value", "$version", "name", "version")) {
notify("Databases were successfully upgraded");
print_heading("<A HREF=\"index.php\">Continue</A>");
@@ -41,6 +46,7 @@
notify("Upgrade failed! (Could not update version in config table)");
}
} else {
+ $db->debug=false;
notify("Upgrade failed! See /version.php");
}
} else if ($version < $dversion) {
@@ -55,14 +61,17 @@
print_heading("<A HREF=\"index.php\">Continue</A>");
die;
} else {
+ $db->debug=true;
if (upgrade_moodle(0)) {
print_heading("<A HREF=\"index.php\">Continue</A>");
} else {
error("A problem occurred inserting current version into databases");
}
+ $db->debug=false;
}
}
+
// Find and check all modules and load them up.
$dir = opendir("$CFG->dirroot/mod");
while ($mod = readdir($dir)) {
@@ -77,7 +86,7 @@
unset($module);
- include_once("$CFG->dirroot/mod/$mod/module.php"); # defines $module
+ include_once("$CFG->dirroot/mod/$mod/version.php"); # defines $module with version etc
if (!isset($module)) {
continue;
@@ -92,14 +101,17 @@
notify("$module->name module needs upgrading");
$upgrade_function = $module->name."_upgrade";
if (function_exists($upgrade_function)) {
+ $db->debug=true;
if ($upgrade_function($currmodule->version, $module)) {
+ $db->debug=false;
// OK so far, now update the modules record
$module->id = $currmodule->id;
if (! update_record("modules", $module)) {
error("Could not update $module->name record in modules table!");
}
notify("$module->name module was successfully upgraded");
} else {
+ $db->debug=false;
notify("Upgrading $module->name from $currmodule->version to $module->version FAILED!");
}
}
View
@@ -276,10 +276,6 @@ function print_recent_activity($course) {
$info = split(" ", $log->info);
$modname = get_field($info[0], "name", "id", $info[1]);
- if ($info[0] == "discuss") {
- $info[0] = "discussion"; // nasty hack, really.
- }
-
switch ($log->action) {
case "add mod":
$changelist["$log->info"] = array ("operation" => "add", "text" => "Added a ".$info[0].":<BR><A HREF=\"$CFG->wwwroot/course/$log->url\">$modname</A>");
@@ -322,19 +318,19 @@ function print_recent_activity($course) {
$heading = false;
foreach ($logs as $log) {
- if ($log->module == "discuss") {
+ if ($log->module == "forum") {
$post = NULL;
- if ($log->action == "add post") {
+ if ($log->action == "add post" or $log->action == "add discussion") {
$post = get_record_sql("SELECT p.*, d.forum, u.firstname, u.lastname,
u.email, u.picture, u.id as userid
- FROM discuss d, discuss_posts p, user u
- WHERE p.id = '$log->info' AND d.id = p.discuss AND p.user = u.id");
+ FROM forum_discussions d, forum_posts p, user u
+ WHERE p.id = '$log->info' AND d.id = p.discussion AND p.user = u.id");
} else if ($log->action == "add") {
$post = get_record_sql("SELECT p.*, d.forum, u.firstname, u.lastname,
u.email, u.picture, u.id as userid
- FROM discuss d, discuss_posts p, user u
+ FROM forum_discussions d, forum_posts p, user u
WHERE d.id = '$log->info' AND d.firstpost = p.id AND p.user = u.id");
}
@@ -356,7 +352,7 @@ function print_recent_activity($course) {
$content = true;
}
echo "<P><FONT SIZE=1 $teacherpost>$post->firstname $post->lastname:<BR>";
- echo "\"<A HREF=\"$CFG->wwwroot/mod/discuss/$log->url\">";
+ echo "\"<A HREF=\"$CFG->wwwroot/mod/forum/$log->url\">";
if ($log->action == "add") {
echo "<B>$post->subject</B>";
} else {
View
@@ -97,19 +97,28 @@
error("This course doesn't exist");
}
+ require_login($course->id);
+
+ if (!isteacher($course->id)) {
+ error("You can't modify this course!");
+ }
+
if (! $module = get_record("modules", "id", $cm->module)) {
error("This module doesn't exist");
}
if (! $instance = get_record($module->name, "id", $cm->instance)) {
- error("The required instance of this module doesn't exist");
+ // Delete this module from the course right away
+ if (! delete_course_module($cm->id)) {
+ notify("Could not delete the $module->name (coursemodule)");
+ }
+ if (! delete_mod_from_section($cm->id, $cm->section)) {
+ notify("Could not delete the $module->name from that section");
+ }
+ error("The required instance of this module didn't exist. Module deleted.",
+ "$CFG->wwwroot/course/view.php?id=$course->id");
}
- require_login($course->id);
-
- if (!isteacher($course->id)) {
- error("You can't modify this course!");
- }
$form->coursemodule = $cm->id;
$form->section = $cm->section;
View
@@ -46,10 +46,10 @@
echo "</TD></TR></TABLE>";
echo "<BR>";
- // Print a form to search discussions
+ // Print a form to search forums
print_simple_box("Search Discussions", $align="CENTER", $width="100%", $color="$THEME->cellheading");
echo "<DIV ALIGN=CENTER>";
- print_discussion_search_form($course);
+ print_forum_search_form($course);
echo "</DIV>";
// Print Admin links for teachers and admin.
@@ -81,7 +81,7 @@
error("Could not find or create a social forum here");
}
- $SESSION->fromdiscuss = "$CFG->wwwdir/course/view.php?id=$course->id";
+ $SESSION->fromdiscussion = "$CFG->wwwdir/course/view.php?id=$course->id";
if (is_subscribed($USER->id, $social->id)) {
$subtext = "Unsubscribe";
} else {
View
@@ -70,10 +70,10 @@
print_simple_box("Activities", $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_side_block("", $moddata, "", $modicon);
- // Print a form to search discussions
+ // Print a form to search forums
print_simple_box("Search Discussions", $align="CENTER", $width="100%", $color="$THEME->cellheading");
echo "<DIV ALIGN=CENTER>";
- print_discussion_search_form($course);
+ print_forum_search_form($course);
echo "</DIV>";
// Admin links and controls
View
@@ -54,10 +54,6 @@
get_all_mods($course->id, $mods, $modtype);
- if (isset($modtype["forum"]) and isset($modtype["discuss"])) { // Only need to display one
- unset($modtype["discuss"]);
- }
-
switch ($course->format) {
case "weeks":
include("weeks.php");
View
@@ -52,10 +52,10 @@
print_simple_box("Activities", $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_side_block("", $moddata, "", $modicon);
- // Print a form to search discussions
+ // Print a form to search forums
print_simple_box("Search Discussions", $align="CENTER", $width="100%", $color="$THEME->cellheading");
echo "<DIV ALIGN=CENTER>";
- print_discussion_search_form($course);
+ print_forum_search_form($course);
echo "</DIV>";
// Admin links and controls
View
@@ -28,7 +28,7 @@
4.0.6 or better), including the <A HREF="http://www.boutell.com/gd/">GD</A>
library for manipulating images.</LI>
<LI>a working database server (<A HREF="http://www.mysql.com/">MySQL</A>, PostgreSQL,
- MSSQL, Oracle, Interbase, Foxpro, Access, ADO, Sybase, DB2 or ODBC)</LI>
+ MSSQL, Oracle, Interbase, Foxpro, Access, ADO, Sybase, DB2 or ODBC).</LI>
</UL>
<P>The quickest way to satisfy these requirements on Windows platforms is to download
<A HREF="http://www.phpgeek.com/">PHPTriad</A> or <A HREF="http://www.foxserv.net/">FoxServ</A>,
View
@@ -76,7 +76,7 @@
}
if (isset($USER->id)) {
- $SESSION->fromdiscuss = "$CFG->wwwroot";
+ $SESSION->fromdiscussion = "$CFG->wwwroot";
if (is_subscribed($USER->id, $newsforum->id)) {
$subtext = get_string("unsubscribe", "forum");
} else {
View
@@ -458,10 +458,10 @@ function execute_sql($command) {
$result = $db->Execute("$command");
if ($result) {
- echo "<P><FONT COLOR=green>SUCCESS: $command</FONT></P>";
+ echo "<P><FONT COLOR=green>SUCCESS</FONT></P>";
return true;
} else {
- echo "<P><FONT COLOR=red>ERROR: $command </FONT></P>";
+ echo "<P><FONT COLOR=red>ERROR</FONT></P>";
return false;
}
}
@@ -1351,7 +1351,7 @@ function add_to_log($course, $module, $action, $url="", $info="") {
// any particular student has been doing.
//
// course = the course id
-// module = discuss, journal, reading, course, user etc
+// module = forum, journal, reading, course, user etc
// action = view, edit, post (often but not always the same as the file.php)
// url = the file and parameters used to see the results of the action
// info = additional description information
File renamed without changes.
File renamed without changes.
View
@@ -13,7 +13,56 @@ CREATE TABLE forum (
timemodified int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id)
-) TYPE=MyISAM COMMENT='Discussion Forums';
+) COMMENT='Forums contain and structure discussion';
+# --------------------------------------------------------
+
+#
+# Table structure for table `forum_discussions`
+#
+
+CREATE TABLE forum_discussions (
+ id int(10) unsigned NOT NULL auto_increment,
+ course int(10) unsigned NOT NULL default '0',
+ forum int(10) unsigned NOT NULL default '0',
+ name varchar(255) NOT NULL default '',
+ firstpost int(10) unsigned NOT NULL default '0',
+ assessed tinyint(1) NOT NULL default '1',
+ timemodified int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (id)
+) COMMENT='Forums are composed of discussions';
+# --------------------------------------------------------
+
+#
+# Table structure for table `forum_posts`
+#
+
+CREATE TABLE forum_posts (
+ id int(10) unsigned NOT NULL auto_increment,
+ discuss int(10) unsigned NOT NULL default '0',
+ parent int(10) unsigned NOT NULL default '0',
+ user int(10) unsigned NOT NULL default '0',
+ created int(10) unsigned NOT NULL default '0',
+ modified int(10) unsigned NOT NULL default '0',
+ mailed tinyint(1) unsigned NOT NULL default '0',
+ subject varchar(255) NOT NULL default '',
+ message text NOT NULL,
+ totalscore tinyint(4) NOT NULL default '0',
+ PRIMARY KEY (id)
+) COMMENT='All posts are stored in this table';
+# --------------------------------------------------------
+
+#
+# Table structure for table `forum_ratings`
+#
+
+CREATE TABLE forum_ratings (
+ id int(10) unsigned NOT NULL auto_increment,
+ user int(10) unsigned NOT NULL default '0',
+ post int(10) unsigned NOT NULL default '0',
+ time int(10) unsigned NOT NULL default '0',
+ rating tinyint(4) NOT NULL default '0',
+ PRIMARY KEY (id)
+) COMMENT='Contains user ratings for individual posts';
# --------------------------------------------------------
#
@@ -26,13 +75,18 @@ CREATE TABLE forum_subscriptions (
forum int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id)
-) TYPE=MyISAM COMMENT='keeps track of who is subscribed to what forum';
-
+) COMMENT='Keeps track of who is subscribed to what forum';
+# --------------------------------------------------------
#
# Dumping data for table `log_display`
#
+INSERT INTO log_display VALUES ('forum', 'add', 'forum', 'name');
+INSERT INTO log_display VALUES ('forum', 'add discussion', 'forum_discuss', 'name');
+INSERT INTO log_display VALUES ('forum', 'add post', 'forum_posts', 'subject');
+INSERT INTO log_display VALUES ('forum', 'update post', 'forum_posts', 'subject');
+INSERT INTO log_display VALUES ('forum', 'view discussion', 'forum_discuss', 'name');
INSERT INTO log_display VALUES ('forum', 'view forum', 'forum', 'name');
INSERT INTO log_display VALUES ('forum', 'subscribe', 'forum', 'name');
INSERT INTO log_display VALUES ('forum', 'unsubscribe', 'forum', 'name');
Oops, something went wrong.

0 comments on commit 501cdbd

Please sign in to comment.