示例#1
0
 /**
  * Supprime le fichier
  * @return boolean TRUE en cas de succès
  */
 public function remove()
 {
     $db = DB::getInstance();
     $db->exec('BEGIN;');
     $db->simpleExec('DELETE FROM fichiers_compta_journal WHERE fichier = ?;', (int) $this->id);
     $db->simpleExec('DELETE FROM fichiers_wiki_pages WHERE fichier = ?;', (int) $this->id);
     $db->simpleExec('DELETE FROM fichiers_membres WHERE fichier = ?;', (int) $this->id);
     $db->simpleExec('DELETE FROM fichiers WHERE id = ?;', (int) $this->id);
     // Suppression du contenu s'il n'est pas utilisé par un autre fichier
     if (!$db->simpleQuerySingle('SELECT 1 FROM fichiers WHERE id_contenu = ? AND id != ? LIMIT 1;', false, (int) $this->id_contenu, (int) $this->id)) {
         $db->simpleExec('DELETE FROM fichiers_contenu WHERE id = ?;', (int) $this->id_contenu);
     }
     $cache_id = 'fichiers.' . $this->id_contenu;
     Static_Cache::remove($cache_id);
     foreach (self::$allowed_thumb_sizes as $size) {
         Static_Cache::remove($cache_id . '.thumb.' . (int) $size);
     }
     return $db->exec('END;');
 }