فهرست منبع

#281 Groups: privacy

Alex Trofimov 10 سال پیش
والد
کامیت
f661ea7988

+ 9 - 1
modules/base/general/classes/BxBaseModGeneralFormsEntryHelper.php

@@ -221,7 +221,7 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
             return MsgBox(_t('_sys_txt_error_entry_is_not_defined'));
 
         // check access
-        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($aContentInfo)))
+        if ($sMsg = $this->_processPermissionsCheckForViewDataForm ($aContentInfo, $oProfile))
             return MsgBox($sMsg);
 
         // get form
@@ -243,6 +243,14 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
         return $oForm->getCode();
     }
 
+    protected function _processPermissionsCheckForViewDataForm ($aContentInfo, $oProfile)
+    {
+        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($aContentInfo)))
+            return $sMsg;
+
+        return '';
+    }
+
     public function onDataDeleteAfter ($iContentId, $aContentInfo, $oProfile)
     {
         return '';

+ 11 - 6
modules/base/general/classes/BxBaseModGeneralPageEntry.php

@@ -23,8 +23,8 @@ class BxBaseModGeneralPageEntry extends BxTemplPage
 
     public function __construct($aObject, $oTemplate = false)
     {
-        parent::__construct($aObject, $oTemplate);
         $this->_oModule = BxDolModule::getInstance($this->MODULE);
+        parent::__construct($aObject, $oTemplate ? $oTemplate : $this->_oModule->_oTemplate);
     }
 
     public function getCode ()
@@ -36,11 +36,7 @@ class BxBaseModGeneralPageEntry extends BxTemplPage
         }
 
         // permissions check 
-        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($this->_aContentInfo))) {
-            $this->_oTemplate->displayAccessDenied($sMsg);
-            exit;
-        }
-        $this->_oModule->checkAllowedView($this->_aContentInfo, true);
+        $this->_processPermissionsCheck ();
 
         // count views
         $CNF = &$this->_oModule->_oConfig->CNF;
@@ -76,6 +72,15 @@ class BxBaseModGeneralPageEntry extends BxTemplPage
         return parent::getCode ();
     }
 
+    protected function _processPermissionsCheck ()
+    {
+        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($this->_aContentInfo))) {
+            $this->_oTemplate->displayAccessDenied($sMsg);
+            exit;
+        }
+        $this->_oModule->checkAllowedView($this->_aContentInfo, true);
+    }
+
     protected function _getThumbForMetaObject ()
     {
         $CNF = &$this->_oModule->_oConfig->CNF;

+ 4 - 0
modules/boonex/groups/classes/BxGroupsConfig.php

@@ -46,6 +46,7 @@ class BxGroupsConfig extends BxBaseModProfileConfig
             'FIELD_PICTURE_PREVIEW' => 'picture_preview',
             'FIELD_COVER' => 'cover',
             'FIELD_COVER_PREVIEW' => 'cover_preview',
+            'FIELD_ALLOW_VIEW_TO' => 'allow_view_to',
             'FIELDS_QUICK_SEARCH' => array('group_name'),
             'FIELDS_WITH_KEYWORDS' => 'auto', // can be 'auto', array of fields or comma separated string of field names, works only when OBJECT_METATAGS is specified
 
@@ -87,8 +88,11 @@ class BxGroupsConfig extends BxBaseModProfileConfig
             'OBJECT_MENU_SUBMENU_VIEW_ENTRY_MAIN_SELECTION' => 'groups-home', // first item in view entry submenu from main module submenu
             'OBJECT_MENU_MANAGE_TOOLS' => 'bx_groups_menu_manage_tools', //manage menu in content administration tools
             'OBJECT_PAGE_VIEW_ENTRY' => 'bx_groups_view_profile',
+            'OBJECT_PRIVACY_VIEW' => 'bx_groups_allow_view_to',
             'OBJECT_GRID_ADMINISTRATION' => 'bx_groups_administration',
         	'OBJECT_GRID_COMMON' => 'bx_groups_common',
+            'OBJECT_GRID_CONNECTIONS' => 'bx_groups_fans',
+            'OBJECT_CONNECTIONS' => 'bx_groups_fans',
 
             'TRIGGER_MENU_PROFILE_VIEW_SUBMENU' => 'trigger_group_view_submenu',
             'TRIGGER_MENU_PROFILE_VIEW_ACTIONS' => '',

+ 8 - 0
modules/boonex/groups/classes/BxGroupsFormEntry.php

@@ -18,6 +18,14 @@ class BxGroupsFormEntry extends BxBaseModProfileFormEntry
     {
         $this->MODULE = 'bx_groups';
         parent::__construct($aInfo, $oTemplate);
+
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+		if(isset($this->aInputs[$CNF['FIELD_ALLOW_VIEW_TO']])) {
+            bx_import('Privacy', $this->MODULE);
+			$this->aInputs[$CNF['FIELD_ALLOW_VIEW_TO']] = BxGroupsPrivacy::getGroupChooser($CNF['OBJECT_PRIVACY_VIEW']);
+			$this->aInputs[$CNF['FIELD_ALLOW_VIEW_TO']]['db']['pass'] = 'Xss';
+		}
     }
 }
 

