1
0
Эх сурвалжийг харах

#4 connections
- friends were renamed to connections
- subscriptions connections
- implementing connection actions in profiles
- standalone AJAX handler of connection actions

Alex Trofimov 13 жил өмнө
parent
commit
91d4641a6e

+ 39 - 0
conn.php

@@ -0,0 +1,39 @@
+<?php
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinCore Dolphin Core
+ * @{
+ */
+
+require_once('./inc/header.inc.php');
+require_once(BX_DIRECTORY_PATH_INC . "params.inc.php");
+require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
+
+check_logged();
+
+$sObj = bx_get('obj') ? bx_get('obj') : '';
+$sAct = bx_get('act') && preg_match ('/^[A-Za-z_]+$/', bx_get('act')) ? bx_get('act') : '';
+$sFmt = bx_get('fmt') ? bx_get('fmt') : 'json';
+
+bx_import('BxDolConnection');
+$oConn = BxDolConnection::getObjectInstance($sObj);
+
+$sMethod = 'action' . $sAct;
+if ($oConn && $sAct && method_exists($oConn, $sMethod)) {
+
+    echo $oConn->outputActionResult($oConn->$sMethod(), $sFmt);
+    exit;
+
+} else {
+
+    bx_import('BxDolLanguages');
+    bx_import('BxDolTemplate');
+
+    $oTemplate = BxDolTemplate::getInstance();
+    $oTemplate->displayPageNotFound();
+
+}
+
+/** @} */

+ 74 - 0
inc/classes/BxDolConnection.php

@@ -151,6 +151,67 @@ class BxDolConnection extends BxDol implements iBxDolFactoryObject {
         return ($GLOBALS['bxDolClasses']['BxDolConnection!'.$sObject] = $o);
         return ($GLOBALS['bxDolClasses']['BxDolConnection!'.$sObject] = $o);
     }
     }
 
 
+    /**
+     * Add new connection.
+     * @param $iContent content to make connection to, in most cases some content id, or other profile id in case of friends
+     * @return array
+     */ 
+    public function actionAdd () {
+        return $this->_action ('addConnection', '_sys_conn_err_connection_already_exists', false, true);
+    }
+
+    /**
+     * Remove connection.
+     * @param $iContent content to make connection to, in most cases some content id, or other profile id in case of friends
+     * @return array
+     */ 
+    public function actionRemove () {
+        return $this->_action ('removeConnection', '_sys_conn_err_connection_does_not_exists', false);
+    }
+
+    /**
+     * Reject connection request.
+     * @param $iContent content to make connection to, in most cases some content id, or other profile id in case of friends
+     * @return array
+     */ 
+    public function actionReject () {
+        return $this->_action ('removeConnection', '_sys_conn_err_connection_does_not_exists', true);
+    }
+
+    protected function _action ($sMethod, $sErrorKey, $bSwapInitiatorAndContent, $isMutual = false) {
+        bx_import('BxDolLanguages');
+        $iContent = 0;
+        $iInitiator = 0;
+        if ($bSwapInitiatorAndContent) {
+            $iInitiator = bx_process_input($_POST['id'], BX_DATA_INT);
+            $iContent = bx_get_logged_profile_id();
+        } else {
+            $iContent = bx_process_input($_POST['id'], BX_DATA_INT);
+            $iInitiator = bx_get_logged_profile_id();
+        }
+
+        if (!$iContent || !$iInitiator)
+            return array ('err' => true, 'msg' => _t('_sys_conn_err_input_data_is_not_defined'));
+
+        if (!$this->$sMethod((int)$iInitiator, (int)$iContent)) {
+            if ($isMutual && BX_CONNECTIONS_TYPE_MUTUAL == $this->_sType && $this->isConnected((int)$iInitiator, (int)$iContent, false) && !$this->isConnected((int)$iInitiator, (int)$iContent, true))
+                return array ('err' => true, 'msg' => _t('_sys_conn_err_connection_is_awaiting_confirmation'));
+
+            return array ('err' => true, 'msg' => _t($sErrorKey));
+        }
+
+        return array ('err' => false, 'msg' => _t('_sys_conn_msg_success'));
+    }
+
+    public function outputActionResult ($mixed, $sFormat = 'json') {
+        switch ($sFormat) {
+            case 'json':
+            default:
+                header('Content-Type: application/json; charset=utf-8');
+                echo json_encode($mixed);  
+        }
+        exit;
+    }
 
 
     /**
     /**
      * Add new connection.
      * Add new connection.
@@ -330,6 +391,19 @@ class BxDolConnection extends BxDol implements iBxDolFactoryObject {
         return false === $isMutual ? true : $oConnection['mutual'];
         return false === $isMutual ? true : $oConnection['mutual'];
     }
     }
 
 
+    /**
+     * Check if initiator and content are connected but connetion is not mutual, for checking pending connection requests. 
+     * This method makes sense only when type of connection is mutual.
+     * @param $iInitiator initiator of the connection
+     * @param $iContent connected content or other profile id in case of friends
+     * @return true - if content and initiator are connected but connection is not mutual or false in all other cases
+     */    
+    public function isConnectedNotMutual ($iInitiator, $iContent) {
+        $oConnection = $this->_oQuery->getConnection ($iInitiator, $iContent);
+        if (!$oConnection)
+            return false;
+        return $oConnection['mutual'] ? false : true;
+    }
 
 
 }
 }
 
 

