Browse Source

Ticket #5026 - Connections flow improvements. In browsing cards.

AntonLV 1 năm trước cách đây
mục cha
commit
2f18b96afb

+ 24 - 9
inc/classes/BxDolConnection.php

@@ -133,6 +133,8 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
 
 
     protected $_sObject;
     protected $_sObject;
     protected $_aObject;
     protected $_aObject;
+    protected $_iInitiator;
+    protected $_iContent;
     protected $_sType;
     protected $_sType;
     protected $_bMutual;
     protected $_bMutual;
 
 
@@ -150,6 +152,7 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
         $this->_aObject = $aObject;
         $this->_aObject = $aObject;
         $this->_aObject['per_page_default'] = 20;
         $this->_aObject['per_page_default'] = 20;
 
 
+        $this->_iInitiator = bx_get_logged_profile_id();
         $this->_sType = $aObject['type'];
         $this->_sType = $aObject['type'];
         $this->_bMutual = $this->_sType == BX_CONNECTIONS_TYPE_MUTUAL;
         $this->_bMutual = $this->_sType == BX_CONNECTIONS_TYPE_MUTUAL;
 
 
@@ -259,10 +262,14 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
      */
      */
     public function actionAdd ($iContent = 0, $iInitiator = false)
     public function actionAdd ($iContent = 0, $iInitiator = false)
     {
     {
-        if (!$iContent)
-            $iContent = bx_process_input($_POST['id'], BX_DATA_INT);
+        if(!$iContent && ($_iContent = bx_get('id')) !== false)
+            $iContent = bx_process_input($_iContent, BX_DATA_INT);
 
 
-        return $this->_action ($iInitiator ? $iInitiator : bx_get_logged_profile_id(), $iContent, 'addConnection', '_sys_conn_err_connection_already_exists', true);
+        if($iInitiator)
+            $this->_iInitiator = $iInitiator;
+        $this->_iContent = $iContent;
+
+        return $this->_action ($this->_iInitiator, $this->_iContent, 'addConnection', '_sys_conn_err_connection_already_exists', true);
     }
     }
 
 
     /**
     /**
@@ -272,8 +279,8 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
      */
      */
     public function actionRemove ($iContent = 0, $iInitiator = false)
     public function actionRemove ($iContent = 0, $iInitiator = false)
     {
     {
-        if (!$iContent)
-            $iContent = bx_process_input($_POST['id'], BX_DATA_INT);
+        if (!$iContent && ($_iContent = bx_get('id')) !== false)
+            $iContent = bx_process_input($_iContent, BX_DATA_INT);
 
 
         if ($iContent != bx_get_logged_profile_id() && BX_CONNECTIONS_TYPE_MUTUAL == $this->_aObject['type']) {
         if ($iContent != bx_get_logged_profile_id() && BX_CONNECTIONS_TYPE_MUTUAL == $this->_aObject['type']) {
             $a = $this->actionReject($iContent, $iInitiator);
             $a = $this->actionReject($iContent, $iInitiator);
@@ -281,7 +288,11 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
                 return $a;
                 return $a;
         }
         }
 
 
-        return $this->_action ($iInitiator ? $iInitiator : bx_get_logged_profile_id(), $iContent, 'removeConnection', '_sys_conn_err_connection_does_not_exists', false, true);
+        if($iInitiator)
+            $this->_iInitiator = $iInitiator;
+        $this->_iContent = $iContent;
+
+        return $this->_action ($this->_iInitiator, $this->_iContent, 'removeConnection', '_sys_conn_err_connection_does_not_exists', false, true);
     }
     }
 
 
     /**
     /**
@@ -291,10 +302,14 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
      */
      */
     public function actionReject ($iContent = 0, $iInitiator = false)
     public function actionReject ($iContent = 0, $iInitiator = false)
     {
     {
-        if (!$iContent)
-            $iContent = bx_process_input($_POST['id'], BX_DATA_INT);
+        if (!$iContent && ($_iContent = bx_get('id')) !== false)
+            $iContent = bx_process_input($_iContent, BX_DATA_INT);
+
+        if($iInitiator)
+            $this->_iInitiator = $iInitiator;
+        $this->_iContent = $iContent;
 
 
-        return $this->_action($iContent, $iInitiator ? $iInitiator : bx_get_logged_profile_id(), 'removeConnection', '_sys_conn_err_connection_does_not_exists', false, true);
+        return $this->_action($this->_iContent, $this->_iInitiator, 'removeConnection', '_sys_conn_err_connection_does_not_exists', false, true);
     }
     }
 
 
     protected function _action ($iInitiator, $iContent, $sMethod, $sErrorKey, $isMutual = false, $isInvert = false)
     protected function _action ($iInitiator, $iContent, $sMethod, $sErrorKey, $isMutual = false, $isInvert = false)

+ 16 - 8
inc/classes/BxDolConnectionRelation.php

