1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00

fixed public/private aspect of playlists, default is to filter out non-owned private playlists now

This commit is contained in:
Karl 'vollmerk' Vollmer 2008-01-14 01:38:50 +00:00
parent fda4bd6deb
commit d7c3ede9e7
12 changed files with 49 additions and 12 deletions

View file

@ -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;

View file

@ -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

BIN
images/icon_lock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 749 B

View file

@ -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))';

View file

@ -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':

View file

@ -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&amp;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;
}

View file

@ -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);
if (!$downsampled_song) {
fseek( $fp, $start );
}
$range = $start ."-". $end . "/" . $song->size;
header("HTTP/1.1 206 Partial Content");
header("Content-Range: bytes $range");

View file

@ -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'];

View file

@ -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); ?>" />
</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" />

View file

@ -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&amp;playlist_id=<?php echo $playlist->id; ?>"><?php echo _('Normalize Tracks'); ?></a></li>

View file

@ -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">

View file

@ -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">&nbsp;</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">&nbsp;</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>