GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( baac3d...439f66 )
by gyeong-won
17:54
created

addonAdminController::doDeactivate()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 19
Code Lines 11

Duplication

Lines 19
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 11
nc 4
nop 4
dl 19
loc 19
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/* Copyright (C) NAVER <http://www.navercorp.com> */
3
4
require_once(_XE_PATH_ . 'modules/addon/addon.controller.php');
5
6
/**
7
 * Admin controller class of addon modules
8
 * @author NAVER ([email protected])
9
 */
10
class addonAdminController extends addonController
11
{
12
13
	/**
14
	 * Initialization
15
	 *
16
	 * @return void
17
	 */
18
	function init()
19
	{
20
21
	}
22
23
	/**
24
	 * Set addon activate
25
	 *
26
	 * @return Object
27
	 */
28
	function procAddonAdminSaveActivate()
29
	{
30
		$pcOnList = Context::get('pc_on');
31
		$mobileOnList = Context::get('mobile_on');
32
		$fixed = Context::get('fixed');
33
34
		$site_module_info = Context::get('site_module_info');
35
36
		if($site_module_info->site_srl)
37
		{
38
			$site_srl = $site_module_info->site_srl;
39
		}
40
		else
41
		{
42
			$site_srl = 0;
43
		}
44
45
		if(!$pcOnList)
46
		{
47
			$pcOnList = array();
48
		}
49
		if(!$mobileOnList)
50
		{
51
			$mobileOnList = array();
52
		}
53
		if(!$fixed)
54
		{
55
			$fixed = array();
56
		}
57
58
		if(!is_array($pcOnList))
59
		{
60
			$pcOnList = array($pcOnList);
61
		}
62
		if(!is_array($mobileOnList))
63
		{
64
			$pcOnList = array($mobileOnList);
65
		}
66
		if(!is_array($fixed))
67
		{
68
			$pcOnList = array($fixed);
69
		}
70
71
		// get current addon info
72
		$oModel = getAdminModel('addon');
73
		$currentAddonList = $oModel->getAddonList($site_srl, 'site');
74
75
		// get need update addon list
76
		$updateList = array();
77
		foreach($currentAddonList as $addon)
78
		{
79
			if($addon->activated !== in_array($addon->addon_name, $pcOnList))
80
			{
81
				$updateList[] = $addon->addon_name;
82
				continue;
83
			}
84
85
			if($addon->mactivated !== in_array($addon->addon_name, $mobileOnList))
86
			{
87
				$updateList[] = $addon->addon_name;
88
				continue;
89
			}
90
91
			if($addon->fixed !== in_array($addon->addon_name, $fixed))
92
			{
93
				$updateList[] = $addon->addon_name;
94
				continue;
95
			}
96
		}
97
98
		// update
99
		foreach($updateList as $targetAddon)
100
		{
101
			$args = new stdClass();
102
103
			if(in_array($targetAddon, $pcOnList))
104
			{
105
				$args->is_used = 'Y';
106
			}
107
			else
108
			{
109
				$args->is_used = 'N';
110
			}
111
112
			if(in_array($targetAddon, $mobileOnList))
113
			{
114
				$args->is_used_m = 'Y';
115
			}
116
			else
117
			{
118
				$args->is_used_m = 'N';
119
			}
120
121
			if(in_array($targetAddon, $fixed))
122
			{
123
				$args->fixed = 'Y';
124
			}
125
			else
126
			{
127
				$args->fixed = 'N';
128
			}
129
130
			$args->addon = $targetAddon;
131
			$args->site_srl = $site_srl;
132
133
			$output = executeQuery('addon.updateSiteAddon', $args);
134
			if(!$output->toBool())
135
			{
136
				return $output;
137
			}
138
		}
139
140
		if(count($updateList))
141
		{
142
			$this->makeCacheFile($site_srl, 'pc', 'site');
143
			$this->makeCacheFile($site_srl, 'mobile', 'site');
144
		}
145
146
		$this->setMessage('success_updated', 'info');
147 View Code Duplication
		if(Context::get('success_return_url'))
148
		{
149
			$this->setRedirectUrl(Context::get('success_return_url'));
150
		}
151
		else
152
		{
153
			$this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAddonAdminIndex'));
154
		}
155
	}
156
157
	/**
158
	 * Add active/inactive change
159
	 *
160
	 * @return Object
161
	 */
162
	function procAddonAdminToggleActivate()
163
	{
164
		$oAddonModel = getAdminModel('addon');
165
166
		$site_module_info = Context::get('site_module_info');
167
		// batahom addon values
168
		$addon = Context::get('addon');
169
		$type = Context::get('type');
170
		if(!$type)
171
		{
172
			$type = "pc";
173
		}
174
		if($addon)
175
		{
176
			// If enabled Disables
177
			if($oAddonModel->isActivatedAddon($addon, $site_module_info->site_srl, $type))
178
			{
179
				$this->doDeactivate($addon, $site_module_info->site_srl, $type);
180
			}
181
			// If it is disabled Activate
182
			else
183
			{
184
				$this->doActivate($addon, $site_module_info->site_srl, $type);
185
			}
186
		}
187
188
		$this->makeCacheFile($site_module_info->site_srl, $type);
189
	}
190
191
	/**
192
	 * Add the configuration information input
193
	 *
194
	 * @return Object
195
	 */
196
	function procAddonAdminSetupAddon()
197
	{
198
		$args = Context::getRequestVars();
199
		$module = $args->module;
200
		$addon_name = $args->addon_name;
201
		unset($args->module);
202
		unset($args->act);
203
		unset($args->addon_name);
204
		unset($args->body);
205
		unset($args->error_return_url);
206
207
		$site_module_info = Context::get('site_module_info');
208
209
		$output = $this->doSetup($addon_name, $args, $site_module_info->site_srl, 'site');
210
		if(!$output->toBool())
211
		{
212
			return $output;
213
		}
214
215
		$this->makeCacheFile($site_module_info->site_srl, "pc", 'site');
216
		$this->makeCacheFile($site_module_info->site_srl, "mobile", 'site');
217
218
		$this->setRedirectUrl(getNotEncodedUrl('', 'module', $module, 'act', 'dispAddonAdminSetup', 'selected_addon', $addon_name), $output);
219
	}
220
221
	/**
222
	 * Adds addon to DB
223
	 *
224
	 * @param string $addon Addon name
225
	 * @param int $site_srl Site srl
226
	 * @param string $gtype site or global
227
	 * @param string $isUsed Whether to use
228
	 * @return Object
229
	 */
230
	function doInsert($addon, $site_srl = 0, $gtype = 'site', $isUsed = 'N')
231
	{
232
		$args = new stdClass;
233
		$args->addon = $addon;
234
		$args->is_used = $isUsed;
235
		if($gtype == 'global')
236
		{
237
			return executeQuery('addon.insertAddon', $args);
238
		}
239
		$args->site_srl = $site_srl;
240
		return executeQuery('addon.insertSiteAddon', $args);
241
	}
242
243
	/**
244
	 * Activate addon
245
	 *
246
	 * @param string $addon Addon name
247
	 * @param int $site_srl Site srl
248
	 * @param string $type pc or modile
249
	 * @param string $gtype site or global
250
	 * @return Object
251
	 */
252 View Code Duplication
	function doActivate($addon, $site_srl = 0, $type = "pc", $gtype = 'site')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
253
	{
254
		$args = new stdClass();
255
		$args->addon = $addon;
256
		if($type == "pc")
257
		{
258
			$args->is_used = 'Y';
259
		}
260
		else
261
		{
262
			$args->is_used_m = "Y";
263
		}
264
		if($gtype == 'global')
265
		{
266
			return executeQuery('addon.updateAddon', $args);
267
		}
268
		$args->site_srl = $site_srl;
269
		return executeQuery('addon.updateSiteAddon', $args);
270
	}
271
272
	/**
273
	 * Deactivate Addon
274
	 *
275
	 * @param string $addon Addon name
276
	 * @param int $site_srl Site srl
277
	 * @param string $type pc or mobile
278
	 * @param string $gtype site or global
279
	 */
280 View Code Duplication
	function doDeactivate($addon, $site_srl = 0, $type = "pc", $gtype = 'site')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
281
	{
282
		$args = new stdClass();
283
		$args->addon = $addon;
284
		if($type == "pc")
285
		{
286
			$args->is_used = 'N';
287
		}
288
		else
289
		{
290
			$args->is_used_m = 'N';
291
		}
292
		if($gtype == 'global')
293
		{
294
			return executeQuery('addon.updateAddon', $args);
295
		}
296
		$args->site_srl = $site_srl;
297
		return executeQuery('addon.updateSiteAddon', $args);
298
	}
299
300
}
301
/* End of file addon.admin.controller.php */
302
/* Location: ./modules/addon/addon.admin.controller.php */
303