You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
3.9 KiB
PHP
134 lines
3.9 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: xmy 280564871@qq.com
|
|
* Date: 2017/4/14
|
|
* Time: 19:43
|
|
*/
|
|
|
|
namespace Admin\Controller;
|
|
|
|
use Admin\Model\CommentModel;
|
|
use App\Model\PointRecordModel;
|
|
|
|
class CommentController extends AdminController{
|
|
|
|
public function _initialize()
|
|
{
|
|
$this->meta_title = "评论管理";
|
|
return parent::_initialize(); // TODO: Change the autogenerated stub
|
|
}
|
|
|
|
public function lists($p=1){
|
|
$model = new CommentModel();
|
|
empty(I('game_id')) || $map['game_id'] = I('game_id');
|
|
empty(I('status'))&&I('status')!=="0"||$map['status']=I('status');
|
|
empty(I("account")) || $map['account'] = ["like","%".I("account")."%"];
|
|
//empty(I("time_start")) || $map['create_time'] = ["between",[strtotime(I("time_start")),empty(I("time_end"))?time():strtotime(I("time_end"))+86400-1]];
|
|
|
|
if(!empty($_REQUEST['time_start']) && !empty($_REQUEST['time_end'])) {$map['create_time'] = array('between',[strtotime($_REQUEST['time_start']),strtotime($_REQUEST['time_end'])+86399]);}
|
|
elseif (!empty($_REQUEST['time_start']) && empty($_REQUEST['time_end'])) {$map['create_time'] = array('between',[strtotime($_REQUEST['time_start']),time()]);}
|
|
elseif (empty($_REQUEST['time_start']) && !empty($_REQUEST['time_end'])) {$map['create_time'] = array('elt',strtotime($_REQUEST['time_end'])+86399);}
|
|
|
|
$data = $model->getLists($map,'create_time desc',$p);
|
|
//分页
|
|
$count = $data['count'];
|
|
|
|
|
|
if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;}
|
|
|
|
$page = set_pagination($count,$row);
|
|
if($page) {$this->assign('_page', $page);}
|
|
|
|
$this->assign("data",$data['data']);
|
|
|
|
$this->m_title = '评论管理';
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Comment/lists','status'=>1])->find());
|
|
|
|
|
|
$this->display();
|
|
}
|
|
|
|
|
|
/**
|
|
* 审核
|
|
* @param $id 评论ID
|
|
* author: xmy 280564871@qq.com
|
|
*/
|
|
public function set_status($id){
|
|
$model = new CommentModel();
|
|
$data = $model->where(['id'=>$id])->find();
|
|
$result = $model->where(['id'=>$id])->setField("status",1);
|
|
if($result){
|
|
$point = new PointRecordModel();
|
|
$point->addPointByType("comment",get_user_id($data['account']));
|
|
$this->success("审核成功",U('lists'));
|
|
}else{
|
|
$this->error("审核失败");
|
|
}
|
|
}
|
|
/**
|
|
* 评论审核
|
|
* @param $id 评论ID
|
|
* author: xmy 280564871@qq.com
|
|
*/
|
|
public function set_statu($Model=CONTROLLER_NAME){
|
|
$ids = I('request.ids',0);
|
|
$status = I('request.status');
|
|
$msg_type = I('request.msg_type',1);
|
|
$field = I('request.field','status');
|
|
if(empty($ids)){
|
|
$this->error('请选择要操作的数据');
|
|
}
|
|
if(!is_array($ids))
|
|
$ids = (array)$ids;
|
|
|
|
$ids = array_unique($ids);
|
|
|
|
$map['id'] = array('in',$ids);
|
|
switch ($status){
|
|
case 1 :
|
|
//$this->resume($Model, $map, $msg[$msg_type], $field);
|
|
$data = array($field=>$status);
|
|
$content = M('Comment','tab_');
|
|
if( $content->where($map)->save($data)!==false ) {
|
|
$point = new PointRecordModel();
|
|
$result = $content->field('account')->where($map)->select();
|
|
foreach ($result as $v) {
|
|
$point->addPointByType("comment",get_user_id($v['account']));
|
|
}
|
|
|
|
$this->success('审核成功');
|
|
}else{
|
|
$this->error('审核失败');
|
|
}
|
|
|
|
break;
|
|
default :
|
|
$this->error('参数错误');
|
|
break;
|
|
}
|
|
|
|
}
|
|
/**
|
|
* 删除评论
|
|
* @param $id 评论ID
|
|
* author: xmy 280564871@qq.com
|
|
*/
|
|
public function delete(){
|
|
$ids = I('request.ids');
|
|
if(is_array($ids)){
|
|
$where='id in ('.implode(',',$ids).')';
|
|
}else{
|
|
$where='id='.$ids;
|
|
}
|
|
$data = M('comment','tab_')->where($where)->delete();
|
|
|
|
if($data){
|
|
$this->success("删除成功",U('lists'));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} |