コード例 #1
0
ファイル: Comment.php プロジェクト: schwarer2006/wikia
function DisplayComments($input)
{
    global $wgUser, $wgTitle, $wgOut, $wgVoteDirectory;
    $wgOut->addScript("<script type=\"text/javascript\" src=\"extensions/Comments/Comment.js\"></script>\n");
    require_once 'CommentClass.php';
    require_once "{$wgVoteDirectory}/VoteClass.php";
    getValue($scorecard, $input, "Scorecard");
    getValue($allow, $input, "Allow");
    getValue($voting, $input, "Voting");
    getValue($title, $input, "title");
    getValue($userRating, $input, "userrating");
    $Comment = new Comment($wgTitle->mArticleID);
    $Comment->setUser($wgUser->mName, $wgUser->mId);
    $Comment->setAllow($allow);
    $Comment->setVoting($voting);
    $Comment->setTitle($title);
    $Comment->setBool("ShowScorecard", $scorecard);
    $Comment->setBool("ShowUserRating", $userRating);
    if ($_POST['commentid']) {
        $Comment->setCommentID($_POST['commentid']);
        $Comment->delete();
    }
    $output = $Comment->displayOrderForm();
    if ($Comment->ShowScoreCard == 1) {
        $output .= "<div id=\"scorecard\"></div>";
    }
    $output .= "<div id=\"allcomments\">" . $Comment->display() . "</div>";
    $output .= $Comment->diplayForm();
    if ($Comment->ShowScoreCard == 1) {
        $output .= $Comment->displayCommentScorecard($scorecard);
    }
    return $output;
}
コード例 #2
0
 public function actionAdmin()
 {
     // delete comment request
     if (Rays::isPost()) {
         if (isset($_POST['checked_comments'])) {
             $commentIds = $_POST['checked_comments'];
             foreach ($commentIds as $id) {
                 if (!is_numeric($id)) {
                     return;
                 } else {
                     $comment = new Comment();
                     $comment->id = $id;
                     $comment->delete();
                 }
             }
         }
     }
     $curPage = $this->getPage("page");
     $pageSize = $this->getPageSize('pagesize', 10);
     $count = Comment::find()->count();
     $comments = Comment::find()->join("user")->join("topic")->order_desc("id")->range(($curPage - 1) * $pageSize, $pageSize);
     $pager = new RPager('page', $count, $pageSize, RHtml::siteUrl('comment/admin'), $curPage);
     $this->layout = 'admin';
     $this->setHeaderTitle("Comments administration");
     $data = array('count' => $count, 'comments' => $comments, 'pager' => $pager->showPager());
     $this->render('admin', $data, false);
 }
 public function testCounterIncrementsAndDecrementsWhen()
 {
     $post_with_comments = new Post();
     $post_with_comments->title = 'post 1';
     $this->assertTrue($post_with_comments->save());
     $post_without_comments = new Post();
     $post_without_comments->title = 'post 2';
     $this->assertTrue($post_without_comments->save());
     //Create 10 comments, ensure counter increments
     for ($i = 1; $i <= 10; $i++) {
         $comment = new Comment();
         $comment->postId = $post_with_comments->id;
         $comment->text = 'comment ' . $i;
         $this->assertTrue($comment->save());
         $post_with_comments->refresh();
         $post_without_comments->refresh();
         $this->assertEquals($post_with_comments->commentsCount, $i);
         $this->assertEquals($post_without_comments->commentsCount, 0);
     }
     //Delete all comments, ensure counter decrements
     $comments = Comment::find()->all();
     $count = count($comments);
     foreach ($comments as $comment) {
         $this->assertEquals($comment->delete(), 1);
         $count--;
         $post_with_comments->refresh();
         $this->assertEquals($post_with_comments->commentsCount, $count);
     }
 }
コード例 #4
0
ファイル: ModelTest.php プロジェクト: gotcms/gotcms
 /**
  * Test
  *
  * @return void
  */
 public function testSaveWithIdShouldReturnTrue()
 {
     $this->object->setContent('test');
     $this->object->setTemplateId(1);
     $this->object->save();
     $this->assertTrue($this->object->save());
     $this->object->delete();
 }
コード例 #5
0
 public function deleteComment(Comment $comment)
 {
     $post = $comment->post;
     $status = $comment->approved;
     $comment->delete();
     $status === 'yes' ? $post->decrement('comment_count') : '';
     return Redirect::back()->with('success', 'Comment deleted!');
 }
コード例 #6
0
 public function deleteComment(Comment $comment)
 {
     $post = $comment->post;
     $status = $comment->approved;
     $comment->delete();
     $status === 'yes' ? $post->decrement('comment_count') : '';
     /*return Redirect::back()->with('success', 'Commentaire suprimé !');*/
     return Redirect::back()->withMessage("Le commentaire a été supprimé");
 }
コード例 #7
0
 public function performHandlerTasks()
 {
     $comment = new Comment();
     $comment->clauseSafe('author_id', Logbook::current()->authorId());
     $comment->clauseSafe('entry_id', Application::param('entry_id'));
     $comment->clauseSafe('comment_id', Application::param('comment_id'));
     $comment->delete();
     Application::setParam('author_id', Logbook::current()->authorId());
     $this->redirectOnSave();
 }
