Bladeren bron

Ticket #1907 - improvements.

AntonLV 7 jaren geleden
bovenliggende
commit
0ae22caf29

+ 1 - 3
inc/classes/BxDolGridRelatedMe.php

@@ -53,9 +53,7 @@ class BxDolGridRelatedMe extends BxDolGridConnectionIn
 
     protected function _getCellRelation($mixedValue, $sKey, $aField, $aRow)
     {
-        $aRelations = BxDolFormQuery::getDataItems('sys_relations');
-
-        return parent::_getCellDefault ($aRelations[$mixedValue], $sKey, $aField, $aRow);
+        return parent::_getCellDefault($this->_oConnection->getRelationTranslation($mixedValue), $sKey, $aField, $aRow);
     }
 
     protected function _getActionConfirm($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())

+ 1 - 3
inc/classes/BxDolGridRelations.php

@@ -18,9 +18,7 @@ class BxDolGridRelations extends BxDolGridConnectionOut
 
     protected function _getCellRelation ($mixedValue, $sKey, $aField, $aRow)
     {
-        $aRelations = BxDolFormQuery::getDataItems('sys_relations');
-
-        return parent::_getCellDefault ($aRelations[$mixedValue], $sKey, $aField, $aRow);
+        return parent::_getCellDefault($this->_oConnection->getRelationTranslation($mixedValue), $sKey, $aField, $aRow);
     }
 
     protected function _getCellMutual($mixedValue, $sKey, $aField, $aRow)

+ 65 - 1
inc/classes/BxDolRelation.php

@@ -9,11 +9,17 @@
 
 class BxDolRelation extends BxDolConnection
 {
+    protected $_sParamEnabled;
+    protected $_sPreList;
+
     protected function __construct($aObject)
     {
         parent::__construct($aObject);
 
         $this->_oQuery = new BxDolRelationQuery($aObject);
+
+        $this->_sParamEnabled = 'sys_relations';
+        $this->_sPreList = 'sys_relations';
     }
 
     /**
@@ -156,12 +162,63 @@ class BxDolRelation extends BxDolConnection
      */
     public function checkAllowedConnect($iInitiator, $iContent, $isPerformAction = false, $isMutual = false, $isInvertResult = false, $isSwap = false)
     {
-        if(!BxDolConnection::getObjectInstance('sys_profiles_friends')->isConnected($iInitiator, $iContent, true))
+        if(!$this->isRelationAvailable($iInitiator, $iContent))
             return _t('_sys_txt_access_denied');
 
+        $mixedResult = $this->checkAllowedConnectCustom($iInitiator, $iContent, $isPerformAction, $isMutual, $isInvertResult, $isSwap);
+        if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
+            return $mixedResult;
+
         return parent::checkAllowedConnect($iInitiator, $iContent, $isPerformAction, $isMutual, $isInvertResult, $isSwap);
     }
 
+    /**
+     * Custom check action method which can be overwritten.
+     * Currently only friends can establish relations.
+     */
+    public function checkAllowedConnectCustom($iInitiator, $iContent, $isPerformAction = false, $isMutual = false, $isInvertResult = false, $isSwap = false)
+    {
+        if(!BxDolConnection::getObjectInstance('sys_profiles_friends')->isConnected($iInitiator, $iContent, true))
+            return _t('_sys_txt_access_denied');
+
+        return CHECK_ACTION_RESULT_ALLOWED;
+    }
+
+    public function isRelationAvailable($iInitiator, $iContent)
+    {
+        $sParam = getParam($this->_sParamEnabled);
+        $oInitiator = BxDolProfile::getInstance($iInitiator);
+        $oContent = BxDolProfile::getInstance($iContent);
+        if(empty($sParam) || !$oInitiator || !$oContent)
+            return false;
+
+        $aParam = explode(',', $sParam);
+        if(!in_array($oInitiator->getModule() . '_' . $oContent->getModule(), $aParam))
+            return false;
+
+        return true;
+    }
+
+    public function getRelations($iInitiator, $iContent, &$aSuggestions = array())
+    {
+        $aRelations = BxDolFormQuery::getDataItems($this->_sPreList, false, BX_DATA_VALUES_ALL);
+
+        bx_alert($this->_sObject, 'get_relations', 0, bx_get_logged_profile_id(), array(
+            'initiator' => (int)$iInitiator,
+            'content' => (int)$iContent,
+            'pre_list' => $this->_sPreList,
+            'relations' => &$aRelations
+        ));
+
+        if($this->isConnected($iContent, $iInitiator)) {
+            $iRelation = $this->getRelation($iContent, $iInitiator);
+            if(!empty($iRelation) && !empty($aRelations[$iRelation]['Data']))
+                $aSuggestions = unserialize($aRelations[$iRelation]['Data']);
+        }
+
+        return $aRelations;
+    }
+
     public function getRelation($iInitiator, $iContent)
     {
         $aConnection = $this->_oQuery->getConnection ($iInitiator, $iContent);
@@ -170,4 +227,11 @@ class BxDolRelation extends BxDolConnection
 
         return (int)$aConnection['relation'];
     }
+
+    public function getRelationTranslation($iValue, $sUseValues = BX_DATA_VALUES_DEFAULT)
+    {
+        $aRelations = BxDolFormQuery::getDataItems($this->_sPreList, false, $sUseValues);
+
+        return !empty($aRelations[$iValue]) ? $aRelations[$iValue] : _t('_uknown');
+    }
 }