+ 8 - 6
inc/classes/BxDolConnectionQuery.php

@@ -91,12 +91,16 @@ class BxDolConnectionQuery extends BxDolDb {
         if ($this->getConnection($iInitiator, $iContent)) // connection already exists
         if ($this->getConnection($iInitiator, $iContent)) // connection already exists
             return false;
             return false;
 
 
+        $iMutual = 0;
+        $sMutualField = '';
         if (BX_CONNECTIONS_TYPE_MUTUAL == $this->_sType) {
         if (BX_CONNECTIONS_TYPE_MUTUAL == $this->_sType) {
             $aConnectionMutual = $this->getConnection($iContent, $iInitiator);
             $aConnectionMutual = $this->getConnection($iContent, $iInitiator);
             $iMutual = $aConnectionMutual ? 1 : 0;
             $iMutual = $aConnectionMutual ? 1 : 0;
-        }
+            $sMutualField = $this->prepare(", `mutual` = ?", $iMutual);
+        } 
 
 
-        $sQuery = $this->prepare("INSERT INTO `" . $this->_sTable . "` SET `initiator` = ?, `content` = ?, `mutual` = ?, `added` = ?", $iInitiator, $iContent, $iMutual, time());
+        $sQuery = $this->prepare("INSERT INTO `" . $this->_sTable . "` SET `initiator` = ?, `content` = ?, `added` = ?", $iInitiator, $iContent, time());
+        $sQuery .= $sMutualField;
         if (!$this->query($sQuery))
         if (!$this->query($sQuery))
             return false;
             return false;
 
 
@@ -122,10 +126,8 @@ class BxDolConnectionQuery extends BxDolDb {
         if (!$this->query($sQuery))
         if (!$this->query($sQuery))
             return false;
             return false;
 
 
-        if (BX_CONNECTIONS_TYPE_MUTUAL == $this->_sType && $aConnection['mutual']) {
-            if (!$this->removeConnection($iContent, $iInitiator)) // in case of mutual connection - remove both connections
-                return false;
-        }
+        if (BX_CONNECTIONS_TYPE_MUTUAL == $this->_sType && $aConnection['mutual'])
+            $this->removeConnection($iContent, $iInitiator);
 
 
         return true;
         return true;
     }
     }

+ 1 - 1
inc/classes/BxDolPrivacy.php

@@ -254,7 +254,7 @@ class BxDolPrivacy extends BxDol implements iBxDolFactoryObject
     public function checkConnections($iOwnerId, $iViewerId)
     public function checkConnections($iOwnerId, $iViewerId)
     {
     {
     	bx_import('BxDolConnection');
     	bx_import('BxDolConnection');
-    	return BxDolConnection::getObjectInstance('sys_profiles_friends')->isConnected($iOwnerId, $iViewerId, true);
+    	return BxDolConnection::getObjectInstance('sys_profiles_connections')->isConnected($iOwnerId, $iViewerId, true);
     }
     }
 
 
 	protected function getCheckMethod($s)
 	protected function getCheckMethod($s)

+ 5 - 0
inc/classes/BxDolTemplate.php

@@ -318,6 +318,11 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton {
             BX_DOL_URL_PLUGINS . 'moment/moment+langs.min.js',
             BX_DOL_URL_PLUGINS . 'moment/moment+langs.min.js',
         ));
         ));
 
 
