<?php
|
|
|
class admin_announcement_controller extends siteadmin_controller{
|
|
function set_search(){
|
$ad_time = array('1'=>'今天', '3'=>'最近三天', '7'=>'最近七天', '15'=>'最近半月', '30'=>'最近一个月');
|
$search_list[] = array("param"=>"end", "name"=>'发布时间', "value"=>$ad_time);
|
$this->yunset("search_list",$search_list);
|
}
|
function index_action(){
|
$this->set_search();
|
$AnnouncementM = $this->MODEL('announcement');
|
if(trim($_GET['keyword'])){
|
$where['title'] = array('like',trim($_GET['keyword']));
|
$urlarr['keyword'] = $_GET['keyword'];
|
}
|
if($_GET['end']){
|
if($_GET['end'] == 1){
|
$where['datetime'] = array('>=',strtotime(date("Y-m-d 00:00:00")));
|
}else{
|
$where['datetime'] = array('>=',strtotime('-'.intval($_GET['end']).' day'));
|
}
|
$urlarr['end'] = $_GET['end'];
|
}
|
$urlarr['page'] = "{{page}}";
|
$pageurl = Url($_GET['m'],$urlarr,'admin');
|
$pageM = $this -> MODEL('page');
|
$pages = $pageM -> pageList('admin_announcement',$where,$pageurl,$_GET['page']);
|
if($pages['total'] > 0){
|
if($_GET['order']){
|
$where['orderby'] = $_GET['t'].','.$_GET['order'];
|
$urlarr['order'] = $_GET['order'];
|
$urlarr['t'] = $_GET['t'];
|
}else{
|
$where['orderby'] = 'id';
|
}
|
$where['limit'] = $pages['limit'];
|
$ListAnnouncement = $AnnouncementM -> getList($where);
|
$this->yunset("announcement" , $ListAnnouncement['list']);
|
}
|
$this->yunset("get_type", $_GET);
|
$this->siteadmin_tpl(array('admin_announcement_list'));
|
}
|
|
function add_action(){
|
$AnnouncementM = $this -> MODEL('announcement');
|
if($_GET['id']){
|
$id = intval($_GET['id']);
|
$info = $AnnouncementM -> getInfo(array('id'=>$id));
|
$this->yunset("info", $info);
|
$this->yunset('lasturl',$_SERVER['HTTP_REFERER']);
|
}
|
$this->siteadmin_tpl(array('admin_announcement_add'));
|
}
|
|
function save_action(){
|
$_POST = $this->post_trim($_POST);
|
$_POST['did'] = $this->config['did'];
|
$AnnouncementM = $this->MODEL('announcement');
|
if($_POST['update']){
|
$lasturl = str_replace("&","&",$_POST['lasturl']);
|
unset($_POST['lasturl']);
|
$nid = $AnnouncementM -> upInfo(array('id'=>intval($_POST['id'])),$_POST);
|
$nid?$this->ACT_layer_msg( "公告(ID:".$_POST['id'].")更新成功!",9,$lasturl,2,1):$this->ACT_layer_msg( "公告(ID:".$_POST['id'].")更新失败!",8,$lasturl,2,1);
|
}
|
if($_POST['add']){
|
$nid = $AnnouncementM -> addInfo($_POST);
|
$nid?$this->ACT_layer_msg( "公告添加成功!",9,"index.php?m=admin_announcement",2,1):$this->ACT_layer_msg( "公告添加失败!",8,"index.php?m=admin_announcement",2,1);
|
}
|
}
|
|
function del_action(){
|
$this->check_token();
|
$AnnouncementM = $this -> Model('announcement');
|
$delID = $_GET['id'] ? intval($_GET['id']) : $_GET['del'];
|
$addArr = $AnnouncementM -> delAnnouncement($delID);
|
$this -> layer_msg( $addArr['msg'],$addArr['errcode'],$addArr['layertype'],$_SERVER['HTTP_REFERER'],2,1);
|
}
|
}
|
?>
|