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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
 
class friend_controller extends ask_controller{
    function myquestion_action(){        
        $uid=(int)$_GET['uid'];        
        
        if($uid==''){
            $uid=$this->uid;
        }
        $this->yunset("myuid",$uid);
        
        $this->yunset("navtype",'myquestion');
        
        $M            =    $this -> MODEL('ask');
        
        $userinfoM    =    $this -> MODEL('userinfo');
        
        $info        =    $M -> getInfo('',array('where'=>array('uid'=>(int)$_GET['uid'])));
        
        $username    =    $userinfoM -> getInfo(array('uid'=>$uid),array('field'=>"`uid`,`username`"));
        
        if($this->uid==$uid){
            
            $data['nickname']    =    $this->username;
            
        }elseif($info['nickname']){
            
            $data['nickname']    =    $info['nickname'];
            
        }elseif($username['username']){
            
            $data['nickname']    =    $username['username'];
            
        }
        $this->data=$data;
        
        $this->seo("myquestio");
        
        $this->ask_tpl('myquestion');
    }
    function myanswer_action(){
        $M            =    $this -> MODEL('ask');
        
        $userinfoM    =    $this -> MODEL('userinfo');
        
        $uid        =    (int)$_GET['uid'];
        
        if($uid==''){
            
            $uid=$this->uid;
        }
        $this->yunset("myuid",$uid);
        
        $where['uid']=    $uid;
        
        $pageurl    =    Url('ask',array("c"=>$_GET['c'],'a'=>$_GET['a'],'uid'=>$uid,"page"=>"{{page}}"));
        
        $pageM        =    $this  -> MODEL('page');
        $pages        =    $pageM -> pageList('answer',$where,$pageurl,$_GET['page']);
        
        if($pages['total'] > 0){
            
            $where['orderby']    =    'add_time';
            
            $where['limit']        =    $pages['limit'];
            
            $List    =    $M -> getAnswersList($where);
            
            $this->yunset("rows" , $List);
        }
        
        $this->yunset("navtype","myquestion");
        
        
        $username    =    $userinfoM -> getInfo(array('uid'=>$uid),array('field'=>"`uid`,`username`"));
        
        $info        =    $M -> getInfo('',array('where'=>array('uid'=>(int)$_GET['uid']),'field'=>'nickname'));
        
        if($this->uid==$uid){
            
            $data['nickname']    =    $this->username;
        }elseif($info['nickname']){
            
            $data['nickname']    =    $info['nickname'];
        }elseif($username['username']){
            
            $data['nickname']    =    $username['username'];
        }
        $this->data=$data;
        
        $this->seo("myanswer");
        
        $this->ask_tpl('myanswer');
     }
    
    function attenquestion_action(){
        $M            =    $this -> MODEL('ask');
        
        $userinfoM    =    $this -> MODEL('userinfo');
        
        $uid        =    (int)$_GET['uid'];
        
        if($uid==''){
            $uid=$this->uid;
        }
        $this->yunset("myuid",$uid);
        
        $atnlist    =    $M -> getAtnInfo(array('uid'=>$uid,'type'=>1),array('field'=>'ids'));
        
        $ids        =    array_filter(@explode(',',$atnlist['ids']));
        
        if(count($ids)){
            $where['id']=    array('in',pylode(',',$ids));
            
            $pageurl    =    Url('ask',array("c"=>$_GET['c'],'a'=>$_GET['a'],'uid'=>$uid,"page"=>"{{page}}"));
            
            $pageM        =    $this  -> MODEL('page');
            $pages        =    $pageM -> pageList('question',$where,$pageurl,$_GET['page']);
            
            if($pages['total'] > 0){
                
                $where['orderby']    =    'add_time';
                
                $where['limit']        =    $pages['limit'];
                
                $List    =    $M -> getList($where);
                
                $this->yunset("rows" , $List);
            }
            
        }
        
        $this->yunset("navtype",'myquestion');
        
        $username    =    $userinfoM -> getInfo(array('uid'=>$uid),array('field'=>"`uid`,`username`"));
        
        $info        =    $M -> getInfo('',array('where'=>array('uid'=>(int)$_GET['uid']),'field'=>'nickname'));
        
        if($this->uid==$uid){
            
            $data['nickname']    =    $this->username;
        }elseif($info['nickname']){
            
            $data['nickname']    =    $info['nickname'];
        }elseif($username['username']){
            
            $data['nickname']    =    $username['username'];
        }
        $this->data=$data;
        
        $this->seo('attenquestion');
        
        $this->ask_tpl('attenquestion');
    }
    function attention_action(){
        $M        =    $this -> MODEL('ask');
        
        if($this->uid==''||$this->username==''){
            $this->layer_msg('请先登录!',8,0,$_SERVER['HTTP_REFERER']);
        }
        $this->is_login();
        
        $id     =    (int)$_POST['id'];
        
        $type    =    (int)$_POST['type'];
        
        if($id==''&&(int)$_GET['id']){
            
            $id    =    (int)$_GET['id'];
            
            $type=    1;
        }
        $data    =    array(
            'uid'        =>    $this->uid,
            
            'usertype'    =>    $this->usertype,
            
            'type'        =>    $type,
            
            'id'        =>    $id
        );
        $return    =    $M -> setAttention($data);
        
        if($return['id']){
            
            if($_GET['id']){
                
                $this->layer_msg($return['msg'],$return['errcode'],0,$_SERVER['HTTP_REFERER']);
            }else{
                
                $this->layer_msg($return['msg'],$return['errcode'],0,$return['atnnum'],$return['isadd']);
            }
        }else{
            
            $this->layer_msg($return['msg'],$return['errcode'],0,$_SERVER['HTTP_REFERER']);
        }
    }
    function delask_action(){
        $id    =    (int)$_GET['id'];
        if($id){
            $AskM    =    $this    ->    MODEL('ask');
            //删除问题、回答、评论
            if($_GET['type']==1){//删除回答
            
                $result    =    $AskM -> delAnswer(array("id"=>$id,"uid"=>$this->uid));
            }else{//删除问题
            
                $result    =    $AskM -> delquestion($id,array('uid'=>$this -> uid));
            }
            $result?$this->layer_msg('操作成功!',9,0,$_SERVER['HTTP_REFERER']):$this->layer_msg('操作失败!',8,0,$_SERVER['HTTP_REFERER']);
        }
    }
}
?>