Просмотр исходного кода

#4908 Subgroups
- Allow posting groups in groups (optionally)
- Option to allow only parent group(space, event, etc) members to join
- Hide privacy field when context is passed via 'context' get param

Alex Trofimov 1 год назад
Родитель
Сommit
84cabebc99

+ 1 - 0
install/sql/system.sql

@@ -535,6 +535,7 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `info`, `value`, `ty
 (@iCategoryId, 'sys_enable_post_to_context_for_privacy', '_adm_stg_cpt_option_sys_enable_post_to_context_for_privacy', '', '', 'checkbox', '', '', '', 50),
 (@iCategoryId, 'sys_hide_post_to_context_for_privacy', '_adm_stg_cpt_option_sys_hide_post_to_context_for_privacy', '', '', 'list', 'a:3:{s:6:"module";s:6:"system";s:6:"method";s:44:"get_options_module_list_for_privacy_selector";s:5:"class";s:13:"TemplServices";}', '', '', 51),
 (@iCategoryId, 'sys_treat_cxt_in_cxt_as_cnt', '_adm_stg_cpt_option_sys_treat_cxt_in_cxt_as_cnt', '', 'on', 'checkbox', '', '', '', 52),
+(@iCategoryId, 'sys_check_fan_in_parent_context', '_adm_stg_cpt_option_sys_check_fan_in_parent_context', '', 'on', 'checkbox', '', '', '', 55),
 
 (@iCategoryId, 'sys_vote_reactions_quick_mode', '_adm_stg_cpt_option_sys_vote_reactions_quick_mode', '', 'on', 'checkbox', '', '', '', 60),
 

+ 5 - 0
modules/base/general/classes/BxBaseModGeneralFormEntry.php

@@ -980,6 +980,11 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
             'display' => $this->aParams['display']
         ));
 
+        if (bx_get('context') && isset($aGroupChooser['values']) && isset($aGroupChooser['values'][bx_get('context')])) {
+            $aSave['type'] = 'hidden';
+            $aSave['value'] = -bx_get('context');
+        }
+
         $this->aInputs[$sField] = array_merge($this->aInputs[$sField], $aGroupChooser, $aSave);
     }
 

+ 8 - 0
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -2003,6 +2003,14 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
 
         $oPrivacy = BxDolPrivacy::getObjectInstance($this->_oConfig->CNF['OBJECT_PRIVACY_VIEW']);
 
+        // when context is in another context
+        if ($aDataEntry[$this->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']] < 0 && getParam('sys_check_fan_in_parent_context')) {
+            $oParent = BxDolProfile::getInstance(abs($aDataEntry[$this->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']]));
+            $oModule = $oParent ? BxDolModule::getInstance($oParent->getModule()) : null;
+            if ($oModule && method_exists($oModule, 'isFan') && !$oModule->isFan($oParent->getContentId()))
+                return _t('_sys_txt_access_denied');
+        }
+
         // if profile view isn't allowed but visibility is in partially visible groups 
         // then display buttons to connect (befriend, join) to profile, 
         // if other conditions (in parent::_checkAllowedConnect) are met as well

+ 1 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -1765,6 +1765,7 @@
     <string name="_adm_stg_cpt_option_sys_enable_post_to_context_for_privacy"><![CDATA[Allow to post to context using Privacy field]]></string>
     <string name="_adm_stg_cpt_option_sys_hide_post_to_context_for_privacy"><![CDATA[Hide post to context for modules in Privacy field]]></string>
     <string name="_adm_stg_cpt_option_sys_treat_cxt_in_cxt_as_cnt"><![CDATA[Treat context posted in context as content]]></string>
+    <string name="_adm_stg_cpt_option_sys_check_fan_in_parent_context"><![CDATA[Only parent group(space, event, etc) members can join]]></string>
     <string name="_adm_stg_cpt_option_sys_search_keyword_min_len"><![CDATA[Keyword min length in site search]]></string>
     <string name="_adm_stg_cpt_option_sys_profile_bot"><![CDATA[System Bot profile]]></string>
     <string name="_adm_stg_inf_option_sys_profile_bot"><![CDATA[Choose profile which will be used as an author of system actions.]]></string>

+ 1 - 2
modules/boonex/groups/classes/BxGroupsConfig.php

@@ -165,8 +165,7 @@ class BxGroupsConfig extends BxBaseModGroupsConfig
             
             'BADGES_AVALIABLE' => true,
             'INVITES_KEYS_LIFETIME' => 86400,
-            'ENABLE_FOR_CONTEXT_IN_MODULES' => array('bx_events', 'bx_spaces'),
-
+            'ENABLE_FOR_CONTEXT_IN_MODULES' => explode(',', getParam('bx_groups_allow_in_contexts')),
             'EMAIL_INVITATION' => 'bx_groups_invitation',
             'EMAIL_JOIN_REQUEST' => 'bx_groups_join_request',
             'EMAIL_JOIN_CONFIRM' => 'bx_groups_join_confirm',

+ 1 - 0
modules/boonex/groups/install/langs/en.xml

@@ -13,6 +13,7 @@
     <string name="_bx_groups_option_per_page_for_favorites_lists"><![CDATA[Number of favorite lists per page]]></string>
     <string name="_bx_groups_option_enable_subscribe_wo_join"><![CDATA[Allow to follow without join]]></string>
     <string name="_bx_groups_option_internal_notifications"><![CDATA[Use internal notifications]]></string>
+    <string name="_bx_groups_option_allow_in_contexts"><![CDATA[Allow posting groups in the following contexts (requires additional setup)]]></string>
 
     <string name="_bx_groups_form_profile"><![CDATA[Groups]]></string>
     <string name="_bx_groups_form_profile_display_add"><![CDATA[Add Group]]></string>

+ 2 - 1
modules/boonex/groups/install/sql/enable.sql

@@ -21,7 +21,8 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `e
 ('bx_groups_searchable_fields', 'group_name,group_desc', @iCategId, '_bx_groups_option_searchable_fields', 'list', 'a:2:{s:6:"module";s:9:"bx_groups";s:6:"method";s:21:"get_searchable_fields";}', '', '', 30),
 ('bx_groups_members_mode', '', @iCategId, '_bx_groups_option_members_mode', 'select', 'a:2:{s:6:"module";s:9:"bx_groups";s:6:"method";s:24:"get_options_members_mode";}', '', '', 40),
 ('bx_groups_enable_subscribe_wo_join', '', @iCategId, '_bx_groups_option_enable_subscribe_wo_join', 'checkbox', '', '', '', 45),
