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

Ticket #241: Content notifications themselves. Integration with New comment and New vote.

AntonLV 10 лет назад
Родитель
Сommit
856ad79b35

+ 15 - 2
inc/classes/BxDolCmts.php

@@ -298,6 +298,7 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
                     `ObjectVote` AS `object_vote`,
                     `TriggerTable` AS `trigger_table`,
                     `TriggerFieldId` AS `trigger_field_id`,
+                    `TriggerFieldAuthor` AS `trigger_field_author`,
                     `TriggerFieldTitle` AS `trigger_field_title`,
                     `TriggerFieldComments` AS `trigger_field_comments`,
                     `ClassName` AS `class_name`,
@@ -478,6 +479,14 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
         return $this->_oQuery->getTableName ();
     }
 
+	public function getObjectAuthorId ($iObjectId = 0)
+    {
+    	if(empty($this->_aSystem['trigger_field_author']))
+    		return 0;
+
+        return $this->_oQuery->getObjectAuthorId ($iObjectId ? $iObjectId : $this->getId());
+    }
+
     public function getObjectTitle ($iObjectId = 0)
     {
     	if(empty($this->_aSystem['trigger_field_title']))
@@ -779,7 +788,8 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
             return;
         }
 
-        if($this->_oQuery->removeComment ($this->getId(), $aCmt['cmt_id'], $aCmt['cmt_parent_id'])) {
+        $iCmtObjectId = $this->getId();
+        if($this->_oQuery->removeComment($iCmtObjectId, $aCmt['cmt_id'], $aCmt['cmt_parent_id'])) {
             $this->_triggerComment();
 
             $oStorage = BxDolStorage::getObjectInstance($this->getStorageObjectName());
@@ -794,9 +804,12 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
 
             $this->deleteMetaInfo ($aCmt['cmt_id']);
 
-            $oZ = new BxDolAlerts($this->_sSystem, 'commentRemoved', $this->getId(), $iCmtAuthorId, array('comment_id' => $aCmt['cmt_id'], 'comment_author_id' => $aCmt['cmt_author_id']));
+            $oZ = new BxDolAlerts($this->_sSystem, 'commentRemoved', $iCmtObjectId, $iCmtAuthorId, array('comment_id' => $aCmt['cmt_id'], 'comment_author_id' => $aCmt['cmt_author_id']));
             $oZ->alert();
 
+            $oZ = new BxDolAlerts('comment', 'deleted', $aCmt['cmt_id'], $iCmtAuthorId, array('object_system' => $this->_sSystem, 'object_id' => $iCmtObjectId));
+        	$oZ->alert();
+
             $this->_echoResultJson(array('id' => $iCmtId));
             return;
         }

+ 8 - 0
inc/classes/BxDolCmtsQuery.php

@@ -17,6 +17,7 @@ class BxDolCmtsQuery extends BxDolDb
     protected $_sTable;
     protected $_sTriggerTable;
     protected $_sTriggerFieldId;
+    protected $_sTriggerFieldAuthor;
     protected $_sTriggerFieldTitle;
     protected $_sTriggerFieldComments;
 
@@ -33,6 +34,7 @@ class BxDolCmtsQuery extends BxDolDb
         $this->_sTable = $aSystem['table'];
         $this->_sTriggerTable = $aSystem['trigger_table'];
         $this->_sTriggerFieldId = $aSystem['trigger_field_id'];
+        $this->_sTriggerFieldAuthor = $aSystem['trigger_field_author'];
         $this->_sTriggerFieldTitle = $aSystem['trigger_field_title'];
         $this->_sTriggerFieldComments = $aSystem['trigger_field_comments'];
 
@@ -347,6 +349,12 @@ class BxDolCmtsQuery extends BxDolDb
         return $this->query ($sQuery);
     }
 
+	function getObjectAuthorId($iId)
+    {
+        $sQuery = $this->prepare("SELECT `{$this->_sTriggerFieldAuthor}` FROM `{$this->_sTriggerTable}` WHERE `{$this->_sTriggerFieldId}` = ? LIMIT 1", $iId);
+        return $this->getOne($sQuery);
+    }
+
     function getObjectTitle($iId)
     {
         $sQuery = $this->prepare("SELECT `{$this->_sTriggerFieldTitle}` FROM `{$this->_sTriggerTable}` WHERE `{$this->_sTriggerFieldId}` = ? LIMIT 1", $iId);

+ 15 - 1
inc/classes/BxDolVote.php

@@ -145,6 +145,7 @@ class BxDolVote extends BxDolObject
                     `IsOn` AS `is_on`,
                     `TriggerTable` AS `trigger_table`,
                     `TriggerFieldId` AS `trigger_field_id`,
+                    `TriggerFieldAuthor` AS `trigger_field_author`,
                     `TriggerFieldRate` AS `trigger_field_rate`,
                     `TriggerFieldRateCount` AS `trigger_field_count`,
                     `ClassName` AS `class_name`,
@@ -201,6 +202,14 @@ class BxDolVote extends BxDolObject
         return (int)$this->_aSystem['max_value'];
     }
 
