XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
member.admin.controller.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
9 {
14  function init()
15  {
16  }
17 
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  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  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  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  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  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 
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 
161  {
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);
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 
209  {
210  $oMemberModel = getModel('member');
211  $oModuleController = getController('module');
212 
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;
254 
255  // set default
256  $all_args->is_nick_name_public = 'Y';
257  $all_args->is_find_account_question_public = 'N';
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)
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);
320  }
321 
322  unset($extendItem);
323  }
324  $signupForm[] = $signupItem;
325  }
326  $args->signupForm = $signupForm;
327 
328  // create Ruleset
329  $this->_createSignupRuleset($signupForm, $args->agreement);
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);
338 
339  unset($args->agreement);
340  }
341 
342  $output = $oModuleController->updateModuleConfig('member', $args);
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 
352  {
353  $oModuleController = getController('module');
354 
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);
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 
388  {
389  $oModuleController = getController('module');
390 
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);
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);
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  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);
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  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 
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)
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 
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 
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 
630  {
631  $args = Context::gets('title','description','is_default','image_mark');
632  $output = $this->insertGroup($args);
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 
648  {
649  $group_srl = Context::get('group_srl');
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 
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 
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;
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)
752  {
753  $config->signupForm[] = $signupItem;
754  }
755  else
756  {
757  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);
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 
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  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);
797  }
798 
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);
813  $msg_code = 'success_moved';
814  break;
815  case 'down' :
816  $output = $this->moveJoinFormDown($member_join_form_srl);
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;
827 
828  $this->setMessage($msg_code);
829  }
830 
836  {
837  $var = Context::getRequestVars();
838  $groups = $var->groups;
839  $members = $var->member_srls;
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)
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;
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;
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 
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 
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 
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 
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 
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);
1099  }
1100 
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 
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);
1133 
1134  return $output;
1135  }
1136 
1142  function insertGroup($args)
1143  {
1144  if(!$args->site_srl) $args->site_srl = 0;
1145  // Check the value of is_default.
1146  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 
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  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 
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 
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;
1241  unset($config->agreement);
1242  $output = $oModuleController->updateModuleConfig('member', $config);
1243 
1244  $defaultGroup = $oMemberModel->getDefaultGroup(0);
1245  $defaultGroupSrl = $defaultGroup->group_srl;
1246  $group_srls = $vars->group_srls;
1247  foreach($group_srls as $order=>$group_srl)
1248  {
1249  $isInsert = false;
1250  $update_args = new stdClass();
1251  $update_args->title = $vars->group_titles[$order];
1252  $update_args->description = $vars->descriptions[$order];
1253  $update_args->image_mark = $vars->image_marks[$order];
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);
1261  }
1262  else {
1263  $update_args->group_srl = getNextSequence();
1264  $output = $this->insertGroup($update_args);
1265  }
1266 
1267  if($vars->defaultGroup == $group_srl) {
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);
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 
1290  {
1291  $vars = Context::getRequestVars();
1292 
1293  foreach($vars->group_srls as $key => $val)
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);
1302 
1303  $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminGroupList'));
1304  }
1305 
1310  function _deleteMemberGroupCache($site_srl = 0)
1311  {
1312  //remove from cache
1313  $oCacheHandler = CacheHandler::getInstance('object', null, true);
1314  if($oCacheHandler->isSupport())
1315  {
1316  $oCacheHandler->invalidateGroupKey('member');
1317  }
1318  }
1319 
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 
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 
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 
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 
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 
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++)
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 */
$oModuleModel
Definition: ko.install.php:236
getController($module_name)
Definition: func.inc.php:90
deleteJoinForm($member_join_form_srl)
removeFile($filename)
$output
Definition: ko.install.php:193
insertDeniedID($user_id, $description= '')
& getInstance($target= 'object', $info=null, $always_use_file=false)
changeGroup($source_group_srl, $target_group_srl)
foreach($sitemap as $id=> &$val) $extra_vars
Definition: ko.install.php:180
getNotEncodedUrl()
Definition: func.inc.php:316
writeFile($filename, $buff, $mode="w")
delObjectVars($target_obj, $del_obj)
Definition: func.inc.php:999
closePopupScript()
Definition: func.inc.php:1757
reload($isOpener=FALSE)
Definition: func.inc.php:1772
$args
Definition: ko.install.php:185
checkCSRF()
Definition: func.inc.php:1623
moveJoinFormUp($member_join_form_srl)
deleteGroup($group_srl, $site_srl=0)
insertDeniedNickName($nick_name, $description= '')
_createSignupRuleset($signupForm, $agreement=null)
alertScript($msg)
Definition: func.inc.php:1738
getInstance($db_type=NULL)
Definition: DB.class.php:142
htmlFooter()
Definition: func.inc.php:1727
getLang($code)
const _XE_PATH_
Definition: config.inc.php:49
moveJoinFormDown($member_join_form_srl)
getNextSequence()
Definition: func.inc.php:236
getModel($module_name)
Definition: func.inc.php:145
htmlHeader()
Definition: func.inc.php:1712
cut_str($string, $cut_size=0, $tail= '...')
Definition: func.inc.php:508
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
Definition: func.inc.php:203
$oModuleController
Definition: ko.install.php:287
if(isset($_REQUEST['encode'])) if(isset($_REQUEST['decode'])) $lang
Definition: example.php:23