forked from ampache/ampache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
albums.php
132 lines (118 loc) · 4.5 KB
/
albums.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU Affero General Public License, version 3 (AGPLv3)
* Copyright 2001 - 2017 Ampache.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
require_once 'lib/init.php';
require_once AmpConfig::get('prefix') . UI::find_template('header.inc.php');
/* Switch on Action */
switch ($_REQUEST['action']) {
case 'delete':
if (AmpConfig::get('demo_mode')) {
break;
}
$album_id = scrub_in($_REQUEST['album_id']);
show_confirmation(
T_('Album Deletion'),
T_('Are you sure you want to permanently delete this album?'),
AmpConfig::get('web_path') . "/albums.php?action=confirm_delete&album_id=" . $album_id,
1,
'delete_album'
);
break;
case 'confirm_delete':
if (AmpConfig::get('demo_mode')) {
break;
}
$album = new Album($_REQUEST['album_id']);
if (!Catalog::can_remove($album)) {
debug_event('album', 'Unauthorized to remove the album `.' . $album->id . '`.', 1);
UI::access_denied();
exit;
}
if ($album->remove_from_disk()) {
show_confirmation(T_('Album Deletion'), T_('Album has been deleted.'), AmpConfig::get('web_path'));
} else {
show_confirmation(T_('Album Deletion'), T_('Cannot delete this album.'), AmpConfig::get('web_path'));
}
break;
case 'update_from_tags':
// Make sure they are a 'power' user at least
if (!Access::check('interface', '75')) {
UI::access_denied();
exit;
}
$type = 'album';
$object_id = intval($_REQUEST['album_id']);
$target_url = AmpConfig::get('web_path') . '/albums.php?action=show&album=' . $object_id;
require_once AmpConfig::get('prefix') . UI::find_template('show_update_items.inc.php');
break;
case 'set_track_numbers':
debug_event('albums', 'Set track numbers called.', '5');
if (!Access::check('interface', '75')) {
UI::access_denied();
exit;
}
// Retrieving final song order from url
foreach ($_GET as $key => $data) {
$_GET[$key] = unhtmlentities(scrub_in($data));
debug_event('albums', $key . '=' . $_GET[$key], '5');
}
if (isset($_GET['order'])) {
$songs = explode(";", $_GET['order']);
$track = $_GET['offset'] ? (intval($_GET['offset']) + 1) : 1;
foreach ($songs as $song_id) {
if ($song_id != '') {
Song::update_track($track, $song_id);
++$track;
}
}
}
break;
case 'show_missing':
set_time_limit(600);
$mbid = $_REQUEST['mbid'];
$walbum = new Wanted(Wanted::get_wanted($mbid));
if (!$walbum->id) {
$walbum->mbid = $mbid;
if (isset($_REQUEST['artist'])) {
$artist = new Artist($_REQUEST['artist']);
$walbum->artist = $artist->id;
$walbum->artist_mbid = $artist->mbid;
} elseif (isset($_REQUEST['artist_mbid'])) {
$walbum->artist_mbid = $_REQUEST['artist_mbid'];
}
}
$walbum->load_all();
$walbum->format();
require AmpConfig::get('prefix') . UI::find_template('show_missing_album.inc.php');
break;
// Browse by Album
case 'show':
default:
$album = new Album($_REQUEST['album']);
$album->format();
if (!count($album->album_suite)) {
require AmpConfig::get('prefix') . UI::find_template('show_album.inc.php');
} else {
require AmpConfig::get('prefix') . UI::find_template('show_album_group_disks.inc.php');
}
break;
} // switch on view
UI::show_footer();