diff --git a/modules/member/member.admin.controller.php b/modules/member/member.admin.controller.php index 278f58f23..ab11219b7 100644 --- a/modules/member/member.admin.controller.php +++ b/modules/member/member.admin.controller.php @@ -359,9 +359,9 @@ class memberAdminController extends member 'emailhost_check', 'special_phone_number', 'special_phone_code', 'redirect_url', 'phone_number_default_country', 'phone_number_hide_country', 'phone_number_allow_duplicate', 'phone_number_verify_by_sms', - 'profile_image', 'profile_image_max_width', 'profile_image_max_height', 'profile_image_max_filesize', - 'image_name', 'image_name_max_width', 'image_name_max_height', 'image_name_max_filesize', - 'image_mark', 'image_mark_max_width', 'image_mark_max_height', 'image_mark_max_filesize', + 'profile_image_max_width', 'profile_image_max_height', 'profile_image_max_filesize', + 'image_name_max_width', 'image_name_max_height', 'image_name_max_filesize', + 'image_mark_max_width', 'image_mark_max_height', 'image_mark_max_filesize', 'signature_editor_skin', 'sel_editor_colorset', 'signature_html', 'signature_html_retroact', 'member_allow_fileupload' ); @@ -405,14 +405,8 @@ class memberAdminController extends member return new BaseObject('-1', 'msg_need_default_country'); } - $args->profile_image = $args->profile_image ? 'Y' : 'N'; - $args->image_name = $args->image_name ? 'Y' : 'N'; - $args->image_mark = $args->image_mark ? 'Y' : 'N'; - $args->signature = $args->signature != 'Y' ? 'N' : 'Y'; - // set default $all_args->is_nick_name_public = 'Y'; - $all_args->is_find_account_question_public = 'N'; // signupForm global $lang; @@ -451,7 +445,11 @@ class memberAdminController extends member $signupItem->required = ($all_args->{$key} == 'required') || $signupItem->mustRequired; $signupItem->isUse = in_array($key, $usable_list) || $signupItem->required; $signupItem->isPublic = ($all_args->{'is_'.$key.'_public'} == 'Y' && $signupItem->isUse) ? 'Y' : 'N'; - + + if(in_array($key, ['signature', 'profile_image', 'image_name', 'image_mark'])) + { + $args->$key = $signupItem->isPublic; + } if($signupItem->imageType) { $signupItem->max_width = $all_args->{$key.'_max_width'}; diff --git a/modules/member/member.class.php b/modules/member/member.class.php index 059554eeb..b1a955481 100644 --- a/modules/member/member.class.php +++ b/modules/member/member.class.php @@ -30,61 +30,19 @@ class member extends ModuleObject */ function moduleInstall() { - // Register action forward (to use in administrator mode) $oModuleController = getController('module'); $config = ModuleModel::getModuleConfig('member'); - - if(empty($config)) - { - $isNotInstall = true; - $config = new stdClass; - } - - // Set the basic information - $config->enable_join = 'Y'; - $config->enable_openid = 'N'; - if(!$config->enable_auth_mail) $config->enable_auth_mail = 'N'; - if(!$config->image_name) $config->image_name = 'Y'; - if(!$config->image_mark) $config->image_mark = 'Y'; - if(!$config->profile_image) $config->profile_image = 'Y'; - if(!$config->image_name_max_width) $config->image_name_max_width = '90'; - if(!$config->image_name_max_height) $config->image_name_max_height = '20'; - if(!$config->image_mark_max_width) $config->image_mark_max_width = '20'; - if(!$config->image_mark_max_height) $config->image_mark_max_height = '20'; - if(!$config->profile_image_max_width) $config->profile_image_max_width = '90'; - if(!$config->profile_image_max_height) $config->profile_image_max_height = '90'; - if($config->group_image_mark!='Y') $config->group_image_mark = 'N'; - if(!$config->authmail_expires) $config->authmail_expires = 3; - if(!$config->authmail_expires_unit) $config->authmail_expires_unit = 86400; - if(!$config->password_strength) $config->password_strength = 'normal'; - if(!$config->password_hashing_algorithm) + // Set default config + if(!$config) { - $config->password_hashing_algorithm = Rhymix\Framework\Password::getBestSupportedAlgorithm(); - } - if(!$config->password_hashing_work_factor) - { - $config->password_hashing_work_factor = 10; - } - if(!$config->password_hashing_auto_upgrade) - { - $config->password_hashing_auto_upgrade = 'Y'; + $config = MemberModel::getMemberConfig(); + $oModuleController->insertModuleConfig('member', $config); } - global $lang; $oMemberModel = getModel('member'); - // Create a member controller object $oMemberController = getController('member'); $oMemberAdminController = getAdminController('member'); - - if(!$config->signupForm || !is_array($config->signupForm)) - { - $identifier = 'user_id'; - $config->signupForm = $oMemberAdminController->createSignupForm($identifier); - $config->identifier = $identifier; - } - $oModuleController->insertModuleConfig('member',$config); - $groups = $oMemberModel->getGroups(); if(!count($groups)) { diff --git a/modules/member/member.controller.php b/modules/member/member.controller.php index 61b9c1eae..206a23cdf 100644 --- a/modules/member/member.controller.php +++ b/modules/member/member.controller.php @@ -2093,36 +2093,12 @@ class memberController extends member /** * Save the member configurations * - * @param object $args - * + * @deprecated * @return void */ function setMemberConfig($args) { - if(!$args->skin) $args->skin = "default"; - if(!$args->colorset) $args->colorset = "white"; - if(!$args->editor_skin) $args->editor_skin= "ckeditor"; - if(!$args->editor_colorset) $args->editor_colorset = "moono-lisa"; - if($args->enable_join!='Y') $args->enable_join = 'N'; - $args->enable_openid= 'N'; - if($args->profile_image !='Y') $args->profile_image = 'N'; - if($args->image_name!='Y') $args->image_name = 'N'; - if($args->image_mark!='Y') $args->image_mark = 'N'; - if($args->group_image_mark!='Y') $args->group_image_mark = 'N'; - if(!trim(strip_tags($args->agreement))) $args->agreement = null; - $args->limit_day = (int)$args->limit_day; - - $agreement = trim($args->agreement); - unset($args->agreement); - - $oModuleController = getController('module'); - $output = $oModuleController->insertModuleConfig('member',$args); - if(!$output->toBool()) return $output; - - $agreement_file = RX_BASEDIR.'files/member_extra_info/agreement.txt'; - FileHandler::writeFile($agreement_file, $agreement); - - return new BaseObject(); + return getController('module')->updateModuleConfig('member', $args); } /** diff --git a/modules/member/member.model.php b/modules/member/member.model.php index f3e90059f..2be062586 100644 --- a/modules/member/member.model.php +++ b/modules/member/member.model.php @@ -32,71 +32,113 @@ class memberModel extends member { return self::$_member_config; } - - // Get member configuration stored in the DB + $config = ModuleModel::getModuleConfig('member') ?: new stdClass; - - if(!isset($config->signupForm) || !is_array($config->signupForm)) + + // Set default config + $config->enable_join = $config->enable_join ?? 'Y'; + $config->enable_confirm = $config->enable_confirm ?? 'N'; + $config->authmail_expires = $config->authmail_expires ?? 1; + $config->authmail_expires_unit = $config->authmail_expires_unit ?? 86400; + $config->member_profile_view = $config->member_profile_view ?? 'N'; + $config->update_nickname_log = $config->update_nickname_log ?? 'N'; + $config->nickname_symbols = $config->nickname_symbols ?? 'Y'; + $config->nickname_symbols_allowed_list = $config->nickname_symbols_allowed_list ?? ''; + $config->password_strength = $config->password_strength ?? 'normal'; + $config->password_hashing_algorithm = $config->password_hashing_algorithm ?? Rhymix\Framework\Password::getBestSupportedAlgorithm(); + $config->password_hashing_work_factor = $config->password_hashing_work_factor ?? 10; + $config->password_hashing_auto_upgrade = $config->password_hashing_auto_upgrade ?? 'Y'; + $config->password_change_invalidate_other_sessions = $config->password_change_invalidate_other_sessions ?? 'N'; + + // Set features config + $config->features = array(); + $config->features['scrapped_documents'] = $config->features['scrapped_documents'] ?? true; + $config->features['saved_documents'] = $config->features['saved_documents'] ?? true; + $config->features['my_documents'] = $config->features['my_documents'] ?? true; + $config->features['my_comments'] = $config->features['my_comments'] ?? true; + $config->features['active_logins'] = $config->features['active_logins'] ?? true; + $config->features['nickname_log'] = $config->features['nickname_log'] ?? true; + + // Set agreements config + $config->agreement = self::_getAgreement(); + if(!isset($config->agreements)) { - $oMemberAdminController = getAdminController('member'); - $identifier = ($config->identifier) ? $config->identifier : 'email_address'; - $config->signupForm = $oMemberAdminController->createSignupForm($identifier); - } - //for multi language - foreach($config->signupForm AS $key=>$value) - { - if(!isset($value->isCustomTitle) || !$value->isCustomTitle) - { - $config->signupForm[$key]->title = ($value->isDefaultForm ?? false) ? lang($value->name) : $value->title; - } - if($config->signupForm[$key]->isPublic != 'N') $config->signupForm[$key]->isPublic = 'Y'; - if($value->name == 'find_account_question') $config->signupForm[$key]->isPublic = 'N'; - } - - // Get terms of user - if(!$config->agreements) - { - $config->agreement = self::_getAgreement(); + $config->agreements = array(); $config->agreements[1] = new stdClass; $config->agreements[1]->title = lang('agreement'); $config->agreements[1]->content = $config->agreement; $config->agreements[1]->type = $config->agreement ? 'required' : 'disabled'; } - - if(!$config->webmaster_name) $config->webmaster_name = 'webmaster'; - - if(!$config->image_name_max_width) $config->image_name_max_width = 90; - if(!$config->image_name_max_height) $config->image_name_max_height = 20; - if(!$config->image_name_max_filesize) $config->image_name_max_filesize = null; - if(!$config->image_mark_max_width) $config->image_mark_max_width = 20; - if(!$config->image_mark_max_height) $config->image_mark_max_height = 20; - if(!$config->image_mark_max_filesize) $config->image_mark_max_filesize = null; - if(!$config->profile_image_max_width) $config->profile_image_max_width = 90; - if(!$config->profile_image_max_height) $config->profile_image_max_height = 90; - if(!$config->profile_image_max_filesize) $config->profile_image_max_filesize = null; - - if(!$config->skin) $config->skin = 'default'; - if(!$config->colorset) $config->colorset = 'white'; - if(!$config->editor_skin || $config->editor_skin == 'default') $config->editor_skin = 'ckeditor'; - if(!$config->group_image_mark) $config->group_image_mark = "N"; - - if(!$config->identifier) $config->identifier = 'user_id'; - - if(!$config->emailhost_check) $config->emailhost_check = 'allowed'; - - if(!$config->max_error_count) $config->max_error_count = 10; - if(!$config->max_error_count_time) $config->max_error_count_time = 300; - - if(!$config->signature_editor_skin || $config->signature_editor_skin == 'default') $config->signature_editor_skin = 'ckeditor'; - if(!$config->sel_editor_colorset) $config->sel_editor_colorset = 'moono-lisa'; - if(!$config->member_allow_fileupload) $config->member_allow_fileupload = 'N'; - if(!$config->member_profile_view) $config->member_profile_view = 'N'; - - if(isset($config->redirect_mid) && $config->redirect_mid) + + // Set signup config + $config->limit_day = $config->limit_day ?? 0; + $config->emailhost_check = $config->emailhost_check ?? 'allowed'; + $config->special_phone_number = $config->special_phone_number ?? null; + $config->special_phone_code = $config->special_phone_code ?? null; + $config->redirect_mid = $config->redirect_mid ?? null; + $config->redirect_url = $config->redirect_mid ? getNotEncodedFullUrl('', 'mid', $config->redirect_mid) : null; + $config->phone_number_default_country = $config->phone_number_default_country ?? (Context::get('lang_type') === 'ko' ? 'KOR' : null); + $config->phone_number_hide_country = $config->phone_number_hide_country ?? 'N'; + $config->phone_number_allow_duplicate = $config->phone_number_allow_duplicate ?? 'N'; + $config->phone_number_verify_by_sms = $config->phone_number_verify_by_sms ?? 'N'; + $config->signature_editor_skin = $config->signature_editor_skin ?? 'ckeditor'; + $config->sel_editor_colorset = $config->sel_editor_colorset ?? 'moono-lisa'; + $config->signature = $config->signature ?? 'N'; + $config->signature_html = $config->signature_html ?? 'Y'; + $config->signature_html_retroact = $config->signature_html_retroact ?? 'N'; + $config->member_allow_fileupload = $config->member_allow_fileupload ?? 'N'; + $config->profile_image = $config->profile_image ?? 'N'; + $config->profile_image_max_width = $config->profile_image_max_width ?? 90; + $config->profile_image_max_height = $config->profile_image_max_height ?? 90; + $config->profile_image_max_filesize = $config->profile_image_max_filesize ?? null; + $config->image_name = $config->image_name ?? 'N'; + $config->image_name_max_width = $config->image_name_max_width ?? 90; + $config->image_name_max_height = $config->image_name_max_height ?? 20; + $config->image_name_max_filesize = $config->image_name_max_filesize ?? null; + $config->image_mark = $config->image_mark ?? 'N'; + $config->image_mark_max_width = $config->image_mark_max_width ?? 20; + $config->image_mark_max_height = $config->image_mark_max_height ?? 20; + $config->image_mark_max_filesize = $config->image_mark_max_filesize ?? null; + if($config->signature_editor_skin === 'default') { - $config->redirect_url = getNotEncodedFullUrl('','mid',$config->redirect_mid); + $config->signature_editor_skin = 'ckeditor'; } - + + // Set login config + $config->identifier = $config->identifier ?? 'user_id'; + $config->identifiers = $config->identifiers ?? array('user_id'); + $config->change_password_date = $config->change_password_date ?? 0; + $config->enable_login_fail_report = $config->enable_login_fail_report ?? 'Y'; + $config->max_error_count = $config->max_error_count ?? 10; + $config->max_error_count_time = $config->max_error_count_time ?? 300; + $config->login_invalidate_other_sessions = $config->login_invalidate_other_sessions ?? 'N'; + $config->after_login_url = $config->after_login_url ?? null; + $config->after_logout_url = $config->after_logout_url ?? null; + + // Set design config + $config->layout_srl = $config->layout_srl ?? 0; + $config->skin = $config->skin ?? 'default'; + $config->colorset = $config->colorset ?? 'white'; + $config->mlayout_srl = $config->mlayout_srl ?? 0; + $config->mskin = $config->mskin ?? 'default'; + + // Set group image config + $config->group_image_mark = $config->group_image_mark ?? 'N'; + + // Set signup form + if(!isset($config->signupForm) || !is_array($config->signupForm)) + { + $config->signupForm = getAdminController('member')->createSignupForm($config->identifier); + } + foreach($config->signupForm as $key => $value) + { + if($value->isDefaultForm && empty($value->isCustomTitle)) + { + $config->signupForm[$key]->title = lang($value->name); + } + $config->signupForm[$key]->isPublic = $config->signupForm[$key]->isPublic ?? 'Y'; + } + return self::$_member_config = $config; } diff --git a/widgets/login_info/login_info.class.php b/widgets/login_info/login_info.class.php index 5bfb6156d..5c26ec5c0 100644 --- a/widgets/login_info/login_info.class.php +++ b/widgets/login_info/login_info.class.php @@ -25,22 +25,20 @@ class login_info extends WidgetHandler Context::set('colorset', $args->colorset); $is_logged = Context::get('is_logged'); - $oMemberModel = getModel('member'); - $memberConfig = $oMemberModel->getMemberConfig(); - + $member_config = MemberModel::getMemberConfig(); $oNcenterliteModel = getModel('ncenterlite'); $ncenter_config = $oNcenterliteModel->getConfig(); if($is_logged) { - if(!empty($ncenter_config->use) && $args->ncenter_use == 'yes') + if($args->ncenter_use === 'yes') { $logged_info = Context::get('logged_info'); $ncenter_list = $oNcenterliteModel->getMyNotifyList($logged_info->member_srl); $_latest_notify_id = $ncenter_list->data ? array_slice($ncenter_list->data, 0, 1) : []; $_latest_notify_id = isset($_latest_notify_id[0]) ? $_latest_notify_id[0]->notify : null; - if($memberConfig->profile_image == 'Y') + if($member_config->profile_image == 'Y') { - $profileImage = $oMemberModel->getProfileImage($logged_info->member_srl); + $profileImage = MemberModel::getProfileImage($logged_info->member_srl); Context::set('profileImage', $profileImage); } Context::set('ncenterlite_latest_notify_id', $_latest_notify_id); @@ -49,6 +47,10 @@ class login_info extends WidgetHandler return; } setcookie('_ncenterlite_hide_id', '', 0, '/'); + if($ncenter_config->zindex) + { + Context::set('ncenterlite_zindex', ' style="z-index:' . $ncenter_config->zindex . ';" '); + } Context::set('ncenterlite_list', $ncenter_list->data); Context::set('ncenterlite_page_navigation', $ncenter_list->page_navigation); Context::set('_ncenterlite_num', $ncenter_list->page_navigation->total_count); @@ -60,14 +62,8 @@ class login_info extends WidgetHandler $tpl_file = 'login_form'; } // Get the member configuration - $oModuleModel = getModel('module'); - $this->member_config = $oModuleModel->getModuleConfig('member'); - if($ncenter_config->zindex) - { - Context::set('ncenterlite_zindex', ' style="z-index:' . $ncenter_config->zindex . ';" '); - } - Context::set('useProfileImage', ($memberConfig->profile_image == 'Y') ? true : false); - Context::set('member_config', $this->member_config); + Context::set('useProfileImage', ($member_config->profile_image == 'Y') ? true : false); + Context::set('member_config', $member_config); // Set a flag to check if the https connection is made when using SSL and create https url $ssl_mode = false;