From ab42292001d28efc1f68c3a2c48fc56406c65b68 Mon Sep 17 00:00:00 2001 From: Jordi Piguillem Date: Mon, 2 Aug 2010 11:49:51 +0000 Subject: [PATCH] Fixing tags and comments issues. --- mod/wiki/db/upgrade.php | 17 +++++++++++++++++ mod/wiki/edit_form.php | 3 +++ mod/wiki/locallib.php | 10 +++++----- mod/wiki/pagelib.php | 6 +++++- mod/wiki/version.php | 2 +- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/mod/wiki/db/upgrade.php b/mod/wiki/db/upgrade.php index 3d06a6ad423bf..4b73cf74b0f3a 100644 --- a/mod/wiki/db/upgrade.php +++ b/mod/wiki/db/upgrade.php @@ -313,5 +313,22 @@ function xmldb_wiki_upgrade($oldversion) { //upgrade_mod_savepoint(true, 2010040120, 'wiki'); } + if ($oldversion < 2010080201) { + + $sql = "UPDATE {comments} + SET commentarea = 'wiki_page' + WHERE commentarea = 'wiki_comment_section'"; + $DB->execute($sql); + + $sql = "UPDATE {tag_instance} + SET itemtype = 'wiki_page' + WHERE itemtype = 'wiki'"; + $DB->execute($sql); + + echo $OUTPUT->notification('Updating comments and tags', 'notifysuccess'); + } + + + return true; } diff --git a/mod/wiki/edit_form.php b/mod/wiki/edit_form.php index 12d66660d3dde..05fbb3b9182f5 100644 --- a/mod/wiki/edit_form.php +++ b/mod/wiki/edit_form.php @@ -43,6 +43,8 @@ protected function definition() { $version = $this->_customdata['version']; $format = $this->_customdata['format']; + $tags = !isset($this->_customdata['tags'])?"":$this->_customdata['tags']; + if ($format != 'html') { $contextid = $this->_customdata['contextid']; @@ -86,6 +88,7 @@ protected function definition() { if (!empty($CFG->usetags)) { $mform->addElement('header', 'tagshdr', get_string('tags', 'tag')); $mform->addElement('tags', 'tags', get_string('tags')); + $mform->setDefault('tags', $tags); } $buttongroup = array(); diff --git a/mod/wiki/locallib.php b/mod/wiki/locallib.php index 9733824bc7212..03576ab6ba927 100644 --- a/mod/wiki/locallib.php +++ b/mod/wiki/locallib.php @@ -1085,7 +1085,7 @@ function wiki_get_comments($context, $pageid) { $cmt->context = $context; $cmt->itemid = $pageid; $cmt->pluginname = 'wiki'; - $cmt->area = 'wiki_comment_section'; + $cmt->area = 'wiki_page'; $cmt->course = $course; $manager = new comment($cmt); @@ -1101,7 +1101,7 @@ function wiki_get_comments($context, $pageid) { function wiki_get_comments_by_user($userid) { global $DB; - $area = 'wiki_comment_section'; + $area = 'wiki_page'; $sql = "SELECT c.* FROM {comments} c WHERE c.userid = ? and c.commentarea = ?"; @@ -1126,7 +1126,7 @@ function wiki_add_comment($context, $pageid, $content, $editor) { $cmt = new stdclass(); $cmt->context = $context; $cmt->itemid = $pageid; - $cmt->area = 'wiki_comment_section'; + $cmt->area = 'wiki_page'; $cmt->course = $course; $cmt->pluginname = 'wiki'; @@ -1157,7 +1157,7 @@ function wiki_delete_comment($idcomment, $context, $pageid) { $cmt = new stdclass; $cmt->context = $context; $cmt->itemid = $pageid; - $cmt->area = 'wiki_comment_section'; + $cmt->area = 'wiki_page'; $cmt->pluginname = 'wiki'; $cmt->course = $course; @@ -1220,7 +1220,7 @@ function wiki_print_page_content($page, $context, $subwikiid) { echo $OUTPUT->box($html); if (!empty($CFG->usetags)) { - $tags = tag_get_tags_array('wiki', $page->id); + $tags = tag_get_tags_array('wiki_page', $page->id); echo '

Tags: ' . join($tags, ", ") . '

'; } diff --git a/mod/wiki/pagelib.php b/mod/wiki/pagelib.php index d4c10549e1cf6..2784f9081ae11 100644 --- a/mod/wiki/pagelib.php +++ b/mod/wiki/pagelib.php @@ -545,6 +545,10 @@ protected function print_edit($content = null) { $params['fileitemid'] = $this->subwiki->id; } + if (!empty($CFG->usetags)) { + $params['tags'] = tag_get_tags_csv('wiki_page', $this->page->id, TAG_RETURN_TEXT); + } + $form = new mod_wiki_edit_form($url, $params); @@ -1937,7 +1941,7 @@ protected function print_save() { $errors = $this->process_uploads($context); } if (!empty($CFG->usetags)) { - tag_set('wiki', $this->page->id, $data->tags); + tag_set('wiki_page', $this->page->id, $data->tags); } $message = '

' . get_string('saving', 'wiki') . '

'; diff --git a/mod/wiki/version.php b/mod/wiki/version.php index 094a9d0fb697e..e422c7481e63f 100644 --- a/mod/wiki/version.php +++ b/mod/wiki/version.php @@ -32,5 +32,5 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$module->version = 2010071900; // The current module version (Date: YYYYMMDDXX) +$module->version = 2010080201; // The current module version (Date: YYYYMMDDXX) $module->cron = 0; // Period for cron to check this module (secs)