diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-10-15 08:57:52 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-10-15 08:57:52 +0000 |
commit | 637656f08dfde4f8843cfaef257e2a2a3c49d770 (patch) | |
tree | 052a9ff6423a24fff04f49675fad7f79aead5cc4 /lib | |
parent | 8cae71c489090f2c59822d04b1622520b8e6b1b0 (diff) | |
download | ampache-637656f08dfde4f8843cfaef257e2a2a3c49d770.tar.gz ampache-637656f08dfde4f8843cfaef257e2a2a3c49d770.tar.bz2 ampache-637656f08dfde4f8843cfaef257e2a2a3c49d770.zip |
added db update for tmp playlist and added initial class definition
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/tmp_playlist.class.php | 81 | ||||
-rw-r--r-- | lib/class/update.class.php | 58 | ||||
-rw-r--r-- | lib/init.php | 5 |
3 files changed, 138 insertions, 6 deletions
diff --git a/lib/class/tmp_playlist.class.php b/lib/class/tmp_playlist.class.php new file mode 100644 index 00000000..7c29c235 --- /dev/null +++ b/lib/class/tmp_playlist.class.php @@ -0,0 +1,81 @@ +<?php +/* + + Copyright (c) 2001 - 2006 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. + +*/ +/** + * TempPlaylist Class + * This class handles the temporary playlists in ampache, it handles the + * tmp_playlist and tmp_playlist_data tables, and sneaks out at night to + * visit user_vote from time to time + */ +class tmpPlaylist { + + /* Variables from the Datbase */ + var $id; + var $session; + var $type; + var $object_type; + var $base_playlist; + + /* Generated Elements */ + var $items = array(); + + + /** + * Constructor + * This takes a playlist_id as an optional argument and gathers the information + * if not playlist_id is passed returns false (or if it isn't found + */ + function tmpPlaylist($playlist_id = 0) { + + if (!$playlist_id) { return false; } + + $this->id = intval($playlist_id); + $info = $this->_get_info(); + + /* If we get something back */ + if (count($info)) { + $this->session = $info['session']; + $this->type = $info['type']; + $this->object_type = $info['object_type']; + $this->base_playlist = $info['base_playlist']; + } + + return true; + + } // tmpPlaylist + + /** + * _get_info + * This is an internal (private) function that gathers the information for this object from the + * playlist_id that was passed in. + */ + function _get_info() { + + $sql = "SELECT * FROM tmp_playlist WHERE id='" . sql_escape($this->id) . "'"; + $db_results = mysql_query($sql, dbh()); + + $results = mysql_fetch_assoc($db_results); + + return $results; + + } // _get_info + +} // class tmpPlaylist diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 872b556b..ae45cffc 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -293,6 +293,11 @@ class Update { $version[] = array('version' => '332013','description' => $update_string); + $update_string = '- Added tmp_playlist tables to allow for <<democratic playback>>.<br />' . + '- Added hash field to song table to allow for some new optional cataloging functionality.<br />' . + '- Added vote tables to allow users to vote on localplay.<br />'; + + $version[] = array('version' => '333000','description' => $update_string); return $version; @@ -341,7 +346,6 @@ class Update { $sql = "DELETE * FROM session"; $db_results = mysql_query($sql, dbh()); - $methods = array(); $current_version = $this->get_version(); @@ -354,7 +358,6 @@ class Update { foreach ($this->versions as $version) { - // If it's newer than our current version // let's see if a function exists and run the // bugger @@ -1825,5 +1828,56 @@ class Update { } // update_332013 + + /** + * update_333000 + * This adds tmp_playlist hotness and adds md5 field + * back to song table for potential use by the file + * moving magic code + */ + function update_333000() { + + $sql = "ALTER TABLE `song` ADD `hash` VARCHAR( 255 ) NOT NULL"; + $db_results = mysql_query($sql, dbh()); + + $sql = "CREATE TABLE `tmp_playlist` (". + "`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,". + "`session` VARCHAR( 32 ) NOT NULL ,". + "`type` VARCHAR( 32 ) NOT NULL ,". + "`object_type` VARCHAR( 32 ) NOT NULL ,". + "`base_playlist` INT( 11 ) UNSIGNED NOT NULL". + ")"; + $db_results = mysql_query($sql, dbh()); + + $sql = "ALTER TABLE `tmp_playlist` ADD INDEX ( `session` )"; + $db_results = mysql_query($sql, dbh()); + + $sql = "ALTER TABLE `tmp_playlist` ADD INDEX ( `type` )"; + $db_results = mysql_query($sql, dbh()); + + $sql = "CREATE TABLE `tmp_playlist_data` (". + "`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,". + "`tmp_playlist` INT( 11 ) UNSIGNED NOT NULL ,". + "`object_id` INT( 11 ) UNSIGNED NOT NULL)"; + $db_results = mysql_query($sql, dbh()); + + $sql = "ALTER TABLE `tmp_playlist_data` ADD INDEX ( `tmp_playlist` )"; + $db_results = mysql_query($sql, dbh()); + + $sql = "CREATE TABLE `user_vote` (" . + "`user` VARCHAR( 64 ) NOT NULL ," . + "`object_id` INT( 11 ) UNSIGNED NOT NULL)"; + $db_results = mysql_query($sql, dbh()); + + $sql = "ALTER TABLE `user_vote` ADD INDEX ( `user` )"; + $db_results = mysql_query($sql, dbh()); + + $sql = "ALTER TABLE `user_vote` ADD INDEX ( `object_id` )"; + $db_results = mysql_query($sql, dbh()); + + $this->set_version('db_version','333000'); + + } // update_333000 + } // end update class ?> diff --git a/lib/init.php b/lib/init.php index 9bd90a4d..96eef2c5 100644 --- a/lib/init.php +++ b/lib/init.php @@ -178,6 +178,7 @@ require_once(conf('prefix') . '/lib/class/localplay.class.php'); require_once(conf('prefix') . '/lib/class/catalog.class.php'); require_once(conf('prefix') . '/lib/class/stream.class.php'); require_once(conf('prefix') . '/lib/class/playlist.class.php'); +require_once(conf('prefix') . '/lib/class/tmp_playlist.class.php'); require_once(conf('prefix') . '/lib/class/song.class.php'); require_once(conf('prefix') . '/lib/class/view.class.php'); require_once(conf('prefix') . '/lib/class/update.class.php'); @@ -201,10 +202,6 @@ if ($results['memory_limit'] < 16) { } set_memory_limit($results['memory_limit']); -if (ini_get('short_open_tag') != "On") { - ini_set (short_open_tag, "On"); -} - // Check Session GC mojo, increase if need be $gc_probability = @ini_get('session.gc_probability'); $gc_divisor = @ini_get('session.gc_divisor'); |