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.

memberAdminController   F
last analyzed

Complexity

Total Complexity 225

Size/Duplication

Total Lines 1473
Duplicated Lines 7.26 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 0
Metric Value
dl 107
loc 1473
rs 0.8
c 0
b 0
f 0
wmc 225
lcom 1
cbo 8

38 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 3 1
F procMemberAdminInsert() 32 119 26
A procMemberAdminDelete() 0 12 2
B procMemberAdminInsertDefaultConfig() 0 47 9
F procMemberAdminInsertSignupConfig() 0 142 23
A procMemberAdminInsertLoginConfig() 0 35 5
B procMemberAdminInsertDesignConfig() 0 36 7
C createSignupForm() 9 66 11
C _createSignupRuleset() 0 68 14
A _createLoginRuleset() 0 22 1
A _createFindAccountByQuestion() 0 25 2
A procMemberAdminInsertGroup() 0 13 3
A procMemberAdminUpdateGroup() 0 16 3
A procMemberAdminDeleteGroup() 14 14 3
F procMemberAdminInsertJoinForm() 7 86 15
A procMemberAdminDeleteJoinForm() 8 20 3
B procMemberAdminUpdateJoinForm() 0 26 6
C procMemberAdminSelectedMemberManage() 0 86 14
A procMemberAdminDeleteMembers() 19 19 4
C procMemberAdminUpdateMembersGroup() 0 63 10
A procMemberAdminInsertDeniedID() 0 21 5
B procMemberAdminUpdateDeniedNickName() 0 34 7
A procMemberAdminUpdateDeniedID() 0 17 3
A insertAdmin() 0 12 1
A changeGroup() 0 11 1
B insertGroup() 9 26 7
A updateGroup() 9 19 5
A deleteGroup() 0 26 3
B procMemberAdminGroupConfig() 0 52 6
A procMemberAdminUpdateGroupOrder() 0 16 2
A _deleteMemberGroupCache() 0 9 2
A insertDeniedID() 0 9 1
A insertDeniedNickName() 0 8 1
A deleteDeniedID() 0 8 2
A deleteDeniedNickName() 0 8 2
A deleteJoinForm() 0 7 1
B moveJoinFormUp() 0 40 7
B moveJoinFormDown() 0 41 7

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like memberAdminController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use memberAdminController, and based on these observations, apply Extract Interface, too.

1
<?php
2
/* Copyright (C) XEHub <https://www.xehub.io> */
3
/**
4
 * @class  memberAdminController
5
 * @author XEHub ([email protected])
6
 * member module of the admin controller class
7
 */