コード例 #8
0
ファイル: CommentTest.php プロジェクト: radig/comments
 /**
  * Test delete method
  * 
  * @return void
  */
 public function testDelete()
 {
     $this->assertFalse($this->Comment->delete('invalid'));
     $before = $this->Comment->Article->find('first', array('conditions' => array('Article.id' => 1)));
     $this->Comment->id = 1;
     $this->assertTrue($this->Comment->delete());
     $after = $this->Comment->Article->find('first', array('conditions' => array('Article.id' => 1)));
     $this->assertEqual($after['Article']['comments'], $before['Article']['comments'] - 1);
     $this->assertFalse($this->Comment->exists(true));
 }
コード例 #9
0
ファイル: CommentTest.php プロジェクト: rodrigorm/comments
 /**
  * Test delete method
  * 
  * @return void
  */
 public function testDelete()
 {
     $this->assertFalse($this->Comment->delete('invalid'));
     $before = $this->Comment->Article->findById(1);
     $this->Comment->id = 1;
     $this->assertTrue($this->Comment->delete());
     $after = $this->Comment->Article->findById(1);
     $this->assertEqual($after['Article']['comments'], $before['Article']['comments'] - 1);
     $this->assertFalse($this->Comment->exists(true));
 }
コード例 #10
0
 public function controlerJob($maincont)
 {
     if ($maincont->isLoggued()) {
         if (isset($_GET["id"])) {
             $p = new Comment($_GET["id"]);
             $p->delete();
         }
         $maincont->goModule("comment", "admin");
     } else {
         $maincont->goModule("home", "display");
     }
 }
コード例 #11
0
 public function delete()
 {
     $id = $this->request->data['id'];
     App::uses('Comment', 'Model');
     $Model = new Comment();
     $params = array();
     $params['recursive'] = -1;
     $params['fields'] = array('user_id');
     $params['conditions']['id'] = $id;
     if (!($comment = $Model->find('first', $params))) {
         exit;
     }
     if ($this->user['User']['id'] == $comment['Comment']['user_id'] || $this->user['User']['can']['manage_own_events'] || $this->user['User']['can']['manage_events'] || $this->user['User']['can']['full_permissions']) {
         $Model->delete($id);
     }
     exit;
 }
コード例 #12
0
 public function testAddComment()
 {
     $comment = new Comment();
     $comment->id_user = $this->user->id;
     $errors = $comment->validateController();
     $this->assertEquals(3, sizeof($errors));
     // username, repository, comment required
     $nbComments = sizeof($comments = $this->user->comments());
     $this->assertEquals(0, $nbComments);
     $comment->setUsername("jessylenne");
     $comment->setRepository("jessylenne");
     $this->setExpectedExceptionRegExp('Exception', '/Veuillez fournir un commentaire valide/');
     $comment->setComment('<script type="text/javascript">console.log("Yeah Fail!")</script>');
     $this->assertFalse($comment->save());
     $comment->setComment("comment");
     $this->assertTrue($comment->save());
     $this->assertEquals($nbComments + 1, sizeof($this->user->comments()));
     $comment->delete();
 }
コード例 #13
0
ファイル: Comment.php プロジェクト: anht37/winelover_server
 public static function createNewComment($rating_id, $input)
 {
     $comment = new Comment();
     $error_code = ApiResponse::OK;
     $comment->user_id = Session::get('user_id');
     if (!empty($input['content'])) {
         $comment->content = $input['content'];
         $comment->rating_id = $rating_id;
         $check_rating = Rating::check_rating($comment->rating_id);
         if ($check_rating !== false) {
             //update comment_count on rating
             $comment_rating = Rating::where('id', $comment->rating_id)->first();
             if ($comment_rating != null) {
                 $comment_rating->comment_count = $comment_rating->comment_count + 1;
                 $comment_rating->save();
                 $comment->delete();
             }
             $comment_profile = Profile::where('user_id', $comment->user_id)->first();
             if ($comment_profile != null) {
                 $comment_profile->comment_count = $comment_profile->comment_count + 1;
                 $comment_profile->save();
             }
             $comment->save();
             $profile = Profile::where('user_id', $comment->user_id)->first();
             if ($profile->image != null) {
                 $comment->avatar_user = URL::asset($profile->image);
             } else {
                 $comment->avatar_user = $profile->image;
             }
             $comment->first_name = $profile->first_name;
             $comment->last_name = $profile->last_name;
             $data = $comment;
         } else {
             $error_code = ApiResponse::UNAVAILABLE_RATING;
             $data = ApiResponse::getErrorContent(ApiResponse::UNAVAILABLE_RATING);
         }
     } else {
         $error_code = ApiResponse::MISSING_PARAMS;
         $data = $input;
     }
     return array("code" => $error_code, "data" => $data);
 }
