当前位置: 首页>>代码示例>>PHP>>正文


PHP Comment::find_by_id方法代码示例

本文整理汇总了PHP中Comment::find_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::find_by_id方法的具体用法?PHP Comment::find_by_id怎么用?PHP Comment::find_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Comment的用法示例。


在下文中一共展示了Comment::find_by_id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: comments_list

 /**
  * 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]);
 }
开发者ID:Max201,项目名称:nanocore,代码行数:45,代码来源:Control.php

示例2: redirect_to

<?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();
}
开发者ID:AlaminMahamud,项目名称:Photo-Gallery-Project-PHP,代码行数:22,代码来源:delete_comment.php

示例3: redirect_to

<?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();
}
开发者ID:RichJones22,项目名称:photo_gallery,代码行数:23,代码来源:delete_comment.php

示例4: header

<?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 
开发者ID:Frosty92,项目名称:PhotoGallery,代码行数:31,代码来源:delete_comment.php

示例5: redirect_head

    } 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']);
开发者ID:onielmartinjr,项目名称:cen4010,代码行数:31,代码来源:view_pet.php

示例6: redirect

<?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');
    }
}
开发者ID:ciplpj,项目名称:photo_gallery,代码行数:18,代码来源:delete_comment.php


注:本文中的Comment::find_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。