-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexperience.class.php
More file actions
204 lines (174 loc) · 4.77 KB
/
experience.class.php
File metadata and controls
204 lines (174 loc) · 4.77 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
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
<?php
/**
* @class experience
* @author CONORY (http://www.conory.com)
* @brief The parent class of the experience module
**/
class experience extends ModuleObject
{
private $triggers = array(
array('point.setPoint', 'experience', 'controller', 'triggerSetPoint', 'after'),
array('moduleHandler.init', 'experience', 'controller', 'triggerModuleHandlerInitAfter', 'after'),
);
private $deleteTriggers = array(
);
private $oCacheHandler = NULL;
/**
* @brief 모듈 설치
*/
function moduleInstall()
{
FileHandler::makeDir('./files/member_extra_info/experience');
$config = new stdClass;
$config->max_level = 30;
$config->level_icon = 'default';
for ($i = 1; $i <= 30; $i++)
{
$config->level_step[$i] = pow($i, 2) * 90;
}
$oModuleController = getController('module');
$oModuleController->insertModuleConfig('experience', $config);
return new BaseObject();
}
/**
* @brief 업데이트 체크
*/
function checkUpdate()
{
$oModuleModel = moduleModel::getInstance();
//트리커 설치
foreach ($this->triggers as $trigger)
{
if(version_compare(RX_VERSION, '2.0.20', '<'))
{
if($this->triggers[0] == 'moduleHandler.init')
{
continue;
}
}
if (!$oModuleModel->getTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4]))
{
return true;
}
}
//레벨업 알림을 위한 알림타입 설치 (알림센터)
$config = $oModuleModel->getModuleConfig('experience');
if (is_dir('./modules/ncenterlite'))
{
$oNcenterliteModel = ncenterliteModel::getInstance();
if (!$config->levelup_ntype || !$oNcenterliteModel->isNotifyTypeExistsbySrl($config->levelup_ntype))
{
return true;
}
if (!$config->medal_update_ntype || !$oNcenterliteModel->isNotifyTypeExistsbySrl($config->medal_update_ntype))
{
return true;
}
}
return false;
}
/**
* @brief 업데이트
*/
function moduleUpdate()
{
$oModuleModel = moduleModel::getInstance();
$oModuleController = moduleController::getInstance();
//트리커 설치
foreach ($this->triggers as $trigger)
{
if(version_compare(RX_VERSION, '2.0.20', '<'))
{
if($this->triggers[0] == 'moduleHandler.init')
{
continue;
}
}
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 = $oModuleModel->getModuleConfig('experience');
if (is_dir('./modules/ncenterlite'))
{
/** @var ncenterliteModel $oNcenterliteModel */
$oNcenterliteModel = ncenterliteModel::getInstance();
if (!$config->levelup_ntype || !$oNcenterliteModel->isNotifyTypeExistsbySrl($config->levelup_ntype))
{
$args = new stdClass;
$args->notify_type_srl = getNextSequence();
$args->notify_type_id = 'levelup';
$args->notify_type_args = 'level';
$args->notify_string = '<strong>레벨 Up!</strong> Lv.%level%이 되셨습니다.';
$oNcenterliteModel->insertNotifyType($args);
$config->levelup_ntype = $args->notify_type_srl;
$oModuleController->insertModuleConfig('experience', $config);
}
if (!$config->medal_update_ntype || !$oNcenterliteModel->isNotifyTypeExistsbySrl($config->medal_update_ntype))
{
$args = new stdClass();
$args->notify_type_srl = getNextSequence();
$args->notify_type_id = 'medal_gift';
$args->notify_type_args = 'medal';
$args->notify_string = '<strong>메달 지급!</strong> 저번 달 활동으로 <strong>%medal%</strong>을 흭득하였습니다. 축하드립니다.';
$oNcenterliteModel->insertNotifyType($args);
$config->medal_update_ntype = $args->notify_type_srl;
$oModuleController->insertModuleConfig('experience', $config);
}
}
return new BaseObject(0, 'success_updated');
}
/**
* @brief 모듈제거
*/
function recompileCache()
{
}
function getCacheHandler()
{
if ($this->oCacheHandler === NULL)
{
$this->oCacheHandler = CacheHandler::getInstance('object');
if (!$this->oCacheHandler->isSupport())
{
$this->oCacheHandler = false;
}
}
return $this->oCacheHandler;
}
function getConfig()
{
$config = moduleModel::getInstance()->getModuleConfig('experience');
if (!$config->max_level)
{
$config->max_level = 30;
}
if ($config->max_level > 1000)
{
$config->max_level = 1000;
}
if ($config->max_level < 1)
{
$config->max_level = 1;
}
if (!$config->level_icon)
{
$config->level_icon = 'default';
}
if (!$config->medal_icon)
{
$config->medal_icon = 'default';
}
if (!$config->sync_point)
{
$config->sync_point = FALSE;
}
if(!$config->experience_group)
{
$config->experience_group = [];
}
return $config;
}
}