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

Ticket #4467 - Groups: Update cover event should update necessary event in Timeline.

AntonLV 3 лет назад
Родитель
Сommit
a2100bf682

+ 28 - 1
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -1262,7 +1262,19 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
      */
     public function serviceGetTimelineData()
     {
-        return BxBaseModGeneralModule::serviceGetTimelineData();
+        $aResult = BxBaseModGeneralModule::serviceGetTimelineData();
+
+        $sModule = $this->_aModule['name'];
+        $aResult['handlers'] = array_merge($aResult['handlers'], [
+            ['group' => $sModule . '_object', 'type' => 'update', 'alert_unit' => $sModule, 'alert_action' => 'context_cover_changed'],
+            ['group' => $sModule . '_object', 'type' => 'update', 'alert_unit' => $sModule, 'alert_action' => 'context_cover_deleted']
+        ]);
+        $aResult['alerts'] = array_merge($aResult['alerts'], [
+            ['unit' => $sModule, 'action' => 'context_cover_changed'],
+            ['unit' => $sModule, 'action' => 'context_cover_deleted']
+        ]);
+
+        return $aResult;
     }
 
     /**
@@ -1685,6 +1697,21 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
 
 
     // ====== COMMON METHODS
+    public function onUpdateImage($iContentId, $sFiledName, $sFiledValue, $iProfileId = 0)
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+
+        $aField2Method = [
+            $CNF['FIELD_PICTURE'] => 'picture',
+            $CNF['FIELD_COVER'] => 'cover',
+        ];
+
+        if(!empty($aField2Method[$sFiledName]))
+            bx_alert($this->getName(), 'context_' . $aField2Method[$sFiledName] . '_changed', $iContentId, $iProfileId, $this->_alertParams($aContentInfo));
+    }
+
     protected function _alertParams($aContentInfo)
     {
         $aParams = parent::_alertParams($aContentInfo);

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

@@ -115,7 +115,6 @@ CREATE TABLE IF NOT EXISTS `bx_timeline_handlers` (
   `content` text NOT NULL,
   `privacy` varchar(64) NOT NULL default '',
   PRIMARY KEY (`id`),
-  UNIQUE `handler` (`group`, `type`),
   UNIQUE `alert` (`alert_unit`, `alert_action`)
 );