Permalink
Browse files

Fixing tags and comments issues.

  • Loading branch information...
1 parent b287039 commit ab42292001d28efc1f68c3a2c48fc56406c65b68 Jordi Piguillem committed Aug 2, 2010
Showing with 31 additions and 7 deletions.
  1. +17 −0 mod/wiki/db/upgrade.php
  2. +3 −0 mod/wiki/edit_form.php
  3. +5 −5 mod/wiki/locallib.php
  4. +5 −1 mod/wiki/pagelib.php
  5. +1 −1 mod/wiki/version.php
View
@@ -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;
}
View
@@ -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();
View
@@ -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 '<p class="wiki-tags"><span>Tags: </span>' . join($tags, ", ") . '</p>';
}
View
@@ -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 = '<p>' . get_string('saving', 'wiki') . '</p>';
View
@@ -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)

0 comments on commit ab42292

Please sign in to comment.