+        //--- Load default JS ---//
+        $this->addJsTranslation(array(
+            '_are you sure?',
+        ));
+
         //--- Load injection's cache ---//
         //--- Load injection's cache ---//
         $oDb = BxDolDb::getInstance();
         $oDb = BxDolDb::getInstance();
         $oCache = $oDb->getDbCacheObject();
         $oCache = $oDb->getDbCacheObject();

+ 36 - 0
inc/js/functions.js

@@ -325,3 +325,39 @@ function bx_time(sLang, isAutoupdate) {
         }, 30000);
         }, 30000);
     }
     }
 }
 }
+
+/**
+ * Perform connections AJAX request. 
+ * In case of error - it shows js alert with error message.
+ * In case of success - the page is reloaded.
+ * 
+ * @param sObj - connections object
+ * @param sAction - 'add', 'remove' or 'reject'
+ * @param iContentId - content id, initiator is always current logged in user
+ * @param bConfirm - show confirmation dialog
+ */
+function bx_conn_action(sObj, sAction, iContentId, bConfirm) {
+    if ('undefined' != typeof(bConfirm) && bConfirm && !confirm(_t('_are you sure?')))
+        return;
+                
+    var aParams = {
+        obj: sObj,
+        act: sAction,
+        id: iContentId
+    };
+    var fCallback = function (data) {
+        if ('object' != typeof(data))
+            return;
+        if (data.err)
+            alert(data.msg);
+        else
+            location.reload();
+    };
+    $.ajax({
+        dataType: 'json',
+        url: sUrlRoot + 'conn.php',
+        data: aParams,
+        type: 'POST',
+        success: fCallback
+    });
+}

+ 4 - 4
install/sql/v70.sql

