Exemple #1
0
 public function remove_from_disk()
 {
     $deleted = true;
     $season_ids = $this->get_seasons();
     foreach ($season_ids as $id) {
         $season = new TVShow_Season($id);
         $deleted = $season->remove_from_disk();
         if (!$deleted) {
             debug_event('tvshow', 'Error when deleting the season `' . $id . '`.', 1);
             break;
         }
     }
     if ($deleted) {
         $sql = "DELETE FROM `tvshow` WHERE `id` = ?";
         $deleted = Dba::write($sql, array($this->id));
         if ($deleted) {
             Art::gc('tvshow', $this->id);
             Userflag::gc('tvshow', $this->id);
             Rating::gc('tvshow', $this->id);
             Shoutbox::gc('tvshow', $this->id);
             Useractivity::gc('tvshow', $this->id);
         }
     }
     return $deleted;
 }
Exemple #2
0
 /**
  * gc
  *
  * This is a wrapper function for all of the different cleaning
  * functions, it runs them in an order that resembles correctness.
  */
 public static function gc()
 {
     debug_event('catalog', 'Database cleanup started', 5);
     Song::gc();
     Album::gc();
     Artist::gc();
     Video::gc();
     Art::gc();
     Stats::gc();
     Rating::gc();
     Userflag::gc();
     Useractivity::gc();
     Playlist::gc();
     Tmp_Playlist::gc();
     Shoutbox::gc();
     Tag::gc();
     // TODO: use InnoDB with foreign keys and on delete cascade to get rid of garbage collection
     \Lib\Metadata\Repository\Metadata::gc();
     \Lib\Metadata\Repository\MetadataField::gc();
     debug_event('catalog', 'Database cleanup ended', 5);
 }
Exemple #3
0
 /**
  * gc
  *
  * This is a wrapper function for all of the different cleaning
  * functions, it runs them in an order that resembles correctness.
  */
 public static function gc()
 {
     debug_event('catalog', 'Database cleanup started', 5);
     Song::gc();
     Album::gc();
     Artist::gc();
     Art::gc();
     Stats::gc();
     Rating::gc();
     Userflag::gc();
     Playlist::gc();
     Tmp_Playlist::gc();
     Shoutbox::gc();
     Tag::gc();
     debug_event('catalog', 'Database cleanup ended', 5);
 }
Exemple #4
0
 public function remove()
 {
     $sql = "DELETE FROM `label` WHERE `id` = ?";
     $deleted = Dba::write($sql, array($this->id));
     if ($deleted) {
         Art::gc('label', $this->id);
         Userflag::gc('label', $this->id);
         Rating::gc('label', $this->id);
         Shoutbox::gc('label', $this->id);
         Useractivity::gc('label', $this->id);
     }
     return $deleted;
 }
Exemple #5
0
 public function remove_from_disk()
 {
     $deleted = true;
     $video_ids = $this->get_episodes();
     foreach ($video_ids as $id) {
         $video = Video::create_from_id($id);
         $deleted = $video->remove_from_disk();
         if (!$deleted) {
             debug_event('tvshow_season', 'Error when deleting the video `' . $id . '`.', 1);
             break;
         }
     }
     if ($deleted) {
         $sql = "DELETE FROM `tvshow_season` WHERE `id` = ?";
         $deleted = Dba::write($sql, array($this->id));
         if ($deleted) {
             Art::gc('tvshow_season', $this->id);
             Userflag::gc('tvshow_season', $this->id);
             Rating::gc('tvshow_season', $this->id);
             Shoutbox::gc('tvshow_season', $this->id);
         }
     }
     return $deleted;
 }
Exemple #6
0
 /**
  * update
  * This takes a key'd array of data and updates the current artist
  */
 public function update($data)
 {
     // Save our current ID
     $current_id = $this->id;
     // Check if name is different than current name
     if ($this->name != $data['name']) {
         $artist_id = self::check($data['name'], $this->mbid);
         $updated = false;
         $songs = array();
         // If it's changed we need to update
         if ($artist_id != $this->id) {
             $songs = $this->get_songs();
             foreach ($songs as $song_id) {
                 Song::update_artist($artist_id, $song_id);
             }
             $updated = true;
             $current_id = $artist_id;
             self::gc();
         }
         // end if it changed
         if ($updated) {
             foreach ($songs as $song_id) {
                 Song::update_utime($song_id);
             }
             Stats::gc();
             Rating::gc();
             Userflag::gc();
         }
         // if updated
     } else {
         if ($this->mbid != $data['mbid']) {
             $sql = 'UPDATE `artist` SET `mbid` = ? WHERE `id` = ?';
             Dba::write($sql, array($data['mbid'], $current_id));
         }
     }
     // Update artist name (if we don't want to use the MusicBrainz name)
     $trimmed = Catalog::trim_prefix(trim($data['name']));
     $name = $trimmed['string'];
     if ($name != '' && $name != $this->name) {
         $sql = 'UPDATE `artist` SET `name` = ? WHERE `id` = ?';
         Dba::write($sql, array($name, $current_id));
     }
     $override_childs = false;
     if ($data['apply_childs'] == 'checked') {
         $override_childs = true;
     }
     $this->update_tags($data['edit_tags'], $override_childs, $current_id);
     return $current_id;
 }
