AntonLV 6 éve
szülő
commit
d5380798ae

+ 29 - 0
modules/base/groups/classes/BxBaseModGroupsConfig.php

@@ -0,0 +1,29 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Groups Groups
+ * @ingroup     UnaModules
+ * 
+ * @{
+ */
+
+class BxBaseModGroupsConfig extends BxBaseModProfileConfig
+{
+    function __construct($aModule)
+    {
+        parent::__construct($aModule);
+
+        $this->_aMenuItems2MethodsActions = array (
+            'profile-fan-add' => 'checkAllowedFanAdd',
+            'profile-fan-remove' => 'checkAllowedFanRemove',
+            'profile-subscribe-add' => 'checkAllowedSubscribeAdd',
+            'profile-subscribe-remove' => 'checkAllowedSubscribeRemove',
+            'profile-actions-more' => 'checkAllowedViewMoreMenu',
+            'convos-compose' => 'checkAllowedContact',
+        );
+    }
+}
+
+/** @} */

+ 13 - 4
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -613,14 +613,23 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
     }
 
     /**
+     * @deprecated since version 11.0.1 use BxBaseModGroupsModule::checkAllowedCompose instead
      * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
      */
-    public function checkAllowedCompose (&$aDataEntry, $isPerformAction = false)
+    public function checkAllowedCompose(&$aDataEntry, $isPerformAction = false)
     {
-        if (!$this->isFan($aDataEntry[$this->_oConfig->CNF['FIELD_ID']]))
+        return $this->checkAllowedContact($aDataEntry, $isPerformAction);
+    }
+
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
+     */
+    public function checkAllowedContact(&$aDataEntry, $isPerformAction = false)
+    {
+        if(!$this->isFan($aDataEntry[$this->_oConfig->CNF['FIELD_ID']]))
             return _t('_sys_txt_access_denied');
-        
-        return parent::checkAllowedCompose ($aDataEntry, $isPerformAction);
+
+        return parent::checkAllowedContact($aDataEntry, $isPerformAction);
     }
 
     /**

+ 2 - 2
modules/base/profile/classes/BxBaseModProfileConfig.php

@@ -27,8 +27,8 @@ class BxBaseModProfileConfig extends BxBaseModGeneralConfig
             'profile-subscribe-remove' => 'checkAllowedSubscribeRemove',
             'profile-actions-more' => 'checkAllowedViewMoreMenu',
             'profile-set-acl-level' => 'checkAllowedSetMembership',
-            'convos-compose' => 'checkAllowedCompose',
-            'messenger' => 'checkAllowedCompose',
+            'convos-compose' => 'checkAllowedContact',
+            'messenger' => 'checkAllowedContact',
         );        
     }
 }

+ 37 - 33
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -1286,34 +1286,17 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
      */
     public function serviceCheckAllowedContactForProfile ($aDataEntry, $isPerformAction = false, $iProfileId = false)
     {
-        $CNF = &$this->_oConfig->CNF;
-
-        if(!$iProfileId)
-            $iProfileId = $this->_iProfileId;
-
-        // check is view allowed
-        if(($mixedResult = $this->serviceCheckAllowedViewForProfile($aDataEntry, $isPerformAction, $iProfileId)) !== CHECK_ACTION_RESULT_ALLOWED)
-            return $mixedResult;
-
-        // moderator and owner always have access
-        $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->getName());
-        if(($oProfile && $oProfile->id() == $iProfileId) || $this->_isModerator($isPerformAction))
-            return CHECK_ACTION_RESULT_ALLOWED;
-
-        // check privacy
-        if(!empty($CNF['OBJECT_PRIVACY_CONTACT'])) {
-            $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_CONTACT']);
-            if($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']], $iProfileId))
-                return _t('_sys_access_denied_to_private_content');
-        }
+        $mixedResult = $this->_serviceCheckAllowedContactForProfile($aDataEntry, $isPerformAction, $iProfileId);
 
         // call alert to allow custom checks
-        $mixedResult = null;
-        bx_alert('system', 'check_allowed_contact', 0, 0, array('module' => $this->getName(), 'content_info' => $aDataEntry, 'profile_id' => $iProfileId, 'override_result' => &$mixedResult));
-        if($mixedResult !== null)
-            return $mixedResult;
+        bx_alert('system', 'check_allowed_contact', 0, 0, array(
+            'module' => $this->getName(), 
+            'content_info' => $aDataEntry, 
+            'profile_id' => $iProfileId, 
+            'override_result' => &$mixedResult
+        ));
 
-        return CHECK_ACTION_RESULT_ALLOWED;
+        return $mixedResult;
     }
 
     public function serviceSetViewProfileCover($oPage, $aProfileInfo)
