Index: mod/glossary/backuplib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/glossary/backuplib.php,v
retrieving revision 1.35
diff -u -r1.35 backuplib.php
--- mod/glossary/backuplib.php	20 Apr 2009 10:05:51 -0000	1.35
+++ mod/glossary/backuplib.php	12 Oct 2009 07:18:27 -0000
@@ -217,8 +217,15 @@
         global $CFG, $DB;
 
         $status = true;
+        $params = array();
+        $params[] = $entryid;
+        $sql = 'SELECT g.id AS glossaryid, g.course as courseid FROM {glossary_entries} e, {glossary} g WHERE e.glossaryid = g.id AND e.id=?';
+        $result = $DB->get_record_sql($sql, $params);
+        if ($cm = get_coursemodule_from_instance('glossary', $result->glossaryid, $result->courseid)) {
+            $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+        }
 
-        $comments = $DB->get_records("glossary_comments", array("entryid"=>$entryid));
+        $comments = $DB->get_records('comments', array('itemid'=>$entryid, 'commentarea'=>'glossary_entry', 'contextid'=>$context->id));
         if ($comments) {
             $status =fwrite ($bf,start_tag("COMMENTS",6,true));
             foreach ($comments as $comment) {
@@ -226,9 +233,10 @@
 
                 fwrite ($bf,full_tag("ID",8,false,$comment->id));
                 fwrite ($bf,full_tag("USERID",8,false,$comment->userid));
-                fwrite ($bf,full_tag("ENTRYCOMMENT",8,false,$comment->entrycomment));
-                fwrite ($bf,full_tag("FORMAT",8,false,$comment->entrycommentformat));
-                fwrite ($bf,full_tag("TIMEMODIFIED",8,false,$comment->timemodified));
+                fwrite ($bf,full_tag("CONTENT",8,false,$comment->content));
+                fwrite ($bf,full_tag("COMMENTAREA",8,false,$comment->commentarea));
+                fwrite ($bf,full_tag("FORMAT",8,false,$comment->format));
+                fwrite ($bf,full_tag("TIMECREATED",8,false,$comment->timecreated));
 
                 $status =fwrite ($bf,end_tag("COMMENT",7,true));
             }
Index: mod/glossary/deleteentry.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/glossary/deleteentry.php,v
retrieving revision 1.47
diff -u -r1.47 deleteentry.php
--- mod/glossary/deleteentry.php	24 Sep 2009 07:29:14 -0000	1.47
+++ mod/glossary/deleteentry.php	12 Oct 2009 07:18:27 -0000
@@ -92,7 +92,7 @@
     } else {
         $fs = get_file_storage();
         $fs->delete_area_files($context->id, 'glossary_attachment', $entry->id);
-        $DB->delete_records("glossary_comments", array("entryid"=>$entry->id));
+        $DB->delete_records("comments", array('itemid'=>$entry->id, 'commentarea'=>'glossary_entry', 'contextid'=>$context->id));
         $DB->delete_records("glossary_alias", array("entryid"=>$entry->id));
         $DB->delete_records("glossary_ratings", array("entryid"=>$entry->id));
         $DB->delete_records("glossary_entries", array("id"=>$entry->id));
@@ -116,4 +116,4 @@
     echo $OUTPUT->footer();
 }
 
-?>
\ No newline at end of file
+?>
Index: mod/glossary/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/glossary/lib.php,v
retrieving revision 1.266
diff -u -r1.266 lib.php
--- mod/glossary/lib.php	11 Sep 2009 05:38:44 -0000	1.266
+++ mod/glossary/lib.php	12 Oct 2009 07:18:29 -0000
@@ -198,7 +198,7 @@
 
     // Delete any dependent records
     $entry_select = "SELECT id FROM {glossary_entries} WHERE glossaryid = ?";
-    $DB->delete_records_select('glossary_comments', "entryid IN ($entry_select)", array($id));
+    $DB->delete_records_select('comments', "contextid={$context->id} AND commentarea='glossary_entry' AND itemid IN ($entry_select)", array($id));
     $DB->delete_records_select('glossary_alias',    "entryid IN ($entry_select)", array($id));
     $DB->delete_records_select('glossary_ratings',  "entryid IN ($entry_select)", array($id));
 
@@ -920,13 +920,6 @@
         $output = true;
         $return .= get_string('entryishidden','glossary');
     }