+ 9 - 0
modules/boonex/groups/classes/BxGroupsFormsEntryHelper.php

@@ -18,6 +18,15 @@ class BxGroupsFormsEntryHelper extends BxBaseModProfileFormsEntryHelper
     {
         parent::__construct($oModule);
     }
+
+    protected function _processPermissionsCheckForViewDataForm ($aContentInfo, $oProfile)
+    {
+        $sMsg = parent::_processPermissionsCheckForViewDataForm ($aContentInfo, $oProfile);
+        if ($sMsg && 'c' == $aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']])
+            return '';
+
+        return $sMsg;
+    }
 }
 
 /** @} */

+ 2 - 2
modules/boonex/groups/classes/BxGroupsGridConnections.php

@@ -18,7 +18,8 @@ class BxGroupsGridConnections extends BxDolGridConnections
     public function __construct ($aOptions, $oTemplate = false)
     {
         $this->_sContentModule = 'bx_groups';
-        $this->_sObjectConnections = 'bx_groups_fans';
+        $this->_oModule = BxDolModule::getInstance($this->_sContentModule);
+        $this->_sObjectConnections = $this->_oModule->_oConfig->CNF['OBJECT_CONNECTIONS'];
 
         parent::__construct ($aOptions, $oTemplate);
 
@@ -33,7 +34,6 @@ class BxGroupsGridConnections extends BxDolGridConnections
         $aProfileInfo = $oProfile->getInfo();
         $this->_iContentId = $aProfileInfo['content_id'];
 
-        $this->_oModule = BxDolModule::getInstance($aProfileInfo['type']);
         $aContentInfo = BxDolService::call($aProfileInfo['type'], 'get_content_info_by_id', array($this->_iContentId));
         if (CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->checkAllowedEdit($aContentInfo) || $oProfile->id() == bx_get_logged_profile_id())
             $this->_bOwner = true;

+ 2 - 7
modules/boonex/groups/classes/BxGroupsMenuView.php

@@ -22,18 +22,13 @@ class BxGroupsMenuView extends BxBaseModProfileMenuView
 
         if ($this->_oProfile && isLogged()) {
 
-            $oConn = BxDolConnection::getObjectInstance('bx_groups_fans');
+            $oConn = BxDolConnection::getObjectInstance($this->_oModule->_oConfig->CNF['OBJECT_CONNECTIONS']);
             if ($oConn->isConnectedNotMutual(bx_get_logged_profile_id(), $this->_aProfileInfo['content_id'])) {
                 $this->addMarkers(array(
                     'title_add_fan' => _t('_bx_groups_menu_item_title_become_fan_sent'),
                     'title_remove_fan' => _t('_bx_groups_menu_item_title_leave_group_cancel_request'),
                 ));
-            } /* elseif ($oConn->isConnectedNotMutual($this->_aProfileInfo['content_id'], bx_get_logged_profile_id())) {
-                $this->addMarkers(array(
-                    'title_add_fan' => _t('_bx_groups_menu_item_title_become_fan_confirm'),
-                    'title_remove_fan' => _t('_bx_groups_menu_item_title_leave_group_reject_request'),
-                ));
-            } */ else {
+            } else {
                 $this->addMarkers(array(
                     'title_add_fan' => _t('_bx_groups_menu_item_title_become_fan'),
                     'title_remove_fan' => _t('_bx_groups_menu_item_title_leave_group'),

+ 16 - 5
modules/boonex/groups/classes/BxGroupsModule.php

@@ -39,13 +39,15 @@ class BxGroupsModule extends BxBaseModProfileModule
         if (!$aContentInfo || $aContentInfo['join_confirmation'])
             return false;
 
-        $oConnection = BxDolConnection::getObjectInstance('bx_groups_fans');
+        if (!($oConnection = BxDolConnection::getObjectInstance($this->_oConfig->CNF['OBJECT_CONNECTIONS'])))
+            return false;
+
         return $oConnection->addConnection((int)$iContentId, (int)$iInitiatorId);
     }
 
     public function serviceFansTable ()
     {
-        $oGrid = BxDolGrid::getObjectInstance('bx_groups_fans');
+        $oGrid = BxDolGrid::getObjectInstance($this->_oConfig->CNF['OBJECT_GRID_CONNECTIONS']);
         if (!$oGrid)
             return false;
 
@@ -64,7 +66,7 @@ class BxGroupsModule extends BxBaseModProfileModule
             return false;
 
         bx_import('BxDolConnection');
-        $s = $this->serviceBrowseConnectionsQuick ($iContentId, 'bx_groups_fans', BX_CONNECTIONS_CONTENT_TYPE_CONTENT, true);
+        $s = $this->serviceBrowseConnectionsQuick ($iContentId, $this->_oConfig->CNF['OBJECT_CONNECTIONS'], BX_CONNECTIONS_CONTENT_TYPE_CONTENT, true);
         if (!$s)
             return MsgBox(_t('_sys_txt_empty'));
         return $s;
@@ -75,7 +77,7 @@ class BxGroupsModule extends BxBaseModProfileModule
      */
     public function checkAllowedFanAdd (&$aDataEntry, $isPerformAction = false)
     {
-        return $this->_checkAllowedConnectContent ($aDataEntry, $isPerformAction, 'bx_groups_fans', true, false);
+        return $this->_checkAllowedConnectContent ($aDataEntry, $isPerformAction, $this->_oConfig->CNF['OBJECT_CONNECTIONS'], true, false);
     }
 
     /**
@@ -85,7 +87,7 @@ class BxGroupsModule extends BxBaseModProfileModule
     {
         if (CHECK_ACTION_RESULT_ALLOWED === $this->_checkAllowedConnectContent ($aDataEntry, $isPerformAction, 'sys_profiles_friends', false, true, true))
             return CHECK_ACTION_RESULT_ALLOWED;
-        return $this->_checkAllowedConnectContent ($aDataEntry, $isPerformAction, 'bx_groups_fans', false, true, false);
+        return $this->_checkAllowedConnectContent ($aDataEntry, $isPerformAction, $this->_oConfig->CNF['OBJECT_CONNECTIONS'], false, true, false);
     }
 
     public function checkAllowedManageAdmins ($mixedDataEntry, $isPerformAction = false)
@@ -115,6 +117,15 @@ class BxGroupsModule extends BxBaseModProfileModule
             return CHECK_ACTION_RESULT_ALLOWED;
         return parent::checkAllowedDelete ($aDataEntry, $isPerformAction);
     }
+
+    protected function _checkAllowedConnect (&$aDataEntry, $isPerformAction, $sObjConnection, $isMutual, $isInvertResult, $isSwap = false)
+    {
+        $sResult = $this->checkAllowedView($aDataEntry);
+        if (CHECK_ACTION_RESULT_ALLOWED !== $sResult)
+            return $sResult;
+
+        return parent::_checkAllowedConnect ($aDataEntry, $isPerformAction, $sObjConnection, $isMutual, $isInvertResult, $isSwap);
+    }
 }
 
 /** @} */

+ 17 - 0
modules/boonex/groups/classes/BxGroupsPageEntry.php

@@ -19,6 +19,23 @@ class BxGroupsPageEntry extends BxBaseModProfilePageEntry
         $this->MODULE = 'bx_groups';
         parent::__construct($aObject, $oTemplate);
     }
+
+    protected function _processPermissionsCheck ()
+    {
+        if ('c' != $this->_aContentInfo['allow_view_to'] && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($this->_aContentInfo))) {
+            $this->_oTemplate->displayAccessDenied($sMsg);
+            exit;
+        }
+        elseif ('c' == $this->_aContentInfo['allow_view_to'] && 'bx_groups_view_profile' == $this->_sObject) {
+            // replace current page with different set of blocks
+            $aObject = BxDolPageQuery::getPageObject('bx_groups_view_profile_closed');
+            $this->_sObject = $aObject['object'];
+            $this->_aObject = $aObject;
+            $this->_oQuery = new BxDolPageQuery($this->_aObject);
+        }
+
+        $this->_oModule->checkAllowedView($this->_aContentInfo, true);
+    }
 }
 
 /** @} */

+ 75 - 0
modules/boonex/groups/classes/BxGroupsPrivacy.php

@@ -0,0 +1,75 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Groups Groups
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxGroupsPrivacy extends BxTemplPrivacy
+{
+	protected $MODULE;
+	protected $_oModule;
+
+    function __construct($aOptions, $oTemplate = false)
+    {
+    	$this->MODULE = 'bx_groups';
+
+    	$this->_oModule = BxDolModule::getInstance($this->MODULE);
+    	if(!$oTemplate)
+			$oTemplate = $this->_oModule->_oTemplate;
+
+        parent::__construct($aOptions, $oTemplate);
+    }
+
+	/**
+     * Check whethere viewer is a member of dynamic group.
+     *
+     * @param  mixed   $mixedGroupId   dynamic group ID.
+     * @param  integer $iObjectOwnerId object owner ID.
+     * @param  integer $iViewerId      viewer ID.
+     * @return boolean result of operation.
+     */
+    function isDynamicGroupMember($mixedGroupId, $iObjectOwnerId, $iViewerId, $iObjectId)
+    {
+        if ('c' == $mixedGroupId)
+            return $this->isClosedGroupAccess($iObjectOwnerId, $iViewerId, $iObjectId);
+
+        if ('s' == $mixedGroupId)
+            return $this->isSecretGroupAccess($iObjectOwnerId, $iViewerId, $iObjectId);
+
+        return false;
+    }
+
+    function isClosedGroupAccess ($iObjectOwnerId, $iViewerId, $iObjectId)
+    {
+        if (!($oConnection = BxDolConnection::getObjectInstance($this->_oModule->_oConfig->CNF['OBJECT_CONNECTIONS'])))
+            return false;
+
+        return $oConnection->isConnected($iViewerId, $iObjectId, true);
+    }
+
+    function isSecretGroupAccess ($iObjectOwnerId, $iViewerId, $iObjectId)
+    {
+        return $this->isClosedGroupAccess($iObjectOwnerId, $iViewerId, $iObjectId);
+    }
+
+    static function getGroupChooser ($sObject, $iOwnerId = 0, $aParams = array())
+    {
+        if (!$iOwnerId)
+    		$iOwnerId = bx_get_logged_profile_id();
+
+		$aParams['dynamic_groups'] = array(
+			array ('key' => '', 'value' => '----'),
+			array ('key' => 'c', 'value' => _t('_bx_groups_privacy_group_closed')),
+			array ('key' => 's', 'value' => _t('_bx_groups_privacy_group_secret')),
+		);
+
+        return parent::getGroupChooser($sObject, $iOwnerId, $aParams);
+    }
+}
+
+/** @} */

+ 15 - 2
modules/boonex/groups/classes/BxGroupsTemplate.php

@@ -26,7 +26,7 @@ class BxGroupsTemplate extends BxBaseModProfileTemplate
 
         $aVars = parent::unitVars ($aData, $isCheckPrivateContent, $sTemplateName);
 
-        $oConn = BxDolConnection::getObjectInstance('bx_groups_fans');
+        $oConn = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS']);
 
         $aVars['cover_url'] = $this->urlCover ($aData, true);
         $aVars['members'] = _t('_bx_groups_txt_N_fans', $oConn ? $oConn->getConnectedInitiatorsCount($aData[$CNF['FIELD_ID']], true) : 0);
@@ -35,12 +35,25 @@ class BxGroupsTemplate extends BxBaseModProfileTemplate
             'content' => array (
                 'id' => $aData[$CNF['FIELD_ID']],
                 'title' => $oConn->isConnectedNotMutual(bx_get_logged_profile_id(), $aData[$CNF['FIELD_ID']]) ? _t('_bx_groups_menu_item_title_become_fan_sent') : _t('_bx_groups_menu_item_title_become_fan'),
-                'object' => 'bx_groups_fans'
+                'object' => $CNF['OBJECT_CONNECTIONS'],
             ),
         );
 
         return $aVars;
     }