コード例 #14
0
 } else {
     if ($comment->parent_type == TYPE_CONTENT) {
         $redirect_url = PA::$url . PA_ROUTE_CONTENT . "/cid=" . $comment->content_id;
     } else {
         if (!empty($_REQUEST['back_page'])) {
             $redirect_url = $_REQUEST['back_page'];
         }
     }
 }
 $cid = $comment->content_id;
 //Content id for which comment has been posted.
 $params = array('comment_info' => array('user_id' => $comment->user_id, 'content_id' => $comment->content_id, 'recipient_id' => $recipient_id), 'permissions' => 'delete_comment');
 if (PermissionsHandler::can_user(PA::$login_uid, $params)) {
     $comment = new Comment();
     $comment->comment_id = $comment_id;
     $comment->delete();
 } else {
     throw new PAException(CONTENT_NOT_AUTHORISED_TO_ACCESS, "You are not authorised to access this page.");
 }
 $msg = 7025;
 //invalidate cache of this content
 if (PA::$network_info) {
     $nid = '_network_' . PA::$network_info->network_id;
 } else {
     $nid = '';
 }
 //unique name
 $cache_id = 'content_' . $cid . $nid;
 CachedTemplate::invalidate_cache($cache_id);
 $redirect_url .= "&msg_id={$msg}";
 /*
コード例 #15
0
function render_main_page_area($user)
{
    global $admin_password;
    $page_url = PA::$url . "/comment_management.php";
    $paging_url = "{$page_url}?";
    // url to pass to the pager object
    $msg = "";
    $path_info = @$_SERVER['PATH_INFO'];
    // see if the user is logged in as an admin
    if ($path_info == "/login") {
        if (@$_REQUEST['admin_password'] == $admin_password) {
            $_SESSION['comment_management_is_admin'] = TRUE;
        } else {
            $msg = "Incorrect password!  Try again...";
        }
    } else {
        if ($path_info == "/logout") {
            $_SESSION['comment_management_is_admin'] = FALSE;
            $msg = "You are now logged out (of admin mode).";
        }
    }
    $is_admin = @$_SESSION['comment_management_is_admin'];
    $limit_set = NULL;
    // set this to an array with keys 'comment_id' to limit display to those keys
    $current_search_terms = NULL;
    // current search terms
    switch ($path_info) {
        case '/analyze_comment':
            $comment_id = (int) @$_REQUEST['comment'];
            if (!$is_admin) {
                $msg = "Sorry, only administrators can analyze comments at the moment :(";
            } elseif ($comment_id) {
                $cmt = new Comment();
                $cmt->load($comment_id);
                $cmt->index_spam_domains();
                $msg = "<p>Analysis of comment {$comment_id}:</p><hr/><p>" . nl2br(htmlspecialchars($cmt->comment)) . "</p><hr/><ul>";
                $hosts = $cmt->get_link_hosts();
                foreach ($hosts as $domain => $links) {
                    $msg .= "<li><b>" . htmlspecialchars($domain) . "</b> (<a href=\"{$page_url}/analyze_domain?domain=" . htmlspecialchars($domain) . "\">analyze</a>): ";
                    $dom = new SpamDomain($domain);
                    if ($dom->blacklisted) {
                        $msg .= " BLACKLISTED";
                    }
                    $msg .= "<ul>";
                    foreach ($links as $link) {
                        list($url, $linktexts) = $link;
                        $msg .= "<li>" . htmlspecialchars($url) . " -> " . implode(" | ", array_map("htmlspecialchars", $linktexts)) . "</li>";
                    }
                    $msg .= "</ul></li>";
                }
                $msg .= "</ul><hr/>";
            }
            break;
        case '/search':
            $current_search_terms = @$_REQUEST['q'];
            if (!$is_admin) {
                $msg = "Sorry, only administrators can search comments at the moment :(";
            } elseif ($current_search_terms) {
                $paging_url = "{$page_url}/search?q=" . urlencode($current_search_terms) . "&";
                $limit_set = Comment::search($current_search_terms);
            }
            break;
        case '/stats':
            $msg = "<p>Stats:</p>";
            list($n) = Dal::query_one("SELECT COUNT(*) FROM {comments}");
            list($n_deleted) = Dal::query_one("SELECT COUNT(*) FROM {comments} WHERE is_active=0");
            $n_active = $n - $n_deleted;
            $msg .= "<li>{$n} comments ({$n_active} active / {$n_deleted} deleted)</li>";
            list($n_ham) = Dal::query_one("SELECT COUNT(*) FROM {comments} WHERE is_active=1 AND spam_state=0");
            $n_spam = $n_active - $n_ham;
            $msg .= "<li>{$n_spam} active+spam / {$n_ham} active+not spam</li>";
            list($n_no_class) = Dal::query_one("SELECT COUNT(*) FROM {comments} WHERE is_active=1 AND akismet_spam IS NULL");
            $msg .= "<li>{$n_no_class} active comments not (yet?) classified by Akismet</li>";
            list($n_akismet_del) = Dal::query_one("SELECT COUNT(*) FROM {comments} WHERE is_active=0 AND akismet_spam=1");
            $msg .= "<li>{$n_akismet_del} comments flagged as spam by akismet and deleted</li>";
            break;
        case '/add_spam_term':
            $spam_term = @$_REQUEST['term'];
            if (!$is_admin) {
                $msg = "Sorry, only administrators can add spam terms at the moment.";
            } elseif ($spam_term) {
                // find the comments
                $matches = Comment::search($spam_term);
                $n_deleted = count($matches);
                // add the term
                Comment::add_spam_term($spam_term);
                // and delete the comments
                $blk_size = 1000;
                $F_fetch_ids = create_function('$item', 'return $item["comment_id"];');
                for ($i = 0; $i < count($matches); $i += $blk_size) {
                    Comment::set_spam_state(array_map($F_fetch_ids, array_slice($matches, $i, $blk_size)), SPAM_STATE_SPAM_WORDS);
                }
                $msg = "Added <b>" . htmlspecialchars($spam_term) . '</b> to the spam term database, and deleted ' . $n_deleted . ' comments containing it.';
            }
            break;
        case '/analyze_domain':
            $domain = @$_REQUEST['domain'];
            if (!$is_admin) {
                $msg = "Sorry, only administrators can analyze domains.";
            } else {
                $msg .= "<p>analysis of domain " . htmlspecialchars($domain) . ":</p><ul>";
                $domain = new SpamDomain($domain);
                foreach ($domain->find_associated_domains() as $r) {
                    $msg .= "<li>" . $r['domain'] . " (" . $r['domain_id'] . "): " . $r['match_count'] . " matches</li>";
                }
                $msg .= "</ul>";
            }
            break;
        case '/blacklist_domain':
            $domain = @$_REQUEST['domain'];
            if (!$is_admin) {
                $msg = "Sorry, only administrators can blacklist domains.";
            } elseif (!trim($domain)) {
                $msg = "Invalid domain";
            } else {
                $dom = new SpamDomain($domain);
                $dom->set_blacklisted(DOMAIN_BLACKLISTED_MANUALLY);
                foreach ($dom->find_associated_domains() as $assoc_domain) {
                    SpamDomain::recalculate_link_counts_for_domain_id($assoc_domain['domain_id']);
                }
            }
            // FALL THROUGH TO /common_domains
        // FALL THROUGH TO /common_domains
        case '/common_domains':
            if (!$is_admin) {
                $msg = "Sorry, only administrators can do this.";
            } else {
                list($total_domains, $total_blacklisted_domains) = SpamDomain::count_domains();
                $msg .= "<p>Most common domains (out of total {$total_domains}, {$total_blacklisted_domains} blacklisted) in comments:</p><ul>";
                foreach (SpamDomain::get_most_common_domains() as $dom) {
                    $msg .= "<li>" . $dom['active_count'] . " times: " . $dom['domain'] . ' ' . ($dom['blacklisted'] ? 'BLACKLISTED' : '') . ' (<a href="' . $page_url . '/blacklist_domain?domain=' . $dom['domain'] . '">blacklist domain</a> | <a href="' . $page_url . '/analyze_domain?domain=' . $dom['domain'] . '">analyze domain</a>)</li>';
                }
                $msg .= "</ul>";
            }
            break;
        case '/akismet_verify_key':
            global $akismet_key;
            if (!$is_admin) {
                $msg = "Sorry, only administrators can access Akismet at the moment.";
            } elseif (!$akismet_key) {
                $msg .= '<p>No Akismet key has been configured - Akismet is not active.</p>';
            } else {
                // global var $_base_url has been removed - please, use PA::$url static variable
                $msg .= "<p>verifying akismet key: {$akismet_key}</p>";
                $ak = new Akismet($akismet_key);
                $msg .= "<p>result: " . var_export($ak->verify_key(PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $user->user_id), TRUE) . "</p>";
            }
            break;
        case '/akismet_check_spam':
            if (!$is_admin) {
                $msg = "Sorry, only administrators can access Akismet at the moment.";
            } else {
                global $akismet_key;
                $msg .= "<p>checking comment for spam</p>";
                $cmt = new Comment();
                try {
                    $cmt->load((int) $_REQUEST['comment']);
                } catch (PAException $e) {
                    if ($e->getCode() != COMMENT_NOT_EXIST) {
                        throw $e;
                    }
                    $msg .= "<p>Comment already deleted.</p>";
                    break;
                }
                $cmt->akismet_check();
                $msg .= "<p>result: " . var_export($cmt->akismet_spam, TRUE) . "</p>";
            }
            break;
        default:
            if (preg_match("~^/delete/(\\d+)\$~", $path_info, $m)) {
                list(, $cid) = $m;
                if (!$is_admin) {
                    $msg = "Sorry, only administrators can delete comments at the moment :(";
                } else {
                    try {
                        $c = new Comment();
                        $c->load((int) $cid);
                        $c->delete();
                        $msg = "Comment deleted.";
                    } catch (PAException $e) {
                        if ($e->code == COMMENT_NOT_EXIST) {
                            $msg = "Comment already deleted.";
                        } else {
                            throw $e;
                        }
                    }
                }
            }
    }
    $per_page = 20;
    // how many comments to show on a page
    // paging
    if ($limit_set !== NULL) {
        $total_comments = count($limit_set);
    } else {
        $total_comments = Comment::count_all_comments($is_admin ? 0 : $user->user_id);
    }
    $pager = new pager($total_comments, $per_page, $paging_url);
    $paging = $pager->getButList(8) . " (total {$total_comments} comments)";
    // main comment list
    if ($limit_set !== NULL) {
        $show_start = max(0, min(($pager->page - 1) * $per_page, $total_comments));
        $show_count = min($per_page, $total_comments - $show_start);
        $limit_set_ids = array_map(create_function('$item', 'return $item["comment_id"];'), array_slice($limit_set, $show_start, $show_count));
        $cmts = Comment::get_selected($limit_set_ids);
    } else {
        $cmts = Comment::get_all_comments($is_admin ? 0 : $user->user_id, $per_page, $pager->page);
    }
    $comments = "";
    foreach ($cmts as $cmt) {
        //      $comments .= "<li>".htmlspecialchars(var_export($cmt, TRUE))."</li>";
        $akismet_result = $cmt['akismet_spam'] ? "spam" : "?";
        $comments .= "<tr><td>" . $cmt['comment_id'] . "</td><td>" . $cmt['content_id'] . "</td><td>" . esc_wbr($cmt['name']) . "</td><td>" . esc_wbr($cmt['email']) . "</td><td>" . esc_wbr($cmt['homepage']) . "</td><td>" . esc_wbr($cmt['subject']) . "</td><td>" . esc_wbr($cmt['comment']) . " {$akismet_result} <a href=\"{$page_url}/analyze_comment?comment=" . $cmt['comment_id'] . "\">analyze</a></td><td>" . esc_wbr($cmt['ip_addr']) . "</td><td>" . '<form method="POST" action="' . PA::$url . '/comment_management.php/delete/' . $cmt['comment_id'] . '?page=' . $pager->page . '"><input type="submit" value="X"></form> <a href="' . $page_url . '/akismet_check_spam?comment=' . $cmt['comment_id'] . '">ak</a></td></tr>';
    }
    if ($is_admin) {
        if ($current_search_terms) {
            $current_search = '<form method="POST" action="' . $page_url . '/add_spam_term"><p>Currently displaying results for: <b>' . htmlspecialchars($current_search_terms) . '</b>. <a href="' . $page_url . '">Show all comments</a>.  <input type="hidden" name="term" value="' . htmlspecialchars($current_search_terms) . '"><input type="submit" value="Blacklist this term"></p></form>';
        } else {
            $current_search = "";
        }
        $your_permissions = <<<EOS
\t<form method="POST" action="{$page_url}/logout"><p>You are an administrator, so all comments in the site will be displayed.  <input type="submit" value="Log out"></p></form>

\t<p><a href="{$page_url}/akismet_verify_key">Verify Akismet key</a> | <a href="{$page_url}/common_domains">Show most common domains</a> | <a href="{$page_url}/stats">Spam statistics</a></p>

\t<form method="GET" action="{$page_url}/search"><p>Search comment content: <input type="text" id="search_q" name="q" size="20"><input type="submit" value="Search"/></p></form>
\t<script language="javascript"><!--
\t    document.getElementById("search_q").focus();
        // --></script>
        {$current_search}
EOS;
    } else {
        $your_permissions = <<<EOS
<p>Showing comments on your blog and groups for which you are moderator.</p>

<form method="POST" action="{$page_url}/login"><p>Or enter the admin password here to adminster the whole site: <input type="password" name="admin_password" size="20"/><input type="submit" value="Log in"/></p></form>
EOS;
    }
    $page_title = "Manage comments";
    global $akismet_key;
    if ($akismet_key) {
        $page_title .= " (Akismet active)";
    } else {
        $page_title .= " (Akismet not configured)";
    }
    $page_html = <<<EOS
<div class="pane comment_manage_pane">

<h1>{$page_title}</h1>

<div id="msg" class="fade">{$msg}</div>

{$your_permissions}

<p>{$paging}</p>

<table class="bulk_comment_summary"><tr>
<td>ID</td>
<td>Post</td>
<td>Name</td>
<td>Email</td>
<td>Website</td>
<td>Subject</td>
<td>Comment</td>
<td>IP</td>
<td>X</td>
</tr>
{$comments}
</table>

</div><!-- comment_manage_pane -->
EOS;
    return $page_html;
}
コード例 #16
0
ファイル: database.php プロジェクト: parmindersingh1/musiclib
        $data = $data . $date . "," . $row[4] . "," . $row[5] . ";";
    }
    $stmt->closeCursor();
    $data = convertToUTF8($data);
    echo $data;
}
//partie suppression
if (isset($_GET['action']) && $_GET['action'] == 1) {
    $notarizealbum = new Notarizealbum($_GET['user'], $_GET['id']);
    $notarizealbum->delete($_GET['user'], $_GET['id']);
}
if (isset($_GET['action']) && $_GET['action'] == 2) {
    $notarizeartist = new Notarizeartist($_GET['user'], $_GET['id']);
    $notarizeartist->delete($_GET['user'], $_GET['id']);
}
if (isset($_GET['action']) && $_GET['action'] == 3) {
    $comment = new Comment($_GET['user'], $_GET['id']);
    $comment->delete($_GET['user'], $_GET['id']);
}
if (isset($_GET['type']) && $_GET['type'] == 'artist') {
    $artist = new Artist($_GET['id']);
    $artist->delete($_GET['id']);
}
if (isset($_GET['type']) && $_GET['type'] == 'album') {
    $album = new Album($_GET['id']);
    $album->delete($_GET['id']);
}
if (isset($_GET['type']) && $_GET['type'] == 'song') {
    $song = new Song($_GET['id']);
    $song->delete($_GET['id']);
}
コード例 #17
0
<?php

require_once "/etc/apache2/capstone-mysql/encrypted-config.php";
require_once "comment.php";
$pdo = connectToEncryptedMySQL("/etc/apache2/data-design/jfindley2.ini");
$comment = new Comment(null, 1, 2, "text", null);
$comment->insert($pdo);
$comment->setCommentText("More text");
$comment->update($pdo);
$comment->delete($pdo);
コード例 #18
0
ファイル: commentTest.php プロジェクト: rick-c/tests
	/**
	 * 
	 */
	public function testCommentInfo()
	{
		// make sure adding info to comment works
		$this->comment->info->test = 'test';
		$this->assertEquals( 'test', $this->comment->info->test );
		$this->comment->update();
		$test_comment = Comment::get($this->comment->id);
		$this->assertEquals( $this->comment->info->test, $test_comment->info->test );
		unset($test_comment);

		// make sure construction works with info
		$new_comment = new Comment();
		$this->assertType( 'CommentInfo', $new_comment->info );
		$this->assertFalse( $new_comment->info->is_key_set() );
		$new_comment->info->test = 'test';
		$new_comment->insert();
		$this->assertTrue( $new_comment->info->is_key_set() );
		$test_comment = Comment::get($new_comment->id);
		$this->assertEquals( $new_comment->info->test, $test_comment->info->test );
		$new_comment->delete();
		unset($test_comment);
	}