@@ -1455,18 +1438,13 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         return CHECK_ACTION_RESULT_ALLOWED;
     }
 
-	/**
+    /**
+     * @deprecated since version 11.0.1 use BxBaseModProfileModule::checkAllowedCompose instead
      * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
      */
     public function checkAllowedCompose (&$aDataEntry, $isPerformAction = false)
     {
-        $CNF = &$this->_oConfig->CNF;
-
-        $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->getName());
-        if($oProfile && $oProfile->id() == $this->_iProfileId)
-            return _t('_sys_txt_access_denied');
-
-        return $this->checkAllowedView ($aDataEntry, $isPerformAction);
+        return $this->checkAllowedContact($aDataEntry, $isPerformAction);
     }
 
     /**
@@ -1567,6 +1545,32 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
 		return $oProfile->id() == $iLogged;
     }
 
+    protected function _serviceCheckAllowedContactForProfile($aDataEntry, $isPerformAction = false, $iProfileId = false)
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        if(!$iProfileId)
+            $iProfileId = $this->_iProfileId;
+
+        // check is view allowed
+        if(($mixedResult = $this->serviceCheckAllowedViewForProfile($aDataEntry, $isPerformAction, $iProfileId)) !== CHECK_ACTION_RESULT_ALLOWED)
+            return $mixedResult;
+
+        // moderator and owner always have access
+        $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$CNF['FIELD_ID']], $this->getName());
+        if(($oProfile && $oProfile->id() == $iProfileId) || $this->_isModerator($isPerformAction))
+            return CHECK_ACTION_RESULT_ALLOWED;
+
+        // check privacy
+        if(!empty($CNF['OBJECT_PRIVACY_CONTACT'])) {
+            $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_CONTACT']);
+            if($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']], $iProfileId))
+                return _t('_sys_access_denied_to_private_content');
+        }
+
+        return CHECK_ACTION_RESULT_ALLOWED;
+    }
+
     // ====== COMMON METHODS
     public function alertAfterAdd($aContentInfo)
     {

+ 5 - 9
modules/boonex/channels/classes/BxCnlConfig.php

@@ -9,23 +9,19 @@
  * @{
  */
 
