chengkun
2025-05-26 8f3df543230cd4403368b39b9bbe5726d11a0284
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
<?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("&amp;","&",$_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);
    }
}
?>