From dafbfadc93e818f822502c7ffd9ec137be3fa218 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 2 Mar 2017 17:47:50 +0900 Subject: [PATCH] Add option to keep existing group when point is reduced #610 --- modules/point/lang/en.php | 8 ++++++-- modules/point/lang/ko.php | 8 ++++++-- modules/point/point.admin.controller.php | 1 + modules/point/point.class.php | 2 ++ modules/point/point.controller.php | 18 +++++++++++++----- modules/point/tpl/config.html | 22 +++++++++++++++++----- 6 files changed, 45 insertions(+), 14 deletions(-) diff --git a/modules/point/lang/en.php b/modules/point/lang/en.php index cc2b61ecc..900a4a486 100644 --- a/modules/point/lang/en.php +++ b/modules/point/lang/en.php @@ -25,8 +25,12 @@ $lang->cmd_point_recal = 'Reset Point'; $lang->about_cmd_point_recal = 'All point will be initialized only with articles/comments/attachments/join points. Only members who do website activities will get signup points after reset. Please use this function when complete initialization is required in case of data transferring or other situations.'; $lang->default_group = 'Default Group'; $lang->point_link_group = 'Group Change by Level'; -$lang->point_group_reset_and_add = 'Reset adjusted groups and add new groups'; -$lang->point_group_add_only = 'Only to new groups'; +$lang->point_group_reset_type = 'Change Type'; +$lang->point_group_reset_and_add = 'Remove from other groups and add new group'; +$lang->point_group_add_only = 'Keep other groups and add new group'; +$lang->point_group_ratchet = 'Change on Point Reduction'; +$lang->point_group_ratchet_yes = 'Maintain current group if point is reduced'; +$lang->point_group_ratchet_no = 'Move to lower group if point is reduced'; $lang->about_point_link_group = 'If you specify level for a specific group, users are assigned into the group when they advance to the level by getting points.'; $lang->about_module_point = 'You can set point for each module, and modules which don\'t have any value will use the default point. All points will be restored on acting reverse.'; $lang->point_signup = 'Sign up'; diff --git a/modules/point/lang/ko.php b/modules/point/lang/ko.php index a64c2163f..4b26c5b77 100644 --- a/modules/point/lang/ko.php +++ b/modules/point/lang/ko.php @@ -25,8 +25,12 @@ $lang->cmd_point_recal = '포인트 초기화'; $lang->about_cmd_point_recal = '게시글/댓글/첨부파일/회원가입 점수만 이용하여 모든 포인트 점수를 초기화합니다. 회원 가입 점수는 초기화 후 해당 회원이 활동을 하면 부여되고 그 전에는 부여되지 않습니다. 데이터 이전 등을 하여 포인트를 완전히 초기화해야 할 경우에만 사용하세요.'; $lang->default_group = '기본 그룹'; $lang->point_link_group = '그룹 연동'; -$lang->point_group_reset_and_add = '설정된 그룹 초기화 후 새 그룹 부여'; -$lang->point_group_add_only = '새 그룹만 부여'; +$lang->point_group_reset_type = '그룹 연동 방식'; +$lang->point_group_reset_and_add = '예전 그룹을 제거하고 새 그룹을 추가'; +$lang->point_group_add_only = '예전 그룹을 유지하며 새 그룹을 추가'; +$lang->point_group_ratchet = '포인트 감소 처리 방식'; +$lang->point_group_ratchet_yes = '포인트가 감소하더라도 기존 그룹을 유지'; +$lang->point_group_ratchet_no = '포인트가 감소하면 하위 그룹으로 이동'; $lang->about_point_link_group = '그룹에 원하는 레벨을 지정하면, 회원의 포인트가 해당 레벨의 포인트에 도달할 때 그룹이 변경됩니다.'; $lang->about_module_point = '모듈별 포인트를 지정할 수 있으며 지정되지 않은 모듈은 기본 포인트를 이용합니다. 모든 점수는 반대 행동을 하였을 경우 원상복구 됩니다.'; $lang->point_signup = '가입'; diff --git a/modules/point/point.admin.controller.php b/modules/point/point.admin.controller.php index 59f5c825f..73fd1c6af 100644 --- a/modules/point/point.admin.controller.php +++ b/modules/point/point.admin.controller.php @@ -99,6 +99,7 @@ class pointAdminController extends point } $config->group_reset = $args->group_reset; + $config->group_ratchet = $args->group_ratchet; // Per-level point configurations unset($config->level_step); for($i=1;$i<=$config->max_level;$i++) diff --git a/modules/point/point.class.php b/modules/point/point.class.php index c53d835fa..4c2570b45 100644 --- a/modules/point/point.class.php +++ b/modules/point/point.class.php @@ -129,6 +129,8 @@ class point extends ModuleObject $config->level_icon = 'default'; $config->disable_read_document = 'N'; $config->disable_download = 'N'; + $config->group_reset = 'Y'; + $config->group_ratchet = 'N'; $config->max_level = 30; for ($i = 1; $i <= 30; $i++) { diff --git a/modules/point/point.controller.php b/modules/point/point.controller.php index 51f6cacdb..84597c076 100644 --- a/modules/point/point.controller.php +++ b/modules/point/point.controller.php @@ -585,7 +585,18 @@ class pointController extends point $level = $oPointModel->getLevel($point, $config->level_step); // If existing level and a new one are different attempt to set a point group - if($level != $current_level) + $new_group_list = array(); + $del_group_list = array(); + if ($config->group_ratchet === 'Y') + { + $change_group = ($level > $current_level); + } + else + { + $change_group = ($level != $current_level); + } + + if ($change_group) { // Check if the level, for which the current points are prepared, is calculate and set the correct group $point_group = $config->point_group; @@ -594,11 +605,8 @@ class pointController extends point { // Get the default group $default_group = $oMemberModel->getDefaultGroup(); - // Get the removed group and the newly granted group - $del_group_list = array(); - $new_group_list = array(); - asort($point_group); + // Reset group after initialization if($config->group_reset != 'N') { diff --git a/modules/point/tpl/config.html b/modules/point/tpl/config.html index 5d6720d87..3c831e9d4 100644 --- a/modules/point/tpl/config.html +++ b/modules/point/tpl/config.html @@ -105,11 +105,23 @@

{$lang->point_link_group}

-
-

{$lang->about_point_link_group}

-
- - +

{$lang->about_point_link_group}

+
+ +
+ +
+
+
+ +
+