コード例 #19
0
 public function delete()
 {
     $thread_id = Param::get('thread_id');
     $comment_id = Param::get('comment_id');
     authorize_user_request($comment_id, self::AUTH_COMMENT_DELETE);
     try {
         Comment::delete($comment_id, $thread_id);
     } catch (PDOException $e) {
         $_SESSION['delete_error'] = true;
     }
     redirect(VIEW_COMMENT_PAGE, array('thread_id' => $thread_id));
 }
コード例 #20
0
            $cache->clearPhoto($photo_data['id']);
        }
        header('Location: ' . BASE_URL . PAGE . ',' . IMAGE_IDENTIFIER . ',' . $photo_data['id'] . ',0,1#comments');
        exit;
    }
} elseif (isset($_SESSION[$settings['session_prefix'] . 'user_id']) && isset($_GET['get_3']) && $_GET['get_3'] == 'edit' && isset($_GET['get_4'])) {
    $template->assign('edit_data', $comment->get_edit_data($_GET['get_4']));
    #$action = 'edit';
} elseif (isset($_POST['edit_save'])) {
    $comment->edit_save();
    if (isset($cache)) {
        $cache->clearPhoto($photo_data['id']);
    }
    header('Location: ' . BASE_URL . PAGE . ',' . IMAGE_IDENTIFIER . ',' . $photo_data['id'] . ',0,1,' . $comment->current_page . '#comments');
} elseif (isset($_SESSION[$settings['session_prefix'] . 'user_id']) && isset($_GET['get_3']) && $_GET['get_3'] == 'delete' && isset($_GET['get_4'])) {
    $comment->delete($_GET['get_4']);
    if (isset($cache)) {
        $cache->clearPhoto($photo_data['id']);
    }
    header('Location: ' . BASE_URL . PAGE . ',' . IMAGE_IDENTIFIER . ',' . $photo_data['id'] . ',0,1,' . $comment->current_page . '#comments');
}
$template->assign('comments', $comment->get_comments());
$template->assign('total_comments', $comment->total_comments);
switch ($comment->total_comments) {
    case 0:
        $localization->selectVariant('number_of_comments', 0);
        break;
    case 1:
        $localization->selectVariant('number_of_comments', 1);
        break;
    default:
コード例 #21
0
ファイル: comment.php プロジェクト: emivo/Tsoha-Bootstrap
 public static function delete_chefs_from_recipe($id, $chef_id)
 {
     $comment = new Comment(array('recipe_id' => $id, 'chef_id' => $chef_id));
     $comment->delete();
 }
コード例 #22
0
 /**
  * Reject (delete) unapproved comment
  */
 function rejectComment()
 {
     Doo::loadModel('Comment');
     $c = new Comment();
     $c->id = intval($this->params['cid']);
     $c->status = 0;
     $c->delete(array('limit' => 1));
     $data['rootUrl'] = Doo::conf()->APP_URL;
     $data['title'] = 'Comment Rejected!';
     $data['content'] = "<p>Comment is rejected &amp; deleted successfully!</p>";
     $this->render('admin_msg', $data);
 }
コード例 #23
0
ファイル: managecomments.php プロジェクト: shubhamoy/photolia
require_once __DIR__ . '/../../includes/helpers.php';
require_once __DIR__ . '/../../loader.php';
Session::checkSession();
$a = new Auth();
if (!$a->isLoggedIn()) {
    redirect_to('login.php');
    exit;
}
$u = User::getUser();
$comments = Comment::findAllComments();
//$l = Logger::start();
$msg = "";
if (isset($_POST['del'])) {
    $id = intval($_POST['did']);
    $d = Comment::delete($id);
    if ($d) {
        $msg = opmsg("Comment Deleted Successfully", "success");
        redirect_to('managecomments.php');
    } else {
        $msg = opmsg("Comment Not Deleted", "danger");
    }
}
if (isset($_POST['approve'])) {
    $id = intval($_POST['cid']);
    $data['allowed'] = 1;
    $d = Comment::update($id, $data);
    if ($d) {
        $msg = opmsg("Comment Approved Successfully", "success");
        redirect_to('managecomments.php');
    } else {
コード例 #24
0
ファイル: Comment.php プロジェクト: yusufchang/app
function displayComments($input, $args, $parser)
{
    global $wgOut;
    wfProfileIn(__METHOD__);
    $parser->disableCache();
    // Add required CSS & JS via ResourceLoader
    $wgOut->addModules('ext.comments');
    // Parse arguments
    // The preg_match() lines here are to support the old-style way of
    // adding arguments:
    // <comments>
    // Allow=Foo,Bar
    // Voting=Plus
    // </comments>
    // whereas the normal, standard MediaWiki style, which this extension
    // also supports is: <comments allow="Foo,Bar" voting="Plus" />
    $allow = '';
    if (preg_match('/^\\s*Allow\\s*=\\s*(.*)/mi', $input, $matches)) {
        $allow = htmlspecialchars($matches[1]);
    } elseif (!empty($args['allow'])) {
        $allow = $args['allow'];
    }
    $voting = '';
    if (preg_match('/^\\s*Voting\\s*=\\s*(.*)/mi', $input, $matches)) {
        $voting = htmlspecialchars($matches[1]);
    } elseif (!empty($args['voting']) && in_array(strtoupper($args['voting']), array('OFF', 'PLUS', 'MINUS'))) {
        $voting = $args['voting'];
    }
    $comment = new Comment($wgOut->getTitle()->getArticleID());
    $comment->setAllow($allow);
    $comment->setVoting($voting);
    if (isset($_POST['commentid'])) {
        // isset added by misza
        $comment->setCommentID($_POST['commentid']);
        $comment->delete();
    }
    // This was originally commented out, I don't know why.
    // Uncommented to prevent E_NOTICE.
    $output = $comment->displayOrderForm();
    $output .= '<div id="allcomments">' . $comment->display() . '</div>';
    // If the database is in read-only mode, display a message informing the
    // user about that, otherwise allow them to comment
    if (!wfReadOnly()) {
        $output .= $comment->displayForm();
    } else {
        $output .= wfMsg('comments-db-locked');
    }
    wfProfileOut(__METHOD__);
    return $output;
}
コード例 #25
0
ファイル: admin.php プロジェクト: hyrmedia/builderengine
 public function delete_comment($id)
 {
     $comments = new Comment($id);
     // foreach ($comments->get() as $comment)
     // {
     //     $comment->delete();
     // }
     $comments->delete();
     redirect(base_url('/admin/module/blog/show_objects/comment_report'), 'location');
 }
コード例 #26
0
 /**
  * 删除评论 
  */
 public function delete()
 {
     $id = (int) $this->_get("id");
     if ($id <= 0) {
         $this->error("参数有误!");
     }
     $r = M("Comments")->where(array("id" => $id))->find();
     if ($r) {
         $Comment = new Comment();
         $status = $Comment->delete($id);
         if ($status["status"]) {
             $this->success("评论删除成功!");
         } else {
             $this->error($status['info']);
         }
     } else {
         $this->error("该评论不存在!");
     }
 }
コード例 #27
0
 if ($comment->loadFromDB(intval($_POST['cid']))) {
     $permEdit = false;
     if (isset($_SESSION['uid'])) {
         if ($comment->getAuthor() == $uid) {
             $permEdit = true;
         }
         $blog_user = Database::get()->querySingle("SELECT user_id FROM blog_post WHERE id = ?d", $comment->getRid());
         if ($blog_user->user_id == $uid) {
             $permEdit = true;
         }
         if (isset($is_admin) && $is_admin) {
             $permEdit = true;
         }
     }
     if ($permEdit) {
         if ($comment->delete()) {
             $response[0] = 'OK';
             $response[1] = "<div class='alert alert-success'>".$langCommentsDelSuccess."</div>"; 
         } else {
             $response[0] = 'ERROR';
             $response[1] = "<div class='alert alert-warning'>".$langCommentsDelFail."</div>";
         }
     } else {
         $response[0] = 'ERROR';
         $response[1] = "<div class='alert alert-warning'>".$langCommentsDelNoPerm."</div>";
     }
 } else {
     $response[0] = 'ERROR';
     $response[1] = "<div class='alert alert-warning'>".$langCommentsLoadFail."</div>";
 }
 echo json_encode($response);
コード例 #28
0
 function testAddDeleteContentComments()
 {
     //    Dal::register_query_callback("explain_query");
     echo "getting a user\n";
     $user = Test::get_test_user();
     echo "test user = {$user->first_name} {$user->last_name}\n";
     echo "adding some content\n";
     $post = new BlogPost();
     $post->author_id = $user->user_id;
     $post->parent_collection_id = -1;
     $post->title = "Test blog post (from testAddDeleteContentComments)";
     $post->body = "<p>This is the post body!</p><p>Foo <b>foo</b> foo</p>";
     $post->allow_comments = 1;
     $post->is_active = 1;
     $post->display_on = DISPLAY_ON_HOMEPAGE;
     $post->save();
     echo "... saved as content_id={$post->content_id}\n";
     echo "testing that it is retrievable\n";
     $post_retr = Content::load_content($post->content_id, $user->user_id);
     $this->assertEquals($post_retr->content_id, $post->content_id);
     $this->assertEquals($post_retr->title, $post->title);
     $this->assertEquals($post_retr->body, $post->body);
     $this->assertEquals($post_retr->author_id, $user->user_id);
     $this->assertEquals($post_retr->is_active, 1);
     echo "posting a comment\n";
     $cmt = new Comment();
     $cmt->content_id = $post->content_id;
     $cmt_comment = "This is an automatic comment - on an autogenerated post";
     $cmt->comment = $cmt_comment;
     $cmt->user_id = $user->user_id;
     $cmt->name = $cmt->email = $cmt->homepage = '';
     $cmt->ip_addr = '127.0.0.1';
     $cmt->referrer = 'http://example.com/';
     $cmt->user_agent = 'phpunit auto-test';
     $cmt->save();
     echo "... saved as comment_id={$cmt->comment_id}\n";
     echo "testing that the comment is retrievable\n";
     $cmt_retr = new Comment();
     $cmt_retr->load($cmt->comment_id);
     $this->assertEquals($cmt_retr->comment_id, $cmt->comment_id);
     $this->assertEquals($cmt_retr->content_id, $post->content_id);
     $this->assertEquals($cmt_retr->comment, $cmt_comment);
     $this->assertEquals($cmt_retr->is_active, 1);
     echo "testing that we see one comment on the post\n";
     $comments = Comment::get_comment_for_content($post->content_id);
     echo count($comments) . " comments\n";
     //var_dump($comments);
     $this->assertEquals(count($comments), 1);
     echo "testing that we have no trackbacks on the post\n";
     $trackbacks = Content::get_trackbacks_for_content($post->content_id);
     echo count($trackbacks) . " trackbacks\n";
     //var_dump($trackbacks);
     $this->assertEquals(count($trackbacks), 0);
     echo "posting ANOTHER comment\n";
     $cmt2 = new Comment();
     $cmt2->content_id = $post->content_id;
     $cmt2_comment = "This is ANOTHER automatic comment - on the same autogenerated post";
     $cmt2->comment = $cmt_comment;
     $cmt2->user_id = $user->user_id;
     $cmt2->name = $cmt2->email = $cmt2->homepage = '';
     $cmt2->ip_addr = '127.0.0.1';
     $cmt2->referrer = 'http://example.com/';
     $cmt2->user_agent = 'phpunit auto-test';
     $cmt2->save();
     echo "... saved as comment_id={$cmt2->comment_id}\n";
     echo "testing that we see two comments on the post\n";
     $comments = Comment::get_comment_for_content($post->content_id);
     $this->assertEquals(count($comments), 2);
     echo "deleting the first comment\n";
     $cmt_retr->delete();
     echo "testing that we see one comment on the post again (not seeing the deleted one)\n";
     $comments = Comment::get_comment_for_content($post->content_id);
     $this->assertEquals(count($comments), 1);
     echo "testing that the first comment (now deleted) is not retrievable\n";
     $cmt_retr_fail = new Comment();
     try {
         $cmt_retr_fail->load($cmt->comment_id);
         $this->assertTrue(FALSE);
         // shouldn't get here
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), COMMENT_NOT_EXIST);
     }
     echo "deleting the post\n";
     Content::delete_by_id($post->content_id);
     echo "testing that the post is not retrievable\n";
     try {
         $post_retr_fail = Content::load_content($post->content_id, $user->user_id);
         $this->assertTrue(FALSE);
         // shouldn't get here
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), CONTENT_NOT_FOUND);
     }
     echo "testing that the last comment is not retrievable\n";
     $cmt_retr_fail = new Comment();
     try {
         $cmt_retr_fail->load($cmt->comment_id);
         $this->assertTrue(FALSE);
         // shouldn't get here
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), COMMENT_NOT_EXIST);
     }
     //    summarize_timed_queries();
 }