+	public function getObjectAuthorId($iObjectId = 0)
+    {
+    	if(empty($this->_aSystem['trigger_field_author']))
+    		return 0;
+
+        return $this->_oQuery->getObjectAuthorId($iObjectId ? $iObjectId : $this->getId());
+    }
+
     /**
      * Interface functions for outer usage
      */
@@ -224,6 +233,7 @@ class BxDolVote extends BxDolObject
         return $this->_oQuery->getSqlParts($sMainTable, $sMainField);
     }
 
+
     /**
      * Actions functions
      */
@@ -235,6 +245,7 @@ class BxDolVote extends BxDolObject
         }
 
         $iObjectId = $this->getId();
+        $iObjectAuthorId = $this->getObjectAuthorId($iObjectId);
         $iAuthorId = $this->_getAuthorId();
         $iAuthorIp = $this->_getAuthorIp();
 
@@ -278,7 +289,10 @@ class BxDolVote extends BxDolObject
 
         $this->_triggerVote();
 
-        $oZ = new BxDolAlerts($this->_sSystem, ($bPerformUndo ? 'un' : '') . 'doVote', $this->getId(), $iAuthorId, array('vote_id' => $iId, 'vote_author_id' => $iAuthorId, 'value' => $iValue));
+        $oZ = new BxDolAlerts($this->_sSystem, ($bPerformUndo ? 'un' : '') . 'doVote', $iObjectId, $iAuthorId, array('vote_id' => $iId, 'vote_author_id' => $iAuthorId, 'object_author_id' => $iObjectAuthorId, 'value' => $iValue));
+        $oZ->alert();
+
+        $oZ = new BxDolAlerts('vote', ($bPerformUndo ? 'un' : '') . 'do', $iId, $iAuthorId, array('object_system' => $this->_sSystem, 'object_id' => $iObjectId, 'object_author_id' => $iObjectAuthorId, 'value' => $iValue));
         $oZ->alert();
 
         $aVote = $this->_oQuery->getVote($iObjectId);

+ 8 - 0
inc/classes/BxDolVoteQuery.php

@@ -18,6 +18,7 @@ class BxDolVoteQuery extends BxDolDb
     protected $_sTableTrack;
     protected $_sTriggerTable;
     protected $_sTriggerFieldId;
+    protected $_sTriggerFieldAuthor;
     protected $_sTriggerFieldRate;
     protected $_sTriggerFieldCount;
 
@@ -34,6 +35,7 @@ class BxDolVoteQuery extends BxDolDb
         $this->_sTableTrack = $aSystem['table_track'];
         $this->_sTriggerTable = $aSystem['trigger_table'];
         $this->_sTriggerFieldId = $aSystem['trigger_field_id'];
+        $this->_sTriggerFieldAuthor = $aSystem['trigger_field_author'];
         $this->_sTriggerFieldRate = $aSystem['trigger_field_rate'];
         $this->_sTriggerFieldCount = $aSystem['trigger_field_count'];
 
@@ -132,6 +134,12 @@ class BxDolVoteQuery extends BxDolDb
         $this->query ("OPTIMIZE TABLE {$this->_sTableTrack}");
     }
 