-('bx_groups_internal_notifications', '', @iCategId, '_bx_groups_option_internal_notifications', 'checkbox', '', '', '', 50);
+('bx_groups_internal_notifications', '', @iCategId, '_bx_groups_option_internal_notifications', 'checkbox', '', '', '', 50),
+('bx_groups_allow_in_contexts', 'bx_events,bx_spaces', @iCategId, '_bx_groups_option_allow_in_contexts', 'list', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:29:"get_modules_by_subtype_simple";s:6:"params";a:1:{i:0;s:7:"context";}s:5:"class";s:13:"TemplServices";}', '', '', 60);
 
 -- PAGES
 

+ 1 - 0
modules/boonex/russian/data/langs/bx_groups/ru.xml

@@ -13,6 +13,7 @@
     <string name="_bx_groups_option_enable_subscribe_wo_join"><![CDATA[Разрешить подписываться не членам группы]]></string>
     <string name="_bx_groups_option_per_page_for_favorites_lists"><![CDATA[Количество списков избранного на странице]]></string>
     <string name="_bx_groups_option_internal_notifications"><![CDATA[Использовать встроенную нотификацию]]></string>
+    <string name="_bx_groups_option_allow_in_contexts"><![CDATA[Разрешить публиковать группы в контекстах (требует дополнительной настройки)]]></string>
 
     <string name="_bx_groups_form_profile"><![CDATA[Группы]]></string>
     <string name="_bx_groups_form_profile_display_add"><![CDATA[Добавление группы]]></string>

+ 1 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -1741,6 +1741,7 @@
     <string name="_adm_stg_cpt_option_sys_enable_post_to_context_for_privacy"><![CDATA[Включить возможность добавления контента в контекст, используя поле "Конфиденциальность"]]></string>
     <string name="_adm_stg_cpt_option_sys_hide_post_to_context_for_privacy"><![CDATA[Скрыть из поля "Конфиденциальность" возможность добавления контента в контекст модулей]]></string>
     <string name="_adm_stg_cpt_option_sys_treat_cxt_in_cxt_as_cnt"><![CDATA[Рассматривать контекст, размещенный в контексте, как контент]]></string>
+    <string name="_adm_stg_cpt_option_sys_check_fan_in_parent_context"><![CDATA[Только для участников родительской группы (события, курса и т.п.)]]></string>
     <string name="_adm_stg_cpt_option_sys_search_keyword_min_len"><![CDATA[Минимальная длина слова в поиске по сайту]]></string>
     <string name="_adm_stg_cpt_option_sys_profile_bot"><![CDATA[Профиль системного бота]]></string>
     <string name="_adm_stg_inf_option_sys_profile_bot"><![CDATA[Выберите профиль, который будет использоваться в качестве автора системных действий.]]></string>

+ 8 - 0
template/scripts/BxBaseServices.php

@@ -540,6 +540,14 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
         return $aResults;
     }
 
+    public function serviceGetModulesBySubtypeSimple($sType)
+    {
+        $a = $this->serviceGetModulesByType($sType, ['name_as_key' => true]);
+        return array_map(function ($r) {
+            return $r['title'];
+        }, $a);
+    }
+
     public function serviceProfileUnit ($iContentId, $aParams = array())
     {
         return $this->_serviceProfileFunc('getUnit', $iContentId, $aParams);