+
+    function setCover ($aData, $sTemplateName = 'cover.html')
+    {
+        $oModule = BxDolModule::getInstance($this->MODULE);
+    
+        if ('c' != $aData['allow_view_to'] && CHECK_ACTION_RESULT_ALLOWED !== $oModule->checkAllowedView($aData)) {
+            $CNF = &$this->_oConfig->CNF;
+            $aData[$CNF['FIELD_COVER']] = 0;
+            $aData[$CNF['FIELD_PICTURE']] = 0;
+        }
+
+        parent::setCover ($aData, $sTemplateName);
+    }
 }
 
 /** @} */

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

@@ -15,6 +15,11 @@
 	<string name="_bx_groups_form_profile_input_sys_do_submit"><![CDATA[Submit]]></string>
     <string name="_bx_groups_form_profile_input_sys_join_confirm"><![CDATA[Join confirmation]]></string>
     <string name="_bx_groups_form_profile_input_join_confirm"><![CDATA[Join confirmation]]></string>
+    <string name="_bx_groups_form_profile_input_sys_allow_view_to"><![CDATA[Privacy]]></string>
+    <string name="_bx_groups_form_profile_input_allow_view_to"><![CDATA[Privacy]]></string>
+    <string name="_bx_groups_form_profile_input_allow_view_to_desc"><![CDATA[Closed - anyone can find the group and see who's in it, only members can see posts. Secret - only members can find the group and see posts.]]></string>
+    <string name="_bx_groups_form_profile_input_sys_initial_members"><![CDATA[Invite Members]]></string>
+    <string name="_bx_groups_form_profile_input_initial_members"><![CDATA[Invite Members]]></string>
     <string name="_bx_groups_form_profile_input_sys_group_name"><![CDATA[Group Name]]></string>
     <string name="_bx_groups_form_profile_input_group_name"><![CDATA[Group Name]]></string>
     <string name="_bx_groups_form_profile_input_group_name_err"><![CDATA[This information is essential. Please, fill in this field.]]></string>
@@ -50,6 +55,7 @@
 	<string name="_bx_groups_page_title_edit_profile_cover"><![CDATA[Edit Cover]]></string>
 	<string name="_bx_groups_page_title_sys_delete_profile"><![CDATA[Delete Group]]></string>
 	<string name="_bx_groups_page_title_delete_profile"><![CDATA[Delete Group]]></string>
+	<string name="_bx_groups_page_title_sys_view_profile_closed"><![CDATA[View Closed Group]]></string>
 	<string name="_bx_groups_page_title_sys_view_profile"><![CDATA[View Group]]></string>
 	<string name="_bx_groups_page_title_view_profile"><![CDATA[{display_name}]]></string>
 	<string name="_bx_groups_page_title_browse"><![CDATA[Groups]]></string>
@@ -193,6 +199,9 @@
     <string name="_bx_groups_txt_to_admins"><![CDATA[To Admins]]></string>
     <string name="_bx_groups_txt_from_admins"><![CDATA[From Admins]]></string>
 
+    <string name="_bx_groups_privacy_group_closed"><![CDATA[Closed]]></string>
+    <string name="_bx_groups_privacy_group_secret"><![CDATA[Secret]]></string>
+
     <string name="_bx_groups_pre_lists_cats"><![CDATA[Group categories]]></string>
     <string name="_bx_groups_cat_General"><![CDATA[General]]></string>
     <string name="_bx_groups_cat_Business"><![CDATA[Business]]></string>

+ 9 - 0
modules/boonex/groups/install/langs/ru.xml

@@ -15,6 +15,11 @@
 	<string name="_bx_groups_form_profile_input_sys_do_submit"><![CDATA[Выполнить]]></string>
     <string name="_bx_groups_form_profile_input_sys_join_confirm"><![CDATA[Подтверждение регистрации]]></string>
     <string name="_bx_groups_form_profile_input_join_confirm"><![CDATA[Подтверждение регистрации]]></string>
+    <string name="_bx_groups_form_profile_input_sys_allow_view_to"><![CDATA[Конфиденциальность]]></string>
+    <string name="_bx_groups_form_profile_input_allow_view_to"><![CDATA[Конфиденциальность]]></string>
+    <string name="_bx_groups_form_profile_input_sys_initial_members"><![CDATA[Пригласить участников]]></string>
+    <string name="_bx_groups_form_profile_input_initial_members"><![CDATA[Пригласить участников]]></string>
+    <string name="_bx_groups_form_profile_input_initial_members_desc"><![CDATA[]]></string>
     <string name="_bx_groups_form_profile_input_sys_group_name"><![CDATA[Название группы]]></string>
     <string name="_bx_groups_form_profile_input_group_name"><![CDATA[Название группы]]></string>
     <string name="_bx_groups_form_profile_input_group_name_err"><![CDATA[Эта информация необходима. Пожалуйста, заполните это поле.]]></string>
@@ -50,6 +55,7 @@
 	<string name="_bx_groups_page_title_edit_profile_cover"><![CDATA[Редактировать обложку]]></string>
 	<string name="_bx_groups_page_title_sys_delete_profile"><![CDATA[Удалить группу]]></string>
 	<string name="_bx_groups_page_title_delete_profile"><![CDATA[Удалить группу]]></string>
+	<string name="_bx_groups_page_title_sys_view_profile_closed"><![CDATA[Просмотреть закрытую группу]]></string>
 	<string name="_bx_groups_page_title_sys_view_profile"><![CDATA[Просмотреть группу]]></string>
 	<string name="_bx_groups_page_title_view_profile"><![CDATA[{display_name}]]></string>
 	<string name="_bx_groups_page_title_browse"><![CDATA[Группы]]></string>
@@ -192,6 +198,9 @@
     <string name="_bx_groups_txt_to_admins"><![CDATA[В админы]]></string>
     <string name="_bx_groups_txt_from_admins"><![CDATA[Из админов]]></string>
 
+    <string name="_bx_groups_privacy_group_closed"><![CDATA[Закрытая группа]]></string>
+    <string name="_bx_groups_privacy_group_secret"><![CDATA[Секретная группа]]></string>
+
     <string name="_bx_groups_pre_lists_cats"><![CDATA[Категории групп]]></string>
     <string name="_bx_groups_cat_General"><![CDATA[Обобщение]]></string>
     <string name="_bx_groups_cat_Business"><![CDATA[Бизнес]]></string>

+ 5 - 1
modules/boonex/groups/install/sql/disable.sql

@@ -10,7 +10,7 @@ DELETE FROM `sys_options_types` WHERE `id` = @iTypeId;
 -- PAGES
 
 DELETE FROM `sys_objects_page` WHERE `module` = 'bx_groups';
-DELETE FROM `sys_pages_blocks` WHERE `module` = 'bx_groups' OR `object` IN('bx_groups_create_profile', 'bx_groups_delete_profile', 'bx_groups_edit_profile', 'bx_groups_edit_profile_cover', 'bx_groups_view_profile', 'bx_groups_profile_info', 'bx_groups_home', 'bx_groups_fans');
+DELETE FROM `sys_pages_blocks` WHERE `module` = 'bx_groups' OR `object` IN('bx_groups_create_profile', 'bx_groups_delete_profile', 'bx_groups_edit_profile', 'bx_groups_edit_profile_cover', 'bx_groups_view_profile', 'bx_groups_view_profile_closed', 'bx_groups_profile_info', 'bx_groups_home', 'bx_groups_fans');
 
 -- MENU
 
@@ -48,3 +48,7 @@ SET @iHandler := (SELECT `id` FROM `sys_alerts_handlers` WHERE `name` = 'bx_grou
 DELETE FROM `sys_alerts` WHERE `handler_id` = @iHandler;
 DELETE FROM `sys_alerts_handlers` WHERE `id` = @iHandler;
 
+-- PRIVACY 
+
+DELETE FROM `sys_objects_privacy` WHERE `object` = 'bx_groups_allow_view_to';
+

+ 14 - 0
modules/boonex/groups/install/sql/enable.sql

@@ -33,6 +33,15 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `t
 ('bx_groups_view_profile', 2, 'bx_groups', '', '_bx_groups_page_block_title_profile_info', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:9:\"bx_groups\";s:6:\"method\";s:11:\"entity_info\";}', 0, 0, 1, 0),
 ('bx_groups_view_profile', 3, 'bx_groups', '', '_bx_groups_page_block_title_fans', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:9:\"bx_groups\";s:6:\"method\";s:4:\"fans\";}', 0, 0, 1, 0);
 
+-- PAGE: view closed profile 
+
+INSERT INTO `sys_objects_page`(`object`, `uri`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
+('bx_groups_view_profile_closed', 'view-group-profile-closed', '_bx_groups_page_title_sys_view_profile_closed', '_bx_groups_page_title_view_profile', 'bx_groups', 10, 2147483647, 1, 'page.php?i=view-group-profile', '', '', '', 0, 1, 0, 'BxGroupsPageEntry', 'modules/boonex/groups/classes/BxGroupsPageEntry.php');
+
+INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
+('bx_groups_view_profile_closed', 2, 'bx_groups', '', '_bx_groups_page_block_title_profile_info', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:9:\"bx_groups\";s:6:\"method\";s:11:\"entity_info\";}', 0, 0, 1, 0),
+('bx_groups_view_profile_closed', 3, 'bx_groups', '', '_bx_groups_page_block_title_fans', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:9:\"bx_groups\";s:6:\"method\";s:4:\"fans\";}', 0, 0, 1, 0);
+
 -- PAGE: edit profile
 
 INSERT INTO `sys_objects_page`(`object`, `uri`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
@@ -345,3 +354,8 @@ SET @iHandler := LAST_INSERT_ID();
 INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
 ('bx_groups_fans', 'connection_added', @iHandler);
 
+-- PRIVACY 
+
+INSERT INTO `sys_objects_privacy` (`object`, `module`, `action`, `title`, `default_group`, `table`, `table_field_id`, `table_field_author`, `override_class_name`, `override_class_file`) VALUES
+('bx_groups_allow_view_to', 'bx_groups', 'view', '_bx_groups_form_profile_input_allow_view_to', '3', 'bx_groups_data', 'id', 'author', '', '');
+

+ 15 - 9
modules/boonex/groups/install/sql/install.sql

@@ -12,6 +12,7 @@ CREATE TABLE IF NOT EXISTS `bx_groups_data` (
   `group_desc` text NOT NULL,
   `views` int(11) NOT NULL default '0',
   `join_confirmation` tinyint(4) NOT NULL DEFAULT '1',
+  `allow_view_to` varchar(255) DEFAULT NULL,
   PRIMARY KEY (`id`),
   FULLTEXT KEY `group_name` (`group_name`)
 );
@@ -122,6 +123,7 @@ INSERT INTO `sys_form_displays`(`object`, `display_name`, `module`, `view_mode`,
 ('bx_group', 'bx_group_view', 'bx_groups', 1, '_bx_groups_form_profile_display_view');
 
 INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `checked`, `type`, `caption_system`, `caption`, `info`, `required`, `collapsed`, `html`, `attrs`, `attrs_tr`, `attrs_wrapper`, `checker_func`, `checker_params`, `checker_error`, `db_pass`, `db_params`, `editable`, `deletable`) VALUES 
+('bx_group', 'bx_groups', 'allow_view_to', 3, '', 0, 'custom', '_bx_groups_form_profile_input_sys_allow_view_to', '_bx_groups_form_profile_input_allow_view_to', '_bx_groups_form_profile_input_allow_view_to_desc', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
 ('bx_group', 'bx_groups', 'cover', '', '', 0, 'file', '_bx_groups_form_profile_input_sys_cover', '_bx_groups_form_profile_input_cover', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
 ('bx_group', 'bx_groups', 'cover_preview', '', '', 0, 'custom', '_bx_groups_form_profile_input_sys_cover_preview', '_bx_groups_form_profile_input_cover_preview', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_group', 'bx_groups', 'delete_confirm', 1, '', 0, 'checkbox', '_bx_groups_form_profile_input_sys_delete_confirm', '_bx_groups_form_profile_input_delete_confirm', '_bx_groups_form_profile_input_delete_confirm_info', 1, 0, 0, '', '', '', 'avail', '', '_bx_groups_form_profile_input_delete_confirm_error', '', '', 1, 0),
@@ -129,6 +131,7 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch
 ('bx_group', 'bx_groups', 'group_desc', '', '', 0, 'textarea', '_bx_groups_form_profile_input_sys_group_desc', '_bx_groups_form_profile_input_group_desc', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 1, 1),
 ('bx_group', 'bx_groups', 'group_cat', '', '#!bx_groups_cats', 0, 'select', '_bx_groups_form_profile_input_sys_group_cat', '_bx_groups_form_profile_input_group_cat', '', 1, 0, 0, '', '', '', 'avail', '', '_bx_groups_form_profile_input_group_cat_err', 'Xss', '', 1, 1),
 ('bx_group', 'bx_groups', 'group_name', '', '', 0, 'text', '_bx_groups_form_profile_input_sys_group_name', '_bx_groups_form_profile_input_group_name', '', 1, 0, 0, '', '', '', 'avail', '', '_bx_groups_form_profile_input_group_name_err', 'Xss', '', 1, 0),
+('bx_group', 'bx_groups', 'initial_members', '', '', 0, 'custom', '_bx_groups_form_profile_input_sys_initial_members', '_bx_groups_form_profile_input_initial_members', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 1),
 ('bx_group', 'bx_groups', 'join_confirmation', 1, '', 1, 'switcher', '_bx_groups_form_profile_input_sys_join_confirm', '_bx_groups_form_profile_input_join_confirm', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 1, 0),
 ('bx_group', 'bx_groups', 'picture', '', '', 0, 'file', '_bx_groups_form_profile_input_sys_picture', '_bx_groups_form_profile_input_picture', '', 1, 0, 0, '', '', '', 'avail', '', '_bx_groups_form_profile_input_picture_err', 'Int', '', 1, 0),
 ('bx_group', 'bx_groups', 'picture_preview', '', '', 0, 'custom', '_bx_groups_form_profile_input_sys_picture_preview', '_bx_groups_form_profile_input_picture_preview', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0);
@@ -138,17 +141,19 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_group_add', 'picture_preview', 2147483647, 0, 2),
 ('bx_group_add', 'delete_confirm', 2147483647, 0, 3),
 ('bx_group_add', 'cover', 2147483647, 0, 4),
-('bx_group_add', 'picture', 2147483647, 1, 5),
-('bx_group_add', 'group_name', 2147483647, 1, 6),
-('bx_group_add', 'group_cat', 2147483647, 1, 7),
-('bx_group_add', 'group_desc', 2147483647, 1, 8),
-('bx_group_add', 'join_confirmation', 2147483647, 1, 9),
-('bx_group_add', 'do_submit', 2147483647, 1, 10),
+('bx_group_add', 'initial_members', 2147483647, 1, 5),
+('bx_group_add', 'picture', 2147483647, 1, 6),
+('bx_group_add', 'group_name', 2147483647, 1, 7),
+('bx_group_add', 'group_cat', 2147483647, 1, 8),
+('bx_group_add', 'group_desc', 2147483647, 1, 9),
+('bx_group_add', 'join_confirmation', 2147483647, 1, 10),
+('bx_group_add', 'allow_view_to', 2147483647, 1, 11),
+('bx_group_add', 'do_submit', 2147483647, 1, 12),
+('bx_group_delete', 'delete_confirm', 2147483647, 1, 0),
+('bx_group_delete', 'picture_preview', 2147483647, 0, 0),
 ('bx_group_delete', 'cover', 2147483647, 0, 0),
 ('bx_group_delete', 'cover_preview', 2147483647, 0, 0),
 ('bx_group_delete', 'picture', 2147483647, 0, 0),
-('bx_group_delete', 'delete_confirm', 2147483647, 1, 0),
-('bx_group_delete', 'picture_preview', 2147483647, 0, 0),
 ('bx_group_delete', 'do_submit', 2147483647, 1, 1),
 ('bx_group_delete', 'group_name', 2147483647, 0, 2),
 ('bx_group_delete', 'group_cat', 2147483647, 0, 3),
@@ -161,7 +166,8 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_group_edit', 'group_cat', 2147483647, 1, 7),
 ('bx_group_edit', 'group_desc', 2147483647, 1, 8),
 ('bx_group_edit', 'join_confirmation', 2147483647, 1, 9),
-('bx_group_edit', 'do_submit', 2147483647, 1, 10),
+('bx_group_edit', 'allow_view_to', 2147483647, 1, 10),
+('bx_group_edit', 'do_submit', 2147483647, 1, 11),
 ('bx_group_edit_cover', 'join_confirmation', 2147483647, 0, 0),
 ('bx_group_edit_cover', 'group_desc', 2147483647, 0, 0),
 ('bx_group_edit_cover', 'delete_confirm', 2147483647, 0, 1),