AntonLV 9 лет назад
Родитель
Сommit
a61c3d279b

+ 5 - 2
inc/classes/BxDolGridSubscribedMe.php

@@ -12,8 +12,10 @@ require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
 class BxDolGridSubscribedMe extends BxTemplGrid
 {
     protected $_bOwner = false;
+
     protected $_sObjectConnections = 'sys_profiles_subscriptions';
     protected $_oConnection;
+    protected $_sConnectionMethod = 'getConnectedInitiatorsAsSQLParts';
 
     public function __construct ($aOptions, $oTemplate = false)
     {
@@ -35,7 +37,7 @@ class BxDolGridSubscribedMe extends BxTemplGrid
         if ($oProfile->id() == bx_get_logged_profile_id())
             $this->_bOwner = true;
 
-        $aSQLParts = $this->_oConnection->getConnectedInitiatorsAsSQLParts('p', 'id', $oProfile->id());
+        $aSQLParts = $this->_oConnection->{$this->_sConnectionMethod}('p', 'id', $oProfile->id());
 
         $this->addMarkers(array(
             'profile_id' => $oProfile->id(),
@@ -70,7 +72,8 @@ class BxDolGridSubscribedMe extends BxTemplGrid
 
     protected function _getActionSubscribe ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
     {
-        if(!isLogged() || $this->_oConnection->isConnected(bx_get_logged_profile_id(), $aRow['id']))
+        $iViewerId = bx_get_logged_profile_id();
+        if(!isLogged() || $iViewerId == $aRow['id'] || $this->_oConnection->isConnected($iViewerId, $aRow['id']))
             return '';
 
         return parent::_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);

+ 2 - 57
inc/classes/BxDolGridSubscriptions.php

@@ -9,38 +9,13 @@
 
 require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
 
-class BxDolGridSubscriptions extends BxTemplGrid
+class BxDolGridSubscriptions extends BxDolGridSubscribedMe
 {
-    protected $_bOwner = false;
-    protected $_sObjectConnections = 'sys_profiles_subscriptions';
-    protected $_oConnection;
+    protected $_sConnectionMethod = 'getConnectedContentAsSQLParts';
 
     public function __construct ($aOptions, $oTemplate = false)
     {
         parent::__construct ($aOptions, $oTemplate);
-        $this->_sDefaultSortingOrder = 'DESC';
-
-        $this->_oConnection = BxDolConnection::getObjectInstance($this->_sObjectConnections);
-        if (!$this->_oConnection)
-            return;
-
-        $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
-        if (!$iProfileId)
-            return;
-
-        $oProfile = BxDolProfile::getInstance($iProfileId);
-        if (!$oProfile)
-            return;
-
-        if ($oProfile->id() == bx_get_logged_profile_id())
-            $this->_bOwner = true;
-
-        $aSQLParts = $this->_oConnection->getConnectedContentAsSQLParts('p', 'id', $oProfile->id());
-
-        $this->addMarkers(array(
-            'profile_id' => $oProfile->id(),
-            'join_connections' => $aSQLParts['join']
-        ));
     }
 
     protected function _delete ($mixedId)
@@ -53,15 +28,6 @@ class BxDolGridSubscriptions extends BxTemplGrid
         return $this->_oConnection->removeConnection($iViewedId, $iId);
     }
 
-    protected function _getCellName ($mixedValue, $sKey, $aField, $aRow)
-    {
-        $oProfile = BxDolProfile::getInstance($aRow['id']);
-        if (!$oProfile)
-            return _t('_sys_txt_error_occured');
-
-        return parent::_getCellDefault ($oProfile->getUnit(), $sKey, $aField, $aRow);
-    }
-
     protected function _getActionDelete ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
     {
         if (!isLogged() || !$this->_bOwner)
@@ -69,27 +35,6 @@ class BxDolGridSubscriptions extends BxTemplGrid
 
         return parent::_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
     }
-
-    protected function _prepareIds ()
-    {
-        $iViewedId = bx_get_logged_profile_id();
-
-        $iId = 0;
-        $aIds = bx_get('ids');
-        if($aIds && is_array($aIds))
-            $mixedId = array_pop($aIds);
-
-        if(strpos($mixedId, ':') !== false) {
-            list($iId, $iViewedId) = explode (':', $mixedId);
-
-            $iId = (int)$iId;
-            $iViewedId = (int)$iViewedId;
-        }
-        else 
-            $iId = (int)$mixedId;
-
-        return array($iId, $iViewedId);
-    }
 }
 
 /** @} */

+ 2 - 1
install/sql/system.sql

@@ -3475,7 +3475,8 @@ INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `conf
 ('sys_grid_connections', 'single', 'delete', '', 'remove', 1, 2),
 ('sys_grid_connections', 'single', 'add_friend', '_sys_add_friend', 'plus', 0, 3),
 
-('sys_grid_subscriptions', 'single', 'delete', '', 'remove', 1, 1),
+('sys_grid_subscriptions', 'single', 'subscribe', '_sys_subscribe', 'check', 0, 1),
+('sys_grid_subscriptions', 'single', 'delete', '', 'remove', 1, 2),
 
 ('sys_grid_subscribed_me', 'single', 'subscribe', '_sys_subscribe', 'check', 0, 1);