~ubuntu-branches/debian/sid/ampache/sid

« back to all changes in this revision

Viewing changes to admin/catalog.php

  • Committer: Package Import Robot
  • Author(s): Charlie Smotherman
  • Date: 2013-08-27 13:19:48 UTC
  • mfrom: (1.2.9)
  • Revision ID: package-import@ubuntu.com-20130827131948-1czew0zxn6u70dtv
Tags: 3.6-rzb2752+dfsg-1
* New upsteam snapshot.  Contains important bug fixes to the installer.
* Correct typo in ampache-common.postrm.
* Remove courtousy copy of php-getid3, during repack.  Closes: #701526
* Update package to use dh_linktree to make the needed sym links to the
  needed system libs that were removed during repack.
* Update debian/rules to reflect upstreams removing/moving of modules.
* Update debian/ampache-common.install to reflect upstreams removal of files.
* Updated to use new apache2.4 API. Closes: #669756
* Updated /debian/po/de.po thx David Prévot for the patch.  Closes:  #691963
* M3U import is now ordered, fixed upstream.  Closes: #684984
* Text input area has been resized so IPv6 addresses will now fit, fixed
  upstream.  Closes:  #716230
* Added ampache-common.preinst to make sure that the courtousy copies of code
  dirs are empty so dh_linktree can do it's magic on upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
 
2
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
3
3
/**
4
 
 * Admin Catalog
5
 
 *
6
4
 *
7
5
 * LICENSE: GNU General Public License, version 2 (GPLv2)
8
 
 * Copyright (c) 2001 - 2011 Ampache.org All Rights Reserved
 
6
 * Copyright 2001 - 2013 Ampache.org
9
7
 *
10
8
 * This program is free software; you can redistribute it and/or
11
9
 * modify it under the terms of the GNU General Public License v2
20
18
 * along with this program; if not, write to the Free Software
21
19
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
20
 *
23
 
 * @package     Ampache
24
 
 * @copyright   2001 - 2011 Ampache.org
25
 
 * @license     http://opensource.org/licenses/gpl-2.0 GPLv2
26
 
 * @link        http://www.ampache.org/
27
21
 */
28
22
 
29
23
require_once '../lib/init.php';
30
24
 
31
25
if (!Access::check('interface','100')) {
32
 
        access_denied();
33
 
        exit;
 
26
    UI::access_denied();
 
27
    exit;
34
28
}
35
29
 
36
 
show_header();
 
30
UI::show_header();
37
31
 
