From 5730ee7803e19265f71c479ab9175b3badd55a82 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Mon, 20 Mar 2006 19:12:49 +0000 Subject: more catalog fun! --- lib/class/catalog.class.php | 84 ++++++++++++++++++++++++++++++++------------- lib/ui.lib.php | 2 +- 2 files changed, 61 insertions(+), 25 deletions(-) (limited to 'lib') diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index fc78971d..171e7745 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -107,6 +107,22 @@ class Catalog { } // get_catalogs + /** + * get_catalog_ids + * This returns an array of all catalog ids + */ + function get_catalog_ids() { + + $sql = "SELECT id FROM catalog"; + $db_results = mysql_query($sql, dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $results[] = $r['id']; + } + + return $results; + + } // get_catalog_ids /*! @function get_catalog_stats @@ -382,7 +398,7 @@ class Catalog { $this->count++; if ( !($this->count%conf('catalog_echo_count')) ) { echo "\n"; flush(); } //echos song count @@ -474,7 +490,9 @@ class Catalog { /* Stupid little cutesie thing */ $search_count++; if ( !($search_count%conf('catalog_echo_count')) ) { - echo _("Searched") . " $search_count. . . .
\n"; + echo "\n"; flush(); } //echos song count @@ -701,6 +719,25 @@ class Catalog { } // update_last_add + /** + * update_settings + * This function updates the basic setting of the catalog + */ + function update_settings($data) { + + $id = sql_escape($data['catalog_id']); + $name = sql_escape($data['name']); + $id3cmd = sql_escape($data['id3cmd']); + $rename = sql_escape($data['rename_pattern']); + $sort = sql_escape($data['sort_pattern']); + + $sql = "UPDATE catalog SET name='$name', id3_set_command='$id3cmd', rename_pattern='$rename', " . + "sort_pattern='$sort' WHERE id = '$id'"; + $db_results = mysql_query($sql, dbh()); + + return true; + + } // update_settings /** * new_catalog @@ -764,6 +801,7 @@ class Catalog { /* Now Adding Album Art? */ if ($gather_art) { echo "
\n" . _("Starting Album Art Search") . ". . .
\n"; + echo _('Searched') . ": id . "\">" . _('None') . ""; flush(); $this->get_album_art(0,$art); } // if we want to gather album art @@ -906,7 +944,7 @@ class Catalog { return true; } - echo _('Found') . ": " . _('None') . "
\n"; + echo _('Found') . ": id ."\">" . _('None') . "
\n"; flush(); /* Set the Start time */ @@ -931,6 +969,7 @@ class Catalog { if ($type != 'fast_add') { if ($verbose) { echo "\n" . _('Starting Album Art Search') . ". . .
\n"; + echo _('Searched') . ": id . "\">" . _('None') . ""; flush(); } $this->get_album_art(); @@ -1139,7 +1178,7 @@ class Catalog { if ($verbose) { echo "\n" . _('Cleaning the') . " [" . $this->name . "] " . _('Catalog') . "...
\n"; - echo _('Checking') . ": \n
"; + echo _('Checking') . ": id . "\">\n
"; flush(); } @@ -1157,7 +1196,7 @@ class Catalog { $this->count++; if ( !($this->count%conf('catalog_echo_count')) && $verbose) { echo "\n"; flush(); } //echos song count @@ -1485,7 +1524,7 @@ class Catalog { if ($verbose) { echo _("Updating the") . " [ $this->name ] " . _("Catalog") . "
\n"; echo $number . " " . _("songs found checking tag information.") . "
\n\n"; - echo _('Verifed') . ": None
\n"; + echo _('Verifed') . ": id . "\">None
\n"; flush(); } @@ -1502,7 +1541,7 @@ class Catalog { /* Create the object from the existing database information */ $song = new Song($results->id); - if (conf('debug')) { log_event($_SESSION['userdata']['username'],' verify ',"Starting work on $song->file",'ampache-catalog'); } + debug_event('verify',"Starting work on $song->file",'5','ampache-catalog'); if (is_readable($song->file)) { unset($skip); @@ -1537,11 +1576,11 @@ class Catalog { $found = $album->get_art(); unset($album); if ($found) { $is_found = _(" FOUND"); } - echo "
" . _("Searching for new Album Art") . ". . .$is_found
\n"; + echo "
" . _('Searching for new Album Art') . ". . .$is_found
\n"; unset($found,$is_found); } elseif (isset($searched_albums[$album_id])) { - echo "
" . _("Album Art Already Found") . ". . .
\n"; + echo "
" . _('Album Art Already Found') . ". . .
\n"; } echo "\t\n\n
\n"; flush(); @@ -1553,14 +1592,14 @@ class Catalog { } // end skip if ($skip) { - if (conf('debug')) { log_event($_SESSION['userdata']['username'],' skip ',"$song->file has been skipped due to newer local update or file mod time",'ampache-catalog'); } + debug_event('skip',"$song->file has been skipped due to newer local update or file mod time",'5','ampache-catalog'); } /* Stupid little cutesie thing */ $this->count++; - if ( !($this->count%conf('catalog_echo_count')) ) { + if (!($this->count%conf('catalog_echo_count')) ) { echo "\n"; flush(); } //echos song count @@ -1570,17 +1609,13 @@ class Catalog { else { echo "
\n
  • "; echo "$song->file does not exist or is not readable\n"; - echo "
  • \n
    \n
    \n"; - - if (conf('debug')) { log_event($_SESSION['userdata']['username'],' read-error ',"$song->file does not exist or is not readable",'ampache-catalog'); } + echo "\n\n
    \n"; - // Should we remove it from catalog? + debug_event('read-error',"$song->file does not exist or is not readable",'5','ampache-catalog'); } - } //end foreach - /* After we have updated all the songs with the new information clear any empty albums/artists */ $this->clean_albums(); $this->clean_artists(); @@ -1590,7 +1625,7 @@ class Catalog { // Update the last_update $this->update_last_update(); - echo "Update Finished. Checked $this->count. $total_updated songs updated.

    "; + echo _('Update Finished.') . _('Checked') . " $this->count. $total_updated " . _('songs updated.') . "

    "; $this->count = 0; @@ -1717,7 +1752,7 @@ class Catalog { if ($artist_count == $cache_limit) { $this->artists = array_slice($this->artists,1); } - if (conf('debug')) { log_event($_SESSION['userdata']['username'],'cache',"Adding $artist with $artist_id to Cache",'ampache-catalog'); } + debug_event('cache',"Adding $artist with $artist_id to Cache",'5','ampache-catalog'); $array = array($artist => $artist_id); $this->artists = array_merge($this->artists, $array); unset($array); @@ -1919,7 +1954,7 @@ class Catalog { $db_results = mysql_query($sql, dbh()); if (!$db_results) { - if (conf('debug')) { log_event($_SESSION['userdata']['username'],'insert',"Unable to insert $file -- $sql",'ampache-catalog'); } + debug_event('insert',"Unable to insert $file -- $sql",'5','ampache-catalog'); echo "Error Adding $file
    $sql
    "; flush(); } @@ -1948,7 +1983,7 @@ class Catalog { $db_results = mysql_query($sql, dbh()); if (!$db_results) { - if (conf('debug')) { log_event($_SESSION['userdata']['username'],'insert',"Unable to Add Remote $url -- $sql",'ampache-catalog'); } + debug_event('insert',"Unable to Add Remote $url -- $sql",'5','ampache-catalog'); echo "Error Adding Remote $url
    $sql
    \n"; flush(); } @@ -1998,7 +2033,7 @@ class Catalog { $db_results = mysql_query($sql, dbh()); //If it's found then return true - if (@mysql_fetch_row($db_results)) { + if (mysql_fetch_row($db_results)) { return true; } @@ -2035,7 +2070,7 @@ class Catalog { } // end foreach line - if (conf('debug')) { log_event($GLOBALS['user']->username,'m3u_parse',"Parsing $filename - Found: " . count($songs) . " Songs"); } + debug_event('m3u_parse',"Parsing $filename - Found: " . count($songs) . " Songs",'5'); if (count($songs)) { $playlist = new Playlist(); @@ -2143,6 +2178,7 @@ class Catalog { $this->clean_stats(); $this->clean_playlists(); $this->clean_flagged(); + $this->clean_genre(); } // delete_catalog diff --git a/lib/ui.lib.php b/lib/ui.lib.php index fc200ee7..dec697ae 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -272,7 +272,7 @@ function return_referer() { /* Strip off the filename */ $referer = substr($referer,0,strlen($referer)-strlen($file)); - + if (substr($referer,strlen($referer)-6,6) == 'admin/') { $file = 'admin/' . $file; } -- cgit