diff options
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/api.class.php | 13 | ||||
-rw-r--r-- | lib/class/catalog.class.php | 6 | ||||
-rw-r--r-- | lib/class/democratic.class.php | 30 | ||||
-rw-r--r-- | lib/class/update.class.php | 14 |
4 files changed, 58 insertions, 5 deletions
diff --git a/lib/class/api.class.php b/lib/class/api.class.php index 2d55aad5..50ca9609 100644 --- a/lib/class/api.class.php +++ b/lib/class/api.class.php @@ -98,7 +98,18 @@ class Api { $db_results = Dba::query($sql); $row = Dba::fetch_assoc($db_results); - return array('auth'=>$token,'api'=>self::$version,'update'=>date("r",$row['update']),'add'=>date("r",$row['add'])); + // Now we need to quickly get the totals of songs + $sql = "SELECT COUNT(`id`) AS `song`,COUNT(DISTINCT(`album`)) AS `album`,COUNT(DISTINCT(`artist`)) AS `artist` FROM `song`"; + $db_results = Dba::query($sql); + $counts = Dba::fetch_assoc($db_results); + + return array('auth'=>$token, + 'api'=>self::$version, + 'update'=>date("r",$row['update']), + 'add'=>date("r",$row['add']), + 'songs'=>$counts['song'], + 'albums'=>$counts['album'], + 'artists'=>$counts['artist']); } // match } // end while diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 0b152458..02e780e8 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -1582,11 +1582,13 @@ class Catalog { public static function clean_playlists() { /* Do a complex delete to get playlist songs where there are no songs */ - $sql = "DELETE FROM playlist_data USING playlist_data LEFT JOIN song ON song.id = playlist_data.song WHERE song.file IS NULL"; + $sql = "DELETE FROM `playlist_data` USING `playlist_data` LEFT JOIN `song` ON `song`.`id` = `playlist_data`.`object_id` " . + "WHERE `song`.`file` IS NULL AND `playlist_data`.`object_type`='song'"; $db_results = Dba::query($sql); // Clear TMP Playlist information as well - $sql = "DELETE FROM tmp_playlist_data USING tmp_playlist_data LEFT JOIN song ON tmp_playlist_data.object_id = song.id WHERE song.id IS NULL"; + $sql = "DELETE FROM `tmp_playlist_data` USING `tmp_playlist_data` LEFT JOIN `song` ON `tmp_playlist_data`.`object_id` = `song`.`id` " . + "WHERE `song`.`id` IS NULL"; $db_results = Dba::query($sql); } // clean_playlists diff --git a/lib/class/democratic.class.php b/lib/class/democratic.class.php index 32ecbee2..922120d2 100644 --- a/lib/class/democratic.class.php +++ b/lib/class/democratic.class.php @@ -374,6 +374,32 @@ class Democratic extends tmpPlaylist { } // delete_votes /** + * delete + * This deletes a democratic playlist + */ + public static function delete($democratic_id) { + + $democratic_id = Dba::escape($democratic_id); + + $sql = "DELETE FROM `democratic` WHERE `id`='$democratic_id'"; + $db_results = Dba::query($sql); + + return true; + + } // delete + + /** + * update + * This updates an existing democratic playlist item. It takes a key'd array just like the create + */ + public function update($data) { + + + + + } // update + + /** * create * This is the democratic play create function it inserts this into the democratic table */ @@ -387,8 +413,8 @@ class Democratic extends tmpPlaylist { $default = Dba::escape($data['make_default']); $user = Dba::escape($GLOBALS['user']->id); - $sql = "INSERT INTO `democratic` (`name`,`cooldown`,`level`,`user`,`primary`) " . - "VALUES ('$name','$cool','$level','$user','$default')"; + $sql = "INSERT INTO `democratic` (`name`,`base_playlist`,`cooldown`,`level`,`user`,`primary`) " . + "VALUES ('$name','$base','$cool','$level','$user','$default')"; $db_results = Dba::query($sql); return $db_results; diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 924e87e7..42cd9b86 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -1158,5 +1158,19 @@ class Update { } // update_340016 + /** + * update_340017 + * This finalizes the democratic table. + */ + public static function update_340017() { + + $sql = "ALTER TABLE `democratic` ADD `base_playlist` INT( 11 ) UNSIGNED NOT NULL AFTER `name`"; + $db_results = Dba::query($sql); + + self::set_version('db_version','340017'); + + + } // update_340017 + } // end update class ?> |