-class BxCnlConfig extends BxBaseModProfileConfig
+class BxCnlConfig extends BxBaseModGroupsConfig
 {
     function __construct($aModule)
     {
         parent::__construct($aModule);
 
-        $aMenuItems2Methods = array (
+        $this->_aMenuItems2MethodsActions = array_merge($this->_aMenuItems2MethodsActions, array(
             'view-channel-profile' => 'checkAllowedView',
             'edit-channel-profile' => 'checkAllowedEdit',
             'edit-channel-cover' => 'checkAllowedChangeCover',
             'invite-to-channel' => 'checkAllowedInvite',
             'delete-channel-profile' => 'checkAllowedDelete',
-            'profile-subscribe-add' => 'checkAllowedSubscribeAdd',
-            'profile-subscribe-remove' => 'checkAllowedSubscribeRemove',
-            'profile-actions-more' => 'checkAllowedViewMoreMenu',
-            'convos-compose' => 'checkAllowedCompose',
-        );
+        ));
 
         $this->CNF = array (
 
@@ -122,8 +118,8 @@ class BxCnlConfig extends BxBaseModProfileConfig
 
             // menu items which visibility depends on custom visibility checking
             'MENU_ITEM_TO_METHOD' => array (
-                'bx_channels_view_actions' => $aMenuItems2Methods,
-                'bx_channels_view_actions_more' => $aMenuItems2Methods,
+                'bx_channels_view_actions' => $this->_aMenuItems2MethodsActions,
+                'bx_channels_view_actions_more' => $this->_aMenuItems2MethodsActions,
             ),
 
             // informer messages

+ 1 - 1
modules/boonex/channels/classes/BxCnlModule.php

@@ -465,7 +465,7 @@ class BxCnlModule extends BxBaseModGroupsModule
         return $a;
     }
     
-    public function checkAllowedCompose (&$aDataEntry, $isPerformAction = false)
+    public function checkAllowedContact(&$aDataEntry, $isPerformAction = false)
     {
         return _t('_sys_txt_access_denied');
     }

+ 7 - 13
modules/boonex/events/classes/BxEventsConfig.php

@@ -9,25 +9,19 @@
  * @{
  */
 
-class BxEventsConfig extends BxBaseModProfileConfig
+class BxEventsConfig extends BxBaseModGroupsConfig
 {
     function __construct($aModule)
     {
         parent::__construct($aModule);
 
-        $aMenuItems2Methods = array (
+        $this->_aMenuItems2MethodsActions = array_merge($this->_aMenuItems2MethodsActions, array(
             'view-event-profile' => 'checkAllowedView',
             'edit-event-profile' => 'checkAllowedEdit',
             'edit-event-cover' => 'checkAllowedChangeCover',
             'invite-to-event' => 'checkAllowedInvite',
-            'delete-event-profile' => 'checkAllowedDelete',
-            'profile-fan-add' => 'checkAllowedFanAdd',
-            'profile-fan-remove' => 'checkAllowedFanRemove',
-            'profile-subscribe-add' => 'checkAllowedSubscribeAdd',
-            'profile-subscribe-remove' => 'checkAllowedSubscribeRemove',
-            'profile-actions-more' => 'checkAllowedViewMoreMenu',
-            'convos-compose' => 'checkAllowedCompose',
-        );
+            'delete-event-profile' => 'checkAllowedDelete'
+        ));
 
         $this->CNF = array (
 
@@ -153,9 +147,9 @@ class BxEventsConfig extends BxBaseModProfileConfig
 
             // menu items which visibility depends on custom visibility checking
             'MENU_ITEM_TO_METHOD' => array (
-                'bx_events_view_actions' => $aMenuItems2Methods,
-                'bx_events_view_actions_more' => $aMenuItems2Methods,
-                'bx_events_view_actions_all' => $aMenuItems2Methods,
+                'bx_events_view_actions' => $this->_aMenuItems2MethodsActions,
+                'bx_events_view_actions_more' => $this->_aMenuItems2MethodsActions,
+                'bx_events_view_actions_all' => $this->_aMenuItems2MethodsActions,
             ),
 
             // informer messages

+ 7 - 13
modules/boonex/groups/classes/BxGroupsConfig.php

@@ -9,25 +9,19 @@
  * @{
  */
 
-class BxGroupsConfig extends BxBaseModProfileConfig
+class BxGroupsConfig extends BxBaseModGroupsConfig
 {
     function __construct($aModule)
     {
         parent::__construct($aModule);
 
-        $aMenuItems2Methods = array (
+        $this->_aMenuItems2MethodsActions = array_merge($this->_aMenuItems2MethodsActions, array(
             'view-group-profile' => 'checkAllowedView',
             'edit-group-profile' => 'checkAllowedEdit',
             'edit-group-cover' => 'checkAllowedChangeCover',
             'invite-to-group' => 'checkAllowedInvite',
-            'delete-group-profile' => 'checkAllowedDelete',
-            'profile-fan-add' => 'checkAllowedFanAdd',
-            'profile-fan-remove' => 'checkAllowedFanRemove',
-            'profile-subscribe-add' => 'checkAllowedSubscribeAdd',
-            'profile-subscribe-remove' => 'checkAllowedSubscribeRemove',
-            'profile-actions-more' => 'checkAllowedViewMoreMenu',
-            'convos-compose' => 'checkAllowedCompose',
-        );
+            'delete-group-profile' => 'checkAllowedDelete'
+        ));
 
         $this->CNF = array (
 
@@ -149,9 +143,9 @@ class BxGroupsConfig extends BxBaseModProfileConfig
 
             // menu items which visibility depends on custom visibility checking
             'MENU_ITEM_TO_METHOD' => array (
-                'bx_groups_view_actions' => $aMenuItems2Methods,
-                'bx_groups_view_actions_more' => $aMenuItems2Methods,
-                'bx_groups_view_actions_all' => $aMenuItems2Methods,
+                'bx_groups_view_actions' => $this->_aMenuItems2MethodsActions,
+                'bx_groups_view_actions_more' => $this->_aMenuItems2MethodsActions,
+                'bx_groups_view_actions_all' => $this->_aMenuItems2MethodsActions,
             ),
 
             // informer messages

+ 2 - 2
modules/boonex/organizations/classes/BxOrgsModule.php

@@ -79,9 +79,9 @@ class BxOrgsModule extends BxBaseModGroupsModule
         $oAccount->updateProfileContextAuto();
     }
 
-    public function checkAllowedCompose (&$aDataEntry, $isPerformAction = false)
+    public function checkAllowedContact(&$aDataEntry, $isPerformAction = false)
     {
-        return BxBaseModProfileModule::checkAllowedCompose ($aDataEntry, $isPerformAction);
+        return BxBaseModProfileModule::checkAllowedContact($aDataEntry, $isPerformAction);
     }
 }
 

+ 7 - 13
modules/boonex/spaces/classes/BxSpacesConfig.php

@@ -9,25 +9,19 @@
  * @{
  */
 
-class BxSpacesConfig extends BxBaseModProfileConfig
+class BxSpacesConfig extends BxBaseModGroupsConfig
 {
     function __construct($aModule)
     {
         parent::__construct($aModule);
 
-        $aMenuItems2Methods = array (
+        $this->_aMenuItems2MethodsActions = array_merge($this->_aMenuItems2MethodsActions, array(
             'view-space-profile' => 'checkAllowedView',
             'edit-space-profile' => 'checkAllowedEdit',
             'edit-space-cover' => 'checkAllowedChangeCover',
             'invite-to-space' => 'checkAllowedInvite',
-            'delete-space-profile' => 'checkAllowedDelete',
-            'profile-fan-add' => 'checkAllowedFanAdd',
-            'profile-fan-remove' => 'checkAllowedFanRemove',
-            'profile-subscribe-add' => 'checkAllowedSubscribeAdd',
-            'profile-subscribe-remove' => 'checkAllowedSubscribeRemove',
-            'profile-actions-more' => 'checkAllowedViewMoreMenu',
-            'convos-compose' => 'checkAllowedCompose',
-        );
+            'delete-space-profile' => 'checkAllowedDelete'
+        ));
 
         $this->CNF = array (
 
@@ -150,9 +144,9 @@ class BxSpacesConfig extends BxBaseModProfileConfig
 
             // menu items which visibility depends on custom visibility checking
             'MENU_ITEM_TO_METHOD' => array (
-                'bx_spaces_view_actions' => $aMenuItems2Methods,
-                'bx_spaces_view_actions_more' => $aMenuItems2Methods,
-                'bx_spaces_view_actions_all' => $aMenuItems2Methods,
+                'bx_spaces_view_actions' => $this->_aMenuItems2MethodsActions,
+                'bx_spaces_view_actions_more' => $this->_aMenuItems2MethodsActions,
+                'bx_spaces_view_actions_all' => $this->_aMenuItems2MethodsActions,
             ),
 
             // informer messages