本文整理汇总了PHP中Comment::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::delete方法的具体用法?PHP Comment::delete怎么用?PHP Comment::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comment
的用法示例。
在下文中一共展示了Comment::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DisplayComments
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: actionAdmin
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);
}
示例3: testCounterIncrementsAndDecrementsWhen
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: testSaveWithIdShouldReturnTrue
/**
* 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: deleteComment
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: deleteComment
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: performHandlerTasks
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: testDelete
/**
* 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: testDelete
/**
* 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: controlerJob
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: delete
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: testAddComment
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: createNewComment
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: array
} 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: render_main_page_area
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 {
//.........这里部分代码省略.........