コード例 #29
0
ファイル: comments.php プロジェクト: relisher/chyrp
    static function ajax()
    {
        header("Content-Type: application/x-javascript", true);
        $config = Config::current();
        $sql = SQL::current();
        $trigger = Trigger::current();
        $visitor = Visitor::current();
        $theme = Theme::current();
        $main = MainController::current();
        switch ($_POST['action']) {
            case "reload_comments":
                $post = new Post($_POST['post_id']);
                if ($post->no_results) {
                    break;
                }
                if ($post->latest_comment > $_POST['last_comment']) {
                    $new_comments = $sql->select("comments", "id, created_at", array("post_id" => $_POST['post_id'], "created_at >" => $_POST['last_comment'], "status not" => "spam", "status != 'denied' OR (\n                                                                (\n                                                                    user_id != 0 AND\n                                                                    user_id = :visitor_id\n                                                                ) OR (\n                                                                    id IN " . self::visitor_comments() . "\n                                                                )\n                                                            )"), "created_at ASC", array(":visitor_id" => $visitor->id));
                    $ids = array();
                    $last_comment = "";
                    while ($the_comment = $new_comments->fetchObject()) {
                        $ids[] = $the_comment->id;
                        if (strtotime($last_comment) < strtotime($the_comment->created_at)) {
                            $last_comment = $the_comment->created_at;
                        }
                    }
                    ?>
{ comment_ids: [ <?php 
                    echo implode(", ", $ids);
                    ?>
 ], last_comment: "<?php 
                    echo $last_comment;
                    ?>
" }
<?php 
                }
                break;
            case "show_comment":
                $comment = new Comment($_POST['comment_id']);
                $trigger->call("show_comment", $comment);
                $main->display("content/comment", array("comment" => $comment));
                break;
            case "delete_comment":
                $comment = new Comment($_POST['id']);
                if (!$comment->deletable()) {
                    break;
                }
                Comment::delete($_POST['id']);
                break;
            case "edit_comment":
                $comment = new Comment($_POST['comment_id'], array("filter" => false));
                if (!$comment->editable()) {
                    break;
                }
                if ($theme->file_exists("forms/comment/edit")) {
                    $main->display("forms/comment/edit", array("comment" => $comment));
                } else {
                    require "edit_form.php";
                }
                break;
        }
    }
コード例 #30
0
ファイル: comment-test.php プロジェクト: jmsaul/open-trails
 /**
  * test deleting a comment that doesn't exist
  *
  * @expectedException PDOException
  */
 public function testDeleteInvalidComment()
 {
     // create a comment and than try deleting it without submitting it to mySQL
     $comment = new Comment(null, $this->trail->getTrailId(), $this->user->getUserId(), $this->VALID_BROWSER, $this->VALID_CREATEDATE, $this->VALID_IPADDRESS, $this->VALID_COMMENTPHOTO, $this->VALID_COMMENTPHOTOTYPE, $this->VALID_COMMENTTEXT);
     $comment->delete($this->getPDO());
 }