XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
member.model.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
8 class memberModel extends member
9 {
13  var $join_form_list = NULL;
14 
18  function init()
19  {
20  }
21 
25  function getMemberConfig()
26  {
27  static $member_config;
28 
29  if($member_config)
30  {
31  return $member_config;
32  }
33 
34  // Get member configuration stored in the DB
35  $oModuleModel = getModel('module');
36  $config = $oModuleModel->getModuleConfig('member');
37 
38  if(!$config->signupForm || !is_array($config->signupForm))
39  {
40  $oMemberAdminController = getAdminController('member');
41  $identifier = ($config->identifier) ? $config->identifier : 'email_address';
42  $config->signupForm = $oMemberAdminController->createSignupForm($identifier);
43  }
44  //for multi language
45  foreach($config->signupForm AS $key=>$value)
46  {
47  $config->signupForm[$key]->title = ($value->isDefaultForm) ? Context::getLang($value->name) : $value->title;
48  if($config->signupForm[$key]->isPublic != 'N') $config->signupForm[$key]->isPublic = 'Y';
49  if($value->name == 'find_account_question') $config->signupForm[$key]->isPublic = 'N';
50  }
51 
52  // Get terms of user
53  $config->agreement = memberModel::_getAgreement();
54 
55  if(!$config->webmaster_name) $config->webmaster_name = 'webmaster';
56 
57  if(!$config->image_name_max_width) $config->image_name_max_width = 90;
58  if(!$config->image_name_max_height) $config->image_name_max_height = 20;
59  if(!$config->image_name_max_filesize) $config->image_name_max_filesize = null;
60  if(!$config->image_mark_max_width) $config->image_mark_max_width = 20;
61  if(!$config->image_mark_max_height) $config->image_mark_max_height = 20;
62  if(!$config->image_mark_max_filesize) $config->image_mark_max_filesize = null;
63  if(!$config->profile_image_max_width) $config->profile_image_max_width = 90;
64  if(!$config->profile_image_max_height) $config->profile_image_max_height = 90;
65  if(!$config->profile_image_max_filesize) $config->profile_image_max_filesize = null;
66 
67  if(!$config->skin) $config->skin = 'default';
68  if(!$config->colorset) $config->colorset = 'white';
69  if(!$config->editor_skin || $config->editor_skin == 'default') $config->editor_skin = 'ckeditor';
70  if(!$config->group_image_mark) $config->group_image_mark = "N";
71 
72  if(!$config->identifier) $config->identifier = 'user_id';
73 
74  if(!$config->max_error_count) $config->max_error_count = 10;
75  if(!$config->max_error_count_time) $config->max_error_count_time = 300;
76 
77  if(!$config->signature_editor_skin || $config->signature_editor_skin == 'default') $config->signature_editor_skin = 'ckeditor';
78  if(!$config->sel_editor_colorset) $config->sel_editor_colorset = 'moono';
79 
80  $member_config = $config;
81 
82  return $config;
83  }
84 
85  function _getAgreement()
86  {
87  $agreement_file = _XE_PATH_.'files/member_extra_info/agreement_' . Context::get('lang_type') . '.txt';
88  if(is_readable($agreement_file))
89  {
90  return FileHandler::readFile($agreement_file);
91  }
92 
93  $db_info = Context::getDBInfo();
94  $agreement_file = _XE_PATH_.'files/member_extra_info/agreement_' . $db_info->lang_type . '.txt';
95  if(is_readable($agreement_file))
96  {
97  return FileHandler::readFile($agreement_file);
98  }
99 
100  $lang_selected = Context::loadLangSelected();
101  foreach($lang_selected as $key => $val)
102  {
103  $agreement_file = _XE_PATH_.'files/member_extra_info/agreement_' . $key . '.txt';
104  if(is_readable($agreement_file))
105  {
106  return FileHandler::readFile($agreement_file);
107  }
108  }
109 
110  return null;
111  }
112 
116  function getMemberMenu()
117  {
118  // Get member_srl of he target member and logged info of the current user
119  $member_srl = Context::get('target_srl');
120  $mid = Context::get('cur_mid');
121  $logged_info = Context::get('logged_info');
122  $act = Context::get('cur_act');
123  // When click user's own nickname
124  if($member_srl == $logged_info->member_srl) $member_info = $logged_info;
125  // When click other's nickname
126  else $member_info = $this->getMemberInfoByMemberSrl($member_srl);
127 
128  $member_srl = $member_info->member_srl;
129  if(!$member_srl) return;
130  // List variables
131  $user_id = $member_info->user_id;
132  $user_name = $member_info->user_name;
133 
134  ModuleHandler::triggerCall('member.getMemberMenu', 'before', $null);
135 
136  $oMemberController = getController('member');
137  // Display member information (Don't display to non-logged user)
138  if($logged_info->member_srl)
139  {
140  $url = getUrl('','mid',$mid,'act','dispMemberInfo','member_srl',$member_srl);
141  $oMemberController->addMemberPopupMenu($url,'cmd_view_member_info',$icon_path,'self');
142  }
143  // When click other's nickname
144  if($member_srl != $logged_info->member_srl && $logged_info->member_srl)
145  {
146  // Get email config
147  foreach($this->module_config->signupForm as $field)
148  {
149  if($field->name == 'email_address')
150  {
151  $email_config = $field;
152  break;
153  }
154  }
155 
156  // Send an email only if email address is public
157  if(($logged_info->is_admin == 'Y' || $email_config->isPublic == 'Y') && $member_info->email_address)
158  {
159  $url = 'mailto:'.htmlspecialchars($member_info->email_address, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
160  $oMemberController->addMemberPopupMenu($url,'cmd_send_email',$icon_path);
161  }
162  }
163  // View homepage info
164  if($member_info->homepage)
165  $oMemberController->addMemberPopupMenu(htmlspecialchars($member_info->homepage, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), 'homepage', '', 'blank');
166  // View blog info
167  if($member_info->blog)
168  $oMemberController->addMemberPopupMenu(htmlspecialchars($member_info->blog, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), 'blog', '', 'blank');
169  // Call a trigger (after)
170  ModuleHandler::triggerCall('member.getMemberMenu', 'after', $null);
171  // Display a menu for editting member info to a top administrator
172  if($logged_info->is_admin == 'Y')
173  {
174  $url = getUrl('','module','admin','act','dispMemberAdminInsert','member_srl',$member_srl);
175  $oMemberController->addMemberPopupMenu($url,'cmd_manage_member_info',$icon_path,'MemberModifyInfo');
176 
177  $url = getUrl('','module','admin','act','dispDocumentAdminList','search_target','member_srl','search_keyword',$member_srl);
178  $oMemberController->addMemberPopupMenu($url,'cmd_trace_document',$icon_path,'TraceMemberDocument');
179 
180  $url = getUrl('','module','admin','act','dispCommentAdminList','search_target','member_srl','search_keyword',$member_srl);
181  $oMemberController->addMemberPopupMenu($url,'cmd_trace_comment',$icon_path,'TraceMemberComment');
182  }
183  // Change a language of pop-up menu
184  $menus = Context::get('member_popup_menu_list');
185  $menus_count = count($menus);
186  for($i=0;$i<$menus_count;$i++)
187  {
188  $menus[$i]->str = Context::getLang($menus[$i]->str);
189  }
190  // Get a list of finalized pop-up menu
191  $this->add('menus', $menus);
192  }
193 
197  function isLogged() {
198  if($_SESSION['is_logged'])
199  {
201  {
202  return true;
203  }
204  elseif(filter_var($_SESSION['ipaddress'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
205  {
206  // IPv6: require same /48
207  if(strncmp(inet_pton($_SESSION['ipaddress']), inet_pton($_SERVER['REMOTE_ADDR']), 6) == 0)
208  {
209  return true;
210  }
211  }
212  else
213  {
214  // IPv4: require same /24
215  if(ip2long($_SESSION['ipaddress']) >> 8 == ip2long($_SERVER['REMOTE_ADDR']) >> 8)
216  {
217  return true;
218  }
219  }
220  }
221 
222  $_SESSION['is_logged'] = false;
223  return false;
224  }
225 
229  function getLoggedInfo()
230  {
231  // Return session info if session info is requested and the user is logged-in
232  if($this->isLogged())
233  {
234  $logged_info = Context::get('logged_info');
235  // Admin/Group list defined depending on site_module_info
236  $site_module_info = Context::get('site_module_info');
237  if($site_module_info->site_srl)
238  {
239  $logged_info->group_list = $this->getMemberGroups($logged_info->member_srl, $site_module_info->site_srl);
240  // Add is_site_admin bool variable into logged_info if site_administrator is
241  $oModuleModel = getModel('module');
242  if($oModuleModel->isSiteAdmin($logged_info)) $logged_info->is_site_admin = true;
243  else $logged_info->is_site_admin = false;
244  }
245  else
246  {
247  // Register a default group if the site doesn't have a member group
248  if(count($logged_info->group_list) === 0)
249  {
250  $default_group = $this->getDefaultGroup(0);
251  $oMemberController = getController('member');
252  $oMemberController->addMemberToGroup($logged_info->member_srl, $default_group->group_srl, 0);
253  $groups[$default_group->group_srl] = $default_group->title;
254  $logged_info->group_list = $groups;
255  }
256 
257  $logged_info->is_site_admin = false;
258  }
259  Context::set('logged_info', $logged_info);
260 
261  return $logged_info;
262  }
263  return NULL;
264  }
265 
269  function getMemberInfoByUserID($user_id, $columnList = array())
270  {
271  if(!$user_id) return;
272 
273  $args = new stdClass;
274  $args->user_id = $user_id;
275  $output = executeQuery('member.getMemberInfo', $args);
276  if(!$output->toBool()) return $output;
277  if(!$output->data) return;
278 
279  $member_info = $this->arrangeMemberInfo($output->data);
280 
281  return $member_info;
282  }
283 
287  function getMemberInfoByEmailAddress($email_address)
288  {
289  if(!$email_address) return;
290 
291  $args = new stdClass();
292 
293  $db_info = Context::getDBInfo ();
294  if($db_info->master_db['db_type'] == "cubrid")
295  {
296  $args->email_address = strtolower($email_address);
297  $output = executeQuery('member.getMemberInfoByEmailAddressForCubrid', $args);
298  }
299  else
300  {
301  $args->email_address = $email_address;
302  $output = executeQuery('member.getMemberInfoByEmailAddress', $args);
303  }
304 
305  if(!$output->toBool()) return $output;
306  if(!$output->data) return;
307 
308  $member_info = $this->arrangeMemberInfo($output->data);
309  return $member_info;
310  }
311 
315  function getMemberInfoByMemberSrl($member_srl, $site_srl = 0, $columnList = array())
316  {
317  if(!$member_srl) return;
318 
319  //columnList size zero... get full member info
320  if(!$GLOBALS['__member_info__'][$member_srl] || count($columnList) == 0)
321  {
322  $GLOBALS['__member_info__'][$member_srl] = false;
323 
324  $oCacheHandler = CacheHandler::getInstance('object');
325  if($oCacheHandler->isSupport())
326  {
327  $columnList = array();
328  $object_key = 'member_info:' . getNumberingPath($member_srl) . $member_srl;
329  $cache_key = $oCacheHandler->getGroupKey('member', $object_key);
330  $GLOBALS['__member_info__'][$member_srl] = $oCacheHandler->get($cache_key);
331  }
332 
333  if($GLOBALS['__member_info__'][$member_srl] === false)
334  {
335  $args = new stdClass();
336  $args->member_srl = $member_srl;
337  $output = executeQuery('member.getMemberInfoByMemberSrl', $args, $columnList);
338  if(!$output->data)
339  {
340  if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, new stdClass);
341  return;
342  }
343  $this->arrangeMemberInfo($output->data, $site_srl);
344 
345  //insert in cache
346  if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $GLOBALS['__member_info__'][$member_srl]);
347  }
348  }
349 
350  return $GLOBALS['__member_info__'][$member_srl];
351  }
352 
356  function arrangeMemberInfo($info, $site_srl = 0)
357  {
358  if(!$GLOBALS['__member_info__'][$info->member_srl])
359  {
360  $oModuleModel = getModel('module');
361  $config = $oModuleModel->getModuleConfig('member');
362 
363 
364  $info->profile_image = $this->getProfileImage($info->member_srl);
365  $info->image_name = $this->getImageName($info->member_srl);
366  $info->image_mark = $this->getImageMark($info->member_srl);
367  if($config->group_image_mark=='Y')
368  {
369  $info->group_mark = $this->getGroupImageMark($info->member_srl,$site_srl);
370  }
371  $info->signature = $this->getSignature($info->member_srl);
372  $info->group_list = $this->getMemberGroups($info->member_srl, $site_srl);
373 
374  $extra_vars = unserialize($info->extra_vars);
375  unset($info->extra_vars);
376  if($extra_vars)
377  {
378  foreach($extra_vars as $key => $val)
379  {
380  if(!is_array($val) && strpos($val, '|@|') !== FALSE) $val = explode('|@|', $val);
381  if(!$info->{$key}) $info->{$key} = $val;
382  }
383  }
384 
385  if(strlen($info->find_account_answer) == 32 && preg_match('/[a-zA-Z0-9]+/', $info->find_account_answer))
386  {
387  $info->find_account_answer = null;
388  }
389 
390  // XSS defence
391  $oSecurity = new Security($info);
392  $oSecurity->encodeHTML('user_id', 'user_name', 'nick_name', 'find_account_answer', 'description', 'address.', 'group_list..');
393 
394  $info->homepage = strip_tags($info->homepage);
395  $info->blog = strip_tags($info->blog);
396 
397  if($extra_vars)
398  {
399  foreach($extra_vars as $key => $val)
400  {
401  if(is_array($val))
402  {
403  $oSecurity->encodeHTML($key . '.');
404  }
405  else
406  {
407  $oSecurity->encodeHTML($key);
408  }
409  }
410  }
411 
412  // Check format.
413  $oValidator = new Validator();
414  if(!$oValidator->applyRule('url', $info->homepage))
415  {
416  $info->homepage = '';
417  }
418 
419  if(!$oValidator->applyRule('url', $info->blog))
420  {
421  $info->blog = '';
422  }
423 
424  $GLOBALS['__member_info__'][$info->member_srl] = $info;
425  }
426 
427  return $GLOBALS['__member_info__'][$info->member_srl];
428  }
429 
433  function getMemberSrlByUserID($user_id)
434  {
435  $args = new stdClass();
436  $args->user_id = $user_id;
437  $output = executeQuery('member.getMemberSrl', $args);
438  return $output->data->member_srl;
439  }
440 
444  function getMemberSrlByEmailAddress($email_address)
445  {
446  $args = new stdClass();
447  $args->email_address = $email_address;
448  $output = executeQuery('member.getMemberSrl', $args);
449  return $output->data->member_srl;
450  }
451 
455  function getMemberSrlByNickName($nick_name)
456  {
457  $args = new stdClass();
458  $args->nick_name = $nick_name;
459  $output = executeQuery('member.getMemberSrl', $args);
460  return $output->data->member_srl;
461  }
462 
467  {
468  if(!$this->isLogged()) return;
469  return $_SESSION['member_srl'];
470  }
471 
475  function getLoggedUserID()
476  {
477  if(!$this->isLogged()) return;
478  $logged_info = Context::get('logged_info');
479  return $logged_info->user_id;
480  }
481 
485  function getMemberGroups($member_srl, $site_srl = 0, $force_reload = false)
486  {
487  static $member_groups = array();
488 
489  // cache controll
490  $group_list = false;
491  $oCacheHandler = CacheHandler::getInstance('object', null, true);
492  if($oCacheHandler->isSupport())
493  {
494  $object_key = 'member_groups:' . getNumberingPath($member_srl) . $member_srl . '_'.$site_srl;
495  $cache_key = $oCacheHandler->getGroupKey('member', $object_key);
496  $group_list = $oCacheHandler->get($cache_key);
497  }
498 
499  if(!$member_groups[$member_srl][$site_srl] || $force_reload)
500  {
501  if($group_list === false)
502  {
503  $args = new stdClass();
504  $args->member_srl = $member_srl;
505  $args->site_srl = $site_srl;
506  $output = executeQueryArray('member.getMemberGroups', $args);
507  $group_list = $output->data;
508  //insert in cache
509  if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $group_list);
510  }
511  if(!$group_list) return array();
512 
513  foreach($group_list as $group)
514  {
515  $result[$group->group_srl] = $group->title;
516  }
517  $member_groups[$member_srl][$site_srl] = $result;
518  }
519  return $member_groups[$member_srl][$site_srl];
520  }
521 
525  function getMembersGroups($member_srls, $site_srl = 0)
526  {
527  $args->member_srls = implode(',',$member_srls);
528  $args->site_srl = $site_srl;
529  $args->sort_index = 'list_order';
530  $output = executeQueryArray('member.getMembersGroups', $args);
531  if(!$output->data) return array();
532 
533  $result = array();
534  foreach($output->data as $key=>$val)
535  {
536  $result[$val->member_srl][] = $val->title;
537  }
538  return $result;
539  }
540 
544  function getDefaultGroup($site_srl = 0, $columnList = array())
545  {
546  $default_group = false;
547  $oCacheHandler = CacheHandler::getInstance('object', null, true);
548  if($oCacheHandler->isSupport())
549  {
550  $columnList = array();
551  $object_key = 'default_group_' . $site_srl;
552  $cache_key = $oCacheHandler->getGroupKey('member', $object_key);
553  $default_group = $oCacheHandler->get($cache_key);
554  }
555 
556  if($default_group === false)
557  {
558  $args = new stdClass();
559  $args->site_srl = $site_srl;
560  $output = executeQuery('member.getDefaultGroup', $args, $columnList);
561  $default_group = $output->data;
562  if($oCacheHandler->isSupport())
563  {
564  $oCacheHandler->put($cache_key, $default_group);
565  }
566  }
567 
568  return $default_group;
569  }
570 
574  function getAdminGroup($columnList = array())
575  {
576  $output = executeQuery('member.getAdminGroup', $args, $columnList);
577  return $output->data;
578  }
579 
583  function getGroup($group_srl, $columnList = array())
584  {
585  $args = new stdClass;
586  $args->group_srl = $group_srl;
587  $output = executeQuery('member.getGroup', $args, $columnList);
588  return $output->data;
589  }
590 
594  function getGroups($site_srl = 0)
595  {
596  if(!$GLOBALS['__group_info__'][$site_srl])
597  {
598  $result = array();
599 
600  if(!isset($site_srl))
601  {
602  $site_srl = 0;
603  }
604 
605  $group_list = false;
606  $oCacheHandler = CacheHandler::getInstance('object', null, true);
607  if($oCacheHandler->isSupport())
608  {
609  $object_key = 'member_groups:site_'.$site_srl;
610  $cache_key = $oCacheHandler->getGroupKey('member', $object_key);
611  $group_list = $oCacheHandler->get($cache_key);
612  }
613 
614  if($group_list === false)
615  {
616  $args = new stdClass();
617  $args->site_srl = $site_srl;
618  $args->sort_index = 'list_order';
619  $args->order_type = 'asc';
620  $output = executeQueryArray('member.getGroups', $args);
621  $group_list = $output->data;
622  //insert in cache
623  if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $group_list);
624  }
625 
626  if(!$group_list)
627  {
628  return array();
629  }
630 
631 
632  foreach($group_list as $val)
633  {
634  $result[$val->group_srl] = $val;
635  }
636 
637  $GLOBALS['__group_info__'][$site_srl] = $result;
638  }
639  return $GLOBALS['__group_info__'][$site_srl];
640  }
641 
642  public function getApiGroups()
643  {
644  $siteSrl = Context::get('siteSrl');
645  $groupInfo = $this->getGroups($siteSrl);
646 
647  $this->add($groupInfo);
648  }
649 
657  function getJoinFormList($filter_response = false)
658  {
659  global $lang;
660  // Set to ignore if a super administrator.
661  $logged_info = Context::get('logged_info');
662 
663  if(!$this->join_form_list)
664  {
665  // Argument setting to sort list_order column
666  $args = new stdClass();
667  $args->sort_index = "list_order";
668  $output = executeQuery('member.getJoinFormList', $args);
669  // NULL if output data deosn't exist
670  $join_form_list = $output->data;
671  if(!$join_form_list) return NULL;
672  // Need to unserialize because serialized array is inserted into DB in case of default_value
673  if(!is_array($join_form_list)) $join_form_list = array($join_form_list);
674  $join_form_count = count($join_form_list);
675  for($i=0;$i<$join_form_count;$i++)
676  {
677  $join_form_list[$i]->column_name = strtolower($join_form_list[$i]->column_name);
678 
679  $member_join_form_srl = $join_form_list[$i]->member_join_form_srl;
680  $column_type = $join_form_list[$i]->column_type;
681  $column_name = $join_form_list[$i]->column_name;
682  $column_title = $join_form_list[$i]->column_title;
683  $default_value = $join_form_list[$i]->default_value;
684  // Add language variable
685  $lang->extend_vars[$column_name] = $column_title;
686  // unserialize if the data type if checkbox, select and so on
687  if(in_array($column_type, array('checkbox','select','radio')))
688  {
689  $join_form_list[$i]->default_value = unserialize($default_value);
690  if(!$join_form_list[$i]->default_value[0]) $join_form_list[$i]->default_value = '';
691  }
692  else
693  {
694  $join_form_list[$i]->default_value = '';
695  }
696 
697  $list[$member_join_form_srl] = $join_form_list[$i];
698  }
699  $this->join_form_list = $list;
700  }
701  // Get object style if the filter_response is true
702  if($filter_response && count($this->join_form_list))
703  {
704  foreach($this->join_form_list as $key => $val)
705  {
706  if($val->is_active != 'Y') continue;
707  unset($obj);
708  $obj->type = $val->column_type;
709  $obj->name = $val->column_name;
710  $obj->lang = $val->column_title;
711  if($logged_info->is_admin != 'Y') $obj->required = $val->required=='Y'?true:false;
712  else $obj->required = false;
713  $filter_output[] = $obj;
714 
715  unset($open_obj);
716  $open_obj->name = 'open_'.$val->column_name;
717  $open_obj->required = false;
718  $filter_output[] = $open_obj;
719 
720  }
721  return $filter_output;
722  }
723  // Return the result
724  return $this->join_form_list;
725  }
726 
733  {
734  $args = new stdClass();
735  $args->sort_index = "list_order";
736  $output = executeQueryArray('member.getJoinFormList', $args);
737 
738  if(!$output->toBool())
739  {
740  return array();
741  }
742 
743  $joinFormList = array();
744  foreach($output->data as $val)
745  {
746  if($val->is_active != 'Y')
747  {
748  continue;
749  }
750 
751  $joinFormList[] = $val;
752  }
753 
754  return $joinFormList;
755  }
756 
760  function getCombineJoinForm($member_info)
761  {
762  $extend_form_list = $this->getJoinFormlist();
763  if(!$extend_form_list) return;
764  // Member info is open only to an administrator and him/herself when is_private is true.
765  $logged_info = Context::get('logged_info');
766 
767  foreach($extend_form_list as $srl => $item)
768  {
769  $column_name = $item->column_name;
770  $value = $member_info->{$column_name};
771 
772  // Change values depening on the type of extend form
773  switch($item->column_type)
774  {
775  case 'checkbox' :
776  if($value && !is_array($value)) $value = array($value);
777  break;
778  case 'text' :
779  case 'homepage' :
780  case 'email_address' :
781  case 'tel' :
782  case 'textarea' :
783  case 'select' :
784  case 'kr_zip' :
785  break;
786  }
787 
788  $extend_form_list[$srl]->value = $value;
789 
790  if($member_info->{'open_'.$column_name}=='Y') $extend_form_list[$srl]->is_opened = true;
791  else $extend_form_list[$srl]->is_opened = false;
792  }
793  return $extend_form_list;
794  }
795 
799  function getJoinForm($member_join_form_srl)
800  {
801  $args->member_join_form_srl = $member_join_form_srl;
802  $output = executeQuery('member.getJoinForm', $args);
803  $join_form = $output->data;
804  if(!$join_form) return NULL;
805 
806  $column_type = $join_form->column_type;
807  $default_value = $join_form->default_value;
808 
809  if(in_array($column_type, array('checkbox','select','radio')))
810  {
811  $join_form->default_value = unserialize($default_value);
812  }
813  else
814  {
815  $join_form->default_value = '';
816  }
817 
818  return $join_form;
819  }
820 
824  function getDeniedIDList()
825  {
826  if(!$this->denied_id_list)
827  {
828  $args->sort_index = "list_order";
829  $args->page = Context::get('page');
830  $args->list_count = 40;
831  $args->page_count = 10;
832 
833  $output = executeQuery('member.getDeniedIDList', $args);
834  $this->denied_id_list = $output;
835  }
836  return $this->denied_id_list;
837  }
838 
839  function getDeniedIDs()
840  {
841  $output = executeQueryArray('member.getDeniedIDs');
842  if(!$output->toBool()) return array();
843  return $output->data;
844  }
845 
847  {
848  $output = executeQueryArray('member.getDeniedNickNames');
849  if(!$output->toBool())
850  {
851  return array();
852  }
853 
854  return $output->data;
855  }
856 
860  function isDeniedID($user_id)
861  {
862  $args = new stdClass();
863  $args->user_id = $user_id;
864  $output = executeQuery('member.chkDeniedID', $args);
865  if($output->data->count) return true;
866  return false;
867  }
868 
872  function isDeniedNickName($nickName)
873  {
874  $args = new stdClass();
875  $args->nick_name = $nickName;
876  $output = executeQuery('member.chkDeniedNickName', $args);
877  if($output->data->count) return true;
878  if(!$output->toBool())
879  {
880  return true;
881  }
882  return false;
883  }
887  function getProfileImage($member_srl)
888  {
889  if(!isset($GLOBALS['__member_info__']['profile_image'][$member_srl]))
890  {
891  $GLOBALS['__member_info__']['profile_image'][$member_srl] = null;
892  $exts = array('gif','jpg','png');
893  for($i=0;$i<3;$i++)
894  {
895  $image_name_file = sprintf('files/member_extra_info/profile_image/%s%d.%s', getNumberingPath($member_srl), $member_srl, $exts[$i]);
896  if(file_exists($image_name_file))
897  {
898  list($width, $height, $type, $attrs) = getimagesize($image_name_file);
899  $info = new stdClass();
900  $info->width = $width;
901  $info->height = $height;
902  $info->src = Context::getRequestUri().$image_name_file . '?' . date('YmdHis', filemtime($image_name_file));
903  $info->file = './'.$image_name_file;
904  $GLOBALS['__member_info__']['profile_image'][$member_srl] = $info;
905  break;
906  }
907  }
908  }
909 
910  return $GLOBALS['__member_info__']['profile_image'][$member_srl];
911  }
912 
916  function getImageName($member_srl)
917  {
918  if(!isset($GLOBALS['__member_info__']['image_name'][$member_srl]))
919  {
920  $image_name_file = sprintf('files/member_extra_info/image_name/%s%d.gif', getNumberingPath($member_srl), $member_srl);
921  if(file_exists($image_name_file))
922  {
923  list($width, $height, $type, $attrs) = getimagesize($image_name_file);
924  $info = new stdClass;
925  $info->width = $width;
926  $info->height = $height;
927  $info->src = Context::getRequestUri().$image_name_file. '?' . date('YmdHis', filemtime($image_name_file));
928  $info->file = './'.$image_name_file;
929  $GLOBALS['__member_info__']['image_name'][$member_srl] = $info;
930  }
931  else $GLOBALS['__member_info__']['image_name'][$member_srl] = null;
932  }
933  return $GLOBALS['__member_info__']['image_name'][$member_srl];
934  }
935 
939  function getImageMark($member_srl)
940  {
941  if(!isset($GLOBALS['__member_info__']['image_mark'][$member_srl]))
942  {
943  $image_mark_file = sprintf('files/member_extra_info/image_mark/%s%d.gif', getNumberingPath($member_srl), $member_srl);
944  if(file_exists($image_mark_file))
945  {
946  list($width, $height, $type, $attrs) = getimagesize($image_mark_file);
947  $info->width = $width;
948  $info->height = $height;
949  $info->src = Context::getRequestUri().$image_mark_file . '?' . date('YmdHis', filemtime($image_mark_file));
950  $info->file = './'.$image_mark_file;
951  $GLOBALS['__member_info__']['image_mark'][$member_srl] = $info;
952  }
953  else $GLOBALS['__member_info__']['image_mark'][$member_srl] = null;
954  }
955 
956  return $GLOBALS['__member_info__']['image_mark'][$member_srl];
957  }
958 
959 
963  function getGroupImageMark($member_srl,$site_srl=0)
964  {
965  if(!isset($GLOBALS['__member_info__']['group_image_mark'][$member_srl]))
966  {
967  $oModuleModel = getModel('module');
968  $config = $oModuleModel->getModuleConfig('member');
969  if($config->group_image_mark!='Y')
970  {
971  return null;
972  }
973  $member_group = $this->getMemberGroups($member_srl,$site_srl);
974  $groups_info = $this->getGroups($site_srl);
975  if(count($member_group) > 0 && is_array($member_group))
976  {
977  $memberGroups = array_keys($member_group);
978 
979  foreach($groups_info as $group_srl=>$group_info)
980  {
981  if(in_array($group_srl, $memberGroups))
982  {
983  if($group_info->image_mark)
984  {
985  $info = new stdClass();
986  $info->title = $group_info->title;
987  $info->description = $group_info->description;
988  $info->src = $group_info->image_mark;
989  $GLOBALS['__member_info__']['group_image_mark'][$member_srl] = $info;
990  break;
991  }
992  }
993  }
994  }
995  if (!$info) $GLOBALS['__member_info__']['group_image_mark'][$member_srl] == 'N';
996  }
997  if ($GLOBALS['__member_info__']['group_image_mark'][$member_srl] == 'N') return null;
998 
999  return $GLOBALS['__member_info__']['group_image_mark'][$member_srl];
1000  }
1001 
1005  function getSignature($member_srl)
1006  {
1007  if(!isset($GLOBALS['__member_info__']['signature'][$member_srl]))
1008  {
1009  $filename = sprintf('files/member_extra_info/signature/%s%d.signature.php', getNumberingPath($member_srl), $member_srl);
1010  if(file_exists($filename))
1011  {
1012  $buff = FileHandler::readFile($filename);
1013  $signature = preg_replace('/<\?.*?\?>/', '', $buff);
1014  $GLOBALS['__member_info__']['signature'][$member_srl] = $signature;
1015  }
1016  else $GLOBALS['__member_info__']['signature'][$member_srl] = null;
1017  }
1018  return $GLOBALS['__member_info__']['signature'][$member_srl];
1019  }
1020 
1028  function isValidPassword($hashed_password, $password_text, $member_srl=null)
1029  {
1030  // False if no password in entered
1031  if(!$password_text)
1032  {
1033  return false;
1034  }
1035 
1036  // Check the password
1037  $oPassword = new Password();
1038  $current_algorithm = $oPassword->checkAlgorithm($hashed_password);
1039  $match = $oPassword->checkPassword($password_text, $hashed_password, $current_algorithm);
1040  if(!$match)
1041  {
1042  return false;
1043  }
1044 
1045  // Update the encryption method if necessary
1046  $config = $this->getMemberConfig();
1047  if($member_srl > 0 && $config->password_hashing_auto_upgrade != 'N')
1048  {
1049  $need_upgrade = false;
1050 
1051  if(!$need_upgrade)
1052  {
1053  $required_algorithm = $oPassword->getCurrentlySelectedAlgorithm();
1054  if($required_algorithm !== $current_algorithm) $need_upgrade = true;
1055  }
1056 
1057  if(!$need_upgrade)
1058  {
1059  $required_work_factor = $oPassword->getWorkFactor();
1060  $current_work_factor = $oPassword->checkWorkFactor($hashed_password);
1061  if($current_work_factor !== false && $required_work_factor > $current_work_factor) $need_upgrade = true;
1062  }
1063 
1064  if($need_upgrade === true)
1065  {
1066  $args = new stdClass();
1067  $args->member_srl = $member_srl;
1068  $args->hashed_password = $this->hashPassword($password_text, $required_algorithm);
1069  $oMemberController = getController('member');
1070  $oMemberController->updateMemberPassword($args);
1071  }
1072  }
1073 
1074  return true;
1075  }
1076 
1083  function hashPassword($password_text, $algorithm = null)
1084  {
1085  $oPassword = new Password();
1086  return $oPassword->createHash($password_text, $algorithm);
1087  }
1088 
1089  function checkPasswordStrength($password, $strength)
1090  {
1091  $logged_info = Context::get('logged_info');
1092  if($logged_info->is_admin == 'Y') return true;
1093 
1094  if($strength == NULL)
1095  {
1096  $config = $this->getMemberConfig();
1097  $strength = $config->password_strength?$config->password_strength:'normal';
1098  }
1099 
1100  $length = strlen($password);
1101 
1102  switch ($strength) {
1103  case 'high':
1104  if($length < 8 || !preg_match('/[^a-zA-Z0-9]/', $password)) return false;
1105  /* no break */
1106 
1107  case 'normal':
1108  if($length < 6 || !preg_match('/[a-zA-Z]/', $password) || !preg_match('/[0-9]/', $password)) return false;
1109  break;
1110 
1111  case 'low':
1112  if($length < 4) return false;
1113  break;
1114  }
1115 
1116  return true;
1117  }
1118 
1119  function getAdminGroupSrl($site_srl = 0)
1120  {
1121  $groupSrl = 0;
1122  $output = $this->getGroups($site_srl);
1123  if(is_array($output))
1124  {
1125  foreach($output AS $key=>$value)
1126  {
1127  if($value->is_admin == 'Y')
1128  {
1129  $groupSrl = $value->group_srl;
1130  break;
1131  }
1132  }
1133  }
1134  return $groupSrl;
1135  }
1136 }
1137 /* End of file member.model.php */
1138 /* Location: ./modules/member/member.model.php */
$oModuleModel
Definition: ko.install.php:236
getController($module_name)
Definition: func.inc.php:90
getNumberingPath($no, $size=3)
Definition: func.inc.php:1081
$obj
Definition: ko.install.php:262
getLoggedMemberSrl()
Return member_srl of the current logged-in user.
if(file_exists(_XE_PATH_. 'config/config.user.inc.php')) if(!defined('__DEBUG__')) if(!defined('__DEBUG_OUTPUT__')) if(!defined('__DEBUG_PROTECT__')) if(!defined('__DEBUG_PROTECT_IP__')) if(!defined('__DEBUG_DB_OUTPUT__')) if(!defined('__LOG_SLOW_QUERY__')) if(!defined('__LOG_SLOW_TRIGGER__')) if(!defined('__LOG_SLOW_ADDON__')) if(!defined('__LOG_SLOW_WIDGET__')) if(!defined('__DEBUG_QUERY__')) if(!defined('__OB_GZHANDLER_ENABLE__')) if(!defined('__ENABLE_PHPUNIT_TEST__')) if(!defined('__PROXY_SERVER__')) if(!defined('__ERROR_LOG__')) if(!defined('__DISABLE_DEFAULT_CSS__')) if(!defined('__AUTO_OPCACHE_INVALIDATE__')) if((__DEBUG_OUTPUT__==2)&&version_compare(PHP_VERSION, '6.0.0')===-1) if(version_compare(PHP_VERSION, '5.3.0') >=0) $GLOBALS['__xe_autoload_file_map']
Definition: config.inc.php:324
$output
Definition: ko.install.php:193
add($key, $val)
getImageName($member_srl)
Get the image name.
& getInstance($target= 'object', $info=null, $always_use_file=false)
$act
a string value to contain the action name
foreach($sitemap as $id=> &$val) $extra_vars
Definition: ko.install.php:180
set($key, $val, $set_to_get_vars=0)
getMemberMenu()
Display menus of the member.
getImageMark($member_srl)
Get the image mark.
init()
Initialization.
getMemberSrlByEmailAddress($email_address)
Get member_srl corresponding to EmailAddress.
getMemberInfoByUserID($user_id, $columnList=array())
Return member information with user_id.
getMemberSrlByUserID($user_id)
Get member_srl corresponding to userid.
getMembersGroups($member_srls, $site_srl=0)
Get a list of groups which member_srls belong to.
$join_form_list
Keep data internally which may be frequently called ...
checkPasswordStrength($password, $strength)
getJoinForm($member_join_form_srl)
Get a join form.
hashPassword($password_text, $algorithm=null)
Create a hash of plain text password.
getDeniedIDList()
Get a list of denied IDs.
getMemberConfig()
Return member&#39;s configuration.
getMemberInfoByMemberSrl($member_srl, $site_srl=0, $columnList=array())
Return member information with member_srl.
getMemberGroups($member_srl, $site_srl=0, $force_reload=false)
Get a list of groups which the member_srl belongs to.
getAdminGroup($columnList=array())
Get an admin group.
isDeniedNickName($nickName)
Verify if nick name is denied.
$args
Definition: ko.install.php:185
getMemberInfoByEmailAddress($email_address)
Return member information with email_address.
$mid
string to represent run-time instance of Module (XE Module)
arrangeMemberInfo($info, $site_srl=0)
Add member info from extra_vars and other information.
getSignature($member_srl)
Get user&#39;s signature.
isFromMobilePhone()
isLogged()
Check if logged-in.
getProfileImage($member_srl)
Get information of the profile image.
isDeniedID($user_id)
Verify if ID is denied.
getLang($code)
const _XE_PATH_
Definition: config.inc.php:49
getJoinFormList($filter_response=false)
Get a list of member join forms.
readFile($filename)
getCombineJoinForm($member_info)
Combine extend join form and member information (used to modify member information) ...
getGroup($group_srl, $columnList=array())
Get group info corresponding to group_srl.
getRequestUri($ssl_mode=FOLLOW_REQUEST_SSL, $domain=null)
getDefaultGroup($site_srl=0, $columnList=array())
Get a default group.
getLoggedInfo()
Return session information of the logged-in user.
getModel($module_name)
Definition: func.inc.php:145
loadLangSelected()
getGroups($site_srl=0)
Get a list of groups.
getMemberSrlByNickName($nick_name)
Get member_srl corresponding to nickname.
executeQueryArray($query_id, $args=NULL, $arg_columns=NULL)
Definition: func.inc.php:219
getAdminGroupSrl($site_srl=0)
getGroupImageMark($member_srl, $site_srl=0)
Get the image mark of the group.
getAdminController($module_name)
Definition: func.inc.php:101
isValidPassword($hashed_password, $password_text, $member_srl=null)
Compare plain text password to the password saved in DB.
getLoggedUserID()
Return user_id of the current logged-in user.
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
Definition: func.inc.php:203
getUrl()
Definition: func.inc.php:297
Model class of the member module.
Definition: member.model.php:8
triggerCall($trigger_name, $called_position, &$obj)
if(isset($_REQUEST['encode'])) if(isset($_REQUEST['decode'])) $lang
Definition: example.php:23