Browse Source

#269 'ghost' info in 'file_deleted' alert

Alex Trofimov 10 years ago
parent
commit
a0b8176c8f
2 changed files with 11 additions and 3 deletions
  1. 5 3
      inc/classes/BxDolStorage.php
  2. 6 0
      inc/classes/BxDolStorageQuery.php

+ 5 - 3
inc/classes/BxDolStorage.php

@@ -556,12 +556,14 @@ abstract class BxDolStorage extends BxDol implements iBxDolFactoryObject
             return false;
         }
 
+        $aGhost = $this->_oDb->getGhost($aFile['id']);
+
         if (!$this->_oDb->deleteFile($aFile['id'])) {
             $this->setErrorCode(BX_DOL_STORAGE_ERR_DB);
             return false;
         }
 
-        if (!$this->onFileDeleted ($aFile, $iProfileId)) {
+        if (!$this->onFileDeleted ($aFile, $iProfileId, $aGhost)) {
             return false;
         }
 
@@ -957,7 +959,7 @@ abstract class BxDolStorage extends BxDol implements iBxDolFactoryObject
         return $bRet;
     }
 
-    function onFileDeleted ($aFileInfo, $iProfileId)
+    function onFileDeleted ($aFileInfo, $iProfileId, $aGhost = false)
     {
         // TODO: update site quota
 
@@ -974,7 +976,7 @@ abstract class BxDolStorage extends BxDol implements iBxDolFactoryObject
         $this->setErrorCode(BX_DOL_STORAGE_ERR_OK);
 
         $bRet = true;
-        bx_alert($this->_aObject['object'], 'file_deleted', $aFileInfo['id'], $iProfileId, array('file_info' => $aFileInfo, 'return_value' => &$bRet));
+        bx_alert($this->_aObject['object'], 'file_deleted', $aFileInfo['id'], $iProfileId, array('file_info' => $aFileInfo, 'ghost' => $aGhost, 'return_value' => &$bRet));
         return $bRet;
     }
 

+ 6 - 0
inc/classes/BxDolStorageQuery.php

@@ -239,6 +239,12 @@ class BxDolStorageQuery extends BxDolDb
         return $this->getFiles($iProfileId, true, $iContentId);
     }
 
+    public function getGhost($iFileId)
+    {
+        $sQuery = $this->prepare("SELECT * FROM `sys_storage_ghosts` WHERE `object` = ? AND `id` = ?", $this->_aObject['object'], $iFileId);
+        return $this->getRow($sQuery);
+    }
+
     public function getFiles($iProfileId, $isGhostsOnly = false, $iContentId = false)
     {
         $sJoin = '';