@@ -41,8 +41,8 @@ class BxDolConnectionRelation extends BxTemplConnection
      */
      */
     public function actionAdd($mixedContent = 0, $iInitiator = false)
     public function actionAdd($mixedContent = 0, $iInitiator = false)
     {
     {
-        if(empty($mixedContent))
-            $mixedContent = bx_process_input($_POST['id'], BX_DATA_INT);
+        if(!$mixedContent && ($_iContent = bx_get('id')) !== false)
+            $mixedContent = bx_process_input($_iContent, BX_DATA_INT);
 
 
         $iContent = 0;
         $iContent = 0;
         $iRelation = 0;
         $iRelation = 0;
@@ -73,10 +73,14 @@ class BxDolConnectionRelation extends BxTemplConnection
      */
      */
     public function actionConfirm($iContent = 0, $iInitiator = false)
     public function actionConfirm($iContent = 0, $iInitiator = false)
     {
     {
-        if(!$iContent)
-            $iContent = bx_process_input($_POST['id'], BX_DATA_INT);
+        if(!$iContent && ($_iContent = bx_get('id')) !== false)
+            $iContent = bx_process_input($_iContent, BX_DATA_INT);
 
 
-        return $this->_action($iContent, $iInitiator ? $iInitiator : bx_get_logged_profile_id(), 'confirmConnection', '_sys_conn_err_connection_does_not_exists');
+        if($iInitiator)
+            $this->_iInitiator = $iInitiator;
+        $this->_iContent = $iContent;
+
+        return $this->_action($this->_iContent, $this->_iInitiator, 'confirmConnection', '_sys_conn_err_connection_does_not_exists');
     }
     }
 
 
     /**
     /**
@@ -86,10 +90,14 @@ class BxDolConnectionRelation extends BxTemplConnection
      */
      */
     public function actionRemove($iContent = 0, $iInitiator = false)
     public function actionRemove($iContent = 0, $iInitiator = false)
     {
     {
-        if(!$iContent)
-            $iContent = bx_process_input($_POST['id'], BX_DATA_INT);
+        if(!$iContent && ($_iContent = bx_get('id')) !== false)
+            $iContent = bx_process_input($_iContent, BX_DATA_INT);
+
+        if($iInitiator)
+            $this->_iInitiator = $iInitiator;
+        $this->_iContent = $iContent;
 
 
-        return $this->_action($iInitiator ? $iInitiator : bx_get_logged_profile_id(), $iContent, 'removeConnection', '_sys_conn_err_connection_does_not_exists', false, true);
+        return $this->_action($this->_iInitiator, $this->_iContent, 'removeConnection', '_sys_conn_err_connection_does_not_exists', false, true);
     }
     }
 
 
     /**
     /**

+ 69 - 14
inc/js/classes/BxDolConnection.js

@@ -6,30 +6,86 @@
  * @{
  * @{
  */
  */
 
 
-function BxDolConnection(options)
+function BxDolConnection(oOptions)
 {
 {
-    this._sObjName = undefined == options.sObjName ? 'oConnection' : options.sObjName; // javascript object name, to run current object instance from onTimer
-    this._sSystem = options.sSystem; // current comment system
-    this._iObjId = options.iObjId; // this object id comments
-    this._sContentType = options.sContentType; 
-    this._bIsMutual = options.bIsMutual; 
-    
+    this._sSystem = oOptions.sSystem;
+    this._iContentId = oOptions.iContentId; // profile or content ID to connect with
+    this._sContentType = oOptions.sContentType; 
+    this._bIsMutual = oOptions.bIsMutual; 
+
+    this._sObjName = undefined == oOptions.sObjName ? 'oConnection' : oOptions.sObjName; // javascript object name, to run current object instance from onTimer
     this._sActionsUri = 'conn.php';
     this._sActionsUri = 'conn.php';
-    this._sActionsUrl = options.sRootUrl + this._sActionsUri; // actions url address
+    this._sActionsUrl = oOptions.sRootUrl + this._sActionsUri; // actions url address
 
 
     this._sAnimationEffect = 'fade';
     this._sAnimationEffect = 'fade';
     this._iAnimationSpeed = 'slow';
     this._iAnimationSpeed = 'slow';
-    this._sSP = undefined == options.sStylePrefix ? 'bx-view' : options.sStylePrefix;
-    this._aHtmlIds = options.aHtmlIds;
+    this._sSP = undefined == oOptions.sStylePrefix ? 'bx-view' : oOptions.sStylePrefix;
+    this._aHtmlIds = oOptions.aHtmlIds;
+    this._aRequestParams = oOptions.aRequestParams;
 }
 }
 
 
+BxDolConnection.prototype.connect = function(oLink, sAction, iContentId, bConfirm) {
+    var $this = this;
+    var oData = this._getDefaultParams();
+    oData['act'] = sAction;
+    oData['out'] = 'eval';
+
+    if(!iContentId)
+        iContentId = this._iContentId;
+
+    var fPerform = function() {
+        bx_loading_btn(oLink, 1);
+
+        $.post(
+            $this._sActionsUrl, 
+            oData,
+            function (oData) {
+                bx_loading_btn(oLink, 0);
+
+                $(oLink).parents('.bx-popup-applied:first:visible').dolPopupHide();
+
+                if(typeof(oData) != 'object')
+                    return;
+
+                if(oData.err)
+                    bx_alert(oData.msg);
+                else {
+                    if(oData.eval != undefined)
+                        eval(oData.eval);
+                    else if(!loadDynamicBlockAuto(oLink))
+                        location.reload();
+                }
+            },
+            'json'
+        );
+    };
+
+    if (typeof(bConfirm) != 'undefined' && bConfirm)
+    	bx_confirm(_t('_Are_you_sure'), fPerform);
+    else
+    	fPerform();
+};
+
+BxDolConnection.prototype.onConnect = function(oData) {
+    if(oData.data != 'undefined')
+        $('#' + this._aHtmlIds['main'] + this._iContentId).replaceWith(oData.data);
+};
+
+BxDolConnection.prototype.toggleConnectPopup = function(oLink, iContentId) {
+    if(!iContentId)
+        iContentId = this._iContentId;
+
+    bx_menu_popup_inline('#' + this._aHtmlIds['do_popup'] + iContentId, oLink);
+};
+
 BxDolConnection.prototype.toggleByPopup = function(oLink) {
 BxDolConnection.prototype.toggleByPopup = function(oLink) {
     var $this = this;
     var $this = this;
     var oData = this._getDefaultParams();
     var oData = this._getDefaultParams();
     oData['act'] = 'GetConnected';
     oData['act'] = 'GetConnected';
+    oData['fmt'] = 'html';
 
 
     $(oLink).dolPopupAjax({
     $(oLink).dolPopupAjax({
-        id: this._aHtmlIds['by_popup'], 
+        id: this._aHtmlIds['by_popup'] + this._iContentId, 
         url: bx_append_url_params(this._sActionsUri, oData)
         url: bx_append_url_params(this._sActionsUri, oData)
     });
     });
 };
 };
@@ -38,7 +94,6 @@ BxDolConnection.prototype.getUsers = function(oLink, iStart, iPerPage) {
     var $this = this;
     var $this = this;
     var oData = this._getDefaultParams();
     var oData = this._getDefaultParams();
     oData['act'] = 'GetUsers';
     oData['act'] = 'GetUsers';
-    oData['fmt'] = 'json';
     oData['start'] = iStart;
     oData['start'] = iStart;
     oData['per_page'] = iPerPage;
     oData['per_page'] = iPerPage;
 
 
@@ -80,11 +135,11 @@ BxDolConnection.prototype._getDefaultParams = function() {
     var oDate = new Date();
     var oDate = new Date();
     return {
     return {
         obj: this._sSystem,
         obj: this._sSystem,
-        id: this._iObjId,
+        id: this._iContentId,
         mutual: this._bIsMutual,
         mutual: this._bIsMutual,
         content_type: this._sContentType,
         content_type: this._sContentType,
+        params: $.param(this._aRequestParams),
         _t: oDate.getTime(),
         _t: oDate.getTime(),
-        fmt: 'html'
     };
     };
 };
 };
 
 

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

@@ -45,10 +45,12 @@ class BxBaseModProfileConfig extends BxBaseModGeneralConfig
 
 
         $this->_aConnectionToFunctionCheck = [
         $this->_aConnectionToFunctionCheck = [
             'sys_profiles_friends' => [
             'sys_profiles_friends' => [
+                'friends' => 'checkAllowedFriends',
             	'add' => 'checkAllowedFriendAdd', 
             	'add' => 'checkAllowedFriendAdd', 
             	'remove' => 'checkAllowedFriendRemove'
             	'remove' => 'checkAllowedFriendRemove'
             ],
             ],
             'sys_profiles_subscriptions' => [
             'sys_profiles_subscriptions' => [
+                'subscriptions' => 'checkAllowedSubscriptions',
                 'add' => 'checkAllowedSubscribeAdd',
                 'add' => 'checkAllowedSubscribeAdd',
                 'remove' => 'checkAllowedSubscribeRemove'
                 'remove' => 'checkAllowedSubscribeRemove'
             ]
             ]

+ 82 - 20
modules/base/profile/classes/BxBaseModProfileMenuSnippetMeta.php

@@ -11,6 +11,8 @@
 
 
 class BxBaseModProfileMenuSnippetMeta extends BxBaseModGeneralMenuSnippetMeta
 class BxBaseModProfileMenuSnippetMeta extends BxBaseModGeneralMenuSnippetMeta
 {
 {
+    protected $_oFunctions;
+
     protected $_bContentPublic;
     protected $_bContentPublic;
     protected $_oContentProfile;
     protected $_oContentProfile;
 
 
@@ -20,6 +22,8 @@ class BxBaseModProfileMenuSnippetMeta extends BxBaseModGeneralMenuSnippetMeta
     {
     {
         parent::__construct($aObject, $oTemplate);
         parent::__construct($aObject, $oTemplate);
 
 
+        $this->_oFunctions = BxTemplFunctions::getInstanceWithTemplate($this->_oTemplate);
+
         $this->_iButtonsMax = 2;
         $this->_iButtonsMax = 2;
         $this->_bShowZeros = true;
         $this->_bShowZeros = true;
 
 
@@ -52,6 +56,16 @@ class BxBaseModProfileMenuSnippetMeta extends BxBaseModGeneralMenuSnippetMeta
         $this->_bContentPublic = $bContentPublic;
         $this->_bContentPublic = $bContentPublic;
     }
     }
 
 
+    protected function _getMenuItemObjFriends($aItem)
+    {
+        return $this->_getMenuItemConnectionObj('sys_profiles_friends', 'friends', $aItem);
+    }
+
+    protected function _getMenuItemObjSubscriptions($aItem)
+    {
+        return $this->_getMenuItemConnectionObj('sys_profiles_subscriptions', 'subscriptions', $aItem);
+    }
+
     protected function _getMenuItemBefriend($aItem)
     protected function _getMenuItemBefriend($aItem)
     {
     {
         if($this->_sContext == 'recom_friends')
         if($this->_sContext == 'recom_friends')
@@ -90,6 +104,8 @@ class BxBaseModProfileMenuSnippetMeta extends BxBaseModGeneralMenuSnippetMeta
 
 
     protected function _getMenuItemFriends($aItem)
     protected function _getMenuItemFriends($aItem)
     {
     {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
         if(!$this->_oModule->_oConfig->isFriends() || !$this->_isVisibleInContext($aItem))
         if(!$this->_oModule->_oConfig->isFriends() || !$this->_isVisibleInContext($aItem))
             return false;
             return false;
 
 
@@ -100,27 +116,30 @@ class BxBaseModProfileMenuSnippetMeta extends BxBaseModGeneralMenuSnippetMeta
         if(!$oConnection)
         if(!$oConnection)
             return false;
             return false;
 
 
-        $iProfileId = $this->_oContentProfile->id();
+        $iContentProfile = $this->_oContentProfile->id();
 
 
-        $iFriends = $oConnection->getConnectedInitiatorsCount($iProfileId, true);
+        $iFriends = $oConnection->getConnectedInitiatorsCount($iContentProfile, true);
         if(!$iFriends && !$this->_bShowZeros)
         if(!$iFriends && !$this->_bShowZeros)
             return false;
             return false;
 
 
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        $sTitle = _t('_sys_menu_item_title_sm_friends', $iFriends);
+        if($this->_bIsApi) {
+            $sUrl = $this->_oContentProfile->getUrl();
+            if(!empty($CNF['URI_VIEW_FRIENDS']))
+                $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_FRIENDS'] . '&profile_id=' . $iContentProfile));
 
 
-        $sUrl = $this->_oContentProfile->getUrl();
-        if(!empty($CNF['URI_VIEW_FRIENDS']))
-            $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_FRIENDS'] . '&profile_id=' . $iProfileId));
-
-        if($this->_bIsApi)
             return $this->_getMenuItemAPI($aItem, 'text', [
             return $this->_getMenuItemAPI($aItem, 'text', [
-                'title' => $sTitle,
+                'title' => _t('_sys_menu_item_title_sm_friends', $iFriends),
                 'link' => bx_api_get_relative_url($sUrl),
                 'link' => bx_api_get_relative_url($sUrl),
             ]);
             ]);
+        }
 
 
-        return $this->getUnitMetaItemText($sTitle);
+        $aObjectOptions = [
+            'caption' => ($sKey = 'menu_item_title_sm_friends') && isset($CNF['T'][$sKey]) ? $CNF['T'][$sKey] : '_sys_' . $sKey
+        ];
+        if(!empty($aItem['icon']))
+            $aObjectOptions['custom_icon'] = $this->_oFunctions->getIconAsHtml($aItem['icon']);
+
+        return $this->getUnitMetaItemCustom($oConnection->getCounter($iContentProfile, false, $aObjectOptions));
     }
     }
 
 
     protected function _getMenuItemFriendsMutual($aItem)
     protected function _getMenuItemFriendsMutual($aItem)
@@ -172,21 +191,23 @@ class BxBaseModProfileMenuSnippetMeta extends BxBaseModGeneralMenuSnippetMeta
         if(!$oConnection)
         if(!$oConnection)
             return false;
             return false;
 
 
-        $iSubscribers = $oConnection->getConnectedInitiatorsCount($this->_oContentProfile->id());
+        $iContentProfile = $this->_oContentProfile->id();
+
+        $iSubscribers = $oConnection->getConnectedInitiatorsCount($iContentProfile);
         if(!$iSubscribers && !$this->_bShowZeros)
         if(!$iSubscribers && !$this->_bShowZeros)
             return false;
             return false;
 
 
-        $sIcon = BxTemplFunctions::getInstanceWithTemplate($this->_oTemplate)->getIconAsHtml(!empty($aItem['icon']) ? $aItem['icon'] : '');
-
         if($this->_bIsApi)
         if($this->_bIsApi)
             return false;
             return false;
 
 
-        $sTitle = isset($CNF['T']['menu_item_title_sm_subscribers']) ? $CNF['T']['menu_item_title_sm_subscribers'] : '_sys_menu_item_title_sm_subscribers';
+        $aObjectOptions = [
+            'content_type' => BX_CONNECTIONS_CONTENT_TYPE_INITIATORS,
+            'caption' => ($sKey = 'menu_item_title_sm_subscribers') && isset($CNF['T'][$sKey]) ? $CNF['T'][$sKey] : '_sys_' . $sKey
+        ];
+        if(!empty($aItem['icon']))
+            $aObjectOptions['custom_icon'] = $this->_oFunctions->getIconAsHtml($aItem['icon']);
 
 
-        return $this->getUnitMetaItemCustom($oConnection->getCounter($this->_oContentProfile->id(), false, [
-            'caption' => $sTitle, 
-            'custom_icon' => $sIcon
-        ], BX_CONNECTIONS_CONTENT_TYPE_INITIATORS));
+        return $this->getUnitMetaItemCustom($oConnection->getCounter($iContentProfile, false, $aObjectOptions));
     }
     }
 
 
     protected function _getMenuItemMembership($aItem)
     protected function _getMenuItemMembership($aItem)
@@ -246,6 +267,47 @@ class BxBaseModProfileMenuSnippetMeta extends BxBaseModGeneralMenuSnippetMeta
         return $mixedItem !== false ? [$mixedItem, 'bx-menu-item-button'] : false;
         return $mixedItem !== false ? [$mixedItem, 'bx-menu-item-button'] : false;
     }
     }
 
 
+    protected function _getMenuItemConnectionObj($sConnection, $sAction, &$aItem)
+    {
+        if(!$this->_isVisibleInContext($aItem))
+            return false;
+
+        if(!isLogged() || $this->_oModule->{$this->_aConnectionToFunctionCheck[$sConnection][$sAction]}($this->_aContentInfo) !== CHECK_ACTION_RESULT_ALLOWED)
+            return false;
+
+        $iContentProfile = $this->_oContentProfile->id();
+
+        if($this->_bIsApi) {
+            $sTitle = $this->_oModule->getMenuItemTitleByConnection($sConnection, $sAction, $iContentProfile);
+            if(empty($sTitle))
+                return false;
+
+            return $this->_getMenuItemAPI($aItem, ['display' => 'element'], [
+                'title' => $sTitle,
+                'data' => [
+                    'type' => 'connections',
+                    'o' => $sConnection,
+                    'a' => $sAction,
+                    'iid' => bx_get_logged_profile_id(),
+                    'cid' => $iContentProfile,
+                    'title' => $sTitle,
+                    'primary' => !empty($aItem['primary']),
+                ]
+            ]);
+        }
+
+        $oObject = BxDolConnection::getObjectInstance($sConnection);
+        if(!$oObject)
+            return false;
+
+        $aObjectOptions = [
+            'uniq_id' => genRndPwd(8, false),
+            'show_do_as_button' => true,
+            'show_do_label' => true
+        ];
+        return ($mixedItem = $oObject->getElement($iContentProfile, false, $aObjectOptions)) && ($mixedItem = $this->getUnitMetaItemCustom($mixedItem)) ? [$mixedItem, 'bx-menu-item-button'] : false;
+    }
+
     protected function _getMenuItemRecommendation($sObject, $sAction, $aItem)
     protected function _getMenuItemRecommendation($sObject, $sAction, $aItem)
     {
     {
         if(!isLogged() || !$this->_isVisibleInContext($aItem))
         if(!isLogged() || !$this->_isVisibleInContext($aItem))

+ 2 - 1
modules/boonex/artificer/data/template/mod_profile/css/main.css

@@ -141,7 +141,8 @@ p.bx-base-pofile-unit-thumb.bx-def-ava-big-size {
 .bx-base-pofile-unit-with-cover .bx-base-general-unit-meta ul.bx-menu-custom.bx-menu-custom-hor .bx-menu-item-nl ~ li {
 .bx-base-pofile-unit-with-cover .bx-base-general-unit-meta ul.bx-menu-custom.bx-menu-custom-hor .bx-menu-item-nl ~ li {
     margin-top: 0.5rem;
     margin-top: 0.5rem;
 }
 }
-.bx-base-pofile-unit-with-cover .bx-base-general-unit-meta ul.bx-menu-custom.bx-menu-custom-hor .bx-menu-item-nl ~ li .bx-base-profile-unit-meta-item {
+.bx-base-pofile-unit-with-cover .bx-base-general-unit-meta ul.bx-menu-custom.bx-menu-custom-hor .bx-menu-item-nl ~ li .bx-base-profile-unit-meta-item,
+.bx-base-pofile-unit-with-cover .bx-base-general-unit-meta ul.bx-menu-custom.bx-menu-custom-hor .bx-menu-item-nl ~ li .sys-action-element-holder {
     display: block;
     display: block;
     width: 100%;
     width: 100%;
     padding: 0;
     padding: 0;

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

@@ -3262,7 +3262,7 @@ If it is not enabled then please consider implement this optimization, since it
     <string name="_sys_menu_item_title_sm_befriend_sent"><![CDATA[Add friend (requested)]]></string>
     <string name="_sys_menu_item_title_sm_befriend_sent"><![CDATA[Add friend (requested)]]></string>
     <string name="_sys_menu_item_title_sm_befriend_confirm"><![CDATA[Accept friend request]]></string>
     <string name="_sys_menu_item_title_sm_befriend_confirm"><![CDATA[Accept friend request]]></string>
     <string name="_sys_menu_item_title_sm_unfriend"><![CDATA[Unfriend]]></string>
     <string name="_sys_menu_item_title_sm_unfriend"><![CDATA[Unfriend]]></string>
-    <string name="_sys_menu_item_title_sm_unfriend_cancel"><![CDATA[Cancel friend request]]></string>
+    <string name="_sys_menu_item_title_sm_unfriend_cancel"><![CDATA[Cancel request]]></string>
     <string name="_sys_menu_item_title_sm_unfriend_reject"><![CDATA[Reject friend request]]></string>
     <string name="_sys_menu_item_title_sm_unfriend_reject"><![CDATA[Reject friend request]]></string>
     <string name="_sys_menu_item_title_sm_join_paid"><![CDATA[Pay & Join]]></string>
     <string name="_sys_menu_item_title_sm_join_paid"><![CDATA[Pay & Join]]></string>
     <string name="_sys_menu_item_title_sm_join"><![CDATA[Join]]></string>
     <string name="_sys_menu_item_title_sm_join"><![CDATA[Join]]></string>
@@ -3402,6 +3402,7 @@ If it is not enabled then please consider implement this optimization, since it
     <string name="_sys_menu_item_title_system_sm_members"><![CDATA[Members]]></string>
     <string name="_sys_menu_item_title_system_sm_members"><![CDATA[Members]]></string>
     <string name="_sys_menu_item_title_system_sm_membership"><![CDATA[Membership]]></string>
     <string name="_sys_menu_item_title_system_sm_membership"><![CDATA[Membership]]></string>
     <string name="_sys_menu_item_title_system_sm_subscribers"><![CDATA[Followers]]></string>
     <string name="_sys_menu_item_title_system_sm_subscribers"><![CDATA[Followers]]></string>
+    <string name="_sys_menu_item_title_system_sm_subscriptions"><![CDATA[Following]]></string>
     <string name="_sys_menu_item_title_system_sm_relations"><![CDATA[Relations]]></string>
     <string name="_sys_menu_item_title_system_sm_relations"><![CDATA[Relations]]></string>
     <string name="_sys_menu_item_title_system_sm_country"><![CDATA[Country]]></string>
     <string name="_sys_menu_item_title_system_sm_country"><![CDATA[Country]]></string>
     <string name="_sys_menu_item_title_system_sm_country_city"><![CDATA[Country and City]]></string>
     <string name="_sys_menu_item_title_system_sm_country_city"><![CDATA[Country and City]]></string>

+ 6 - 4
modules/boonex/persons/install/sql/enable.sql

@@ -356,10 +356,12 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_persons_snippet_meta', 'bx_persons', 'subscribers', '_sys_menu_item_title_system_sm_subscribers', '_sys_menu_item_title_sm_subscribers', '', '', '', '', '', 2147483647, 'recom_friends', 1, 0, 1, 40),
 ('bx_persons_snippet_meta', 'bx_persons', 'subscribers', '_sys_menu_item_title_system_sm_subscribers', '_sys_menu_item_title_sm_subscribers', '', '', '', '', '', 2147483647, 'recom_friends', 1, 0, 1, 40),
 ('bx_persons_snippet_meta', 'bx_persons', 'membership', '_sys_menu_item_title_system_sm_membership', '_sys_menu_item_title_sm_membership', '', '', '', '', '', 2147483647, '', 0, 0, 1, 50),
 ('bx_persons_snippet_meta', 'bx_persons', 'membership', '_sys_menu_item_title_system_sm_membership', '_sys_menu_item_title_sm_membership', '', '', '', '', '', 2147483647, '', 0, 0, 1, 50),
 ('bx_persons_snippet_meta', 'bx_persons', 'nl', '_sys_menu_item_title_system_sm_nl', '_sys_menu_item_title_sm_nl', '', '', '', '', '', 2147483647, '', 1, 0, 1, 55),
 ('bx_persons_snippet_meta', 'bx_persons', 'nl', '_sys_menu_item_title_system_sm_nl', '_sys_menu_item_title_sm_nl', '', '', '', '', '', 2147483647, '', 1, 0, 1, 55),
-('bx_persons_snippet_meta', 'bx_persons', 'befriend', '_sys_menu_item_title_system_sm_befriend', '_sys_menu_item_title_sm_befriend', '', '', '', '', '', 2147483647, 'recom_subscriptions', 1, 0, 1, 60),
-('bx_persons_snippet_meta', 'bx_persons', 'unfriend', '_sys_menu_item_title_system_sm_unfriend', '_sys_menu_item_title_sm_unfriend', '', '', '', '', '', 2147483647, 'recom_friends,recom_subscriptions', 1, 0, 1, 65),
-('bx_persons_snippet_meta', 'bx_persons', 'subscribe', '_sys_menu_item_title_system_sm_subscribe', '_sys_menu_item_title_sm_subscribe', '', '', '', '', '', 2147483647, 'recom_friends', 1, 0, 1, 70),
-('bx_persons_snippet_meta', 'bx_persons', 'unsubscribe', '_sys_menu_item_title_system_sm_unsubscribe', '_sys_menu_item_title_sm_unsubscribe', '', '', '', '', '', 2147483647, 'recom_friends,recom_subscriptions', 1, 0, 1, 75),
+('bx_persons_snippet_meta', 'bx_persons', 'obj-friends', '_sys_menu_item_title_system_sm_friends', '', '', '', '', '', '', 2147483647, 'recom_friends,recom_subscriptions', 1, 0, 1, 60),
+('bx_persons_snippet_meta', 'bx_persons', 'befriend', '_sys_menu_item_title_system_sm_befriend', '_sys_menu_item_title_sm_befriend', '', '', '', '', '', 2147483647, 'all!recom_friends', 1, 0, 1, 62),
+('bx_persons_snippet_meta', 'bx_persons', 'unfriend', '_sys_menu_item_title_system_sm_unfriend', '_sys_menu_item_title_sm_unfriend', '', '', '', '', '', 2147483647, 'recom_friends,recom_subscriptions', 0, 0, 1, 64),
+('bx_persons_snippet_meta', 'bx_persons', 'obj-subscriptions', '_sys_menu_item_title_system_sm_subscriptions', '', '', '', '', '', '', 2147483647, 'recom_friends,recom_subscriptions', 1, 0, 1, 70),
+('bx_persons_snippet_meta', 'bx_persons', 'subscribe', '_sys_menu_item_title_system_sm_subscribe', '_sys_menu_item_title_sm_subscribe', '', '', '', '', '', 2147483647, 'all!recom_subscriptions', 1, 0, 1, 72),
+('bx_persons_snippet_meta', 'bx_persons', 'unsubscribe', '_sys_menu_item_title_system_sm_unsubscribe', '_sys_menu_item_title_sm_unsubscribe', '', '', '', '', '', 2147483647, 'recom_friends,recom_subscriptions', 0, 0, 1, 74),
 ('bx_persons_snippet_meta', 'bx_persons', 'ignore-befriend', '_sys_menu_item_title_system_sm_ignore_befriend', '_sys_menu_item_title_sm_ignore', '', '', '', '', '', 2147483647, 'all!recom_friends', 1, 0, 1, 80),
 ('bx_persons_snippet_meta', 'bx_persons', 'ignore-befriend', '_sys_menu_item_title_system_sm_ignore_befriend', '_sys_menu_item_title_sm_ignore', '', '', '', '', '', 2147483647, 'all!recom_friends', 1, 0, 1, 80),
 ('bx_persons_snippet_meta', 'bx_persons', 'ignore-subscribe', '_sys_menu_item_title_system_sm_ignore_subscribe', '_sys_menu_item_title_sm_ignore', '', '', '', '', '', 2147483647, 'all!recom_subscriptions', 1, 0, 1, 85);
 ('bx_persons_snippet_meta', 'bx_persons', 'ignore-subscribe', '_sys_menu_item_title_system_sm_ignore_subscribe', '_sys_menu_item_title_sm_ignore', '', '', '', '', '', 2147483647, 'all!recom_subscriptions', 1, 0, 1, 85);
 
 

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

@@ -3232,7 +3232,7 @@
     <string name="_sys_menu_item_title_sm_befriend_sent"><![CDATA[Добавить в друзья (запрошено)]]></string>
     <string name="_sys_menu_item_title_sm_befriend_sent"><![CDATA[Добавить в друзья (запрошено)]]></string>
     <string name="_sys_menu_item_title_sm_befriend_confirm"><![CDATA[Принять запрос о дружбе]]></string>
     <string name="_sys_menu_item_title_sm_befriend_confirm"><![CDATA[Принять запрос о дружбе]]></string>
     <string name="_sys_menu_item_title_sm_unfriend"><![CDATA[Удалить из друзей]]></string>
     <string name="_sys_menu_item_title_sm_unfriend"><![CDATA[Удалить из друзей]]></string>
-    <string name="_sys_menu_item_title_sm_unfriend_cancel"><![CDATA[Отменить запрос о дружбе]]></string>
+    <string name="_sys_menu_item_title_sm_unfriend_cancel"><![CDATA[Отменить запрос]]></string>
     <string name="_sys_menu_item_title_sm_unfriend_reject"><![CDATA[Отвергнуть запрос о дружбе]]></string>
     <string name="_sys_menu_item_title_sm_unfriend_reject"><![CDATA[Отвергнуть запрос о дружбе]]></string>
     <string name="_sys_menu_item_title_sm_join_paid"><![CDATA[Оплатить и присоединиться]]></string>
     <string name="_sys_menu_item_title_sm_join_paid"><![CDATA[Оплатить и присоединиться]]></string>
     <string name="_sys_menu_item_title_sm_join"><![CDATA[Присоединиться]]></string>
     <string name="_sys_menu_item_title_sm_join"><![CDATA[Присоединиться]]></string>
@@ -3370,6 +3370,7 @@
     <string name="_sys_menu_item_title_system_sm_members"><![CDATA[Участники]]></string>
     <string name="_sys_menu_item_title_system_sm_members"><![CDATA[Участники]]></string>
     <string name="_sys_menu_item_title_system_sm_membership"><![CDATA[Членство]]></string>
     <string name="_sys_menu_item_title_system_sm_membership"><![CDATA[Членство]]></string>
     <string name="_sys_menu_item_title_system_sm_subscribers"><![CDATA[Подписки]]></string>
     <string name="_sys_menu_item_title_system_sm_subscribers"><![CDATA[Подписки]]></string>
+    <string name="_sys_menu_item_title_system_sm_subscriptions"><![CDATA[Подписки]]></string>
     <string name="_sys_menu_item_title_system_sm_relations"><![CDATA[Связи]]></string>
     <string name="_sys_menu_item_title_system_sm_relations"><![CDATA[Связи]]></string>
     <string name="_sys_menu_item_title_system_sm_ignore"><![CDATA[Игнорировать рекомендацию]]></string>
     <string name="_sys_menu_item_title_system_sm_ignore"><![CDATA[Игнорировать рекомендацию]]></string>
     <string name="_sys_menu_item_title_system_sm_ignore_befriend"><![CDATA[Игнорировать рекомендацию: Дружба]]></string>
     <string name="_sys_menu_item_title_system_sm_ignore_befriend"><![CDATA[Игнорировать рекомендацию: Дружба]]></string>

+ 3 - 3
template/connection_element.html

@@ -1,9 +1,9 @@
 <div id="__html_id__" class="sys-action __style_prefix__ __class__ flex items-center whitespace-nowrap">
 <div id="__html_id__" class="sys-action __style_prefix__ __class__ flex items-center whitespace-nowrap">
-    <div class="sys-action-cnt __style_prefix__-cnt __style_prefix__-do bx-def-valign-center bx-clearfix">
+    <div class="sys-action-cnt __style_prefix__-cnt __style_prefix__-do bx-def-valign-center bx-clearfix w-full">
         <bx_if:show_do>
         <bx_if:show_do>
             <div class="sys-action-element-holder __style_prefix__-element-holder">
             <div class="sys-action-element-holder __style_prefix__-element-holder">
                 <bx_if:show_action>
                 <bx_if:show_action>
-                    <a class="__style_prefix__-do__class__ flex" href="javascript:void(0)" onclick="javascript:bx_conn_action(this, '__object__', '__action__', __profile_id__)">
+                    <a class="__style_prefix__-do__class__ flex" href="javascript:void(0)" onclick="javascript:__js_object__.connect(this, '__action__', __profile_id__)">
                         <div class="sys-action-do __style_prefix__-do bx-def-valign-center">
                         <div class="sys-action-do __style_prefix__-do bx-def-valign-center">
                             <bx_if:show_icon><span class="sys-action-do-icon __style_prefix__-do-icon bx-def-align-center">__icon__</span></bx_if:show_icon>
                             <bx_if:show_icon><span class="sys-action-do-icon __style_prefix__-do-icon bx-def-align-center">__icon__</span></bx_if:show_icon>
                             <bx_if:show_text><span class="sys-action-do-text __style_prefix__-do-text bx-def-margin-sec-left-auto bx-dir">__text__</span></bx_if:show_text>
                             <bx_if:show_text><span class="sys-action-do-text __style_prefix__-do-text bx-def-margin-sec-left-auto bx-dir">__text__</span></bx_if:show_text>
@@ -11,7 +11,7 @@
                     </a>
                     </a>
                 </bx_if:show_action>
                 </bx_if:show_action>
                 <bx_if:show_actions>
                 <bx_if:show_actions>
-                    <a class="__style_prefix__-do__class__ flex" href="javascript:void(0)" onclick="javascript:bx_menu_popup_inline('#__html_id_popup__', this)">
+                    <a class="__style_prefix__-do__class__ flex" href="javascript:void(0)" onclick="javascript:__js_object__.toggleConnectPopup(this, __profile_id__)">
                         <div class="sys-action-do __style_prefix__-do bx-def-valign-center">
                         <div class="sys-action-do __style_prefix__-do bx-def-valign-center">
                             <bx_if:show_icon><span class="sys-action-do-icon __style_prefix__-do-icon bx-def-align-center">__icon__</span></bx_if:show_icon>
                             <bx_if:show_icon><span class="sys-action-do-icon __style_prefix__-do-icon bx-def-align-center">__icon__</span></bx_if:show_icon>
                             <bx_if:show_text><span class="sys-action-do-text __style_prefix__-do-text bx-def-margin-sec-left-auto bx-dir">__text__</span></bx_if:show_text>
                             <bx_if:show_text><span class="sys-action-do-text __style_prefix__-do-text bx-def-margin-sec-left-auto bx-dir">__text__</span></bx_if:show_text>

+ 103 - 49
template/scripts/BxBaseConnection.php

@@ -55,6 +55,7 @@ class BxBaseConnection extends BxDolConnection
         $this->_sTmplContentCounter = $this->_oTemplate->getHtml('connection_counter.html');
         $this->_sTmplContentCounter = $this->_oTemplate->getHtml('connection_counter.html');
 
 
         $this->_aElementDefaults = [
         $this->_aElementDefaults = [
+            'uniq_id' => '',
             'dynamic_mode' => true,
             'dynamic_mode' => true,
             'show_do_as_button_small' => false,
             'show_do_as_button_small' => false,
             'show_do_as_button' => false,
             'show_do_as_button' => false,
@@ -71,7 +72,9 @@ class BxBaseConnection extends BxDolConnection
         $sContentType = bx_process_input(bx_get('content_type'));
         $sContentType = bx_process_input(bx_get('content_type'));
         $iProfileId = (int)bx_get('id');
         $iProfileId = (int)bx_get('id');
         $bIsMutual = (bool)bx_get('mutual');
         $bIsMutual = (bool)bx_get('mutual');
-        return $this->_getConnected ($sContentType, $iProfileId, $bIsMutual, $iStart, $iPerPage);
+        $aRequestParamsData = $this->_getRequestParamsData();
+
+        return $this->_getConnected ($sContentType, $iProfileId, $bIsMutual, $iStart, $iPerPage, $aRequestParamsData);
     }
     }
     
     
     public function actionGetUsers ($iStart = 0, $iPerPage = 0)
     public function actionGetUsers ($iStart = 0, $iPerPage = 0)
@@ -81,28 +84,29 @@ class BxBaseConnection extends BxDolConnection
         $bIsMutual = (bool)bx_get('mutual');
         $bIsMutual = (bool)bx_get('mutual');
         $iStart = (int)bx_get('start');
         $iStart = (int)bx_get('start');
         $iPerPage = (int)bx_get('per_page');
         $iPerPage = (int)bx_get('per_page');
+        $aRequestParamsData = $this->_getRequestParamsData();
 
 
         return [
         return [
-            'content' => $this->_getConnected($sContentType, $iProfileId, $bIsMutual, $iStart, $iPerPage),
-            'eval' => $this->getJsObjectName($iProfileId) . '.onGetUsers(oData)'
+            'content' => $this->_getConnected($sContentType, $iProfileId, $bIsMutual, $iStart, $iPerPage, $aRequestParamsData),
+            'eval' => $this->getJsObjectName($iProfileId, $aRequestParamsData) . '.onGetUsers(oData)'
         ];
         ];
     }
     }
     
     
-    public function getJsObjectName($iProfileId)
+    public function getJsObjectName($iProfileId, $aParams = [])
     {
     {
-        return $this->_sJsObjName . $iProfileId;
+        return $this->_sJsObjName . (!empty($aParams['uniq_id']) ? $aParams['uniq_id'] : '') . $iProfileId;
     }
     }
 
 
     public function getElement($iContent, $iInitiator = false, $aParams = [])
     public function getElement($iContent, $iInitiator = false, $aParams = [])
     {
     {
-    	$aParams = array_merge($this->_aElementDefaults, $aParams);
-    	$bDynamicMode = isset($aParams['dynamic_mode']) && $aParams['dynamic_mode'] === true;
+    	$aParams = $this->_prepareParamsData($aParams);
 
 
+    	$bDynamicMode = isset($aParams['dynamic_mode']) && (bool)$aParams['dynamic_mode'] === true;
         $bShowDo = !isset($aParams['show_do']) || (bool)$aParams['show_do'] === true;
         $bShowDo = !isset($aParams['show_do']) || (bool)$aParams['show_do'] === true;
-        $bShowDoAsButtonSmall = isset($aParams['show_do_as_button_small']) && $aParams['show_do_as_button_small'] == true;
-        $bShowDoAsButton = !$bShowDoAsButtonSmall && isset($aParams['show_do_as_button']) && $aParams['show_do_as_button'] == true;
-        $bShowDoLabel = isset($aParams['show_do_label']) && $aParams['show_do_label'] === true;
-        $bShowCounter = isset($aParams['show_counter']) && $aParams['show_counter'] === true;
+        $bShowDoAsButtonSmall = isset($aParams['show_do_as_button_small']) && (bool)$aParams['show_do_as_button_small'] === true;
+        $bShowDoAsButton = !$bShowDoAsButtonSmall && isset($aParams['show_do_as_button']) && (bool)$aParams['show_do_as_button'] === true;
+        $bShowDoLabel = isset($aParams['show_do_label']) && (bool)$aParams['show_do_label'] === true;
+        $bShowCounter = isset($aParams['show_counter']) && (bool)$aParams['show_counter'] === true;
 
 
         if(!$iInitiator)
         if(!$iInitiator)
             $iInitiator = bx_get_logged_profile_id();
             $iInitiator = bx_get_logged_profile_id();
@@ -110,12 +114,12 @@ class BxBaseConnection extends BxDolConnection
             return '';
             return '';
 
 
         $aActions = $this->_getActions($iInitiator, $iContent, $aParams);
         $aActions = $this->_getActions($iInitiator, $iContent, $aParams);
-
         $iCount = $this->_getCounterCount($iContent, $this->_bMutual, $aParams);
         $iCount = $this->_getCounterCount($iContent, $this->_bMutual, $aParams);
-
         if((empty($aActions['items']) || !is_array($aActions['items'])) && (!$bShowCounter || !$iCount))
         if((empty($aActions['items']) || !is_array($aActions['items'])) && (!$bShowCounter || !$iCount))
             return '';        
             return '';        
 
 
+        $sJsObject = $this->getJsObjectName($iContent, $aParams);
+
         $sClassDo = '';
         $sClassDo = '';
         if($bShowDoAsButton)
         if($bShowDoAsButton)
             $sClassDo = ' bx-btn';
             $sClassDo = ' bx-btn';
@@ -128,8 +132,8 @@ class BxBaseConnection extends BxDolConnection
 
 
             $aTmplVarsAction = array_merge([
             $aTmplVarsAction = array_merge([
                 'style_prefix' => $this->_sStylePrefix,
                 'style_prefix' => $this->_sStylePrefix,
+                'js_object' => $sJsObject,
                 'class' => $sClassDo,
                 'class' => $sClassDo,
-                'object' => $this->_sObject, 
                 'action' => $aAction['name'],
                 'action' => $aAction['name'],
                 'profile_id' => $iContent,
                 'profile_id' => $iContent,
                 'title' => $bShowDoLabel && !empty($aAction['title']) ? _t($aAction['title']) : ''
                 'title' => $bShowDoLabel && !empty($aAction['title']) ? _t($aAction['title']) : ''
@@ -148,7 +152,7 @@ class BxBaseConnection extends BxDolConnection
                             'name' => $aItem['name'], 
                             'name' => $aItem['name'], 
                             'icon' => $this->_getActionIcon($aItem, $aParams), 
                             'icon' => $this->_getActionIcon($aItem, $aParams), 
                             'link' => 'javascript:void(0)', 
                             'link' => 'javascript:void(0)', 
-                            'onclick' => "javascript:bx_conn_action(this, '" . $this->_sObject . "', '" . $aItem['name'] . "', " . $iContent . ")", 
+                            'onclick' => "javascript:" . $sJsObject . ".connect(this, '" . $aItem['name'] . "', " . $iContent . ")", 
                             'target' => '_self', 
                             'target' => '_self', 
                             'title' => !empty($aItem['title']) ? _t($aItem['title']) : '', 
                             'title' => !empty($aItem['title']) ? _t($aItem['title']) : '', 
                             'active' => 1
                             'active' => 1
@@ -161,8 +165,9 @@ class BxBaseConnection extends BxDolConnection
 
 
             $aTmplVarsActions = array_merge([
             $aTmplVarsActions = array_merge([
                 'style_prefix' => $this->_sStylePrefix,
                 'style_prefix' => $this->_sStylePrefix,
+                'js_object' => $sJsObject,
                 'class' => $sClassDo,
                 'class' => $sClassDo,
-                'html_id_popup' => $sHtmlIdDoPopup,
+                'profile_id' => $iContent,
                 'do_popup' => $this->_oFunctions->transBox($sHtmlIdDoPopup, $oMenu->getCode(), true),
                 'do_popup' => $this->_oFunctions->transBox($sHtmlIdDoPopup, $oMenu->getCode(), true),
             ], $this->_getTmplVarsAction([
             ], $this->_getTmplVarsAction([
                 'name' => $aActions['name'],
                 'name' => $aActions['name'],
@@ -204,25 +209,24 @@ class BxBaseConnection extends BxDolConnection
 
 
     public function getCounter($iProfileId, $bIsMutual = false, $aParams = [])
     public function getCounter($iProfileId, $bIsMutual = false, $aParams = [])
     {
     {
+        $aParams = $this->_prepareParamsData($aParams);
+
         if(!$iProfileId)
         if(!$iProfileId)
             $iProfileId = bx_get_logged_profile_id();
             $iProfileId = bx_get_logged_profile_id();
 
 
         if($this->_aObject['type'] != 'mutual')
         if($this->_aObject['type'] != 'mutual')
             $bIsMutual = false;
             $bIsMutual = false;
 
 
-        $aParams = array_merge($this->_aElementDefaults, (!empty($aParams) ? $aParams : []));
-
         $iCount = !empty($aParams['count']) ? $aParams['count'] : $this->_getCounterCount($iProfileId, $bIsMutual, $aParams);
         $iCount = !empty($aParams['count']) ? $aParams['count'] : $this->_getCounterCount($iProfileId, $bIsMutual, $aParams);
         if(!$iCount)
         if(!$iCount)
             return '';
             return '';
 
 
-        $sJsObject = $this->getJsObjectName($iProfileId);
-        $sHtmlIdCounter = $this->_aHtmlIds['counter'] . $iProfileId;
+        $bDynamicMode = isset($aParams['dynamic_mode']) && (bool)$aParams['dynamic_mode'] === true;
+        $bShowDoAsButtonSmall = isset($aParams['show_do_as_button_small']) && (bool)$aParams['show_do_as_button_small'] === true;
+        $bShowDoAsButton = !$bShowDoAsButtonSmall && isset($aParams['show_do_as_button']) && (bool)$aParams['show_do_as_button'] === true;
+        $bShowScript = !isset($aParams['show_script']) || (bool)$aParams['show_script'] === true;
 
 
-        $bDynamicMode = isset($aParams['dynamic_mode']) && $aParams['dynamic_mode'] === true;
-        $bShowDoAsButtonSmall = isset($aParams['show_do_as_button_small']) && $aParams['show_do_as_button_small'] === true;
-        $bShowDoAsButton = !$bShowDoAsButtonSmall && isset($aParams['show_do_as_button']) && $aParams['show_do_as_button'] === true;
-        $bShowScript = !isset($aParams['show_script']) || $aParams['show_script'] == true;
+        $sJsObject = $this->getJsObjectName($iProfileId, $aParams);
 
 
         $sClass = $this->_sStylePrefix . '-counter';
         $sClass = $this->_sStylePrefix . '-counter';
         if($bShowDoAsButtonSmall)
         if($bShowDoAsButtonSmall)
@@ -230,37 +234,38 @@ class BxBaseConnection extends BxDolConnection
         if($bShowDoAsButton)
         if($bShowDoAsButton)
             $sClass .= ' bx-btn-height';
             $sClass .= ' bx-btn-height';
 
 
+        $sHtmlIdCounter = $this->_aHtmlIds['counter'] . $iProfileId;
         $sContent = $this->_getCounterLabel($iCount, $iProfileId, $bIsMutual, $aParams);
         $sContent = $this->_getCounterLabel($iCount, $iProfileId, $bIsMutual, $aParams);
 
 
         $this->_oTemplate->addCss(['connection.css']);
         $this->_oTemplate->addCss(['connection.css']);
-        return $this->_oTemplate->parseHtmlByContent($this->_getTmplContentCounter(), array(
+        return $this->_oTemplate->parseHtmlByContent($this->_getTmplContentCounter(), [
             'html_id' => $sHtmlIdCounter,
             'html_id' => $sHtmlIdCounter,
             'style_prefix' => $this->_sStylePrefix,
             'style_prefix' => $this->_sStylePrefix,
-            'bx_if:show_text' => array(
+            'bx_if:show_text' => [
                 'condition' => false,
                 'condition' => false,
-                'content' => array(
+                'content' => [
                     'class' => $sClass,
                     'class' => $sClass,
-                    'bx_repeat:attrs' => array(
-                        array('key' => 'id', 'value' => $sHtmlIdCounter),
-                    ),
+                    'bx_repeat:attrs' => [
+                        ['key' => 'id', 'value' => $sHtmlIdCounter],
+                    ],
                     'content' => $sContent
                     'content' => $sContent
-                )
-            ),
-            'bx_if:show_link' => array(
+                ]
+            ],
+            'bx_if:show_link' => [
                 'condition' => true,
                 'condition' => true,
-                'content' => array(
+                'content' => [
                     'class' => $sClass,
                     'class' => $sClass,
-                    'bx_repeat:attrs' => array(
-                        array('key' => 'id', 'value' => $sHtmlIdCounter),
-                        array('key' => 'href', 'value' => 'javascript:void(0)'),
-                        array('key' => 'onclick', 'value' => 'javascript:' . $sJsObject . '.toggleByPopup(this)'),
-                        array('key' => 'title', 'value' => _t('_sys_conn_do_by'))
-                    ),
+                    'bx_repeat:attrs' => [
+                        ['key' => 'id', 'value' => $sHtmlIdCounter],
+                        ['key' => 'href', 'value' => 'javascript:void(0)'],
+                        ['key' => 'onclick', 'value' => 'javascript:' . $sJsObject . '.toggleByPopup(this)'],
+                        ['key' => 'title', 'value' => _t('_sys_conn_do_by')]
+                    ],
                     'content' => $sContent
                     'content' => $sContent
-                )
-            ),
+                ]
+            ],
             'script' => $bShowScript ? $this->_getJsScript($iProfileId, $bIsMutual, $aParams) : ''
             'script' => $bShowScript ? $this->_getJsScript($iProfileId, $bIsMutual, $aParams) : ''
-        ));
+        ]);
     }
     }
 
 
     public function getCounterAPI($iProfileId, $bIsMutual = false, $aParams = [])
     public function getCounterAPI($iProfileId, $bIsMutual = false, $aParams = [])
@@ -296,18 +301,34 @@ class BxBaseConnection extends BxDolConnection
         return $aProfiles;
         return $aProfiles;
     }
     }
 
 
-    protected function _getJsScript($iProfileId, $bIsMutual = false, $aParams = [])
+    protected function _action($iInitiator, $iContent, $sMethod, $sErrorKey, $isMutual = false, $isInvert = false)
     {
     {
-        $sJsObject = $this->getJsObjectName($iProfileId);
+        $aResult = parent::_action($iInitiator, $iContent, $sMethod, $sErrorKey, $isMutual, $isInvert);
+        if(!$aResult['err'] && ($sOut = bx_get('out')) !== false && $sOut == 'eval') {
+            $aRequestParamsData = $this->_getRequestParamsData();
+
+            $aResult = array_merge($aResult, [
+                'data' => $this->getElement($this->_iContent, $this->_iInitiator, $aRequestParamsData),
+                'eval' => $this->getJsObjectName($this->_iContent, $aRequestParamsData) . '.onConnect(oData)',
+            ]);
+        }
+
+        return $aResult;
+    }
+
+    protected function _getJsScript($iContentId, $bIsMutual = false, $aParams = [])
+    {
+        $sJsObject = $this->getJsObjectName($iContentId, $aParams);
 
 
         $aParamsJs = [
         $aParamsJs = [
             'sSystem' => $this->_sObject,
             'sSystem' => $this->_sObject,
-            'iObjId' => $iProfileId,
+            'iContentId' => $iContentId,
             'bIsMutual' => $bIsMutual ? 1 : 0,
             'bIsMutual' => $bIsMutual ? 1 : 0,
             'sObjName' => $sJsObject,
             'sObjName' => $sJsObject,
             'sRootUrl' => BX_DOL_URL_ROOT,
             'sRootUrl' => BX_DOL_URL_ROOT,
             'sStylePrefix' => $this->_sStylePrefix,
             'sStylePrefix' => $this->_sStylePrefix,
-            'aHtmlIds' => $this->_aHtmlIds
+            'aHtmlIds' => $this->_aHtmlIds,
+            'aRequestParams' => $this->_prepareRequestParamsData($aParams)
         ];
         ];
         if(($sKey = 'content_type') && !empty($aParams[$sKey]))
         if(($sKey = 'content_type') && !empty($aParams[$sKey]))
             $aParamsJs['sContentType'] = $aParams[$sKey];
             $aParamsJs['sContentType'] = $aParams[$sKey];
@@ -381,7 +402,7 @@ class BxBaseConnection extends BxDolConnection
             return 'users';
             return 'users';
     }
     }
     
     
-    public function _getConnected ($sContentType, $iProfileId, $bIsMutual, $iStart = 0, $iPerPage = 0)
+    public function _getConnected ($sContentType, $iProfileId, $bIsMutual, $iStart = 0, $iPerPage = 0, $aParams = [])
     {
     {
         if ('mutual' != $this->_aObject['type'])
         if ('mutual' != $this->_aObject['type'])
             $bIsMutual = false;
             $bIsMutual = false;
@@ -392,7 +413,7 @@ class BxBaseConnection extends BxDolConnection
         $aUsers = $this->getConnectionsAsArray($sContentType, $iProfileId, null, $bIsMutual, $iStart, $iPerPage + 1);
         $aUsers = $this->getConnectionsAsArray($sContentType, $iProfileId, null, $bIsMutual, $iStart, $iPerPage + 1);
 
 
         $oPaginate = new BxTemplPaginate([
         $oPaginate = new BxTemplPaginate([
-            'on_change_page' => $this->getJsObjectName($iProfileId) . '.getUsers(this, {start}, {per_page})',
+            'on_change_page' => $this->getJsObjectName($iProfileId, $aParams) . '.getUsers(this, {start}, {per_page})',
             'start' => $iStart,
             'start' => $iStart,
             'per_page' => $iPerPage,
             'per_page' => $iPerPage,
         ]);
         ]);
@@ -481,4 +502,37 @@ class BxBaseConnection extends BxDolConnection
             ]
             ]
         ];
         ];
     }
     }
+
+    protected function _prepareParamsData($aParams)
+    {        
+        $aResult = $this->_aElementDefaults;
+        if(!empty($aParams) && is_array($aParams))
+            $aResult = array_merge($aResult, $aParams);
+
+        return $aResult;
+    }
+
+    protected function _getRequestParamsData($aKeys = [])
+    {
+        $sParams = bx_get('params');
+        if($sParams === false)
+            return [];
+
+        $aParams = [];
+        parse_str(bx_process_input($sParams), $aParams);
+
+        return $aParams;
+    }
+
+    protected function _prepareRequestParamsData($aParams, $aParamsAdd = [])
+    {
+        $aRequestParams = array_intersect_key($aParams, $this->_aElementDefaults);
+        $aRequestParams = array_merge($aRequestParams, $aParamsAdd);
+
+        foreach($aRequestParams as $sKey => $mixedValue)
+            if(is_bool($mixedValue))
+                $aRequestParams[$sKey] = (int)$mixedValue;
+
+        return $aRequestParams;
+    }
 }
 }

+ 1 - 5
template/scripts/BxBaseConnectionFriend.php

@@ -29,12 +29,7 @@ class BxBaseConnectionFriend extends BxDolConnectionFriend
         $aActions = [];
         $aActions = [];
 
 
         if($this->isConnectedNotMutual($iInitiator, $iContent)) {
         if($this->isConnectedNotMutual($iInitiator, $iContent)) {
-            $sName = 'default';
-            $sTitle = $this->_aT['do_initiator'];
             $aActions = [[
             $aActions = [[
-                'name' => 'add',
-                'title' => ($sKey = 'txt_befriend_sent') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_befriend_sent'
-            ], [
                 'name' => 'remove',
                 'name' => 'remove',
                 'title' => ($sKey = 'txt_unfriend_cancel') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_unfriend_cancel'
                 'title' => ($sKey = 'txt_unfriend_cancel') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_unfriend_cancel'
             ]];
             ]];
@@ -51,6 +46,7 @@ class BxBaseConnectionFriend extends BxDolConnectionFriend
             ]];
             ]];
         }
         }
         else if($this->isConnected($iInitiator, $iContent, true)) {
         else if($this->isConnected($iInitiator, $iContent, true)) {
+            $sName = 'default';
             $sTitle = $this->_aT['do_initiator'];
             $sTitle = $this->_aT['do_initiator'];
             $aActions = [[
             $aActions = [[
                 'name' => 'remove',
                 'name' => 'remove',

+ 2 - 1
template/scripts/BxBaseConnectionRelation.php

@@ -51,6 +51,7 @@ class BxBaseConnectionRelation extends BxDolConnectionRelation
             $aRelations = $this->getRelations($iInitiator, $iContent, $aSuggestions);
             $aRelations = $this->getRelations($iInitiator, $iContent, $aSuggestions);
             $bSuggestions = !empty($aSuggestions) && is_array($aSuggestions);
             $bSuggestions = !empty($aSuggestions) && is_array($aSuggestions);
 
 
+            $sJsObject = $this->getJsObjectName($iContent, $aParams);
             $sClassHidden = 'bx-menu-add-relation-hidden';
             $sClassHidden = 'bx-menu-add-relation-hidden';
             foreach($aRelations as $iId => $aRelation) {
             foreach($aRelations as $iId => $aRelation) {
                 $aActions[] = [
                 $aActions[] = [
@@ -60,7 +61,7 @@ class BxBaseConnectionRelation extends BxDolConnectionRelation
                     'title' => _t($aRelation[BX_DATA_VALUES_DEFAULT]),
                     'title' => _t($aRelation[BX_DATA_VALUES_DEFAULT]),
                     'icon' => '',
                     'icon' => '',
                     'link' => 'javascript:void(0);',
                     'link' => 'javascript:void(0);',
-                    'onclick' => "bx_conn_action(this, '" . $this->_sObject . "', 'add', " . bx_js_string(json_encode(['content' => $iContent, 'relation' => $iId])) . ")"
+                    'onclick' => $sJsObject . ".connect(this, 'add', " . bx_js_string(json_encode(['content' => $iContent, 'relation' => $iId])) . ")"
                 ];
                 ];
             }
             }