Ejemplo n.º 1
0
 function do_delete()
 {
     $a = new Album();
     $previews = $a->where_related('cover', 'id', $this->id)->get_iterated();
     foreach ($previews as $a) {
         $a->reset_covers();
     }
     $albums = $a->where_related('content', 'id', $this->id)->get_iterated();
     foreach ($albums as $a) {
         $a->update_counts();
     }
     $this->clear_cache();
     if (empty($this->storage_url)) {
         $original = $this->path_to_original();
         $info = pathinfo($original);
         $mid = preg_replace('/\\.' . $info['extension'] . '$/', '.1600.' . $info['extension'], $original);
         unlink($original);
         if (file_exists($mid)) {
             unlink($mid);
         }
         if ($this->file_type > 0 && is_dir($original . '_previews')) {
             delete_files($original . '_previews', true, 1);
         }
         if (@rmdir(dirname($original))) {
             @rmdir(dirname(dirname($original)));
         }
     } else {
         Shutter::delete_original($this->storage_url);
         if (!empty($this->storage_url_midsize)) {
             Shutter::delete_original($this->storage_url_midsize);
         }
     }
     Shutter::hook('content.delete', $this->to_array(array('auth' => true)));
     $s = new Slug();
     $this->db->query("DELETE FROM {$s->table} WHERE id = 'content.{$this->slug}'");
     $this->delete();
 }