Explorar el Código

Ticket #3835 - Timeline: the changes of profile pics or covers don't affect in the feeds.

AntonLV hace 4 años
padre
commit
5690b79fea
Se han modificado 1 ficheros con 16 adiciones y 14 borrados
  1. 16 14
      modules/base/profile/classes/BxBaseModProfileFormEntry.php

+ 16 - 14
modules/base/profile/classes/BxBaseModProfileFormEntry.php

@@ -186,23 +186,25 @@ class BxBaseModProfileFormEntry extends BxBaseModGeneralFormEntry
 
     protected function _associalFileWithContent($oStorage, $iFileId, $iProfileId, $iContentId, $sPictureField = '')
     {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
         $oStorage->updateGhostsContentId ($iFileId, $iProfileId, $iContentId, $this->_isAdmin($iContentId));
 
         $bResult = (int)$this->_oModule->_oDb->updateContentPictureById($iContentId, 0/*$iProfileId*/, $iFileId, $sPictureField) > 0;
-        if($bResult) {
-            $sModule = $this->_oModule->getName();
-            switch($sPictureField) {
-                case $CNF['FIELD_PICTURE']:
-                    bx_alert($sModule, 'profile_picture_changed', $iFileId, $iProfileId, array('content' => $iContentId, 'field' => $CNF['FIELD_PICTURE']));
-                    break;
-
-                case $CNF['FIELD_COVER']:
-                    bx_alert($sModule, 'profile_cover_changed', $iFileId, $iProfileId, array('content' => $iContentId, 'field' => $CNF['FIELD_COVER']));
-                    break;
-            }
-        }
+        if(!$bResult) 
+            return;
+
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        $aField2Method = [
+            $CNF['FIELD_PICTURE'] => 'picture',
+            $CNF['FIELD_COVER'] => 'cover',
+        ];
+
+        if(!empty($aField2Method[$sPictureField]))
+            bx_alert($this->_oModule->getName(), 'profile_' . $aField2Method[$sPictureField] . '_changed', $iFileId, $iProfileId, [
+                'object_author_id' => $iProfileId, 
+                'content' => $iContentId, 
+                'field' => $sPictureField
+            ]);
     }
 
     protected function _getProfilePhotoGhostTmplVars($sField, $aContentInfo = array())