Exemple #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
             PhocaGalleryHelper::deleteFileThumbnail($value->filename, 1, 1, 1);
             PhocaGalleryHelper::deleteFile($value->filename);
         }
     }
     return true;
 }
Exemple #2
0
 function deletethumbs($id)
 {
     if ($id > 0) {
         $query = 'SELECT a.filename as filename' . ' FROM #__phocagallery AS a' . ' WHERE a.id = ' . (int) $id;
         $this->_db->setQuery($query);
         $file = $this->_db->loadObject();
         if (isset($file->filename) && $file->filename != '') {
             $deleteThubms = PhocaGalleryHelper::deleteFileThumbnail($file->filename, 1, 1, 1);
             if ($deleteThubms) {
                 return true;
             } else {
                 return false;
             }
         }
         return false;
     }
     return false;
 }