+	public function getObjectAuthorId($iId)
+    {
+        $sQuery = $this->prepare("SELECT `{$this->_sTriggerFieldAuthor}` FROM `{$this->_sTriggerTable}` WHERE `{$this->_sTriggerFieldId}` = ? LIMIT 1", $iId);
+        return $this->getOne($sQuery);
+    }
+
     public function updateTriggerTable($iObjectId)
     {
         $aVote = $this->getVote($iObjectId);

+ 4 - 2
install/sql/system.sql

@@ -121,6 +121,7 @@ CREATE TABLE `sys_objects_cmts` (
   `ObjectVote` varchar(64) NOT NULL,
   `TriggerTable` varchar(32) NOT NULL,
   `TriggerFieldId` varchar(32) NOT NULL,
+  `TriggerFieldAuthor` varchar(32) NOT NULL,
   `TriggerFieldTitle` varchar(32) NOT NULL,
   `TriggerFieldComments` varchar(32) NOT NULL,
   `ClassName` varchar(32) NOT NULL,
@@ -734,6 +735,7 @@ CREATE TABLE `sys_objects_vote` (
   `IsOn` tinyint(1) NOT NULL default '1',
   `TriggerTable` varchar(32) NOT NULL default '',
   `TriggerFieldId` varchar(32) NOT NULL default '',
+  `TriggerFieldAuthor` varchar(32) NOT NULL default '',
   `TriggerFieldRate` varchar(32) NOT NULL default '',
   `TriggerFieldRateCount` varchar(32) NOT NULL default '',
   `ClassName` varchar(32) NOT NULL default '',
@@ -741,8 +743,8 @@ CREATE TABLE `sys_objects_vote` (
   PRIMARY KEY  (`ID`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 
-INSERT INTO `sys_objects_vote` (`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
-('sys_cmts', 'sys_cmts_votes', 'sys_cmts_votes_track', '604800', '1', '1', '0', '1', 'sys_cmts_ids', 'id', 'rate', 'votes', '', '');
+INSERT INTO `sys_objects_vote` (`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
+('sys_cmts', 'sys_cmts_votes', 'sys_cmts_votes_track', '604800', '1', '1', '0', '1', 'sys_cmts_ids', 'id', '', 'rate', 'votes', '', '');
 
 
 -- -------------------------------------------------------

+ 1 - 0
modules/base/notifications/classes/BxBaseModNotificationsModule.php

@@ -14,6 +14,7 @@ define('BX_BASE_MOD_NTFS_HANDLER_TYPE_UPDATE', 'update');
 define('BX_BASE_MOD_NTFS_HANDLER_TYPE_DELETE', 'delete');
 
 define('BX_BASE_MOD_NTFS_TYPE_OWNER', 'owner');
+define('BX_BASE_MOD_NTFS_TYPE_OBJECT_OWNER', 'object_owner');
 define('BX_BASE_MOD_NTFS_TYPE_CONNECTIONS', 'connections');
 define('BX_BASE_MOD_NTFS_TYPE_PUBLIC', 'public');
 

+ 6 - 1
modules/base/notifications/classes/BxBaseModNotificationsResponse.php

@@ -18,7 +18,12 @@ class BxBaseModNotificationsResponse extends BxDolAlertsResponse
         parent::__construct();
     }
 
-    protected function _getPrivacyView($aExtras)
+	protected function _getObjectOwnerId($aExtras)
+    {
+        return is_array($aExtras) && isset($aExtras['object_author_id']) ? (int)$aExtras['object_author_id'] : 0;
+    }
+
+    protected function _getObjectPrivacyView($aExtras)
     {
         return is_array($aExtras) && isset($aExtras['privacy_view']) ? (int)$aExtras['privacy_view'] : $this->_oModule->_oConfig->getPrivacyViewDefault();
     }

+ 10 - 3
modules/base/text/classes/BxBaseModTextFormsEntryHelper.php

@@ -90,8 +90,12 @@ class BxBaseModTextFormsEntryHelper extends BxBaseModGeneralFormsEntryHelper
         if ($oProfile->isActive() && !empty($aTrackTextFieldsChanges['changed_fields']))
             $oProfile->disapprove(BX_PROFILE_ACTION_AUTO);
 
-        // create an alert
-        bx_alert($this->_oModule->getName(), 'edited', $aContentInfo[$CNF['FIELD_ID']], false, array('privacy_view' => $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]));
+        // alert
+        $aParams = array('object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']]);
+        if(isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]))
+        	$aParams['privacy_view'] = $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']];
+
+        bx_alert($this->_oModule->getName(), 'edited', $aContentInfo[$CNF['FIELD_ID']], false, $aParams);
 
         return '';
     }
@@ -107,7 +111,10 @@ class BxBaseModTextFormsEntryHelper extends BxBaseModGeneralFormsEntryHelper
             return MsgBox(_t('_sys_txt_error_occured'));
 
         // alert
-        $aParams = isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) ? array('privacy_view' => $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) : array();
+        $aParams = array('object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']]);
+        if(isset($aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]))
+        	$aParams['privacy_view'] = $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']];
+
         bx_alert($this->_oModule->getName(), 'added', $iContentId, false, $aParams);
 
         return '';

+ 3 - 0
modules/base/text/classes/BxBaseModTextModule.php

@@ -233,6 +233,7 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
 			'entry_sample' => _t($CNF['T']['txt_sample_single']),
 			'entry_url' => $sEntryUrl,
 			'entry_caption' => $sEntryCaption,
+			'entry_author' => $aContentInfo[$CNF['FIELD_AUTHOR']],
 			'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
 		);
     }
@@ -260,6 +261,7 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
 			'entry_sample' => _t($CNF['T']['txt_sample_single']),
 			'entry_url' => $sEntryUrl,
 			'entry_caption' => $sEntryCaption,
+			'entry_author' => $aContentInfo[$CNF['FIELD_AUTHOR']],
 			'subentry_sample' => _t($CNF['T']['txt_sample_comment_single']),
 			'subentry_url' => $oComment->getViewUrl((int)$aEvent['subobject_id']),
 			'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
@@ -289,6 +291,7 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
 			'entry_sample' => _t($CNF['T']['txt_sample_single']),
 			'entry_url' => $sEntryUrl,
 			'entry_caption' => $sEntryCaption,
+			'entry_author' => $aContentInfo[$CNF['FIELD_AUTHOR']],
 			'subentry_sample' => _t($CNF['T']['txt_sample_vote_single']),
 			'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
 		);

+ 6 - 6
modules/boonex/albums/install/sql/install.sql

@@ -282,15 +282,15 @@ INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_fo
 
 -- COMMENTS
 
