From 16f655ba45459c5a0d1be76d1f43094f49dfd0a7 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Thu, 16 Mar 2006 05:25:00 +0000 Subject: new tabbed preferences and account page is back --- docs/CHANGELOG | 2 + lib/class/user.class.php | 15 +++-- lib/ui.lib.php | 16 +---- modules/init.php | 2 +- play/index.php | 1 + preferences.php | 45 +++++++++++-- templates/header.inc | 13 +--- templates/menustyle.inc | 35 ++++++++++ templates/show_preference_box.inc.php | 1 - templates/show_preferences.inc | 111 ++++++++++++++++++++------------ templates/show_user.inc.php | 117 ++++++++++++++-------------------- user.php | 85 ------------------------ 12 files changed, 210 insertions(+), 233 deletions(-) delete mode 100644 user.php diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 65bc735c..e74ab9fe 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,8 @@ -------------------------------------------------------------------------- v.3.3.2-Beta2 + - Tweaked preferences adding tab'd views rather then all on one + page, also added account page back in. - Fixed popen in downsample, forcing binary mode, so that windows works correctly (Thx SoundOfEmotion) - Tweaked some defaults in .dist config file as well as the error diff --git a/lib/class/user.class.php b/lib/class/user.class.php index 084ae359..dbcbd97d 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -29,6 +29,7 @@ class User { //Basic Componets + var $id; var $username; var $fullname; var $access; @@ -46,6 +47,7 @@ class User { } $this->username = sql_escape($username); + $this->id = $this->username; $info = $this->get_info(); $this->username = $info->username; $this->fullname = $info->fullname; @@ -82,11 +84,12 @@ class User { * 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 + * You can specify a type to limit it to a single type of preference * []['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) { + function get_preferences($user_id=0,$type=0) { if (!$user_id) { $user_id = $this->username; @@ -97,6 +100,10 @@ class User { if ($user_id != '-1') { $user_limit = "AND preferences.type != 'system'"; } + + if ($type != '0') { + $user_limit = "AND preferences.type = '" . sql_escape($type) . "'"; + } $sql = "SELECT preferences.name, preferences.description, preferences.type, user_preference.value FROM preferences,user_preference " . @@ -332,7 +339,7 @@ class User { function update_fullname($new_fullname) { $new_fullname = sql_escape($new_fullname); - $sql = "UPDATE user SET fullname='$new_fullname' WHERE username='$this->username'"; + $sql = "UPDATE user SET fullname='$new_fullname' WHERE username='$this->id'"; $db_results = mysql_query($sql, dbh()); } // update_username @@ -344,7 +351,7 @@ class User { function update_email($new_email) { $new_email = sql_escape($new_email); - $sql = "UPDATE user SET email='$new_email' WHERE username='$this->username'"; + $sql = "UPDATE user SET email='$new_email' WHERE username='$this->id'"; $db_results = mysql_query($sql, dbh()); } // update_email @@ -356,7 +363,7 @@ class User { function update_offset($new_offset) { $new_offset = sql_escape($new_offset); - $sql = "UPDATE user SET offset_limit='$new_offset' WHERE username='$this->username'"; + $sql = "UPDATE user SET offset_limit='$new_offset' WHERE username='$this->id'"; $db_results = mysql_query($sql, dbh()); } // update_offset diff --git a/lib/ui.lib.php b/lib/ui.lib.php index 8b7891dd..7dd36aad 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -416,20 +416,6 @@ function show_user_registration ($values=array()) { } // show_user_registration -/** - * show_edit_profile - * shows a single user profile for editing - * @package Web Interface - * @catagory Display - */ -function show_edit_profile($username) { - - $this_user = new User($username); - - require (conf('prefix') . "/templates/show_user.inc.php"); - -} // show_edit_profile - /** * show_play_selected * this shows the playselected/add to playlist @@ -1039,7 +1025,7 @@ function get_location() { * it does not contain the
tags */ function show_preference_box($preferences) { - + include (conf('prefix') . '/templates/show_preference_box.inc.php'); } // show_preference_box diff --git a/modules/init.php b/modules/init.php index f361a7fd..e94f3ba5 100644 --- a/modules/init.php +++ b/modules/init.php @@ -80,7 +80,7 @@ if (!$results['allow_stream_playback']) { /** This is the version.... fluf nothing more... **/ -$results['version'] = '3.3.2-Beta2 (Build 007)'; +$results['version'] = '3.3.2-Beta2 (Build 008)'; diff --git a/play/index.php b/play/index.php index d13c447f..42cc1913 100644 --- a/play/index.php +++ b/play/index.php @@ -1,4 +1,5 @@ has_access(25) || conf('demo_mode') || ($GLOBALS['user']->id != $user_id && !$GLOBALS['user']->has_access(100))) { + show_access_denied(); + exit(); + } + + /* Go ahead and update normal stuff */ + $this_user = new User($user_id); + $this_user->update_fullname($_REQUEST['fullname']); + $this_user->update_email($_REQUEST['email']); + $this_user->update_offset($_REQUEST['offset_limit']); + + /* Check for password change */ + if ($_REQUEST['password1'] !== $_REQUEST['password2'] && !empty($_REQUEST['password1'])) { + $GLOBALS['error']->add_error('password',_('Error: Password Does Not Match or Empty')); + break; + } + elseif (!empty($_REQUEST['password1'])) { + /* We're good change the mofo! */ + $this_user->update_password($_REQUEST['password1']); + + /* Haha I'm fired... it's not an error but screw it */ + $GLOBALS['error']->add_error('password',_('Password Updated')); + } + + /* Check for stats */ + if ($_REQUEST['clear_stats'] == '1') { + $this_user->delete_stats(); + } + break; case 'update_preferences': - $user_id = scrub_in($_REQUEST['user_id']); /* Do the work */ update_preferences($user_id); @@ -45,17 +80,17 @@ switch(scrub_in($_REQUEST['action'])) { /* Reset the Theme */ set_theme(); default: - $user_id = $user->username; - $preferences = $user->get_preferences(); + if (!$user_id) { $user_id = $GLOBALS['user']->id; } + $preferences = $GLOBALS['user']->get_preferences(0,$_REQUEST['tab']); break; } // End Switch Action -if (!$user->fullname) { +if (!$GLOBALS['user']->fullname) { $fullname = "Site"; } else { - $fullname = $user->fullname; + $fullname = $GLOBALS['user']->fullname; } diff --git a/templates/header.inc b/templates/header.inc index 514c2310..0e8185f0 100644 --- a/templates/header.inc +++ b/templates/header.inc @@ -46,25 +46,16 @@ if (conf('use_rss')) { ?> Ampache: For the love of music +
prefs['play_type']=='mpd') && ($location['page'] != 'mpd.php')) { $myMpd = init_mpd(); show_template ('show_mpdminicontrol'); } else { ?> -
Ampache v.
fullname; ?>
- : -
- - " class="button" /> -
-
+