forked from bjrambo/xe-module-notifymessage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotifymessage.class.php
More file actions
136 lines (122 loc) · 3.12 KB
/
notifymessage.class.php
File metadata and controls
136 lines (122 loc) · 3.12 KB
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
<?php
class notifymessage extends ModuleObject
{
/**
* 설치할 트리거를 배열형태로 저장한다음 배열대로 각각 설치를 할 수 잇도록 추가
* @var array
*/
private $triggers = array(
array('ncenterlite._insertNotify', 'notifymessage', 'controller', 'triggerAfterinsertNotify', 'after'),
array('document.insertDocument', 'notifymessage', 'controller', 'triggerAfterInsertDocument', 'after'),
array('comment.insertComment', 'notifymessage', 'controller', 'triggerAfterInsertComment', 'after'),
);
/**
* Install notifymessage module
* @return Object
*/
function moduleInstall()
{
return new Object();
}
/**
* If update is necessary it returns true
* @return bool
*/
function checkUpdate()
{
$oModuleModel = getModel('module');
foreach($this->triggers as $trigger)
{
if(!$oModuleModel->getTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4]))
{
return true;
}
}
$config = getModel('notifymessage')->getConfig();
// getConfig 단위에서는 모든 설정을 캐시에서 불러오므로 디비쿼리를 하지않지만 맴버쪽은 로직에 따라 불필요한 동작이 있을 수 있음
if(!$config->variable_name)
{
$member_config = getModel('member')->getMemberConfig();
$variable_name = array();
foreach($member_config->signupForm as $value)
{
if($value->type == 'tel')
{
$variable_name[] = $value->name;
}
}
if(!$config->variable_name && count($variable_name) == 1)
{
return true;
}
}
return FALSE;
}
/**
* Update module
* @return Object
*/
function moduleUpdate()
{
$oModuleModel = getModel('module');
$oModuleController = getController('module');
foreach($this->triggers as $trigger)
{
if(!$oModuleModel->getTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4]))
{
$oModuleController->insertTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4]);
}
}
$config = getModel('notifymessage')->getConfig();
if(!$config)
{
$config = new stdClass();
}
if(!$config->variable_name)
{
$member_config = getModel('member')->getMemberConfig();
$variable_name = array();
foreach($member_config->signupForm as $value)
{
if($value->type == 'tel')
{
$variable_name[] = $value->name;
}
}
if(count($variable_name) == 1)
{
foreach($variable_name as $item)
{
$config->variable_name = $item;
}
$output = $oModuleController->insertModuleConfig('notifymessage', $config);
if(!$output->toBool())
{
return new Object(-1, '모듈설정을 저장하지 못했습니다.');
}
}
}
}
/**
* Regenerate cache file
* @return void
*/
function recompileCache()
{
}
/**
* module unstall.
* @return Object
*/
function moduleUninstall()
{
$oModuleController = getController('module');
foreach($this->triggers as $trigger)
{
$oModuleController->deleteTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4]);
}
return new Object();
}
}
/* End of file notifymessage.class.php */
/* Location: ./modules/notifymessage/notifymessage.class.php */