summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormartian <martian@ampache>2010-02-09 17:44:44 +0000
committermartian <martian@ampache>2010-02-09 17:44:44 +0000
commit1b35c20dd0a93b143d8b9542743a743e0db66386 (patch)
tree0500ae3eec1dfb70b66c3ca30e9a61da2c0daba8 /lib
parent5e52f0d7ccb6183d7e1b4e5033adad0d08a48eb6 (diff)
downloadampache-1b35c20dd0a93b143d8b9542743a743e0db66386.tar.gz
ampache-1b35c20dd0a93b143d8b9542743a743e0db66386.tar.bz2
ampache-1b35c20dd0a93b143d8b9542743a743e0db66386.zip
Adding the bandwidth option to the preferences. This changes the complexity of the UI and toggles album art.
Diffstat (limited to 'lib')
-rw-r--r--lib/class/config.class.php5
-rw-r--r--lib/class/preference.class.php2
-rw-r--r--lib/class/song.class.php11
-rw-r--r--lib/class/update.class.php17
-rw-r--r--lib/class/user.class.php5
-rw-r--r--lib/preferences.php8
6 files changed, 37 insertions, 11 deletions
diff --git a/lib/class/config.class.php b/lib/class/config.class.php
index d846f225..64a45522 100644
--- a/lib/class/config.class.php
+++ b/lib/class/config.class.php
@@ -28,6 +28,11 @@
* config overides and/or local configs (for like dba)
* The class should be a static var in the other classes
*/
+
+define('BANDWIDTH_LOW', 0);
+define('BANDWIDTH_MEDIUM', 1);
+define('BANDWIDTH_HIGH', 2);
+
class Config {
// These are the settings for this specific class
diff --git a/lib/class/preference.class.php b/lib/class/preference.class.php
index cfc08bf8..04d7f2f7 100644
--- a/lib/class/preference.class.php
+++ b/lib/class/preference.class.php
@@ -226,7 +226,7 @@ class Preference {
$sql = "SELECT `preference`.`name`,`preference`.`description`,`user_preference`.`value` FROM `preference` " .
" INNER JOIN `user_preference` ON `user_preference`.`preference`=`preference`.`id` " .
- " WHERE `user_preference`.`user`='$user_id' AND `preference`.`catagory` != 'internal' $user_limit";
+ " WHERE `user_preference`.`user`='$user_id' AND `preference`.`catagory` != 'internal' $user_limit order by `preference`.`description`";
$db_results = Dba::read($sql);
$results = array();
diff --git a/lib/class/song.class.php b/lib/class/song.class.php
index 7d30b116..6b68df94 100644
--- a/lib/class/song.class.php
+++ b/lib/class/song.class.php
@@ -918,7 +918,7 @@ class Song extends database_object implements media {
* it uses the popular threshold to figure out how many to pull
* it will only return unique object
*/
- public static function get_recently_played($user_id='') {
+ public static function get_recently_played($user_id='', $limit=null) {
if ($user_id) {
$user_limit = " AND `object_count`.`user`='" . Dba::escape($user_id) . "'";
@@ -931,12 +931,15 @@ class Song extends database_object implements media {
"ORDER BY `object_count`.`date` DESC ";
$db_results = Dba::read($sql);
- $results = array();
+ $results = array();
while ($row = Dba::fetch_assoc($db_results)) {
if (isset($results[$row['object_id']])) { continue; }
- $results[$row['object_id']] = $row;
- if (count($results) > Config::get('popular_threshold')) { break; }
+ $results[$row['object_id']] = $row;
+ if (!is_null($limit))
+ if (count($results) > $limit) { break; }
+ else
+ if (count($results) > Config::get('popular_threshold')) { break; }
}
return $results;
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index 106c3480..bda724a4 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -1828,12 +1828,21 @@ class Update {
$sql = "ALTER TABLE `live_stream` CHANGE `url` `url` VARCHAR ( 4096 )";
$db_results = Dba::write($sql);
+
+ // Now add in the min_object_count preference and the random_method
+ $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
+ "VALUES('bandwidth','1','Bandwidth','100','integer','interface')";
+ $db_results = Dba::write($sql);
+
+ /* Fix every users preferences */
+ $sql = "SELECT `id` FROM `user`";
+ $db_results = Dba::read($sql);
- User::fix_preferences('-1');
+ User::fix_preferences('-1');
- while ($r = Dba::fetch_assoc($db_results)) {
- User::fix_preferences($r['id']);
- } // while we're fixing the useres stuff
+ while ($r = Dba::fetch_assoc($db_results)) {
+ User::fix_preferences($r['id']);
+ } // while results
} // update_360002
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index 5608e025..40065922 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -197,7 +197,8 @@ class User extends database_object {
$sql = "SELECT preference.name, preference.description, preference.catagory, preference.level, user_preference.value " .
"FROM preference INNER JOIN user_preference ON user_preference.preference=preference.id " .
- "WHERE user_preference.user='$user_id' " . $user_limit;
+ "WHERE user_preference.user='$user_id' " . $user_limit . " ORDER BY preference.catagory, preference.description";
+
$db_results = Dba::read($sql);
/* Ok this is crapy, need to clean this up or improve the code FIXME */
@@ -206,7 +207,7 @@ class User extends database_object {
$admin = false;
if ($type == 'system') { $admin = true; }
$type_array[$type][$r['name']] = array('name'=>$r['name'],'level'=>$r['level'],'description'=>$r['description'],'value'=>$r['value']);
- ksort($type_array[$type]);
+ //ksort($type_array[$type]); // sorted this via sql and added sub-category sorting - Vlet
$results[$type] = array ('title'=>ucwords($type),'admin'=>$admin,'prefs'=>$type_array[$type]);
} // end while
diff --git a/lib/preferences.php b/lib/preferences.php
index 5ea7aba4..5b496ba0 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -257,6 +257,14 @@ function create_preference_input($name,$value) {
echo "\t<option value=\"default\"$default>" . _('Default') . "</option>\n";
echo "</select>\n";
break;
+ case 'bandwidth':
+ ${"bandwidth_$value"} = ' selected="selected"';
+ echo "<select name=\"$name\">\n";
+ echo "\t<option value=\"0\"$bandwidth_0>" . _('Low') . "</option>\n";
+ echo "\t<option value=\"1\"$bandwidth_1>" . _('Medium') . "</option>\n";
+ echo "\t<option value=\"2\"$bandwidth_2>" . _('High') . "</option>\n";
+ echo "</select>\n";
+ break;
case 'transcode':
${$value} = ' selected="selected"';
echo "<select name=\"$name\">\n";