TcCommentPlugin.php
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
// +----------------------------------------------------------------------
// | TcComment [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017 Tangchao All rights reserved.
// +----------------------------------------------------------------------
// | Author: Tangchao <79300975@qq.com>
// +----------------------------------------------------------------------
namespace plugins\tc_comment;
use cmf\lib\Plugin;
use think\Db;
class TcCommentPlugin extends Plugin
{
public $info = [
'name' => 'TcComment',
'title' => '评论管理',
'description' => '评论管理',
'status' => 1,
'author' => 'Tangchao',
'version' => '1.4',
'demo_url' => 'https://qq.ytecn.cn',
'author_url' => 'https://qq.ytecn.cn'
];
public $hasAdmin = 1;
public function install()
{
return true;
}
public function uninstall()
{
return true;
}
public function comment($param)
{
$join = [
['__USER__ u', 'a.user_id = u.id']
];
$where = [];
$where['status'] = 1;
$where['object_id'] = $param['object_id'];
$where['delete_time'] = 0;
$comments = Db::name('comment')
->field('a.*,u.user_login,u.avatar')
->alias('a')->join($join)
->where($where)
->order("id DESC")
->paginate(10);
dump($comments);
$page = $comments->render();
$this->assign("page", $page);
$this->assign("comments", $comments);
if(cmf_get_current_user_id()>0){
$this->assign($param);
return $this->fetch('comment');
}else{
return $this->fetch('nocomment');
}
}
}