diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-01-14 01:38:50 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-01-14 01:38:50 +0000 |
commit | d7c3ede9e757dab9889503a415d78c7937a311b3 (patch) | |
tree | 4311b7aac78600968bdb151c6873eaca80caee5f | |
parent | fda4bd6deb683fc937f1ae831d9c8ed5b4748eaf (diff) | |
download | ampache-d7c3ede9e757dab9889503a415d78c7937a311b3.tar.gz ampache-d7c3ede9e757dab9889503a415d78c7937a311b3.tar.bz2 ampache-d7c3ede9e757dab9889503a415d78c7937a311b3.zip |
fixed public/private aspect of playlists, default is to filter out non-owned private playlists now
-rw-r--r-- | browse.php | 1 | ||||
-rwxr-xr-x | docs/CHANGELOG | 3 | ||||
-rw-r--r-- | images/icon_lock.png | bin | 0 -> 749 bytes | |||
-rw-r--r-- | lib/album.lib.php | 2 | ||||
-rw-r--r-- | lib/class/browse.class.php | 13 | ||||
-rw-r--r-- | lib/class/playlist.class.php | 7 | ||||
-rw-r--r-- | play/index.php | 6 | ||||
-rw-r--r-- | server/ajax.server.php | 9 | ||||
-rw-r--r-- | templates/show_edit_playlist_row.inc.php | 12 | ||||
-rw-r--r-- | templates/show_playlist.inc.php | 2 | ||||
-rw-r--r-- | templates/show_playlist_row.inc.php | 1 | ||||
-rw-r--r-- | templates/show_playlists.inc.php | 5 |
12 files changed, 49 insertions, 12 deletions
@@ -87,6 +87,7 @@ switch($_REQUEST['action']) { Browse::set_type('playlist'); Browse::set_simple_browse(1); Browse::set_sort('name','ASC'); + Browse::set_filter('playlist_type','1'); $playlist_ids = Browse::get_objects(); Browse::show_objects($playlist_ids); break; diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 8212fe9b..83c29832 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,9 @@ -------------------------------------------------------------------------- v.3.4-Beta2 + - Fixed filtering of Private Playlists and fixed editing of type + of playlist. Default is still public on creation. + - Fixed erronous fseek() when downsampling. - Fixed search by stars so that it returns the correct results (Thx alex2008) - Fixed issue where random didn't end correctly when no results found diff --git a/images/icon_lock.png b/images/icon_lock.png Binary files differnew file mode 100644 index 00000000..2ebc4f6f --- /dev/null +++ b/images/icon_lock.png diff --git a/lib/album.lib.php b/lib/album.lib.php index bf491c2a..3216b35e 100644 --- a/lib/album.lib.php +++ b/lib/album.lib.php @@ -116,7 +116,7 @@ function get_random_albums($count=6) { $sql = 'SELECT '; - for ($i = 0; $i < ceil($count * 1.5); $i++) { + for ($i = 0; $i < ceil($count * 2); $i++) { if ($i > 0) $sql .= ', '; $sql .= 'floor(rand() * count(id))'; diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index ae82d271..6eda41c7 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -62,7 +62,6 @@ class Browse { switch ($key) { case 'show_art': - $key = $_REQUEST['key']; if ($_SESSION['browse']['filter'][$key]) { unset($_SESSION['browse']['filter'][$key]); } @@ -80,6 +79,11 @@ class Browse { if ($value == _('All')) { $value = ''; } $_SESSION['browse']['filter'][$key] = $value; break; + case 'playlist_type': + // They must be content managers to turn this off + if ($_SESSION['browse']['filter'][$key] AND Access::check('interface','50')) { unset($_SESSION['browse']['filter'][$key]); } + else { $_SESSION['browse']['filter'][$key] = '1'; } + break; default: // Rien a faire return false; @@ -477,6 +481,10 @@ class Browse { case 'alpha_match': $filter_sql = " `playlist`.`name` LIKE '" . Dba::escape($value) . "%' AND "; break; + case 'playlist_type': + $user_id = intval($GLOBALS['user']->id); + $filter_sql = " (`playlist`.`type` = 'public' OR `playlist`.`user`='$user_id') AND "; + break; default; // Rien a faire break; @@ -553,6 +561,9 @@ class Browse { case 'name': $sql = "`playlist`.`name`"; break; + case 'user': + $sql = "`playlist`.`user`"; + break; } // end switch break; case 'live_stream': diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php index 8310219c..b5cb8f71 100644 --- a/lib/class/playlist.class.php +++ b/lib/class/playlist.class.php @@ -78,6 +78,8 @@ class Playlist { $this->f_name = truncate_with_ellipsis($this->name,Config::get('ellipse_threshold_title')); $this->f_link = '<a href="' . Config::get('web_path') . '/playlist.php?action=show_playlist&playlist_id=' . $this->id . '">' . $this->f_name . '</a>'; + $this->f_type = ($this->type == 'private') ? get_user_icon('lock',_('Private')) : ''; + $client = new User($this->user); $this->f_user = $client->fullname; @@ -263,6 +265,9 @@ class Playlist { if ($data['name'] != $this->name) { $this->update_name($data['name']); } + if ($data['pl_type'] != $this->type) { + $this->update_type($data['pl_type']); + } } // update @@ -296,7 +301,7 @@ class Playlist { */ private function _update_item($field,$value,$level) { - if ($GLOBALS['user']->id != $this->user AND !$GLOBALS['user']->has_access($level)) { + if ($GLOBALS['user']->id != $this->user AND !Access::check('interface',$level)) { return false; } diff --git a/play/index.php b/play/index.php index ff1be7e0..b1e2b3f4 100644 --- a/play/index.php +++ b/play/index.php @@ -251,6 +251,8 @@ if (($GLOBALS['user']->prefs['transcode'] == 'always' || !$song->native_stream() debug_event('downsample','Starting Downsample...','5'); $fp = Stream::start_downsample($song,$lastid,$song_name,$start); $song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type; + // Note that this is downsampling + $downsampled_song = true; } // end if downsampling else { // Send file, possible at a byte offset @@ -278,7 +280,9 @@ if (isset($start)) { debug_event('seek','Content-Range header recieved, skipping ahead ' . $start . ' bytes out of ' . $song->size,'5'); $browser->downloadHeaders($song_name, $song->mime, false, $song->size); - fseek( $fp, $start ); + if (!$downsampled_song) { + fseek( $fp, $start ); + } $range = $start ."-". $end . "/" . $song->size; header("HTTP/1.1 206 Partial Content"); header("Content-Range: bytes $range"); diff --git a/server/ajax.server.php b/server/ajax.server.php index 6f3237c6..b2436758 100644 --- a/server/ajax.server.php +++ b/server/ajax.server.php @@ -126,8 +126,9 @@ switch ($_REQUEST['action']) { } // end switch on type // Make sure they got them rights - if (!$GLOBALS['user']->has_access($level)) { - exit; + if (!Access::check('interface',$level)) { + $results['rfc3514'] = '0x1'; + break; } ob_start(); @@ -148,7 +149,8 @@ switch ($_REQUEST['action']) { // Make sure we've got them rights if (!Access::check('interface',$level) || Config::get('demo_mode')) { - exit; + $results['rfc3514'] = '0x1'; + break; } switch ($_POST['type']) { @@ -189,6 +191,7 @@ switch ($_REQUEST['action']) { $key = 'playlist_row_' . $_POST['id']; $playlist->update($_POST); $playlist->format(); + $count = $playlist->get_song_count(); break; case 'live_stream': $key = 'live_stream_' . $_POST['id']; diff --git a/templates/show_edit_playlist_row.inc.php b/templates/show_edit_playlist_row.inc.php index edc8e63f..3a1e6161 100644 --- a/templates/show_edit_playlist_row.inc.php +++ b/templates/show_edit_playlist_row.inc.php @@ -19,13 +19,19 @@ */ ?> -<td colspan="5"> -<form method="post" id="edit_playlist_<?php echo $playlist->id; ?>" action="#"> +<td colspan="6"> +<form method="post" id="edit_playlist_<?php echo $playlist->id; ?>" action="javascript:void(0);"> <table cellpadding="0" cellspacing="0"> <tr> <td> - <input type="textbox" name="name" size="9" value="<?php echo scrub_out($playlist->name); ?>" /> + <input type="textbox" name="name" size="9" value="<?php echo scrub_out($playlist->name); ?>" /> </td> + <td> + <?php $name = 'select_' . $playlist->type; ${$name} = ' selected="selected"'; ?> + <select name="pl_type"> + <option value="public"<?php echo $select_public; ?>><?php echo _('Public'); ?></option> + <option value="private"<?php echo $select_private; ?>><?php echo _('Private'); ?></option> + </select> <td> <input type="hidden" name="id" value="<?php echo $playlist->id; ?>" /> <input type="hidden" name="type" value="playlist" /> diff --git a/templates/show_playlist.inc.php b/templates/show_playlist.inc.php index 0c72526c..622e266b 100644 --- a/templates/show_playlist.inc.php +++ b/templates/show_playlist.inc.php @@ -24,7 +24,7 @@ */ $web_path = Config::get('web_path'); ?> -<?php show_box_top($playlist->name . ' ' . _('Playlist')); ?> +<?php show_box_top($playlist->f_type . ' ' . $playlist->name . ' ' . _('Playlist')); ?> <div id="information_actions"> <ul> <li><a href="<?php echo $web_path; ?>/playlist.php?action=normalize_tracks&playlist_id=<?php echo $playlist->id; ?>"><?php echo _('Normalize Tracks'); ?></a></li> diff --git a/templates/show_playlist_row.inc.php b/templates/show_playlist_row.inc.php index 1efb252a..a6579a05 100644 --- a/templates/show_playlist_row.inc.php +++ b/templates/show_playlist_row.inc.php @@ -24,6 +24,7 @@ <?php echo Ajax::button('?action=basket&type=playlist_random&id=' . $playlist->id,'random',_('Random'),'random_playlist_' . $playlist->id); ?> </td> <td class="cel_playlist"><?php echo $playlist->f_link; ?></td> +<td class="cel_type"><?php echo $playlist->f_type; ?></td> <td class="cel_songs"><?php echo $count; ?></td> <td class="cel_owner"><?php echo scrub_out($playlist->f_user); ?></td> <td class="cel_action"> diff --git a/templates/show_playlists.inc.php b/templates/show_playlists.inc.php index 5707c772..553d65f5 100644 --- a/templates/show_playlists.inc.php +++ b/templates/show_playlists.inc.php @@ -25,6 +25,7 @@ <colgroup> <col id="col_add" /> <col id="col_playlist" /> + <col id="col_type" /> <col id="col_songs" /> <col id="col_owner" /> <col id="col_action" /> @@ -32,6 +33,7 @@ <tr class="th-top"> <th class="cel_add"><?php echo _('Add'); ?></th> <th class="cel_playlist"><?php echo Ajax::text('?page=browse&action=set_sort&sort=name',_('Playlist Name'),'playlist_sort_name'); ?></th> + <th class="cel_type"> </th> <th class="cel_songs"><?php echo _('# Songs'); ?></th> <th class="cel_owner"><?php echo Ajax::text('?page=browse&action=set_sort&sort=user',_('Owner'),'playlist_sort_owner'); ?></th> <th class="cel_action"><?php echo _('Actions'); ?></th> @@ -49,8 +51,9 @@ foreach ($object_ids as $playlist_id) { <tr class="th-bottom"> <th class="cel_add"><?php echo _('Add'); ?></th> <th class="cel_playlist"><?php echo Ajax::text('?page=browse&action=set_sort&sort=name',_('Playlist Name'),'playlist_sort_name_bottom'); ?></th> + <th class="cel_type"> </th> <th class="cel_songs"><?php echo _('# Songs'); ?></th> - <th class="cel_owner"><?php echo Ajax::text('?page=browse&action=set_sort&sort=user',_('Owner'),'playlist_sort_owner'); ?></th> + <th class="cel_owner"><?php echo Ajax::text('?page=browse&action=set_sort&sort=user',_('Owner'),'playlist_sort_owner_bottom'); ?></th> <th class="cel_action"><?php echo _('Actions'); ?></th> </tr> </table> |