20 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
22 include_once XOOPS_ROOT_PATH . '/class/xoopstree.php';
23 require_once XOOPS_ROOT_PATH . '/class/xoopsobject.php';
24 include_once XOOPS_ROOT_PATH . '/language/' .
$GLOBALS['xoopsConfig']['language'] . '/comment.php';
26 $GLOBALS['xoopsLogger']->addDeprecated("'/class/xoopscommments.php' is deprecated since XOOPS 2.5.4, please use 'kernel/comment.php' instead.");
46 $this->ctable = $ctable;
66 $this->assignVars($id);
68 $this->load(intval($id));
81 $sql =
"SELECT * FROM " . $this->ctable .
" WHERE comment_id=" . $id;
82 $arr = $this->db->fetchArray($this->db->query(
$sql));
83 $this->assignVars($arr);
93 if (!$this->cleanVars()) {
96 foreach ($this->cleanVars as $k => $v) {
100 if (empty($comment_id)) {
102 $comment_id = $this->db->genId($this->ctable .
"_comment_id_seq");
103 $sql = sprintf(
"INSERT INTO %s (comment_id, pid, item_id, date, user_id, ip, subject, comment, nohtml, nosmiley, noxcode, icon) VALUES (%u, %u, %u, %u, %u, '%s', '%s', '%s', %u, %u, %u, '%s')", $this->ctable, $comment_id, $pid, $item_id, time(),
$user_id, $ip, $subject,
$comment, $nohtml, $nosmiley, $noxcode,
$icon);
105 $sql = sprintf(
"UPDATE %s SET subject = '%s', comment = '%s', nohtml = %u, nosmiley = %u, noxcode = %u, icon = '%s' WHERE comment_id = %u", $this->ctable, $subject,
$comment, $nohtml, $nosmiley, $noxcode,
$icon, $comment_id);
111 if (empty($comment_id)) {
112 $comment_id = $this->db->getInsertId();
114 if ($isnew !=
false) {
115 $sql = sprintf(
"UPDATE %s SET posts = posts+1 WHERE uid = %u", $this->db->prefix(
"users"),
$user_id);
117 echo
"Could not update user posts.";
130 $sql = sprintf(
"DELETE FROM %s WHERE comment_id = %u", $this->ctable, $this->getVar(
'comment_id'));
134 $sql = sprintf(
"UPDATE %s SET posts = posts-1 WHERE uid = %u", $this->db->prefix(
"users"), $this->getVar(
"user_id"));
136 echo
"Could not update user posts.";
138 $mytree =
new XoopsTree($this->ctable,
"comment_id",
"pid");
139 $arr = $mytree->getAllChild($this->getVar(
"comment_id"),
"comment_id");
142 for (
$i = 0;
$i < $size;
$i++) {
143 $sql = sprintf(
"DELETE FROM %s WHERE comment_bid = %u", $this->ctable, $arr[
$i][
'comment_id']);
145 echo
"Could not delete comment.";
147 $sql = sprintf(
"UPDATE %s SET posts = posts-1 WHERE uid = %u", $this->db->prefix(
"users"), $arr[
$i][
'user_id']);
149 echo
"Could not update user posts.";
161 function getCommentTree()
163 $mytree =
new XoopsTree($this->ctable,
"comment_id",
"pid");
165 $tarray = $mytree->getChildTreeArray($this->getVar(
"comment_id"),
"comment_id");
166 foreach ($tarray as $ele) {
187 $where_query =
" WHERE";
189 $where_query .=
" $c AND";
191 $where_query = substr($where_query, 0, - 4);
194 $sql =
"SELECT comment_id FROM " . $this->ctable .
"$where_query ORDER BY $orderby";
196 while ($myrow = $this->db->fetchArray(
$result)) {
197 $ret[] = $myrow[
'comment_id'];
200 $sql =
"SELECT * FROM " . $this->ctable .
"" . $where_query .
" ORDER BY $orderby";
202 while ($myrow = $this->db->fetchArray(
$result)) {
217 function printNavBar($item_id, $mode =
"flat", $order = 1)
220 echo
"<form method='get' action='" .
$_SERVER[
'PHP_SELF'] .
"'><table width='100%' border='0' cellspacing='1' cellpadding='2'><tr><td class='bg1' align='center'><select name='mode'><option value='nocomments'";
221 if ($mode ==
"nocomments") {
222 echo
" selected='selected'";
224 echo
">" .
_NOCOMMENTS .
"</option><option value='flat'";
225 if ($mode ==
'flat') {
226 echo
" selected='selected'";
228 echo
">" .
_FLAT .
"</option><option value='thread'";
229 if ($mode ==
"thread" || $mode ==
"") {
230 echo
" selected='selected'";
232 echo
">" .
_THREADED .
"</option></select><select name='order'><option value='0'";
234 echo
" selected='selected'";
238 echo
" selected='selected'";
240 echo
">" .
_NEWESTFIRST .
"</option></select><input type='hidden' name='item_id' value='" . intval($item_id) .
"' /><input type='submit' value='" .
_CM_REFRESH .
"' />";
241 if ($xoopsConfig[
'anonpost'] == 1 || $xoopsUser) {
242 if ($mode !=
"flat" || $mode !=
"nocomments" || $mode !=
"thread") {
245 echo
" <input type='button' onclick='location=\"newcomment.php?item_id=" . intval($item_id) .
"&order=" . intval($order) .
"&mode=" . $mode .
"\"' value='" .
_CM_POSTCOMMENT .
"' />";
247 echo
"</td></tr></table></form>";
254 function showThreadHead()
267 function showThreadPost($order, $mode, $adminview = 0, $color_num = 1)
274 if ($this->getVar(
"user_id") != 0) {
282 if ($this->getVar(
"icon") != null && $this->getVar(
"icon") !=
"") {
283 $subject_image =
"<a name='" . $this->getVar(
"comment_id") .
"' id='" . $this->getVar(
"comment_id") .
"'></a><img src='" . XOOPS_URL .
"/images/subject/" . $this->getVar(
"icon") .
"' alt='' />";
285 $subject_image =
"<a name='" . $this->getVar(
"comment_id") .
"' id='" . $this->getVar(
"comment_id") .
"'></a><img src='" . XOOPS_URL .
"/images/icons/no_posticon.gif' alt='' />";
288 $ip_image =
"<img src='" . XOOPS_URL .
"/images/icons/ip.gif' alt='" . $this->getVar(
"ip") .
"' />";
290 $ip_image =
"<img src='" . XOOPS_URL .
"/images/icons/ip.gif' alt='' />";
292 if ($adminview || ($xoopsUser && $this->getVar(
"user_id") == $xoopsUser->getVar(
"uid"))) {
293 $edit_image =
"<a href='editcomment.php?comment_id=" . $this->getVar(
"comment_id") .
"&mode=" . $mode .
"&order=" . intval($order) .
"'><img src='" . XOOPS_URL .
"/images/icons/edit.gif' alt='" .
_EDIT .
"' /></a>";
295 if ($xoopsConfig[
'anonpost'] || $xoopsUser) {
296 $reply_image =
"<a href='replycomment.php?comment_id=" . $this->getVar(
"comment_id") .
"&mode=" . $mode .
"&order=" . intval($order) .
"'><img src='" . XOOPS_URL .
"/images/icons/reply.gif' alt='" .
_REPLY .
"' /></a>";
299 $delete_image =
"<a href='deletecomment.php?comment_id=" . $this->getVar(
"comment_id") .
"&mode=" . $mode .
"&order=" . intval($order) .
"'><img src='" . XOOPS_URL .
"/images/icons/delete.gif' alt='" .
_DELETE .
"' /></a>";
303 $text = $this->getVar(
"comment");
304 if (
$poster->getVar(
"attachsig")) {
305 $text .=
"<p><br />_________________<br />" .
$poster->user_sig() .
"</p>";
310 $posts .=
$poster->getVar(
"posts");
312 $user_from .=
$poster->getVar(
"user_from");
314 if ($rank[
'image'] !=
"") {
315 $rank[
'image'] =
"<img src='" .
XOOPS_UPLOAD_URL .
"/" . $rank[
'image'] .
"' alt='' />";
319 $online_image =
"<span style='color:#ee0000;font-weight:bold;'>" . _ONLINE .
"</span>";
323 $profile_image =
"<a href='" . XOOPS_URL .
"/userinfo.php?uid=" .
$poster->getVar(
"uid") .
"'><img src='" . XOOPS_URL .
"/images/icons/profile.gif' alt='" .
_PROFILE .
"' /></a>";
325 $pm_image =
"<a href='javascript:openWithSelfMain(\"" . XOOPS_URL .
"/pmlite.php?send2=1&to_userid=" .
$poster->getVar(
"uid") .
"\",\"pmlite\",450,370);'><img src='" . XOOPS_URL .
"/images/icons/pm.gif' alt='" . sprintf(
_SENDPMTO,
$poster->getVar(
"uname",
"E")) .
"' /></a>";
329 if (
$poster->getVar(
"user_viewemail")) {
330 $email_image =
"<a href='mailto:" .
$poster->getVar(
"email",
"E") .
"'><img src='" . XOOPS_URL .
"/images/icons/email.gif' alt='" . sprintf(
_SENDEMAILTO,
$poster->getVar(
"uname",
"E")) .
"' /></a>";
334 $posterurl =
$poster->getVar(
"url");
335 if ($posterurl !=
"") {
336 $www_image =
"<a href='$posterurl' rel='external'><img src='" . XOOPS_URL .
"/images/icons/www.gif' alt='" .
_VISITWEBSITE .
"' /></a>";
340 if (
$poster->getVar(
"user_icq") !=
"") {
341 $icq_image =
"<a href='http://wwp.icq.com/scripts/search.dll?to=" .
$poster->getVar(
"user_icq",
"E") .
"'><img src='" . XOOPS_URL .
"/images/icons/icq_add.gif' alt='" .
_ADD .
"' /></a>";
345 if (
$poster->getVar(
"user_aim") !=
"") {
346 $aim_image =
"<a href='aim:goim?screenname=" .
$poster->getVar(
"user_aim",
"E") .
"&message=Hi+" .
$poster->getVar(
"user_aim") .
"+Are+you+there?'><img src='" . XOOPS_URL .
"/images/icons/aim.gif' alt='aim' /></a>";
350 if (
$poster->getVar(
"user_yim") !=
"") {
351 $yim_image =
"<a href='http://edit.yahoo.com/config/send_webmesg?.target=" .
$poster->getVar(
"user_yim",
"E") .
"&.src=pg'><img src='" . XOOPS_URL .
"/images/icons/yim.gif' alt='yim' /></a>";
355 if (
$poster->getVar(
"user_msnm") !=
"") {
356 $msnm_image =
"<a href='" . XOOPS_URL .
"/userinfo.php?uid=" .
$poster->getVar(
"uid") .
"'><img src='" . XOOPS_URL .
"/images/icons/msnm.gif' alt='msnm' /></a>";
360 showThread($color_num, $subject_image, $this->getVar(
"subject"), $text, $post_date, $ip_image, $reply_image, $edit_image, $delete_image,
$poster->getVar(
"uname"), $rank[
'title'], $rank[
'image'], $avatar_image, $reg_date, $posts, $user_from, $online_image, $profile_image, $pm_image, $email_image, $www_image, $icq_image, $aim_image, $yim_image, $msnm_image);
362 showThread($color_num, $subject_image, $this->getVar(
"subject"), $this->getVar(
"comment"), $post_date, $ip_image, $reply_image, $edit_image, $delete_image, $xoopsConfig[
'anonymous']);
370 function showThreadFoot()
380 function showTreeHead($width =
"100%")
382 echo
"<table border='0' class='outer' cellpadding='0' cellspacing='0' align='center' width='$width'><tr class='bg3' align='center'><td colspan='3'>" .
_CM_REPLIES .
"</td></tr><tr class='bg3' align='left'><td width='60%' class='fg2'>" .
_CM_TITLE .
"</td><td width='20%' class='fg2'>" .
_CM_POSTER .
"</td><td class='fg2'>" .
_CM_POSTED .
"</td></tr>";
392 function showTreeItem($order, $mode, $color_num)
394 if ($color_num == 1) {
399 $prefix = str_replace(
".",
" ", $this->getVar(
"prefix"));
401 if ($this->getVar(
"icon") !=
"") {
402 $icon =
"subject/" . $this->getVar(
"icon",
"E");
404 $icon =
"icons/no_posticon.gif";
406 echo
"<tr class='$bg' align='left'><td>" . $prefix .
"<img src='" . XOOPS_URL .
"/images/" .
$icon .
"'> <a href='" .
$_SERVER[
'PHP_SELF'] .
"?item_id=" . $this->getVar(
"item_id") .
"&comment_id=" . $this->getVar(
"comment_id") .
"&mode=" . $mode .
"&order=" . $order .
"#" . $this->getVar(
"comment_id") .
"'>" . $this->getVar(
"subject") .
"</a></td><td><a href='" . XOOPS_URL .
"/userinfo.php?uid=" . $this->getVar(
"user_id") .
"'>" .
XoopsUser::getUnameFromId($this->getVar(
"user_id")) .
"</a></td><td>" .
$date .
"</td></tr>";
413 function showTreeFoot()
415 echo
"</table><br />";