38
32
/* Big switch statement to handle various actions */
39
33
switch ($_REQUEST['action']) {
40
 
        case 'fixed':
41
 
                /* Does this use now? */
42
 
                delete_flagged($flag);
43
 
                $type = 'show_flagged_songs';
44
 
                include(conf('prefix') . '/templates/flag.inc');
45
 
        break;
46
 
        case 'add_to_all_catalogs':
47
 
                $catalog = new Catalog();
48
 
                $_REQUEST['catalogs'] = $catalog->get_catalog_ids();
49
 
        case 'add_to_catalog':
50
 
                toggle_visible('ajax-loading');
51
 
                ob_end_flush();
52
 
                        if (Config::get('demo_mode')) { break; }
53
 
                if ($_REQUEST['catalogs'] ) {
54
 
                        foreach ($_REQUEST['catalogs'] as $catalog_id) {
55
 
                                $catalog = new Catalog($catalog_id);
56
 
                                $catalog->add_to_catalog();
57
 
                        }
58
 
                }
59
 
                $url    = Config::get('web_path') . '/admin/catalog.php';
60
 
                $title  = T_('Catalog Updated');
61
 
                $body   = '';
62
 
                show_confirmation($title,$body,$url);
63
 
                toggle_visible('ajax-loading');
64
 
        break;
65
 
        case 'update_all_catalogs':
66
 
                $_REQUEST['catalogs'] = Catalog::get_catalog_ids();
67
 
        case 'update_catalog':
68
 
                toggle_visible('ajax-loading');
69
 
                ob_end_flush();
70
 
                        /* If they are in demo mode stop here */
71
 
                        if (Config::get('demo_mode')) { break; }
72
 
 
73
 
                if (isset($_REQUEST['catalogs'])) {
74
 
                        foreach ($_REQUEST['catalogs'] as $catalog_id) {
75
 
                                $catalog = new Catalog($catalog_id);
76
 
                                $catalog->verify_catalog();
77
 
                        }
78
 
                }
79
 
                $url    = Config::get('web_path') . '/admin/catalog.php';
80
 
                $title  = T_('Catalog Updated');
81
 
                $body   = '';
82
 
                show_confirmation($title,$body,$url);
83
 
                toggle_visible('ajax-loading');
84
 
        break;
85
 
        case 'full_service':
86
 
                toggle_visible('ajax-loading');
87
 
                ob_end_flush();
88
 
                /* Make sure they aren't in demo mode */
89
 
                if (Config::get('demo_mode')) { access_denied(); break; }
90
 
 
91
 
                if (!$_REQUEST['catalogs']) {
92
 
                        $_REQUEST['catalogs'] = Catalog::get_catalog_ids();
93
 
                }
94
 
 
95
 
                /* This runs the clean/verify/add in that order */
96
 
                foreach ($_REQUEST['catalogs'] as $catalog_id) {
97
 
                        $catalog = new Catalog($catalog_id);
98
 
                        $catalog->clean_catalog();
99
 
                        $catalog->count = 0;
100
 
                        $catalog->verify_catalog();
101
 
                        $catalog->count = 0;
102
 
                        $catalog->add_to_catalog();
103
 
                }
104
 
                Catalog::optimize_tables();
105
 
                $url    = Config::get('web_path') . '/admin/catalog.php';
106
 
                $title  = T_('Catalog Updated');
107
 
                $body   = '';
108
 
                show_confirmation($title,$body,$url);
109
 
                toggle_visible('ajax-loading');
110
 
        break;
111
 
        case 'delete_catalog':
112
 
                /* Make sure they aren't in demo mode */
113
 
                        if (Config::get('demo_mode')) { break; }
114
 
 
115
 
                if (!Core::form_verify('delete_catalog')) {
116
 
                        access_denied();
117
 
                        exit;
118
 
                }
119
 
 
120
 
                /* Delete the sucker, we don't need to check perms as thats done above */
121
 
                Catalog::delete($_GET['catalog_id']);
122
 
                $next_url = Config::get('web_path') . '/admin/catalog.php';
123
 
                show_confirmation(T_('Catalog Deleted'), T_('The Catalog and all associated records have been deleted'),$next_url);
124
 
        break;
125
 
        case 'show_delete_catalog':
126
 
                $catalog_id = scrub_in($_GET['catalog_id']);
127
 
 
128
 
                $next_url = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($catalog_id);
129
 
                show_confirmation(T_('Catalog Delete'), T_('Confirm Deletion Request'),$next_url,1,'delete_catalog');
130
 
        break;
131
 
        case 'remove_disabled':
132
 
                if (conf('demo_mode')) { break; }
133
 
 
134
 
                $song = $_REQUEST['song'];
135
 
 
136
 
                if (count($song)) {
137
 
                        $catalog->remove_songs($song);
138
 
                        $body = T_ngettext('Song Removed', 'Songs Removed', count($song));
139
 
                }
140
 
                else {
141
 
                        $body = T_('No Songs Removed');
142
 
                }
143
 
                $url    = Config::get('web_path') . '/admin/catalog.php';
144
 
                $title  = T_ngettext('Disabled Song Processed','Disabled Songs Processed',count($song));
145
 
                show_confirmation($title,$body,$url);
146
 
        break;
147
 
        case 'clean_all_catalogs':
148
 
                $catalog = new Catalog();
149
 
                $_REQUEST['catalogs'] = Catalog::get_catalog_ids();
150
 
        case 'clean_catalog':
151
 
                toggle_visible('ajax-loading');
152
 
                ob_end_flush();
153
 
                        /* If they are in demo mode stop them here */
154
 
                        if (Config::get('demo_mode')) { break; }
155
 
 
156
 
                // Make sure they checked something
157
 
                if (isset($_REQUEST['catalogs'])) {
158
 
                        foreach($_REQUEST['catalogs'] as $catalog_id) {
159
 
                                $catalog = new Catalog($catalog_id);
160
 
                                $catalog->clean_catalog();
161
 
                        } // end foreach catalogs
162
 
                        Catalog::optimize_tables();
163
 
                }
164
 
 
165
 
                $url    = Config::get('web_path') . '/admin/catalog.php';
166
 
                $title  = T_('Catalog Cleaned');
167
 
                $body   = '';
168
 
                show_confirmation($title,$body,$url);
169
 
                toggle_visible('ajax-loading');
170
 
        break;
171
 
        case 'update_catalog_settings':
172
 
                /* No Demo Here! */
173
 
                if (Config::get('demo_mode')) { break; }
174
 
 
175
 
                /* Update the catalog */
176
 
                Catalog::update_settings($_POST);
177
 
 
178
 
                $url    = Config::get('web_path') . '/admin/catalog.php';
179
 
                $title  = T_('Catalog Updated');
180
 
                $body   = '';
181
 
                show_confirmation($title,$body,$url);
182
 
        break;
183
 
        case 'update_from':
184
 
                if (Config::get('demo_mode')) { break; }
185
 
 
186
 
                // First see if we need to do an add
187
 
                if ($_POST['add_path'] != '/' AND strlen($_POST['add_path'])) {
188
 
                        if ($catalog_id = Catalog::get_from_path($_POST['add_path'])) {
189
 
                                $catalog = new Catalog($catalog_id);
190
 
                                $catalog->run_add(array('subdirectory'=>$_POST['add_path']));
191
 
                        }
192
 
                } // end if add
193
 
 
194
 
                // Now check for an update
195
 
                if ($_POST['update_path'] != '/' AND strlen($_POST['update_path'])) {
196
 
                        if ($catalog_id = Catalog::get_from_path($_POST['update_path'])) {
197
 
                                $songs = Song::get_from_path($_POST['update_path']);
198
 
                                foreach ($songs as $song_id) { Catalog::update_single_item('song',$song_id); }
199
 
                        }
200
 
                } // end if update
201
 
 
202
 
        break;
203
 
        case 'add_catalog':
204
 
                /* Wah Demo! */
205
 
                if (Config::get('demo_mode')) { break; }
206
 
 
207
 
                ob_end_flush();
208
 
 
209
 
                if (!strlen($_POST['path']) || !strlen($_POST['name'])) {
210
 
                        Error::add('general', T_('Error: Name and path not specified'));
211
 
                }
212
 
 
213
 
                if (substr($_POST['path'],0,7) != 'http://' && $_POST['type'] == 'remote') {
214
 
                        Error::add('general', T_('Error: Remote selected, but path is not a URL'));
215
 
                }
216
 
                if ($POST['type'] == 'remote' AND (!strlen($POST['remote_username']) OR !strlen($POST['remote_password']))) {
217
 
                        Error::add('general', T_('Error: Username and Password Required for Remote Catalogs'));
218
 
                }
219
 
 
220
 
                if (!Core::form_verify('add_catalog','post')) {
221
 
                        access_denied();
222
 
                        exit;
223
 
                }
224
 
 
225
 
                // Make sure that there isn't a catalog with a directory above this one
226
 
                if (Catalog::get_from_path($_POST['path'])) {
227
 
                        Error::add('general', T_('Error: Defined Path is inside an existing catalog'));
228
 
                }
229
 
 
230
 
                // If an error hasn't occured
231
 
                if (!Error::occurred()) {
232
 
 
233
 
                        $catalog_id = Catalog::Create($_POST);
234
 
 
235
 
                        if (!$catalog_id) {
236
 
                                require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
237
 
                                break;
238
 
                        }
239
 
 
240
 
                        $catalog = new Catalog($catalog_id);
241
 
 
242
 
                        // Run our initial add
243
 
                        $catalog->run_add($_POST);
244
 
 
245
 
                        show_box_top(T_('Catalog Created'), 'box box_catalog_created');
246
 
                        echo "<h2>" .  T_('Catalog Created') . "</h2>";
247
 
                        Error::display('general');
248
 
                        Error::display('catalog_add');
249
 
                        show_box_bottom();
250
 
 
251
 
                        show_confirmation('','', Config::get('web_path').'/admin/catalog.php');
252
 
 
253
 
                }
254
 
                else {
255
 
                        require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
256
 
                }
257
 
        break;
258
 
        case 'clear_stats':
259
 
                        if (Config::get('demo_mode')) { access_denied(); break; }
260
 
 
261
 
                Catalog::clear_stats();
262
 
                $url    = Config::get('web_path') . '/admin/catalog.php';
263
 
                $title  = T_('Catalog statistics cleared');
264
 
                $body   = '';
265
 
                show_confirmation($title,$body,$url);
266
 
        break;
267
 
        default:
268
 
        case 'show_catalogs':
269
 
                require_once Config::get('prefix') . '/templates/show_manage_catalogs.inc.php';
270
 
        break;
271
 
        case 'show_add_catalog':
272
 
                require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
273
 
        break;
274
 
        case 'clear_now_playing':
275
 
                if (Config::get('demo_mode')) { access_denied(); break; }
276
 
                Stream::clear_now_playing();
277
 
                show_confirmation(T_('Now Playing Cleared'), T_('All now playing data has been cleared'),Config::get('web_path') . '/admin/catalog.php');
278
 
        break;
279
 
        case 'show_disabled':
280
 
                /* Stop the demo hippies */
281
 
                if (conf('demo_mode')) { break; }
282
 
 
283
 
                $songs = $catalog->get_disabled();
284
 
                if (count($songs)) {
285
 
                        require (conf('prefix') . '/templates/show_disabled_songs.inc.php');
286
 
                }
287
 
                else {
288
 
                        echo "<div class=\"error\" align=\"center\">" . T_('No Disabled songs found') . "</div>";
289
 
                }
290
 
        break;
291
 
        case 'show_delete_catalog':
292
 
                /* Stop the demo hippies */
293
 
                if (Config::get('demo_mode')) { access_denied(); break; }
294
 
 
295
 
                $catalog = new Catalog($_REQUEST['catalog_id']);
296
 
                $nexturl = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&amp;catalog_id=' . scrub_out($_REQUEST['catalog_id']);
297
 
                show_confirmation(T_('Delete Catalog'), T_('Do you really want to delete this catalog?') . " -- $catalog->name ($catalog->path)",$nexturl,1);
298
 
        break;
299
 
        case 'show_customize_catalog':
300
 
                $catalog = new Catalog($_REQUEST['catalog_id']);
301
 
                require_once Config::get('prefix') . '/templates/show_edit_catalog.inc.php';
302
 
        break;
303
 
        case 'gather_album_art':
304
 
                toggle_visible('ajax-loading');
305
 
                ob_end_flush();
306
 
 
307
 
                $catalogs = $_REQUEST['catalogs'] ? $_REQUEST['catalogs'] : Catalog::get_catalogs();
308
 
 
309
 
                // Itterate throught the catalogs and gather as needed
310
 
                foreach ($catalogs as $catalog_id) {
311
 
                        $catalog = new Catalog($catalog_id);
312
 
                        require Config::get('prefix') . '/templates/show_gather_art.inc.php';
313
 
                        flush();
314
 
                        $catalog->get_art('',1);
315
 
                }
316
 
                $url    = Config::get('web_path') . '/admin/catalog.php';
317
 
                $title  = T_('Album Art Search Finished');
318
 
                $body   = '';
319
 
                show_confirmation($title,$body,$url);
320
 
        break;
 
34
    case 'fixed':
 
35
        /* Does this use now? */
 
36
        delete_flagged($flag);
 
37
        $type = 'show_flagged_songs';
 
38
        require Config::get('prefix') . '/templates/flag.inc';
 
39
    break;
 
40
    case 'add_to_all_catalogs':
 
41
        $_REQUEST['catalogs'] = Catalog::get_catalogs();
 
42
    case 'add_to_catalog':
 
43
        toggle_visible('ajax-loading');
 
44
        ob_end_flush();
 
45
        if (Config::get('demo_mode')) { break; }
 
46
        if ($_REQUEST['catalogs'] ) {
 
47
            foreach ($_REQUEST['catalogs'] as $catalog_id) {
 
48
                $catalog = new Catalog($catalog_id);
 
49
                $catalog->add_to_catalog();
 
50
            }
 
51
        }
 
52
        $url = Config::get('web_path') . '/admin/catalog.php';
 
53
        $title = T_('Catalog Updated');
 
54
        $body = '';
 
55
        show_confirmation($title, $body, $url);
 
56
        toggle_visible('ajax-loading');
 
57
    break;
 
58
    case 'update_all_catalogs':
 
59
        $_REQUEST['catalogs'] = Catalog::get_catalogs();
 
60
    case 'update_catalog':
 
61
        toggle_visible('ajax-loading');
 
62
        ob_end_flush();
 
63
            /* If they are in demo mode stop here */
 
64
            if (Config::get('demo_mode')) { break; }
 
65
 
 
66
        if (isset($_REQUEST['catalogs'])) {
 
67
            foreach ($_REQUEST['catalogs'] as $catalog_id) {
 
68
                $catalog = new Catalog($catalog_id);
 
69
                $catalog->verify_catalog();
 
70
            }
 
71
        }
 
72
        $url    = Config::get('web_path') . '/admin/catalog.php';
 
73
        $title    = T_('Catalog Updated');
 
74
        $body    = '';
 
75
        show_confirmation($title,$body,$url);
 
76
        toggle_visible('ajax-loading');
 
77
    break;
 
78
    case 'full_service':
 
79
        toggle_visible('ajax-loading');
 
80
        ob_end_flush();
 
81
        /* Make sure they aren't in demo mode */
 
82
        if (Config::get('demo_mode')) { UI::access_denied(); break; }
 
83
 
 
84
        if (!$_REQUEST['catalogs']) {
 
85
            $_REQUEST['catalogs'] = Catalog::get_catalogs();
 
86
        }
 
87
 
 
88
        /* This runs the clean/verify/add in that order */
 
89
        foreach ($_REQUEST['catalogs'] as $catalog_id) {
 
90
            $catalog = new Catalog($catalog_id);
 
91
            $catalog->clean_catalog();
 
92
            $catalog->count = 0;
 
93
            $catalog->verify_catalog();
 
94
            $catalog->count = 0;
 
95
            $catalog->add_to_catalog();
 
96
        }
 
97
        Dba::optimize_tables();
 
98
        $url    = Config::get('web_path') . '/admin/catalog.php';
 
99
        $title    = T_('Catalog Updated');
 
100
        $body    = '';
 
101
        show_confirmation($title,$body,$url);
 
102
        toggle_visible('ajax-loading');
 
103
    break;
 
104
    case 'delete_catalog':
 
105
        /* Make sure they aren't in demo mode */
 
106
            if (Config::get('demo_mode')) { break; }
 
107
 
 
108
        if (!Core::form_verify('delete_catalog')) {
 
109
            UI::access_denied();
 
110
            exit;
 
111
        }
 
112
 
 
113
        /* Delete the sucker, we don't need to check perms as thats done above */
 
114
        Catalog::delete($_GET['catalog_id']);
 
115
        $next_url = Config::get('web_path') . '/admin/catalog.php';
 
116
        show_confirmation(T_('Catalog Deleted'), T_('The Catalog and all associated records have been deleted'),$next_url);
 
117
    break;
 
118
    case 'show_delete_catalog':
 
119
        $catalog_id = scrub_in($_GET['catalog_id']);
 
120
 
 
121
        $next_url = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($catalog_id);
 
122
        show_confirmation(T_('Catalog Delete'), T_('Confirm Deletion Request'),$next_url,1,'delete_catalog');
 
123
    break;
 
124
    case 'remove_disabled':
 
125
        if (Config::get('demo_mode')) { break; }
 
126
 
 
127
        $song = $_REQUEST['song'];
 
128
 
 
129
        if (count($song)) {
 
130
            $catalog->remove_songs($song);
 
131
            $body = T_ngettext('Song Removed', 'Songs Removed', count($song));
 
132
        }
 
133
        else {
 
134
            $body = T_('No Songs Removed');
 
135
        }
 
136
        $url    = Config::get('web_path') . '/admin/catalog.php';
 
137
        $title    = T_ngettext('Disabled Song Processed','Disabled Songs Processed',count($song));
 
138
        show_confirmation($title,$body,$url);
 
139
    break;
 
140
    case 'clean_all_catalogs':
 
141
        $catalog = new Catalog();
 
142
        $_REQUEST['catalogs'] = Catalog::get_catalogs();
 
143
    case 'clean_catalog':
 
144
        toggle_visible('ajax-loading');
 
145
        ob_end_flush();
 
146
            /* If they are in demo mode stop them here */
 
147
            if (Config::get('demo_mode')) { break; }
 
148
 
 
149
        // Make sure they checked something
 
150
        if (isset($_REQUEST['catalogs'])) {
 
151
            foreach($_REQUEST['catalogs'] as $catalog_id) {
 
152
                $catalog = new Catalog($catalog_id);
 
153
                $catalog->clean_catalog();
 
154
            } // end foreach catalogs
 
155
            Dba::optimize_tables();
 
156
        }
 
157
 
 
158
        $url     = Config::get('web_path') . '/admin/catalog.php';
 
159
        $title    = T_('Catalog Cleaned');
 
160
        $body    = '';
 
161
        show_confirmation($title,$body,$url);
 
162
        toggle_visible('ajax-loading');
 
163
    break;
 
164
    case 'update_catalog_settings':
 
165
        /* No Demo Here! */
 
166
        if (Config::get('demo_mode')) { break; }
 
167
 
 
168
        /* Update the catalog */
 
169
        Catalog::update_settings($_POST);
 
170
 
 
171
        $url     = Config::get('web_path') . '/admin/catalog.php';
 
172
        $title     = T_('Catalog Updated');
 
173
        $body    = '';
 
174
        show_confirmation($title,$body,$url);
 
175
    break;
 
176
    case 'update_from':
 
177
        if (Config::get('demo_mode')) { break; }
 
178
 
 
179
        // First see if we need to do an add
 
180
        if ($_POST['add_path'] != '/' AND strlen($_POST['add_path'])) {
 
181
            if ($catalog_id = Catalog::get_from_path($_POST['add_path'])) {
 
182
                $catalog = new Catalog($catalog_id);
 
183
                $catalog->run_add(array('subdirectory'=>$_POST['add_path']));
 
184
            }
 
185
        } // end if add
 
186
 
 
187
        // Now check for an update
 
188
        if ($_POST['update_path'] != '/' AND strlen($_POST['update_path'])) {
 
189
            if ($catalog_id = Catalog::get_from_path($_POST['update_path'])) {
 
190
                $songs = Song::get_from_path($_POST['update_path']);
 
191
                foreach ($songs as $song_id) { Catalog::update_single_item('song',$song_id); }
 
192
            }
 
193
        } // end if update
 
194
 
 
195
    break;
 
196
    case 'add_catalog':
 
197
        /* Wah Demo! */
 
198
        if (Config::get('demo_mode')) { break; }
 
199
 
 
200
        ob_end_flush();
 
201
 
 
202
        if (!strlen($_POST['path']) || !strlen($_POST['name'])) {
 
203
            Error::add('general', T_('Error: Name and path not specified'));
 
204
        }
 
205
 
 
206
        if (substr($_POST['path'],0,7) != 'http://' && $_POST['type'] == 'remote') {
 
207
            Error::add('general', T_('Error: Remote selected, but path is not a URL'));
 
208
        }
 
209
        if ($POST['type'] == 'remote' AND (!strlen($POST['remote_username']) OR !strlen($POST['remote_password']))) {
 
210
            Error::add('general', T_('Error: Username and Password Required for Remote Catalogs'));
 
211
        }
 
212
 
 
213
        if (!Core::form_verify('add_catalog','post')) {
 
214
            UI::access_denied();
 
215
            exit;
 
216
        }
 
217
 
 
218
        // Make sure that there isn't a catalog with a directory above this one
 
219
        if (Catalog::get_from_path($_POST['path'])) {
 
220
            Error::add('general', T_('Error: Defined Path is inside an existing catalog'));
 
221
        }
 
222
 
 
223
        // If an error hasn't occured
 
224
        if (!Error::occurred()) {
 
225
 
 
226
            $catalog_id = Catalog::create($_POST);
 
227
 
 
228
            if (!$catalog_id) {
 
229
                require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
 
230
                break;
 
231
            }
 
232
 
 
233
            $catalog = new Catalog($catalog_id);
 
234
 
 
235
            // Run our initial add
 
236
            $catalog->run_add($_POST);
 
237
 
 
238
            UI::show_box_top(T_('Catalog Created'), 'box box_catalog_created');
 
239
            echo "<h2>" .  T_('Catalog Created') . "</h2>";
 
240
            Error::display('general');
 
241
            Error::display('catalog_add');
 
242
            UI::show_box_bottom();
 
243
 
 
244
            show_confirmation('','', Config::get('web_path').'/admin/catalog.php');
 
245
 
 
246
        }
 
247
        else {
 
248
            require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
 
249
        }
 
250
    break;
 
251
    case 'clear_stats':
 
252
        if (Config::get('demo_mode')) { UI::access_denied(); break; }
 
253
        Stats::clear();
 
254
        $url    = Config::get('web_path') . '/admin/catalog.php';
 
255
        $title    = T_('Catalog statistics cleared');
 
256
        $body    = '';
 
257
        show_confirmation($title, $body, $url);
 
258
    break;
 
259
    default:
 
260
    case 'show_catalogs':
 
261
        require_once Config::get('prefix') . '/templates/show_manage_catalogs.inc.php';
 
262
    break;
 
263
    case 'show_add_catalog':
 
264
        require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
 
265
    break;
 
266
    case 'clear_now_playing':
 
267
        if (Config::get('demo_mode')) { UI::access_denied(); break; }
 
268
        Stream::clear_now_playing();
 
269
        show_confirmation(T_('Now Playing Cleared'), T_('All now playing data has been cleared'),Config::get('web_path') . '/admin/catalog.php');
 
270
    break;
 
271
    case 'show_disabled':
 
272
        /* Stop the demo hippies */
 
273
        if (Config::get('demo_mode')) { break; }
 
274
 
 
275
        $songs = Song::get_disabled();
 
276
        if (count($songs)) {
 
277
            require Config::get('prefix') . '/templates/show_disabled_songs.inc.php';
 
278
        }
 
279
        else {
 
280
            echo "<div class=\"error\" align=\"center\">" . T_('No Disabled songs found') . "</div>";
 
281
        }
 
282
    break;
 
283
    case 'show_delete_catalog':
 
284
        /* Stop the demo hippies */
 
285
        if (Config::get('demo_mode')) { UI::access_denied(); break; }
 
286
 
 
287
        $catalog = new Catalog($_REQUEST['catalog_id']);
 
288
        $nexturl = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&amp;catalog_id=' . scrub_out($_REQUEST['catalog_id']);
 
289
        show_confirmation(T_('Delete Catalog'), T_('Do you really want to delete this catalog?') . " -- $catalog->name ($catalog->path)",$nexturl,1);
 
290
    break;
 
291
    case 'show_customize_catalog':
 
292
        $catalog = new Catalog($_REQUEST['catalog_id']);
 
293
        require_once Config::get('prefix') . '/templates/show_edit_catalog.inc.php';
 
294
    break;
 
295
    case 'gather_album_art':
 
296
        toggle_visible('ajax-loading');
 
297
        ob_end_flush();
 
298
 
 
299
        $catalogs = $_REQUEST['catalogs'] ? $_REQUEST['catalogs'] : Catalog::get_catalogs();
 
300
 
 
301
        // Iterate throught the catalogs and gather as needed
 
302
        foreach ($catalogs as $catalog_id) {
 
303
            $catalog = new Catalog($catalog_id);
 
304
            require Config::get('prefix') . '/templates/show_gather_art.inc.php';
 
305
            flush();
 
306
            $catalog->gather_art();
 
307
        }
 
308
        $url     = Config::get('web_path') . '/admin/catalog.php';
 
309
        $title     = T_('Album Art Search Finished');
 
310
        $body    = '';
 
311
        show_confirmation($title,$body,$url);
 
312
    break;
321
313
} // end switch
322
314
 
323
315
/* Show the Footer */
324
 
show_footer();
 
316
UI::show_footer();
325
317
 
326
318
?>