8
class memberAdminController extends member
9
{
10
	/**
11
	 * Initialization
12
	 * @return void
13
	 */
14
	function init()
15
	{
16
	}
17
18
	/**
19
	 * Add a user (Administrator)
20
	 * @return void|BaseObject (void : success, BaseObject : fail)
21
	 */
22
	function procMemberAdminInsert()
23
	{
24
		// if(Context::getRequestMethod() == "GET") return new BaseObject(-1, "msg_invalid_request");
25
		// Extract the necessary information in advance
26
		$logged_info = Context::get('logged_info');
27
		if($logged_info->is_admin != 'Y' || !checkCSRF())
28
		{
29
			return new BaseObject(-1, 'msg_invalid_request');
30
		}
31
32
		$args = Context::gets('member_srl','email_address','find_account_answer', 'allow_mailing','allow_message','denied','is_admin','description','group_srl_list','limit_date');
33
		$oMemberModel = &getModel ('member');
34
		$config = $oMemberModel->getMemberConfig();
35
		$getVars = array();
36 View Code Duplication
		if($config->signupForm)
37
		{
38
			foreach($config->signupForm as $formInfo)
39
			{
40
				if($formInfo->isDefaultForm && ($formInfo->isUse || $formInfo->required || $formInfo->mustRequired))
41
				{
42
					$getVars[] = $formInfo->name;
43
				}
44
			}
45
		}
46
		foreach($getVars as $val)
47
		{
48
			$args->{$val} = Context::get($val);
49
		}
50
		$args->member_srl = Context::get('member_srl');
51
		if(Context::get('reset_password'))
52
			$args->password = Context::get('reset_password');
53
		else unset($args->password);
54
55
		// Remove some unnecessary variables from all the vars
56
		$all_args = Context::getRequestVars();
57
		unset($all_args->module);
58
		unset($all_args->act);
59
		unset($all_args->mid);
60
		unset($all_args->error_return_url);
61
		unset($all_args->success_return_url);
62
		unset($all_args->ruleset);
63
		unset($all_args->password);
64
		unset($all_args->password2);
65
		unset($all_args->reset_password);
66
67
		if(!isset($args->limit_date)) $args->limit_date = "";
68
		if(!isset($args->description)) $args->description = "";
69
70
		// Add extra vars after excluding necessary information from all the requested arguments
71
		$extra_vars = delObjectVars($all_args, $args);
72
		$args->extra_vars = serialize($extra_vars);
73
		// Check if an original member exists having the member_srl
74
		if($args->member_srl)
75
		{
76
			// Create a member model object
77
			$oMemberModel = getModel('member');
78
			// Get memebr profile
79
			$columnList = array('member_srl');
80
			$member_info = $oMemberModel->getMemberInfoByMemberSrl($args->member_srl, 0, $columnList);
81
			// If no original member exists, make a new one
82
			if($member_info->member_srl != $args->member_srl) unset($args->member_srl);
83
		}
84
85
		// remove whitespace
86
		$checkInfos = array('user_id', 'user_name', 'nick_name', 'email_address');
87 View Code Duplication
		foreach($checkInfos as $val)
88
		{
89
			if(isset($args->{$val}))
90
			{
91
				$args->{$val} = preg_replace('/[\pZ\pC]+/u', '', html_entity_decode($args->{$val}));
92
			}
93
		}
94
95
		$oMemberController = getController('member');
96
		// Execute insert or update depending on the value of member_srl
97
		if(!$args->member_srl)
98
		{
99
			$args->password = Context::get('password');
100
			$output = $oMemberController->insertMember($args);
101
			$msg_code = 'success_registed';
102
		}
103
		else
104
		{
105
			$output = $oMemberController->updateMember($args);
106
			$msg_code = 'success_updated';
107
		}
108
109
		if(!$output->toBool()) return $output;
110
		// Save Signature
111
		$signature = Context::get('signature');
112
		$oMemberController->putSignature($args->member_srl, $signature);
113
		// Return result
114
		$this->add('member_srl', $args->member_srl);
115
		$this->setMessage($msg_code);
116
117
		$profile_image = Context::get('profile_image');
118 View Code Duplication
		if(is_uploaded_file($profile_image['tmp_name']))
119
		{
120
			$output = $oMemberController->insertProfileImage($args->member_srl, $profile_image['tmp_name']);
121
			if(!$output->toBool()) return $output;
122
		}
123
124
		$image_mark = Context::get('image_mark');
125 View Code Duplication
		if(is_uploaded_file($image_mark['tmp_name']))
126
		{
127
			$output = $oMemberController->insertImageMark($args->member_srl, $image_mark['tmp_name']);
128
			if(!$output->toBool()) return $output;
129
		}
130
131
		$image_name = Context::get('image_name');
132 View Code Duplication
		if (is_uploaded_file($image_name['tmp_name']))
133
		{
134
			$output = $oMemberController->insertImageName($args->member_srl, $image_name['tmp_name']);
135
			if(!$output->toBool()) return $output;
136
		}
137
138
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminList');
139
		$this->setRedirectUrl($returnUrl);
140
	}
141
142
	/**
143
	 * Delete a user (Administrator)
144
	 * @return void|BaseObject (void : success, BaseObject : fail)
145
	 */
146
	function procMemberAdminDelete()
147
	{
148
		// Separate all the values into DB entries and others
149
		$member_srl = Context::get('member_srl');
150
151
		$oMemberController = getController('member');
152
		$output = $oMemberController->deleteMember($member_srl);
153
		if(!$output->toBool()) return $output;
154
155
		$this->add('page',Context::get('page'));
156
		$this->setMessage("success_deleted");
157
	}
158
159
160
	public function procMemberAdminInsertDefaultConfig()
161
	{
162
		$args = Context::gets(
163
			'enable_join',
164
			'enable_confirm',
165
			'webmaster_name',
166
			'webmaster_email',
167
			'password_strength',
168
			'password_hashing_algorithm',
169
			'password_hashing_work_factor',
170
			'password_hashing_auto_upgrade'
171
		);
172
173
		$oPassword = new Password();
174
		if(!array_key_exists($args->password_hashing_algorithm, $oPassword->getSupportedAlgorithms()))
175
		{
176
			$args->password_hashing_algorithm = 'md5';
177
		}
178
179
		$args->password_hashing_work_factor = intval($args->password_hashing_work_factor, 10);
180
		if($args->password_hashing_work_factor < 4)
181
		{
182
			$args->password_hashing_work_factor = 4;
183
		}
184
		if($args->password_hashing_work_factor > 16)
185
		{
186
			$args->password_hashing_work_factor = 16;
187
		}
188
		if($args->password_hashing_auto_upgrade != 'Y')
189
		{
190
			$args->password_hashing_auto_upgrade = 'N';
191
		}
192
193
		if((!$args->webmaster_name || !$args->webmaster_email) && $args->enable_confirm == 'Y')
194
		{
195
			return new BaseObject(-1, 'msg_mail_authorization');
196
		}
197
198
		$oModuleController = getController('module');
199
		$output = $oModuleController->updateModuleConfig('member', $args);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
200
201
		// default setting end
202
		$this->setMessage('success_updated');
203
204
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminDefaultConfig');
205
		$this->setRedirectUrl($returnUrl);
206
	}
207
208
	public function procMemberAdminInsertSignupConfig()
209
	{
210
		$oMemberModel = getModel('member');
211
		$oModuleController = getController('module');
212
213
		$args = Context::gets(
214
			'limit_day',
215
			'limit_day_description',
216
			'agreement',
217
			'redirect_url',
218
			'profile_image', 'profile_image_max_width', 'profile_image_max_height', 'profile_image_max_filesize',
219
			'image_name', 'image_name_max_width', 'image_name_max_height', 'image_name_max_filesize',
220
			'image_mark', 'image_mark_max_width', 'image_mark_max_height', 'image_mark_max_filesize',
221
			'signature_editor_skin', 'sel_editor_colorset'
222
		);
223
224
		$list_order = Context::get('list_order');
225
		$usable_list = Context::get('usable_list');
226
		$all_args = Context::getRequestVars();
227
228
		$args->limit_day = (int)$args->limit_day;
229
		if(!trim(strip_tags($args->agreement)))
230
		{
231
			$agreement_file = _XE_PATH_.'files/member_extra_info/agreement_' . Context::get('lang_type') . '.txt';
232
			FileHandler::removeFile($agreement_file);
233
			$args->agreement = NULL;
234
		}
235
236
		if($args->redirect_url)
237
		{
238
			$oModuleModel = getModel('module');
239
			$redirectModuleInfo = $oModuleModel->getModuleInfoByModuleSrl($args->redirect_url, array('mid'));
240
241
			if(!$redirectModuleInfo)
242
			{
243
				return new BaseObject('-1', 'msg_exist_selected_module');
244
			}
245
246
			$args->redirect_url = Context::getDefaultUrl().$redirectModuleInfo->mid;
247
		}
248
249
		$args->profile_image = $args->profile_image ? 'Y' : 'N';
250
		$args->image_name = $args->image_name ? 'Y' : 'N';
251
		$args->image_mark = $args->image_mark ? 'Y' : 'N';
252
		$args->signature  = $args->signature != 'Y' ? 'N' : 'Y';
253
		$args->identifier = $all_args->identifier;
0 ignored issues
show
Bug introduced by
The property identifier does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
254
255
		// set default
256
		$all_args->is_nick_name_public = 'Y';
0 ignored issues
show
Bug introduced by
The property is_nick_name_public does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
257
		$all_args->is_find_account_question_public = 'N';
0 ignored issues
show
Bug introduced by
The property is_find_account_question_public does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
258
259
		// signupForm
260
		global $lang;
261
		$signupForm = array();
262
		$items = array(
263
			'user_id',
264
			'password',
265
			'user_name',
266
			'nick_name',
267
			'email_address',
268
			'find_account_question',
269
			'homepage',
270
			'blog',
271
			'birthday',
272
			'signature',
273
			'profile_image', 'profile_image_max_width', 'profile_image_max_height', 'profile_image_max_filesize',
274
			'image_name', 'image_name_max_width', 'image_name_max_height', 'image_name_max_filesize',
275
			'image_mark', 'image_mark_max_width', 'image_mark_max_height', 'image_mark_max_filesize',
276
		);
277
		$mustRequireds = array('email_address', 'nick_name', 'password', 'find_account_question');
278
		$extendItems = $oMemberModel->getJoinFormList();
279
280
		foreach($list_order as $key)
0 ignored issues
show
Bug introduced by
The expression $list_order of type string is not traversable.
Loading history...
281
		{
282
			$signupItem = new stdClass();
283
			$signupItem->isIdentifier = ($key == $all_args->identifier);
284
			$signupItem->isDefaultForm = in_array($key, $items);
285
			$signupItem->name = $key;
286
			$signupItem->title = (!in_array($key, $items)) ? $key : $lang->{$key};
287
			$signupItem->mustRequired = in_array($key, $mustRequireds);
288
			$signupItem->imageType = (strpos($key, 'image') !== false);
289
			$signupItem->required = ($all_args->{$key} == 'required') || $signupItem->mustRequired || $signupItem->isIdentifier;
290
			$signupItem->isUse = in_array($key, $usable_list) || $signupItem->required;
291
			$signupItem->isPublic = ($all_args->{'is_'.$key.'_public'} == 'Y' && $signupItem->isUse) ? 'Y' : 'N';
292
293
			if($signupItem->imageType)
294
			{
295
				$signupItem->max_width = $all_args->{$key.'_max_width'};
296
				$signupItem->max_height = $all_args->{$key.'_max_height'};
297
				$signupItem->max_filesize = $all_args->{$key.'_max_filesize'};
298
				$signupItem->allow_transparent_thumbnail = $all_args->{$key.'_transparent_thumbnail'};
299
			}
300
301
			// set extends form
302
			if(!$signupItem->isDefaultForm)
303
			{
304
				$extendItem = $extendItems[$all_args->{$key.'_member_join_form_srl'}];
305
				$signupItem->type = $extendItem->column_type;
306
				$signupItem->member_join_form_srl = $extendItem->member_join_form_srl;
307
				$signupItem->title = $extendItem->column_title;
308
				$signupItem->description = $extendItem->description;
309
310
				// check usable value change, required/option
311
				if($signupItem->isUse != ($extendItem->is_active == 'Y') || $signupItem->required != ($extendItem->required == 'Y'))
312
				{
313
					unset($update_args);
314
					$update_args = new stdClass;
315
					$update_args->member_join_form_srl = $extendItem->member_join_form_srl;
316
					$update_args->is_active = $signupItem->isUse?'Y':'N';
317
					$update_args->required = $signupItem->required?'Y':'N';
318
319
					$update_output = executeQuery('member.updateJoinForm', $update_args);
0 ignored issues
show
Unused Code introduced by
$update_output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
320
				}
321
322
				unset($extendItem);
323
			}
324
			$signupForm[] = $signupItem;
325
		}
326
		$args->signupForm = $signupForm;
327
328
		// create Ruleset
329
		$this->_createSignupRuleset($signupForm, $args->agreement);
0 ignored issues
show
Documentation introduced by
$signupForm is of type array, but the function expects a object.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
330
		$this->_createLoginRuleset($args->identifier);
331
		$this->_createFindAccountByQuestion($args->identifier);
332
333
		// check agreement value exist
334
		if($args->agreement)
335
		{
336
			$agreement_file = _XE_PATH_.'files/member_extra_info/agreement_' . Context::get('lang_type') . '.txt';
337
			$output = FileHandler::writeFile($agreement_file, $args->agreement);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $output is correct as \FileHandler::writeFile(...file, $args->agreement) (which targets FileHandler::writeFile()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
338
339
			unset($args->agreement);
340
		}
341
342
		$output = $oModuleController->updateModuleConfig('member', $args);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
343
344
		// default setting end
345
		$this->setMessage('success_updated');
346
347
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminSignUpConfig');
348
		$this->setRedirectUrl($returnUrl);
349
	}
350
351
	public function procMemberAdminInsertLoginConfig()
352
	{
353
		$oModuleController = getController('module');
354
355
		$args = Context::gets(
356
			'change_password_date',
357
			'enable_login_fail_report',
358
			'max_error_count',
359
			'max_error_count_time',
360
			'after_login_url',
361
			'after_logout_url'
362
		);
363
364
		if(!$args->change_password_date)
365
		{
366
			$args->change_password_date = 0;
367
		}
368
369
		if(!trim(strip_tags($args->after_login_url)))
370
		{
371
			$args->after_login_url = NULL;
372
		}
373
		if(!trim(strip_tags($args->after_logout_url)))
374
		{
375
			$args->after_logout_url = NULL;
376
		}
377
378
		$output = $oModuleController->updateModuleConfig('member', $args);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
379
380
		// default setting end
381
		$this->setMessage('success_updated');
382
383
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminLoginConfig');
384
		$this->setRedirectUrl($returnUrl);
385
	}
386
387
	public function procMemberAdminInsertDesignConfig()
388
	{
389
		$oModuleController = getController('module');
390
391
		$args = Context::gets(
392
			'layout_srl',
393
			'skin',
394
			'colorset',
395
			'mlayout_srl',
396
			'mskin'
397
		);
398
399
		$args->layout_srl = $args->layout_srl ? $args->layout_srl : NULL;
400
		if(!$args->skin)
401
		{
402
			$args->skin = 'default';
403
		}
404
		if(!$args->colorset)
405
		{
406
			$args->colorset = 'white';
407
		}
408
409
		$args->mlayout_srl = $args->mlayout_srl ? $args->mlayout_srl : NULL;
410
		if(!$args->mskin)
411
		{
412
			$args->mskin = 'default';
413
		}
414
415
		$output = $oModuleController->updateModuleConfig('member', $args);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
416
417
		// default setting end
418
		$this->setMessage('success_updated');
419
420
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminDesignConfig');
421
		$this->setRedirectUrl($returnUrl);
422
	}
423
424
	function createSignupForm($identifier)
425
	{
426
		global $lang;
427
		$oMemberModel = getModel('member');
428
429
		// Get join form list which is additionally set
430
		$extendItems = $oMemberModel->getJoinFormList();
431
432
		$items = array('user_id', 'password', 'user_name', 'nick_name', 'email_address', 'find_account_question', 'homepage', 'blog', 'birthday', 'signature', 'profile_image', 'image_name', 'image_mark');
433
		$mustRequireds = array('email_address', 'nick_name','password', 'find_account_question');
434
		$orgRequireds = array('email_address', 'password', 'find_account_question', 'user_id', 'nick_name', 'user_name');
435
		$orgUse = array('email_address', 'password', 'find_account_question', 'user_id', 'nick_name', 'user_name', 'homepage', 'blog', 'birthday');
436
		$list_order = array();
437
438
		foreach($items as $key)
439
		{
440
			unset($signupItem);
441
			$signupItem = new stdClass;
442
			$signupItem->isDefaultForm = true;
443
			$signupItem->name = $key;
444
			$signupItem->title = $key;
445
			$signupItem->mustRequired = in_array($key, $mustRequireds);
446
			$signupItem->imageType = (strpos($key, 'image') !== false);
447
			$signupItem->required = in_array($key, $orgRequireds);
448
			$signupItem->isUse = ($config->{$key} == 'Y') || in_array($key, $orgUse);
0 ignored issues
show
Bug introduced by
The variable $config does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
449
			$signupItem->isPublic = ($signupItem->isUse) ? 'Y' : 'N';
450
			if(in_array($key, array('find_account_question', 'password', 'email_address')))
451
			{
452
				$signupItem->isPublic = 'N';
453
			}
454
			$signupItem->isIdentifier = ($key == $identifier);
455 View Code Duplication
			if ($signupItem->imageType){
456
				$signupItem->max_width = $config->{$key.'_max_width'};
457
				$signupItem->max_height = $config->{$key.'_max_height'};
458
			}
459
			if($signupItem->isIdentifier)
460
				array_unshift($list_order, $signupItem);
461
			else
462
				$list_order[] = $signupItem;
463
		}
464
		if(is_array($extendItems))
465
		{
466
			foreach($extendItems as $form_srl=>$item_info)
467
			{
468
				unset($signupItem);
469
				$signupItem = new stdClass;
470
				$signupItem->name = $item_info->column_name;
471
				$signupItem->title = $item_info->column_title;
472
				$signupItem->type = $item_info->column_type;
473
				$signupItem->member_join_form_srl = $form_srl;
474
				$signupItem->mustRequired = in_array($key, $mustRequireds);
0 ignored issues
show
Bug introduced by
The variable $key seems to be defined by a foreach iteration on line 438. Are you sure the iterator is never empty, otherwise this variable is not defined?

It seems like you are relying on a variable being defined by an iteration:

foreach ($a as $b) {
}

// $b is defined here only if $a has elements, for example if $a is array()
// then $b would not be defined here. To avoid that, we recommend to set a
// default value for $b.


// Better
$b = 0; // or whatever default makes sense in your context
foreach ($a as $b) {
}

// $b is now guaranteed to be defined here.
Loading history...
475
				$signupItem->required = ($item_info->required == 'Y');
476
				$signupItem->isUse = ($item_info->is_active == 'Y');
477
				$signupItem->isPublic = ($signupItem->isUse) ? 'Y' : 'N';
478
				$signupItem->description = $item_info->description;
479 View Code Duplication
				if($signupItem->imageType)
480
				{
481
					$signupItem->max_width = $config->{$key.'_max_width'};
482
					$signupItem->max_height = $config->{$key.'_max_height'};
483
				}
484
				$list_order[] = $signupItem;
485
			}
486
		}
487
488
		return $list_order;
489
	}
490
491
	/**
492
	 * Create ruleset file of signup
493
	 * @param object $signupForm (user define signup form)
494
	 * @param string $agreement
495
	 * @return void
496
	 */
497
	function _createSignupRuleset($signupForm, $agreement = null){
498
		$xml_file = './files/ruleset/insertMember.xml';
499
		$buff = '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL.
500
			'<ruleset version="1.5.0">' . PHP_EOL.
501
			'<customrules>' . PHP_EOL.
502
			'</customrules>' . PHP_EOL.
503
			'<fields>' . PHP_EOL . '%s' . PHP_EOL . '</fields>' . PHP_EOL.
504
			'</ruleset>';
505
506
		$fields = array();
507
508
		if ($agreement)
0 ignored issues
show
Bug Best Practice introduced by
The expression $agreement of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
509
		{
510
			$fields[] = '<field name="accept_agreement"><if test="$act == \'procMemberInsert\'" attr="required" value="true" /></field>';
511
		}
512
		foreach($signupForm as $formInfo)
513
		{
514
			if($formInfo->required || $formInfo->mustRequired)
515
			{
516
				if($formInfo->type == 'tel' || $formInfo->type == 'kr_zip')
517
				{
518
					$fields[] = sprintf('<field name="%s[]" required="true" />', $formInfo->name);
519
				}
520
				else if($formInfo->name == 'password')
521
				{
522
					$fields[] = '<field name="password"><if test="$act == \'procMemberInsert\'" attr="required" value="true" /><if test="$act == \'procMemberInsert\'" attr="length" value="4:60" /></field>';
523
					$fields[] = '<field name="password2"><if test="$act == \'procMemberInsert\'" attr="required" value="true" /><if test="$act == \'procMemberInsert\'" attr="equalto" value="password" /></field>';
524
				}
525
				else if($formInfo->name == 'find_account_question')
526
				{
527
					$fields[] = '<field name="find_account_question"><if test="$modify_find_account_answer" attr="required" value="true" /></field>';
528
					$fields[] = '<field name="find_account_answer" length=":250"><if test="$modify_find_account_answer" attr="required" value="true" /></field>';
529
				}
530
				else if($formInfo->name == 'email_address')
531
				{
532
					$fields[] = sprintf('<field name="%s" required="true" rule="email"/>', $formInfo->name);
533
				}
534
				else if($formInfo->name == 'user_id')
535
				{
536
					$fields[] = sprintf('<field name="%s" required="true" rule="userid" length="3:20" />', $formInfo->name);
537
				}
538
				else if($formInfo->name == 'nick_name')
539
				{
540
					$fields[] = sprintf('<field name="%s" required="true" length="2:20" />', $formInfo->name);
541
				}
542
				else if(strpos($formInfo->name, 'image') !== false)
543
				{
544
					$fields[] = sprintf('<field name="%s"><if test="$act != \'procMemberAdminInsert\' &amp;&amp; $__%s_exist != \'true\'" attr="required" value="true" /></field>', $formInfo->name, $formInfo->name);
545
				}
546
				else if($formInfo->name == 'signature')
547
				{
548
					$fields[] = '<field name="signature"><if test="$member_srl" attr="required" value="true" /></field>';
549
				}
550
				else
551
				{
552
					$fields[] = sprintf('<field name="%s" required="true" />', $formInfo->name);
553
				}
554
			}
555
		}
556
557
		$xml_buff = sprintf($buff, implode(PHP_EOL, $fields));
558
		FileHandler::writeFile($xml_file, $xml_buff);
559
		unset($xml_buff);
560
561
		$validator   = new Validator($xml_file);
562
		$validator->setCacheDir('files/cache');
563
		$validator->getJsPath();
564
	}
565
566
	/**
567
	 * Create ruleset file of login
568
	 * @param string $identifier (login identifier)
569
	 * @return void
570
	 */
571
	function _createLoginRuleset($identifier)
572
	{
573
		$xml_file = './files/ruleset/login.xml';
574
		$buff = '<?xml version="1.0" encoding="utf-8"?>'.
575
			'<ruleset version="1.5.0">'.
576
			'<customrules>'.
577
			'</customrules>'.
578
			'<fields>%s</fields>'.
579
			'</ruleset>';
580
581
		$fields = array();
582
		$trans = array('email_address'=>'email', 'user_id'=> 'userid');
583
		$fields[] = sprintf('<field name="user_id" required="true" rule="%s"/>', $trans[$identifier]);
584
		$fields[] = '<field name="password" required="true" />';
585
586
		$xml_buff = sprintf($buff, implode('', $fields));
587
		Filehandler::writeFile($xml_file, $xml_buff);
588
589
		$validator   = new Validator($xml_file);
590
		$validator->setCacheDir('files/cache');
591
		$validator->getJsPath();
592
	}
593
594
	/**
595
	 * Create ruleset file of find account
596
	 * @param string $identifier (login identifier)
597
	 * @return void
598
	 */
599
	function _createFindAccountByQuestion($identifier)
600
	{
601
		$xml_file = './files/ruleset/find_member_account_by_question.xml';
602
		$buff = '<?xml version="1.0" encoding="utf-8"?>'.
603
			'<ruleset version="1.5.0">'.
604
			'<customrules>'.
605
			'</customrules>'.
606
			'<fields>%s</fields>'.
607
			'</ruleset>';
608
609
		$fields = array();
610
		if($identifier == 'user_id')
611
			$fields[] = '<field name="user_id" required="true" rule="userid" />';
612
613
		$fields[] = '<field name="email_address" required="true" rule="email" />';
614
		$fields[] = '<field name="find_account_question" required="true" />';
615
		$fields[] = '<field name="find_account_answer" required="true" length=":250"/>';
616
617
		$xml_buff = sprintf($buff, implode('', $fields));
618
		Filehandler::writeFile($xml_file, $xml_buff);
619
620
		$validator   = new Validator($xml_file);
621
		$validator->setCacheDir('files/cache');
622
		$validator->getJsPath();
623
	}
624
625
	/**
626
	 * Add a user group
627
	 * @return void|BaseObject (void : success, BaseObject : fail)
628
	 */
629
	function procMemberAdminInsertGroup()
630
	{
631
		$args = Context::gets('title','description','is_default','image_mark');
632
		$output = $this->insertGroup($args);
0 ignored issues
show
Bug introduced by
It seems like $args defined by \Context::gets('title', ...default', 'image_mark') on line 631 can be null; however, memberAdminController::insertGroup() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
633
		if(!$output->toBool()) return $output;
634
635
		$this->add('group_srl','');
636
		$this->add('page',Context::get('page'));
637
		$this->setMessage('success_registed');
638
639
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminGroupList');
640
		$this->setRedirectUrl($returnUrl);
641
	}
642
643
	/**
644
	 * Update user group information
645
	 * @return void|BaseObject (void : success, BaseObject : fail)
646
	 */
647
	function procMemberAdminUpdateGroup()
648
	{
649
		$group_srl = Context::get('group_srl');
0 ignored issues
show
Unused Code introduced by
$group_srl is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
650
651
		$args = Context::gets('group_srl','title','description','is_default','image_mark');
652
		$args->site_srl = 0;
653
		$output = $this->updateGroup($args);
654
		if(!$output->toBool()) return $output;
655
656
		$this->add('group_srl','');
657
		$this->add('page',Context::get('page'));
658
		$this->setMessage('success_updated');
659
660
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminGroupList');
661
		$this->setRedirectUrl($returnUrl);
662
	}
663
664
	/**
665
	 * Update user group information
666
	 * @return void|BaseObject (void : success, BaseObject : fail)
667
	 */
668 View Code Duplication
	function procMemberAdminDeleteGroup()
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...
669
	{
670
		$group_srl = Context::get('group_srl');
671
672
		$output = $this->deleteGroup($group_srl);
673
		if(!$output->toBool()) return $output;
674
675
		$this->add('group_srl','');
676
		$this->add('page',Context::get('page'));
677
		$this->setMessage('success_deleted');
678
679
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminGroupList');
680
		$this->setRedirectUrl($returnUrl);
681
	}
682
683
	/**
684
	 * Add a join form
685
	 * @return void|BaseObject (void : success, BaseObject : fail)
686
	 */
687
	function procMemberAdminInsertJoinForm()
688
	{
689
		$args = new stdClass();
690
		$args->member_join_form_srl = Context::get('member_join_form_srl');
691
692
		$args->column_type = Context::get('column_type');
693
		$args->column_name = strtolower(Context::get('column_id'));
694
		$args->column_title = Context::get('column_title');
695
		$args->default_value = explode("\n", str_replace("\r", '', Context::get('default_value')));
696
		$args->required = Context::get('required');
697
		$args->is_active = (isset($args->required));
698
		if(!in_array(strtoupper($args->required), array('Y','N')))$args->required = 'N';
699
		$args->description = Context::get('description') ? Context::get('description') : '';
700
		// Default values
701
		if(in_array($args->column_type, array('checkbox','select','radio')) && count($args->default_value))
702
		{
703
			$args->default_value = serialize($args->default_value);
704
		}
705
		else
706
		{
707
			$args->default_value = '';
708
		}
709
710
		// Check ID duplicated
711
		$oMemberModel = getModel('member');
712
		$config = $oMemberModel->getMemberConfig();
713
		foreach($config->signupForm as $item)
714
		{
715
			if($item->name == $args->column_name)
716
			{
717
				if($args->member_join_form_srl && $args->member_join_form_srl == $item->member_join_form_srl) continue;
718
				return new BaseObject(-1,'msg_exists_user_id');
719
			}
720
		}
721
		// Fix if member_join_form_srl exists. Add if not exists.
722
		$isInsert;
0 ignored issues
show
Bug introduced by
The variable $isInsert seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?

This error can happen if you refactor code and forget to move the variable initialization.

Let’s take a look at a simple example:

function someFunction() {
    $x = 5;
    echo $x;
}

The above code is perfectly fine. Now imagine that we re-order the statements:

function someFunction() {
    echo $x;
    $x = 5;
}

In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.

Loading history...
723
		if(!$args->member_join_form_srl)
724
		{
725
			$isInsert = true;
726
			$args->list_order = $args->member_join_form_srl = getNextSequence();
727
			$output = executeQuery('member.insertJoinForm', $args);
728
		}
729
		else
730
		{
731
			$output = executeQuery('member.updateJoinForm', $args);
732
		}
733
734
		if(!$output->toBool()) return $output;
735
736
		// memberConfig update
737
		$signupItem = new stdClass();
738
		$signupItem->name = $args->column_name;
739
		$signupItem->title = $args->column_title;
740
		$signupItem->type = $args->column_type;
741
		$signupItem->member_join_form_srl = $args->member_join_form_srl;
742
		$signupItem->required = ($args->required == 'Y');
743
		$signupItem->isUse = ($args->is_active == 'Y');
744
		$signupItem->description = $args->description;
745
		$signupItem->isPublic = 'Y';
746
747
		$oMemberModel = getModel('member');
748
		$config = $oMemberModel->getMemberConfig();
749
		unset($config->agreement);
750
751
		if($isInsert)
0 ignored issues
show
Bug introduced by
The variable $isInsert does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
752
		{
753
			$config->signupForm[] = $signupItem;
754
		}
755
		else
756
		{
757 View Code Duplication
			foreach($config->signupForm as $key=>$val)
758
			{
759
				if($val->member_join_form_srl == $signupItem->member_join_form_srl)
760
				{
761
					$config->signupForm[$key] = $signupItem;
762
				}
763
			}
764
		}
765
		$oModuleController = getController('module');
766
		$output = $oModuleController->updateModuleConfig('member', $config);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
767
768
		$this->setMessage('success_registed');
769
770
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminJoinFormList');
771
		$this->setRedirectUrl($returnUrl);
772
	}
773
774
	/**
775
	 * Delete a join form
776
	 * @return void
777
	 */
778
	function procMemberAdminDeleteJoinForm()
779
	{
780
		$member_join_form_srl = Context::get('member_join_form_srl');
781
		$this->deleteJoinForm($member_join_form_srl);
782
783
		$oMemberModel = getModel('member');
784
		$config = $oMemberModel->getMemberConfig();
785
		unset($config->agreement);
786
787 View Code Duplication
		foreach($config->signupForm as $key=>$val)
788
		{
789
			if($val->member_join_form_srl == $member_join_form_srl)
790
			{
791
				unset($config->signupForm[$key]);
792
				break;
793
			}
794
		}
795
		$oModuleController = getController('module');
796
		$output = $oModuleController->updateModuleConfig('member', $config);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
797
	}
798
799
	/**
800
	 * Move up/down the member join form and modify it
801
	 * @deprecated
802
	 * @return void
803
	 */
804
	function procMemberAdminUpdateJoinForm()
805
	{
806
		$member_join_form_srl = Context::get('member_join_form_srl');
807
		$mode = Context::get('mode');
808
809
		switch($mode)
810
		{
811
			case 'up' :
812
				$output = $this->moveJoinFormUp($member_join_form_srl);
0 ignored issues
show
Deprecated Code introduced by
The method memberAdminController::moveJoinFormUp() has been deprecated.

This method has been deprecated.

Loading history...
813
				$msg_code = 'success_moved';
814
				break;
815
			case 'down' :
816
				$output = $this->moveJoinFormDown($member_join_form_srl);
0 ignored issues
show
Deprecated Code introduced by
The method memberAdminController::moveJoinFormDown() has been deprecated.

This method has been deprecated.

Loading history...
817
				$msg_code = 'success_moved';
818
				break;
819
			case 'delete' :
820
				$output = $this->deleteJoinForm($member_join_form_srl);
821
				$msg_code = 'success_deleted';
822
				break;
823
			case 'update' :
824
				break;
825
		}
826
		if(!$output->toBool()) return $output;
0 ignored issues
show
Bug introduced by
The variable $output does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
827
828
		$this->setMessage($msg_code);
0 ignored issues
show
Bug introduced by
The variable $msg_code does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
829
	}
830
831
	/**
832
	 * selected member manager layer in dispAdminList
833
	 * @return void|BaseObject (void : success, BaseObject : fail)
834
	 */
835
	function procMemberAdminSelectedMemberManage()
836
	{
837
		$var = Context::getRequestVars();
838
		$groups = $var->groups;
0 ignored issues
show
Bug introduced by
The property groups does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
839
		$members = $var->member_srls;
0 ignored issues
show
Bug introduced by
The property member_srls does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
840
841
		$oDB = &DB::getInstance();
842
		$oDB->begin();
843
844
		$oMemberController = getController('member');
845
		foreach($members as $key=>$member_srl)
846
		{
847
			$args = new stdClass();
848
			$args->member_srl = $member_srl;
849
			switch($var->type)
0 ignored issues
show
Bug introduced by
The property type does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
850
			{
851
				case 'modify':
852
					{
853
						if(count($groups) > 0)
854
						{
855
							$args->site_srl = 0;
856
							// One of its members to delete all the group
857
							$output = executeQuery('member.deleteMemberGroupMember', $args);
858
							if(!$output->toBool())
859
							{
860
								$oDB->rollback();
861
								return $output;
862
							}
863
							// Enter one of the loop a
864
							foreach($groups as $group_srl)
865
							{
866
								$output = $oMemberController->addMemberToGroup($args->member_srl,$group_srl);
867
								if(!$output->toBool())
868
								{
869
									$oDB->rollback();
870
									return $output;
871
								}
872
							}
873
						}
874
						if($var->denied)
875
						{
876
							$args->denied = $var->denied;
0 ignored issues
show
Bug introduced by
The property denied does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
877
							$output = executeQuery('member.updateMemberDeniedInfo', $args);
878
							if(!$output->toBool())
879
							{
880
								$oDB->rollback();
881
								return $output;
882
							}
883
						}
884
						$this->setMessage('success_updated');
885
						break;
886
					}
887
				case 'delete':
888
					{
889
						$oMemberController->memberInfo = null;
0 ignored issues
show
Bug introduced by
The property memberInfo does not seem to exist in ModuleObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
890
						$output = $oMemberController->deleteMember($member_srl);
891
						if(!$output->toBool())
892
						{
893
							$oDB->rollback();
894
							return $output;
895
						}
896
						$this->setMessage('success_deleted');
897
					}
898
			}
899
			$oMemberController->_clearMemberCache($args->member_srl);
900
		}
901
902
		$message = $var->message;
903
		// Send a message
904
		if($message)
905
		{
906
			$oCommunicationController = getController('communication');
907
908
			$logged_info = Context::get('logged_info');
909
			$title = cut_str($message,10,'...');
910
			$sender_member_srl = $logged_info->member_srl;
911
912
			foreach($members as $member_srl)
913
			{
914
				$oCommunicationController->sendMessage($sender_member_srl, $member_srl, $title, $message, false);
915
			}
916
		}
917
918
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminList');
919
		$this->setRedirectUrl($returnUrl);
920
	}
921
922
	/**
923
	 * Delete the selected members
924
	 * @return void|BaseObject (void : success, BaseObject : fail)
925
	 */
926 View Code Duplication
	function procMemberAdminDeleteMembers()
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...
927
	{
928
		$target_member_srls = Context::get('target_member_srls');
929
		if(!$target_member_srls) return new BaseObject(-1, 'msg_invalid_request');
930
		$member_srls = explode(',', $target_member_srls);
931
		$oMemberController = getController('member');
932
933
		foreach($member_srls as $member)
934
		{
935
			$output = $oMemberController->deleteMember($member);
936
			if(!$output->toBool())
937
			{
938
				$this->setMessage('failed_deleted');
939
				return $output;
940
			}
941
		}
942
943
		$this->setMessage('success_deleted');
944
	}
945
946
	/**
947
	 * Update a group of selected memebrs
948
	 * @return void|BaseObject (void : success, BaseObject : fail)
949
	 */
950
	function procMemberAdminUpdateMembersGroup()
951
	{
952
		$member_srl = Context::get('member_srl');
953
		if(!$member_srl) return new BaseObject(-1,'msg_invalid_request');
954
		$member_srls = explode(',',$member_srl);
955
956
		$group_srl = Context::get('group_srls');
957
		if(!is_array($group_srl)) $group_srls = explode('|@|', $group_srl);
958
		else $group_srls = $group_srl;
959
960
		$oDB = &DB::getInstance();
961
		$oDB->begin();
962
		// Delete a group of selected members
963
		$args = new stdClass;
964
		$args->member_srl = $member_srl;
965
		$output = executeQuery('member.deleteMembersGroup', $args);
966
		if(!$output->toBool())
967
		{
968
			$oDB->rollback();
969
			return $output;
970
		}
971
		// Add to a selected group
972
		$group_count = count($group_srls);
973
		$member_count = count($member_srls);
974
		for($j=0;$j<$group_count;$j++)
975
		{
976
			$group_srl = (int)trim($group_srls[$j]);
977
			if(!$group_srl) continue;
978
			for($i=0;$i<$member_count;$i++)
979
			{
980
				$member_srl = (int)trim($member_srls[$i]);
981
				if(!$member_srl) continue;
982
983
				$args = new stdClass;
984
				$args->member_srl = $member_srl;
985
				$args->group_srl = $group_srl;
986
987
				$output = executeQuery('member.addMemberToGroup', $args);
988
				if(!$output->toBool())
989
				{
990
					$oDB->rollback();
991
					return $output;
992
				}
993
			}
994
		}
995
		$oDB->commit();
996
997
		$this->_deleteMemberGroupCache();
998
999
		$this->setMessage('success_updated');
1000
1001
		if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON')))
1002
		{
1003
			global $lang;
1004
			htmlHeader();
1005
			alertScript($lang->success_updated);
1006
			reload(true);
1007
			closePopupScript();
1008
			htmlFooter();
1009
			Context::close();
1010
			exit;
1011
		}
1012
	}
1013
1014
	/**
1015
	 * Add a denied ID
1016
	 * @return void
1017
	 */
1018
	function procMemberAdminInsertDeniedID()
1019
	{
1020
		$user_ids = Context::get('user_id');
1021
1022
		$user_ids = explode(',',$user_ids);
1023
		$success_ids = array();
1024
1025
		foreach($user_ids as $val)
1026
		{
1027
			$val = trim($val);
1028
			if(!$val) continue;
1029
1030
			$output = $this->insertDeniedID($val, '');
1031
			if($output->toBool()) $success_ids[] = $val;
1032
		}
1033
1034
		$this->add('user_ids', implode(',',$success_ids));
1035
1036
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminDeniedIDList');
1037
		$this->setRedirectUrl($returnUrl);
1038
	}
1039
1040
	/**
1041
	 * Add a denied nick name
1042
	 * @return void
1043
	 */
1044
	function procMemberAdminUpdateDeniedNickName()
1045
	{
1046
		$nick_name = Context::get('nick_name');
1047
1048
		$mode = Context::get('mode');
1049
		$mode = $mode ? $mode : 'insert';
1050
1051
		if($mode == 'delete')
1052
		{
1053
			$output = $this->deleteDeniedNickName($nick_name);
1054
			if(!$output->toBool())
1055
			{
1056
				return $output;
1057
			}
1058
			$msg_code = 'success_deleted';
1059
			$this->setMessage($msg_code);
1060
		}
1061
		else
1062
		{
1063
			$nick_names = explode(',',$nick_name);
1064
			$success_nick_names = array();
1065
1066
			foreach($nick_names as $val)
1067
			{
1068
				$val = trim($val);
1069
				if(!$val) continue;
1070
1071
				$output = $this->insertDeniedNickName($val, '');
1072
				if($output->toBool()) $success_nick_names[] = $val;
1073
			}
1074
1075
			$this->add('nick_names', implode(',',$success_nick_names));
1076
		}
1077
	}
1078
1079
	/**
1080
	 * Update denied ID
1081
	 * @return void|BaseObject (void : success, BaseObject : fail)
1082
	 */
1083
	function procMemberAdminUpdateDeniedID()
1084
	{
1085
		$user_id = Context::get('user_id');
1086
		$mode = Context::get('mode');
1087
1088
		switch($mode)
1089
		{
1090
			case 'delete' :
1091
				$output = $this->deleteDeniedID($user_id);
1092
				if(!$output->toBool()) return $output;
1093
				$msg_code = 'success_deleted';
1094
				break;
1095
		}
1096
1097
		$this->add('page',Context::get('page'));
1098
		$this->setMessage($msg_code);
0 ignored issues
show
Bug introduced by
The variable $msg_code does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
1099
	}
1100
1101
	/**
1102
	 * Add an administrator
1103
	 * @param object $args
1104
	 * @return object (info of added member)
1105
	 */
1106
	function insertAdmin($args)
1107
	{
1108
		// Assign an administrator
1109
		$args->is_admin = 'Y';
1110
		// Get admin group and set
1111
		$oMemberModel = getModel('member');
1112
		$admin_group = $oMemberModel->getAdminGroup();
1113
		$args->group_srl_list = $admin_group->group_srl;
1114
1115
		$oMemberController = getController('member');
1116
		return $oMemberController->insertMember($args);
1117
	}
1118
1119
	/**
1120
	 * Change the group values of member
1121
	 * @param int $source_group_srl
1122
	 * @param int $target_group_srl
1123
	 * @return BaseObject
1124
	 */
1125
	function changeGroup($source_group_srl, $target_group_srl)
1126
	{
1127
		$args = new stdClass;
1128
		$args->source_group_srl = $source_group_srl;
1129
		$args->target_group_srl = $target_group_srl;
1130
1131
		$output = executeQuery('member.changeGroup', $args);
1132
		$this->_deleteMemberGroupCache($site_srl);
0 ignored issues
show
Bug introduced by
The variable $site_srl does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
1133
1134
		return $output;
1135
	}
1136
1137
	/**
1138
	 * Insert a group
1139
	 * @param object $args
1140
	 * @return BaseObject
1141
	 */
1142
	function insertGroup($args)
1143
	{
1144
		if(!$args->site_srl) $args->site_srl = 0;
1145
		// Check the value of is_default.
1146 View Code Duplication
		if($args->is_default != 'Y')
1147
		{
1148
			$args->is_default = 'N';
1149
		}
1150
		else
1151
		{
1152
			$output = executeQuery('member.updateGroupDefaultClear', $args);
1153
			if(!$output->toBool()) return $output;
1154
		}
1155
1156
		if(!isset($args->list_order) || $args->list_order=='')
1157
		{
1158
			$args->list_order = $args->group_srl;
1159
		}
1160
1161
		if(!$args->group_srl) $args->group_srl = getNextSequence();
1162
		$args->list_order = $args->group_srl;
1163
		$output = executeQuery('member.insertGroup', $args);
1164
		$this->_deleteMemberGroupCache($args->site_srl);
1165
1166
		return $output;
1167
	}
1168
1169
	/**
1170
	 * Modify Group Information
1171
	 * @param object $args
1172
	 * @return BaseObject
1173
	 */
1174
	function updateGroup($args)
1175
	{
1176
		if(!$args->site_srl) $args->site_srl = 0;
1177
		// Check the value of is_default.
1178
		if(!$args->group_srl) return new BaseObject(-1, 'lang->msg_not_founded');
1179 View Code Duplication
		if($args->is_default!='Y')
1180
		{
1181
			$args->is_default = 'N';
1182
		}
1183
		else
1184
		{
1185
			$output = executeQuery('member.updateGroupDefaultClear', $args);
1186
			if(!$output->toBool()) return $output;
1187
		}
1188
1189
		$output = executeQuery('member.updateGroup', $args);
1190
		$this->_deleteMemberGroupCache($args->site_srl);
1191
		return $output;
1192
	}
1193
1194
	/**
1195
	 * Delete a Group
1196
	 * @param int $group_srl
1197
	 * @param int $site_srl
1198
	 * @return BaseObject
1199
	 */
1200
	function deleteGroup($group_srl, $site_srl = 0)
1201
	{
1202
		// Create a member model object
1203
		$oMemberModel = getModel('member');
1204
1205
		// Check the group_srl (If is_default == 'Y', it cannot be deleted)
1206
		$columnList = array('group_srl', 'is_default');
1207
		$group_info = $oMemberModel->getGroup($group_srl, $columnList);
1208
1209
		if(!$group_info) return new BaseObject(-1, 'lang->msg_not_founded');
1210
		if($group_info->is_default == 'Y') return new BaseObject(-1, 'msg_not_delete_default');
1211
1212
		// Get groups where is_default == 'Y'
1213
		$columnList = array('site_srl', 'group_srl');
1214
		$default_group = $oMemberModel->getDefaultGroup($site_srl, $columnList);
1215
		$default_group_srl = $default_group->group_srl;
1216
1217
		// Change to default_group_srl
1218
		$this->changeGroup($group_srl, $default_group_srl);
1219
1220
		$args = new stdClass;
1221
		$args->group_srl = $group_srl;
1222
		$output = executeQuery('member.deleteGroup', $args);
1223
		$this->_deleteMemberGroupCache($site_srl);
1224
		return $output;
1225
	}
1226
1227
	/**
1228
	 * Set group config
1229
	 * @return void
1230
	 */
1231
	public function procMemberAdminGroupConfig()
1232
	{
1233
		$vars = Context::getRequestVars();
1234
1235
		$oMemberModel = getModel('member');
1236
		$oModuleController = getController('module');
1237
1238
		// group image mark option
1239
		$config = $oMemberModel->getMemberConfig();
1240
		$config->group_image_mark = $vars->group_image_mark;
0 ignored issues
show
Bug introduced by
The property group_image_mark does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1241
		unset($config->agreement);
1242
		$output = $oModuleController->updateModuleConfig('member', $config);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1243
1244
		$defaultGroup = $oMemberModel->getDefaultGroup(0);
1245
		$defaultGroupSrl = $defaultGroup->group_srl;
1246
		$group_srls = $vars->group_srls;
0 ignored issues
show
Bug introduced by
The property group_srls does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1247
		foreach($group_srls as $order=>$group_srl)
1248
		{
1249
			$isInsert = false;
0 ignored issues
show
Unused Code introduced by
$isInsert is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1250
			$update_args = new stdClass();
1251
			$update_args->title = $vars->group_titles[$order];
0 ignored issues
show
Bug introduced by
The property group_titles does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1252
			$update_args->description = $vars->descriptions[$order];
0 ignored issues
show
Bug introduced by
The property descriptions does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1253
			$update_args->image_mark = $vars->image_marks[$order];
0 ignored issues
show
Bug introduced by
The property image_marks does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1254
			$update_args->list_order = $order + 1;
1255
1256
			if(!$update_args->title) continue;
1257
1258
			if(is_numeric($group_srl)) {
1259
				$update_args->group_srl = $group_srl;
1260
				$output = $this->updateGroup($update_args);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1261
			}
1262
			else {
1263
				$update_args->group_srl = getNextSequence();
1264
				$output = $this->insertGroup($update_args);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1265
			}
1266
1267
			if($vars->defaultGroup == $group_srl) {
0 ignored issues
show
Bug introduced by
The property defaultGroup does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1268
				$defaultGroupSrl = $update_args->group_srl;
1269
			}
1270
		}
1271
1272
		//set default group
1273
		$default_args = $oMemberModel->getGroup($defaultGroupSrl);
1274
		$default_args->is_default = 'Y';
1275
		$default_args->group_srl = $defaultGroupSrl;
1276
		$output = $this->updateGroup($default_args);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1277
1278
		$this->setMessage(Context::getLang('success_updated').' ('.Context::getLang('msg_insert_group_name_detail').')');
1279
1280
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminGroupList');
1281
		$this->setRedirectUrl($returnUrl);
1282
	}
1283
1284
1285
	/**
1286
	 * Set group order
1287
	 * @return void
1288
	 */
1289
	function procMemberAdminUpdateGroupOrder()
1290
	{
1291
		$vars = Context::getRequestVars();
1292
1293
		foreach($vars->group_srls as $key => $val)
0 ignored issues
show
Bug introduced by
The property group_srls does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1294
		{
1295
			$args = new stdClass;
1296
			$args->group_srl = $val;
1297
			$args->list_order = $key + 1;
1298
			executeQuery('member.updateMemberGroupListOrder', $args);
1299
		}
1300
1301
		$this->_deleteMemberGroupCache($vars->site_srl);
0 ignored issues
show
Bug introduced by
The property site_srl does not seem to exist in BaseObject.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1302
1303
		$this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminGroupList'));
1304
	}
1305
1306
	/**
1307
	 * Delete cached group data
1308
	 * @return void
1309
	*/
1310
	function _deleteMemberGroupCache($site_srl = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $site_srl is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
1311
	{
1312
		//remove from cache
1313
		$oCacheHandler = CacheHandler::getInstance('object', null, true);
1314
		if($oCacheHandler->isSupport())
1315
		{
1316
			$oCacheHandler->invalidateGroupKey('member');
1317
		}
1318
	}
1319
1320
	/**
1321
	 * Register denied ID
1322
	 * @param string $user_id
1323
	 * @param string $description
1324
	 * @return BaseObject
1325
	 */
1326
	function insertDeniedID($user_id, $description = '')
1327
	{
1328
		$args = new stdClass();
1329
		$args->user_id = $user_id;
1330
		$args->description = $description;
1331
		$args->list_order = -1*getNextSequence();
1332
1333
		return executeQuery('member.insertDeniedID', $args);
1334
	}
1335
1336
	function insertDeniedNickName($nick_name, $description = '')
1337
	{
1338
		$args = new stdClass();
1339
		$args->nick_name = $nick_name;
1340
		$args->description = $description;
1341
1342
		return executeQuery('member.insertDeniedNickName', $args);
1343
	}
1344
1345
	/**
1346
	 * delete a denied id
1347
	 * @param string $user_id
1348
	 * @return object
1349
	 */
1350
	function deleteDeniedID($user_id)
1351
	{
1352
		if(!$user_id) unset($user_id);
1353
1354
		$args = new stdClass;
1355
		$args->user_id = $user_id;
1356
		return executeQuery('member.deleteDeniedID', $args);
1357
	}
1358
1359
	/**
1360
	 * delete a denied nick name
1361
	 * @param string $nick_name
1362
	 * @return object
1363
	 */
1364
	function deleteDeniedNickName($nick_name)
1365
	{
1366
		if(!$nick_name) unset($nick_name);
1367
1368
		$args = new stdClass;
1369
		$args->nick_name = $nick_name;
1370
		return executeQuery('member.deleteDeniedNickName', $args);
1371
	}
1372
1373
	/**
1374
	 * Delete a join form
1375
	 * @param int $member_join_form_srl
1376
	 * @return BaseObject
1377
	 */
1378
	function deleteJoinForm($member_join_form_srl)
1379
	{
1380
		$args = new stdClass();
1381
		$args->member_join_form_srl = $member_join_form_srl;
1382
		$output = executeQuery('member.deleteJoinForm', $args);
1383
		return $output;
1384
	}
1385
1386
	/**
1387
	 * Move up a join form
1388
	 * @deprecated
1389
	 * @param int $member_join_form_srl
1390
	 * @return BaseObject
1391
	 */
1392
	function moveJoinFormUp($member_join_form_srl)
1393
	{
1394
		$oMemberModel = getModel('member');
1395
		// Get information of the join form
1396
		$args = new stdClass;
1397
		$args->member_join_form_srl = $member_join_form_srl;
1398
		$output = executeQuery('member.getJoinForm', $args);
1399
1400
		$join_form = $output->data;
1401
		$list_order = $join_form->list_order;
1402
		// Get a list of all join forms
1403
		$join_form_list = $oMemberModel->getJoinFormList();
1404
		$join_form_srl_list = array_keys($join_form_list);
1405
		if(count($join_form_srl_list)<2) return new BaseObject();
1406
1407
		$prev_member_join_form = NULL;
1408
		foreach($join_form_list as $key => $val)
1409
		{
1410
			if($val->member_join_form_srl == $member_join_form_srl) break;
1411
			$prev_member_join_form = $val;
1412
		}
1413
		// Return if no previous join form exists
1414
		if(!$prev_member_join_form) return new BaseObject();
1415
		// Information of the join form
1416
		$cur_args = new stdClass;
1417
		$cur_args->member_join_form_srl = $member_join_form_srl;
1418
		$cur_args->list_order = $prev_member_join_form->list_order;
1419
		// Information of the target join form
1420
		$prev_args = new stdClass;
1421
		$prev_args->member_join_form_srl = $prev_member_join_form->member_join_form_srl;
1422
		$prev_args->list_order = $list_order;
1423
		// Execute Query
1424
		$output = executeQuery('member.updateMemberJoinFormListorder', $cur_args);
1425
		if(!$output->toBool()) return $output;
1426
1427
		executeQuery('member.updateMemberJoinFormListorder', $prev_args);
1428
		if(!$output->toBool()) return $output;
1429
1430
		return new BaseObject();
1431
	}
1432
1433
	/**
1434
	 * Move down a join form
1435
	 * @deprecated
1436
	 * @param int $member_join_form_srl
1437
	 * @return BaseObject
1438
	 */
1439
	function moveJoinFormDown($member_join_form_srl)
1440
	{
1441
		$oMemberModel = getModel('member');
1442
		// Get information of the join form
1443
		$args = new stdClass;
1444
		$args->member_join_form_srl = $member_join_form_srl;
1445
		$output = executeQuery('member.getJoinForm', $args);
1446
1447
		$join_form = $output->data;
1448
		$list_order = $join_form->list_order;
1449
		// Get information of all join forms
1450
		$join_form_list = $oMemberModel->getJoinFormList();
1451
		$join_form_srl_list = array_keys($join_form_list);
1452
		if(count($join_form_srl_list)<2) return new BaseObject();
1453
1454
		for($i=0;$i<count($join_form_srl_list);$i++)
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
1455
		{
1456
			if($join_form_srl_list[$i]==$member_join_form_srl) break;
1457
		}
1458
1459
		$next_member_join_form_srl = $join_form_srl_list[$i+1];
1460
		// Return if no previous join form exists
1461
		if(!$next_member_join_form_srl) return new BaseObject();
1462
		$next_member_join_form = $join_form_list[$next_member_join_form_srl];
1463
		// Information of the join form
1464
		$cur_args = new stdClass;
1465
		$cur_args->member_join_form_srl = $member_join_form_srl;
1466
		$cur_args->list_order = $next_member_join_form->list_order;
1467
		// Information of the target join form
1468
		$next_args = new stdClass;
1469
		$next_args->member_join_form_srl = $next_member_join_form->member_join_form_srl;
1470
		$next_args->list_order = $list_order;
1471
		// Execute Query
1472
		$output = executeQuery('member.updateMemberJoinFormListorder', $cur_args);
1473
		if(!$output->toBool()) return $output;
1474
1475
		$output = executeQuery('member.updateMemberJoinFormListorder', $next_args);
1476
		if(!$output->toBool()) return $output;
1477
1478
		return new BaseObject();
1479
	}
1480
}
1481
/* End of file member.admin.controller.php */
1482
/* Location: ./modules/member/member.admin.controller.php */
1483