1
0
Эх сурвалжийг харах

#212 Allow admin to see and edit other authors attachments

Alex Trofimov 10 жил өмнө
parent
commit
2dce5d5ab0

+ 10 - 0
inc/classes/BxDolStorage.php

@@ -651,6 +651,16 @@ abstract class BxDolStorage extends BxDol implements iBxDolFactoryObject
         return $this->_oDb->getFileById($iFileId);
         return $this->_oDb->getFileById($iFileId);
     }
     }
 
 
+    /**
+     * Get ghost file info array by file id.
+     * @param $iFileId file id
+     * @return array
+     */
+    public function getGhost($iFileId)
+    {    
+        return $this->_oDb->getGhost($iFileId);
+    }
+
     /**
     /**
      * check if file is private or public
      * check if file is private or public
      * @param $iFileId file id
      * @param $iFileId file id

+ 4 - 1
inc/classes/BxDolStorageQuery.php

@@ -281,7 +281,10 @@ class BxDolStorageQuery extends BxDolDb
             $aBindings['object'] = $this->_aObject['object'];
             $aBindings['object'] = $this->_aObject['object'];
 
 
             $sOnProfile = '';
             $sOnProfile = '';
-            if (is_array($mixedProfileId) && $mixedProfileId) {
+            if (isAdmin() && $iContentId) {
+                // don't check profile id for admins, so admin can edit any entry
+            }
+            elseif (is_array($mixedProfileId) && $mixedProfileId) {
                 $sOnProfile = " AND `g`.`profile_id` IN(" . $this->implode_escape($mixedProfileId) . ") ";
                 $sOnProfile = " AND `g`.`profile_id` IN(" . $this->implode_escape($mixedProfileId) . ") ";
             } 
             } 
             elseif (!is_array($mixedProfileId) && false !== $mixedProfileId) {
             elseif (!is_array($mixedProfileId) && false !== $mixedProfileId) {

+ 3 - 1
inc/classes/BxDolUploader.php

@@ -359,7 +359,9 @@ abstract class BxDolUploader extends BxDol
     {
     {
         $oStorage = BxDolStorage::getObjectInstance($this->_sStorageObject);
         $oStorage = BxDolStorage::getObjectInstance($this->_sStorageObject);
 
 
-        $aFile = $oStorage->getFile ($iFileId);
+        $aFile = $oStorage->getGhost ($iFileId);
+        if (!$aFile)
+            $aFile = $oStorage->getFile ($iFileId);
         if (!$aFile)
         if (!$aFile)
             return _t('_error occured');
             return _t('_error occured');
 
 

+ 1 - 1
modules/base/general/classes/BxBaseModGeneralFormEntry.php

@@ -163,7 +163,7 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
             return true;
             return true;
 
 
         foreach ($aGhostFiles as $aFile) {
         foreach ($aGhostFiles as $aFile) {
-            if (!in_array($aFile['id'], $mixedFileIds))
+            if (is_array($mixedFileIds) && !in_array($aFile['id'], $mixedFileIds))
                 continue;
                 continue;
             if ($aFile['private'])
             if ($aFile['private'])
                 $oStorage->setFilePrivate ($aFile['id'], 0);
                 $oStorage->setFilePrivate ($aFile['id'], 0);