Exemple #7
0
 /**
  * update
  * This function takes a key'd array of data and updates this object
  * as needed
  */
 public function update($data)
 {
     $year = $data['year'];
     $artist = $data['artist'];
     $name = $data['name'];
     $disk = $data['disk'];
     $mbid = $data['mbid'];
     $current_id = $this->id;
     $updated = false;
     $songs = null;
     if ($artist != $this->artist_id and $artist) {
         // Update every song
         $songs = $this->get_songs();
         foreach ($songs as $song_id) {
             Song::update_artist($artist, $song_id);
         }
         $updated = true;
         Artist::gc();
     }
     $album_id = self::check($name, $year, $disk, $mbid);
     if ($album_id != $this->id) {
         if (!is_array($songs)) {
             $songs = $this->get_songs();
         }
         foreach ($songs as $song_id) {
             Song::update_album($album_id, $song_id);
             Song::update_year($year, $song_id);
         }
         $current_id = $album_id;
         $updated = true;
         self::gc();
     }
     if ($updated && is_array($songs)) {
         foreach ($songs as $song_id) {
             Song::update_utime($song_id);
         }
         // foreach song of album
         Stats::gc();
         Rating::gc();
         Userflag::gc();
     }
     // if updated
     $override_songs = false;
     if ($data['apply_childs'] == 'checked') {
         $override_songs = true;
     }
     $this->update_tags($data['edit_tags'], $override_songs, $current_id);
     return $current_id;
 }
Exemple #8
0
 public function remove_from_disk()
 {
     $deleted = true;
     $song_ids = $this->get_songs();
     foreach ($song_ids as $id) {
         $song = new Song($id);
         $deleted = $song->remove_from_disk();
         if (!$deleted) {
             debug_event('album', 'Error when deleting the song `' . $id . '`.', 1);
             break;
         }
     }
     if ($deleted) {
         $sql = "DELETE FROM `album` WHERE `id` = ?";
         $deleted = Dba::write($sql, array($this->id));
         if ($deleted) {
             Art::gc('album', $this->id);
             Userflag::gc('album', $this->id);
             Rating::gc('album', $this->id);
             Shoutbox::gc('album', $this->id);
             Useractivity::gc('album', $this->id);
         }
     }
     return $deleted;
 }
Exemple #9
0
 /**
  * Remove the video from disk.
  */
 public function remove_from_disk()
 {
     if (file_exists($this->file)) {
         $deleted = unlink($this->file);
     } else {
         $deleted = true;
     }
     if ($deleted === true) {
         $sql = "DELETE FROM `video` WHERE `id` = ?";
         $deleted = Dba::write($sql, array($this->id));
         if ($deleted) {
             Art::gc('video', $this->id);
             Userflag::gc('video', $this->id);
             Rating::gc('video', $this->id);
             Shoutbox::gc('video', $this->id);
             Useractivity::gc('video', $this->id);
         }
     } else {
         debug_event('video', 'Cannot delete ' . $this->file . 'file. Please check permissions.', 1);
     }
     return $deleted;
 }
Exemple #10
0
 public function remove_from_disk()
 {
     $deleted = true;
     $album_ids = $this->get_albums();
     foreach ($album_ids as $id) {
         $album = new Album($id);
         $deleted = $album->remove_from_disk();
         if (!$deleted) {
             debug_event('artist', 'Error when deleting the album `' . $id . '`.', 1);
             break;
         }
     }
     if ($deleted) {
         $sql = "DELETE FROM `artist` WHERE `id` = ?";
         $deleted = Dba::write($sql, array($this->id));
         if ($deleted) {
             Art::gc('artist', $this->id);
             Userflag::gc('artist', $this->id);
             Rating::gc('artist', $this->id);
             Shoutbox::gc('artist', $this->id);
         }
     }
     return $deleted;
 }