@@ -3144,11 +3144,11 @@ CREATE TABLE IF NOT EXISTS `sys_objects_connection` (
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
 
 INSERT INTO `sys_objects_connection` (`object`, `table`, `type`, `override_class_name`, `override_class_file`) VALUES
 INSERT INTO `sys_objects_connection` (`object`, `table`, `type`, `override_class_name`, `override_class_file`) VALUES
-('sys_profiles_friends', 'sys_profiles_conn_friends', 'mutual', '', ''),
-('sys_profiles_contacts', 'sys_profiles_conn_contacts', 'one-way', '', '');
+('sys_profiles_connections', 'sys_profiles_conn_connections', 'mutual', '', ''),
+('sys_profiles_subscriptions', 'sys_profiles_conn_subscriptions', 'one-way', '', '');
 
 
 
 
-CREATE TABLE IF NOT EXISTS `sys_profiles_conn_contacts` (
+CREATE TABLE IF NOT EXISTS `sys_profiles_conn_subscriptions` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `initiator` int(11) NOT NULL,
   `initiator` int(11) NOT NULL,
   `content` int(11) NOT NULL,
   `content` int(11) NOT NULL,
@@ -3158,7 +3158,7 @@ CREATE TABLE IF NOT EXISTS `sys_profiles_conn_contacts` (
   KEY `content` (`content`)
   KEY `content` (`content`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
 
-CREATE TABLE IF NOT EXISTS `sys_profiles_conn_friends` (
+CREATE TABLE IF NOT EXISTS `sys_profiles_conn_connections` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `initiator` int(11) NOT NULL,
   `initiator` int(11) NOT NULL,
   `content` int(11) NOT NULL,
   `content` int(11) NOT NULL,

+ 6 - 0
modules/boonex/english/data/langs/system.xml

@@ -3579,6 +3579,12 @@ More info about URI DNSBL: <br />
 
 
     <string name="_sys_profile_system"><![CDATA[Account]]></string>
     <string name="_sys_profile_system"><![CDATA[Account]]></string>
 
 
+    <string name="_sys_conn_err_input_data_is_not_defined"><![CDATA[Input data isn't defined]]></string>
+    <string name="_sys_conn_err_connection_already_exists"><![CDATA[Connection already exists]]></string>
+    <string name="_sys_conn_err_connection_does_not_exists"><![CDATA[Connection doesn't exist]]></string>
+    <string name="_sys_conn_err_connection_is_awaiting_confirmation"><![CDATA[Connection request is awaiting confirmation]]></string>
+    <string name="_sys_conn_msg_success"><![CDATA[Operation has beed succesfully completed]]></string>
+
     <!-- ********************** -->
     <!-- ********************** -->
     <!-- Auto Installed Modules -->
     <!-- Auto Installed Modules -->
     <!-- ********************** -->
     <!-- ********************** -->

+ 1 - 1
modules/boonex/notes/classes/BxNotesPageNote.php

@@ -11,6 +11,7 @@
 
 
 bx_import('BxTemplPage');
 bx_import('BxTemplPage');
 bx_import('BxDolModule');
 bx_import('BxDolModule');
+bx_import('BxDolMenu');
 
 
 /**
 /**
  * Note create/edit pages.
  * Note create/edit pages.
@@ -27,7 +28,6 @@ class BxNotesPageNote extends BxTemplPage {
         parent::__construct($aObject, $oTemplate);
         parent::__construct($aObject, $oTemplate);
 
 
         // select view note submenu
         // select view note submenu
-        bx_import('BxDolMenu');
         $oMenuSumbemu = BxDolMenu::getObjectInstance('sys_site_submenu');
         $oMenuSumbemu = BxDolMenu::getObjectInstance('sys_site_submenu');
         $oMenuSumbemu->setObjectSubmenu('bx_notes_view_submenu', 'notes-home');
         $oMenuSumbemu->setObjectSubmenu('bx_notes_view_submenu', 'notes-home');
 
 

+ 1 - 0
modules/boonex/persons/classes/BxPersonsConfig.php

@@ -13,6 +13,7 @@ bx_import('BxDolModuleConfig');
 
 
 class BxPersonsConfig extends BxDolModuleConfig {
 class BxPersonsConfig extends BxDolModuleConfig {
 
 
+    public static $FIELD_ID = 'id';
     public static $FIELD_AUTHOR = 'author';
     public static $FIELD_AUTHOR = 'author';
     public static $FIELD_ADDED = 'added';
     public static $FIELD_ADDED = 'added';
     public static $FIELD_CHANGED = 'changed';
     public static $FIELD_CHANGED = 'changed';

+ 29 - 8
modules/boonex/persons/classes/BxPersonsMenuViewPerson.php

@@ -26,8 +26,17 @@ class BxPersonsMenuViewPerson extends BxTemplMenu {
 
 
         $this->_oModule = BxDolModule::getInstance('bx_persons');
         $this->_oModule = BxDolModule::getInstance('bx_persons');
         $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
         $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
-        if ($this->_aContentInfo)
-            $this->addMarkers(array('content_id' => $this->_aContentInfo['id']));
+
+        if ($this->_aContentInfo) {
+
+            $oProfileAuthor = BxDolProfile::getInstance($this->_aContentInfo[BxPersonsConfig::$FIELD_AUTHOR]);
+            $oProfile = $oProfileAuthor ? BxDolProfile::getInstanceByContentTypeAccount($iContentId, 'bx_persons', $oProfileAuthor->getAccountId()) : false;
+
+            $this->addMarkers(array(
+                'content_id' => $this->_aContentInfo['id'],
+                'profile_id' => $oProfile ? $oProfile->id() : 0
+            ));
+        }
     }
     }
 
 
     /**
     /**
@@ -37,6 +46,11 @@ class BxPersonsMenuViewPerson extends BxTemplMenu {
      */ 
      */ 
     protected function _isVisible ($a) {
     protected function _isVisible ($a) {
 
 
+        // default visible settings
+        bx_import('BxDolAcl');
+        if (!BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']))
+            return false;
+
         // don't show current item, also this will solve problem when only one view note item is visible
         // don't show current item, also this will solve problem when only one view note item is visible
         if ('bx_persons_view' == $this->_sObject && $this->_isSelected($a))
         if ('bx_persons_view' == $this->_sObject && $this->_isSelected($a))
             return false;
             return false;
@@ -52,14 +66,21 @@ class BxPersonsMenuViewPerson extends BxTemplMenu {
             case 'delete-persons-profile':
             case 'delete-persons-profile':
                 $sFuncCheckAccess = 'isAllowedDelete';
                 $sFuncCheckAccess = 'isAllowedDelete';
                 break;
                 break;
+            case 'profile-connect-add':
+                $sFuncCheckAccess = 'isAllowedConnectAdd';
+                break;
+            case 'profile-connect-remove':
+                $sFuncCheckAccess = 'isAllowedConnectRemove';
+                break;
+            case 'profile-subscribe-add':
+                $sFuncCheckAccess = 'isAllowedSubscribeAdd';
+                break;
+            case 'profile-subscribe-remove':
+                $sFuncCheckAccess = 'isAllowedSubscribeRemove';
+                break;
         }
         }
 
 
-        if ($sFuncCheckAccess && CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->$sFuncCheckAccess($this->_aContentInfo))
-            return true;
-
-        // default visible settings
-        bx_import('BxDolAcl');
-        return BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']);
+        return $sFuncCheckAccess && CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->$sFuncCheckAccess($this->_aContentInfo) ? true : false;
     }
     }
 
 
 }
 }

+ 47 - 1
modules/boonex/persons/classes/BxPersonsModule.php

@@ -81,7 +81,7 @@ class BxPersonsModule extends BxDolModule implements iBxDolProfileService {
         return $this->_serviceBrowse ('recent');
         return $this->_serviceBrowse ('recent');
     }
     }
 
 
-    public function serviceBrowseConnections ($iProfileId, $sObjectConnections = 'sys_profiles_friends', $sConnectionsType = 'content', $iMutual = false, $iDesignBox = BX_DB_PADDING_DEF) {
+    public function serviceBrowseConnections ($iProfileId, $sObjectConnections = 'sys_profiles_connections', $sConnectionsType = 'content', $iMutual = false, $iDesignBox = BX_DB_PADDING_DEF) {
         return $this->_serviceBrowse (
         return $this->_serviceBrowse (
             'connections', 
             'connections', 
             array(
             array(
@@ -333,6 +333,52 @@ class BxPersonsModule extends BxDolModule implements iBxDolProfileService {
         return _t('_sys_txt_access_denied');
         return _t('_sys_txt_access_denied');
     }
     }
 
 
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. 
+     */
+    function isAllowedConnectAdd (&$aDataEntry, $isPerformAction = false) {
+        return $this->_isAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_connections', true, false);
+    }
+
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. 
+     */
+    function isAllowedConnectRemove (&$aDataEntry, $isPerformAction = false) {
+        return $this->_isAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_connections', true, true);
+    }
+
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. 
+     */
+    function isAllowedSubscribeAdd (&$aDataEntry, $isPerformAction = false) {
+        return $this->_isAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_subscriptions', false, false);
+    }
+
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. 
+     */
+    function isAllowedSubscribeRemove (&$aDataEntry, $isPerformAction = false) {
+        return $this->_isAllowedConnect ($aDataEntry, $isPerformAction, 'sys_profiles_subscriptions', false, true);
+    }
+
+    function _isAllowedConnect (&$aDataEntry, $isPerformAction, $sObjConnection, $isMutual, $isInvertResult) {
+        if (!$this->_iProfileId)
+            return _t('_sys_txt_access_denied');
+
+        $oProfileAuthor = BxDolProfile::getInstance($aDataEntry[BxPersonsConfig::$FIELD_AUTHOR]);
+        $oProfile = $oProfileAuthor ? BxDolProfile::getInstanceByContentTypeAccount($aDataEntry[BxPersonsConfig::$FIELD_ID], 'bx_persons', $oProfileAuthor->getAccountId()) : false;
+        if (!$oProfile || $oProfile->id() == $this->_iProfileId)
+            return _t('_sys_txt_access_denied');
+
+        bx_import('BxDolConnection');
+        $oConn = BxDolConnection::getObjectInstance($sObjConnection);
+        $isConnected = $oConn->isConnected($this->_iProfileId, $oProfile->id(), $isMutual);
+
+        if ($isInvertResult)
+            $isConnected = !$isConnected;
+
+        return $isConnected ? _t('_sys_txt_access_denied') : CHECK_ACTION_RESULT_ALLOWED;
+    }
 }
 }
 
 
 /** @} */ 
 /** @} */ 

+ 29 - 5
modules/boonex/persons/classes/BxPersonsPageProfile.php

@@ -13,6 +13,7 @@ bx_import('BxTemplPage');
 bx_import('BxDolModule');
 bx_import('BxDolModule');
 bx_import('BxDolMenu');
 bx_import('BxDolMenu');
 bx_import('BxDolProfile');
 bx_import('BxDolProfile');
+bx_import('BxDolInformer');
 
 
 /**
 /**
  * Profile create/edit/delete pages.
  * Profile create/edit/delete pages.
@@ -31,6 +32,8 @@ class BxPersonsPageProfile extends BxTemplPage {
     public function __construct($aObject, $oTemplate = false) {
     public function __construct($aObject, $oTemplate = false) {
         parent::__construct($aObject, $oTemplate);
         parent::__construct($aObject, $oTemplate);
 
 
+        $aInformers = array ();
+
         // get profile info
         // get profile info
         $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
         $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
         if ($iContentId) {
         if ($iContentId) {
@@ -55,24 +58,45 @@ class BxPersonsPageProfile extends BxTemplPage {
         $oMenuAction = BxDolMenu::getObjectInstance('sys_site_action');
         $oMenuAction = BxDolMenu::getObjectInstance('sys_site_action');
         $oMenuAction->setActionsMenu('bx_persons_view');        
         $oMenuAction->setActionsMenu('bx_persons_view');        
 
 
-        // add replacible markers
+        // add replaceable markers
         $this->addMarkers($this->_aContentInfo); // every profile field can be used as marker
         $this->addMarkers($this->_aContentInfo); // every profile field can be used as marker
+        $this->addMarkers(array('profile_id' => $this->_oProfile->id())); // profile id field is also suported
 
 
         // display message if profile isn't active
         // display message if profile isn't active
         if (bx_get_logged_profile_id() == $this->_oProfileAuthor->id()) { 
         if (bx_get_logged_profile_id() == $this->_oProfileAuthor->id()) { 
             $sStatus = $this->_aContentInfo['profile_status'];
             $sStatus = $this->_aContentInfo['profile_status'];
             if (isset($this->_aMapStatus2LangKey[$sStatus])) {
             if (isset($this->_aMapStatus2LangKey[$sStatus])) {
-                bx_import('BxDolInformer');
-                $oInformer = BxDolInformer::getInstance($this->_oTemplate);
-                if ($oInformer)
-                    $oInformer->add('bx-persons-status-not-active', _t($this->_aMapStatus2LangKey[$sStatus]), BX_INFORMER_ALERT);
+                $aInformers[] = array ('name' => 'bx-persons-status-not-active', 'msg' => _t($this->_aMapStatus2LangKey[$sStatus]), 'type' => BX_INFORMER_ALERT);
             }
             }
         }
         }
 
 
+        // display pending connetion requests
+        if (isLogged()) {
+            $aInformer = false;
+            bx_import('BxDolConnection');
+            $oConn = BxDolConnection::getObjectInstance('sys_profiles_connections');
+            if ($oConn->isConnectedNotMutual(bx_get_logged_profile_id(), $this->_oProfile->id()))
+                $aInformer = array ('name' => 'bx-persons-connection-pending-initiator', 'msg' => _t('_bx_persons_txt_connection_pending_initiator'), 'type' => BX_INFORMER_ALERT);
+            elseif ($oConn->isConnectedNotMutual($this->_oProfile->id(), bx_get_logged_profile_id()))
+                $aInformer = array ('name' => 'bx-persons-connection-pending-content', 'msg' => _t('_bx_persons_txt_connection_pending_content'), 'type' => BX_INFORMER_ALERT);
+            if ($aInformer)
+                $aInformers[] = $aInformer;
+        }
+
         // display message if it is possible to switch to this profile
         // display message if it is possible to switch to this profile
         $oProfile = $this->_aContentInfo ? BxDolProfile::getInstanceByContentTypeAccount($this->_aContentInfo['id'], 'bx_persons') : false;
         $oProfile = $this->_aContentInfo ? BxDolProfile::getInstanceByContentTypeAccount($this->_aContentInfo['id'], 'bx_persons') : false;
         if ($oProfile)
         if ($oProfile)
             $oProfile->checkSwitchToProfile($this->_oTemplate);
             $oProfile->checkSwitchToProfile($this->_oTemplate);
+
+        // add informers
+        if ($aInformers) {            
+            $oInformer = BxDolInformer::getInstance($this->_oTemplate);
+            if ($oInformer) {
+                foreach ($aInformers as $a)
+                    $oInformer->add($a['name'], $this->_replaceMarkers($a['msg']), $a['type']);
+            }
+        }
+
     }
     }
 
 
     public function getCode () {
     public function getCode () {

+ 2 - 0
modules/boonex/persons/install/langs/en.xml

@@ -89,6 +89,8 @@
 
 
     <string name="_bx_persons_txt_account_pending"><![CDATA[This profile is pending approval, please wait until it is activated.]]></string>
     <string name="_bx_persons_txt_account_pending"><![CDATA[This profile is pending approval, please wait until it is activated.]]></string>
     <string name="_bx_persons_txt_account_suspended"><![CDATA[This profile is suspended.]]></string>
     <string name="_bx_persons_txt_account_suspended"><![CDATA[This profile is suspended.]]></string>
+    <string name="_bx_persons_txt_connection_pending_initiator"><![CDATA[Your connection request to this profile is awaiting confirmation.]]></string>
+    <string name="_bx_persons_txt_connection_pending_content"><![CDATA[You have pending connection request from this profile - <a href="javascript:void(0);" onclick="bx_conn_action('sys_profiles_connections', 'add', '{profile_id}')">Accept</a> or <a href="javascript:void(0);" onclick="bx_conn_action('sys_profiles_connections', 'reject', '{profile_id}')">Reject</a>?]]></string>
 
 
     <string name="_bx_persons_txt_change_image"><![CDATA[Change Picure]]></string>
     <string name="_bx_persons_txt_change_image"><![CDATA[Change Picure]]></string>
     <string name="_bx_persons_txt_no_picture_uploaded"><![CDATA[No picture uploaded]]></string>
     <string name="_bx_persons_txt_no_picture_uploaded"><![CDATA[No picture uploaded]]></string>

+ 7 - 3
modules/boonex/persons/install/sql/enable.sql

@@ -133,9 +133,13 @@ INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES
 ('bx_persons_view', 'bx_persons', '_bx_persons_menu_set_title_view_person', 0);
 ('bx_persons_view', 'bx_persons', '_bx_persons_menu_set_title_view_person', 0);
 
 
 INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
 INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
-('bx_persons_view', 'bx_persons', 'view-persons-profile', '_bx_persons_menu_item_title_system_view_person', '_bx_persons_menu_item_title_view_person', 'page.php?i=view-persons-profile&id={content_id}', '', '', 'user', '', 0, 1, 0, 0),
-('bx_persons_view', 'bx_persons', 'edit-persons-profile', '_bx_persons_menu_item_title_system_edit_person', '_bx_persons_menu_item_title_edit_person', 'page.php?i=edit-persons-profile&id={content_id}', '', '', 'pencil', '', 0, 1, 0, 1),
-('bx_persons_view', 'bx_persons', 'delete-persons-profile', '_bx_persons_menu_item_title_system_delete_person', '_bx_persons_menu_item_title_delete_person', 'page.php?i=delete-persons-profile&id={content_id}', '', '', 'remove', '', 0, 1, 0, 2);
+('bx_persons_view', 'bx_persons', 'profile-connect-add', '_bx_persons_menu_item_title_system_connect', '_bx_persons_menu_item_title_connect', 'javascript:void(0)', 'bx_conn_action(\'sys_profiles_connections\', \'add\', \'{profile_id}\')', '', 'smile', '', 2147483647, 1, 0, 0),
+('bx_persons_view', 'bx_persons', 'profile-connect-remove', '_bx_persons_menu_item_title_system_connect', '_bx_persons_menu_item_title_connect', 'javascript:void(0)', 'bx_conn_action(\'sys_profiles_connections\', \'remove\', \'{profile_id}\', true)', '', 'frown', '', 2147483647, 1, 0, 1),
+('bx_persons_view', 'bx_persons', 'profile-subscribe-add', '_bx_persons_menu_item_title_system_subscribe', '_bx_persons_menu_item_title_subscribe', 'javascript:void(0)', 'bx_conn_action(\'sys_profiles_subscriptions\', \'add\', \'{profile_id}\')', '', 'plus-sign-alt', '', 2147483647, 1, 0, 2),
+('bx_persons_view', 'bx_persons', 'profile-subscribe-remove', '_bx_persons_menu_item_title_system_subscribe', '_bx_persons_menu_item_title_subscribe', 'javascript:void(0)', 'bx_conn_action(\'sys_profiles_subscriptions\', \'remove\', \'{profile_id}\')', '', 'minus-sign-alt', '', 2147483647, 1, 0, 3),
+('bx_persons_view', 'bx_persons', 'view-persons-profile', '_bx_persons_menu_item_title_system_view_person', '_bx_persons_menu_item_title_view_person', 'page.php?i=view-persons-profile&id={content_id}', '', '', 'user', '', 2147483647, 1, 0, 4),
+('bx_persons_view', 'bx_persons', 'edit-persons-profile', '_bx_persons_menu_item_title_system_edit_person', '_bx_persons_menu_item_title_edit_person', 'page.php?i=edit-persons-profile&id={content_id}', '', '', 'pencil', '', 2147483647, 1, 0, 5),
+('bx_persons_view', 'bx_persons', 'delete-persons-profile', '_bx_persons_menu_item_title_system_delete_person', '_bx_persons_menu_item_title_delete_person', 'page.php?i=delete-persons-profile&id={content_id}', '', '', 'remove', '', 2147483647, 1, 0, 6);
 
 
 --
 --
 -- Dumping data for 'bx_persons_view_submenu' menu
 -- Dumping data for 'bx_persons_view_submenu' menu

+ 7 - 7
samples/connections.php

@@ -49,11 +49,11 @@ function PageCompMainCode() {
     // config: for data generation
     // config: for data generation
     $iMutual = 2; // around 2 mutual connections for each profile
     $iMutual = 2; // around 2 mutual connections for each profile
     $iOneWay = 1; // around 1 one-way connections for each profile
     $iOneWay = 1; // around 1 one-way connections for each profile
-    $sTable = "`sys_profiles_conn_friends`"; // to clean table before inserting genrated data
+    $sTable = "`sys_profiles_conn_connections`"; // to clean table before inserting genrated data
 
 
     // config: for displaying and data generation
     // config: for displaying and data generation
     $sType = 'bx_persons'; // profiles type
     $sType = 'bx_persons'; // profiles type
-    $sObject = 'sys_profiles_friends'; // connections object
+    $sObject = 'sys_profiles_connections'; // connections object
 
 
 
 
     if ('gen' == bx_get('action') || (isset($_SERVER['argv'][1]) && 'gen' == $_SERVER['argv'][1])) {
     if ('gen' == bx_get('action') || (isset($_SERVER['argv'][1]) && 'gen' == $_SERVER['argv'][1])) {
@@ -140,19 +140,19 @@ function PageCompMainCode() {
         case 'search-results':
         case 'search-results':
 
 
             echo "<h2>Mutual Content (like Friends)</h2>";
             echo "<h2>Mutual Content (like Friends)</h2>";
-            echo BxDolService::call('bx_persons', 'browse_connections', array($iProfileId, 'sys_profiles_friends', 'content', 1, BX_DB_CONTENT_ONLY));
+            echo BxDolService::call('bx_persons', 'browse_connections', array($iProfileId, 'sys_profiles_connections', 'content', 1, BX_DB_CONTENT_ONLY));
 
 
             echo "<h2>Connected Content</h2>";
             echo "<h2>Connected Content</h2>";
-            echo BxDolService::call('bx_persons', 'browse_connections', array($iProfileId, 'sys_profiles_friends', 'content', false, BX_DB_CONTENT_ONLY));
+            echo BxDolService::call('bx_persons', 'browse_connections', array($iProfileId, 'sys_profiles_connections', 'content', false, BX_DB_CONTENT_ONLY));
 
 
             echo "<h2>Connected Initiators</h2>";
             echo "<h2>Connected Initiators</h2>";
-            echo BxDolService::call('bx_persons', 'browse_connections', array($iProfileId, 'sys_profiles_friends', 'initiators', false, BX_DB_CONTENT_ONLY));
+            echo BxDolService::call('bx_persons', 'browse_connections', array($iProfileId, 'sys_profiles_connections', 'initiators', false, BX_DB_CONTENT_ONLY));
 
 
             echo "<h2>Connected Content without mutual content (like Friend Requests sent)</h2>";
             echo "<h2>Connected Content without mutual content (like Friend Requests sent)</h2>";
-            echo BxDolService::call('bx_persons', 'browse_connections', array($iProfileId, 'sys_profiles_friends', 'content', 0, BX_DB_CONTENT_ONLY));
+            echo BxDolService::call('bx_persons', 'browse_connections', array($iProfileId, 'sys_profiles_connections', 'content', 0, BX_DB_CONTENT_ONLY));
 
 
             echo "<h2>Connected Initiators without mutual content (like Friend Requests received)</h2>";
             echo "<h2>Connected Initiators without mutual content (like Friend Requests received)</h2>";
-            echo BxDolService::call('bx_persons', 'browse_connections', array($iProfileId, 'sys_profiles_friends', 'initiators', 0, BX_DB_CONTENT_ONLY));
+            echo BxDolService::call('bx_persons', 'browse_connections', array($iProfileId, 'sys_profiles_connections', 'initiators', 0, BX_DB_CONTENT_ONLY));
             
             
         break;
         break;
     }
     }