summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/class/album.class.php2
-rw-r--r--lib/class/genre.class.php34
-rw-r--r--lib/class/localplay.class.php18
-rw-r--r--lib/class/user.class.php2
-rw-r--r--lib/localplay.lib.php12
-rw-r--r--lib/preferences.php61
-rw-r--r--lib/ui.lib.php8
7 files changed, 58 insertions, 79 deletions
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 513256d6..af9cadb8 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -108,7 +108,7 @@ class Album {
private function _get_extra_info() {
$sql = "SELECT COUNT(DISTINCT(song.artist)) as artist_count,COUNT(song.id) AS song_count,artist.name AS artist_name" .
- ",artist.prefix AS artist_prefix,album_data.art AS has_art,album_data.thumb AS has_thumb ".
+ ",artist.prefix AS artist_prefix,album_data.art AS has_art,album_data.thumb AS has_thumb, artist.id AS artist_id ".
"FROM `song` " .
"INNER JOIN `artist` ON `artist`.`id`=`song`.`artist` " .
"LEFT JOIN `album_data` ON `album_data`.`album_id` = `song`.`album` " .
diff --git a/lib/class/genre.class.php b/lib/class/genre.class.php
index 7e311fda..90db7d53 100644
--- a/lib/class/genre.class.php
+++ b/lib/class/genre.class.php
@@ -91,34 +91,30 @@ class Genre {
/**
* get_album_count
* Returns the number of albums that contain a song of this genre
- * @package Genre
- * @catagory Class
*/
- function get_album_count() {
+ public function get_album_count() {
- $sql = "SELECT COUNT(DISTINCT(song.album)) FROM song WHERE genre='" . $this->id . "'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "SELECT COUNT(DISTINCT(song.album)) FROM `song` WHERE `genre`='" . $this->id . "'";
+ $db_results = Dba::query($sql);
- $total_items = mysql_fetch_array($db_results);
+ $total_items = Dba::fetch_row($db_results);
- return $total_items[0];
+ return $total_items['0'];
} // get_album_count
/**
* get_artist_count
* Returns the number of artists who have at least one song in this genre
- * @package Genre
- * @catagory Class
*/
- function get_artist_count() {
+ public function get_artist_count() {
- $sql = "SELECT COUNT(DISTINCT(song.artist)) FROM song WHERE genre='" . $this->id . "'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "SELECT COUNT(DISTINCT(`song`.`artist`)) FROM `song` WHERE `genre`='" . $this->id . "'";
+ $db_results = Dba::query($sql);
- $total_items = mysql_fetch_array($db_results);
+ $total_items = Dba::fetch_row($db_results);
- return $total_items[0];
+ return $total_items['0'];
} // get_artist_count
@@ -169,15 +165,13 @@ class Genre {
*/
function get_albums() {
- $sql = "SELECT DISTINCT(song.album) FROM song WHERE genre='" . $this->id . "'";
- $db_results = mysql_query($sql,dbh());
+ $sql = "SELECT DISTINCT(`song`.`album`) FROM `song` WHERE `genre`='" . $this->id . "'";
+ $db_results = Dba::query($sql);
$results = array();
- while ($r = mysql_fetch_assoc($db_results)) {
- $album = new Album($r['album']);
- $album->format_album();
- $results[] = $album;
+ while ($r = Dba::fetch_row($db_results)) {
+ $results[] = $r['0'];
}
return $results;
diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php
index 4c12aaef..78a3c70e 100644
--- a/lib/class/localplay.class.php
+++ b/lib/class/localplay.class.php
@@ -23,15 +23,15 @@
class Localplay {
/* Base Variables */
- var $type;
+ public $type;
/* Built Variables */
- var $_function_map = array();
- var $_template;
- var $_preferences = array();
- var $_player;
+ public $_function_map = array();
+ public $_template;
+ public $_preferences = array();
+ public $_player;
/**
@@ -42,7 +42,6 @@ class Localplay {
*/
function Localplay($type) {
-
$this->type = $type;
$this->_get_info();
@@ -57,11 +56,10 @@ class Localplay {
* any failures, fatal errors will actually return something to the
* gui
*/
- function _get_info() {
+ private function _get_info() {
$this->_load_player();
-
} // _get_info
@@ -71,11 +69,11 @@ class Localplay {
* Will interface with in order to make all this magical stuf work
* all LocalPlay modules should be located in /modules/<name>/<name>.class.php
*/
- function _load_player() {
+ private function _load_player() {
if (!$this->type) { return false; }
- $filename = conf('prefix') . '/modules/localplay/' . $this->type . '.controller.php';
+ $filename = Config::get('prefix') . '/modules/localplay/' . $this->type . '.controller.php';
$include = require_once ($filename);
if (!$include) {
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index 876b4a36..5b4b77b6 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -154,7 +154,7 @@ class User {
ksort($type_array[$type]);
$results[$type] = array ('title'=>ucwords($type),'admin'=>$admin,'prefs'=>$type_array[$type]);
} // end while
-
+
return $results;
} // get_preferences
diff --git a/lib/localplay.lib.php b/lib/localplay.lib.php
index fb98d3fb..99b13932 100644
--- a/lib/localplay.lib.php
+++ b/lib/localplay.lib.php
@@ -36,10 +36,10 @@ function verify_localplay_preferences($type) {
foreach ($preferences as $preference) {
$name = 'localplay_' . $type . '_' . $preference['name'];
/* check for an existing record */
- $sql = "SELECT id FROM preferences WHERE name = '" . sql_escape($name) . "'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "SELECT id FROM preferences WHERE name = '" . Dba::escape($name) . "'";
+ $db_results = Dba::query($sql);
- if (!mysql_num_rows($db_results)) { return false; }
+ if (!Dba::num_rows($db_results)) { return false; }
} // end foreach preferences
@@ -76,8 +76,8 @@ function insert_localplay_preferences($type) {
} // end foreach preferences
/* Fix everyones preferences */
- $sql = "SELECT * FROM user";
- $db_results = mysql_query($sql, dbh());
+ $sql = "SELECT * FROM `user`";
+ $db_results = Dba::query($sql);
$temp_user = new User();
$temp_user->fix_preferences('-1');
@@ -143,7 +143,7 @@ function remove_localplay_preferences($type=0) {
function get_localplay_controllers($disabled='') {
/* First get a list of the files */
- $handle = opendir(conf('prefix') . '/modules/localplay');
+ $handle = opendir(Config::get('prefix') . '/modules/localplay');
if (!is_resource($handle)) {
debug_event('localplay','Error: Unable to read localplay controller directory','1');
diff --git a/lib/preferences.php b/lib/preferences.php
index 531532cd..ac8c9e50 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -80,26 +80,26 @@ function clean_preference_name($name) {
} // clean_preference_name
-/*!
- @function update_preferences
- @discussion grabs the current keys that should be added
- and then runs throught $_REQUEST looking for those
- values and updates them for this user
-*/
+/*
+ * update_preferences
+ * grabs the current keys that should be added
+ * and then runs throught $_REQUEST looking for those
+ * values and updates them for this user
+ */
function update_preferences($pref_id=0) {
$pref_user = new User($pref_id);
/* Get current keys */
- $sql = "SELECT id,name,type FROM preferences";
+ $sql = "SELECT `id`,`name`,`type` FROM `preference`";
/* If it isn't the System Account's preferences */
- if ($pref_id != '-1') { $sql .= " WHERE type!='system'"; }
+ if ($pref_id != '-1') { $sql .= " WHERE `type` != 'system'"; }
- $db_results = mysql_query($sql, dbh());
+ $db_results = Dba::query($sql);
// Collect the current possible keys
- while ($r = mysql_fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$results[] = array('id' => $r['id'], 'name' => $r['name'],'type' => $r['type']);
} // end collecting keys
@@ -110,16 +110,10 @@ function update_preferences($pref_id=0) {
$name = $data['name'];
$apply_to_all = "check_" . $data['name'];
$id = $data['id'];
- $value = sql_escape(scrub_in($_REQUEST[$name]));
+ $value = Dba::escape(scrub_in($_REQUEST[$name]));
/* Some preferences require some extra checks to be performed */
switch ($name) {
- case 'theme_name':
- // If the theme exists and it's different then our current one reset the colors
- if (theme_exists($value) AND $pref_user->prefs['theme_name'] != $value) {
- set_theme_colors($value,$pref_id);
- }
- break;
case 'sample_rate':
$value = validate_bitrate($value);
break;
@@ -146,28 +140,22 @@ function update_preferences($pref_id=0) {
/**
* update_preference
* This function updates a single preference and is called by the update_preferences function
- * @package Preferences
- * @catagory Update
*/
-function update_preference($username,$name,$pref_id,$value) {
+function update_preference($user_id,$name,$pref_id,$value) {
$apply_check = "check_" . $name;
/* First see if they are an administrator and we are applying this to everything */
if ($GLOBALS['user']->has_access(100) AND make_bool($_REQUEST[$apply_check])) {
- $sql = "UPDATE user_preference SET `value`='$value' WHERE preference='$pref_id'";
- $db_results = mysql_query($sql, dbh());
- /* Reset everyones colors! */
- if ($name =='theme_name') {
- set_theme_colors($value,0);
- }
+ $sql = "UPDATE `user_preference` SET `value`='$value' WHERE `preference`='$pref_id'";
+ $db_results = Dba::query($sql);
return true;
}
/* Else make sure that the current users has the right to do this */
if (has_preference_access($name)) {
- $sql = "UPDATE user_preference SET `value`='$value' WHERE preference='$pref_id' AND user='$username'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "UPDATE `user_preference` SET `value`='$value' WHERE `preference`='$pref_id' AND `user`='$user_id'";
+ $db_results = Dba::query($sql);
return true;
}
@@ -191,7 +179,7 @@ function has_preference_access($name) {
$name = Dba::escape($name);
/* Check Against the Database Row */
- $sql = "SELECT `level` FROM `preferences` " .
+ $sql = "SELECT `level` FROM `preference` " .
"WHERE `name`='$name'";
$db_results = Dba::query($sql);
@@ -208,11 +196,10 @@ function has_preference_access($name) {
} //has_preference_access
-/*!
- @function create_preference_input
- @discussion takes the key and then creates
- the correct type of input for updating it
-*/
+/**
+ * create_preference_input
+ * takes the key and then creates the correct type of input for updating it
+ */
function create_preference_input($name,$value) {
$len = strlen($value);
@@ -339,6 +326,11 @@ function create_preference_input($name,$value) {
} // foreach themes
echo "</select>\n";
break;
+ case 'random_method':
+ echo "<select name=\"$name\">\n";
+ echo "\t<option value=\"genre\">" . _('Similar Genre') . "</option>";
+ echo "</select>\n";
+ break;
case 'lastfm_pass':
echo "<input type=\"password\" size=\"16\" name=\"$name\" value=\"******\" />";
break;
@@ -523,7 +515,6 @@ function fix_all_users_prefs() {
} // fix_all_users_prefs
-
/**
* fix_preferences
* This takes the preferences, explodes what needs to
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 1476307a..cbf3bde0 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -627,26 +627,22 @@ function img_resize($image,$size,$type,$album_id) {
/**
* show_genres
* this shows the 'many' genre form, it takes an array of genre objects and the view object
- * @package Genre
- * @catagory Display
*/
function show_genres($genres,$view) {
- require (conf('prefix') . '/templates/show_genres.inc.php');
+ require Config::get('prefix') . '/templates/show_genres.inc.php';
} // show_genres
/**
* show_genre
* this shows a single genre item which is basicly just a link to the albums/artists/songs of said genre
- * @package Genre
- * @catagory Display
*/
function show_genre($genre_id) {
$genre = new Genre($genre_id);
- require (conf('prefix') . '/templates/show_genre.inc.php');
+ require Config::get('prefix') . '/templates/show_genre.inc.php';
} // show_genre