-    $return .= glossary_print_entry_commentslink($course, $cm, $glossary, $entry,$mode,$hook,'html');
-
-    if (has_capability('mod/glossary:comment', $context) and $glossary->allowcomments) {
-        $output = true;
-        $return .= ' <a title="' . get_string('addcomment','glossary') . '" href="comment.php?action=add&amp;entryid='.$entry->id.'"><img src="comment.gif" class="iconsmall" alt="'.get_string('addcomment','glossary').$altsuffix.'" /></a>';
-    }
-
 
     if (has_capability('mod/glossary:manageentries', $context) or (!empty($USER->id) and has_capability('mod/glossary:write', $context) and $entry->userid == $USER->id)) {
         // only teachers can export entries so check it out
@@ -970,6 +963,21 @@
 
     $return .= '</span>';
 
+    if (has_capability('mod/glossary:comment', $context) and $glossary->allowcomments) {
+        $output = true;
+        if (!empty($CFG->usecomments)) {
+            require_once($CFG->libdir . '/commentlib.php');
+            $cmt = new stdclass;
+            $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+            $cmt->area    = 'glossary_entry';
+            $cmt->context = $modcontext;
+            $cmt->itemid  = $entry->id;
+            $cmt->showcount = true;
+            $comment = new comment($cmt);
+            $return .= '<div style="width:500px">'.$comment->init(true).'</div>';
+        }
+    }
+
     //If we haven't calculated any REAL thing, delete result ($return)
     if (!$output) {
         $return = '';
@@ -983,41 +991,6 @@
 }
 
 /**
- * @global object
- * @param object $course
- * @param object $cm
- * @param object $glossary
- * @param object $entry
- * @param string $mode
- * @param string $hook
- * @param string $type
- * @return string|void
- */
-function glossary_print_entry_commentslink($course, $cm, $glossary, $entry,$mode,$hook, $type = 'print') {
-    global $DB;
-
-    $return = '';
-
-    $count = $DB->count_records('glossary_comments', array('entryid'=>$entry->id));
-    if ($count) {
-        $return = '';
-        $return .= "<a href=\"comments.php?id=$cm->id&amp;eid=$entry->id\">$count ";
-        if ($count == 1) {
-            $return .= get_string('comment', 'glossary');
-        } else {
-            $return .= get_string('comments', 'glossary');
-        }
-        $return .= '</a>';
-    }
-
-    if ($type == 'print') {
-        echo $return;
-    } else {
-        return $return;
-    }
-}
-
-/**
  * @param object $course
  * @param object $cm
  * @param object $glossary
@@ -1720,65 +1693,6 @@
     }
 }
 
-/**
- * @global object
- * @global object
- * @global object
- * @param object $course
- * @param object $cm
- * @param object $glossary
- * @param object $entry
- * @param object $comment
- */
-function glossary_print_comment($course, $cm, $glossary, $entry, $comment) {
-    global $CFG, $USER, $DB, $OUTPUT;
-
-    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
-    $user = $DB->get_record('user', array('id'=>$comment->userid));
-    $strby = get_string('writtenby','glossary');
-    $fullname = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
-
-    echo '<div class="boxaligncenter">';
-    echo '<table class="glossarycomment" cellspacing="0">';
-    echo '<tr valign="top">';
-    echo '<td class="left picture">';
-    echo $OUTPUT->user_picture(moodle_user_picture::make($user, $course->id));
-    echo '</td>';
-    echo '<td class="entryheader">';
-
-    $fullname = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
-    $by = new object();
-    $by->name = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id.'">'.$fullname.'</a>';
-    $by->date = userdate($comment->timemodified);
-    echo '<span class="author">'.get_string('bynameondate', 'forum', $by).'</span>';
-
-    echo '</td></tr>';
-
-    echo '<tr valign="top"><td class="left side">';
-    echo '&nbsp;';
-    echo '</td><td class="entry">';
-
-    $options = new object();
-    $options->trusted = $comment->entrycommenttrust;
-    echo format_text($comment->entrycomment, $comment->entrycommentformat, $options);
-
-    echo '<div class="icons commands">';
-
-    $ineditperiod = ((time() - $comment->timemodified <  $CFG->maxeditingtime) || $glossary->editalways);
-    if ( ($glossary->allowcomments &&  $ineditperiod && $USER->id == $comment->userid)  || has_capability('mod/glossary:managecomments', $context)) {
-        echo "<a href=\"comment.php?id=$comment->id&amp;action=edit\"><img
-               alt=\"" . get_string("edit") . "\" src=\"" . $OUTPUT->old_icon_url('t/edit') . "\" class=\"iconsmall\" /></a> ";
-    }
-    if ( ($glossary->allowcomments && $USER->id == $comment->userid) || has_capability('mod/glossary:managecomments', $context) ) {
-        echo "<a href=\"comment.php?id=$comment->id&amp;action=delete\"><img
-               alt=\"" . get_string("delete") . "\" src=\"" . $OUTPUT->old_icon_url('t/delete') . "\" class=\"iconsmall\" /></a>";
-    }
-
-    echo '</div></td></tr>';
-    echo '</table></div>';
-
-}
 
 /**
  * @global object
@@ -2467,7 +2381,7 @@
  * @return array
  */
 function glossary_get_post_actions() {
-    return array('add category','add comment','add entry','approve entry','delete category','delete comment','delete entry','edit category','update comment','update entry');
+    return array('add category','add entry','approve entry','delete category','delete entry','edit category','update entry');
 }
 
 
@@ -2561,7 +2475,8 @@
          or (!empty($data->reset_glossary_types) and in_array('main', $data->reset_glossary_types) and in_array('secondary', $data->reset_glossary_types))) {
 
         $DB->delete_records_select('glossary_ratings', "entryid IN ($allentriessql)", $params);
-        $DB->delete_records_select('glossary_comments', "entryid IN ($allentriessql)", $params);
+        // TODO: delete comments 
+        //$DB->delete_records_select('comments', "entryid IN ($allentriessql)", array());
         $DB->delete_records_select('glossary_entries', "glossaryid IN ($allglossariessql)", $params);
 
         // now get rid of all attachments
@@ -2678,7 +2593,7 @@
         $status[] = array('component'=>$componentstr, 'item'=>get_string('deleteallratings'), 'error'=>false);
     }
 