+ 3 - 1
install/sql/system.sql

@@ -301,7 +301,9 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `ex
 (@iCategoryId, 'sys_tinymce_plugins_full', '_adm_stg_cpt_option_sys_tinymce_plugins_full', 'advlist,anchor,autolink,autoresize,autosave,charmap,code,emoticons,hr,image,link,lists,media,nonbreaking,pagebreak,preview,paste,save,searchreplace,table,textcolor,visualblocks,fullscreen', 'digit', '', '', '', 76),
 (@iCategoryId, 'sys_tinymce_toolbar_full', '_adm_stg_cpt_option_sys_tinymce_toolbar_full', 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image, preview media | forecolor emoticons | fullscreen', 'digit', '', '', '', 77),
 
-(@iCategoryId, 'sys_search_keyword_min_len', '_adm_stg_cpt_option_sys_search_keyword_min_len', '1', 'digit', '', '', '', 80);
+(@iCategoryId, 'sys_search_keyword_min_len', '_adm_stg_cpt_option_sys_search_keyword_min_len', '1', 'digit', '', '', '', 80),
+
+(@iCategoryId, 'sys_relations', '_adm_stg_cpt_option_sys_relations', '', 'list', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:21:"get_options_relations";s:6:"params";a:0:{}s:5:"class";s:13:"TemplServices";}', '', '', 90);
 
 
 --

+ 17 - 1
modules/base/profile/classes/BxBaseModProfileInstaller.php

@@ -11,12 +11,14 @@
 
 class BxBaseModProfileInstaller extends BxBaseModGeneralInstaller
 {
+    protected $_sParamRelations;
     protected $_sParamDefaultProfileType;
 
     function __construct($aConfig)
     {
         parent::__construct($aConfig);
 
+        $this->_sParamRelations = 'sys_relations';
         $this->_sParamDefaultProfileType = 'sys_account_default_profile_type';
     }
 
@@ -38,9 +40,23 @@ class BxBaseModProfileInstaller extends BxBaseModGeneralInstaller
         if(BxDolService::call($this->_aConfig['name'], 'act_as_profile') !== true)
             return $aResult;
 
-        if($aResult['result'] && getParam($this->_sParamDefaultProfileType) == $this->_aConfig['name'])
+        $sName = $this->_aConfig['name'];
+        if($aResult['result'] && getParam($this->_sParamDefaultProfileType) == $sName)
         	setParam($this->_sParamDefaultProfileType, '');
 
+        if($aResult['result']) {
+            $sDiv = ',';
+            $sRelations = getParam($this->_sParamRelations);
+            if(!empty($sRelations) && strpos($sRelations, $sName) !== false) {
+                $aRelations = explode($sDiv, $sRelations);
+                foreach($aRelations as $iIndex => $sValue)
+                    if(strpos($sValue, $sName) !== false)
+                        unset($aRelations[$iIndex]);
+
+                setParam($this->_sParamRelations, implode($sDiv, $aRelations));
+            }
+        }
+
         if ($aResult['result']) { // disabling was successful
             // TODO: switch accounts context which active profiles belong to this module
         }

+ 3 - 5
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -517,14 +517,12 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         if(empty($aConnections) || !is_array($aConnections))
             return '';
 
-        $aRelations = BxDolFormQuery::getDataItems('sys_relations');
-
         $aResult = array();
         foreach($aConnections as $iProfile => $aConnection)
             $aResult[] = array(
                 'id' => $iProfile,
                 'info' => array(
-                    'addon' => _t($aRelations[$aConnection['relation']])
+                    'addon' => $oConnection->getRelationTranslation($aConnection['relation'])
                 )
             );
 
@@ -745,7 +743,7 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         list($iContentId, $aContentInfo) = $mixedContent;
 
         bx_import('BxDolConnection');
-        $s = $this->serviceBrowseRelationsQuick ($aContentInfo['profile_id'], 'sys_profiles_relations', BX_CONNECTIONS_CONTENT_TYPE_CONTENT);
+        $s = $this->serviceBrowseRelationsQuick ($aContentInfo['profile_id'], 'sys_profiles_relations', BX_CONNECTIONS_CONTENT_TYPE_CONTENT, 1);
         if (!$s)
             return MsgBox(_t('_sys_txt_empty'));
 
@@ -761,7 +759,7 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         list($iContentId, $aContentInfo) = $mixedContent;
 
         bx_import('BxDolConnection');
-        $s = $this->serviceBrowseRelationsQuick ($aContentInfo['profile_id'], 'sys_profiles_relations', BX_CONNECTIONS_CONTENT_TYPE_INITIATORS);
+        $s = $this->serviceBrowseRelationsQuick ($aContentInfo['profile_id'], 'sys_profiles_relations', BX_CONNECTIONS_CONTENT_TYPE_INITIATORS, 1);
         if (!$s)
             return MsgBox(_t('_sys_txt_empty'));
 

+ 5 - 4
modules/boonex/english/data/langs/system/en.xml

@@ -1331,6 +1331,7 @@
 	<string name="_adm_stg_cpt_option_sys_recaptcha_key_public"><![CDATA[reCAPTCHA public key]]></string>
 	<string name="_adm_stg_cpt_option_sys_redirect_after_account_added"><![CDATA[Redirect after account creation to]]></string>
 	<string name="_adm_stg_cpt_option_sys_redirect_after_email_confirmation"><![CDATA[Redirect after email confirmation to]]></string>
+        <string name="_adm_stg_cpt_option_sys_relations"><![CDATA[Enable relationships between]]></string>
 	<string name="_adm_stg_cpt_option_sys_revision"><![CDATA[Revision number]]></string>
 	<string name="_adm_stg_cpt_option_sys_security_form_token_enable"><![CDATA[Enable CSRF token in forms]]></string>
 	<string name="_adm_stg_cpt_option_sys_security_form_token_lifetime"><![CDATA[CSRF token lifetime in seconds(0 - do not track time)]]></string>
@@ -1635,7 +1636,7 @@
 	<string name="_sys_acl_expire"><![CDATA[Expire: ]]></string>
 	<string name="_sys_acl_expire_never"><![CDATA[never]]></string>
 	<string name="_sys_add_friend"><![CDATA[Add friend]]></string>
-        <string name="_sys_add_relation"><![CDATA[Add relation]]></string>
+        <string name="_sys_add_relation"><![CDATA[Add relationship]]></string>
 	<string name="_sys_adm_installed"><![CDATA[Installed]]></string>
 	<string name="_sys_admin_apply"><![CDATA[Apply]]></string>
 	<string name="_sys_admin_filter"><![CDATA[Filter:]]></string>
@@ -2374,7 +2375,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_menu_title_set_acl_level"><![CDATA[ACL Levels]]></string>
 	<string name="_sys_menu_title_social_sharing"><![CDATA[Social Sharing]]></string>
         <string name="_sys_menu_title_create_post"><![CDATA[Create Post Menu]]></string>
-        <string name="_sys_menu_title_add_relation"><![CDATA[Add Relation Menu]]></string>
+        <string name="_sys_menu_title_add_relation"><![CDATA[Add Relationship Menu]]></string>
 	<string name="_sys_menu_title_submenu"><![CDATA[Site Submenu]]></string>
 	<string name="_sys_menu_title_toolbar_member"><![CDATA[Member Toolbar]]></string>
 	<string name="_sys_menu_title_toolbar_site"><![CDATA[Site Toolbar]]></string>
@@ -2491,7 +2492,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_paginate_info"><![CDATA[{0}-{1}]]></string>
 	<string name="_sys_paginate_view_all"><![CDATA[View All]]></string>
 	<string name="_sys_please_select"><![CDATA[Please select...]]></string>
-        <string name="_sys_pre_lists_relations"><![CDATA[Relations]]></string>
+        <string name="_sys_pre_lists_relations"><![CDATA[Relationships]]></string>
         <string name="_sys_pre_lists_relations_husband"><![CDATA[husband]]></string>
         <string name="_sys_pre_lists_relations_wife"><![CDATA[wife]]></string>
         <string name="_sys_pre_lists_relations_father"><![CDATA[father]]></string>
@@ -2538,7 +2539,7 @@ If it is not enabled then please consider implement this optimization, since it
     <string name="_sys_push_notification_request_yes"><![CDATA[Yes]]></string>  
     <string name="_sys_push_notification_request_no"><![CDATA[No, thanks]]></string>
     <string name="_sys_read_more"><![CDATA[Continue reading "{0}"]]></string>
-    <string name="_sys_relation"><![CDATA[Relation]]></string>
+    <string name="_sys_relation"><![CDATA[Relationship]]></string>
 	<string name="_sys_request_module_not_found_cpt"><![CDATA[Module was not found]]></string>
 	<string name="_sys_request_module_not_found_cnt"><![CDATA[Module({0}) was not found]]></string>
 	<string name="_sys_request_page_not_found_cpt"><![CDATA[Page was not found]]></string>

+ 18 - 18
modules/boonex/organizations/install/langs/en.xml

@@ -101,8 +101,8 @@
     <string name="_bx_orgs_page_title_friend_requests"><![CDATA[Friend Requests]]></string>
 	<string name="_bx_orgs_page_title_sys_profile_subscriptions"><![CDATA[Following]]></string>
     <string name="_bx_orgs_page_title_profile_subscriptions"><![CDATA[Following & Followers]]></string>
-    <string name="_bx_orgs_page_title_sys_profile_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_orgs_page_title_profile_relations"><![CDATA[Relations]]></string>
+    <string name="_bx_orgs_page_title_sys_profile_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_orgs_page_title_profile_relations"><![CDATA[Relationships]]></string>
     <string name="_bx_orgs_page_title_sys_fans"><![CDATA[Members]]></string>
     <string name="_bx_orgs_page_title_fans"><![CDATA[Members]]></string>
     <string name="_bx_orgs_page_title_sys_profile_comments"><![CDATA[Comments]]></string>
@@ -154,10 +154,10 @@
     <string name="_bx_orgs_page_block_title_profile_subscriptions"><![CDATA[Following]]></string>
     <string name="_bx_orgs_page_block_title_system_profile_subscribed_me"><![CDATA[Followers]]></string>
     <string name="_bx_orgs_page_block_title_profile_subscribed_me"><![CDATA[Followers]]></string>
-    <string name="_bx_orgs_page_block_title_system_profile_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_orgs_page_block_title_profile_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_orgs_page_block_title_system_profile_related_me"><![CDATA[Related Me]]></string>
-    <string name="_bx_orgs_page_block_title_profile_related_me"><![CDATA[Related Me]]></string>
+    <string name="_bx_orgs_page_block_title_system_profile_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_orgs_page_block_title_profile_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_orgs_page_block_title_system_profile_related_me"><![CDATA[Relationships with Me]]></string>
+    <string name="_bx_orgs_page_block_title_profile_related_me"><![CDATA[Relationships with Me]]></string>
     <string name="_bx_orgs_page_block_title_profile_comments"><![CDATA[Comments]]></string>
     <string name="_bx_orgs_page_block_title_profile_comments_link"><![CDATA[Comments to <a href="{entry_link}">{title}</a>]]></string>
 	<string name="_bx_orgs_page_block_title_profile_actions"><![CDATA[Actions]]></string>
@@ -224,8 +224,8 @@
     <string name="_bx_orgs_menu_item_title_view_profile_fans"><![CDATA[Members]]></string>
     <string name="_bx_orgs_menu_item_title_system_view_profile_friends"><![CDATA[Friends]]></string>
     <string name="_bx_orgs_menu_item_title_view_profile_friends"><![CDATA[Friends]]></string>
-    <string name="_bx_orgs_menu_item_title_system_view_profile_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_orgs_menu_item_title_view_profile_relations"><![CDATA[Relations]]></string>
+    <string name="_bx_orgs_menu_item_title_system_view_profile_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_orgs_menu_item_title_view_profile_relations"><![CDATA[Relationships]]></string>
     <string name="_bx_orgs_menu_item_title_system_view_profile_subscriptions"><![CDATA[Following]]></string>
     <string name="_bx_orgs_menu_item_title_view_profile_subscriptions"><![CDATA[Following]]></string>
     <string name="_bx_orgs_menu_item_title_system_view_profile_comments"><![CDATA[Comments]]></string>
@@ -258,18 +258,18 @@
     <string name="_bx_orgs_menu_item_title_subscribe"><![CDATA[Follow]]></string>
     <string name="_bx_orgs_menu_item_title_system_unsubscribe"><![CDATA[Unfollow]]></string>
     <string name="_bx_orgs_menu_item_title_unsubscribe"><![CDATA[Unfollow]]></string>
-    <string name="_bx_orgs_menu_item_title_system_relation_add"><![CDATA[Add Relation]]></string>
-    <string name="_bx_orgs_menu_item_title_relation_add"><![CDATA[Add Relation]]></string>
-    <string name="_bx_orgs_menu_item_title_system_relation_delete"><![CDATA[Remove Relation]]></string>
-    <string name="_bx_orgs_menu_item_title_relation_delete"><![CDATA[Remove Relation]]></string>
+    <string name="_bx_orgs_menu_item_title_system_relation_add"><![CDATA[Add Relationship]]></string>
+    <string name="_bx_orgs_menu_item_title_relation_add"><![CDATA[Add Relationship]]></string>
+    <string name="_bx_orgs_menu_item_title_system_relation_delete"><![CDATA[Remove Relationship]]></string>
+    <string name="_bx_orgs_menu_item_title_relation_delete"><![CDATA[Remove Relationship]]></string>
     <string name="_bx_orgs_menu_item_title_system_more_actions"><![CDATA[More Actions]]></string>
     <string name="_bx_orgs_menu_item_title_more_actions"><![CDATA[]]></string>
     <string name="_bx_orgs_menu_item_title_system_friends"><![CDATA[Friends]]></string>
     <string name="_bx_orgs_menu_item_title_friends"><![CDATA[Friends]]></string>
     <string name="_bx_orgs_menu_item_title_system_friend_requests"><![CDATA[Friend requests number]]></string>
     <string name="_bx_orgs_menu_item_title_friend_requests"><![CDATA[Friend requests]]></string>
-    <string name="_bx_orgs_menu_item_title_system_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_orgs_menu_item_title_relations"><![CDATA[Relations]]></string>
+    <string name="_bx_orgs_menu_item_title_system_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_orgs_menu_item_title_relations"><![CDATA[Relationships]]></string>
     <string name="_bx_orgs_menu_item_title_system_manage_my_organizations"><![CDATA[My organizations]]></string>
     <string name="_bx_orgs_menu_item_title_manage_my_organizations"><![CDATA[Organizations]]></string>
     <string name="_bx_orgs_menu_item_title_system_favorites"><![CDATA[Favorite Organizations]]></string>
@@ -278,10 +278,10 @@
     <string name="_bx_orgs_menu_item_title_subscriptions"><![CDATA[Following]]></string>
     <string name="_bx_orgs_menu_item_title_system_subscribed_me"><![CDATA[Followers]]></string>
     <string name="_bx_orgs_menu_item_title_subscribed_me"><![CDATA[Followers]]></string>
-    <string name="_bx_orgs_menu_item_title_system_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_orgs_menu_item_title_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_orgs_menu_item_title_system_related_me"><![CDATA[Related Me]]></string>
-    <string name="_bx_orgs_menu_item_title_related_me"><![CDATA[Related Me]]></string>
+    <string name="_bx_orgs_menu_item_title_system_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_orgs_menu_item_title_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_orgs_menu_item_title_system_related_me"><![CDATA[Relationships with Me]]></string>
+    <string name="_bx_orgs_menu_item_title_related_me"><![CDATA[Relationships with Me]]></string>
     <string name="_bx_orgs_menu_item_title_system_entries_recent"><![CDATA[New]]></string>
     <string name="_bx_orgs_menu_item_title_entries_recent"><![CDATA[New]]></string>
     <string name="_bx_orgs_menu_item_title_system_entries_search"><![CDATA[Search]]></string>

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

@@ -400,8 +400,8 @@ INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `tit
 ('sys_profile_stats', 'bx_organizations', 'profile-stats-favorite-organizations', '_bx_orgs_menu_item_title_system_favorites', '_bx_orgs_menu_item_title_favorites', 'page.php?i=organization-profile-favorites&profile_id={member_id}', '', '', 'star col-red2', 'a:2:{s:6:"module";s:16:"bx_organizations";s:6:"method";s:38:"get_menu_addon_favorites_profile_stats";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 3),
 ('sys_profile_stats', 'bx_organizations', 'profile-stats-subscriptions', '_bx_orgs_menu_item_title_system_subscriptions', '_bx_orgs_menu_item_title_subscriptions', 'page.php?i=organization-profile-subscriptions&profile_id={member_id}#subscriptions', '', '_self', 'rss col-red2', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:25:"get_connected_content_num";s:6:"params";a:1:{i:0;s:26:"sys_profiles_subscriptions";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 4),
 ('sys_profile_stats', 'bx_organizations', 'profile-stats-subscribed-me', '_bx_orgs_menu_item_title_system_subscribed_me', '_bx_orgs_menu_item_title_subscribed_me', 'page.php?i=organization-profile-subscribed-me&profile_id={member_id}#subscribers', '', '_self', 'rss col-red2', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:28:"get_connected_initiators_num";s:6:"params";a:1:{i:0;s:26:"sys_profiles_subscriptions";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 5),
-('sys_profile_stats', 'bx_organizations', 'profile-stats-relations', '_bx_orgs_menu_item_title_system_relations', '_bx_orgs_menu_item_title_relations', 'page.php?i=organization-profile-relations&profile_id={member_id}#relations', '', '_self', 'sync col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:25:"get_connected_content_num";s:6:"params";a:1:{i:0;s:26:"sys_profiles_subscriptions";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 6),
-('sys_profile_stats', 'bx_organizations', 'profile-stats-related-me', '_bx_orgs_menu_item_title_system_related_me', '_bx_orgs_menu_item_title_related_me', 'page.php?i=organization-profile-relations&profile_id={member_id}#related-me', '', '_self', 'sync col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:28:"get_connected_initiators_num";s:6:"params";a:1:{i:0;s:26:"sys_profiles_subscriptions";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 7);
+('sys_profile_stats', 'bx_organizations', 'profile-stats-relations', '_bx_orgs_menu_item_title_system_relations', '_bx_orgs_menu_item_title_relations', 'page.php?i=organization-profile-relations&profile_id={member_id}#relations', '', '_self', 'sync col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:25:"get_connected_content_num";s:6:"params";a:3:{i:0;s:22:"sys_profiles_relations";i:1;i:0;i:2;i:1;}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 6),
+('sys_profile_stats', 'bx_organizations', 'profile-stats-related-me', '_bx_orgs_menu_item_title_system_related_me', '_bx_orgs_menu_item_title_related_me', 'page.php?i=organization-profile-relations&profile_id={member_id}#related-me', '', '_self', 'sync col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:28:"get_connected_initiators_num";s:6:"params";a:3:{i:0;s:22:"sys_profiles_relations";i:1;i:0;i:2;i:1;}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 7);
 
 -- MENU: manage tools submenu
 INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 

+ 10 - 0
modules/boonex/persons/install/installer.php

@@ -15,6 +15,16 @@ class BxPersonsInstaller extends BxBaseModProfileInstaller
     {
         parent::__construct($aConfig);
     }
+
+    function enable($aParams)
+    {
+        $aResult = parent::enable($aParams);
+
+        if($aResult['result'] && getParam($this->_sParamRelations) == '')
+            setParam($this->_sParamRelations, $this->_aConfig['name'] . '_' . $this->_aConfig['name']);
+
+        return $aResult;
+    }
 }
 
 /** @} */

+ 18 - 18
modules/boonex/persons/install/langs/en.xml

@@ -96,8 +96,8 @@
 	<string name="_bx_persons_page_title_friend_requests"><![CDATA[Friend Requests]]></string>
 	<string name="_bx_persons_page_title_sys_profile_subscriptions"><![CDATA[Following]]></string>
     <string name="_bx_persons_page_title_profile_subscriptions"><![CDATA[Following & Followers]]></string>
-    <string name="_bx_persons_page_title_sys_profile_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_persons_page_title_profile_relations"><![CDATA[Relations]]></string>
+    <string name="_bx_persons_page_title_sys_profile_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_persons_page_title_profile_relations"><![CDATA[Relationships]]></string>
     <string name="_bx_persons_page_title_sys_profile_comments"><![CDATA[Comments]]></string>
     <string name="_bx_persons_page_title_profile_comments"><![CDATA[Comments]]></string>
 	<string name="_bx_persons_page_title_sys_profile_info"><![CDATA[Profile Info]]></string>
@@ -139,10 +139,10 @@
     <string name="_bx_persons_page_block_title_profile_subscriptions"><![CDATA[Following]]></string>
     <string name="_bx_persons_page_block_title_system_profile_subscribed_me"><![CDATA[Followers]]></string>
     <string name="_bx_persons_page_block_title_profile_subscribed_me"><![CDATA[Followers]]></string>
-    <string name="_bx_persons_page_block_title_system_profile_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_persons_page_block_title_profile_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_persons_page_block_title_system_profile_related_me"><![CDATA[Related Me]]></string>
-    <string name="_bx_persons_page_block_title_profile_related_me"><![CDATA[Related Me]]></string>
+    <string name="_bx_persons_page_block_title_system_profile_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_persons_page_block_title_profile_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_persons_page_block_title_system_profile_related_me"><![CDATA[Relationships with Me]]></string>
+    <string name="_bx_persons_page_block_title_profile_related_me"><![CDATA[Relationships with Me]]></string>
     <string name="_bx_persons_page_block_title_profile_comments"><![CDATA[Comments]]></string>
     <string name="_bx_persons_page_block_title_profile_comments_link"><![CDATA[Comments to <a href="{entry_link}">{title}</a>]]></string>
     <string name="_bx_persons_page_block_title_featured_profiles"><![CDATA[Featured People]]></string>
@@ -195,8 +195,8 @@
     <string name="_bx_persons_menu_item_title_create_profile"><![CDATA[Person]]></string>
     <string name="_bx_persons_menu_item_title_system_view_profile_friends"><![CDATA[Friends]]></string>
     <string name="_bx_persons_menu_item_title_view_profile_friends"><![CDATA[Friends]]></string>
-    <string name="_bx_persons_menu_item_title_system_view_profile_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_persons_menu_item_title_view_profile_relations"><![CDATA[Relations]]></string>
+    <string name="_bx_persons_menu_item_title_system_view_profile_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_persons_menu_item_title_view_profile_relations"><![CDATA[Relationships]]></string>
     <string name="_bx_persons_menu_item_title_system_view_profile_subscriptions"><![CDATA[Following]]></string>
     <string name="_bx_persons_menu_item_title_view_profile_subscriptions"><![CDATA[Following]]></string>
     <string name="_bx_persons_menu_item_title_system_view_profile_comments"><![CDATA[Comments]]></string>
@@ -217,16 +217,16 @@
     <string name="_bx_persons_menu_item_title_subscribe"><![CDATA[Follow]]></string>
     <string name="_bx_persons_menu_item_title_system_unsubscribe"><![CDATA[Unfollow]]></string>
     <string name="_bx_persons_menu_item_title_unsubscribe"><![CDATA[Unfollow]]></string>
-    <string name="_bx_persons_menu_item_title_system_relation_add"><![CDATA[Add Relation]]></string>
-    <string name="_bx_persons_menu_item_title_relation_add"><![CDATA[Add Relation]]></string>
-    <string name="_bx_persons_menu_item_title_system_relation_delete"><![CDATA[Remove Relation]]></string>
-    <string name="_bx_persons_menu_item_title_relation_delete"><![CDATA[Remove Relation]]></string>
+    <string name="_bx_persons_menu_item_title_system_relation_add"><![CDATA[Add Relationship]]></string>
+    <string name="_bx_persons_menu_item_title_relation_add"><![CDATA[Add Relationship]]></string>
+    <string name="_bx_persons_menu_item_title_system_relation_delete"><![CDATA[Remove Relationship]]></string>
+    <string name="_bx_persons_menu_item_title_relation_delete"><![CDATA[Remove Relationship]]></string>
     <string name="_bx_persons_menu_item_title_system_more_actions"><![CDATA[More Actions]]></string>
     <string name="_bx_persons_menu_item_title_more_actions"><![CDATA[]]></string>
     <string name="_bx_persons_menu_item_title_system_friends"><![CDATA[Friends]]></string>
     <string name="_bx_persons_menu_item_title_friends"><![CDATA[Friends]]></string>
-    <string name="_bx_persons_menu_item_title_system_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_persons_menu_item_title_relations"><![CDATA[Relations]]></string>
+    <string name="_bx_persons_menu_item_title_system_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_persons_menu_item_title_relations"><![CDATA[Relationships]]></string>
     <string name="_bx_persons_menu_item_title_system_friend_requests"><![CDATA[Friend requests number]]></string>
     <string name="_bx_persons_menu_item_title_friend_requests"><![CDATA[Friend requests]]></string>
     <string name="_bx_persons_menu_item_title_system_manage_my_profiles"><![CDATA[My profiles]]></string>
@@ -237,10 +237,10 @@
     <string name="_bx_persons_menu_item_title_subscriptions"><![CDATA[Following]]></string>
     <string name="_bx_persons_menu_item_title_system_subscribed_me"><![CDATA[Followers]]></string>
     <string name="_bx_persons_menu_item_title_subscribed_me"><![CDATA[Followers]]></string>
-    <string name="_bx_persons_menu_item_title_system_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_persons_menu_item_title_relations"><![CDATA[Relations]]></string>
-    <string name="_bx_persons_menu_item_title_system_related_me"><![CDATA[Related Me]]></string>
-    <string name="_bx_persons_menu_item_title_related_me"><![CDATA[Related Me]]></string>
+    <string name="_bx_persons_menu_item_title_system_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_persons_menu_item_title_relations"><![CDATA[Relationships]]></string>
+    <string name="_bx_persons_menu_item_title_system_related_me"><![CDATA[Relationships with Me]]></string>
+    <string name="_bx_persons_menu_item_title_related_me"><![CDATA[Relationships with Me]]></string>
     <string name="_bx_persons_menu_item_title_system_entries_recent"><![CDATA[New]]></string>
     <string name="_bx_persons_menu_item_title_entries_recent"><![CDATA[New]]></string>
     <string name="_bx_persons_menu_item_title_system_entries_search"><![CDATA[Search]]></string>

+ 2 - 2
modules/boonex/persons/install/sql/enable.sql

@@ -349,8 +349,8 @@ INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `tit
 ('sys_profile_stats', 'bx_persons', 'profile-stats-favorite-persons', '_bx_persons_menu_item_title_system_favorites', '_bx_persons_menu_item_title_favorites', 'page.php?i=persons-profile-favorites&profile_id={member_id}', '', '', 'star col-blue3', 'a:2:{s:6:"module";s:10:"bx_persons";s:6:"method";s:38:"get_menu_addon_favorites_profile_stats";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 3),
 ('sys_profile_stats', 'bx_persons', 'profile-stats-subscriptions', '_bx_persons_menu_item_title_system_subscriptions', '_bx_persons_menu_item_title_subscriptions', 'page.php?i=persons-profile-subscriptions&profile_id={member_id}#subscriptions', '', '_self', 'rss col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:25:"get_connected_content_num";s:6:"params";a:1:{i:0;s:26:"sys_profiles_subscriptions";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 4),
 ('sys_profile_stats', 'bx_persons', 'profile-stats-subscribed-me', '_bx_persons_menu_item_title_system_subscribed_me', '_bx_persons_menu_item_title_subscribed_me', 'page.php?i=persons-profile-subscriptions&profile_id={member_id}#subscribers', '', '_self', 'rss col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:28:"get_connected_initiators_num";s:6:"params";a:1:{i:0;s:26:"sys_profiles_subscriptions";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 5),
-('sys_profile_stats', 'bx_persons', 'profile-stats-relations', '_bx_persons_menu_item_title_system_relations', '_bx_persons_menu_item_title_relations', 'page.php?i=persons-profile-relations&profile_id={member_id}#relations', '', '_self', 'sync col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:25:"get_connected_content_num";s:6:"params";a:1:{i:0;s:26:"sys_profiles_subscriptions";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 6),
-('sys_profile_stats', 'bx_persons', 'profile-stats-related-me', '_bx_persons_menu_item_title_system_related_me', '_bx_persons_menu_item_title_related_me', 'page.php?i=persons-profile-relations&profile_id={member_id}#related-me', '', '_self', 'sync col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:28:"get_connected_initiators_num";s:6:"params";a:1:{i:0;s:26:"sys_profiles_subscriptions";}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 7);
+('sys_profile_stats', 'bx_persons', 'profile-stats-relations', '_bx_persons_menu_item_title_system_relations', '_bx_persons_menu_item_title_relations', 'page.php?i=persons-profile-relations&profile_id={member_id}#relations', '', '_self', 'sync col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:25:"get_connected_content_num";s:6:"params";a:3:{i:0;s:22:"sys_profiles_relations";i:1;i:0;i:2;i:1;}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 6),
+('sys_profile_stats', 'bx_persons', 'profile-stats-related-me', '_bx_persons_menu_item_title_system_related_me', '_bx_persons_menu_item_title_related_me', 'page.php?i=persons-profile-relations&profile_id={member_id}#related-me', '', '_self', 'sync col-blue3', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:28:"get_connected_initiators_num";s:6:"params";a:3:{i:0;s:22:"sys_profiles_relations";i:1;i:0;i:2;i:1;}s:5:"class";s:23:"TemplServiceConnections";}', '', 2147483646, 1, 0, @iNotifMenuOrder + 7);
 
 -- MENU: manage tools submenu
 INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 

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

@@ -1329,6 +1329,7 @@
 	<string name="_adm_stg_cpt_option_sys_recaptcha_key_public"><![CDATA[reCAPTCHA - публичный ключ]]></string>
 	<string name="_adm_stg_cpt_option_sys_redirect_after_account_added"><![CDATA[Перенаправлять после создания аккаунта на]]></string>
     <string name="_adm_stg_cpt_option_sys_redirect_after_email_confirmation"><![CDATA[Перенаправлять после подтверждения имейла на]]></string>
+    <string name="_adm_stg_cpt_option_sys_relations"><![CDATA[Разрешить связи между]]></string>
     <string name="_adm_stg_cpt_option_sys_revision"><![CDATA[Номер ревизии]]></string>
 	<string name="_adm_stg_cpt_option_sys_security_form_token_enable"><![CDATA[Задействовать CSRF токен в формах]]></string>
 	<string name="_adm_stg_cpt_option_sys_security_form_token_lifetime"><![CDATA[CSRF token - срок жизни в секундах (0 - не вести отчёт времени)]]></string>

+ 5 - 14
template/scripts/BxBaseMenuAddRelation.php

@@ -12,7 +12,6 @@
  */
 class BxBaseMenuAddRelation extends BxTemplMenu
 {
-    protected $_sPreList;
     protected $_sConnection;
 
     protected $_iInitiator;
@@ -22,7 +21,6 @@ class BxBaseMenuAddRelation extends BxTemplMenu
     {
         parent::__construct ($aObject, $oTemplate);
 
-        $this->_sPreList = 'sys_relations';
         $this->_sConnection = 'sys_profiles_relations';
 
         $this->_iInitiator = bx_get_logged_profile_id();
@@ -55,23 +53,16 @@ class BxBaseMenuAddRelation extends BxTemplMenu
         if(bx_get('profile_id') !== false)
             $this->_iContent = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
 
-        $oRelation = BxDolConnection::getObjectInstance($this->_sConnection);
-        $aRelations = BxDolFormQuery::getDataItems($this->_sPreList, false, BX_DATA_VALUES_ALL);
-
-        $aSuggest = array();
-        $bSuggest = $oRelation->isConnected($this->_iContent, $this->_iInitiator);
-        if($bSuggest) {
-            $iRelation = $oRelation->getRelation($this->_iContent, $this->_iInitiator);
-            if(!empty($iRelation) && !empty($aRelations[$iRelation]['Data']))
-                $aSuggest = unserialize($aRelations[$iRelation]['Data']);
-        }
+        $aSuggestions = array();
+        $aRelations = BxDolConnection::getObjectInstance($this->_sConnection)->getRelations($this->_iInitiator, $this->_iContent, $aSuggestions);
+        $bSuggestions = !empty($aSuggestions) && is_array($aSuggestions);
 
         $aItems = array();
         foreach($aRelations as $iId => $aRelation) {
             $aItems[] = array(
                 'id' => $iId,
                 'name' => $iId,
-                'class' => $bSuggest && !in_array($iId, $aSuggest) ? $sClassHidden : '',
+                'class' => $bSuggestions && !in_array($iId, $aSuggestions) ? $sClassHidden : '',
                 'title' => _t($aRelation[BX_DATA_VALUES_DEFAULT]),
                 'icon' => '',
                 'link' => 'javascript:void(0);',
@@ -79,7 +70,7 @@ class BxBaseMenuAddRelation extends BxTemplMenu
             );
         }
 
-        if($bSuggest && !empty($aSuggest))
+        if($bSuggestions)
             $aItems[] = array(
                 'id' => 'see_more',
                 'name' => 'see_more',

+ 21 - 0
template/scripts/BxBaseServices.php

@@ -262,6 +262,27 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
 
         return $aResults;
     }
+
+    public function serviceGetOptionsRelations()
+    {
+        $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1));
+
+        $aProfiles = array();
+        foreach($aModules as $aModule) {
+            $sMethod = 'act_as_profile';
+            if(!BxDolRequest::serviceExists($aModule['name'], $sMethod) || !BxDolService::call($aModule['name'], $sMethod))
+                continue;
+
+            $aProfiles[$aModule['name']] = _t('_' . $aModule['name']);
+        }
+
+        $aResults = array();
+        foreach($aProfiles as $sName1 => $sTitle1)
+            foreach($aProfiles as $sName2 => $sTitle2)
+                $aResults[$sName1 . '_' . $sName2] = $sTitle1 . ' - ' . $sTitle2;
+
+        return $aResults;
+    }
 }
 
 /** @} */