diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-12-25 10:04:27 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-12-25 10:04:27 +0000 |
commit | 27158141ee1a14b7d23ae8997d2c41b49fc904d9 (patch) | |
tree | 2180fff67d21ffdbab32f2105cff3c7275b6b511 /lib/class/user.class.php | |
parent | 5415c2e847032896907946c98d68a254399e4416 (diff) | |
download | ampache-27158141ee1a14b7d23ae8997d2c41b49fc904d9.tar.gz ampache-27158141ee1a14b7d23ae8997d2c41b49fc904d9.tar.bz2 ampache-27158141ee1a14b7d23ae8997d2c41b49fc904d9.zip |
initial ratings mojo, some stylesheet fixes, changed user preferences again and a db update
Diffstat (limited to 'lib/class/user.class.php')
-rw-r--r-- | lib/class/user.class.php | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/lib/class/user.class.php b/lib/class/user.class.php index 83a778ce..0b0459a7 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -74,11 +74,14 @@ class User { } // get_info - /*! - @function get_preferences - @discussion gets the prefs for this specific - user and returns them as an array - */ + /** + * get_preferences + * This is a little more complicate now that we've got many types of preferences + * This funtions pulls all of them an arranges them into a spiffy little array + * []['title'] = ucased type name + * []['prefs'] = array(array('name','display','value')); + * []['admin'] = t/f value if this is an admin only section + */ function get_preferences($user_id=0) { if (!$user_id) { @@ -86,14 +89,25 @@ class User { } if (!conf('use_auth')) { $user_id = '-1'; } - + + if ($user_id != '-1') { + $user_limit = "AND preferences.type != 'system'"; + } + + $sql = "SELECT preferences.name, preferences.description, preferences.type, user_preference.value FROM preferences,user_preference " . - "WHERE user_preference.user='$user_id' AND user_preference.preference=preferences.id AND preferences.type='user'"; + "WHERE user_preference.user='$user_id' AND user_preference.preference=preferences.id $user_limit"; $db_results = mysql_query($sql, dbh()); - while ($r = mysql_fetch_object($db_results)) { - $results[] = $r; - } + /* Ok this is crapy, need to clean this up or improve the code FIXME */ + while ($r = mysql_fetch_assoc($db_results)) { + $type = $r['type']; + $admin = false; + if ($type == 'system') { $admin = true; } + $type_array[$type][] = array('name'=>$r['name'],'description'=>$r['description'],'value'=>$r['value']); + $results[$type] = array ('title'=>ucwords($type),'admin'=>$admin,'prefs'=>$type_array[$type]); + } // end while + return $results; |