Skip to content

Commit

Permalink
Fixing tags and comments issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordi Piguillem committed Aug 2, 2010
1 parent b287039 commit ab42292
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
17 changes: 17 additions & 0 deletions mod/wiki/db/upgrade.php
Expand Up @@ -313,5 +313,22 @@ function xmldb_wiki_upgrade($oldversion) {
//upgrade_mod_savepoint(true, 2010040120, 'wiki'); //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; return true;
} }
3 changes: 3 additions & 0 deletions mod/wiki/edit_form.php
Expand Up @@ -43,6 +43,8 @@ protected function definition() {


$version = $this->_customdata['version']; $version = $this->_customdata['version'];
$format = $this->_customdata['format']; $format = $this->_customdata['format'];
$tags = !isset($this->_customdata['tags'])?"":$this->_customdata['tags'];



if ($format != 'html') { if ($format != 'html') {
$contextid = $this->_customdata['contextid']; $contextid = $this->_customdata['contextid'];
Expand Down Expand Up @@ -86,6 +88,7 @@ protected function definition() {
if (!empty($CFG->usetags)) { if (!empty($CFG->usetags)) {
$mform->addElement('header', 'tagshdr', get_string('tags', 'tag')); $mform->addElement('header', 'tagshdr', get_string('tags', 'tag'));
$mform->addElement('tags', 'tags', get_string('tags')); $mform->addElement('tags', 'tags', get_string('tags'));
$mform->setDefault('tags', $tags);
} }


$buttongroup = array(); $buttongroup = array();
Expand Down
10 changes: 5 additions & 5 deletions mod/wiki/locallib.php
Expand Up @@ -1085,7 +1085,7 @@ function wiki_get_comments($context, $pageid) {
$cmt->context = $context; $cmt->context = $context;
$cmt->itemid = $pageid; $cmt->itemid = $pageid;
$cmt->pluginname = 'wiki'; $cmt->pluginname = 'wiki';
$cmt->area = 'wiki_comment_section'; $cmt->area = 'wiki_page';
$cmt->course = $course; $cmt->course = $course;
$manager = new comment($cmt); $manager = new comment($cmt);


Expand All @@ -1101,7 +1101,7 @@ function wiki_get_comments($context, $pageid) {
function wiki_get_comments_by_user($userid) { function wiki_get_comments_by_user($userid) {
global $DB; global $DB;


$area = 'wiki_comment_section'; $area = 'wiki_page';
$sql = "SELECT c.* $sql = "SELECT c.*
FROM {comments} c FROM {comments} c
WHERE c.userid = ? and c.commentarea = ?"; WHERE c.userid = ? and c.commentarea = ?";
Expand All @@ -1126,7 +1126,7 @@ function wiki_add_comment($context, $pageid, $content, $editor) {
$cmt = new stdclass(); $cmt = new stdclass();
$cmt->context = $context; $cmt->context = $context;
$cmt->itemid = $pageid; $cmt->itemid = $pageid;
$cmt->area = 'wiki_comment_section'; $cmt->area = 'wiki_page';
$cmt->course = $course; $cmt->course = $course;
$cmt->pluginname = 'wiki'; $cmt->pluginname = 'wiki';


Expand Down Expand Up @@ -1157,7 +1157,7 @@ function wiki_delete_comment($idcomment, $context, $pageid) {
$cmt = new stdclass; $cmt = new stdclass;
$cmt->context = $context; $cmt->context = $context;
$cmt->itemid = $pageid; $cmt->itemid = $pageid;
$cmt->area = 'wiki_comment_section'; $cmt->area = 'wiki_page';
$cmt->pluginname = 'wiki'; $cmt->pluginname = 'wiki';
$cmt->course = $course; $cmt->course = $course;


Expand Down Expand Up @@ -1220,7 +1220,7 @@ function wiki_print_page_content($page, $context, $subwikiid) {
echo $OUTPUT->box($html); echo $OUTPUT->box($html);


if (!empty($CFG->usetags)) { 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>'; echo '<p class="wiki-tags"><span>Tags: </span>' . join($tags, ", ") . '</p>';
} }


Expand Down
6 changes: 5 additions & 1 deletion mod/wiki/pagelib.php
Expand Up @@ -545,6 +545,10 @@ protected function print_edit($content = null) {
$params['fileitemid'] = $this->subwiki->id; $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); $form = new mod_wiki_edit_form($url, $params);




Expand Down Expand Up @@ -1937,7 +1941,7 @@ protected function print_save() {
$errors = $this->process_uploads($context); $errors = $this->process_uploads($context);
} }
if (!empty($CFG->usetags)) { 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>'; $message = '<p>' . get_string('saving', 'wiki') . '</p>';
Expand Down
2 changes: 1 addition & 1 deletion mod/wiki/version.php
Expand Up @@ -32,5 +32,5 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @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) $module->cron = 0; // Period for cron to check this module (secs)

0 comments on commit ab42292

Please sign in to comment.