/** * Comments list * * @param $request * @return mixed */ public function comments_list($request) { // Delete page if ($request->get('delete')) { $delete = $request->get('delete'); if ($delete != 'all') { $comment = \Comment::find_by_id(intval($delete)); if ($comment) { // Delete child comments \Comment::table()->delete('parent_id = ' . $comment->id); if ($comment->delete()) { $this->view->assign('message', $this->lang->translate('form.deleted')); } } } else { \Comment::table()->delete('1'); $this->view->assign('message', $this->lang->translate('form.deleted')); } } // Filter $filter = []; if ($request->get('author')) { $author = \User::find($request->get('author')); if ($author) { $filter['conditions'] = ['author_id = ?', $author->id]; } } $filter['order'] = 'id DESC'; if ($request->order) { $filter['order'] = $request->order; } /** @var Listing $paginator */ $paginator = NCService::load('Paginator.Listing', [$request->page, \Comment::count('all')]); $filter = array_merge($filter, $paginator->limit()); // Filter users $comments = \Comment::all($filter); $comments = \Comment::as_array($comments); return $this->view->render('comment/list.twig', ['title' => $this->lang->translate('comment.list'), 'comments_list' => $comments, 'listing' => $paginator->pages(), 'page' => $paginator->cur_page]); }
<?php require_once "../../includes/initialize.php"; if (!$session->is_logged_in()) { redirect_to("login.php"); } // must have an ID if (empty($_GET['id'])) { $session->message("No comment ID was provided."); redirect_to('index.php'); } $comment = Comment::find_by_id($_GET['id']); if ($comment && $comment->delete()) { $session->message("The comment was deleted."); redirect_to("comments.php?id={$comment->photograph_id}"); } else { $session->message("The comment could not be deleted."); redirect_to('list_photos.php'); } if (isset($database)) { $database->close_connection(); }
<?php require_once "../../includes/initialize.php"; if (!$session->is_logged_in()) { redirect_to("login.php"); } // must have an ID if (empty($_GET['comment_id'])) { $session->message("No comment ID was provied."); redirect("index.php"); } // check if passed comment id exists. $comment = Comment::find_by_id($_GET["comment_id"]); if ($comment && $comment->delete()) { //$session->message("The comment {$comment->filename} was deleted."); redirect_to("comments.php?id={$_GET['photo_id']}"); } else { $session->message("The comments could not be deleted."); redirect_to("list_photos.php"); } if (isset($database)) { $database->close_connection(); }
<?php include "includes/header.php"; ?> <?php if (!$session->is_signedin() || !isset($_GET['id'])) { header("Location: login.php"); } else { $id = $_GET['id']; } ?> <?php if (isset($_POST['submit-yes'])) { $comment = Comment::find_by_id($id); if (!$comment) { header("Location: comments.php"); } $comment->delete("comment"); header("Location:comments.php"); } if (isset($_POST['submit-no'])) { header("Location: comments.php"); } ?> <!-- Navigation --> <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <!-- Brand and toggle get grouped for better mobile display --> <?php
} else { //the comment did not save successfully, for whatever reason $session->message("Your comment was not added successfully."); redirect_head(current_url()); //redirect back to itself } } //FLAG NEW COMMENTS HERE if (isset($_GET['flag_comment_wk'])) { //make sure user has access to do this if (!$session->is_logged_in) { $session->message("You do not have sufficient rights to flag this comment."); redirect_head(ROOT_URL . file_name_without_get() . "?pet_wk=" . $_GET['pet_wk']); } //first, make sure the comment exists $comment_to_flag = Comment::find_by_id($_GET['flag_comment_wk']); if (!$comment_to_flag) { //if the item does not exist in the database $session->message("You must've clicked on a bad URL; please try again."); redirect_head(ROOT_URL . file_name_without_get() . "?pet_wk=" . $_GET['pet_wk']); } //now we make sure the comment is not already flagged if ($comment_to_flag->is_flagged == '1') { $session->message("That comment is already flagged."); redirect_head(ROOT_URL . file_name_without_get() . "?pet_wk=" . $_GET['pet_wk']); } //if we're here, go ahead and flag the comment $comment_to_flag->is_flagged = 1; if ($comment_to_flag->save()) { $session->message("The comment was successfully flagged."); redirect_head(ROOT_URL . file_name_without_get() . "?pet_wk=" . $_GET['pet_wk']);
<?php require_once '../../includes/initialize.php'; if (!$session->is_logged_in()) { redirect("login.php"); } if (!isset($_GET['commentid'])) { redirect('index.php'); } if ($comment = Comment::find_by_id($_GET['commentid'])) { if ($comment && $comment->delete()) { $session->set_get_message('Comment Was Deleted Successfully'); redirect("photo_comment.php?commentid={$comment->photograph_id}"); } else { $session->set_get_message('Comment Was Not Deleted'); redirect('view_photograph.php'); } }