AntonLV před 9 roky
rodič
revize
c55ad0976b

+ 3 - 0
modules/base/notifications/classes/BxBaseModNotificationsResponse.php

@@ -36,6 +36,9 @@ class BxBaseModNotificationsResponse extends BxDolAlertsResponse
    		if(is_array($aExtras) && isset($aExtras['vote_id']))
     		return (int)$aExtras['vote_id'];
 
+        if(is_array($aExtras) && isset($aExtras['repost_id']))
+    		return (int)$aExtras['repost_id'];
+
         if(is_array($aExtras) && isset($aExtras['notification_subobject_id']))
             return (int)$aExtras['notification_subobject_id'];
                 

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

@@ -154,6 +154,7 @@
 	<string name="_bx_timeline_txt_err_cannot_repost"><![CDATA[Невозможно сделать репост. Пожалуйста, сообщите нам об этой проблеме.]]></string>
 	<string name="_bx_timeline_txt_err_already_reposted"><![CDATA[Вы уже сделали репост этого элемента.]]></string>
 	<string name="_bx_timeline_txt_msg_success_repost"><![CDATA[Репост данного элемента был сделан успешно.]]></string>
+	<string name="_bx_timeline_txt_object_reposted"><![CDATA[<a class="bx-ntfs-content-profile" href="{owner_link}">{owner_name}</a> сделал репост {entry_sample} <a href="{entry_url}">{entry_caption}</a>]]></string>
 
     <!-- EMAIL TEMPLATES -->
     <string name="_bx_timeline_et_txt_name_send"><![CDATA[Послать другу.]]></string>

+ 31 - 5
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -436,6 +436,8 @@ class BxTimelineModule extends BxBaseModNotificationsModule
             'handlers' => array(
                 array('group' => $sModule . '_object', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'post_common', 'module_name' => $sModule, 'module_method' => 'get_notifications_post', 'module_class' => 'Module'),
                 array('group' => $sModule . '_object', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'delete'),
+                array('group' => $sModule . '_repost', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'repost', 'module_name' => $sModule, 'module_method' => 'get_notifications_repost', 'module_class' => 'Module'),
+                array('group' => $sModule . '_repost', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'delete_repost'),
                 array('group' => $sModule . '_comment', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'commentPost', 'module_name' => $sModule, 'module_method' => 'get_notifications_comment', 'module_class' => 'Module'),
                 array('group' => $sModule . '_comment', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'commentRemoved'),
                 array('group' => $sModule . '_vote', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'doVote', 'module_name' => $sModule, 'module_method' => 'get_notifications_vote', 'module_class' => 'Module'),
@@ -444,6 +446,8 @@ class BxTimelineModule extends BxBaseModNotificationsModule
             'alerts' => array(
                 array('unit' => $sModule, 'action' => 'post_common'),
                 array('unit' => $sModule, 'action' => 'delete'),
+                array('unit' => $sModule, 'action' => 'repost'),
+                array('unit' => $sModule, 'action' => 'delete_repost'),
                 array('unit' => $sModule, 'action' => 'commentPost'),
                 array('unit' => $sModule, 'action' => 'commentRemoved'),
                 array('unit' => $sModule, 'action' => 'doVote'),
@@ -452,6 +456,14 @@ class BxTimelineModule extends BxBaseModNotificationsModule
         );
     }
 