-    // remove all comments
+    // TODO: remove all comments
     if (!empty($data->reset_glossary_comments)) {
         $DB->delete_records_select('glossary_comments', "entryid IN ($allentriessql)", $params);
         $status[] = array('component'=>$componentstr, 'item'=>get_string('deleteallcomments'), 'error'=>false);
@@ -2926,4 +2841,10 @@
     if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
         $glossarynav->add(get_string('updatethis', '', get_string('modulename', 'glossary')), new moodle_url($CFG->wwwroot.'/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey())));
     }
-}
\ No newline at end of file
+}
+function glossary_comment_display(&$comments, $params) {
+    foreach($comments as &$c) {
+        $c->content .= ' did call back';
+    }
+    return true;
+}
Index: mod/glossary/restorelib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/glossary/restorelib.php,v
retrieving revision 1.57
diff -u -r1.57 restorelib.php
--- mod/glossary/restorelib.php	20 Apr 2009 10:38:29 -0000	1.57
+++ mod/glossary/restorelib.php	12 Oct 2009 07:18:30 -0000
@@ -205,7 +205,7 @@
                     //Restore glossary_alias
                     $status = glossary_alias_restore_mods($oldid,$newid,$ent_info,$restore);
                     //Now restore glossary_comments
-                    $status = glossary_comments_restore_mods($oldid,$newid,$ent_info,$restore);
+                    $status = glossary_comments_restore_mods($oldid,$newid,$old_glossary_id,$new_glossary_id,$ent_info,$restore);
                     //Now restore glossary_ratings
                     $status = glossary_ratings_restore_mods($oldid,$newid,$ent_info,$restore);
                     //Now copy moddata associated files if needed
@@ -223,11 +223,14 @@
     }
 
     //This function restores the glossary_comments
