summaryrefslogtreecommitdiffstats
path: root/admin/catalog.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-03-20 01:55:03 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-03-20 01:55:03 +0000
commiteda7fd335cc4bea64a637c5d3bcdd1d1f3fd0d94 (patch)
treee18c1c233bf14c2a9c57640c4e694d9365f84473 /admin/catalog.php
parentb99e8307ac784e046d21d346c845f896a5b4317d (diff)
downloadampache-eda7fd335cc4bea64a637c5d3bcdd1d1f3fd0d94.tar.gz
ampache-eda7fd335cc4bea64a637c5d3bcdd1d1f3fd0d94.tar.bz2
ampache-eda7fd335cc4bea64a637c5d3bcdd1d1f3fd0d94.zip
catalog clean up and admin index changes
Diffstat (limited to 'admin/catalog.php')
-rw-r--r--admin/catalog.php401
1 files changed, 193 insertions, 208 deletions
diff --git a/admin/catalog.php b/admin/catalog.php
index 7716a0b4..c6d7f322 100644
--- a/admin/catalog.php
+++ b/admin/catalog.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright (c) 2001 - 2005 Ampache.org
+ Copyright (c) 2001 - 2006 Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
@@ -28,7 +28,7 @@
require('../modules/init.php');
-if (!$user->has_access(100)) {
+if (!$GLOBALS['user']->has_access(100)) {
access_denied();
}
@@ -40,244 +40,229 @@ show_template('header');
/* Big switch statement to handle various actions */
switch ($_REQUEST['action']) {
- case 'fixed':
- delete_flagged($flag);
- $type = 'show_flagged_songs';
- include(conf('prefix') . '/templates/flag.inc');
+ case 'fixed':
+ delete_flagged($flag);
+ $type = 'show_flagged_songs';
+ include(conf('prefix') . '/templates/flag.inc');
break;
-
- case _("Add to Catalog(s)"):
- if (conf('demo_mode')) { break; }
- if ($_REQUEST['catalogs'] ) {
- foreach ($_REQUEST['catalogs'] as $catalog_id) {
- $catalog = new Catalog($catalog_id);
- $catalog->add_to_catalog($_REQUEST['update_type']);
- }
- }
- include(conf('prefix') . '/templates/catalog.inc');
+ case _("Add to Catalog(s)"):
+ case 'add_to_catalog':
+ if (conf('demo_mode')) { break; }
+ if ($_REQUEST['catalogs'] ) {
+ foreach ($_REQUEST['catalogs'] as $catalog_id) {
+ $catalog = new Catalog($catalog_id);
+ $catalog->add_to_catalog($_REQUEST['update_type']);
+ }
+ }
+ include(conf('prefix') . '/templates/catalog.inc');
break;
-
- case _("Add to all Catalogs"):
- if (conf('demo_mode')) { break; }
+ case _("Add to all Catalogs"):
+ if (conf('demo_mode')) { break; }
- /* If they are using the file MPD type, and it's currently enabled lets do a DBRefresh for em */
- if (conf('mpd_method') == 'file' AND conf('allow_mpd_playback')) {
- // Connect to the MPD
- if (!class_exists('mpd')) { require_once(conf('prefix') . "/modules/mpd/mpd.class.php"); }
- if (!is_object($myMpd)) { $myMpd = new mpd(conf('mpd_host'),conf('mpd_port')); }
- if (!$myMpd->connected) {
- echo "<font class=\"error\">" . _("Error Connecting") . ": " . $myMpd->errStr . "</font>\n";
- log_event($_SESSION['userdata']['username'],' connection_failed ',"Error: Unable able to connect to MPD, " . $myMpd->errStr);
- } // MPD connect failed
-
+ /* If they are using the file MPD type, and it's currently enabled lets do a DBRefresh for em */
+ if (conf('mpd_method') == 'file' AND conf('allow_mpd_playback')) {
+ // Connect to the MPD
+ if (!class_exists('mpd')) { require_once(conf('prefix') . "/modules/mpd/mpd.class.php"); }
+ if (!is_object($myMpd)) { $myMpd = new mpd(conf('mpd_host'),conf('mpd_port')); }
+ if (!$myMpd->connected) {
+ echo "<font class=\"error\">" . _("Error Connecting") . ": " . $myMpd->errStr . "</font>\n";
+ log_event($_SESSION['userdata']['username'],' connection_failed ',"Error: Unable able to connect to MPD, " . $myMpd->errStr);
+ } // MPD connect failed
+
$myMpd->DBRefresh();
- } // if MPD enabled
- $catalogs = $catalog->get_catalogs();
+ } // if MPD enabled
+ $catalogs = $catalog->get_catalogs();
- foreach ($catalogs as $data) {
- $data->add_to_catalog($_REQUEST['update_type']);
- }
- include(conf('prefix') . '/templates/catalog.inc');
+ foreach ($catalogs as $data) {
+ $data->add_to_catalog($_REQUEST['update_type']);
+ }
+ include(conf('prefix') . '/templates/catalog.inc');
break;
-
- case _("Update Catalog(s)"):
- if (conf('demo_mode')) { break; }
- if (isset($_REQUEST['catalogs'])) {
- foreach ($_REQUEST['catalogs'] as $catalog_id) {
- $catalog = new Catalog($catalog_id);
- $catalog->verify_catalog($catalog_id->id,$_REQUEST['update_type']);
+ case _("Update Catalog(s)"):
+ case 'update_catalog':
+ /* If they are in demo mode stop here */
+ if (conf('demo_mode')) { break; }
+
+ if (isset($_REQUEST['catalogs'])) {
+ foreach ($_REQUEST['catalogs'] as $catalog_id) {
+ $catalog = new Catalog($catalog_id);
+ $catalog->verify_catalog($catalog_id->id,$_REQUEST['update_type']);
+ }
}
- }
- include(conf('prefix') . '/templates/catalog.inc');
+ include(conf('prefix') . '/templates/catalog.inc');
break;
+ case _("Update All Catalogs"):
+ if (conf('demo_mode')) { break; }
+ $catalogs = $catalog->get_catalogs();
- case _("Update All Catalogs"):
- if (conf('demo_mode')) { break; }
- $catalogs = $catalog->get_catalogs();
-
- foreach ($catalogs as $data) {
- $data->verify_catalog($data->id,$_REQUEST['update_type']);
- }
- include(conf('prefix') . '/templates/catalog.inc');
+ foreach ($catalogs as $data) {
+ $data->verify_catalog($data->id,$_REQUEST['update_type']);
+ }
+ include(conf('prefix') . '/templates/catalog.inc');
break;
+ case 'full_service':
+ /* Make sure they aren't in demo mode */
+ if (conf('demo_mode')) { break; }
- case 'delete_catalog':
- if (conf('demo_mode')) { break; }
- if ($_REQUEST['confirm'] === 'Yes') {
- $catalog = new Catalog($_REQUEST['catalog_id']);
- $catalog->delete_catalog();
- }
- include(conf('prefix') . '/templates/catalog.inc');
+ /* This runs the clean/verify/add in that order */
+ foreach ($_REQUEST['catalogs'] as $catalog_id) {
+ $catalog = new Catalog($catalog_id);
+ $catalog->clean_catalog();
+ $catalog->count = 0;
+ $catalog->update_catalog();
+ $catalog->count = 0;
+ $catalog->add_to_catalog();
+ }
break;
-
- case 'remove_disabled':
- if (conf('demo_mode')) { break; }
- $song = $_REQUEST['song'];
- if (count($song)) {
- $catalog->remove_songs($song);
- echo "<p align=\"center\">Songs Removed... </p>";
- }
- else {
- echo "<p align=\"center\">No Songs Removed... </p>";
- }
- include(conf('prefix') . '/templates/catalog.inc');
+ case 'delete_catalog':
+ if (conf('demo_mode')) { break; }
+ if ($_REQUEST['confirm'] === 'Yes') {
+ $catalog = new Catalog($_REQUEST['catalog_id']);
+ $catalog->delete_catalog();
+ }
+ include(conf('prefix') . '/templates/catalog.inc');
break;
-
- case _("Clean Catalog(s)"):
- if (conf('demo_mode')) { break; }
-
- // Make sure they checked something
- if (isset($_REQUEST['catalogs'])) {
- foreach($_REQUEST['catalogs'] as $catalog_id) {
- $catalog = new Catalog($catalog_id);
- $catalog->clean_catalog(0,$_REQUEST['update_type']);
- } // end foreach catalogs
- }
- include(conf('prefix') . '/templates/catalog.inc');
+ case 'remove_disabled':
+ if (conf('demo_mode')) { break; }
+ $song = $_REQUEST['song'];
+ if (count($song)) {
+ $catalog->remove_songs($song);
+ echo "<p align=\"center\">Songs Removed... </p>";
+ }
+ else {
+ echo "<p align=\"center\">No Songs Removed... </p>";
+ }
+ include(conf('prefix') . '/templates/catalog.inc');
break;
- case 'update_catalog_settings':
- if (conf('demo_mode')) { break; }
- $id = strip_tags($_REQUEST['catalog_id']);
- $name = strip_tags($_REQUEST['name']);
- $id3cmd = strip_tags($_REQUEST['id3_set_command']);
- $rename = strip_tags($_REQUEST['rename_pattern']);
- $sort = strip_tags($_REQUEST['sort_pattern']);
- /* Setup SQL */
- $sql = "UPDATE catalog SET " .
- " name = '$name'," .
- " id3_set_command = '$id3cmd'," .
- " rename_pattern = '$rename'," .
- " sort_pattern = '$sort'" .
- " WHERE id = '$id'";
- $result = mysql_query($sql, dbh());
- include(conf('prefix') . '/templates/catalog.inc');
+ case _('Clean Catalog(s)'):
+ case 'clean_catalog':
+ /* If they are in demo mode stop them here */
+ if (conf('demo_mode')) { break; }
+
+ // Make sure they checked something
+ if (isset($_REQUEST['catalogs'])) {
+ foreach($_REQUEST['catalogs'] as $catalog_id) {
+ $catalog = new Catalog($catalog_id);
+ $catalog->clean_catalog(0,1);
+ } // end foreach catalogs
+ }
+ include(conf('prefix') . '/templates/catalog.inc');
break;
-
- case _("Clean All Catalogs"):
- if (conf('demo_mode')) { break; }
- $catalogs = $catalog->get_catalogs();
- $dead_files = array();
-
- foreach ($catalogs as $catalog) {
- $catalog->clean_catalog(0,$_REQUEST['update_type']);
- }
-
- include(conf('prefix') . '/templates/catalog.inc');
+ case 'update_catalog_settings':
+ if (conf('demo_mode')) { break; }
+ $id = strip_tags($_REQUEST['catalog_id']);
+ $name = strip_tags($_REQUEST['name']);
+ $id3cmd = strip_tags($_REQUEST['id3_set_command']);
+ $rename = strip_tags($_REQUEST['rename_pattern']);
+ $sort = strip_tags($_REQUEST['sort_pattern']);
+ /* Setup SQL */
+ $sql = "UPDATE catalog SET " .
+ " name = '$name'," .
+ " id3_set_command = '$id3cmd'," .
+ " rename_pattern = '$rename'," .
+ " sort_pattern = '$sort'" .
+ " WHERE id = '$id'";
+ $result = mysql_query($sql, dbh());
+ include(conf('prefix') . '/templates/catalog.inc');
break;
- case 'add_catalog':
- if (conf('demo_mode')) { break; }
- if ($_REQUEST['path'] AND $_REQUEST['name']) {
- /* Throw all of the album art types into an array */
- $art = array('id3'=>$_REQUEST['art_id3v2'],'amazon'=>$_REQUEST['art_amazon'],'folder'=>$_REQUEST['art_folder']);
- /* Create the Catalog */
- $catalog->new_catalog($_REQUEST['path'],
- $_REQUEST['name'],
- $_REQUEST['id3set_command'],
- $_REQUEST['rename_pattern'],
- $_REQUEST['sort_pattern'],
- $_REQUEST['type'],
- $_REQUEST['gather_art'],
- $_REQUEST['parse_m3u'],
- $art);
+ case _("Clean All Catalogs"):
+ if (conf('demo_mode')) { break; }
+ $catalogs = $catalog->get_catalogs();
+ $dead_files = array();
+
+ foreach ($catalogs as $catalog) {
+ $catalog->clean_catalog(0,$_REQUEST['update_type']);
+ }
+
include(conf('prefix') . '/templates/catalog.inc');
- }
- else {
- $error = "Please complete the form.";
- include(conf('prefix') . '/templates/add_catalog.inc');
- }
break;
-
- case 'really_clear_stats':
-
- if (conf('demo_mode')) { break; }
- if ($_REQUEST['confirm'] == 'Yes') {
- clear_catalog_stats();
- }
- include(conf('prefix') . '/templates/catalog.inc');
+ case 'add_catalog':
+ if (conf('demo_mode')) { break; }
+ if ($_REQUEST['path'] AND $_REQUEST['name']) {
+ /* Throw all of the album art types into an array */
+ $art = array('id3'=>$_REQUEST['art_id3v2'],'amazon'=>$_REQUEST['art_amazon'],'folder'=>$_REQUEST['art_folder']);
+ /* Create the Catalog */
+ $catalog->new_catalog($_REQUEST['path'],
+ $_REQUEST['name'],
+ $_REQUEST['id3set_command'],
+ $_REQUEST['rename_pattern'],
+ $_REQUEST['sort_pattern'],
+ $_REQUEST['type'],
+ $_REQUEST['gather_art'],
+ $_REQUEST['parse_m3u'],
+ $art);
+ include(conf('prefix') . '/templates/catalog.inc');
+ }
+ else {
+ $error = "Please complete the form.";
+ include(conf('prefix') . '/templates/add_catalog.inc');
+ }
break;
-
- case 'show_add_catalog':
- include(conf('prefix') . '/templates/add_catalog.inc');
+ case 'really_clear_stats':
+ if (conf('demo_mode')) { break; }
+ if ($_REQUEST['confirm'] == 'Yes') {
+ clear_catalog_stats();
+ }
+ include(conf('prefix') . '/templates/catalog.inc');
break;
-
- case 'clear_now_playing':
- if (conf('demo_mode')) { break; }
- clear_now_playing();
- show_confirmation(_("Now Playing Cleared"),_("All now playing data has been cleared"),"/admin/catalog.php");
-
+ case 'show_add_catalog':
+ include(conf('prefix') . '/templates/add_catalog.inc');
break;
- case 'Clear Catalog':
- if (conf('demo_mode')) { break; }
- show_confirm_action(_("Do you really want to clear your catalog?"),
- "admin/catalog.php", "action=really_clear_catalog");
- print("<hr />\n");
+ case 'clear_now_playing':
+ if (conf('demo_mode')) { break; }
+ clear_now_playing();
+ show_confirmation(_("Now Playing Cleared"),_("All now playing data has been cleared"),"/admin/catalog.php");
break;
-
- case 'clear_stats':
- if (conf('demo_mode')) { break; }
- show_confirm_action(_("Do you really want to clear the statistics for this catalog?"),
- "admin/catalog.php", "action=really_clear_stats");
+ case 'Clear Catalog':
+ if (conf('demo_mode')) { break; }
+ show_confirm_action(_("Do you really want to clear your catalog?"),
+ "admin/catalog.php", "action=really_clear_catalog");
+ print("<hr />\n");
break;
-
- case 'show_disabled':
- if (conf('demo_mode')) { break; }
- $songs = $catalog->get_disabled();
- if (count($songs)) {
- require (conf('prefix') . '/templates/show_disabled_songs.inc');
- }
- else {
- echo "<p class=\"error\" align=\"center\">No Disabled songs found</p>";
- }
+ case 'clear_stats':
+ if (conf('demo_mode')) { break; }
+ show_confirm_action(_("Do you really want to clear the statistics for this catalog?"),
+ "admin/catalog.php", "action=really_clear_stats");
break;
-
- case 'show_delete_catalog':
- if (conf('demo_mode')) { break; }
- show_confirm_action(_("Do you really want to delete this catalog?"),
- "admin/catalog.php",
- "catalog_id=" . $_REQUEST['catalog_id'] . "&amp;action=delete_catalog");
+ case 'show_disabled':
+ if (conf('demo_mode')) { break; }
+ $songs = $catalog->get_disabled();
+ if (count($songs)) {
+ require (conf('prefix') . '/templates/show_disabled_songs.inc');
+ }
+ else {
+ echo "<p class=\"error\" align=\"center\">No Disabled songs found</p>";
+ }
break;
-
- case 'show_flagged_songs':
- if (conf('demo_mode')) { break; }
- $type = $_REQUEST['action'];
- include (conf('prefix') . '/templates/flag.inc');
+ case 'show_delete_catalog':
+ if (conf('demo_mode')) { break; }
+ show_confirm_action(_("Do you really want to delete this catalog?"),
+ "admin/catalog.php",
+ "catalog_id=" . $_REQUEST['catalog_id'] . "&amp;action=delete_catalog");
break;
-
- case 'Update Flags':
- if (conf('demo_mode')) { break; }
- echo "<pre>";
- print_r($_REQUEST);
- echo "</pre>";
+ case 'show_flagged_songs':
+ if (conf('demo_mode')) { break; }
+ $type = $_REQUEST['action'];
+ include (conf('prefix') . '/templates/flag.inc');
break;
-
- case 'show_customize_catalog':
- include(conf('prefix') . '/templates/customize_catalog.inc');
+ case 'show_customize_catalog':
+ include(conf('prefix') . '/templates/customize_catalog.inc');
break;
- case 'gather_album_art':
+ case 'gather_album_art':
+ echo "<b>" . _("Starting Album Art Search") . ". . .</b><br /><br />\n";
+ flush();
- echo "<b>" . _("Starting Album Art Search") . ". . .</b><br /><br />\n";
- flush();
-
- $catalogs = $catalog->get_catalogs();
- foreach ($catalogs as $data) {
- $data->get_album_art();
- }
+ $catalogs = $catalog->get_catalogs();
+ foreach ($catalogs as $data) {
+ $data->get_album_art();
+ }
- echo "<b>" . _("Album Art Search Finished") . ". . .</b><br />\n";
+ echo "<b>" . _("Album Art Search Finished") . ". . .</b><br />\n";
break;
- // (Added by Cucumber 20050216)
- case 'dump_album_art':
- $catalogs = $catalog->get_catalogs();
-
- foreach ($catalogs as $data) {
- $data->dump_album_art();
- }
- break;
-
- default:
- include(conf('prefix') . '/templates/catalog.inc');
-
+ default:
+ include(conf('prefix') . '/templates/catalog.inc');
+ break;
} // end switch
/* Show the Footer */