XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
member.admin.view.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
8 class memberAdminView extends member
9 {
15  var $group_list = NULL;
16 
22  var $memberInfo = NULL;
23 
29  var $memberConfig = NULL;
30 
36  function init()
37  {
38  $oMemberModel = getModel('member');
39  $this->memberConfig = $oMemberModel->getMemberConfig();
40  Context::set('config', $this->memberConfig);
41  $oSecurity = new Security();
42  $oSecurity->encodeHTML('config.signupForm..');
43 
44  // if member_srl exists, set memberInfo
45  $member_srl = Context::get('member_srl');
46  if($member_srl)
47  {
48  $this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($member_srl);
49  if(!$this->memberInfo)
50  {
51  Context::set('member_srl','');
52  }
53  else
54  {
55  Context::set('member_info',$this->memberInfo);
56  }
57  }
58 
59  // retrieve group list
60  $this->group_list = $oMemberModel->getGroups();
61  Context::set('group_list', $this->group_list);
62 
63  $security = new Security();
64  $security->encodeHTML('group_list..', 'config..');
65 
66  $this->setTemplatePath($this->module_path.'tpl');
67  }
68 
75  {
76  $oMemberAdminModel = getAdminModel('member');
77  $oMemberModel = getModel('member');
78  $output = $oMemberAdminModel->getMemberList();
79 
80  $filter = Context::get('filter_type');
81  global $lang;
82  switch($filter)
83  {
84  case 'super_admin' : Context::set('filter_type_title', $lang->cmd_show_super_admin_member);break;
85  case 'site_admin' : Context::set('filter_type_title', $lang->cmd_show_site_admin_member);break;
86  default : Context::set('filter_type_title', $lang->cmd_show_all_member);break;
87  }
88  // retrieve list of groups for each member
89  if($output->data)
90  {
91  foreach($output->data as $key => $member)
92  {
93  $output->data[$key]->group_list = $oMemberModel->getMemberGroups($member->member_srl,0);
94  }
95  }
96  $config = $this->memberConfig;
97  $memberIdentifiers = array('user_id'=>'user_id', 'user_name'=>'user_name', 'nick_name'=>'nick_name');
98  $usedIdentifiers = array();
99 
100  if(is_array($config->signupForm))
101  {
102  foreach($config->signupForm as $signupItem)
103  {
104  if(!count($memberIdentifiers)) break;
105  if(in_array($signupItem->name, $memberIdentifiers) && ($signupItem->required || $signupItem->isUse))
106  {
107  unset($memberIdentifiers[$signupItem->name]);
108  $usedIdentifiers[$signupItem->name] = $lang->{$signupItem->name};
109  }
110  }
111  }
112  Context::set('total_count', $output->total_count);
113  Context::set('total_page', $output->total_page);
114  Context::set('page', $output->page);
115  Context::set('member_list', $output->data);
116  Context::set('usedIdentifiers', $usedIdentifiers);
117  Context::set('page_navigation', $output->page_navigation);
118 
119  $security = new Security();
120  $security->encodeHTML('member_list..user_name', 'member_list..nick_name', 'member_list..group_list..');
121  $security->encodeHTML('search_target', 'search_keyword');
122 
123  $this->setTemplateFile('member_list');
124  }
125 
131  public function dispMemberAdminConfig()
132  {
133  $oPassword = new Password();
134  Context::set('password_hashing_algos', $oPassword->getSupportedAlgorithms());
135 
136  $this->setTemplateFile('default_config');
137  }
138 
139  public function dispMemberAdminSignUpConfig()
140  {
141  $config = $this->memberConfig;
142 
143  if($config->redirect_url)
144  {
145  $mid = str_ireplace(Context::getDefaultUrl(), '', $config->redirect_url);
146 
147  $siteModuleInfo = Context::get('site_module_info');
148 
149  $oModuleModel = getModel('module');
150  $moduleInfo = $oModuleModel->getModuleInfoByMid($mid, (int)$siteModuleInfo->site_srl);
151 
152  $config->redirect_url = $moduleInfo->module_srl;
153  Context::set('config', $config);
154  }
155 
156  $oMemberModel = getModel('member');
157  // retrieve skins of editor
158  $oEditorModel = getModel('editor');
159  Context::set('editor_skin_list', $oEditorModel->getEditorSkinList());
160 
161  // get an editor
162  $option = new stdClass();
163  $option->skin = $oEditorModel->getEditorConfig()->editor_skin;
164  $option->primary_key_name = 'temp_srl';
165  $option->content_key_name = 'agreement';
166  $option->allow_fileupload = false;
167  $option->enable_autosave = false;
168  $option->enable_default_component = true;
169  $option->enable_component = true;
170  $option->resizable = true;
171  $option->height = 300;
172  $editor = $oEditorModel->getEditor(0, $option);
173  Context::set('editor', $editor);
174 
175  $signupForm = $config->signupForm;
176  foreach($signupForm as $val)
177  {
178  if($val->name == 'user_id')
179  {
180  $userIdInfo = $val;
181  break;
182  }
183  }
184 
185  $oSecurity = new Security();
186  if($userIdInfo->isUse)
187  {
188  // get denied ID list
189  Context::set('useUserID', 1);
190  $denied_list = $oMemberModel->getDeniedIDs();
191  Context::set('deniedIDs', $denied_list);
192  $oSecurity->encodeHTML('deniedIDs..user_id');
193  }
194 
195  // get denied NickName List
196  $deniedNickNames = $oMemberModel->getDeniedNickNames();
197  Context::set('deniedNickNames', $deniedNickNames);
198  $oSecurity->encodeHTML('deniedNickNames..nick_name');
199  $this->setTemplateFile('signup_config');
200  }
201 
202  public function dispMemberAdminLoginConfig()
203  {
204  $this->setTemplateFile('login_config');
205  }
206 
207  public function dispMemberAdminDesignConfig()
208  {
209  $oModuleModel = getModel('module');
210  // Get a layout list
211  $oLayoutModel = getModel('layout');
212  $layout_list = $oLayoutModel->getLayoutList();
213 
214  Context::set('layout_list', $layout_list);
215 
216  $mlayout_list = $oLayoutModel->getLayoutList(0, 'M');
217 
218  Context::set('mlayout_list', $mlayout_list);
219 
220  // list of skins for member module
221  $skin_list = $oModuleModel->getSkins($this->module_path);
222  Context::set('skin_list', $skin_list);
223 
224  // list of skins for member module
225  $mskin_list = $oModuleModel->getSkins($this->module_path, 'm.skins');
226  Context::set('mskin_list', $mskin_list);
227 
228  $this->setTemplateFile('design_config');
229  }
230 
237  {
238  $oModuleModel = getModel('module');
239  $oMemberModel = getModel('member');
240 
241  // Get a layout list
242  $oLayoutModel = getModel('layout');
243  $layout_list = $oLayoutModel->getLayoutList();
244 
245  Context::set('layout_list', $layout_list);
246 
247  $mlayout_list = $oLayoutModel->getLayoutList(0, 'M');
248 
249  Context::set('mlayout_list', $mlayout_list);
250 
251  // list of skins for member module
252  $skin_list = $oModuleModel->getSkins($this->module_path);
253  Context::set('skin_list', $skin_list);
254 
255  // list of skins for member module
256  $mskin_list = $oModuleModel->getSkins($this->module_path, 'm.skins');
257  Context::set('mskin_list', $mskin_list);
258 
259  // retrieve skins of editor
260  $oEditorModel = getModel('editor');
261  Context::set('editor_skin_list', $oEditorModel->getEditorSkinList());
262 
263  // get an editor
264  $option->skin = $oEditorModel->getEditorConfig()->editor_skin;
265  $option->primary_key_name = 'temp_srl';
266  $option->content_key_name = 'agreement';
267  $option->allow_fileupload = false;
268  $option->enable_autosave = false;
269  $option->enable_default_component = true;
270  $option->enable_component = true;
271  $option->resizable = true;
272  $option->height = 300;
273  $editor = $oEditorModel->getEditor(0, $option);
274  Context::set('editor', $editor);
275 
276  $signupForm = $config->signupForm;
277  foreach($signupForm as $val)
278  {
279  if($val->name == 'user_id')
280  {
281  $userIdInfo = $val;
282  break;
283  }
284  }
285 
286  if($userIdInfo->isUse)
287  {
288  // get denied ID list
289  Context::set('useUserID', 1);
290  $denied_list = $oMemberModel->getDeniedIDs();
291  Context::set('deniedIDs', $denied_list);
292  }
293 
294  // get denied NickName List
295  $deniedNickNames = $oMemberModel->getDeniedNickNames();
296  Context::set('deniedNickNames', $deniedNickNames);
297 
298  $security = new Security();
299  $security->encodeHTML('config..');
300 
301  $this->setTemplateFile('member_config');
302  }
303 
310  {
311  $oMemberModel = getModel('member');
312  $oModuleModel = getModel('module');
313 
314  $member_config = $oModuleModel->getModuleConfig('member');
315  Context::set('member_config', $member_config);
316  $extendForm = $oMemberModel->getCombineJoinForm($this->memberInfo);
317  Context::set('extend_form_list', $extendForm);
318  $memberInfo = get_object_vars(Context::get('member_info'));
319  if (!is_array($memberInfo['group_list'])) $memberInfo['group_list'] = array();
320  Context::set('memberInfo', $memberInfo);
321 
322  $disableColumns = array('password', 'find_account_question', 'find_account_answer');
323  Context::set('disableColumns', $disableColumns);
324 
325  $security = new Security();
326  $security->encodeHTML('member_config..');
327  $security->encodeHTML('extend_form_list...');
328 
329  $oMemberView = getView('member');
330 
331  $oMemberView->_getDisplayedMemberInfo($this->memberInfo, $extendForm, $member_config);
332 
333  $this->setTemplateFile('member_info');
334  }
335 
342  {
343  // retrieve extend form
344  $oMemberModel = getModel('member');
345 
346  $memberInfo = Context::get('member_info');
347  if(isset($memberInfo))
348  {
349  $memberInfo->signature = $oMemberModel->getSignature($this->memberInfo->member_srl);
350  }
351  Context::set('member_info', $memberInfo);
352 
353  // get an editor for the signature
354  if($memberInfo->member_srl)
355  {
356  $oEditorModel = getModel('editor');
357  $option = new stdClass();
358  $option->skin = $oEditorModel->getEditorConfig()->editor_skin;
359  $option->primary_key_name = 'member_srl';
360  $option->content_key_name = 'signature';
361  $option->allow_fileupload = false;
362  $option->enable_autosave = false;
363  $option->enable_default_component = true;
364  $option->enable_component = false;
365  $option->resizable = false;
366  $option->height = 200;
367  $editor = $oEditorModel->getEditor($this->memberInfo->member_srl, $option);
368  Context::set('editor', $editor);
369  }
370 
371  unset($memberInfo->find_account_question);
372  unset($memberInfo->find_account_answer);
373  $formTags = $this->_getMemberInputTag($memberInfo, true);
374  Context::set('formTags', $formTags);
375  $member_config = $this->memberConfig;
376 
377  global $lang;
378  $identifierForm = new stdClass();
379  $identifierForm->title = $lang->{$member_config->identifier};
380  $identifierForm->name = $member_config->identifier;
381  $identifierForm->value = $memberInfo->{$member_config->identifier};
382  Context::set('identifierForm', $identifierForm);
383  $this->setTemplateFile('insert_member');
384  }
385 
394  function _getMemberInputTag($memberInfo, $isAdmin = false)
395  {
396  $logged_info = Context::get('logged_info');
397  $oMemberModel = getModel('member');
398  $extend_form_list = $oMemberModel->getCombineJoinForm($memberInfo);
399  $security = new Security($extend_form_list);
400  $security->encodeHTML('..column_title', '..description', '..default_value.');
401 
402  if ($memberInfo)
403  {
404  $memberInfo = get_object_vars($memberInfo);
405  }
406 
407  $member_config = $this->memberConfig;
408  if(!$this->memberConfig)
409  {
410  $member_config = $this->memberConfig = $oMemberModel->getMemberConfig();
411  }
412 
413  unset($member_config->signupForm->find_account_question);
414  unset($member_config->signupForm->find_account_answer);
415 
416  $formTags = array();
417  global $lang;
418 
419  foreach($member_config->signupForm as $no=>$formInfo)
420  {
421  if(!$formInfo->isUse)continue;
422 
423  // 회원 본인이 아닌 경우 입력 폼 제거
424  if($formInfo->name == 'find_account_question' && $memberInfo['member_srl'] !== $logged_info->member_srl)
425  {
426  unset($member_config->signupForm[$no]);
427  continue;
428  }
429 
430  if($formInfo->name == $member_config->identifier || $formInfo->name == 'password') continue;
431 
432  $formTag = new stdClass();
433  $inputTag = '';
434  $formTag->title = ($formInfo->isDefaultForm) ? $lang->{$formInfo->name} : $formInfo->title;
435  if($isAdmin)
436  {
437  if($formInfo->mustRequired) $formTag->title = '<em style="color:red">*</em> '.$formTag->title;
438  }
439  else
440  {
441  if ($formInfo->required && $formInfo->name != 'password') $formTag->title = '<em style="color:red">*</em> '.$formTag->title;
442  }
443  $formTag->name = $formInfo->name;
444 
445  if($formInfo->isDefaultForm)
446  {
447  if($formInfo->imageType)
448  {
449  $formTag->type = 'image';
450  if($formInfo->name == 'profile_image')
451  {
452  $target = $memberInfo['profile_image'];
453  $functionName = 'doDeleteProfileImage';
454  }
455  else if($formInfo->name == 'image_name')
456  {
457  $target = $memberInfo['image_name'];
458  $functionName = 'doDeleteImageName';
459  }
460  else if($formInfo->name == 'image_mark')
461  {
462  $target = $memberInfo['image_mark'];
463  $functionName = 'doDeleteImageMark';
464  }
465 
466  if($target->src)
467  {
468  $inputTag = sprintf('<input type="hidden" name="__%s_exist" value="true" /><span id="%s"><img src="%s" alt="%s" /> <button type="button" onclick="%s(%d);return false;">%s</button></span>',
469  $formInfo->name,
470  $formInfo->name.'tag',
471  $target->src,
472  $formInfo->title,
473  $functionName,
474  $memberInfo['member_srl'],
475  $lang->cmd_delete);
476  }
477  else
478  {
479  $inputTag = sprintf('<input type="hidden" name="__%s_exist" value="false" />', $formInfo->name);
480  }
481  $inputTag .= sprintf('<input type="file" name="%s" id="%s" value="" accept="image/*" /><p class="help-block">%s: %dpx, %s: %dpx</p>',
482  $formInfo->name,
483  $formInfo->name,
484  $lang->{$formInfo->name.'_max_width'},
485  $member_config->{$formInfo->name.'_max_width'},
486  $lang->{$formInfo->name.'_max_height'},
487  $member_config->{$formInfo->name.'_max_height'});
488  }//end imageType
489  else if($formInfo->name == 'birthday')
490  {
491  $formTag->type = 'date';
492  $inputTag = sprintf('<input type="hidden" name="birthday" id="date_birthday" value="%s" /><input type="text" placeholder="YYYY-MM-DD" name="birthday_ui" class="inputDate" id="birthday" value="%s" readonly="readonly" /> <input type="button" value="%s" class="btn dateRemover" />',
493  $memberInfo['birthday'],
494  zdate($memberInfo['birthday'], 'Y-m-d', false),
495  $lang->cmd_delete);
496  }
497  else if($formInfo->name == 'find_account_question')
498  {
499  $disabled = (!!$memberInfo['member_srl']) ? 'disabled="disabled"' : '';
500 
501  $formTag->type = 'select';
502  $inputTag = '<select name="find_account_question" id="find_account_question" style="display:block;margin:0 0 8px 0" %s>%s</select>';
503  $optionTag = array();
504  foreach($lang->find_account_question_items as $key=>$val)
505  {
506  if($key == $memberInfo['find_account_question']) $selected = 'selected="selected"';
507  else $selected = '';
508  $optionTag[] = sprintf('<option value="%s" %s >%s</option>',
509  $key,
510  $selected,
511  $val);
512  }
513  $inputTag = sprintf($inputTag, $disabled, implode('', $optionTag));
514  $inputTag .= '<input type="text" name="find_account_answer" id="find_account_answer" title="'.Context::getLang('find_account_answer').'" value="" ' . $disabled . ' />';
515 
516  if($disabled) {
517  $inputTag .= ' <label><input type="checkbox" name="modify_find_account_answer" value="Y" /> ' . Context::getLang('cmd_modify') . '</label>';
518  $inputTag .= '<script>(function($) {$(function() {$(\'[name=modify_find_account_answer]\').change(function() {var $this = $(this); if($this.prop(\'checked\')) {$(\'[name=find_account_question],[name=find_account_answer]\').attr(\'disabled\', false); } else {$(\'[name=find_account_question]\').attr(\'disabled\', true); $(\'[name=find_account_answer]\').attr(\'disabled\', true).val(\'\'); } }); }); })(jQuery);</script>';
519  }
520  }
521  else if($formInfo->name == 'email_address')
522  {
523  $formTag->type = 'email';
524  $inputTag = '<input type="email" name="email_address" id="email_address" value="'.$memberInfo['email_address'].'" />';
525  }
526  else if($formInfo->name == 'homepage')
527  {
528  $formTag->type = 'url';
529  $inputTag = '<input type="url" name="homepage" id="homepage" value="'.$memberInfo['homepage'].'" />';
530  }
531  else if($formInfo->name == 'blog')
532  {
533  $formTag->type = 'url';
534  $inputTag = '<input type="url" name="blog" id="blog" value="'.$memberInfo['blog'].'" />';
535  }
536  else
537  {
538  $formTag->type = 'text';
539  $inputTag = sprintf('<input type="text" name="%s" id="%s" value="%s" />',
540  $formInfo->name,
541  $formInfo->name,
542  $memberInfo[$formInfo->name]);
543  }
544  }//end isDefaultForm
545  else
546  {
547  $extendForm = $extend_form_list[$formInfo->member_join_form_srl];
548  $replace = array('column_name' => $extendForm->column_name, 'value' => $extendForm->value);
549  $extentionReplace = array();
550 
551  $formTag->type = $extendForm->column_type;
552  if($extendForm->column_type == 'text')
553  {
554  $template = '<input type="text" name="%column_name%" id="%column_name%" value="%value%" />';
555  }
556  else if($extendForm->column_type == 'homepage')
557  {
558  $template = '<input type="url" name="%column_name%" id="%column_name%" value="%value%" />';
559  }
560  else if($extendForm->column_type == 'email_address')
561  {
562  $template = '<input type="email" name="%column_name%" id="%column_name%" value="%value%" />';
563  }
564  else if($extendForm->column_type == 'tel')
565  {
566  $extentionReplace = array('tel_0' => $extendForm->value[0],
567  'tel_1' => $extendForm->value[1],
568  'tel_2' => $extendForm->value[2]);
569  $template = '<input type="tel" name="%column_name%[]" id="%column_name%" value="%tel_0%" size="4" maxlength="4" style="width:30px" title="First Number" /> - <input type="tel" name="%column_name%[]" value="%tel_1%" size="4" maxlength="4" style="width:35px" title="Second Number" /> - <input type="tel" name="%column_name%[]" value="%tel_2%" size="4" maxlength="4" style="width:35px" title="Third Number" />';
570  }
571  else if($extendForm->column_type == 'textarea')
572  {
573  $template = '<textarea name="%column_name%" id="%column_name%" rows="4" cols="42">%value%</textarea>';
574  }
575  else if($extendForm->column_type == 'checkbox')
576  {
577  $template = '';
578  if($extendForm->default_value)
579  {
580  $template = '<div style="padding-top:5px">%s</div>';
581  $__i = 0;
582  $optionTag = array();
583  foreach($extendForm->default_value as $v)
584  {
585  $checked = '';
586  if(is_array($extendForm->value) && in_array($v, $extendForm->value))$checked = 'checked="checked"';
587  $optionTag[] = '<label for="%column_name%'.$__i.'"><input type="checkbox" id="%column_name%'.$__i.'" name="%column_name%[]" value="'.$v.'" '.$checked.' /> '.$v.'</label>';
588  $__i++;
589  }
590  $template = sprintf($template, implode('', $optionTag));
591  }
592  }
593  else if($extendForm->column_type == 'radio')
594  {
595  $template = '';
596  if($extendForm->default_value)
597  {
598  $template = '<div style="padding-top:5px">%s</div>';
599  $optionTag = array();
600  foreach($extendForm->default_value as $v)
601  {
602  if($extendForm->value == $v)$checked = 'checked="checked"';
603  else $checked = '';
604  $optionTag[] = '<label><input type="radio" name="%column_name%" value="'.$v.'" '.$checked.' /> '.$v.'</label>';
605  }
606  $template = sprintf($template, implode('', $optionTag));
607  }
608  }
609  else if($extendForm->column_type == 'select')
610  {
611  $template = '<select name="'.$formInfo->name.'" id="'.$formInfo->name.'">%s</select>';
612  $optionTag = array();
613  $optionTag[] = sprintf('<option value="">%s</option>', $lang->cmd_select);
614  if($extendForm->default_value)
615  {
616  foreach($extendForm->default_value as $v)
617  {
618  if($v == $extendForm->value) $selected = 'selected="selected"';
619  else $selected = '';
620  $optionTag[] = sprintf('<option value="%s" %s >%s</option>', $v, $selected, $v);
621  }
622  }
623  $template = sprintf($template, implode('', $optionTag));
624  }
625  else if($extendForm->column_type == 'kr_zip')
626  {
627  $krzipModel = getModel('krzip');
628  if($krzipModel && method_exists($krzipModel , 'getKrzipCodeSearchHtml' ))
629  {
630  $template = $krzipModel->getKrzipCodeSearchHtml($extendForm->column_name, $extendForm->value);
631  }
632  }
633  else if($extendForm->column_type == 'jp_zip')
634  {
635  $template = '<input type="text" name="%column_name%" id="%column_name%" value="%value%" />';
636  }
637  else if($extendForm->column_type == 'date')
638  {
639  $extentionReplace = array('date' => zdate($extendForm->value, 'Y-m-d'), 'cmd_delete' => $lang->cmd_delete);
640  $template = '<input type="hidden" name="%column_name%" id="date_%column_name%" value="%value%" /><input type="text" placeholder="YYYY-MM-DD" class="inputDate" value="%date%" readonly="readonly" /> <input type="button" value="%cmd_delete%" class="btn dateRemover" />';
641  }
642 
643  $replace = array_merge($extentionReplace, $replace);
644  $inputTag = preg_replace_callback('@%(\w+)%@', function($n) use($replace) { return $replace[$n[1]]; }, $template);
645 
646  if($extendForm->description)
647  $inputTag .= '<p class="help-block">'.$extendForm->description.'</p>';
648  }
649  $formTag->inputTag = $inputTag;
650  $formTags[] = $formTag;
651  }
652  return $formTags;
653  }
654 
661  {
662  $oModuleModel = getModel('module');
663  $output = $oModuleModel->getModuleFileBoxList();
664  Context::set('fileBoxList', $output->data);
665 
666  $this->setTemplateFile('group_list');
667  }
668 
675  // Get the value of join_form
676  $member_join_form_srl = Context::get('member_join_form_srl');
677  if($member_join_form_srl)
678  {
679  $oMemberModel = getModel('member');
680  $join_form = $oMemberModel->getJoinForm($member_join_form_srl);
681 
682  if(!$join_form) Context::set('member_join_form_srl','',true);
683  else
684  {
685  Context::set('join_form', $join_form);
686  $security = new Security();
687  $security->encodeHTML('join_form..');
688  }
689 
690  }
691  $this->setTemplateFile('insert_join_form');
692  }
693 }
694 /* End of file member.admin.view.php */
695 /* Location: ./modules/member/member.admin.view.php */
setTemplateFile($filename)
$oModuleModel
Definition: ko.install.php:236
zdate($str, $format= 'Y-m-d H:i:s', $conversion=TRUE)
Definition: func.inc.php:692
$output
Definition: ko.install.php:193
set($key, $val, $set_to_get_vars=0)
getView($module_name)
Definition: func.inc.php:112
getAdminModel($module_name)
Definition: func.inc.php:156
getLang($code)
$moduleInfo
Definition: ko.install.php:253
getModel($module_name)
Definition: func.inc.php:145
_getMemberInputTag($memberInfo, $isAdmin=false)
if(isset($_REQUEST['encode'])) if(isset($_REQUEST['decode'])) $lang
Definition: example.php:23