summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-07-02 04:57:56 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-07-02 04:57:56 +0000
commit9457b75fb16f05347c08b484db6fe2b848efba15 (patch)
tree18245ab1b8a2fc7953c9fc04e541d46791737ec8
parentd54efca7bd1ee28683506b452f58742f8a8f678f (diff)
downloadampache-9457b75fb16f05347c08b484db6fe2b848efba15.tar.gz
ampache-9457b75fb16f05347c08b484db6fe2b848efba15.tar.bz2
ampache-9457b75fb16f05347c08b484db6fe2b848efba15.zip
fixed some catalog update issues, fixed some genre pages and made the sql sort stuff for show songs work
-rw-r--r--admin/catalog.php22
-rw-r--r--genre.php11
-rw-r--r--lib/class/artist.class.php12
-rw-r--r--lib/class/browse.class.php29
-rw-r--r--lib/class/catalog.class.php35
-rw-r--r--lib/class/genre.class.php12
-rw-r--r--lib/class/user.class.php2
-rw-r--r--lib/general.lib.php21
-rw-r--r--modules/vauth/session.lib.php1
-rw-r--r--templates/show_songs.inc.php2
10 files changed, 65 insertions, 82 deletions
diff --git a/admin/catalog.php b/admin/catalog.php
index f987c289..8c29fa9c 100644
--- a/admin/catalog.php
+++ b/admin/catalog.php
@@ -145,13 +145,12 @@ switch ($_REQUEST['action']) {
break;
case 'update_catalog_settings':
/* No Demo Here! */
- if (conf('demo_mode')) { break; }
+ if (Config::get('demo_mode')) { break; }
/* Update the catalog */
- $catalog = new Catalog();
- $catalog->update_settings($_REQUEST);
+ Catalog::update_settings($_REQUEST);
- $url = conf('web_path') . '/admin/index.php';
+ $url = Config::get('web_path') . '/admin/index.php';
$title = _('Catalog Updated');
$body = '';
show_confirmation($title,$body,$url);
@@ -198,10 +197,10 @@ switch ($_REQUEST['action']) {
}
break;
case 'clear_stats':
- if (conf('demo_mode')) { break; }
+ if (Config::get('demo_mode')) { break; }
- clear_catalog_stats();
- $url = conf('web_path') . '/admin/index.php';
+ Catalog::clear_stats();
+ $url = Config::get('web_path') . '/admin/index.php';
$title = _('Catalog statistics cleared');
$body = '';
show_confirmation($title,$body,$url);
@@ -214,15 +213,6 @@ switch ($_REQUEST['action']) {
clear_now_playing();
show_confirmation(_('Now Playing Cleared'),_('All now playing data has been cleared'),Config::get('web_path') . '/admin/index.php');
break;
- case 'show_clear_stats':
- /* Demo Bad! */
- if (conf('demo_mode')) { break; }
-
- $url = conf('web_path') . '/admin/catalog.php?action=clear_stats';
- $body = _('Do you really want to clear the statistics for this catalog?');
- $title = _('Clear Catalog Stats');
- show_confirmation($title,$body,$url,1);
- break;
case 'show_disabled':
if (conf('demo_mode')) { break; }
diff --git a/genre.php b/genre.php
index 20ce70ae..de8d1262 100644
--- a/genre.php
+++ b/genre.php
@@ -34,7 +34,10 @@ switch($_REQUEST['action']) {
case 'show_songs':
$genre = new Genre($_REQUEST['genre_id']);
show_genre($_REQUEST['genre_id']);
- $songs = $genre->get_songs();
+ $object_ids = $genre->get_songs();
+ show_box_top(_('Songs'));
+ require_once Config::get('prefix') . '/templates/show_songs.inc.php';
+ show_box_bottom();
break;
case 'show_genre':
default:
@@ -49,8 +52,10 @@ switch($_REQUEST['action']) {
case 'show_artists':
$genre = new Genre($_REQUEST['genre_id']);
show_genre($_REQUEST['genre_id']);
- $artists = $genre->get_artists();
- require (conf('prefix') . '/templates/show_artists.inc');
+ $object_ids = $genre->get_artists();
+ show_box_top(_('Artists'));
+ require_once Config::get('prefix') . '/templates/show_artists.inc.php';
+ show_box_bottom();
break;
} // action
diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php
index 7de2f62d..eb18b539 100644
--- a/lib/class/artist.class.php
+++ b/lib/class/artist.class.php
@@ -189,8 +189,6 @@ class Artist {
//FIXME: This shouldn't be scrubing right here!!!!
$this->full_name = scrub_out(trim($this->prefix . " " . $this->name));
- //FIXME: This should be f_link
-
$this->f_name_link = "<a href=\"" . Config::get('web_path') . "/artists.php?action=show&amp;artist=" . $this->id . "\" title=\"" . $this->full_name . "\">" . $name . "</a>";
// Get the counts
@@ -200,16 +198,6 @@ class Artist {
} // format
- /**
- * format_artist
- * DEFUNCT, do not use anymore
- */
- function format_artist() {
-
- $this->format();
-
- } // format_artist
-
/*!
@function rename
@discussion changes the name of the artist in the db,
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php
index c5258c0c..b4c2361a 100644
--- a/lib/class/browse.class.php
+++ b/lib/class/browse.class.php
@@ -107,7 +107,12 @@ class Browse {
if ($_SESSION['browse']['type'] == 'song') {
switch ($sort) {
case'title':
- $_SESSION['browse']['sort']['title'] = 'ASC';
+ if ($_SESSION['browse']['sort'][$sort] == 'DESC') {
+ $_SESSION['browse']['sort'][$sort] = 'ASC';
+ }
+ else {
+ $_SESSION['browse']['sort'][$sort] = 'DESC';
+ }
break;
}
}
@@ -189,16 +194,18 @@ class Browse {
// Now Add the Order
$order_sql = "ORDER BY ";
+ // If we don't have a sort, then go ahead and return it now
+ if (!is_array($_SESSION['browse']['sort'])) { return $sql; }
+
foreach ($_SESSION['browse']['sort'] as $key=>$value) {
- $order_sql .= self::sql_sort($value);
+ $order_sql .= self::sql_sort($key,$value);
}
-
// Clean her up
$order_sql = rtrim($order_sql,"ORDER BY ");
$order_sql = rtrim($order_sql,",");
- self::$sql = $sql . $order_sql;
-
+ $sql = $sql . $order_sql;
+
return $sql;
} // get_sql
@@ -279,7 +286,7 @@ class Browse {
if ($order != 'DESC') { $order == 'ASC'; }
-
+
if ($_SESSION['browse']['type'] == 'song') {
switch($field) {
case 'title';
@@ -294,7 +301,7 @@ class Browse {
} // end switch
} // end if song
- return $sql . "$order,";
+ return "$sql $order,";
} // sql_sort
@@ -308,17 +315,17 @@ class Browse {
switch ($_SESSION['browse']['type']) {
case 'song':
- show_box_top();
+ show_box_top(_('Songs'));
require_once Config::get('prefix') . '/templates/show_songs.inc.php';
show_box_bottom();
break;
case 'album':
- show_box_top();
+ show_box_top(_('Albums'));
require_once Config::get('prefix') . '/templates/show_albums.inc.php';
show_box_bottom();
break;
case 'genre':
- show_box_top();
+ show_box_top(_('Genres'));
require_once Config::get('prefix') . '/templates/show_genres.inc.php';
show_box_bottom();
break;
@@ -328,7 +335,7 @@ class Browse {
show_box_bottom();
break;
case 'artist':
- show_box_top();
+ show_box_top(_('Artists'));
require_once Config::get('prefix') . '/templates/show_artists.inc.php';
show_box_bottom();
break;
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index 1ceaf9ce..0befc219 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -131,6 +131,23 @@ class Catalog {
} // get_stats
/**
+ * clear_stats
+ * This clears all stats for _everything_
+ */
+ public static function clear_stats() {
+
+ /* Whip out everything */
+ $sql = "TRUNCATE `object_count`";
+ $db_results = Dba::query($sql);
+
+ $sql = "UDPATE `song` SET `player`='0'";
+ $db_results = Dba::query($sql);
+
+ return true;
+
+ } // clear_stats
+
+ /**
* create
* This creates a new catalog entry and then returns the insert id
* it checks to make sure this path is not already used before creating
@@ -741,17 +758,17 @@ class Catalog {
* update_settings
* This function updates the basic setting of the catalog
*/
- function update_settings($data) {
+ public static function update_settings($data) {
- $id = sql_escape($data['catalog_id']);
- $name = sql_escape($data['name']);
- $key = sql_escape($data['key']);
- $rename = sql_escape($data['rename_pattern']);
- $sort = sql_escape($data['sort_pattern']);
+ $id = Dba::escape($data['catalog_id']);
+ $name = Dba::escape($data['name']);
+ $key = Dba::escape($data['key']);
+ $rename = Dba::escape($data['rename_pattern']);
+ $sort = Dba::escape($data['sort_pattern']);
- $sql = "UPDATE catalog SET name='$name', `key`='$key', rename_pattern='$rename', " .
- "sort_pattern='$sort' WHERE id = '$id'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "UPDATE `catalog` SET `name`='$name', `key`='$key', `rename_pattern`='$rename', " .
+ "`sort_pattern`='$sort' WHERE `id` = '$id'";
+ $db_results = Dba::query($sql);
return true;
diff --git a/lib/class/genre.class.php b/lib/class/genre.class.php
index 90db7d53..c0780591 100644
--- a/lib/class/genre.class.php
+++ b/lib/class/genre.class.php
@@ -181,18 +181,16 @@ class Genre {
/**
* get_artists
* This gets all of the artists who have at least one song in this genre
- * @package Genre
- * @catagory Class
*/
- function get_artists() {
+ public function get_artists() {
- $sql = "SELECT DISTINCT(song.artist) FROM song WHERE genre='" . $this->id . "'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "SELECT DISTINCT(`song`.`artist`) FROM `song` WHERE `genre`='" . $this->id . "'";
+ $db_results = Dba::query($sql);
$results = array();
- while ($r = mysql_fetch_assoc($db_results)) {
- $results[] = get_artist_info($r['artist']);
+ while ($r = Dba::fetch_assoc($db_results)) {
+ $results[] = $r['artist'];
}
return $results;
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index ce014179..44f37bed 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -689,7 +689,7 @@ class User {
}
$item = "[$data->count] - $data->f_name";
- $results[]->f_link = $item;
+ $results[]->f_name_link = $item;
} // end foreach items
return $results;
diff --git a/lib/general.lib.php b/lib/general.lib.php
index a8bc18d6..03855ad8 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -534,27 +534,6 @@ function tbl_name($table) {
} // tbl_name
/**
- * clear_catalog_stats()
- *
- * Use this to clear the stats for the entire Ampache server.
- * @package Catalog
- * @catagory Clear
- */
-function clear_catalog_stats() {
-
- $dbh = dbh();
-
- /* Wipe out the object_count table */
- $sql = "TRUNCATE object_count";
- $results = mysql_query($sql, $dbh);
-
- /* Set every song to unplayed */
- $sql = "UPDATE song SET played='0'";
- $results = mysql_query($sql, $dbh);
-
-} // clear_catalog_stats
-
-/**
* scrub_out
* This function is used to escape user data that is getting redisplayed
* onto the page, it htmlentities the mojo
diff --git a/modules/vauth/session.lib.php b/modules/vauth/session.lib.php
index ddb99d1c..03b9b66f 100644
--- a/modules/vauth/session.lib.php
+++ b/modules/vauth/session.lib.php
@@ -158,7 +158,6 @@ function vauth_get_session($key) {
$results = Dba::fetch_assoc($db_results);
if (!count($results)) {
- vauth_error("Query: $sql failed to return results " . mysql_error());
return false;
}
diff --git a/templates/show_songs.inc.php b/templates/show_songs.inc.php
index 95ea8f3d..7ad023db 100644
--- a/templates/show_songs.inc.php
+++ b/templates/show_songs.inc.php
@@ -32,7 +32,7 @@ $ajax_url = Config::get('ajax_url');
</tr>
<tr class="table-header">
<th><?php echo _('Add'); ?></th>
- <th onclick="ajaxPut('<?php echo $ajax_url; ?>?action=browse&amp;sort=title');return true;" >
+ <th onclick="ajaxPut('<?php echo $ajax_url; ?>?action=browse&amp;sort=title');return true;" style="cursor:pointer;">
<?php echo _('Song Title'); ?>
</th>
<th><?php echo _('Artist'); ?></th>