XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
communication.view.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 
10 {
11 
16  function init()
17  {
18  $oCommunicationModel = getModel('communication');
19 
20  $this->communication_config = $oCommunicationModel->getConfig();
21  $skin = $this->communication_config->skin;
22 
23  Context::set('communication_config', $this->communication_config);
24 
25  $config_parse = explode('|@|', $skin);
26 
27  if(count($config_parse) > 1)
28  {
29  $tpl_path = sprintf('./themes/%s/modules/communication/', $config_parse[0]);
30  }
31  else
32  {
33  $tpl_path = sprintf('%sskins/%s', $this->module_path, $skin);
34  }
35 
36  $this->setTemplatePath($tpl_path);
37 
38  $oLayoutModel = getModel('layout');
39  $layout_info = $oLayoutModel->getLayout($this->communication_config->layout_srl);
40  if($layout_info)
41  {
42  $this->module_info->layout_srl = $this->communication_config->layout_srl;
43  $this->setLayoutPath($layout_info->path);
44  }
45  }
46 
52  {
53  // Error appears if not logged-in
54  if(!Context::get('is_logged'))
55  {
56  return $this->stop('msg_not_logged');
57  }
58 
59  $logged_info = Context::get('logged_info');
60 
61  if(!array_key_exists('dispCommunicationMessages', $logged_info->menu_list))
62  {
63  return $this->stop('msg_invalid_request');
64  }
65 
66  // Set the variables
67  $message_srl = Context::get('message_srl');
68  $message_type = Context::get('message_type');
69 
70  if(!in_array($message_type, array('R', 'S', 'T')))
71  {
72  $message_type = 'R';
73  Context::set('message_type', $message_type);
74  }
75 
76  $oCommunicationModel = getModel('communication');
77 
78  // extract contents if message_srl exists
79  if($message_srl)
80  {
81  $columnList = array('message_srl', 'sender_srl', 'receiver_srl', 'message_type', 'title', 'content', 'readed', 'regdate');
82  $message = $oCommunicationModel->getSelectedMessage($message_srl, $columnList);
83 
84  switch($message->message_type)
85  {
86  case 'R':
87  if($message->receiver_srl != $logged_info->member_srl)
88  {
89  return $this->stop('msg_invalid_request');
90  }
91  break;
92 
93  case 'S':
94  if($message->sender_srl != $logged_info->member_srl)
95  {
96  return $this->stop('msg_invalid_request');
97  }
98  break;
99 
100  case 'T':
101  if($message->receiver_srl != $logged_info->member_srl && $message->sender_srl != $logged_info->member_srl)
102  {
103  return $this->stop('msg_invalid_request');
104  }
105  break;
106  }
107 
108  if($message->message_srl == $message_srl && ($message->receiver_srl == $logged_info->member_srl || $message->sender_srl == $logged_info->member_srl))
109  {
110  stripEmbedTagForAdmin($message->content, $message->sender_srl);
111  Context::set('message', $message);
112  }
113  }
114 
115  // Extract a list
116  $columnList = array('message_srl', 'readed', 'title', 'member.member_srl', 'member.nick_name', 'message.regdate', 'readed_date');
117  $output = $oCommunicationModel->getMessages($message_type, $columnList);
118 
119  // set a template file
120  Context::set('total_count', $output->total_count);
121  Context::set('total_page', $output->total_page);
122  Context::set('page', $output->page);
123  Context::set('message_list', $output->data);
124  Context::set('page_navigation', $output->page_navigation);
125 
126  $oSecurity = new Security();
127  $oSecurity->encodeHTML('message_list..nick_name');
128 
129  $this->setTemplateFile('messages');
130  }
131 
137  {
138  $this->setLayoutPath('./common/tpl/');
139  $this->setLayoutFile('popup_layout');
140 
141  // Error appears if not logged-in
142  if(!Context::get('is_logged'))
143  {
144  return $this->stop('msg_not_logged');
145  }
146 
147  $logged_info = Context::get('logged_info');
148 
149  $oCommunicationModel = getModel('communication');
150 
151  // get a new message
152  $columnList = array('message_srl', 'member_srl', 'nick_name', 'title', 'content', 'sender_srl');
153  $message = $oCommunicationModel->getNewMessage($columnList);
154  if($message)
155  {
156  stripEmbedTagForAdmin($message->content, $message->sender_srl);
157  Context::set('message', $message);
158  }
159 
160  // Delete a flag
161  $flag_path = './files/communication_extra_info/new_message_flags/' . getNumberingPath($logged_info->member_srl);
162  $flag_file = sprintf('%s%s', $flag_path, $logged_info->member_srl);
163  FileHandler::removeFile($flag_file);
164 
165  $this->setTemplateFile('new_message');
166  }
167 
173  {
174  $this->setLayoutPath('./common/tpl/');
175  $this->setLayoutFile("popup_layout");
176 
177  $oCommunicationModel = getModel('communication');
178  $oMemberModel = getModel('member');
179 
180  // Error appears if not logged-in
181  if(!Context::get('is_logged'))
182  {
183  return $this->stop('msg_not_logged');
184  }
185 
186  $logged_info = Context::get('logged_info');
187 
188  // get receipient's information
189  // check inalid request
190  $receiver_srl = Context::get('receiver_srl');
191  if(!$receiver_srl)
192  {
193  return $this->stop('msg_invalid_request');
194  }
195 
196  // check receiver and sender are same
197  if($logged_info->member_srl == $receiver_srl)
198  {
199  return $this->stop('msg_cannot_send_to_yourself');
200  }
201 
202  // get message_srl of the original message if it is a reply
203  $message_srl = Context::get('message_srl');
204  if($message_srl)
205  {
206  $source_message = $oCommunicationModel->getSelectedMessage($message_srl);
207  if($source_message->message_srl == $message_srl && $source_message->sender_srl == $receiver_srl)
208  {
209  $source_message->title = "[re] " . $source_message->title;
210  $source_message->content = "\r\n<br />\r\n<br /><div style=\"padding-left:5px; border-left:5px solid #DDDDDD;\">" . trim($source_message->content) . "</div>";
211  Context::set('source_message', $source_message);
212  }
213  }
214 
215  $receiver_info = $oMemberModel->getMemberInfoByMemberSrl($receiver_srl);
216  if(!$receiver_info)
217  {
218  return $this->stop('msg_invalid_request');
219  }
220 
221  Context::set('receiver_info', $receiver_info);
222 
223  // set a signiture by calling getEditor of the editor module
224  $oEditorModel = getModel('editor');
225  $option = new stdClass();
226  $option->primary_key_name = 'receiver_srl';
227  $option->content_key_name = 'content';
228  $option->allow_fileupload = FALSE;
229  $option->enable_autosave = FALSE;
230  $option->enable_default_component = TRUE; // FALSE;
231  $option->enable_component = FALSE;
232  $option->resizable = FALSE;
233  $option->disable_html = TRUE;
234  $option->height = 300;
235  $option->skin = $this->communication_config->editor_skin;
236  $option->colorset = $this->communication_config->editor_colorset;
237  $editor = $oEditorModel->getEditor($logged_info->member_srl, $option);
238  Context::set('editor', $editor);
239 
240  $this->setTemplateFile('send_message');
241  }
242 
248  {
249  // Error appears if not logged-in
250  if(!Context::get('is_logged'))
251  {
252  return $this->stop('msg_not_logged');
253  }
254 
255  $oCommunicationModel = getModel('communication');
256 
257  // get a group list
258  $tmp_group_list = $oCommunicationModel->getFriendGroups();
259  $group_count = count($tmp_group_list);
260 
261  for($i = 0; $i < $group_count; $i++)
262  {
263  $friend_group_list[$tmp_group_list[$i]->friend_group_srl] = $tmp_group_list[$i];
264  }
265 
266  Context::set('friend_group_list', $friend_group_list);
267 
268  // get a list of friends
269  $friend_group_srl = Context::get('friend_group_srl');
270  $columnList = array('friend_srl', 'friend_group_srl', 'target_srl', 'member.nick_name', 'friend.regdate');
271 
272  $output = $oCommunicationModel->getFriends($friend_group_srl, $columnList);
273  $friend_count = count($output->data);
274 
275  if($friend_count)
276  {
277  foreach($output->data as $key => $val)
278  {
279  $group_srl = $val->friend_group_srl;
280  $group_title = $friend_group_list[$group_srl]->title;
281  if(!$group_title)
282  {
283  $group_title = Context::get('default_friend_group');
284  }
285  $output->data[$key]->group_title = $group_title;
286  }
287  }
288 
289  // set a template file
290  Context::set('total_count', $output->total_count);
291  Context::set('total_page', $output->total_page);
292  Context::set('page', $output->page);
293  Context::set('friend_list', $output->data);
294  Context::set('page_navigation', $output->page_navigation);
295 
296  $this->setTemplateFile('friends');
297  }
298 
304  {
305  $this->setLayoutPath('./common/tpl/');
306  $this->setLayoutFile("popup_layout");
307 
308  // error appears if not logged-in
309  if(!Context::get('is_logged'))
310  {
311  return $this->stop('msg_not_logged');
312  }
313 
314  $logged_info = Context::get('logged_info');
315  $target_srl = Context::get('target_srl');
316 
317  if(!$target_srl)
318  {
319  return $this->stop('msg_invalid_request');
320  }
321 
322  // get information of the member
323  $oMemberModel = getModel('member');
324  $oCommunicationModel = getModel('communication');
325  $communication_info = $oMemberModel->getMemberInfoByMemberSrl($target_srl);
326 
327  if($communication_info->member_srl != $target_srl)
328  {
329  return $this->stop('msg_invalid_request');
330  }
331 
332  Context::set('target_info', $communication_info);
333 
334  // get a group list
335  $friend_group_list = $oCommunicationModel->getFriendGroups();
336  Context::set('friend_group_list', $friend_group_list);
337 
338  $this->setTemplateFile('add_friend');
339  }
340 
346  {
347  $this->setLayoutPath('./common/tpl/');
348  $this->setLayoutFile("popup_layout");
349 
350  // error apprears if not logged-in
351  if(!Context::get('is_logged'))
352  {
353  return $this->stop('msg_not_logged');
354  }
355 
356  $logged_info = Context::get('logged_info');
357 
358  // change to edit mode when getting the group_srl
359  $friend_group_srl = Context::get('friend_group_srl');
360  if($friend_group_srl)
361  {
362  $oCommunicationModel = getModel('communication');
363  $friend_group = $oCommunicationModel->getFriendGroupInfo($friend_group_srl);
364  if($friend_group->friend_group_srl == $friend_group_srl)
365  {
366  Context::set('friend_group', $friend_group);
367  }
368  }
369 
370  $this->setTemplateFile('add_friend_group');
371  }
372 
373 }
374 /* End of file communication.view.php */
375 /* Location: ./modules/comment/communication.view.php */
setTemplateFile($filename)
getNumberingPath($no, $size=3)
Definition: func.inc.php:1081
removeFile($filename)
stripEmbedTagForAdmin(&$content, $writer_member_srl)
Definition: func.inc.php:1568
$output
Definition: ko.install.php:193
setLayoutFile($filename)
set($key, $val, $set_to_get_vars=0)
getModel($module_name)
Definition: func.inc.php:145