chengkun
2025-05-26 4462855c0033970c39ac8d0da704b7dc41eabbfe
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
 
class admin_chat_useful_controller extends adminCommon{  
    function index_action(){
        $chatM = $this->MODEL('chat');
        $where = array();
        $noUsername = true;
        if($_GET['keyword']){
            
            $keyword    =    trim($_GET['keyword']);
            
            $type        =    intval($_GET['type']);
            
            if ($type==1){
                
                $userInfoM  =  $this->MODEL('userinfo');
                $member  =  $userInfoM->getList(array('username'=>array('like',$keyword)),array('field'=>'`uid`'));
                if (!empty($member)){
                    
                    $muids  =  array();
                    foreach ($member as $v){
                        
                        $muids[] = $v['uid'];
                    }
                    if ($type == 1){
                        
                        $where['from']  =  array('in',pylode(',', $muids));
                        
                    }elseif ($type == 2){
                        
                        $where['to']  =  array('in',pylode(',', $muids));
                    }
                }else{
                    $noUsername = false;
                }
            }elseif($type==2){
                
                $where['content']    =    array('like',$keyword);
            }
            $urlarr['type']            =    "".$type."";
            
            $urlarr['keyword']        =    "".$keyword."";
        }
        // 用户名没搜到的,不查询
        if ($noUsername){
            $urlarr            =   $_GET;
            $urlarr['page']    =    "{{page}}";
            
            $pageurl        =    Url($_GET['m'],$urlarr,'admin');
            
            $pageM            =    $this  -> MODEL('page');
            
            $pages            =    $pageM -> pageList('chat_useful',$where,$pageurl,$_GET['page']);
            
            //分页数大于0的情况下 执行列表查询
            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'];
                
                $chatList        =    $chatM -> getChatUsefulList($where,array('admin'=>1));
            }
            
            $this->yunset('rows',$chatList);
        }
        
        $this->yuntpl(array('admin/admin_chat_useful'));
    }
    function usefulSet_action(){
        if($_GET['type'] !=''){
            $type=$_GET['type'];
        }else{
            $type="1";
        }
 
        $chatM = $this->MODEL('chat');
        $chatList = $chatM->getUsefulSetList(array('type'=>$type,'orderby'=>'sort,desc'),array('admin'=>1));
        $this->yunset('rows',$chatList);
        $this->yunset('type',$type);
        $this->yuntpl(array('admin/admin_chat_useful_set'));
    }
    function usefulSetAdd_action(){
        if($_POST['submit']){
            unset($_POST['submit']);
            $chatM = $this->MODEL('chat');
            $_POST['content'] = trim($_POST['content']);
            if(isset($_POST['id'])&&!empty($_POST['id'])){
                $return = $chatM->upChatUsefulSet(array('id'=>intval($_POST['id'])),$_POST);
            }else{
 
                $return = $chatM->addChatUsefulSet($_POST);
            }
 
        }else{
            $return['msg'] = '非法操作!';
            $return['errcode'] = '8';
        }
        $this->ACT_layer_msg($return['msg'],$return['errcode'],'index.php?m=admin_chat_useful&c=usefulSet&type='.$_POST['type'],2,1);
    }
    function add_action(){
        
        $data = array('content'=>trim($_POST['content']));
        
        $chatM    =    $this->Model('chat');
        $data['utype'] = "admin";
        if (isset($_POST['id'])){
            $res = $chatM->upChatUseful(array('id'=>intval($_POST['id'])), $data);
        }
    }
    function customdel_action(){
        $this -> check_token();
 
        $delid        =    (int)$_GET['id'];
        $chatM    =    $this -> Model('chat');
 
        $where['id']    =    $delid;
        $return    =    $chatM -> delUsefulSet($where);
 
        $return?$this -> layer_msg($return['msg'],9,2,$_SERVER['HTTP_REFERER']):$this -> layer_msg($return['msg'],8,2,$_SERVER['HTTP_REFERER']);
 
    }
    function del_action(){
 
        $chatM    =    $this -> Model('chat');
        
        if(is_array($_POST['del'])){
            
            $delid        =    @implode(',',$_POST['del']);
            
            $layer_type    =    1;
        }else{
            $this -> check_token();
            
            $delid        =    (int)$_GET['id'];
            
            $layer_type    =    0;
        }
 
        $where['id']    =    array('in',$delid);
 
        $data['utype'] = "admin";
        $del    =    $chatM -> delChatUseful($where,$data);
 
        $del?$this -> layer_msg('用户常用语(ID:'.$delid.')删除成功!',9,$layer_type,$_SERVER['HTTP_REFERER']):$this -> layer_msg('删除失败!',8,$layer_type,$_SERVER['HTTP_REFERER']);
 
    }
}
 
?>