-INSERT INTO `sys_objects_cmts` (`Name`, `Table`, `CharsPostMin`, `CharsPostMax`, `CharsDisplayMax`, `Nl2br`, `PerView`, `PerViewReplies`, `BrowseType`, `IsBrowseSwitch`, `PostFormPosition`, `NumberOfLevels`, `IsDisplaySwitch`, `IsRatable`, `ViewingThreshold`, `IsOn`, `RootStylePrefix`, `BaseUrl`, `ObjectVote`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldTitle`, `TriggerFieldComments`, `ClassName`, `ClassFile`) VALUES
-('bx_albums', 'bx_albums_cmts', 1, 5000, 1000, 1, 5, 3, 'tail', 1, 'bottom', 1, 1, 1, -3, 1, 'cmt', 'page.php?i=view-album&id={object_id}', '', 'bx_albums_albums', 'id', 'title', 'comments', '', ''),
-('bx_albums_media', 'bx_albums_cmts_media', 1, 5000, 1000, 1, 5, 3, 'tail', 1, 'bottom', 1, 1, 1, -3, 1, 'cmt', 'page.php?i=view-album-media&id={object_id}', '', 'bx_albums_files2albums', 'id', 'title', 'comments', '', '');
+INSERT INTO `sys_objects_cmts` (`Name`, `Table`, `CharsPostMin`, `CharsPostMax`, `CharsDisplayMax`, `Nl2br`, `PerView`, `PerViewReplies`, `BrowseType`, `IsBrowseSwitch`, `PostFormPosition`, `NumberOfLevels`, `IsDisplaySwitch`, `IsRatable`, `ViewingThreshold`, `IsOn`, `RootStylePrefix`, `BaseUrl`, `ObjectVote`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldTitle`, `TriggerFieldComments`, `ClassName`, `ClassFile`) VALUES
+('bx_albums', 'bx_albums_cmts', 1, 5000, 1000, 1, 5, 3, 'tail', 1, 'bottom', 1, 1, 1, -3, 1, 'cmt', 'page.php?i=view-album&id={object_id}', '', 'bx_albums_albums', 'id', 'author', 'title', 'comments', '', ''),
+('bx_albums_media', 'bx_albums_cmts_media', 1, 5000, 1000, 1, 5, 3, 'tail', 1, 'bottom', 1, 1, 1, -3, 1, 'cmt', 'page.php?i=view-album-media&id={object_id}', '', 'bx_albums_files2albums', 'id', '', 'title', 'comments', '', '');
 
 -- VOTES
 
-INSERT INTO `sys_objects_vote` (`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
-('bx_albums', 'bx_albums_votes', 'bx_albums_votes_track', '604800', '1', '1', '0', '1', 'bx_albums_albums', 'id', 'rate', 'votes', '', ''),
-('bx_albums_media', 'bx_albums_votes_media', 'bx_albums_votes_media_track', '604800', '1', '1', '0', '1', 'bx_albums_files2albums', 'id', 'rate', 'votes', '', '');
+INSERT INTO `sys_objects_vote` (`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
+('bx_albums', 'bx_albums_votes', 'bx_albums_votes_track', '604800', '1', '1', '0', '1', 'bx_albums_albums', 'id', 'author', 'rate', 'votes', '', ''),
+('bx_albums_media', 'bx_albums_votes_media', 'bx_albums_votes_media_track', '604800', '1', '1', '0', '1', 'bx_albums_files2albums', 'id', '', 'rate', 'votes', '', '');
 
 -- VIEWS
 

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

@@ -175,8 +175,8 @@ INSERT INTO `sys_acl_matrix` (`IDLevel`, `IDAction`) VALUES
 
 
 -- COMMENTS
-INSERT INTO `sys_objects_cmts` (`Name`, `Table`, `CharsPostMin`, `CharsPostMax`, `CharsDisplayMax`, `Nl2br`, `PerView`, `PerViewReplies`, `BrowseType`, `IsBrowseSwitch`, `PostFormPosition`, `NumberOfLevels`, `IsDisplaySwitch`, `IsRatable`, `ViewingThreshold`, `IsOn`, `RootStylePrefix`, `BaseUrl`, `ObjectVote`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldTitle`, `TriggerFieldComments`, `ClassName`, `ClassFile`) VALUES
-('bx_convos', 'bx_convos_cmts', 1, 5000, 1000, 1, 5, 3, 'tail', 1, 'bottom', 1, 1, 1, -3, 1, 'cmt', 'page.php?i=view-convo&id={object_id}', '', 'bx_convos_conversations', 'id', '', 'comments', 'BxCnvCmts', 'modules/boonex/convos/classes/BxCnvCmts.php');
+INSERT INTO `sys_objects_cmts` (`Name`, `Table`, `CharsPostMin`, `CharsPostMax`, `CharsDisplayMax`, `Nl2br`, `PerView`, `PerViewReplies`, `BrowseType`, `IsBrowseSwitch`, `PostFormPosition`, `NumberOfLevels`, `IsDisplaySwitch`, `IsRatable`, `ViewingThreshold`, `IsOn`, `RootStylePrefix`, `BaseUrl`, `ObjectVote`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldTitle`, `TriggerFieldComments`, `ClassName`, `ClassFile`) VALUES
+('bx_convos', 'bx_convos_cmts', 1, 5000, 1000, 1, 5, 3, 'tail', 1, 'bottom', 1, 1, 1, -3, 1, 'cmt', 'page.php?i=view-convo&id={object_id}', '', 'bx_convos_conversations', 'id', 'author', '', 'comments', 'BxCnvCmts', 'modules/boonex/convos/classes/BxCnvCmts.php');
 
 -- VIEWS
 INSERT INTO `sys_objects_view` (`name`, `table_track`, `period`, `is_on`, `trigger_table`, `trigger_field_id`, `trigger_field_count`, `class_name`, `class_file`) VALUES 

+ 1 - 0
modules/boonex/notifications/classes/BxNtfsConfig.php

@@ -40,6 +40,7 @@ class BxNtfsConfig extends BxBaseModNotificationsConfig
         	'view' => 'BxNtfsView',
         );
         $this->_aJsObjects = array(
+        	'main' => 'oBxNtfsMain',
             'view' => 'oBxNtfsView',
         );
 

