diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-03-16 05:25:00 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-03-16 05:25:00 +0000 |
commit | 16f655ba45459c5a0d1be76d1f43094f49dfd0a7 (patch) | |
tree | 2e365e5f6625e8ef307211e58b92a3233b016044 | |
parent | e2bf8254895b30b679865585b37e72aa1e867320 (diff) | |
download | ampache-16f655ba45459c5a0d1be76d1f43094f49dfd0a7.tar.gz ampache-16f655ba45459c5a0d1be76d1f43094f49dfd0a7.tar.bz2 ampache-16f655ba45459c5a0d1be76d1f43094f49dfd0a7.zip |
new tabbed preferences and account page is back
-rwxr-xr-x | docs/CHANGELOG | 2 | ||||
-rw-r--r-- | lib/class/user.class.php | 15 | ||||
-rw-r--r-- | lib/ui.lib.php | 16 | ||||
-rw-r--r-- | modules/init.php | 2 | ||||
-rw-r--r-- | play/index.php | 1 | ||||
-rw-r--r-- | preferences.php | 45 | ||||
-rw-r--r-- | templates/header.inc | 13 | ||||
-rw-r--r-- | templates/menustyle.inc | 35 | ||||
-rw-r--r-- | templates/show_preference_box.inc.php | 1 | ||||
-rw-r--r-- | templates/show_preferences.inc | 111 | ||||
-rw-r--r-- | templates/show_user.inc.php | 117 | ||||
-rw-r--r-- | user.php | 85 |
12 files changed, 210 insertions, 233 deletions
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 @@ -417,20 +417,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 * box, which includes a little javascript @@ -1039,7 +1025,7 @@ function get_location() { * it does not contain the <form> </form> 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 @@ <?php +if (1==1) { } /* Copyright (c) 2001 - 2006 Ampache.org diff --git a/preferences.php b/preferences.php index 804405fd..985f225f 100644 --- a/preferences.php +++ b/preferences.php @@ -29,9 +29,44 @@ require('modules/init.php'); +/* Scrub in the needed mojo */ +if (!$_REQUEST['tab']) { $_REQUEST['tab'] = 'theme'; } +$user_id = scrub_in($_REQUEST['user_id']); + + switch(scrub_in($_REQUEST['action'])) { + case 'update_user': + /* Verify permissions */ + if (!$GLOBALS['user']->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')) { ?> <img class="pageheader" src="<?php echo $web_path; ?><?php echo conf('theme_path'); ?>/images/ampache.gif" border="0" title="Ampache: For the love of music" alt="Ampache: For the love of music" /> </a> </div><!--End topbarleft --> + <div id="topbarright"> <?php if (($user->prefs['play_type']=='mpd') && ($location['page'] != 'mpd.php')) { $myMpd = init_mpd(); show_template ('show_mpdminicontrol'); } else { ?> - <div id="topbarright"> <a href="http://www.ampache.org/index.php">Ampache v.<?php echo conf('version'); ?></a><br /> <b><?php echo _("You are currently logged in as") . " " . $GLOBALS['user']->fullname; ?></b> <br /> - <?php echo _("Browse"); ?>: - <form method="post" action="<?php echo $web_path; ?>/browse.php" enctype="multipart/form-data" style="Display:inline;"> - <select name="action"> - <option value="album">Album</option> - <option value="artist">Artist</option> - <option value="genre">Genre</option> - </select> - <input type="submit" value="<?php echo _("Go!"); ?>" class="button" /> - </form> - </div> <!-- End topbarright --> <?php } ?> + </div> <!-- End topbarright --> </div><!-- End topbar --> <div id="sidebar"><!-- This is the sidebar --> <?php require_once(conf('prefix') . '/templates/sidebar.inc.php'); ?> diff --git a/templates/menustyle.inc b/templates/menustyle.inc index 1b785924..09846d1b 100644 --- a/templates/menustyle.inc +++ b/templates/menustyle.inc @@ -210,5 +210,40 @@ text-indent: -9000px; z-index: 1; } + #tablist { + padding: 3px 0; + margin-left: 0; + border-bottom: 1px solid #778; + font: bold 12px Verdana, sans-serif; + } + + #tablist li { + list-style: none; + margin: 0; + display: inline; + } + + #tablist li a { + padding: 3px 0.5em; + margin-left: 3px; + border: 1px solid #778; + border-bottom: none; + background: #DDE; + text-decoration: none; + } + + #tablist li a:link { color: #448; } + #tablist li a:visited { color: #667; } + + #tablist li a:hover { + color: #000; + background: #AAE; + border-color: #227; + } + + #tablist li a#current { + background: white; + border-bottom: 1px solid white; + } --> </style> diff --git a/templates/show_preference_box.inc.php b/templates/show_preference_box.inc.php index 45e86d6c..4d2ffa67 100644 --- a/templates/show_preference_box.inc.php +++ b/templates/show_preference_box.inc.php @@ -32,7 +32,6 @@ if ($GLOBALS['user']->has_access(100) AND conf('use_auth')) { $show_apply_to_all = true; } - ?> diff --git a/templates/show_preferences.inc b/templates/show_preferences.inc index 9cbf9a15..f87d0378 100644 --- a/templates/show_preferences.inc +++ b/templates/show_preferences.inc @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2005 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved This program is free software; you can redistribute it and/or @@ -26,6 +26,20 @@ */ +/** + * This page has a few tabs, as such we need to figure out which tab we are on + * and display the information accordingly + */ +$current_tab = scrub_in($_REQUEST['tab']); +if (!$current_tab) { $current_tab = 'theme'; } +$link = conf('web_path') . $target; + +/* CSS construction bs */ +$link_active = "a_" . $current_tab; +${$link_active} = "id=\"current\""; +$tab_active = "tab_" .$current_tab; +${$tab_active} = "id=\"tabactive\""; + /* I'm cheating a little here, check to see if we want to show the * Apply to All button on this page */ @@ -33,43 +47,58 @@ if (($GLOBALS['user']->has_access(100)) AND ($user_id == '-1' AND conf('use_auth $show_apply_to_all = true; } ?> -<table class="text-box"> -<tr> - <td> - <span class="header1"> - <?php echo _("Editing"); ?> <?php echo $fullname; ?> <?php echo _("preferences"); ?> - <?php if ($GLOBALS['user']->has_access(100)) { ?> - [<a href="<?php echo conf('web_path'); ?>/admin/preferences.php?action=fix_preferences&user_id=<?php echo $user_id; ?>"><?php echo _("Rebuild Preferences"); ?></a>] - <?php } ?> - </span> - <form method="post" name="preferences" action="<?php echo conf('web_path'); ?><?php echo $target; ?>" enctype="multipart/form-data"> - <table cellspacing="10"> - <tr> - <td valign="top"><?php show_preference_box($preferences['theme']); ?></td> - <?php if (isset($preferences['system'])) { ?> - <td valign="top"><?php show_preference_box($preferences['system']); ?></td> - <?php } else { ?> - <td valign="top"> </td> - <?php } ?> - </tr> - <tr> - <td valign="top"><?php show_preference_box($preferences['streaming']); ?></td> - <td> </td> - </tr> - <tr> - <td valign="top"><?php show_preference_box($preferences['interface']); ?></td> - <td> </td> - </tr> - <tr> - <td valign="top"><?php show_preference_box($preferences['options']); ?></td> - <td> </td> - </tr> - </table> - <input class="button" type="submit" value="<?php echo _("Update Preferences"); ?>" /> - <input type="hidden" name="action" value="update_preferences" /> - <input type="hidden" name="user_id" value="<?php echo $user_id; ?>" /> - <input class="button" type="submit" name="action" value="<?php echo _("Cancel"); ?>" /> - </form> - </td> -</tr> -</table> +<span class="header1"> +<?php echo _("Editing"); ?> <?php echo $fullname; ?> <?php echo _("preferences"); ?> +<?php if ($GLOBALS['user']->has_access(100)) { ?> +[<a href="<?php echo conf('web_path'); ?>/admin/preferences.php?action=fix_preferences&user_id=<?php echo $user_id; ?>"><?php echo _("Rebuild Preferences"); ?></a>] +<?php } ?> +</span> + + +<ul> +<div id="tabcontainer"> +<ul id="tablist"> +<li <?php echo $tab_theme; ?>> + <a href="<?php echo $link; ?>?tab=theme&user_id=<?php echo $user_id; ?>" <?php echo $a_theme; ?>>Theme</a> +</li> +<li <?php echo $tab_streaming; ?>> + <a href="<?php echo $link; ?>?tab=streaming&user_id=<?php echo $user_id; ?>" <?php echo $a_streaming; ?>>Streaming</a> +</li> +<li <?php echo $tab_interface; ?>> + <a href="<?php echo $link; ?>?tab=interface&user_id=<?php echo $user_id; ?>" <?php echo $a_interface; ?>>Interface</a> +</li> +<li <?php echo $tab_options; ?>> + <a href="<?php echo $link; ?>?tab=options&user_id=<?php echo $user_id; ?>" <?php echo $a_options; ?>>Options</a> +</li> +<?php if ($user_id != '-1') { ?> +<li <?php echo $tab_account; ?>> + <a href="<?php echo $link; ?>?tab=account&user_id=<?php echo $user_id; ?>" <?php echo $a_account; ?>>Account</a> +</li> +<?php } else { ?> +<li <?php echo $tab_system; ?>> + <a href="<?php echo $link; ?>?tab=system&user_id=<?php echo $user_id; ?>" <?php echo $a_system; ?>>System</a> +</li> +<?php } ?> +</ul> +</div> +<div class="text-box"> +<form method="post" name="preferences" action="<?php echo conf('web_path'); ?><?php echo $target; ?>" enctype="multipart/form-data"> +<?php +if ($current_tab != 'account') { + show_preference_box($preferences[$current_tab]); +?> + <input class="button" type="submit" value="<?php echo _("Update Preferences"); ?>" /> + <input type="hidden" name="action" value="update_preferences" /> + <input type="hidden" name="user_id" value="<?php echo $user_id; ?>" /> + <input type="hidden" name="tab" value="<?php echo scrub_out($current_tab); ?>" /> + <input class="button" type="submit" name="action" value="<?php echo _("Cancel"); ?>" /> +<?php + } + + else { + $this_user = new User($user_id); + require (conf('prefix') . '/templates/show_user.inc.php'); + } +?> +</form> +</div> diff --git a/templates/show_user.inc.php b/templates/show_user.inc.php index 9d59d5ea..eeb32f9b 100644 --- a/templates/show_user.inc.php +++ b/templates/show_user.inc.php @@ -20,73 +20,50 @@ */ ?> -<br /><br /> -<div class="text-box"> -<form name="update_user" method="post" action="<?php echo conf('web_path'); ?>/user.php?action=update_user" enctype="multipart/form-data" > - <p class="header2"><?php echo _("Changing User Information for") . " " . $this_user->fullname; ?></p> - <table> - <tr> - <td> - <?php echo _("Name"); ?>: - </td> - <td> - <input type="text" name="fullname" size="30" value="<?php echo $this_user->fullname; ?>" /> - </td> - </tr> - - <tr> - <td> - <?php echo _("E-mail"); ?>: - </td> - <td> - <input type="text" name="email" size="30" value="<?php echo $this_user->email; ?>" /> - </td> - </tr> - <tr> - <td> - <?php echo _("Results Per Page"); ?>: - </td> - <td> - <input type="text" name="offset_limit" size="5" value="<?php echo $this_user->offset_limit; ?>" /> - </td> - </tr> - </table> - <input type="hidden" name="user_id" value="<?php echo $this_user->username; ?>" /> - <input type="submit" name="action" value="<?php echo _("Update Profile"); ?>" /> -</form> -</div> -<br /> -<div class="text-box"> -<form name="change_password" method="post" action="<?php echo conf('web_path'); ?>/user.php?action=change_password" enctype="multipart/form-data" > - <span class="header2">Changing User Password</span> - <?php $GLOBALS['error']->print_error('password'); ?> - <table border="0" cellpadding="5" cellspacing="0"> - <tr> - <td> - <?php echo _("Enter password"); ?>: - </td> - <td> - <input type="password" name="password" size="30" /> - </td> - </tr> - <tr> - <td> - <?php echo _("Confirm Password"); ?>: - </td> - <td> - <input type="password" name="confirm_password" size="30" /> - </td> - </tr> - </table> - <input type="hidden" name="user_id" value="<?php echo $this_user->username; ?>" /> - <input type="submit" name="action" value="<?php echo _("Change Password"); ?>" /> -</form> -</div> -<br /> -<div class="text-box"> -<form name="clear_statistics" method="post" action="<?php echo conf('web_path'); ?>/user.php?action=clear_stats" enctype="multipart/form-data"> - <span class="header2"><?php echo _("Delete Your Personal Statistics"); ?></span><br /> - <input type="hidden" name="user_id" value="<?php echo $this_user->username; ?>" /> - <input type="submit" value="<?php echo _("Clear Stats"); ?>" /> -</form> -</div> +<table> +<tr> + <td><?php echo _('Name'); ?>:</td> + <td> + <input type="text" name="fullname" size="27" value="<?php echo scrub_out($this_user->fullname); ?>" /> + </td> +</tr> +<tr> + <td><?php echo _('E-mail'); ?>:</td> + <td> + <input type="text" name="email" size="27" value="<?php echo scrub_out($this_user->email); ?>" /> + </td> +</tr> +<tr> + <td><?php echo _('Results Per Page'); ?>:</td> + <td> + <input type="text" name="offset_limit" size="3" value="<?php echo scrub_out($this_user->offset_limit); ?>" /> + </td> +</tr> +<tr> + <td><?php echo _('New Password'); ?>:</td> + <td> + <?php $GLOBALS['error']->print_error('password'); ?> + <input type="password" name="password1" size="27" /> + </td> +</tr> +<tr> + <td><?php echo _('Confirm Password'); ?>:</td> + <td> + <input type="password" name="password2" size="27" /> + </td> +</tr> +<tr> + <td><?php echo _('Clear Stats'); ?>:</td> + <td> + <input type="checkbox" name="clear_stats" value="1" /> + </td> +</tr> +<tr> + <td colspan="2"> + <input type="hidden" name="user_id" value="<?php echo scrub_out($this_user->id); ?>" /> + <input type="hidden" name="action" value="update_user" /> + <input type="hidden" name="tab" value="<?php echo scrub_out($current_tab); ?>" /> + <input type="submit" value="<?php echo _('Update Account'); ?>" /> + </td> +</tr> +</table> diff --git a/user.php b/user.php deleted file mode 100644 index 633d74a5..00000000 --- a/user.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php -/* - - Copyright (c) 2001 - 2005 Ampache.org - All Rights Reserved - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -require_once("modules/init.php"); - -show_template('header'); - -show_menu_items('Profile'); - -$action = scrub_in($_REQUEST['action']); -$username = $user->username; -$password = $_REQUEST['password']; -$confirm_password = scrub_in($_REQUEST['confirm_password']); -$fullname = scrub_in($_REQUEST['fullname']); -$email = scrub_in($_REQUEST['email']); -$offset = scrub_in($_REQUEST['offset_limit']); -$user_id = scrub_in($_REQUEST['user_id']); - - -switch ($action) { - - case 'Change Password': - case 'change_password': - /* Make sure the passwords match */ - if ($confirm_password !== $password || empty($password) ) { - $error->add_error('password',_("Error: Password Does Not Match or Empty")); - show_edit_profile($username); - break; - } - /* Make sure they have the rights */ - if (!$user->has_access(25) || conf('demo_mode')) { - $error->add_error('password',_("Error: Insufficient Rights")); - show_edit_profile($username); - break; - } - $this_user = new User($user_id); - $this_user->update_password($password); - show_confirmation("User Updated","Password updated for " . $this_user->username,"user.php?action=show_edit_profile"); - break; - case 'Update Profile': - case 'update_user': - if (!$user->has_access(25) || conf('demo_mode')) { - $error->add_error('general',_("Error: Insufficient Rights")); - show_edit_profile($username); - break; - } // no rights! - $this_user = new User($user_id); - $this_user->update_fullname($fullname); - $this_user->update_email($email); - $this_user->update_offset($offset); - show_confirmation("User Updated","User Information for " . $this_user->username . " has been updated","user.php?action=show_edit_profile"); - break; - case 'Clear Stats': - case 'clear_stats': - $this_user = new User($user_id); - $this_user->delete_stats(); - show_confirmation("Statistics Cleared","Your Personal Statistics have been cleared","user.php?action=show_edit_profile"); - break; - case 'show_edit_profile': - default: - show_edit_profile($username); - break; -} // end action switch - -show_page_footer ('Profile', '',$user->prefs['display_menu']); -?> |