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

Ticket #4265 - Groups: no join button for private groups.

AntonLV 3 лет назад
Родитель
Сommit
06d2077b27

+ 17 - 4
inc/classes/BxDolConnection.php

@@ -188,12 +188,11 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
             return _t('_sys_txt_access_denied');
 
         // check ACL
-        $aCheck = checkActionModule($iInitiator, 'connect', 'system', $isPerformAction);
-        if($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
-            return $aCheck[CHECK_ACTION_MESSAGE];
+        if(($mixedResult = $this->_checkAllowedConnectInitiator($oInitiator, $isPerformAction)) !== CHECK_ACTION_RESULT_ALLOWED)
+            return $mixedResult;
 
         // check content's visibility
-        if(($mixedResult = $oContent->checkAllowedProfileView()) !== CHECK_ACTION_RESULT_ALLOWED)
+        if(($mixedResult = $this->_checkAllowedConnectContent($oContent)) !== CHECK_ACTION_RESULT_ALLOWED)
             return $mixedResult;
 
         if($isSwap)
@@ -207,6 +206,20 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
         return $isConnected ? _t('_sys_txt_access_denied') : CHECK_ACTION_RESULT_ALLOWED;
     }
 
+    protected function _checkAllowedConnectInitiator ($oInitiator, $isPerformAction = false)
+    {
+        $aCheck = checkActionModule($oInitiator->id(), 'connect', 'system', $isPerformAction);
+        if($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
+            return $aCheck[CHECK_ACTION_MESSAGE];
+
+        return CHECK_ACTION_RESULT_ALLOWED;
+    }
+
+    protected function _checkAllowedConnectContent ($oContent)
+    {
+        return $oContent->checkAllowedProfileView();
+    }
+
     /**
      * Add new connection.
      * @param $iContent content to make connection to, in most cases some content id, or other profile id in case of friends

+ 40 - 0
modules/base/groups/classes/BxBaseModGroupsConnectionFans.php

@@ -0,0 +1,40 @@
+<?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 BxBaseModGroupsConnectionFans extends BxTemplConnection
+{
+    protected $_sModule;
+    protected $_oModule;
+
+    public function __construct($aObject)
+    {
+        parent::__construct($aObject);
+
+        $this->_oModule = BxDolModule::getInstance($this->_sModule);
+    }
+
+    public function _checkAllowedConnectContent ($oContent)
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if(!empty($CNF['OBJECT_PRIVACY_VIEW']) && ($oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW'])) !== false) {
+            $iContentId = $oContent->getContentId();
+            $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
+
+            if(in_array($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']], array_merge($oPrivacy->getPartiallyVisiblePrivacyGroups(), ['s'])))
+                return CHECK_ACTION_RESULT_ALLOWED;
+        }
+
+        return parent::_checkAllowedConnectContent($oContent);
+    }
+}
+
+/** @} */

+ 22 - 0
modules/boonex/courses/classes/BxCoursesConnectionFans.php

@@ -0,0 +1,22 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Courses Courses
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxCoursesConnectionFans extends BxBaseModGroupsConnectionFans
+{
+    public function __construct($aObject)
+    {
+        $this->_sModule = 'bx_courses';
+
+        parent::__construct($aObject);
+    }
+}
+
+/** @} */

+ 1 - 1
modules/boonex/courses/install/sql/enable.sql

@@ -505,7 +505,7 @@ INSERT INTO `sys_objects_search` (`ObjectName`, `Title`, `Order`, `ClassName`, `
 
 -- CONNECTIONS
 INSERT INTO `sys_objects_connection` (`object`, `table`, `profile_initiator`, `profile_content`, `type`, `override_class_name`, `override_class_file`) VALUES
-('bx_courses_fans', 'bx_courses_fans', 1, 1, 'mutual', '', '');
+('bx_courses_fans', 'bx_courses_fans', 1, 1, 'mutual', 'BxCoursesConnectionFans', 'modules/boonex/courses/classes/BxCoursesConnectionFans.php');
 
 -- STATS
 SET @iMaxOrderStats = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_statistics`);

+ 22 - 0
modules/boonex/events/classes/BxEventsConnectionFans.php

@@ -0,0 +1,22 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Events Events
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxEventsConnectionFans extends BxBaseModGroupsConnectionFans
+{
+    public function __construct($aObject)
+    {
+        $this->_sModule = 'bx_events';
+
+        parent::__construct($aObject);
+    }
+}
+
+/** @} */

+ 1 - 1
modules/boonex/events/install/sql/enable.sql

@@ -563,7 +563,7 @@ INSERT INTO `sys_objects_search` (`ObjectName`, `Title`, `Order`, `ClassName`, `
 
 -- CONNECTIONS
 INSERT INTO `sys_objects_connection` (`object`, `table`, `profile_initiator`, `profile_content`, `type`, `override_class_name`, `override_class_file`) VALUES
-('bx_events_fans', 'bx_events_fans', 1, 1, 'mutual', '', '');
+('bx_events_fans', 'bx_events_fans', 1, 1, 'mutual', 'BxEventsConnectionFans', 'modules/boonex/events/classes/BxEventsConnectionFans.php');
 
 -- STATS
 SET @iMaxOrderStats = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_statistics`);

+ 22 - 0
modules/boonex/groups/classes/BxGroupsConnectionFans.php

@@ -0,0 +1,22 @@
+<?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 BxGroupsConnectionFans extends BxBaseModGroupsConnectionFans
+{
+    public function __construct($aObject)
+    {
+        $this->_sModule = 'bx_groups';
+
+        parent::__construct($aObject);
+    }
+}
+
+/** @} */

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

@@ -520,7 +520,7 @@ INSERT INTO `sys_objects_search` (`ObjectName`, `Title`, `Order`, `ClassName`, `
 
 -- CONNECTIONS
 INSERT INTO `sys_objects_connection` (`object`, `table`, `profile_initiator`, `profile_content`, `type`, `override_class_name`, `override_class_file`) VALUES
-('bx_groups_fans', 'bx_groups_fans', 1, 1, 'mutual', '', '');
+('bx_groups_fans', 'bx_groups_fans', 1, 1, 'mutual', 'BxGroupsConnectionFans', 'modules/boonex/groups/classes/BxGroupsConnectionFans.php');
 
 
 -- STATS

+ 22 - 0
modules/boonex/organizations/classes/BxOrgsConnectionFans.php

@@ -0,0 +1,22 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Organizations Organizations
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxOrgsConnectionFans extends BxBaseModGroupsConnectionFans
+{
+    public function __construct($aObject)
+    {
+        $this->_sModule = 'bx_organizations';
+
+        parent::__construct($aObject);
+    }
+}
+
+/** @} */

+ 1 - 1
modules/boonex/organizations/install/sql/enable.sql

@@ -589,7 +589,7 @@ INSERT INTO `sys_objects_search` (`ObjectName`, `Title`, `Order`, `ClassName`, `
 
 -- CONNECTIONS
 INSERT INTO `sys_objects_connection` (`object`, `table`, `profile_initiator`, `profile_content`, `type`, `override_class_name`, `override_class_file`) VALUES
-('bx_organizations_fans', 'bx_organizations_fans', 1, 1, 'mutual', '', '');
+('bx_organizations_fans', 'bx_organizations_fans', 1, 1, 'mutual', 'BxOrgsConnectionFans', 'modules/boonex/organizations/classes/BxOrgsConnectionFans.php');
 
 
 -- STATS

+ 22 - 0
modules/boonex/spaces/classes/BxSpacesConnectionFans.php

@@ -0,0 +1,22 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defdroup    Spaces Spaces
+ * @indroup     UnaModules
+ *
+ * @{
+ */
+
+class BxSpacesConnectionFans extends BxBaseModGroupsConnectionFans
+{
+    public function __construct($aObject)
+    {
+        $this->_sModule = 'bx_spaces';
+
+        parent::__construct($aObject);
+    }
+}
+
+/** @} */

+ 1 - 1
modules/boonex/spaces/install/sql/enable.sql

@@ -507,7 +507,7 @@ INSERT INTO `sys_objects_search` (`ObjectName`, `Title`, `Order`, `ClassName`, `
 
 -- CONNECTIONS
 INSERT INTO `sys_objects_connection` (`object`, `table`, `profile_initiator`, `profile_content`, `type`, `override_class_name`, `override_class_file`) VALUES
-('bx_spaces_fans', 'bx_spaces_fans', 1, 1, 'mutual', '', '');
+('bx_spaces_fans', 'bx_spaces_fans', 1, 1, 'mutual', 'BxSpacesConnectionFans', 'modules/boonex/spaces/classes/BxSpacesConnectionFans.php');
 
 -- STATS
 SET @iMaxOrderStats = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_statistics`);