+ 4 - 0
modules/boonex/notifications/classes/BxNtfsDb.php

@@ -68,6 +68,10 @@ class BxNtfsDb extends BxBaseModNotificationsDb
 					$sWhereClause .= $this->prepare("AND `{$this->_sTable}`.`owner_id`=? ", $aParams['owner_id']);
 					break;
 
+				case BX_BASE_MOD_NTFS_TYPE_OBJECT_OWNER:
+					$sWhereClause .= $this->prepare("AND `{$this->_sTable}`.`owner_id`<>`{$this->_sTable}`.`object_owner_id` AND `{$this->_sTable}`.`object_owner_id`=? ", $aParams['owner_id']);
+					break;
+
 				case BX_BASE_MOD_NTFS_TYPE_CONNECTIONS:
 					$oConnection = BxDolConnection::getObjectInstance($this->_oConfig->getObject('conn_subscriptions'));
 

+ 27 - 4
modules/boonex/notifications/classes/BxNtfsModule.php

@@ -42,13 +42,15 @@ class BxNtfsModule extends BxBaseModNotificationsModule
      * 
      * Get View block for a separate page. Will return a block with "Empty" message if nothing found.
      */
-    public function serviceGetBlockView($iStart = -1, $iPerPage = -1, $aModules = array())
+    public function serviceGetBlockView($sType = BX_NTFS_TYPE_DEFAULT, $iStart = -1, $iPerPage = -1, $aModules = array())
     {
+    	$aBrowseTypes = array(BX_BASE_MOD_NTFS_TYPE_CONNECTIONS, BX_BASE_MOD_NTFS_TYPE_OBJECT_OWNER);
+
     	$iOwnerId = $this->getUserId();
         if(!$iOwnerId)
-            return array('content' => MsgBox(_t('_bx_timeline_txt_msg_no_results')));
+            return array('content' => MsgBox(_t('_bx_ntfs_txt_msg_no_results')));
 
-		$aParams = $this->_prepareParams(BX_NTFS_TYPE_DEFAULT, $iOwnerId, $iStart, $iPerPage, $aModules);
+		$aParams = $this->_prepareParams($sType, $iOwnerId, $iStart, $iPerPage, $aModules);
 		$sContent = $this->_oTemplate->getViewBlock($aParams);
 
 		$aParams['browse'] = 'first';
@@ -56,7 +58,28 @@ class BxNtfsModule extends BxBaseModNotificationsModule
     	if(!empty($aEvent))
 			$this->_oDb->markAsRead($iOwnerId, $aEvent['id']);
 
-        return array('content' => $sContent); 
+		$sModule = $this->_oConfig->getName();
+		$sJsObject = $this->_oConfig->getJsObject('view');
+
+		$aMenu = array();
+		foreach($aBrowseTypes as $sBrowseType)
+			$aMenu[] = array(
+				'id' => $sModule . '-' . $sBrowseType,
+				'name' => $sModule . '-' . $sBrowseType,
+				'class' => '',
+				'title' => '_bx_ntfs_menu_item_title_' . $sBrowseType,
+				'target' => '_self',
+				'onclick' => 'javascript:' . $sJsObject . '.changeType(this, \'' . $sBrowseType . '\');'
+			);
+
+		$oMenu = new BxTemplMenuInteractive(array(
+        	'template' => 'menu_interactive_vertical.html',
+			'menu_id' => $sModule . '-browse-types',
+        	'menu_items' => $aMenu
+        ), $this->_oTemplate);
+        $oMenu->setSelected($sModule, $sModule . '-' . $sType);
+
+        return array('content' => $sContent, 'menu' => $oMenu); 
     }
 
     public function serviceGetUnreadNotificationsNum($iOwnerId = 0)

+ 5 - 4
modules/boonex/notifications/classes/BxNtfsResponse.php

