diff options
-rw-r--r-- | democratic.php | 15 | ||||
-rwxr-xr-x | docs/CHANGELOG | 1 | ||||
-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 | ||||
-rw-r--r-- | server/democratic.ajax.php | 2 | ||||
-rw-r--r-- | stream.php | 2 | ||||
-rw-r--r-- | templates/show_manage_democratic.inc.php | 5 |
9 files changed, 78 insertions, 10 deletions
diff --git a/democratic.php b/democratic.php index 6cca46c4..ec7c7fcc 100644 --- a/democratic.php +++ b/democratic.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2007 Ampache.org + Copyright (c) 2001 - 2008 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -40,6 +40,19 @@ switch ($_REQUEST['action']) { // Show the create page require_once Config::get('prefix') . '/templates/show_create_democratic.inc.php'; break; + case 'delete': + if (!Access::check('interface','75')) { + access_denied(); + break; + } + + Democratic::delete($_REQUEST['democratic_id']); + + $title = ''; + $text = _('The Requested Playlist has been deleted.'); + $url = Config::get('web_path') . '/democratic.php?action=manage_playlists'; + show_confirmation($title,$text,$url); + break; case 'create': // Only power users here if (!Access::check('interface','75')) { diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 00f91a9b..d90fa2b8 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,7 @@ -------------------------------------------------------------------------- v.3.4-Beta2 + - Fixed an issue with the clean function for playlists - DB Update, fixes the playlist create issue with full strict on MySQL 5.x - Corrected mime type for JPG (Thx CoF) 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 ?> diff --git a/server/democratic.ajax.php b/server/democratic.ajax.php index 123bd3c5..e7bd745b 100644 --- a/server/democratic.ajax.php +++ b/server/democratic.ajax.php @@ -68,7 +68,7 @@ switch ($_REQUEST['action']) { exit; } - $_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=democratic'; + $_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=democratic&democratic_id=' . scrub_out($_REQUEST['democratic_id']); $results['rfc3514'] = '<script type="text/javascript">reload_util("'.$_SESSION['iframe']['target'].'")</script>'; break; default: @@ -144,7 +144,7 @@ switch ($_REQUEST['action']) { $song_ids = get_random_songs($options, $matchlist); break; case 'democratic': - $democratic = Democratic::get_current_playlist(); + $democratic = new Democratic($_REQUEST['democratic_id']); $urls[] = $democratic->get_url(); $song_ids = array('0'); break; diff --git a/templates/show_manage_democratic.inc.php b/templates/show_manage_democratic.inc.php index 8361e525..8498bebc 100644 --- a/templates/show_manage_democratic.inc.php +++ b/templates/show_manage_democratic.inc.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2007 Ampache.org + Copyright (c) 2001 - 2008 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -54,7 +54,8 @@ show_box_top(_('Manage Democratic Playlists')); ?> <td><?php echo $democratic->f_primary; ?></td> <td><?php echo $democratic->count_items(); ?></td> <td> - <?php echo Ajax::button('?page=democratic&action=send_playlist','all',_('Play'),'play_democratic'); ?> + <?php echo Ajax::button('?page=democratic&action=send_playlist&democratic_id=' . $democratic->id,'all',_('Play'),'play_democratic'); ?> + <a href="<?php echo Config::get('web_path'); ?>/democratic.php?action=delete&democratic_id=<?php echo scrub_out($democratic->id); ?>"><?php echo get_user_icon('delete'); ?></a> </td> </tr> <?php } if (!count($playlists)) { ?> |