diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-09-25 01:34:19 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-09-25 01:34:55 +0200 |
commit | 64b68f2474c2101ccd24e06dc78934133753865f (patch) | |
tree | fa08d50dd2bf97d06e635925177c673b0ce51a8e /apps/media/lib_collection.php | |
parent | 6c2b22406c710a82f05d7449a90ba584ffc06a58 (diff) | |
download | nextcloud-server-64b68f2474c2101ccd24e06dc78934133753865f.tar.gz nextcloud-server-64b68f2474c2101ccd24e06dc78934133753865f.zip |
correctly update the collection when music files are moved around
Diffstat (limited to 'apps/media/lib_collection.php')
-rw-r--r-- | apps/media/lib_collection.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php index 273ea2494f8..82c4afedd0a 100644 --- a/apps/media/lib_collection.php +++ b/apps/media/lib_collection.php @@ -251,10 +251,12 @@ class OC_MEDIA_COLLECTION{ if($name=='' or $path==''){ return 0; } - $uid=$_SESSION['user_id']; + $uid=OC_User::getUser(); //check if the song is already in the database $songId=self::getSongId($name,$artist,$album); if($songId!=0){ + $songInfo=self::getSong($songId); + self::moveSong($songInfo['song_path'],$path); return $songId; }else{ if(!isset(self::$queries['addsong'])){ @@ -357,13 +359,23 @@ class OC_MEDIA_COLLECTION{ */ public static function getSongByPath($path){ $query=OC_DB::prepare("SELECT song_id FROM *PREFIX*media_songs WHERE song_path = ?"); - $result=$query->execute(array($path))->fetchAll(); - if(count($result)>0){ - return $result[0]['song_id']; + $result=$query->execute(array($path)); + if($row=$result->fetchRow()){ + return $row['song_id']; }else{ return 0; } } + + /** + * set the path of a song + * @param string $oldPath + * @param string $newPath + */ + public static function moveSong($oldPath,$newPath){ + $query=OC_DB::prepare("UPDATE *PREFIX*media_songs SET song_path = ? WHERE song_path = ?"); + $query->execute(array($newPath,$oldPath)); + } } ?>
\ No newline at end of file |