Beispiel #1
0
 function delete($id = 0)
 {
     // Get all filenames we want to delete from database, we delete all thumbnails from server of this file
     $queryd = 'SELECT filename as filename FROM #__phocagallery WHERE id =' . (int) $id;
     $this->_db->setQuery($queryd);
     $file_object = $this->_db->loadObjectList();
     $query = 'DELETE FROM #__phocagallery' . ' WHERE id =' . (int) $id;
     $this->_db->setQuery($query);
     if (!$this->_db->query()) {
         $this->setError('Database Error 2');
         return false;
     }
     // Delete thumbnails - medium and large, small from server
     // All id we want to delete - gel all filenames
     foreach ($file_object as $key => $value) {
         //The file can be stored in other category - don't delete it from server because other category use it
         $querys = "SELECT id as id FROM #__phocagallery WHERE filename='" . $value->filename . "' ";
         $this->_db->setQuery($queryd);
         $same_file_object = $this->_db->loadObject();
         //same file in other category doesn't exist - we can delete it
         if (!$same_file_object) {
             //Delete all thumbnail files but not original
             PhocaGalleryFileThumbnail::deleteFileThumbnail($value->filename, 1, 1, 1);
             PhocaGalleryFile::deleteFile($value->filename);
         }
     }
     return true;
 }