ArticleAction.class.php
3.83 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
class ArticleAction extends CommonAction {
public $tab='Article';
public function __construct() {
parent::__construct();
$this->checkLog(); //判断用户是否已经登录
}
/**
* 通知公告
*/
public function index(){
$this->assign('authlist',$this->getPower()); //用户权限
// $order='Article.sort=0,sort asc,id desc'; //注意排序
$order='dotop desc,sort asc,addtime desc,id desc';
$where['isshow'] = array('eq',1);
$model = M($this->tab);
$field = array('id','uid','title','dotop','dotopend','dotopday','addtime','clicknum');
$data = $this->_getLists($model,$where,$order,$field,12,'Pages3',array('header'=>'<li style="border:none;">共%totalRows%条记录','pages'=>'%nowPage%/%totalPages%页 </li>','prev'=>'<上一页','next'=>'下一页>','first'=>'首页','last'=>'尾页','theme'=>'%header% %pages% %prePage% %linkPage% %nextPage% %end%'));
$this->assign('list',$data['list']?$data['list']:array()); //列表
$this->assign('page',$data['page']); //分页
$this->assign('p',$data['p']); //当前页数
$this->assign('page_title','通知公告');
$this->assign('empty','<tr><td colspan="7" style="padding-left:15px;font-size:14px;">暂无相关信息!</td></tr>');
$this->display();
}
/**
* 修改通知公告
*/
public function edit(){
$id=I('id',0,'intval');
if(!$id){
$this->error('参数有误!');
}
$Article=D($this->tab);
if($this->isPost()){
if($Article->create()){
$Article->title=htmlspecialchars($Article->title,ENT_QUOTES);
$lastid=$Article->save();
if($lastid){
$this->success('通知公告修改成功',U('Article/index',array('p'=>I('p',1,'intval'))));
}else{
$this->error('通知公告修改失败');
}
}else{
$this->error($Article->getError());
}
}else{
$data=$Article->where('id='.$id)->find();
$this->assign('data',$data);
$this->display();
}
}
/**
* 发布通知公告
*/
public function add(){
//最大排序值
// $maxp['tid']=array('in',$this->AllCatid($tid,1,'Category'));
// $maxsort=$Article->where($maxp)->max('sort');
if($this->isPost()){
$Article=D($this->tab);
if($Article->create()){
$Article->title=htmlspecialchars($Article->title,ENT_QUOTES);
$lastid=$Article->add();
//echo $Article->getLastSql();
// exit;
if($lastid){
$this->success('通知公告发布成功',U('index'));
}else{
$this->error('通知公告发布失败');
}
}else{
$this->error($Article->getError());
}
}else{
$this->display();
}
}
/**
* 删除通知公告
*/
public function delete(){
$id=I('id',0,'intval');
if(!$id){
$this->error('参数有误!');
}
$where['id'] = array('eq',$id);
$back=M($this->tab)->where($where)->delete();
if($back){
$this->success('删除成功!',U('index',array('p'=>I('p',1,'intval'))));
}else{
$this->error('删除失败!');
}
}
//查看详情通知公告-回收站
public function Look(){
$id=I('id',0,'intval');
if(!$id){
$this->error('参数有误!');
}
$where['id'] = array('eq',$id);
$where['isshow'] = array('eq',1);
$m = M($this->tab);
$arr = $m->where(array('id'=>array('eq',$id)))->find();
$this->assign('data',$arr);
if($arr){
$m->where($where)->setInc('clicknum');
}
$this->display();
}
/**
* zjp
* ajax 通知公告审核
*/
public function Shenhe(){
$Article=D($this->tab);
$is=$Article->where('id='.$this->_param('id'))->getField('isshow');
if($is==1){
$isnew=0;
}else{
$isnew=1;
}
$aa=$Article->where('id='.$this->_param('id'))->setField('isshow',$isnew);
if($aa){
$msg['success']=true;
$msg['msg']='修改成功';
$msg['val']=$isnew;
}else{
$msg['success']=false;
}
echo json_encode($msg);
}
}