1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 17:59:21 +02:00

Resolve #401 new database update, reset album thumbs and use resized art...

This commit is contained in:
Karl 'vollmerk' Vollmer 2009-03-01 02:35:42 +00:00
parent c9ccb05a40
commit e474991d13
14 changed files with 94 additions and 38 deletions

View file

@ -29,6 +29,7 @@ class Catalog extends database_object {
public $name;
public $last_update;
public $last_add;
public $last_clean;
public $key;
public $rename_pattern;
public $sort_pattern;
@ -144,6 +145,7 @@ class Catalog extends database_object {
$this->f_path = truncate_with_ellipsis($this->path,Config::get('ellipse_threshold_title'));
$this->f_update = $this->last_update ? date('d/m/Y h:i',$this->last_update) : _('Never');
$this->f_add = $this->last_add ? date('d/m/Y h:i',$this->last_add) : _('Never');
$this->f_clean = $this->last_clean ? date('d/m/Y h:i',$this->last_clean) : _('Never');
} // format
@ -908,7 +910,7 @@ class Catalog extends database_object {
$date = time();
$sql = "UPDATE `catalog` SET `last_update`='$date' WHERE `id`='$this->id'";
$db_results = Dba::query($sql);
$db_results = Dba::write($sql);
} // update_last_update
@ -917,14 +919,26 @@ class Catalog extends database_object {
* updates the last_add of the catalog
* @package Catalog
*/
function update_last_add() {
public function update_last_add() {
$date = time();
$sql = "UPDATE `catalog` SET `last_add`='$date' WHERE `id`='$this->id'";
$db_results = Dba::query($sql);
$db_results = Dba::write($sql);
} // update_last_add
/**
* update_last_clean
* This updates the last clean information
*/
public function update_last_clean() {
$date = time();
$sql = "UPDATE `catalog` SET `last_clean`='$date' WHERE `id`='$this->id'";
$db_results = Dba::write($sql);
} // update_last_clean
/**
* update_settings
* This function updates the basic setting of the catalog
@ -1515,6 +1529,9 @@ class Catalog extends database_object {
show_box_bottom();
flush();
// Set the last clean date
$this->update_last_clean();
} //clean_catalog
/**
@ -1765,7 +1782,7 @@ class Catalog extends database_object {
$cached_results = array_merge($songs,$videos);
$number = count($results);
$number = count($cached_results);
require_once Config::get('prefix') . '/templates/show_verify_catalog.inc.php';
flush();
@ -1994,8 +2011,8 @@ class Catalog extends database_object {
}
// Check to see if we've seen this album before
if (isset(self::$albums[$album][$year][$disk])) {
return self::$albums[$album][$year][$disk];
if (isset(self::$albums[$album][$album_year][$disk])) {
return self::$albums[$album][$album_year][$disk];
}
/* Setup the Query */
@ -2040,7 +2057,7 @@ class Catalog extends database_object {
}
// Save the cache
self::$albums[$album][$year][$disk] = $album_id;
self::$albums[$album][$album_year][$disk] = $album_id;
return $album_id;

View file

@ -137,15 +137,10 @@ class Playlist extends database_object {
$results = array();
$sql = "SELECT `id`,`object_id`,`object_type`,`dynamic_song`,`track` FROM `playlist_data` WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY `track`";
$sql = "SELECT `id`,`object_id`,`object_type`,`track` FROM `playlist_data` WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY `track`";
$db_results = Dba::query($sql);
while ($row = Dba::fetch_assoc($db_results)) {
if (strlen($row['dynamic_song'])) {
// Do something here FIXME!
}
$results[] = array('type'=>$row['object_type'],'object_id'=>$row['object_id'],'track'=>$row['track'],'track_id'=>$row['id']);
} // end while
@ -163,16 +158,12 @@ class Playlist extends database_object {
$limit_sql = $limit ? 'LIMIT ' . intval($limit) : '';
$sql = "SELECT `object_id`,`object_type`,`dynamic_song` FROM `playlist_data` " .
$sql = "SELECT `object_id`,`object_type` FROM `playlist_data` " .
"WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY RAND() $limit_sql";
$db_results = Dba::query($sql);
while ($row = Dba::fetch_assoc($db_results)) {
if (strlen($row['dynamic_song'])) {
// Do something here FIXME!!!
}
$results[] = array('type'=>$row['object_type'],'object_id'=>$row['object_id']);
} // end while

View file

@ -307,6 +307,15 @@ class Update {
$version[] = array('version'=>'350006','description'=>$update_string);
$update_string = '- Remove unused fields from catalog, playlist, playlist_data<br />' .
'- Add tables for dynamic playlists<br />' .
'- Add last_clean to catalog table<br />' .
'- Add track to tmp_playlist_data<br />' .
'- Increase Thumbnail blob size<br />';
$version[] = array('version'=>'350007','description'=>$update_string);
return $version;
} // populate_version
@ -1629,10 +1638,10 @@ class Update {
public static function update_350007() {
// We need to clear the thumbs as they will need to be re-generated
$sql = "UPDATE `album_data` SET `thumb`=NULL";
$sql = "UPDATE `album_data` SET `thumb`=NULL,`thumb_mime`=NULL";
$db_results = Dba::write($sql);
$sql = "UPDATE `artist_data` SET `thumb`=NULL";
$sql = "UPDATE `artist_data` SET `thumb`=NULL,`thumb_mime`=NULL";
$db_results = Dba::write($sql);
// Change the db thumb sizes
@ -1663,7 +1672,24 @@ class Update {
$sql = "ALTER TABLE `catalog` DROP `add_path`";
$db_results = Dba::write($sql);
$sql = "CREATE TABLE `dynamic_playlist` (" .
"`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ," .
"`name` VARCHAR( 255 ) NOT NULL ," .
"`user` INT( 11 ) NOT NULL ," .
"`date` INT( 11 ) UNSIGNED NOT NULL ," .
"`type` VARCHAR( 128 ) NOT NULL" .
") ENGINE = MYISAM ";
$db_results = Dba::write($sql);
$sql = "CREATE TABLE `dynamic_playlist_data` (" .
"`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ," .
"`dynamic_id` INT( 11 ) UNSIGNED NOT NULL ," .
"`field` VARCHAR( 255 ) NOT NULL ," .
"`internal_operator` VARCHAR( 64 ) NOT NULL ," .
"`external_operator` VARCHAR( 64 ) NOT NULL ," .
"`value` VARCHAR( 255 ) NOT NULL" .
") ENGINE = MYISAM";
$db_results = Dba::write($sql);
self::set_version('db_version','350007');

View file

@ -107,12 +107,14 @@ class vauth {
/**
* destroy
* This removes the specified sessoin from the database
* This removes the specified session from the database
*/
public static function destroy($key) {
$key = Dba::escape($key);
if (!strlen($key)) { return false; }
// Remove anything and EVERYTHING
$sql = "DELETE FROM `session` WHERE `id`='$key'";
$db_results = Dba::query($sql);