diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/catalog.class.php | 2 | ||||
-rw-r--r-- | lib/class/playlist.class.php | 3 | ||||
-rw-r--r-- | lib/class/update.class.php | 45 | ||||
-rw-r--r-- | lib/class/user.class.php | 127 | ||||
-rw-r--r-- | lib/init.php | 3 | ||||
-rw-r--r-- | lib/preferences.php | 8 |
6 files changed, 102 insertions, 86 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; 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); |