summaryrefslogtreecommitdiffstats
path: root/lib/class
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-06-17 23:59:04 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-06-17 23:59:04 +0000
commit56c960c34a17746beeec455fc225428360d5d91d (patch)
tree85fae55dbb16f1c42109b85549f3853fd270ba7f /lib/class
parentb032ac027e531b992a62b1af5d19e865e28e8b7d (diff)
downloadampache-56c960c34a17746beeec455fc225428360d5d91d.tar.gz
ampache-56c960c34a17746beeec455fc225428360d5d91d.tar.bz2
ampache-56c960c34a17746beeec455fc225428360d5d91d.zip
fixed some issues with the installer, and also made it so that you can delete/disable users again
Diffstat (limited to 'lib/class')
-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
4 files changed, 95 insertions, 82 deletions
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;