@@ -25,8 +25,8 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
      */
     public function response($oAlert)
     {
-    	$iPrivacyView = $this->_getPrivacyView($oAlert->aExtras);
-        if($iPrivacyView == BX_DOL_PG_HIDDEN)
+    	$iObjectPrivacyView = $this->_getObjectPrivacyView($oAlert->aExtras);
+        if($iObjectPrivacyView == BX_DOL_PG_HIDDEN)
             return;
 
         $aHandler = $this->_oModule->_oConfig->getHandlers($oAlert->sUnit . '_' . $oAlert->sAction);
@@ -37,7 +37,8 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
                     'type' => $oAlert->sUnit,
                     'action' => $oAlert->sAction,
                     'object_id' => $oAlert->iObject,
-                    'object_privacy_view' => $iPrivacyView,
+                	'object_owner_id' => $this->_getObjectOwnerId($oAlert->aExtras),
+                    'object_privacy_view' => $iObjectPrivacyView,
                 	'subobject_id' => $this->_getSubObjectId($oAlert->aExtras),
                     'content' => '',
                 	'processed' => 0
@@ -49,7 +50,7 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
 				break;
 
             case BX_BASE_MOD_NTFS_HANDLER_TYPE_UPDATE:
-                $this->_oModule->_oDb->updateEvent(array('object_privacy_view' => $iPrivacyView), array('type' => $oAlert->sUnit, 'object_id' => $oAlert->iObject));
+                $this->_oModule->_oDb->updateEvent(array('object_privacy_view' => $iObjectPrivacyView), array('type' => $oAlert->sUnit, 'object_id' => $oAlert->iObject));
                 break;
 
             case BX_BASE_MOD_NTFS_HANDLER_TYPE_DELETE:

+ 12 - 1
modules/boonex/notifications/classes/BxNtfsTemplate.php

@@ -77,9 +77,20 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
     	if((int)$aEvent['processed'] == 0) {
     		$aContent = $this->_getContent($aEvent);
     		if(!empty($aContent) && is_array($aContent)) {
+    			$aSet = array();
+
+    			if(!empty($aContent['entry_author'])) {
+    				$aSet['object_owner_id'] = (int)$aContent['entry_author'];
+    				unset($aContent['entry_author']);
+    			}
+
     			$aEvent['content'] = serialize($aContent);
+    			$aSet = array_merge($aSet, array(
+    				'content' => $aEvent['content'], 
+    				'processed' => 1
+    			));
 
-    			$this->_oDb->updateEvent(array('content' => $aEvent['content'], 'processed' => 1), array('id' => $aEvent['id']));
+    			$this->_oDb->updateEvent($aSet, array('id' => $aEvent['id']));
     		}
     	}
 

+ 3 - 0
modules/boonex/notifications/install/langs/en.xml

@@ -13,6 +13,9 @@
     <string name="_bx_ntfs_menu_item_title_system_notifications"><![CDATA[Notifications]]></string>
     <string name="_bx_ntfs_menu_item_title_notifications"><![CDATA[Notifications]]></string>
 
+	<string name="_bx_ntfs_menu_item_title_connections"><![CDATA[My Subscriptions]]></string>
+	<string name="_bx_ntfs_menu_item_title_object_owner"><![CDATA[My Content]]></string>
+
 	<string name="_bx_ntfs_option_events_per_page"><![CDATA[Number of events are displayed on View page]]></string>
 	<string name="_bx_ntfs_option_events_hide"><![CDATA[Show events in Notifications]]></string>
 

+ 1 - 0
modules/boonex/notifications/install/sql/install.sql

@@ -8,6 +8,7 @@ CREATE TABLE IF NOT EXISTS `bx_notifications_events` (
   `type` varchar(255) collate utf8_unicode_ci NOT NULL,
   `action` varchar(255) collate utf8_unicode_ci NOT NULL,
   `object_id` text collate utf8_unicode_ci NOT NULL,
+  `object_owner_id` int(11) unsigned NOT NULL default '0',
   `object_privacy_view` int(11) NOT NULL default '3',
   `subobject_id` int(11) NOT NULL default '0',
   `content` text collate utf8_unicode_ci NOT NULL,

+ 7 - 0
modules/boonex/notifications/js/view.js

@@ -11,6 +11,13 @@ function BxNtfsView(oOptions) {
 
 BxNtfsView.prototype = new BxNtfsMain();
 
+BxNtfsView.prototype.changeType = function(oElement, sType) {
+	this._oRequestParams.start = 0;
+	this._oRequestParams.type = sType;
+
+    this._getPosts(oElement);
+};
+
 BxNtfsView.prototype.changePage = function(oElement, iStart, iPerPage) {
 	this._oRequestParams.start = iStart;
     this._oRequestParams.per_page = iPerPage;

+ 4 - 4
modules/boonex/posts/install/sql/install.sql

@@ -241,13 +241,13 @@ INSERT INTO `sys_form_pre_values`(`Key`, `Value`, `Order`, `LKey`, `LKey2`) VALU
 
 -- COMMENTS
 
-INSERT INTO `sys_objects_cmts` (`Name`, `Table`, `CharsPostMin`, `CharsPostMax`, `CharsDisplayMax`, `Nl2br`, `PerView`, `PerViewReplies`, `BrowseType`, `IsBrowseSwitch`, `PostFormPosition`, `NumberOfLevels`, `IsDisplaySwitch`, `IsRatable`, `ViewingThreshold`, `IsOn`, `RootStylePrefix`, `BaseUrl`, `ObjectVote`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldTitle`, `TriggerFieldComments`, `ClassName`, `ClassFile`) VALUES
-('bx_posts', 'bx_posts_cmts', 1, 5000, 1000, 1, 5, 3, 'tail', 1, 'bottom', 1, 1, 1, -3, 1, 'cmt', 'page.php?i=view-post&id={object_id}', '', 'bx_posts_posts', 'id', 'title', 'comments', '', '');
+INSERT INTO `sys_objects_cmts` (`Name`, `Table`, `CharsPostMin`, `CharsPostMax`, `CharsDisplayMax`, `Nl2br`, `PerView`, `PerViewReplies`, `BrowseType`, `IsBrowseSwitch`, `PostFormPosition`, `NumberOfLevels`, `IsDisplaySwitch`, `IsRatable`, `ViewingThreshold`, `IsOn`, `RootStylePrefix`, `BaseUrl`, `ObjectVote`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldTitle`, `TriggerFieldComments`, `ClassName`, `ClassFile`) VALUES
+('bx_posts', 'bx_posts_cmts', 1, 5000, 1000, 1, 5, 3, 'tail', 1, 'bottom', 1, 1, 1, -3, 1, 'cmt', 'page.php?i=view-post&id={object_id}', '', 'bx_posts_posts', 'id', 'author', 'title', 'comments', '', '');
 
 -- VOTES
 
-INSERT INTO `sys_objects_vote` (`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
-('bx_posts', 'bx_posts_votes', 'bx_posts_votes_track', '604800', '1', '1', '0', '1', 'bx_posts_posts', 'id', 'rate', 'votes', '', '');
+INSERT INTO `sys_objects_vote` (`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
+('bx_posts', 'bx_posts_votes', 'bx_posts_votes_track', '604800', '1', '1', '0', '1', 'bx_posts_posts', 'id', 'author', 'rate', 'votes', '', '');
 
 -- VIEWS
 

+ 3 - 0
modules/boonex/russian/data/langs/bx_notifications/ru.xml

@@ -13,6 +13,9 @@
     <string name="_bx_ntfs_menu_item_title_system_notifications"><![CDATA[Уведомления]]></string>
     <string name="_bx_ntfs_menu_item_title_notifications"><![CDATA[Уведомления]]></string>
 
+	<string name="_bx_ntfs_menu_item_title_connections"><![CDATA[Мои подписки]]></string>
+	<string name="_bx_ntfs_menu_item_title_object_owner"><![CDATA[Мой контент]]></string>
+
 	<string name="_bx_ntfs_option_events_per_page"><![CDATA[Количество событий, отображаемых на странице Просмотра]]></string>
 	<string name="_bx_ntfs_option_events_hide"><![CDATA[Показывать события в Уведомлениях]]></string>
 

+ 4 - 4
modules/boonex/timeline/classes/BxTimelineResponse.php

@@ -25,8 +25,8 @@ class BxTimelineResponse extends BxBaseModNotificationsResponse
      */
     public function response($oAlert)
     {
-    	$iPrivacyView = $this->_getPrivacyView($oAlert->aExtras);
-        if($iPrivacyView == BX_DOL_PG_HIDDEN)
+    	$iObjectPrivacyView = $this->_getObjectPrivacyView($oAlert->aExtras);
+        if($iObjectPrivacyView == BX_DOL_PG_HIDDEN)
             return;
 
         $aHandler = $this->_oModule->_oConfig->getHandlers($oAlert->sUnit . '_' . $oAlert->sAction);
@@ -39,7 +39,7 @@ class BxTimelineResponse extends BxBaseModNotificationsResponse
                     'type' => $oAlert->sUnit,
                     'action' => $oAlert->sAction,
                     'object_id' => $oAlert->iObject,
-                    'object_privacy_view' => $iPrivacyView,
+                    'object_privacy_view' => $iObjectPrivacyView,
                     'content' => $sContent,
                     'title' => '',
                     'description' => ''
@@ -55,7 +55,7 @@ class BxTimelineResponse extends BxBaseModNotificationsResponse
             case BX_BASE_MOD_NTFS_HANDLER_TYPE_UPDATE:
                 $sContent = !empty($oAlert->aExtras) && is_array($oAlert->aExtras) ? serialize(bx_process_input($oAlert->aExtras)) : '';
 
-                $this->_oModule->_oDb->updateEvent(array('object_privacy_view' => $iPrivacyView, 'content' => $sContent), array('type' => $oAlert->sUnit, 'object_id' => $oAlert->iObject));
+                $this->_oModule->_oDb->updateEvent(array('object_privacy_view' => $iObjectPrivacyView, 'content' => $sContent), array('type' => $oAlert->sUnit, 'object_id' => $oAlert->iObject));
                 break;
 
             case BX_BASE_MOD_NTFS_HANDLER_TYPE_DELETE:

+ 4 - 4
modules/boonex/timeline/install/sql/enable.sql

@@ -164,13 +164,13 @@ INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
 
 
 -- COMMENTS
-INSERT INTO `sys_objects_cmts` (`Name`, `Table`, `CharsPostMin`, `CharsPostMax`, `CharsDisplayMax`, `Nl2br`, `PerView`, `PerViewReplies`, `BrowseType`, `IsBrowseSwitch`, `PostFormPosition`, `NumberOfLevels`, `IsDisplaySwitch`, `IsRatable`, `ViewingThreshold`, `IsOn`, `RootStylePrefix`, `BaseUrl`, `ObjectVote`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldTitle`, `TriggerFieldComments`, `ClassName`, `ClassFile`) VALUES
-('bx_timeline', 'bx_timeline_comments', 1, 5000, 1000, 1, 5, 3, 'tail', 1, 'bottom', 1, 1, 1, -3, 1, 'cmt', 'page.php?i=timeline-item&id={object_id}', '', 'bx_timeline_events', 'id', 'title', 'comments', 'BxTimelineCmts', 'modules/boonex/timeline/classes/BxTimelineCmts.php');
+INSERT INTO `sys_objects_cmts` (`Name`, `Table`, `CharsPostMin`, `CharsPostMax`, `CharsDisplayMax`, `Nl2br`, `PerView`, `PerViewReplies`, `BrowseType`, `IsBrowseSwitch`, `PostFormPosition`, `NumberOfLevels`, `IsDisplaySwitch`, `IsRatable`, `ViewingThreshold`, `IsOn`, `RootStylePrefix`, `BaseUrl`, `ObjectVote`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldTitle`, `TriggerFieldComments`, `ClassName`, `ClassFile`) VALUES
+('bx_timeline', 'bx_timeline_comments', 1, 5000, 1000, 1, 5, 3, 'tail', 1, 'bottom', 1, 1, 1, -3, 1, 'cmt', 'page.php?i=timeline-item&id={object_id}', '', 'bx_timeline_events', 'id', 'object_id', 'title', 'comments', 'BxTimelineCmts', 'modules/boonex/timeline/classes/BxTimelineCmts.php');
 
 
 -- VOTES
-INSERT INTO `sys_objects_vote`(`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
-('bx_timeline', 'bx_timeline_votes', 'bx_timeline_votes_track', '604800', '1', '1', '0', '1', 'bx_timeline_events', 'id', 'rate', 'votes', 'BxTimelineVote', 'modules/boonex/timeline/classes/BxTimelineVote.php');
+INSERT INTO `sys_objects_vote`(`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
+('bx_timeline', 'bx_timeline_votes', 'bx_timeline_votes_track', '604800', '1', '1', '0', '1', 'bx_timeline_events', 'id', 'object_id', 'rate', 'votes', 'BxTimelineVote', 'modules/boonex/timeline/classes/BxTimelineVote.php');
 
 
 -- SEARCH

+ 14 - 3
template/scripts/BxBaseCmts.php

@@ -532,6 +532,8 @@ class BxBaseCmts extends BxDolCmts
         $oForm->initChecker();
 
         if($oForm->isSubmittedAndValid()) {
+        	$iCmtObjectId = (int)$this->getId();
+        	$iCmtObjectAuthorId = $this->getObjectAuthorId($iCmtObjectId);
             $iCmtAuthorId = $this->_getAuthorId();
             $iCmtParentId = $oForm->getCleanValue('cmt_parent_id');
             $sCmtText = $oForm->getCleanValue('cmt_text');
@@ -575,9 +577,12 @@ class BxBaseCmts extends BxDolCmts
                     $oMetatags->keywordsAdd($this->_oQuery->getUniqId($this->_aSystem['system_id'], $iCmtId), $sCmtText);
                 }
 
-                $oZ = new BxDolAlerts($this->_sSystem, 'commentPost', $this->getId(), $iCmtAuthorId, array('comment_id' => $iCmtId, 'comment_author_id' => $iCmtAuthorId));
+                $oZ = new BxDolAlerts($this->_sSystem, 'commentPost', $iCmtObjectId, $iCmtAuthorId, array('comment_id' => $iCmtId, 'comment_author_id' => $iCmtAuthorId, 'object_author_id' => $iCmtObjectAuthorId));
                 $oZ->alert();
 
+                $oZ = new BxDolAlerts('comment', 'added', $iCmtId, $iCmtAuthorId, array('object_system' => $this->_sSystem, 'object_id' => $iCmtObjectId, 'object_author_id' => $iCmtObjectAuthorId));
+        		$oZ->alert();
+
                 return array('id' => $iCmtId, 'parent_id' => $iCmtParentId);
             }
 
@@ -589,7 +594,10 @@ class BxBaseCmts extends BxDolCmts
 
     protected function _getFormEdit($iCmtId)
     {
-        $aCmt = $this->_oQuery->getCommentSimple ($this->getId(), $iCmtId);
+    	$iCmtObjectId = (int)$this->getId();
+    	$iCmtObjectAuthorId = $this->getObjectAuthorId($iCmtObjectId);
+
+        $aCmt = $this->_oQuery->getCommentSimple ($iCmtObjectId, $iCmtId);
         if(!$aCmt)
             return array('msg' => _t('_No such comment'));
 
@@ -615,9 +623,12 @@ class BxBaseCmts extends BxDolCmts
                     $oMetatags->keywordsAdd($this->_oQuery->getUniqId($this->_aSystem['system_id'], $iCmtId), $sCmtText);
                 }
 
-                $oZ = new BxDolAlerts($this->_sSystem, 'commentUpdated', $this->getId(), $iCmtAuthorId, array('comment_id' => $aCmt['cmt_id'], 'comment_author_id' => $aCmt['cmt_author_id']));
+                $oZ = new BxDolAlerts($this->_sSystem, 'commentUpdated', $iCmtObjectId, $iCmtAuthorId, array('comment_id' => $aCmt['cmt_id'], 'comment_author_id' => $aCmt['cmt_author_id'], 'object_author_id' => $iCmtObjectAuthorId));
                 $oZ->alert();
 
+                $oZ = new BxDolAlerts('comment', 'edited', $iCmtId, $iCmtAuthorId, array('object_system' => $this->_sSystem, 'object_id' => $iCmtObjectId, 'object_author_id' => $iCmtObjectAuthorId));
+        		$oZ->alert();
+
                 return array('id' => $iCmtId, 'text' => $this->_prepareTextForOutput($sCmtText, $iCmtId));
             }