From 0703d22ede550c163cd303168b0252e7cd3b301b Mon Sep 17 00:00:00 2001 From: stronk7 Date: Mon, 4 Sep 2006 20:37:27 +0000 Subject: [PATCH] One less reserved word. glossary->comment is out! --- mod/glossary/backuplib.php | 2 +- mod/glossary/comment.php | 4 ++-- mod/glossary/db/install.xml | 8 ++++---- mod/glossary/db/migrate2utf8.xml | 2 +- mod/glossary/db/mysql.php | 6 +++++- mod/glossary/db/mysql.sql | 2 +- mod/glossary/db/postgres7.php | 5 ++++- mod/glossary/db/postgres7.sql | 2 +- mod/glossary/lib.php | 2 +- mod/glossary/restorelib.php | 14 +++++++++----- mod/glossary/version.php | 2 +- 11 files changed, 30 insertions(+), 19 deletions(-) diff --git a/mod/glossary/backuplib.php b/mod/glossary/backuplib.php index 1b1d12726a..8ad9dd81a3 100644 --- a/mod/glossary/backuplib.php +++ b/mod/glossary/backuplib.php @@ -233,7 +233,7 @@ fwrite ($bf,full_tag("ID",8,false,$comment->id)); fwrite ($bf,full_tag("USERID",8,false,$comment->userid)); - fwrite ($bf,full_tag("COMMENT",8,false,$comment->comment)); + fwrite ($bf,full_tag("ENTRYCOMMENT",8,false,$comment->entrycomment)); fwrite ($bf,full_tag("FORMAT",8,false,$comment->format)); fwrite ($bf,full_tag("TIMEMODIFIED",8,false,$comment->timemodified)); diff --git a/mod/glossary/comment.php b/mod/glossary/comment.php index 879eaad396..ab6a0be206 100644 --- a/mod/glossary/comment.php +++ b/mod/glossary/comment.php @@ -137,7 +137,7 @@ trusttext_after_edit($form->text, $context); $newentry->entryid = $entry->id; - $newentry->comment = $form->text; + $newentry->entrycomment = $form->text; $newentry->format = $form->format; $newentry->timemodified = time(); @@ -178,7 +178,7 @@ $defaultformat = FORMAT_MOODLE; } if (isset($comment) ) { - $form->text = $comment->comment; + $form->text = $comment->entrycomment; $form->format = $comment->format; } else { $form->text = ''; diff --git a/mod/glossary/db/install.xml b/mod/glossary/db/install.xml index f5cef91361..5db7489b30 100644 --- a/mod/glossary/db/install.xml +++ b/mod/glossary/db/install.xml @@ -103,9 +103,9 @@ - - - + + + @@ -169,4 +169,4 @@ - \ No newline at end of file + diff --git a/mod/glossary/db/migrate2utf8.xml b/mod/glossary/db/migrate2utf8.xml index de2947a2fc..807051ce8e 100755 --- a/mod/glossary/db/migrate2utf8.xml +++ b/mod/glossary/db/migrate2utf8.xml @@ -46,7 +46,7 @@ - + SELECT gco.userid FROM {$CFG->prefix}glossary_comments gco diff --git a/mod/glossary/db/mysql.php b/mod/glossary/db/mysql.php index 5274c55ca7..11406096f5 100644 --- a/mod/glossary/db/mysql.php +++ b/mod/glossary/db/mysql.php @@ -436,7 +436,11 @@ function glossary_upgrade($oldversion) { } } - return true; + if ($oldversion < 2006090400) { + table_column('glossary_comments', 'comment', 'entrycomment', 'text', '', '', ''); + } + + return true; } ?> diff --git a/mod/glossary/db/mysql.sql b/mod/glossary/db/mysql.sql index 8ba1a25c09..a4c7bbf53a 100644 --- a/mod/glossary/db/mysql.sql +++ b/mod/glossary/db/mysql.sql @@ -107,7 +107,7 @@ CREATE TABLE prefix_glossary_comments ( id int(10) unsigned NOT NULL auto_increment, entryid int(10) unsigned NOT NULL default '0', userid int(10) unsigned NOT NULL default '0', - comment text NOT NULL default '', + entrycomment text NOT NULL default '', format tinyint(2) unsigned NOT NULL default '0', timemodified int(10) unsigned NOT NULL default '0', PRIMARY KEY (id), diff --git a/mod/glossary/db/postgres7.php b/mod/glossary/db/postgres7.php index 7eb5baca52..0e5296b1e3 100644 --- a/mod/glossary/db/postgres7.php +++ b/mod/glossary/db/postgres7.php @@ -200,8 +200,11 @@ function glossary_upgrade($oldversion) { } } + if ($oldversion < 2006090400) { + table_column('glossary_comments', 'comment', 'entrycomment', 'text', '', '', ''); + } - return true; + return true; } ?> diff --git a/mod/glossary/db/postgres7.sql b/mod/glossary/db/postgres7.sql index 4d9fc9772e..2ae6bbd26a 100644 --- a/mod/glossary/db/postgres7.sql +++ b/mod/glossary/db/postgres7.sql @@ -117,7 +117,7 @@ CREATE TABLE prefix_glossary_comments ( id SERIAL, entryid int4 NOT NULL default '0', userid int4 NOT NULL default '0', - comment text NOT NULL, + entrycomment text NOT NULL, format int2 NOT NULL default '0', timemodified int4 NOT NULL default '0', PRIMARY KEY (id) diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 075f7e80df..bdd3938c82 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -1582,7 +1582,7 @@ function glossary_print_comment($course, $cm, $glossary, $entry, $comment) { $options = new object(); $options->trusttext = true; - echo format_text($comment->comment, $comment->format, $options); + echo format_text($comment->entrycomment, $comment->format, $options); echo '
'; diff --git a/mod/glossary/restorelib.php b/mod/glossary/restorelib.php index fdb6925ca6..a3b58fe185 100644 --- a/mod/glossary/restorelib.php +++ b/mod/glossary/restorelib.php @@ -244,7 +244,11 @@ //Now, build the GLOSSARY_COMMENTS record structure $comment->entryid = $new_entry_id; $comment->userid = backup_todb($com_info['#']['USERID']['0']['#']); - $comment->comment = backup_todb($com_info['#']['COMMENT']['0']['#']); + if (isset($com_info['#']['COMMENT']['0']['#'])) { + $comment->entrycomment = backup_todb($com_info['#']['COMMENT']['0']['#']); + } else { + $comment->entrycomment = backup_todb($com_info['#']['ENTRYCOMMENT']['0']['#']); + } $comment->timemodified = backup_todb($com_info['#']['TIMEMODIFIED']['0']['#']); $comment->format = backup_todb($com_info['#']['FORMAT']['0']['#']); @@ -676,8 +680,8 @@ $status = true; - //Convert glossary_comments->comment - if ($records = get_records_sql ("SELECT c.id, c.comment, c.format + //Convert glossary_comments->entrycomment + if ($records = get_records_sql ("SELECT c.id, c.entrycomment, c.format FROM {$CFG->prefix}glossary_comments c, {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary g, @@ -691,10 +695,10 @@ b.new_id = c.id")) { foreach ($records as $record) { //Rebuild wiki links - $record->comment = restore_decode_wiki_content($record->comment, $restore); + $record->entrycomment = restore_decode_wiki_content($record->entrycomment, $restore); //Convert to Markdown $wtm = new WikiToMarkdown(); - $record->comment = $wtm->convert($record->comment, $restore->course_id); + $record->entrycomment = $wtm->convert($record->entrycomment, $restore->course_id); $record->format = FORMAT_MARKDOWN; $status = update_record('glossary_comments', addslashes_object($record)); //Do some output diff --git a/mod/glossary/version.php b/mod/glossary/version.php index 3237b2a4c5..ec6ad12f40 100644 --- a/mod/glossary/version.php +++ b/mod/glossary/version.php @@ -5,7 +5,7 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2006082600; +$module->version = 2006090400; $module->requires = 2006082600; // Requires this Moodle version $module->cron = 0; // Period for cron to check this module (secs) -- 2.39.5