+    public function serviceGetNotificationsRepost($aEvent)
+    {
+        $aResult = $this->serviceGetNotificationsPost($aEvent);
+        $aResult['lang_key'] = '_bx_timeline_txt_object_reposted';
+
+        return $aResult;
+    }
+
     public function serviceGetNotificationsPost($aEvent)
     {
     	$CNF = &$this->_oConfig->CNF;
@@ -999,13 +1011,17 @@ class BxTimelineModule extends BxBaseModNotificationsModule
         $this->_oDb->updateRepostCounter($aReposted['id'], $aReposted['reposts']);
 
         //--- Timeline -> Update for Alerts Engine ---//
-        $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'repost', $aReposted['id'], $iUserId);
+        $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'repost', $aReposted['id'], $iUserId, array(
+        	'repost_id' => $iId,
+        	'object_author_id' => $aReposted['owner_id'],
+        ));
         $oAlert->alert();
         //--- Timeline -> Update for Alerts Engine ---//
     }
 
     public function onDelete($aEvent)
     {
+        $iUserId = $this->getUserId();
     	$sCommonPostPrefix = $this->_oConfig->getPrefix('common_post');
 
     	//--- Delete attached photos, videos and links when common event was deleted.
@@ -1017,7 +1033,8 @@ class BxTimelineModule extends BxBaseModNotificationsModule
     	}
 
     	//--- Update parent event when repost event was deleted.
-        if($aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_REPOST) {
+    	$bRepost = $aEvent['type'] == $sCommonPostPrefix . BX_TIMELINE_PARSE_TYPE_REPOST;
+        if($bRepost) {
             $this->_oDb->deleteRepostTrack($aEvent['id']);
 
             $aContent = unserialize($aEvent['content']);
@@ -1031,8 +1048,12 @@ class BxTimelineModule extends BxBaseModNotificationsModule
 	    $aRepostEvents = $this->_oDb->getEvents(array('browse' => 'reposted_by_descriptor', 'type' => $aEvent['type']));
 		foreach($aRepostEvents as $aRepostEvent) {
 			$aContent = unserialize($aRepostEvent['content']);
-			if(isset($aContent['type']) && $aContent['type'] == $aEvent['type'] && isset($aContent['object_id']) && (($bSystem && (int)$aContent['object_id'] == (int)$aEvent['object_id']) || (!$bSystem  && (int)$aContent['object_id'] == (int)$aEvent['id'])))
-				$this->_oDb->deleteEvent(array('id' => (int)$aRepostEvent['id']));
+			if(isset($aContent['type']) && $aContent['type'] == $aEvent['type'] && isset($aContent['object_id']) && (($bSystem && (int)$aContent['object_id'] == (int)$aEvent['object_id']) || (!$bSystem  && (int)$aContent['object_id'] == (int)$aEvent['id'])) && (int)$this->_oDb->deleteEvent(array('id' => (int)$aRepostEvent['id'])) > 0) {
+                $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'delete_repost', $aEvent['id'], $iUserId, array(
+                    'repost_id' => $aRepostEvent['id'],
+                ));
+                $oAlert->alert();
+            }
 		}
 
 		//--- Delete associated meta.
@@ -1040,7 +1061,12 @@ class BxTimelineModule extends BxBaseModNotificationsModule
         $oMetatags->onDeleteContent($aEvent['id']);
 
         //--- Event -> Delete for Alerts Engine ---//
-        $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'delete', $aEvent['id'], $this->getUserId());
+        if($bRepost)
+            $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'delete_repost', $aReposted['id'], $iUserId, array(
+                'repost_id' => $aEvent['id'],
+            ));
+        else
+            $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'delete', $aEvent['id'], $iUserId);
         $oAlert->alert();
         //--- Event -> Delete for Alerts Engine ---//
     }

+ 1 - 0
modules/boonex/timeline/install/langs/en.xml

@@ -154,6 +154,7 @@
 	<string name="_bx_timeline_txt_err_cannot_repost"><![CDATA[Cannot repost. Please report.]]></string>
 	<string name="_bx_timeline_txt_err_already_reposted"><![CDATA[You already reposted the item.]]></string>
 	<string name="_bx_timeline_txt_msg_success_repost"><![CDATA[The item was successfully reposted.]]></string>
+	<string name="_bx_timeline_txt_object_reposted"><![CDATA[<a class="bx-ntfs-content-profile" href="{owner_link}">{owner_name}</a> reposted a {entry_sample} <a href="{entry_url}">{entry_caption}</a>]]></string>
 
     <!-- EMAIL TEMPLATES -->
     <string name="_bx_timeline_et_txt_name_send"><![CDATA[Send to Friend.]]></string>