Commit 00f056a0 authored by nyloth's avatar nyloth

[FIX] forums: moderation now worksfor every posts in a moderated forum (only...

[FIX] forums: moderation now worksfor every posts in a moderated forum (only new topics where moderated before).
parent a4536f8d
......@@ -2,7 +2,7 @@
// $start_time = microtime(true);
// $Header: /cvsroot/tikiwiki/tiki/comments.php,v 1.77 2007-07-14 18:18:53 nyloth Exp $
// $Header: /cvsroot/tikiwiki/tiki/comments.php,v 1.78 2007-08-13 08:57:47 nyloth Exp $
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -227,45 +227,81 @@ if ( ($tiki_p_post_comments == 'y' && (!isset($forum_mode) || $forum_mode == 'n'
if ( empty($_REQUEST["comments_parentId"]) ) $_REQUEST["comments_parentId"] = 0;
$object = explode(':', $comments_objectId );
if( $object[0] == 'forum' && ! empty($_REQUEST["comments_grandParentId"] )) {
$parent_id = $_REQUEST["comments_grandParentId"];
} else {
$parent_id = $_REQUEST["comments_parentId"];
}
if ( isset($_REQUEST["comments_reply_threadId"]) && ! empty($_REQUEST["comments_reply_threadId"]) ) {
$reply_info = $commentslib->get_comment($_REQUEST["comments_reply_threadId"]);
$in_reply_to = $reply_info["message_id"];
} else {
$in_reply_to = '';
}
// Remove HTML tags and empty lines at the end of the posted comment
$_REQUEST["comments_data"] = rtrim(strip_tags($_REQUEST["comments_data"]));
if ( $_REQUEST["comments_threadId"] == 0 ) {
if ( isset($_REQUEST["comments_reply_threadId"]) && ! empty($_REQUEST["comments_reply_threadId"]) ) {
$reply_info = $commentslib->get_comment($_REQUEST["comments_reply_threadId"]);
$in_reply_to = $reply_info["message_id"];
} else {
$in_reply_to = '';
}
$message_id = '';
if ( $tiki_p_forum_autoapp != 'y'
&& ( $forum_info['approval_type'] == 'queue_all' || ( ! $user && $forum_info['approval_type'] == 'queue_anon' ) )
) {
$smarty->assign('was_queued', 'y');
$qId = $commentslib->replace_queue(0, $_REQUEST['forumId'], $comments_objectId, $parent_id,
$user, $_REQUEST["comments_title"], $_REQUEST["comments_data"], 'n', '', '', $thread_info['title'], $in_reply_to);
// PROCESS ATTACHMENT HERE
if ( $qId && isset($_FILES['userfile1']) && ! empty($_FILES['userfile1']['name']) ) {
if ( is_uploaded_file($_FILES['userfile1']['tmp_name']) ) {
check_ticket('view-forum');
$fp = fopen($_FILES['userfile1']['tmp_name'], "rb");
$commentslib->add_thread_attachment(
$forum_info, $qId, $fp, '',
$_FILES['userfile1']['name'],
$_FILES['userfile1']['type'],
$_FILES['userfile1']['size']
);
} else {
$smarty->assign('msg', $tikilib->uploaded_file_error($_FILES['userfile1']['error']));
$smarty->display("error.tpl");
die;
}
}
//END ATTACHMENT PROCESSING
$object = explode(':', $comments_objectId );
if( $object[0] == 'forum' && ! empty($_REQUEST["comments_grandParentId"] )) {
$parent_id = $_REQUEST["comments_grandParentId"];
} else {
$parent_id = $_REQUEST["comments_parentId"];
}
$qId = $commentslib->post_new_comment($comments_objectId, $parent_id,
$user,
$_REQUEST["comments_title"],
$_REQUEST["comments_data"],
$message_id, $in_reply_to, 'n', '', '', isset($_REQUEST['contributions'])? $_REQUEST['contributions']: '');
if ($object[0] != "forum") {
$smarty->assign("comments_parentId", 0); // to display all the comments
$_REQUEST["comments_parentId"] = 0;
}
$_REQUEST["comments_reply_threadId"] = $_REQUEST["comments_parentId"]; // to have the right re:
$smarty->assign("comments_reply_threadId", $_REQUEST["comments_parentId"]); // without the flag
} else {
$qId = $_REQUEST["comments_threadId"];
if (($tiki_p_edit_comments == 'y' && (!isset($forum_mode) || $forum_mode == 'n'))
|| (($tiki_p_forum_post == 'y' || $tiki_p_admin_forum == 'y') && isset($forum_mode) && $forum_mode == 'y' )
|| ($commentslib->user_can_edit_post($user, $_REQUEST["comments_threadId"]))) {
$commentslib->update_comment($_REQUEST["comments_threadId"], $_REQUEST["comments_title"],
$_REQUEST["comment_rating"], $_REQUEST["comments_data"], 'n', '', '', $comments_objectId, isset($_REQUEST['contributions'])? $_REQUEST['contributions']: '');
}
$smarty->assign('was_queued', 'n');
if ( $_REQUEST["comments_threadId"] == 0 ) {
$message_id = '';
$qId = $commentslib->post_new_comment($comments_objectId, $parent_id,
$user,
$_REQUEST["comments_title"],
$_REQUEST["comments_data"],
$message_id, $in_reply_to, 'n', '', '', isset($_REQUEST['contributions'])? $_REQUEST['contributions']: '');
if ($object[0] != "forum") {
$smarty->assign("comments_parentId", 0); // to display all the comments
$_REQUEST["comments_parentId"] = 0;
}
$_REQUEST["comments_reply_threadId"] = $_REQUEST["comments_parentId"]; // to have the right re:
$smarty->assign("comments_reply_threadId", $_REQUEST["comments_parentId"]); // without the flag
} else {
$qId = $_REQUEST["comments_threadId"];
if (($tiki_p_edit_comments == 'y' && (!isset($forum_mode) || $forum_mode == 'n'))
|| (($tiki_p_forum_post == 'y' || $tiki_p_admin_forum == 'y') && isset($forum_mode) && $forum_mode == 'y' )
|| ($commentslib->user_can_edit_post($user, $_REQUEST["comments_threadId"]))) {
$commentslib->update_comment($_REQUEST["comments_threadId"], $_REQUEST["comments_title"],
$_REQUEST["comment_rating"], $_REQUEST["comments_data"], 'n', '', '', $comments_objectId, isset($_REQUEST['contributions'])? $_REQUEST['contributions']: '');
}
}
}
if (isset($_REQUEST['contributions']))
unset($_REQUEST['contributions']);
......
# $Rev$
# $Date: 2007-08-09 21:33:59 $
# $Author: sylvieg $
# $Date: 2007-08-13 08:57:47 $
# $Author: nyloth $
# $Name: not supported by cvs2svn $
# phpMyAdmin MySQL-Dump
# version 2.5.1
......@@ -1501,6 +1501,7 @@ CREATE TABLE tiki_forums_queue (
topic_smiley varchar(80) default NULL,
topic_title varchar(240) default NULL,
summary varchar(240) default NULL,
in_reply_to varchar(128) default NULL,
PRIMARY KEY (qId)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
# --------------------------------------------------------
......
# $Header: /cvsroot/tikiwiki/tiki/db/tiki_1.9to1.10.sql,v 1.197 2007-08-11 16:36:33 tombombadilom Exp $
# $Header: /cvsroot/tikiwiki/tiki/db/tiki_1.9to1.10.sql,v 1.198 2007-08-13 08:57:48 nyloth Exp $
# The following script will update a tiki database from verion 1.9 to 1.10
#
......@@ -1485,3 +1485,6 @@ INSERT INTO users_permissions (permName, permDesc, level, type) VALUES ('tiki_p_
INSERT INTO users_permissions (permName, permDesc, level, type) VALUES ('tiki_p_assign_perm_mypage', 'Can assign perms to mypage', 'admin', 'mypage');
INSERT INTO users_permissions (permName, permDesc, level, type) VALUES ('tiki_p_assign_perm_component', 'Can assign perms to component', 'admin', 'component');
DELETE FROM users_permissions where type = 'component';
#2007-08-13 nyloth
ALTER TABLE tiki_forums_queue ADD COLUMN `in_reply_to` varchar(128) default NULL;
<?php
// $Header: /cvsroot/tikiwiki/tiki/lib/commentslib.php,v 1.161 2007-08-10 13:34:06 guidoscherp Exp $
// $Header: /cvsroot/tikiwiki/tiki/lib/commentslib.php,v 1.162 2007-08-13 08:57:48 nyloth Exp $
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
header("location: index.php");
......@@ -502,7 +502,7 @@ class Comments extends TikiLib {
/* queue management */
function replace_queue($qId, $forumId, $object, $parentId, $user, $title, $data, $type = 'n', $topic_smiley = '', $summary = '',
$topic_title = '') {
$topic_title = '', $in_reply_to = '') {
// timestamp
$hash2 = md5($title . $data);
......@@ -524,22 +524,23 @@ class Comments extends TikiLib {
`topic_title`=?,
`topic_smiley`=?,
`summary` = ?,
`timestamp` = ?
`timestamp` = ?,
`in_reply_to` = ?
where `qId`=?
";
$this->query($query,array($object,$parentId,$user,$title,$data,$forumId,$type,$hash2,$topic_title,$topic_smiley,$summary,(int)$this->now,$qId));
$this->query($query,array($object,$parentId,$user,$title,$data,$forumId,$type,$hash2,$topic_title,$topic_smiley,$summary,(int)$this->now,$in_reply_to,$qId));
return $qId;
} else {
$query = "insert into
`tiki_forums_queue`(`object`, `parentId`, `user`,
`title`, `data`, `type`, `topic_smiley`, `summary`,
`timestamp`, `topic_title`, `hash`, `forumId`)
values(?,?,?,?,?,?,?,?,?,?,?,?)";
`timestamp`, `topic_title`, `hash`, `forumId`, `in_reply_to`)
values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
$this->query($query, array($object, $parentId, $user,
$title, $data, $type, $topic_smiley, $summary, (int)$this->now,
$topic_title, $hash2, $forumId));
$topic_title, $hash2, $forumId, $in_reply_to));
$qId = $this->getOne("select max(`qId`) from
`tiki_forums_queue` where `hash`=? and
`timestamp`=?",array($hash2,(int)$this->now));
......@@ -610,7 +611,7 @@ class Comments extends TikiLib {
$threadId = $this->post_new_comment(
'forum:' . $info['forumId'], $info['parentId'],
$info['user'], $info['title'], $info['data'],
$message_id, '', //in_reply_to
$message_id, $info['in_reply_to'],
$info['type'],
$info['summary'], $info['topic_smiley']
);
......
......@@ -6,6 +6,7 @@
<h3>{tr}Edit queued message{/tr}</h3>
<form method="post" action="tiki-forum_queue.php">
<input type="hidden" name="forumId" value="{$forumId|escape}" />
<input type="hidden" name="in_reply_to" value="{$msg_info.in_reply_to|escape}" />
<input type="hidden" name="qId" value="{$smarty.request.qId|escape}" />
<table class="normal">
<tr>
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-forum_queue.php,v 1.16 2007-03-06 19:29:48 sylvieg Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-forum_queue.php,v 1.17 2007-08-13 08:57:47 nyloth Exp $
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -118,6 +118,9 @@ if (isset($_REQUEST['qId'])) {
if (!isset($_REQUEST['topic_title']))
$_REQUEST['topic_title'] = '';
if (!isset($_REQUEST['in_reply_to']))
$_REQUEST['in_reply_to'] = '';
if (!isset($_REQUEST['parentId']))
$_REQUEST['parentId'] = $msg_info['parentId'];
......@@ -129,7 +132,7 @@ if (isset($_REQUEST['qId'])) {
$commentslib->replace_queue($_REQUEST['qId'], $_REQUEST['forumId'], 'forum' . $_REQUEST['forumId'], $_REQUEST['parentId'],
$user, $_REQUEST['title'], $_REQUEST['data'], $_REQUEST['type'], $_REQUEST['topic_smiley'], $_REQUEST['summary'],
$_REQUEST['topic_title']);
$_REQUEST['topic_title'], $_REQUEST['in_reply_to']);
unset ($_REQUEST['qId']);
}
......@@ -160,6 +163,9 @@ if (isset($_REQUEST['qId'])) {
if (!isset($_REQUEST['topic_title']))
$_REQUEST['topic_title'] = '';
if (!isset($_REQUEST['in_reply_to']))
$_REQUEST['in_reply_to'] = '';
if (!isset($_REQUEST['parentId']))
$_REQUEST['parentId'] = $msg_info['parentId'];
......@@ -171,7 +177,7 @@ if (isset($_REQUEST['qId'])) {
$commentslib->replace_queue($_REQUEST['qId'], $_REQUEST['forumId'], 'forum' . $_REQUEST['forumId'], $_REQUEST['parentId'],
$user, $_REQUEST['title'], $_REQUEST['data'], $_REQUEST['type'], $_REQUEST['topic_smiley'], $_REQUEST['summary'],
$_REQUEST['topic_title']);
$_REQUEST['topic_title'], $_REQUEST['in_reply_to']);
$commentslib->approve_queued($_REQUEST['qId']);
unset ($_REQUEST['qId']);
}
......@@ -193,11 +199,14 @@ if (isset($_REQUEST['qId'])) {
if (!isset($_REQUEST['topic_title']))
$_REQUEST['topic_title'] = '';
if (!isset($_REQUEST['in_reply_to']))
$_REQUEST['in_reply_to'] = '';
$_REQUEST['parentId'] = 0;
$_REQUEST['type'] = 'n';
$commentslib->replace_queue($_REQUEST['qId'], $_REQUEST['forumId'], 'forum' . $_REQUEST['forumId'], $_REQUEST['parentId'],
$user, $_REQUEST['title'], $_REQUEST['data'], $_REQUEST['type'], $_REQUEST['topic_smiley'], $_REQUEST['summary'],
$_REQUEST['topic_title']);
$_REQUEST['topic_title'], $_REQUEST['in_reply_to']);
unset ($_REQUEST['qId']);
}
}
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-view_forum.php,v 1.118 2007-08-10 13:42:39 guidoscherp Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-view_forum.php,v 1.119 2007-08-13 08:57:47 nyloth Exp $
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -267,9 +267,9 @@ if ($tiki_p_admin_forum == 'y' || $tiki_p_forum_post_topic == 'y') {
&& ! ( $feature_contribution == 'y' && $feature_contribution_mandatory_forum == 'y' && empty($_REQUEST['contributions']) )
) {
if ($tiki_p_admin_forum == 'y' || $commentslib->user_can_post_to_forum($user, $_REQUEST["forumId"])) {
//Replace things between square brackets by links
// no need to strip, & replaced by &lt; on display anyway
#$_REQUEST["comments_data"] = strip_tags($_REQUEST["comments_data"]);
// Remove HTML tags and empty lines at the end of the posted comment
$_REQUEST["comments_data"] = rtrim(strip_tags($_REQUEST["comments_data"]));
if ($tiki_p_admin_forum != 'y') {
$_REQUEST["comment_topictype"] = 'n';
......@@ -294,7 +294,7 @@ if ($tiki_p_admin_forum == 'y' || $tiki_p_forum_post_topic == 'y') {
$qId = $commentslib->replace_queue(0, $_REQUEST['forumId'], $comments_objectId, 0,
$user, $_REQUEST["comments_title"], $_REQUEST["comments_data"], $_REQUEST["comment_topictype"],
$_REQUEST['comment_topicsmiley'], $_REQUEST["comment_topicsummary"], $_REQUEST["comments_title"]);
$_REQUEST['comment_topicsmiley'], $_REQUEST["comment_topicsummary"], $_REQUEST["comments_title"], '');
// PROCESS ATTACHMENT HERE
if ($qId && isset($_FILES['userfile1']) && !empty($_FILES['userfile1']['name'])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment