summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/users.php16
-rw-r--r--lib/class/catalog.class.php2
-rw-r--r--lib/class/playlist.class.php3
-rw-r--r--lib/class/update.class.php45
-rw-r--r--lib/class/user.class.php127
-rw-r--r--lib/init.php3
-rw-r--r--lib/preferences.php8
-rw-r--r--templates/show_confirmation.inc.php4
-rw-r--r--templates/show_login_form.inc4
9 files changed, 114 insertions, 98 deletions
diff --git a/admin/users.php b/admin/users.php
index 56a6fcf5..677c9510 100644
--- a/admin/users.php
+++ b/admin/users.php
@@ -119,13 +119,6 @@ switch ($_REQUEST['action']) {
show_confirmation(_('New User Added'),__('%user% has been created with an access level of ' . $access,'%user%',$username),'admin/users.php');
break;
- case 'delete':
- if (conf('demo_mode')) { break; }
- $working_user = new User($user_id);
- show_confirmation(_('Deletion Request'),
- _('Are you sure you want to permanently delete') . " $working_user->fullname ($working_user->username)?",
- "admin/users.php?action=confirm_delete&user_id=$user_id",1);
- break;
case 'enable':
$working_user = new User($user_id);
$working_user->enable();
@@ -156,7 +149,7 @@ switch ($_REQUEST['action']) {
require_once Config::get('prefix') . '/templates/show_edit_user.inc.php';
break;
case 'confirm_delete':
- if (conf('demo_mode')) { break; }
+ if (Config::get('demo_mode')) { break; }
$working_user = new User($_REQUEST['user_id']);
if ($working_user->delete()) {
show_confirmation(_('User Deleted'), "$working_user->username has been Deleted","admin/users.php");
@@ -165,6 +158,13 @@ switch ($_REQUEST['action']) {
show_confirmation(_('Delete Error'), _("Unable to delete last Admin User"),"admin/users.php");
}
break;
+ case 'delete':
+ if (Config::get('demo_mode')) { break; }
+ $client = new User($user_id);
+ show_confirmation(_('Deletion Request'),
+ _('Are you sure you want to permanently delete') . " $client->fullname ($client->username)?",
+ "admin/users.php?action=confirm_delete&user_id=$user_id",1);
+ break;
/* Show IP History for the Specified User */
case 'show_ip_history':
/* get the user and their history */
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index dd1ea064..eef579ac 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -1553,7 +1553,9 @@ class Catalog {
echo "</script>\n";
flush();
+ show_box_top();
echo _('Update Finished.') . _('Checked') . " $count. $total_updated " . _('songs updated.') . "<br /><br />";
+ show_box_bottom();
return true;
diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php
index 5ee93800..a5a6fd75 100644
--- a/lib/class/playlist.class.php
+++ b/lib/class/playlist.class.php
@@ -478,9 +478,6 @@ class Playlist {
$sql = "DELETE FROM playlist WHERE id='$id'";
$db_results = mysql_query($sql, dbh());
- $sql = "DELETE FROM playlist_permission WHERE playlist='$id'";
- $db_results = mysql_query($sql, dbh());
-
return true;
} // delete
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index 85f2938c..e6328838 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -19,22 +19,21 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/*!
- @header Update Class
- @discussion this class handles updating from one version of
- maintain to the next. Versions are a 6 digit number
- 220000
- ^
- Major Revision
-
- 220000
- ^
- Minor Revision
-
- The last 4 digits are a build number...
- If Minor can't go over 9 Major can go as high as we want
-*/
-
+/**
+ * Update Class
+ * this class handles updating from one version of
+ * maintain to the next. Versions are a 6 digit number
+ * 220000
+ * ^
+ * Major Revision
+ *
+ * 220000
+ * ^
+ * Minor Revision
+ *
+ * The last 4 digits are a build number...
+ * If Minor can't go over 9 Major can go as high as we want
+ */
class Update {
public $key;
@@ -62,7 +61,7 @@ class Update {
*/
private function _get_info() {
- $sql = "SELECT * FROM update_info WHERE key='$this->key'";
+ $sql = "SELECT * FROM `update_info` WHERE `key`='$this->key'";
$db_results = Dba::query($sql);
return Dba::fetch_assoc($db_results);
@@ -589,13 +588,13 @@ class Update {
$insert_results = Dba::query($sql);
} // end while
- $sql = "RENAME TABLE `ampache`.`song_ext_data` TO `ampache`.`song_data`";
+ $sql = "RENAME TABLE `song_ext_data` TO `song_data`";
$db_results = Dba::query($sql);
- $sql = "RENAME TABLE `ampache`.`preferences` TO `ampache`.`preference`";
+ $sql = "RENAME TABLE `preferences` TO `preference`";
$db_results = Dba::query($sql);
- $sql = "RENAME TABLE `ampache`.`ratings` TO `ampache`.`rating`";
+ $sql = "RENAME TABLE `ratings` TO `rating`";
$db_results = Dba::query($sql);
// Go ahead and drop the art/thumb stuff
@@ -610,16 +609,16 @@ class Update {
$sql = "ALTER TABLE `user` DROP `offset_limit`";
$db_results = Dba::query($sql);
- $sql = "ALTER TABLE `ratings` CHANGE `user_rating` `rating` ENUM( '-1', '0', '1', '2', '3', '4', '5' ) NOT NULL DEFAULT '0'";
+ $sql = "ALTER TABLE `rating` CHANGE `user_rating` `rating` ENUM( '-1', '0', '1', '2', '3', '4', '5' ) NOT NULL DEFAULT '0'";
$db_results = Dba::query($sql);
/* Add the rate_limit preference */
- $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
+ $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
"VALUES ('rate_limit','8192','Rate Limit','100','integer','streaming')";
$db_results = Dba::query($sql);
/* Add the playlist_method preference and remove it from the user table */
- $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
+ $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
"VALUES ('playlist_method','50','Playlist Method','5','string','streaming')";
$db_results = Dba::query($sql);
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index be0bfe31..8806890b 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -18,61 +18,57 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/*!
- @header User Object
- View object that is thrown into their session
-
-*/
-
+/**
+ * User Class
+ * This class handles all of the user related functions includingn the creationg
+ * and deletion of the user objects from the database by defualt you constrcut it
+ * with a user_id from user.id
+ */
class User {
//Basic Componets
- var $id;
- var $uid; // HACK ALERT
- var $username;
- var $fullname;
- var $access;
- var $disabled;
- var $email;
- var $last_seen;
- var $create_date;
- var $validation;
+ public $id;
+ public $username;
+ public $fullname;
+ public $access;
+ public $disabled;
+ public $email;
+ public $last_seen;
+ public $create_date;
+ public $validation;
+
+ // Constructed variables
+ public $prefs = array();
/**
* Constructor
* This function is the constructor object for the user
* class, it currently takes a username
- * //FIXME take UID
*/
- function User($id=0) {
-
- if (!$id) {
- return true;
- }
+ public function __construct($user_id=0) {
- $this->id = $id;
+ $this->id = intval($user_id);
$info = $this->_get_info();
- if (!count($info)) { return false; }
foreach ($info as $key=>$value) {
// Let's not save the password in this object :S
if ($key == 'password') { continue; }
-
$this->$key = $value;
}
- $this->uid = $info->id;
+
+ // Set the preferences for thsi user
$this->set_preferences();
// Make sure the Full name is always filled
if (strlen($this->fullname) < 1) { $this->fullname = $this->username; }
- } // User
+ } // Constructor
/**
* _get_info
* This function returns the information for this object
*/
- function _get_info() {
+ private function _get_info() {
$id = Dba::escape($this->id);
@@ -447,20 +443,20 @@ class User {
* disable
* This disables the current user
*/
- function disable() {
+ public function disable() {
// Make sure we aren't disabling the last admin
$sql = "SELECT `id` FROM `user` WHERE `disabled` = '0' AND `id` != '" . $this->id . "' AND `access`='100'";
- $db_results = mysql_query($sql,dbh());
+ $db_results = Dba::query($sql);
- if (!mysql_num_rows($db_results)) { return false; }
+ if (!Dba::num_rows($db_results)) { return false; }
$sql = "UPDATE `user` SET `disabled`='1' WHERE id='" . $this->id . "'";
- $db_results = mysql_query($sql,dbh());
+ $db_results = Dba::query($sql);
// Delete any sessions they may have
- $sql = "DELETE FROM `session` WHERE `username`='" . sql_escape($this->username) . "'";
- $db_results = mysql_query($sql,dbh());
+ $sql = "DELETE FROM `session` WHERE `username`='" . Dba::escape($this->username) . "'";
+ $db_results = Dba::query($sql);
return true;
@@ -833,54 +829,73 @@ class User {
} // delete_stats
- /*!
- @function delete
- @discussion deletes this user and everything assoicated with it
- */
- function delete() {
+ /**
+ * delete
+ * deletes this user and everything assoicated with it. This will affect
+ * ratings and tottal stats
+ */
+ public function delete() {
/*
Before we do anything make sure that they aren't the last
admin
*/
if ($this->has_access(100)) {
- $sql = "SELECT `id` FROM user WHERE `access`='100' AND id !='" . sql_escape($this->id) . "'";
- $db_results = mysql_query($sql, dbh());
- if (!mysql_num_rows($db_results)) {
+ $sql = "SELECT `id` FROM `user` WHERE `access`='100' AND id !='" . Dba::escape($this->id) . "'";
+ $db_results = mysql_query($sql);
+ if (!Dba::num_rows($db_results)) {
return false;
}
} // if this is an admin check for others
// Delete their playlists
- $sql = "DELETE FROM playlist WHERE user='$this->id'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "DELETE FROM `playlist` WHERE `user`='$this->id'";
+ $db_results = Dba::query($sql);
+
+ // Clean up the playlist data table
+ $sql = "DELETE FROM `playlist_data` USING `playlist_data` " .
+ "LEFT JOIN `playlist` ON `playlist`.`id`=`playlist_data`.`playlist` " .
+ "WHERE `playlist`.`id` IS NULL";
+ $db_results = Dba::query($sql);
// Delete any stats they have
- $sql = "DELETE FROM object_count WHERE user='$this->id'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "DELETE FROM `object_count` WHERE `user`='$this->id'";
+ $db_results = Dba::query($sql);
+
+ // Clear the IP history for this user
+ $sql = "DELETE FROM `ip_history` WHERE `user`='$this->id'";
+ $db_results = Dba::query($sql);
+
+ // Nuke any access lists that are specific to this user
+ $sql = "DELETE FROM `access_list` WHERE `user`='$this->id'";
+ $db_results = Dba::query($sql);
// Delete their ratings
- $sql = "DELETE FROM `ratings` WHERE `user`='$this->id'";
- $db_results = mysql_query($sql,dbh());
+ $sql = "DELETE FROM `rating` WHERE `user`='$this->id'";
+ $db_results = Dba::query($sql);
// Delete their tags
$sql = "DELETE FROM `tag_map` WHERE `user`='$this->id'";
- $db_results = mysql_query($sql,dbh());
+ $db_results = Dba::query($sql);
// Clean out the tags
$sql = "DELETE FROM `tags` USING `tag_map` LEFT JOIN `tag_map` ON tag_map.id=tags.map_id AND tag_map.id IS NULL";
- $db_results = mysql_query($sql,dbh());
+ $db_results = Dba::query($sql);
// Delete their preferences
- $sql = "DELETE FROM user_preference WHERE `user`='$this->id'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "DELETE FROM `user_preference` WHERE `user`='$this->id'";
+ $db_results = Dba::query($sql);
+
+ // Delete their voted stuff in democratic play
+ $sql = "DELETE FROM `user_vote` WHERE `user`='$this->id'";
+ $db_results = Dba::query($sql);
// Delete the user itself
- $sql = "DELETE FROM user WHERE `id`='$this->id'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "DELETE FROM `user` WHERE `id`='$this->id'";
+ $db_results = Dba::query($sql);
- $sql = "DELETE FROM session WHERE username='" . sql_escape($this->username) . "'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "DELETE FROM `session` WHERE `username`='" . Dba::escape($this->username) . "'";
+ $db_results = Dba::query($sql);
return true;
diff --git a/lib/init.php b/lib/init.php
index a96462a1..8bccb7c8 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -244,9 +244,6 @@ unset($results);
/* Setup the flip class */
flip_class(array('odd','even'));
-/* Set the Theme */
-$theme = get_theme(Config::get('theme_name'));
-
/* Check to see if we need to perform an update */
if (! preg_match('/update\.php/', $_SERVER['PHP_SELF'])) {
if (Update::need_update()) {
diff --git a/lib/preferences.php b/lib/preferences.php
index ac8c9e50..6b603863 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -439,9 +439,15 @@ function init_preferences() {
} // end while
/* Set the Theme mojo */
- if (strlen($results['theme_name']) > 0) {
+ if (strlen($results['theme']) > 0) {
$results['theme_path'] = '/themes/' . $results['theme_name'];
}
+ // Default to the classic theme if we don't get anything from their
+ // preferenecs because we're going to want at least something otherwise
+ // the page is going to be really ugly
+ else {
+ $results['theme_path'] = '/themes/classic';
+ }
Config::set_by_array($results,1);
diff --git a/templates/show_confirmation.inc.php b/templates/show_confirmation.inc.php
index e278ed7d..84a885d9 100644
--- a/templates/show_confirmation.inc.php
+++ b/templates/show_confirmation.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
@@ -25,7 +25,7 @@
<div class="text-action">
<a href="<?php echo $path; ?>"><?php echo _('Continue'); ?></a>
<?php if ($cancel) { ?>
- <a href="<?php echo conf('web_path') . "/" . return_referer(); ?>"><?php echo _('Cancel'); ?></a>
+ <a href="<?php echo Config::get('web_path') . "/" . return_referer(); ?>"><?php echo _('Cancel'); ?></a>
<?php } ?>
</div>
<?php show_box_bottom(); ?>
diff --git a/templates/show_login_form.inc b/templates/show_login_form.inc
index b46d77ff..f5608cc1 100644
--- a/templates/show_login_form.inc
+++ b/templates/show_login_form.inc
@@ -32,8 +32,8 @@ $htmllang = str_replace("_","-",Config::get('lang'));
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo Config::get('site_charset'); ?>" />
<link rel="shortcut icon" href="<?php echo Config::get('web_path'); ?>/favicon.ico" />
-<link rel="stylesheet" href="templates/print.css" type="text/css" media="print" />
-<link rel="stylesheet" href="templates/handheld.css" type="text/css" media="handheld" />
+<link rel="stylesheet" href="<?php echo Config::get('web_path'); ?>/templates/print.css" type="text/css" media="print" />
+<link rel="stylesheet" href="<?php echo Config::get('web_path'); ?>/templates/handheld.css" type="text/css" media="handheld" />
<link rel="stylesheet" href="<?php echo Config::get('web_path'); ?><?php echo Config::get('theme_path'); ?>/templates/default.css" type="text/css" media="screen" />
<title> <?php echo Config::get('site_title'); ?> </title>
<script type="text/javascript" language="javascript">