/** * testDeleteOtherUserComment * */ public function testDeleteOtherUserComment() { $this->goIntoLoginStatus('Comments'); $result = $this->testAction('/comments/delete/4?return_url=/sashimi', array('method' => 'POST', 'return' => 'contents')); $this->assertContains('/sashimi', $this->headers['Location']); App::uses('Comment', 'Model'); $comment = new Comment(); $comment->useDbConfig = 'test'; $comment->recursive = -1; $rec = $comment->read(null, 4); $this->assertTrue(is_array($rec) && $rec["Comment"]["content"] === "てすと4"); }
function insert_comment() { global $commentownerid, $link, $db, $current_user; // Check if is a POST of a comment if ($_POST['link_id'] == $link->id && $current_user->authenticated && $_POST['user_id'] == $current_user->user_id && $_POST['randkey'] > 0 && strlen($_POST['comment_content']) > 0) { require_once mnminclude . 'comment.php'; $comment = new Comment(); $comment->id = $link->commentid; $comment->read(); $comment->link = $link->id; $comment->randkey = $_POST['randkey']; $comment->author = $commentownerid; //$_POST['user_id']; $comment->content = $_POST['comment_content']; $comment->store(); header('Location: ' . getmyurl('story', $_GET['id'])); die; } }
// The source code packaged with this file is Free Software, Copyright (C) 2005 by // Ricardo Galli <gallir at uib dot es>. // It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise. // You can get copies of the licenses here: // http://www.affero.org/oagpl.html // AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING". if (!defined('mnmpath')) { include '../config.php'; include mnminclude . 'html1.php'; include mnminclude . 'link.php'; require_once mnminclude . 'comment.php'; } if (!empty($_REQUEST['id']) && is_numeric($_REQUEST['id'])) { $comment = new Comment(); $comment->id = intval($_REQUEST['id']); if (!$comment->read()) { die; } } else { header('Location: http://' . get_server_name() . $globals['base_url']); die; } $link = new Link(); $link->id = $comment->link; if (!$link->read()) { header('Location: http://' . get_server_name() . $globals['base_url']); die; } //$globals['link']=$link; //$globals['link_id']=$link->id; if ($_POST['process'] == 'editcomment') {
function insert_comment() { global $commentownerid, $link, $db, $current_user; // Check if is a POST of a comment if (sanitize($_POST['link_id'], 3) == $link->id && $current_user->authenticated && sanitize($_POST['user_id'], 3) == $current_user->user_id && is_numeric(sanitize($_POST['randkey'], 3)) && sanitize($_POST['randkey'], 3) > 0 && sanitize($_POST['comment_content'], 4) != '') { require_once mnminclude . 'comment.php'; $comment = new Comment(); $comment->id = $link->commentid; $comment->read(); $comment->link = $link->id; $comment->randkey = sanitize($_POST['randkey'], 3); $comment->author = $commentownerid; $comment->content = sanitize($_POST['comment_content'], 4); $comment->store(); header('Location: ' . getmyurl('story', sanitize($_POST['link_id'], 3))); die; } }
// You can get copies of the licenses here: // http://www.affero.org/oagpl.html // AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING". if (! defined('mnmpath')) { include('../config.php'); include(mnminclude.'html1.php'); include(mnminclude.'link.php'); require_once(mnminclude.'comment.php'); } if (!empty($_REQUEST['id']) && is_numeric($_REQUEST['id'])) { $comment = new Comment; $comment->id = intval($_REQUEST['id']); if (! $comment->read()) die; } else { header('Location: http://'.get_server_name().$globals['base_url']); die; } $link = new Link; $link->id = $comment->link; if (! $link->read() ) { header('Location: http://'.get_server_name().$globals['base_url']); die; } //$globals['link']=$link; //$globals['link_id']=$link->id;
function do_shaken_comments() { global $db, $rows, $user, $offset, $page_size, $globals; do_user_subheader(array($user->username => get_user_uri($user->username, 'commented'), _('conversación') . $globals['extra_comment_conversation'] => get_user_uri($user->username, 'conversation'), _('votados') => get_user_uri($user->username, 'shaken_comments'), _('favoritos') => get_user_uri($user->username, 'favorite_comments')), 2); $comment = new Comment(); $rows = -1; $db->get_var("SELECT count(*) FROM votes, comments WHERE vote_type='comments' and vote_user_id={$user->id} and comment_id = vote_link_id and comment_user_id != vote_user_id"); $comments = $db->get_results("SELECT vote_link_id as id, vote_value as value FROM votes, comments WHERE vote_type='comments' and vote_user_id={$user->id} and comment_id = vote_link_id and comment_user_id != vote_user_id ORDER BY vote_date DESC LIMIT {$offset},{$page_size}"); if ($comments) { echo '<ol class="comments-list">'; foreach ($comments as $c) { $comment->id = $c->id; if ($c->value > 0) { $color = '#00d'; } else { $color = '#f00'; } $comment->read(); if ($comment->author != $user->id && !$comment->admin) { echo '<li>'; $comment->print_summary(false, 1000, false); echo '<div class="box" style="margin:0 0 -16px 0;background:' . $color . ';position:relative;top:-34px;left:30px;width:30px;height:16px;border-color:' . $color . ';opacity: 0.5"></div>'; echo '</li>'; } } echo "</ol>\n"; } }
function print_comment_list($comments, $user) { global $globals, $current_user; $link = new Link; $comment = new Comment; foreach ($comments as $dbcomment) { if ($dbcomment->comment_type == 'admin' && ! $current_user->admin) continue; $link->id=$dbcomment->link_id; $comment->id = $dbcomment->comment_id; if ($last_link != $link->id) { $link->read(); echo '<h4>'; echo '<a href="'.$link->get_permalink().'">'. $link->title. '</a>'; echo ' ['.$link->comments.']'; echo '</h4>'; $last_link = $link->id; } $comment->read(); echo '<ol class="comments-list">'; echo '<li>'; $comment->print_summary($link, 2000, false); echo '</li>'; echo "</ol>\n"; } }
function insert_comment() { global $commentownerid, $link, $db, $current_user, $main_smarty, $the_template; check_actions('story_edit_comment', $vars); // Check if is a POST of a comment if (sanitize($_POST['link_id'], 3) == $link->id && $current_user->authenticated && sanitize($_POST['user_id'], 3) == $current_user->user_id && is_numeric(sanitize($_POST['randkey'], 3)) && sanitize($_POST['randkey'], 3) > 0 && sanitize($_POST['comment_content'], 4) != '') { require_once mnminclude . 'comment.php'; $comment = new Comment(); $comment->id = $link->commentid; $comment->read(); $comment->link = $link->id; $comment->randkey = sanitize($_POST['randkey'], 3); $comment->author = $commentownerid; $comment->content = sanitize($_POST['comment_content'], 4); if (strlen($comment->content) > maxCommentLength) { $main_smarty->assign('url', $_SERVER['REQUEST_URI']); $main_smarty->assign('tpl_center', $the_template . '/comment_errors'); $main_smarty->display($the_template . '/pligg.tpl'); exit; } $vars['comment'] = $comment->id; $vars = array('comment' => &$comment); check_actions('after_comment_edit', $vars); if ($vars['comment']->status) { $comment->status = $vars['comment']->status; } $comment->store(); header('Location: ' . getmyurl('story', sanitize($_POST['link_id'], 3))); die; } }
function do_commented() { global $db, $rows, $user, $offset, $page_size; $link = new Link(); $comment = new Comment(); echo '<h2>' . _('comentarios') . '</h2><br />'; $rows = $db->get_var("SELECT count(*) FROM comments WHERE comment_user_id={$user->id}"); $comments = $db->get_results("SELECT comment_id, link_id FROM comments, links WHERE comment_user_id={$user->id} and link_id=comment_link_id ORDER BY comment_date desc LIMIT {$offset},{$page_size}"); if ($comments) { foreach ($comments as $dbcomment) { $link->id = $dbcomment->link_id; $comment->id = $dbcomment->comment_id; if ($last_link != $link->id) { $link->read(); echo '<h4>'; echo '<a href="' . $link->get_permalink() . '">' . $link->title . '</a>'; echo ' [' . $link->comments . ']'; echo '</h4>'; $last_link = $link->id; } $comment->read(); echo '<ol class="comments-list">'; $comment->print_summary($link, 2000, false); echo "</ol>\n"; } } }
function get_comments() { global $db, $main_smarty, $current_user, $CommentOrder, $link; //Set comment order to 1 if it's not set in the config.php if (!isset($CommentOrder)) { $CommentOrder = 1; } if ($CommentOrder == 1) { $CommentOrderBy = "comment_votes DESC, comment_date DESC"; } if ($CommentOrder == 2) { $CommentOrderBy = "comment_date DESC"; } if ($CommentOrder == 3) { $CommentOrderBy = "comment_votes DESC, comment_date ASC"; } if ($CommentOrder == 4) { $CommentOrderBy = "comment_date ASC"; } $comments = $db->get_col("SELECT comment_id FROM " . table_comments . " WHERE comment_link_id={$link->id} and comment_parent = 0 ORDER BY " . $CommentOrderBy); if ($comments) { echo '<ul id="comments-list">'; require_once mnminclude . 'comment.php'; $comment = new Comment(); foreach ($comments as $comment_id) { $comment->id = $comment_id; $comment->read(); $comment->print_summary($link); $comments2 = $db->get_col("SELECT comment_id FROM " . table_comments . " WHERE comment_parent={$comment_id} ORDER BY " . $CommentOrderBy); if ($comments2) { echo '<ul id="comments-list">'; require_once mnminclude . 'comment.php'; $comment2 = new Comment(); foreach ($comments2 as $comment_id) { $comment2->id = $comment_id; $comment2->read(); $comment2->print_summary($link); } echo "</ul>\n"; } } echo "</ul>\n"; } }
function get_comments($fetch = false) { global $db, $main_smarty, $current_user, $CommentOrder, $link, $cached_comments; //Set comment order to 1 if it's not set in the admin panel if (!isset($CommentOrder)) { $CommentOrder = 1; } if ($CommentOrder == 1) { $CommentOrderBy = "comment_votes DESC, comment_date DESC"; } if ($CommentOrder == 2) { $CommentOrderBy = "comment_date DESC"; } if ($CommentOrder == 3) { $CommentOrderBy = "comment_votes DESC, comment_date ASC"; } if ($CommentOrder == 4) { $CommentOrderBy = "comment_date ASC"; } $output = ''; if (checklevel('god') || checklevel('admin')) { $status_sql = " OR comment_status='moderated'"; } // get all parent comments $comments = $db->get_results("SELECT * FROM " . table_comments . " WHERE (comment_status='published' {$status_sql}) AND comment_link_id={$link->id} and comment_parent = 0 ORDER BY " . $CommentOrderBy); if ($comments) { require_once mnminclude . 'comment.php'; $comment = new Comment(); foreach ($comments as $dbcomment) { $comment->id = $dbcomment->comment_id; $cached_comments[$dbcomment->comment_id] = $dbcomment; $comment->read(); $output .= $comment->print_summary($link, true); // get all child comments $comments2 = $db->get_results("SELECT * FROM " . table_comments . " WHERE (comment_status='published' {$status_sql}) AND comment_parent={$dbcomment->comment_id} ORDER BY " . $CommentOrderBy); if ($comments2) { $output .= '<div class="child-comment">'; require_once mnminclude . 'comment.php'; $comment2 = new Comment(); foreach ($comments2 as $dbcomment2) { $comment2->id = $dbcomment2->comment_id; $cached_comments[$dbcomment2->comment_id] = $dbcomment2; $comment2->read(); $output .= $comment2->print_summary($link, true); } $output .= "</div>\n"; } } if ($fetch == false) { echo $output; } else { return $output; } } }
echo '<h3 style="text-shadow: 0 1px #ccc"><a href="' . $link->get_permalink() . '">' . $link->title . '</a></h3>'; echo '<ol class="comments-list">'; echo '<li>'; $comment->print_summary($link, 10000, true); echo "</li>\n"; echo "</ol>\n"; // Print answers to the comment $sql = "SELECT conversation_from as comment_id FROM conversations, comments WHERE conversation_type='comment' and conversation_to = {$comment->id} and comment_id = conversation_from ORDER BY conversation_from asc LIMIT {$page_size}"; $answers = $db->get_results($sql); if ($answers) { $answer = new Comment(); echo '<div style="padding-left: 40px; padding-top: 10px">' . "\n"; echo '<ol class="comments-list">'; foreach ($answers as $dbanswer) { $answer->id = $dbanswer->comment_id; $answer->read(); echo '<li>'; $answer->print_summary($link); echo '</li>'; } echo "</ol>\n"; echo '</div>' . "\n"; } Comment::print_form($link, 8); echo '</div>'; // Show the error if the comment couldn't be inserted if (!empty($new_comment_error)) { echo '<script type="text/javascript">'; echo '$(function(){alert(\'' . _('Aviso') . ": {$new_comment_error}" . '\')});'; echo '</script>'; }
function do_commented() { global $db, $rows, $user, $offset, $page_size, $globals, $current_user; if ($globals['bot']) { return; } $link = new Link(); $comment = new Comment(); $rows = $db->get_var("SELECT count(*) FROM comments WHERE comment_user_id={$user->id}"); $comments = $db->get_results("SELECT comment_id, link_id, comment_type FROM comments, links WHERE comment_user_id={$user->id} and link_id=comment_link_id ORDER BY comment_date desc LIMIT {$offset},{$page_size}"); if ($comments) { echo '<div class="bookmarks-export-user-stories">'; echo '<a href="' . $globals['base_url'] . 'link_bookmark.php?user_id=' . $user->id . '&option=commented" title="' . _('exportar bookmarks en formato Mozilla') . '" class="bookmarks-export-user-commented"><img src="' . $globals['base_url'] . 'img/common/bookmarks-export-01.png" alt="Mozilla bookmark"/></a>'; echo ' <a href="' . $globals['base_url'] . 'comments_rss2.php?user_id=' . $user->id . '" title="' . _('obtener comentarios en rss2') . '"><img src="' . $globals['base_url'] . 'img/common/rss-button01.png" alt="rss2"/></a>'; echo '</div>'; foreach ($comments as $dbcomment) { if ($dbcomment->comment_type == 'admin' && $current_user->user_level != 'god' && $current_user->user_level != 'admin') { continue; } $link->id = $dbcomment->link_id; $comment->id = $dbcomment->comment_id; if ($last_link != $link->id) { $link->read(); echo '<h4>'; echo '<a href="' . $link->get_permalink() . '">' . $link->title . '</a>'; echo ' [' . $link->comments . ']'; echo '</h4>'; $last_link = $link->id; } $comment->read(); echo '<ol class="comments-list">'; $comment->print_summary($link, 2000, false); echo "</ol>\n"; } } }
$trackback->id = $trackback_id; $trackback->read(); echo '<li class="tab-trackback-entry"><a href="' . $trackback->url . '" rel="nofollow">' . $trackback->title . '</a> [' . preg_replace('/https*:\\/\\/([^\\/]+).*/', "\$1", $trackback->url) . ']</li>' . "\n"; } echo '</ul>'; echo '</fieldset>'; } } $comments = $db->get_col("SELECT comment_id FROM comments WHERE comment_link_id={$link->id} ORDER BY {$order_field} {$limit}"); if ($comments) { echo '<ol class="comments-list">'; require_once mnminclude . 'comment.php'; $comment = new Comment(); foreach ($comments as $comment_id) { $comment->id = $comment_id; $comment->read(); $comment->print_summary($link, 700, true); echo "\n"; } echo "</ol>\n"; } if ($link->date < $globals['now'] - $globals['time_enabled_comments'] || $link->comments >= $globals['max_comments']) { // Comments already closed if ($tab_option == 1) { do_comment_pages($link->comments, $current_page); } echo '<div class="commentform warn">' . "\n"; echo _('comentarios cerrados') . "\n"; echo '</div>' . "\n"; } elseif ($current_user->authenticated && ($current_user->user_karma > $globals['min_karma_for_comments'] || $current_user->user_id == $link->author)) { // User can comment
function get_comments($fetch = false) { global $db, $main_smarty, $current_user, $CommentOrder, $link; //Set comment order to 1 if it's not set in the admin panel if (!isset($CommentOrder)) { $CommentOrder = 1; } if ($CommentOrder == 1) { $CommentOrderBy = "comment_votes DESC, comment_date DESC"; } if ($CommentOrder == 2) { $CommentOrderBy = "comment_date DESC"; } if ($CommentOrder == 3) { $CommentOrderBy = "comment_votes ASC, comment_date DESC"; } if ($CommentOrder == 4) { $CommentOrderBy = "comment_date ASC"; } $output = ''; // get all parent comments $comments = $db->get_col("SELECT comment_id FROM " . table_comments . " WHERE comment_link_id={$link->id} and comment_parent = 0 ORDER BY " . $CommentOrderBy); if ($comments) { require_once mnminclude . 'comment.php'; $comment = new Comment(); foreach ($comments as $comment_id) { $comment->id = $comment_id; $comment->read(); $output .= $comment->print_summary($link, true); // get all child comments $comments2 = $db->get_col("SELECT comment_id FROM " . table_comments . " WHERE comment_parent={$comment_id} ORDER BY " . $CommentOrderBy); if ($comments2) { $output .= '<div style="margin-left:40px">'; require_once mnminclude . 'comment.php'; $comment2 = new Comment(); foreach ($comments2 as $comment_id) { $comment2->id = $comment_id; $comment2->read(); $output .= $comment2->print_summary($link, true); } $output .= "</div>\n"; } } if ($fetch == false) { echo $output; } else { return $output; } } }
function get_comments($fetch = false, $parent = 0, $comment_id = 0, $show_parent = 0) { global $db, $main_smarty, $current_user, $CommentOrder, $link, $cached_comments; //Set comment order to 1 if it's not set in the admin panel if (isset($_GET['comment_sort'])) { setcookie('CommentOrder', $CommentOrder = $_GET['comment_sort'], time() + 60 * 60 * 24 * 180); } elseif (isset($_COOKIE['CommentOrder'])) { $CommentOrder = $_COOKIE['CommentOrder']; } if (!isset($CommentOrder)) { $CommentOrder = 1; } if ($CommentOrder == 1) { $CommentOrderBy = "comment_votes DESC, comment_date DESC"; } if ($CommentOrder == 2) { $CommentOrderBy = "comment_date DESC"; } if ($CommentOrder == 3) { $CommentOrderBy = "comment_votes ASC, comment_date DESC"; } if ($CommentOrder == 4) { $CommentOrderBy = "comment_date ASC"; } $output = ''; if (checklevel('admin') || checklevel('moderator')) { $status_sql = " OR comment_status='moderated'"; } // get all parent comments if ($comment_id != 0) { $comments = $db->get_results("SELECT * \n\t FROM " . table_comments . " \n\t WHERE (comment_status='published' {$status_sql}) AND \n\t comment_link_id={$link->id} AND comment_id = {$comment_id} \n\t ORDER BY " . $CommentOrderBy); } elseif ($show_parent == 1) { $comments = $db->get_results("SELECT * \n\t FROM " . table_comments . " \n\t WHERE (comment_status='published' {$status_sql}) AND \n\t comment_link_id={$link->id} AND comment_id = {$parent} \n\t ORDER BY " . $CommentOrderBy); } else { $comments = $db->get_results("SELECT * \n\t FROM " . table_comments . " \n\t WHERE (comment_status='published' {$status_sql}) AND \n\t comment_link_id={$link->id} AND comment_parent = {$parent} \n\t ORDER BY " . $CommentOrderBy); } if ($comments) { require_once mnminclude . 'comment.php'; $comment = new Comment(); foreach ($comments as $dbcomment) { $comment->id = $dbcomment->comment_id; $cached_comments[$dbcomment->comment_id] = $dbcomment; $comment->read(); $output .= $comment->print_summary($link, true); $output .= "<div class='child-comment'>\n"; if ($comment_id == 0) { $output .= get_comments(true, $dbcomment->comment_id); } $output .= "</div>\n"; } if ($fetch == false) { echo $output; } else { return $output; } } }
function do_commented() { global $db, $main_smarty, $rows, $user, $offset, $page_size, $cached_links, $the_template; $output = ''; $link = new Link(); $comment = new Comment(); $rows = $db->get_var("SELECT count(*) FROM " . table_links . ", " . table_comments . " WHERE comment_status='published' AND comment_user_id={$user->id} AND comment_link_id=link_id"); $links = $db->get_results("SELECT DISTINCT * FROM " . table_links . ", " . table_comments . " WHERE comment_status='published' AND comment_user_id={$user->id} AND comment_link_id=link_id AND (link_status='published' OR link_status='new') ORDER BY link_date DESC LIMIT {$offset},{$page_size}"); if ($links) { foreach ($links as $dblink) { $link->id = $dblink->link_id; $cached_links[$dblink->link_id] = $dblink; $link->read(); $link->fill_smarty($main_smarty); $comment->id = $dblink->comment_id; $comment->read(); $comment->fill_smarty($main_smarty); $output .= $main_smarty->fetch($the_template . '/' . 'user_comment_center.tpl'); } } $main_smarty->assign('user_page', $output); }