diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-06-11 05:16:20 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-06-11 05:16:20 +0000 |
commit | 689517e332c874ac09bb41398602622a1fc36af8 (patch) | |
tree | c97a077bd164e594211ed213405eb0cfbbf77b1c | |
parent | 7327a025db941554501bbbe79c057fa308fb205c (diff) | |
download | ampache-689517e332c874ac09bb41398602622a1fc36af8.tar.gz ampache-689517e332c874ac09bb41398602622a1fc36af8.tar.bz2 ampache-689517e332c874ac09bb41398602622a1fc36af8.zip |
fixed preferences mostly, also fixed some genre issues and other stuff I am forgetting now
-rw-r--r-- | admin/catalog.php | 4 | ||||
-rw-r--r-- | albums.php | 41 | ||||
-rw-r--r-- | browse.php | 2 | ||||
-rw-r--r-- | genre.php | 20 | ||||
-rw-r--r-- | index.php | 3 | ||||
-rw-r--r-- | lib/class/album.class.php | 2 | ||||
-rw-r--r-- | lib/class/genre.class.php | 34 | ||||
-rw-r--r-- | lib/class/localplay.class.php | 18 | ||||
-rw-r--r-- | lib/class/user.class.php | 2 | ||||
-rw-r--r-- | lib/localplay.lib.php | 12 | ||||
-rw-r--r-- | lib/preferences.php | 61 | ||||
-rw-r--r-- | lib/ui.lib.php | 8 | ||||
-rw-r--r-- | modules/localplay/httpq.controller.php | 9 | ||||
-rw-r--r-- | modules/localplay/mpd.controller.php | 8 | ||||
-rw-r--r-- | preferences.php | 100 | ||||
-rw-r--r-- | templates/show_genre.inc.php | 4 | ||||
-rw-r--r-- | templates/show_genres.inc.php | 2 | ||||
-rw-r--r-- | templates/show_preference_box.inc.php | 21 | ||||
-rw-r--r-- | templates/show_preferences.inc.php | 52 | ||||
-rw-r--r-- | templates/sidebar_preferences.inc.php | 9 |
20 files changed, 163 insertions, 249 deletions
diff --git a/admin/catalog.php b/admin/catalog.php index fa9b35fb..8f07f094 100644 --- a/admin/catalog.php +++ b/admin/catalog.php @@ -210,9 +210,9 @@ switch ($_REQUEST['action']) { require Config::get('prefix') . '/templates/show_add_catalog.inc.php'; break; case 'clear_now_playing': - if (conf('demo_mode')) { break; } + if (Config::get('demo_mode')) { break; } clear_now_playing(); - show_confirmation(_('Now Playing Cleared'),_('All now playing data has been cleared'),conf('web_path') . '/admin/index.php'); + show_confirmation(_('Now Playing Cleared'),_('All now playing data has been cleared'),Config::get('web_path') . '/admin/index.php'); break; case 'show_clear_stats': /* Demo Bad! */ @@ -31,15 +31,6 @@ switch ($_REQUEST['action']) { $album->clear_art(); show_confirmation(_('Album Art Cleared'),_('Album Art information has been removed from the database'),"/albums.php?action=show&album=" . $album->id); break; - case 'show': - $album = new Album($_REQUEST['album']); - $album->format(); - - require Config::get('prefix') . '/templates/show_album.inc'; - - /* Get the song ids for this album */ - $song_ids = $album->get_songs(0,$_REQUEST['artist']); - break; // Upload album art case 'upload_art': @@ -177,21 +168,7 @@ switch ($_REQUEST['action']) { show_box_bottom(); break; // Browse by Album - default: - if (strlen($_REQUEST['match']) < '1') { $match = 'a'; } - - // Setup the View Ojbect - $view = new View(); - $view->import_session_view(); - - if ($match == 'Show_all' || $match == 'Show_missing_art' || $match == 'Browse') { $chr = ''; } - else { $chr = $match; } - - require (conf('prefix') . '/templates/show_box_top.inc.php'); - show_alphabet_list('albums','albums.php',$match); - show_alphabet_form($chr,_('Show Albums starting with'),"albums.php?action=match"); - require (conf('prefix') . '/templates/show_box_bottom.inc.php'); - + case 'broken': switch($match) { case 'Show_all': $offset_limit = 99999; @@ -263,5 +240,21 @@ switch ($_REQUEST['action']) { break; } // end switch on action + +/** + * switch on view + */ +switch ($_REQUEST['action']) { + case 'show': + $album = new Album($_REQUEST['album']); + $album->format(); + + require Config::get('prefix') . '/templates/show_album.inc.php'; + + /* Get the song ids for this album */ + $song_ids = $album->get_songs(0,$_REQUEST['artist']); + break; +} // switch on view + show_footer(); ?> @@ -36,7 +36,7 @@ require_once 'lib/init.php'; /* Display the headers and menus */ -require_once Config::get('prefix') . '/templates/header.inc.php'; +show_header(); echo '<div id="browse_content">'; switch($_REQUEST['action']) { @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -23,26 +23,28 @@ * Genres Pages * Nuff Said for now */ -require_once('lib/init.php'); +require_once 'lib/init.php'; -show_template('header'); +show_header(); -$action = scrub_in($_REQUEST['action']); - -switch($action) { +/** + * switch on action + */ +switch($_REQUEST['action']) { case 'show_songs': $genre = new Genre($_REQUEST['genre_id']); show_genre($_REQUEST['genre_id']); $songs = $genre->get_songs(); - show_songs($songs); break; case 'show_genre': default: case 'show_albums': $genre = new Genre($_REQUEST['genre_id']); show_genre($_REQUEST['genre_id']); - $albums = $genre->get_albums(); - require (conf('prefix') . '/templates/show_albums.inc.php'); + $object_ids = $genre->get_albums(); + show_box_top(_('Albums')); + require Config::get('prefix') . '/templates/show_albums.inc.php'; + show_box_bottom(); break; case 'show_artists': $genre = new Genre($_REQUEST['genre_id']); @@ -20,7 +20,8 @@ */ require_once 'lib/init.php'; -require_once Config::get('prefix') . '/templates/header.inc.php'; + +show_header(); $action = scrub_in($_REQUEST['action']); 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 diff --git a/modules/localplay/httpq.controller.php b/modules/localplay/httpq.controller.php index b6d26445..184d6e81 100644 --- a/modules/localplay/httpq.controller.php +++ b/modules/localplay/httpq.controller.php @@ -30,20 +30,19 @@ class AmpacheHttpq { /* Constructed variables */ - var $_httpq; + private $_httpq; /** * Constructor * This returns the array map for the localplay object * REQUIRED for Localplay */ - function AmpacheHttpq() { + public function __construct() { /* Do a Require Once On the needed Libraries */ - require_once(conf('prefix') . '/modules/httpq/httpqplayer.class.php'); - - } // AmpacheHttpq + require_once Config::get('prefix') . '/modules/httpq/httpqplayer.class.php'; + } // Constructor /** * function_map diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php index c002d299..c38c8a63 100644 --- a/modules/localplay/mpd.controller.php +++ b/modules/localplay/mpd.controller.php @@ -30,17 +30,17 @@ class AmpacheMpd { /* Constructed variables */ - var $_mpd; + private $_mpd; /** * Constructor * This returns the array map for the localplay object * REQUIRED for Localplay */ - function AmpacheMpd() { + public function __construct() { /* Do a Require Once On the needed Libraries */ - require_once(conf('prefix') . '/modules/mpd/mpd.class.php'); + require_once Config::get('prefix') . '/modules/mpd/mpd.class.php'; } // AmpacheMpd @@ -51,7 +51,7 @@ class AmpacheMpd { * that this player supports and their names in this local * class. This is a REQUIRED function */ - function function_map() { + public function function_map() { $map = array(); diff --git a/preferences.php b/preferences.php index 8f8423c2..a83890d2 100644 --- a/preferences.php +++ b/preferences.php @@ -24,81 +24,57 @@ require 'lib/init.php'; /* Scrub in the needed mojo */ if (!$_REQUEST['tab']) { $_REQUEST['tab'] = 'interface'; } -$user_id = scrub_in($_REQUEST['user_id']); // Switch on the action switch($_REQUEST['action']) { - case 'update_user': - /* Verify permissions */ - if (!$GLOBALS['user']->has_access(25) || Config::get('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']); - - - /* 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']); + case 'update_preferences': + if ($_REQUEST['method'] == 'admin' && !$GLOBALS['user']->has_access('100')) { + access_denied(); + exit; + } - /* Haha I'm fired... it's not an error but screw it */ - $GLOBALS['error']->add_error('password',_('Password Updated')); + /* Reset the Theme */ + if ($_REQUEST['method'] == 'admin') { + $user_id = '-1'; + $fullname = _('Server'); } + else { + $user_id = $GLOBALS['user']->id; + $fullname = $GLOBALS['user']->fullname; + } - /* Check for stats */ - if ($_REQUEST['clear_stats'] == '1') { - $this_user->delete_stats(); - } - break; - case 'update_preferences': - - /* Do the work */ + /* Update and reset preferences */ update_preferences($user_id); - - /* Reload the Preferences */ - $GLOBALS['user']->set_preferences(); - - /* Reset the conf values */ init_preferences(); - /* Reset the Theme */ - set_theme(); - default: - if (!$user_id) { $user_id = $GLOBALS['user']->id; } - $preferences = $GLOBALS['user']->get_preferences(0,$_REQUEST['tab']); + $preferences = $GLOBALS['user']->get_preferences($user_id,$_REQUEST['tab']); + break; + case 'admin': + // Make sure only admins here + if (!$GLOBALS['user']->has_access('100')) { + access_denied(); + exit; + } + $fullname= _('Server'); + $preferences = $GLOBALS['user']->get_preferences(-1,$_REQUEST['tab']); + break; + default: + $fullname = $GLOBALS['user']->fullname; + $preferences = $GLOBALS['user']->get_preferences(0,$_REQUEST['tab']); break; - } // End Switch Action -if (!$GLOBALS['user']->fullname) { - $fullname = "Site"; -} -else { - $fullname = $GLOBALS['user']->fullname; -} - - -// HEADER -require_once Config::get('prefix') . '/templates/header.inc.php'; -// HEADER - -// Set Target -$target = "/preferences.php"; - -// Show the default preferences page -require Config::get('prefix') . '/templates/show_preferences.inc.php'; +show_header(); +/** + * switch on the view + */ +switch ($_REQUEST['action']) { + default: + // Show the default preferences page + require Config::get('prefix') . '/templates/show_preferences.inc.php'; + break; +} // end switch on action -// FOOTER show_footer(); ?> diff --git a/templates/show_genre.inc.php b/templates/show_genre.inc.php index 5e9466d9..1eb1cc14 100644 --- a/templates/show_genre.inc.php +++ b/templates/show_genre.inc.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -24,7 +24,7 @@ * This shows a single genre and lets you pick between * albums/artists or songs */ -$web_path = conf('web_path'); +$web_path = Config::get('web_path'); ?> <?php show_box_top(_('Viewing') . " " . $genre->name . " " . _('Genre')); ?> [<?php echo $genre->get_album_count(); ?>] diff --git a/templates/show_genres.inc.php b/templates/show_genres.inc.php index e3ae1223..bd7b0a3d 100644 --- a/templates/show_genres.inc.php +++ b/templates/show_genres.inc.php @@ -39,7 +39,7 @@ <?php foreach ($object_ids as $genre_id) { $genre = new Genre($genre_id); - $genre->format_genre(); + $genre->format(); ?> <tr class="<?php echo flip_class(); ?>"> <td> diff --git a/templates/show_preference_box.inc.php b/templates/show_preference_box.inc.php index eedaa2b7..7fa4ae72 100644 --- a/templates/show_preference_box.inc.php +++ b/templates/show_preference_box.inc.php @@ -22,32 +22,33 @@ /* I'm cheating a little here, check to see if we want to show the * Apply to All button on this page */ -if ($GLOBALS['user']->has_access(100) AND Config::get('use_auth')) { - $show_apply_to_all = true; +if (($GLOBALS['user']->has_access(100) OR !Config::get('use_auth')) AND $_REQUEST['action'] == 'admin') { + $is_admin = true; } ?> - - <table class="tabledata" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr class="odd"> - <th colspan="3" class="header2" align="left"><?php echo $preferences['title']; ?></th> + <th colspan="5" class="header2" align="left"><?php echo $preferences['title']; ?></th> </tr> <tr class="table-header"> <th><?php echo _('Preference'); ?></th> <th><?php echo _('Value'); ?></th> - <?php if ($show_apply_to_all) { ?> - <th><?php echo _('Apply to All'); ?></th> + <?php if ($is_admin) { ?> + <th><?php echo _('Apply to All'); ?></th> + <th><?php echo _('Access Level'); ?></th> <?php } ?> </tr> -<?php -foreach ($preferences['prefs'] as $pref) { ?> +<?php foreach ($preferences['prefs'] as $pref) { ?> <tr class="<?php echo flip_class(); ?>"> <td><?php echo _($pref['description']); ?></td> <td> <?php create_preference_input($pref['name'], $pref['value']); ?> </td> - <?php if ($show_apply_to_all) { ?> + <?php if ($is_admin) { ?> <td align="center"><input type="checkbox" name="check_<?php echo $pref['name']; ?>" value="1" /></td> + <td align="center"> + + </td> <?php } ?> </tr> <?php } // End foreach ($preferences['prefs'] as $pref) ?> diff --git a/templates/show_preferences.inc.php b/templates/show_preferences.inc.php index 22843bfb..31500393 100644 --- a/templates/show_preferences.inc.php +++ b/templates/show_preferences.inc.php @@ -23,63 +23,19 @@ * 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 = 'interface'; } -// HORRIBLE HACK! -if ($_REQUEST['action'] == 'user') { $action_txt = '&action=user'; } -$link = Config::get('web_path') . $target; -/* CSS construction bs */ -$link_active = "a_" . $current_tab; -${$link_active} = "id=\"current\""; -$tab_active = "tab_" .$current_tab; -${$tab_active} = "id=\"tabactive\""; ?> -<?php show_box_top(); ?> -<span class="header1"> -<?php echo _('Editing'); ?> <?php echo $fullname; ?> <?php echo _('preferences'); ?> -<?php if ($GLOBALS['user']->has_access(100)) { ?> -[<a href="<?php echo Config::get('web_path'); ?>/admin/preferences.php?action=fix_preferences&user_id=<?php echo $user_id; ?>"><?php echo _('Rebuild Preferences'); ?></a>] -<?php } ?> -</span> - -<div id="tabcontainer"> -<ul id="tablist"> -<li <?php echo $tab_interface; ?>> - <a href="<?php echo $link; ?>?tab=interface&user_id=<?php echo $user_id . $action_txt; ?>" <?php echo $a_interface; ?>><?php echo _('Interface'); ?></a> -</li> -<li <?php echo $tab_streaming; ?>> - <a href="<?php echo $link; ?>?tab=streaming&user_id=<?php echo $user_id . $action_txt; ?>" <?php echo $a_streaming; ?>><?php echo _('Streaming'); ?></a> -</li> -<li <?php echo $tab_options; ?>> - <a href="<?php echo $link; ?>?tab=options&user_id=<?php echo $user_id . $action_txt; ?>" <?php echo $a_options; ?>><?php echo _('Options'); ?></a> -</li> -<?php if ($user_id != '-1' && $_SESSION['userdata']['type'] == 'mysql') { ?> -<li <?php echo $tab_account; ?>> - <a href="<?php echo $link; ?>?tab=account&user_id=<?php echo $user_id . $action_txt; ?>" <?php echo $a_account; ?>><?php echo _('Account'); ?></a> -</li> -<?php } elseif ($_SESSION['userdata']['type'] == 'mysql' || $user_id == '-1') { ?> -<li <?php echo $tab_system; ?>> - <a href="<?php echo $link; ?>?tab=system&user_id=<?php echo $user_id; ?>" <?php echo $a_system; ?>><?php echo _('System'); ?></a> -</li> -<li <?php echo $tab_modules; ?>> - <a href="<?php echo $link; ?>?tab=modules&user_id=<?php echo $user_id; ?>" <?php echo $a_modules; ?>><?php echo _('Modules'); ?></a> -</li> - -<?php } ?> -</ul> -</div> -<div class="text-box" style="width:45em;"> -<form method="post" name="preferences" action="<?php echo Config::get('web_path'); ?><?php echo $target; ?>" enctype="multipart/form-data"> +<?php show_box_top(_('Editing') . ' ' . $fullname . ' ' . _('preferences')); ?> +<form method="post" name="preferences" action="<?php echo Config::get('web_path'); ?>/preferences.php?action=update_preferences" enctype="multipart/form-data"> <?php if ($current_tab != 'account' && $current_tab != 'modules') { - show_preference_box($preferences[$current_tab]); + show_preference_box($preferences[$_REQUEST['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 type="hidden" name="method" value="<?php echo scrub_out($_REQUEST['action']); ?>" /> <input class="button" type="submit" name="action" value="<?php echo _("Cancel"); ?>" /> <?php } diff --git a/templates/sidebar_preferences.inc.php b/templates/sidebar_preferences.inc.php index 14bb5c67..1b988086 100644 --- a/templates/sidebar_preferences.inc.php +++ b/templates/sidebar_preferences.inc.php @@ -1,7 +1,14 @@ <h4><?php echo _('Sections'); ?></h4> -<hr /> <span><a href="<?php echo $web_path; ?>/preferences.php?tab=interface"><?php echo _('Interface'); ?></a></span> <span><a href="<?php echo $web_path; ?>/preferences.php?tab=streaming"><?php echo _('Streaming'); ?></a></span> <span><a href="<?php echo $web_path; ?>/preferences.php?tab=options"><?php echo _('Options'); ?></a></span> <span><a href="<?php echo $web_path; ?>/preferences.php?tab=account"><?php echo _('Account'); ?></a></span> <hr /> +<?php if ($GLOBALS['user']->has_access('100')) { ?> +<h4><?php echo _('Server Config'); ?></h4> +<span><a href="<?php echo $web_path; ?>/preferences.php?action=admin&tab=interface"><?php echo _('Interface'); ?></a></span> +<span><a href="<?php echo $web_path; ?>/preferences.php?action=admin&tab=streaming"><?php echo _('Streaming'); ?></a></span> +<span><a href="<?php echo $web_path; ?>/preferences.php?action=admin&tab=options"><?php echo _('Options'); ?></a></span> +<span><a href="<?php echo $web_path; ?>/preferences.php?action=admin&tab=system"><?php echo _('System'); ?></a></span> +<hr /> +<?php } ?> |