XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
communication.mobile.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 
4 require_once(_XE_PATH_ . 'modules/communication/communication.view.php');
5 
12 {
13 
14  function init()
15  {
16  $oCommunicationModel = getModel('communication');
17 
18  $this->communication_config = $oCommunicationModel->getConfig();
19  $skin = $this->communication_config->mskin;
20 
21  Context::set('communication_config', $this->communication_config);
22 
23  $tpl_path = sprintf('%sm.skins/%s', $this->module_path, $skin);
24  $this->setTemplatePath($tpl_path);
25 
26  $oLayoutModel = getModel('layout');
27  $layout_info = $oLayoutModel->getLayout($this->communication_config->mlayout_srl);
28  if($layout_info)
29  {
30  $this->module_info->mlayout_srl = $this->communication_config->mlayout_srl;
31  $this->setLayoutPath($layout_info->path);
32  }
33  }
34 
40  {
41  // Error appears if not logged-in
42  if(!Context::get('is_logged'))
43  {
44  return $this->stop('msg_not_logged');
45  }
46 
47  $logged_info = Context::get('logged_info');
48  if(!array_key_exists('dispCommunicationMessages', $logged_info->menu_list))
49  {
50  return $this->stop('msg_invalid_request');
51  }
52 
53  // Set the variables
54  $message_srl = Context::get('message_srl');
55  $message_type = Context::get('message_type');
56  if(!in_array($message_type, array('R', 'S', 'T')))
57  {
58  $message_type = 'R';
59  Context::set('message_type', $message_type);
60  }
61  $oCommunicationModel = getModel('communication');
62 
63  // extract contents if message_srl exists
64  if($message_srl)
65  {
66  $templateFile = 'read_message';
67  $columnList = array('message_srl', 'sender_srl', 'receiver_srl', 'message_type', 'title', 'content', 'readed', 'regdate');
68  $message = $oCommunicationModel->getSelectedMessage($message_srl, $columnList);
69 
70  switch($message->message_type)
71  {
72  case 'R':
73  if($message->receiver_srl != $logged_info->member_srl)
74  {
75  return $this->stop('msg_invalid_request');
76  }
77  break;
78 
79  case 'S':
80  if($message->sender_srl != $logged_info->member_srl)
81  {
82  return $this->stop('msg_invalid_request');
83  }
84  break;
85 
86  case 'T':
87  if($message->receiver_srl != $logged_info->member_srl && $message->sender_srl != $logged_info->member_srl)
88  {
89  return $this->stop('msg_invalid_request');
90  }
91  break;
92  }
93 
94  if($message->message_srl == $message_srl && ($message->receiver_srl == $logged_info->member_srl || $message->sender_srl == $logged_info->member_srl))
95  {
96  stripEmbedTagForAdmin($message->content, $message->sender_srl);
97  Context::set('message', $message);
98  }
99  }
100  else
101  {
102  $templateFile = 'messages';
103  }
104 
105  // Extract a list
106  $columnList = array('message_srl', 'readed', 'title', 'member.member_srl', 'member.nick_name', 'message.regdate', 'readed_date');
107  $output = $oCommunicationModel->getMessages($message_type, $columnList);
108 
109  // set a template file
110  Context::set('total_count', $output->total_count);
111  Context::set('total_page', $output->total_page);
112  Context::set('page', $output->page);
113  Context::set('message_list', $output->data);
114  Context::set('page_navigation', $output->page_navigation);
115 
116  $oSecurity = new Security();
117  $oSecurity->encodeHTML('message_list..nick_name');
118 
119  $this->setTemplateFile($templateFile);
120  }
121 
127  {
128  $this->setTemplateFile('message_box');
129  }
130 
136  {
137  $oCommunicationModel = getModel('communication');
138  $oMemberModel = getModel('member');
139 
140  // Error appears if not logged-in
141  if(!Context::get('is_logged'))
142  {
143  return $this->stop('msg_not_logged');
144  }
145 
146  $logged_info = Context::get('logged_info');
147 
148  // get receipient's information
149  // check inalid request
150  $receiver_srl = Context::get('receiver_srl');
151  if(!$receiver_srl)
152  {
153  return $this->stop('msg_invalid_request');
154  }
155 
156  // check receiver and sender are same
157  if($logged_info->member_srl == $receiver_srl)
158  {
159  return $this->stop('msg_cannot_send_to_yourself');
160  }
161 
162  // get message_srl of the original message if it is a reply
163  $message_srl = Context::get('message_srl');
164  if($message_srl)
165  {
166  $source_message = $oCommunicationModel->getSelectedMessage($message_srl);
167  if($source_message->message_srl == $message_srl && $source_message->sender_srl == $receiver_srl)
168  {
169  $source_message->title = "[re] " . $source_message->title;
170  $source_message->content = "\r\n<br />\r\n<br /><div style=\"padding-left:5px; border-left:5px solid #DDDDDD;\">" . trim($source_message->content) . "</div>";
171  Context::set('source_message', $source_message);
172  }
173  }
174 
175  $receiver_info = $oMemberModel->getMemberInfoByMemberSrl($receiver_srl);
176  if(!$receiver_info)
177  {
178  return $this->stop('msg_invalid_request');
179  }
180 
181  $oEditorModel = getModel('editor');
182  $option = new stdClass();
183  $option->primary_key_name = 'receiver_srl';
184  $option->content_key_name = 'new_content';
185  $option->allow_fileupload = FALSE;
186  $option->enable_autosave = FALSE;
187  $option->enable_default_component = TRUE;
188  $option->enable_component = FALSE;
189  $option->resizable = FALSE;
190  $option->disable_html = TRUE;
191  $option->height = 150;
192  $option->skin = $this->communication_config->editor_skin;
193  $option->colorset = $this->communication_config->editor_colorset;
194  $editor = $oEditorModel->getEditor($logged_info->member_srl, $option);
195 
196  Context::set('receiver_info', $receiver_info);
197  Context::set('editor', $editor);
198 
199  $this->setTemplateFile('send_message');
200  }
201 
202 }
203 /* End of file communication.mobile.php */
204 /* Location: ./modules/comment/communication.mobile.php */
setTemplateFile($filename)
stripEmbedTagForAdmin(&$content, $writer_member_srl)
Definition: func.inc.php:1568
$output
Definition: ko.install.php:193
set($key, $val, $set_to_get_vars=0)
const _XE_PATH_
Definition: config.inc.php:49
getModel($module_name)
Definition: func.inc.php:145