-    function glossary_comments_restore_mods($old_entry_id,$new_entry_id,$info,$restore) {
+    function glossary_comments_restore_mods($old_entry_id,$new_entry_id,$old_gid,$new_gid,$info,$restore) {
         global $CFG, $DB;
 
         $status = true;
 
+        $newmodcontext = restore_get_new_context($restore, 'course_modules', CONTEXT_MODULE, $old_gid);
+
+
         //Get the comments array
         $comments = isset($info['#']['COMMENTS']['0']['#']['COMMENT'])?$info['#']['COMMENTS']['0']['#']['COMMENT']:array();
 
@@ -242,15 +245,17 @@
             $oldid = backup_todb($com_info['#']['ID']['0']['#']);
 
             //Now, build the GLOSSARY_COMMENTS record structure
-            $comment->entryid = $new_entry_id;
-            $comment->userid = backup_todb($com_info['#']['USERID']['0']['#']);
+            $comment->itemid = $new_entry_id;
             if (isset($com_info['#']['COMMENT']['0']['#'])) {
-                $comment->entrycomment = backup_todb($com_info['#']['COMMENT']['0']['#']);
+                $comment->content = backup_todb($com_info['#']['COMMENT']['0']['#']);
             } else {
-                $comment->entrycomment = backup_todb($com_info['#']['ENTRYCOMMENT']['0']['#']);
+                $comment->content = backup_todb($com_info['#']['ENTRYCOMMENT']['0']['#']);
             }
-            $comment->timemodified = backup_todb($com_info['#']['TIMEMODIFIED']['0']['#']);
-            $comment->entrycommentformat = backup_todb($com_info['#']['FORMAT']['0']['#']);
+            $comment->userid = backup_todb($com_info['#']['USERID']['0']['#']);
+            $comment->timecreated = backup_todb($com_info['#']['TIMECREATED']['0']['#']);
+            $comment->format = backup_todb($com_info['#']['FORMAT']['0']['#']);
+            $comment->commentarea = backup_todb($com_info['#']['COMMENTAREA']['0']['#']);
+            $comment->contextid = $newmodcontext->id;
 
             //We have to recode the userid field
             $user = backup_getid($restore->backup_unique_code,"user",$comment->userid);
@@ -259,7 +264,7 @@
             }
 
             //The structure is equal to the db, so insert the glossary_comments
-            $newid = $DB->insert_record ("glossary_comments",$comment);
+            $newid = $DB->insert_record ("comments", $comment);
 
             //Do some output
             if (($i+1) % 50 == 0) {
Index: mod/glossary/version.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/glossary/version.php,v
retrieving revision 1.66
diff -u -r1.66 version.php
--- mod/glossary/version.php	20 Apr 2009 19:14:57 -0000	1.66
+++ mod/glossary/version.php	12 Oct 2009 07:18:30 -0000
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2009042006;
+$module->version  = 2009092009;
 $module->requires = 2009041700;  // Requires this Moodle version
 $module->cron     = 0;           // Period for cron to check this module (secs)
 
Index: mod/glossary/view.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/glossary/view.php,v
retrieving revision 1.153
diff -u -r1.153 view.php
--- mod/glossary/view.php	24 Sep 2009 07:29:15 -0000	1.153
+++ mod/glossary/view.php	12 Oct 2009 07:18:30 -0000
@@ -49,6 +49,8 @@
 require_course_login($course->id, true, $cm);
 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
+    require_once($CFG->libdir . '/commentlib.php');
+    comment::js();
 /// Loading the textlib singleton instance. We are going to need it.
 $textlib = textlib_get_instance();
 
Index: mod/glossary/db/install.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/glossary/db/install.php,v
retrieving revision 1.2
diff -u -r1.2 install.php
--- mod/glossary/db/install.php	29 Jan 2009 19:58:49 -0000	1.2
+++ mod/glossary/db/install.php	12 Oct 2009 07:18:30 -0000
@@ -18,9 +18,6 @@
     update_log_display_entry('glossary', 'add category', 'glossary', 'name');
     update_log_display_entry('glossary', 'update category', 'glossary', 'name');
     update_log_display_entry('glossary', 'delete category', 'glossary', 'name');
-    update_log_display_entry('glossary', 'add comment', 'glossary', 'name');
-    update_log_display_entry('glossary', 'update comment', 'glossary', 'name');
-    update_log_display_entry('glossary', 'delete comment', 'glossary', 'name');
     update_log_display_entry('glossary', 'approve entry', 'glossary', 'name');
     update_log_display_entry('glossary', 'view entry', 'glossary_entries', 'concept');
 
Index: mod/glossary/db/install.xml
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/glossary/db/install.xml,v
retrieving revision 1.9
diff -u -r1.9 install.xml
--- mod/glossary/db/install.xml	1 May 2009 14:07:47 -0000	1.9
+++ mod/glossary/db/install.xml	12 Oct 2009 07:18:31 -0000
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/glossary/db" VERSION="20090420" COMMENT="XMLDB file for Moodle mod/glossary"
+<XMLDB PATH="mod/glossary/db" VERSION="20090925" COMMENT="XMLDB file for Moodle mod/glossary"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
 >
@@ -91,7 +91,7 @@
         <KEY NAME="glossaryid" TYPE="foreign" FIELDS="glossaryid" REFTABLE="glossary" REFFIELDS="id" PREVIOUS="primary"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="glossary_entries_categories" COMMENT="categories of each glossary entry" PREVIOUS="glossary_categories" NEXT="glossary_comments">
+    <TABLE NAME="glossary_entries_categories" COMMENT="categories of each glossary entry" PREVIOUS="glossary_categories" NEXT="glossary_formats">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="categoryid"/>
         <FIELD NAME="categoryid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="entryid"/>
@@ -103,25 +103,7 @@
         <KEY NAME="entryid" TYPE="foreign" FIELDS="entryid" REFTABLE="glossary_entries" REFFIELDS="id" PREVIOUS="categoryid"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="glossary_comments" COMMENT="comments on glossary entries" PREVIOUS="glossary_entries_categories" NEXT="glossary_formats">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="entryid"/>
-        <FIELD NAME="entryid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="userid"/>
-        <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="entryid" NEXT="entrycomment"/>
-        <FIELD NAME="entrycomment" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" PREVIOUS="userid" NEXT="entrycommentformat"/>
-        <FIELD NAME="entrycommentformat" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="entrycomment" NEXT="entrycommenttrust"/>
-        <FIELD NAME="entrycommenttrust" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="entrycommentformat" NEXT="timemodified"/>
-        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="entrycommenttrust"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="entryid"/>
-        <KEY NAME="entryid" TYPE="foreign" FIELDS="entryid" REFTABLE="glossary_entries" REFFIELDS="id" PREVIOUS="primary"/>
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="userid" UNIQUE="false" FIELDS="userid"/>
-      </INDEXES>
-    </TABLE>
-    <TABLE NAME="glossary_formats" COMMENT="Setting of the display formats" PREVIOUS="glossary_comments" NEXT="glossary_ratings">
+    <TABLE NAME="glossary_formats" COMMENT="Setting of the display formats" PREVIOUS="glossary_entries_categories" NEXT="glossary_ratings">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
         <FIELD NAME="name" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="popupformatname"/>
Index: mod/glossary/db/upgrade.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/glossary/db/upgrade.php,v
retrieving revision 1.22
diff -u -r1.22 upgrade.php
--- mod/glossary/db/upgrade.php	18 Aug 2009 05:14:56 -0000	1.22
+++ mod/glossary/db/upgrade.php	12 Oct 2009 07:18:31 -0000
@@ -204,6 +204,53 @@
     /// glossary savepoint reached
         upgrade_mod_savepoint($result, 2009042006, 'glossary');
     }
+    if ($result && $oldversion < 2009092009) {
+        require_once($CFG->libdir . '/commentlib.php');
+ 
+    /// Define table glossary_comments to be dropped
+        $table = new xmldb_table('glossary_comments');
+
+    /// Conditionally launch drop table for glossary_comments
+        if ($dbman->table_exists($table)) {
+            $sql = 'SELECT e.glossaryid AS glossaryid,
+                g.course AS courseid,
+                e.id AS itemid,
+                c.entrycomment AS comment,
+                c.entrycommentformat AS format,
+                c.entrycommenttrust AS trust,
+                c.timemodified AS timemodified
+                FROM {glossary_comments} c, {glossary_entries} e, {glossary} g
+                WHERE c.entryid=e.id AND e.glossaryid=g.id';
+        /// move glossary comments to new comments table
+            $error = false;
+            if ($rs = $DB->get_recordset_sql($sql)) {
+                foreach($rs as $res) {
+                    if ($cm = get_coursemodule_from_instance('glossary', $res->glossaryid, $res->courseid)) {
+                        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+                        $cmt = new stdclass;
+                        $cmt->contextid = $context->id;
+                        $cmt->courseid  = $res->courseid;
+                        $cmt->area      = 'glossary_entry';
+                        $cmt->itemid    = $res->itemid;
+                        $comment = new comment($cmt);
+                        try {
+                            $cmt = $comment->add($res->comment, $res->format);
+                        } catch (comment_exception $e) {
+                            $error = true;
+                        }
+                    }
+                }
+            }
+            if (empty($error)) {
+                $dbman->drop_table($table);
+            } else {
+                print_error('error');
+            }
+        }
+
+    /// glossary savepoint reached
+        upgrade_mod_savepoint($result, 2009092009, 'glossary');
+    }
 
     return $result;
 }
