49
40
$catalog = new Catalog();
50
41
$_REQUEST['catalogs'] = $catalog->get_catalog_ids();
51
42
case 'add_to_catalog':
52
if (conf('demo_mode')) { break; }
43
toggle_visible('ajax-loading');
45
if (Config::get('demo_mode')) { break; }
53
46
if ($_REQUEST['catalogs'] ) {
54
47
foreach ($_REQUEST['catalogs'] as $catalog_id) {
55
echo "<div class=\"confirmation-box\">";
56
48
$catalog = new Catalog($catalog_id);
57
49
$catalog->add_to_catalog();
61
$url = conf('web_path') . '/admin/index.php';
52
$url = Config::get('web_path') . '/admin/index.php';
62
53
$title = _('Catalog Updated');
64
55
show_confirmation($title,$body,$url);
56
toggle_visible('ajax-loading');
66
58
case 'update_all_catalogs':
67
$catalog = new Catalog();
68
$_REQUEST['catalogs'] = $catalog->get_catalog_ids();
59
$_REQUEST['catalogs'] = Catalog::get_catalog_ids();
69
60
case 'update_catalog':
61
toggle_visible('ajax-loading');
70
63
/* If they are in demo mode stop here */
71
if (conf('demo_mode')) { break; }
64
if (Config::get('demo_mode')) { break; }
73
66
if (isset($_REQUEST['catalogs'])) {
74
67
foreach ($_REQUEST['catalogs'] as $catalog_id) {
75
echo "<div class=\"confirmation-box\">";
76
$catalog = new Catalog($catalog_id);
77
$catalog->verify_catalog($catalog_id->id);
68
$catalog = new Catalog($catalog_id);
69
$catalog->verify_catalog($catalog_id);
81
$url = conf('web_path') . '/admin/index.php';
72
$url = Config::get('web_path') . '/admin/index.php';
82
73
$title = _('Catalog Updated');
84
75
show_confirmation($title,$body,$url);
76
toggle_visible('ajax-loading');
86
78
case 'full_service':
87
$catalog = new Catalog();
79
toggle_visible('ajax-loading');
88
81
/* Make sure they aren't in demo mode */
89
if (conf('demo_mode')) { break; }
82
if (Config::get('demo_mode')) { access_denied(); break; }
91
84
if (!$_REQUEST['catalogs']) {
92
$_REQUEST['catalogs'] = $catalog->get_catalog_ids();
85
$_REQUEST['catalogs'] = Catalog::get_catalog_ids();
95
88
/* This runs the clean/verify/add in that order */
96
89
foreach ($_REQUEST['catalogs'] as $catalog_id) {
97
echo "<div class=\"confirmation-box\">";
98
90
$catalog = new Catalog($catalog_id);
99
$catalog->clean_catalog();
101
$catalog->verify_catalog();
103
$catalog->add_to_catalog();
91
$catalog->clean_catalog($catalog_id);
93
$catalog->verify_catalog($catalog_id);
95
$catalog->add_to_catalog($catalog_id);
106
$url = conf('web_path') . '/admin/index.php';
97
$url = Config::get('web_path') . '/admin/index.php';
107
98
$title = _('Catalog Updated');
109
100
show_confirmation($title,$body,$url);
101
toggle_visible('ajax-loading');
111
103
case 'delete_catalog':
112
104
/* Make sure they aren't in demo mode */
113
if (conf('demo_mode')) { break; }
105
if (Config::get('demo_mode')) { break; }
115
107
/* Delete the sucker, we don't need to check perms as thats done above */
116
$catalog = new Catalog($_REQUEST['catalog_id']);
117
$catalog->delete_catalog();
118
$next_url = conf('web_path') . '/admin/index.php';
119
show_confirmation(_('Catalog Deleted'),_('The Catalog and all associated records has been deleted'),$nexturl);
108
Catalog::delete($_REQUEST['catalog_id']);
109
$next_url = Config::get('web_path') . '/admin/index.php';
110
show_confirmation(_('Catalog Deleted'),_('The Catalog and all associated records have been deleted'),$nexturl);
121
112
case 'remove_disabled':
122
113
if (conf('demo_mode')) { break; }
124
$songs = $_REQUEST['items'];
115
$song = $_REQUEST['song'];
127
$catalog->remove_songs($songs);
118
$catalog->remove_songs($song);
128
119
$body = _('Songs Removed');
137
128
case 'clean_all_catalogs':
138
129
$catalog = new Catalog();
139
$_REQUEST['catalogs'] = $catalog->get_catalog_ids();
130
$_REQUEST['catalogs'] = Catalog::get_catalog_ids();
140
131
case 'clean_catalog':
132
toggle_visible('ajax-loading');
141
134
/* If they are in demo mode stop them here */
142
if (conf('demo_mode')) { break; }
135
if (Config::get('demo_mode')) { break; }
144
137
// Make sure they checked something
145
138
if (isset($_REQUEST['catalogs'])) {
146
139
foreach($_REQUEST['catalogs'] as $catalog_id) {
147
echo "<div class=\"confirmation-box\">";
148
140
$catalog = new Catalog($catalog_id);
149
141
$catalog->clean_catalog(0,1);
151
142
} // end foreach catalogs
154
$url = conf('web_path') . '/admin/index.php';
145
$url = Config::get('web_path') . '/admin/index.php';
155
146
$title = _('Catalog Cleaned');
157
148
show_confirmation($title,$body,$url);
149
toggle_visible('ajax-loading');
159
151
case 'update_catalog_settings':
160
152
/* No Demo Here! */
161
if (conf('demo_mode')) { break; }
153
if (Config::get('demo_mode')) { break; }
163
155
/* Update the catalog */
164
$catalog = new Catalog();
165
$catalog->update_settings($_REQUEST);
156
Catalog::update_settings($_REQUEST);
167
$url = conf('web_path') . '/admin/index.php';
158
$url = Config::get('web_path') . '/admin/index.php';
168
159
$title = _('Catalog Updated');
170
161
show_confirmation($title,$body,$url);
173
163
case 'add_catalog':
175
if (conf('demo_mode')) { break; }
165
if (Config::get('demo_mode')) { break; }
169
if (!strlen($_REQUEST['path']) || !strlen($_REQUEST['name'])) {
170
Error::add('general','Error Name and path not specified');
173
if (substr($_REQUEST['path'],0,7) != 'http://' && $_REQUEST['type'] == 'remote') {
174
Error::add('general','Error Remote selected, but path is not a URL');
177
if ($_REQUEST['path'] AND $_REQUEST['name']) {
178
/* Throw all of the album art types into an array */
179
$art = array('id3'=>$_REQUEST['art_id3v2'],'amazon'=>$_REQUEST['art_amazon'],'folder'=>$_REQUEST['art_folder']);
181
/* Enclose it in a purrty box! */
182
echo "<div class=\"confirmation-box\">";
177
if ($_REQUEST['type'] == 'remote' && !strlen($_REQUEST['key'])) {
178
Error::add('general','Error Remote Catalog specified, but no key provided');
181
// If an error hasn't occured
182
if (!Error::$state) {
184
$catalog_id = Catalog::Create($_REQUEST);
187
require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
191
$catalog = new Catalog($catalog_id);
184
/* Create the Catalog */
185
$catalog->new_catalog($_REQUEST['path'],
188
$_REQUEST['rename_pattern'],
189
$_REQUEST['sort_pattern'],
191
$_REQUEST['gather_art'],
192
$_REQUEST['parse_m3u'],
197
$url = conf('web_path') . '/admin/index.php';
198
$title = _('Catalog Created');
199
$body = _('Catalog Created and Songs Indexed');
200
show_confirmation($title,$body,$url);
193
// Run our initial add
194
$catalog->run_add($_REQUEST);
197
echo "<h2>" . _('Catalog Created') . "</h2>";
198
Error::display('general');
199
Error::display('catalog_add');
202
show_confirmation('','','/admin/index.php');
203
$error = "Please complete the form.";
204
include(conf('prefix') . '/templates/show_add_catalog.inc.php');
206
require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
207
209
case 'clear_stats':
208
if (conf('demo_mode')) { break; }
210
if (Config::get('demo_mode')) { access_denied(); break; }
210
clear_catalog_stats();
211
$url = conf('web_path') . '/admin/index.php';
212
Catalog::clear_stats();
213
$url = Config::get('web_path') . '/admin/index.php';
212
214
$title = _('Catalog statistics cleared');
214
216
show_confirmation($title,$body,$url);
218
case 'show_catalogs':
219
$catalog_ids = Catalog::get_catalogs();
220
Browse::set_type('catalog');
221
Browse::set_static_content(1);
222
Browse::save_objects($catalog_ids);
223
Browse::show_objects($catalog_ids);
216
225
case 'show_add_catalog':
217
include(conf('prefix') . '/templates/show_add_catalog.inc.php');
226
require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
219
228
case 'clear_now_playing':
220
if (conf('demo_mode')) { break; }
222
show_confirmation(_('Now Playing Cleared'),_('All now playing data has been cleared'),conf('web_path') . '/admin/index.php');
224
case 'show_clear_stats':
226
if (conf('demo_mode')) { break; }
228
$url = conf('web_path') . '/admin/catalog.php?action=clear_stats';
229
$body = _('Do you really want to clear the statistics for this catalog?');
230
$title = _('Clear Catalog Stats');
231
show_confirmation($title,$body,$url,1);
229
if (Config::get('demo_mode')) { access_denied(); break; }
230
Stream::clear_now_playing();
231
show_confirmation(_('Now Playing Cleared'),_('All now playing data has been cleared'),Config::get('web_path') . '/admin/index.php');
233
233
case 'show_disabled':
234
234
if (conf('demo_mode')) { break; }
236
236
$songs = $catalog->get_disabled();
237
237
if (count($songs)) {
238
require (conf('prefix') . '/templates/show_disabled_songs.inc');
238
require (conf('prefix') . '/templates/show_disabled_songs.inc.php');
241
241
echo "<div class=\"error\" align=\"center\">" . _('No Disabled songs found') . "</div>";
244
244
case 'show_delete_catalog':
245
245
/* Stop the demo hippies */
246
if (conf('demo_mode')) { break; }
246
if (Config::get('demo_mode')) { access_denied(); break; }
247
248
$catalog = new Catalog($_REQUEST['catalog_id']);
248
$nexturl = conf('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($_REQUEST['catalog_id']);
249
$nexturl = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($_REQUEST['catalog_id']);
249
250
show_confirmation(_('Delete Catalog'),_('Do you really want to delete this catalog?') . " -- $catalog->name ($catalog->path)",$nexturl,1);
251
252
case 'show_customize_catalog':
252
include(conf('prefix') . '/templates/show_edit_catalog.inc.php');
253
$catalog = new Catalog($_REQUEST['catalog_id']);
254
require_once Config::get('prefix') . '/templates/show_edit_catalog.inc.php';
254
256
case 'gather_album_art':
256
$catalogs = $catalog->get_catalogs();
257
foreach ($catalogs as $data) {
258
echo "<div class=\"confirmation-box\"><b>" . _('Starting Album Art Search') . ". . .</b><br /><br />\n";
259
echo _('Searched') . ": <span id=\"count_art_" . $data->id . "\">" . _('None') . "</span><br />";
260
$data->get_album_art(0,1);
261
echo "<b>" . _('Album Art Search Finished') . ". . .</b></div>\n";
257
toggle_visible('ajax-loading');
260
$catalogs = $_REQUEST['catalogs'] ? $_REQUEST['catalogs'] : Catalog::get_catalogs();
262
// Itterate throught the catalogs and gather as needed
263
foreach ($catalogs as $catalog_id) {
264
$catalog = new Catalog($catalog_id);
265
require Config::get('prefix') . '/templates/show_gather_art.inc.php';
267
$catalog->get_album_art('',1);
263
$url = conf('web_path') . '/admin/index.php';
269
$url = Config::get('web_path') . '/admin/index.php';
264
270
$title = _('Album Art Search Finished');
266
272
show_confirmation($title,$body,$url);