-
Notifications
You must be signed in to change notification settings - Fork 0
/
notification.model.php
200 lines (172 loc) · 4.85 KB
/
notification.model.php
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
<?php
/**
* vi:set sw=4 ts=4 noexpandtab fileencoding=utf8:
* @class notificationModel
* @author diver([email protected])
* @brief notificationModel
*/
class notificationModel extends notification
{
function init()
{
}
/**
* 모듈 환경설정값 가져오기
*/
function getModuleConfig()
{
if (!$GLOBALS['__notification_config__'])
{
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('notification');
$GLOBALS['__notification_config__'] = $config;
}
return $GLOBALS['__notification_config__'];
}
/**
* 특정 필드가 설정 된 값이 있는지 체크
*/
function isConfigFieldSetted($field_name)
{
$config = $this->getModuleConfig();
if (isset($config->{$field_name}) && $config->{$field_name}) return true;
return false;
}
/**
* 환경값 읽어오기
*/
function getConfig()
{
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('notification');
// country code
if (!$config->default_country) $config->default_country = '82';
if ($config->default_country == '82')
{
$config->limit_bytes = 80;
}
else
{
$config->limit_bytes = 160;
}
// callback
$callback = explode("|@|", $config->callback); // source
$config->a_callback = $callback; // array
$config->s_callback = join($callback); // string
// admin_phone
if (!is_array($config->admin_phones))
$config->admin_phones = explode("|@|", $config->admin_phones);
return $config;
}
/**
* $obj : member info object.
*/
function getConfigValue(&$obj, $fieldname, $type=null)
{
$return_value = null;
$config = $this->getModuleConfig();
// 기본필드에서 확인
if ($obj->{$fieldname})
{
$return_value = $obj->{$fieldname};
}
// 확장필드에서 확인
if ($obj->extra_vars)
{
$extra_vars = unserialize($obj->extra_vars);
if ($extra_vars->{$fieldname}) {
$return_value = $extra_vars->{$fieldname};
}
}
if ($type=='tel' && is_array($return_value))
{
$return_value = implode($return_value);
}
return $return_value;
}
function getNotificationList()
{
$query_id = 'notification.getNotificationList';
$args->page = Context::get('page');
$args->list_count = 40;
$args->page_count = 10;
return executeQuery($query_id, $args);
}
function getMessageInfo($args)
{
$query_id = 'notification.getNotification';
return executeQuery($query_id, $args);
}
function getNotificationMessageInfo()
{
$logged_info = Context::get('logged_info');
if (!$logged_info) return new Object(-1, 'msg_login_required');
$args->msgid = Context::get('msgid');
$output = $this->getMessageInfo($args);
$output->data->content = str_replace("\r", "", $output->data->content);
$output->data->content = str_replace("\n", "<br>", $output->data->content);
$this->add('data', $output->data);
}
function getNotificationListByMessageId()
{
$message_ids_arr = explode(',', Context::get('message_ids'));
$args->message_ids = "'" . implode("','", $message_ids_arr) . "'";
$output = executeQueryArray('notification.getStatusListByMessageId', $args);
if(!$output->toBool()) return $output;
$this->add('data', $output->data);
}
/**
* @brief MemberMessageList 가져오기
**/
function getNotificationMemberMessageList()
{
$logged_info = Context::get('logged_info');
if (!$logged_info) return new Object(-1, 'msg_login_required');
$args->gid = Context::get('gid');
$output = $this->getMessagesInGroup($args);
foreach ($output->data as $no => $row)
{
$output->data[$no]->content = str_replace("\r", "", $output->data[$no]->content);
$output->data[$no]->content = str_replace("\n", "", $output->data[$no]->content);
}
$this->add('total_count', $output->total_count);
$this->add('total_page', $output->total_page);
$this->add('page', $output->page);
$this->add('data', $output->data);
$this->add('gid', Context::get('gid'));
$config = $this->getModuleConfig();
$this->add('base_url', $config->callback_url);
}
function getNotiConfig($module_srl)
{
if (!$module_srl) return false;
$args->module_srl = $module_srl;
$output = executeQuery("notification.getNotiConfigByModuleSrl", $args);
if (!$output->toBool() || !$output->data) return false;
$noticom_infos = $output->data;
if (!is_array($noticom_infos)) $noticom_infos = array($output->data);
foreach($noticom_infos as $key=>$val)
{
$extra_vars = unserialize($val->extra_vars);
if ($extra_vars)
{
foreach ($extra_vars as $key2 => $val2)
{
$noticom_infos[$key]->{$key2} = $val2;
}
}
}
return $noticom_infos;
}
/**
* @brief get registered sender ids
*/
function getRegisteredSenderIds()
{
$oTextMessageModel = &getModel('textmessage');
$result = $oTextMessageModel->getSenderNumbers();
return $result;
}
}
/* End of file newposts.model.php */
/* Location: ./modules/newposts/newposts.model.php */