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

@ -46,7 +46,7 @@ switch ($_REQUEST['thumb']) {
case '2':
$size['height'] = '128';
$size['width'] = '128';
$return_raw = true;
// $return_raw = true;
break;
case '3':
/* This is used by the flash player */
@ -57,7 +57,7 @@ switch ($_REQUEST['thumb']) {
default:
$size['height'] = '275';
$size['width'] = '275';
$return_raw = true;
// $return_raw = true;
break;
} // define size based on thumbnail
@ -104,7 +104,7 @@ switch ($_REQUEST['type']) {
$art_data = $art['raw'];
}
else {
$art_data = img_resize($art,$size,$extension,$_REQUEST['id']);
$art_data = img_resize($art,array('width'=>'275','height'=>'275'),$extension,$_REQUEST['id']);
}
// Send the headers and output the image

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);

View file

@ -235,9 +235,8 @@ function img_resize($image,$size,$type,$album_id) {
$width = imagesx($src);
$height = imagesy($src);
// Make it the largest always
$new_w = '275';
$new_h = '275';
$new_w = $size['width'];
$new_h = $size['height'];
$img = imagecreatetruecolor($new_w,$new_h);

View file

@ -116,12 +116,16 @@ switch ($_REQUEST['action']) {
break;
}
$songs = array();
// Itterate through and add them to our new playlist
foreach ($objects as $uid=>$object_data) {
// For now only allow songs on here, we'll change this later
if ($object_data['1'] == 'song') {
$songs[] = $object_data['0'];
}
foreach ($objects as $element) {
$type = array_shift($element);
switch ($type) {
case 'song':
$songs[] = array_shift($element);
break;
} // end switch
} // foreach
// Add our new songs

View file

@ -42,7 +42,9 @@ while ($i <= $rows) {
<br />
<p align="center">
<?php if (is_array($dimensions)) { ?>
[<?php echo intval($dimensions['width']); ?>x<?php echo intval($dimensions['heigh']); ?>]
[<?php echo intval($dimensions['width']); ?>x<?php echo intval($dimensions['height']); ?>]
<?php } else { ?>
<span class="error"><?php echo _('Invalid'); ?></span>
<?php } ?>
[<a href="<?php echo Config::get('web_path'); ?>/albums.php?action=select_art&amp;image=<?php echo $key; ?>&amp;album_id=<?php echo intval($_REQUEST['album_id']); ?>"><?php echo _('Select'); ?></a>]
</p>

View file

@ -24,6 +24,7 @@ $web_path = Config::get('web_path');
<td class="cel_path"><?php echo scrub_out($catalog->f_path); ?></td>
<td class="cel_lastverify"><?php echo scrub_out($catalog->f_update); ?></td>
<td class="cel_lastadd"><?php echo scrub_out($catalog->f_add); ?></td>
<td class="cel_lastclean"><?php echo scrub_out($catalog->f_clean); ?></td>
<td class="cel_action">
<a href="<?php echo $web_path; ?>/admin/catalog.php?action=add_to_catalog&amp;catalogs[]=<?php echo $catalog->id; ?>"><?php echo _('Add'); ?></a>
| <a href="<?php echo $web_path; ?>/admin/catalog.php?action=update_catalog&amp;catalogs[]=<?php echo $catalog->id; ?>"><?php echo _('Verify'); ?></a>

View file

@ -26,6 +26,7 @@
<col id="col_path" />
<col id="col_lastverify" />
<col id="col_lastadd" />
<col id="col_lastclean" />
<col id="col_action" />
</colgroup>
<tr class="th-top">
@ -33,6 +34,7 @@
<th class="cel_path"><?php echo _('Path'); ?></th>
<th class="cel_lastverify"><?php echo _('Last Verify'); ?></th>
<th class="cel_lastadd"><?php echo _('Last Add'); ?></th>
<th class="cel_lastclean"><?php echo _('Last Clean'); ?></th>
<th class="cel_action"><?php echo _('Actions'); ?></th>
</tr>
<?php
@ -49,6 +51,7 @@
<th class="cel_path"><?php echo _('Path'); ?></th>
<th class="cel_lastverify"><?php echo _('Last Verify'); ?></th>
<th class="cel_lastadd"><?php echo _('Last Add'); ?></th>
<th class="cel_lastclean"><?php echo _('Last Clean'); ?></th>
<th class="cel_action"><?php echo _('Actions'); ?></th>
</tr>
</table>

View file

@ -51,6 +51,5 @@
Browse::set_type('playlist_song');
Browse::add_supplemental_object('playlist',$playlist->id);
Browse::set_static_content(1);
Browse::save_objects($object_ids);
Browse::show_objects($object_ids);
?>

View file

@ -25,11 +25,13 @@
<col id="col_field" />
<col id="col_operator" />
<col id="col_value" />
<col id="col_method" />
</colgroup>
<tr class="th-top">
<th class="col_field"><?php echo _('Field'); ?></th>
<th class="col_operator"><?php echo _('Operator'); ?></th>
<th class="col_value"><?php echo _('Value'); ?></th>
<th class="col_method"><?php echo _('Method'); ?></th>
</tr>
<tr>
<td valign="top">
@ -57,6 +59,12 @@
<td valign="top">
<input type="textbox" name="value" />
</td>
<td valign="top">
<select name="method">
<option value="OR"><?php echo _('OR'); ?></option>
<option value="AND"><?php echo _('AND'); ?></option>
</select>
</td>
</tr>
<tr>
<td>
@ -65,12 +73,13 @@
<td>
<?php echo Ajax::button('?page=random&action=save_rules','download',_('Save Rules As'),'save_random_rules'); ?><?php echo _('Save Rules As'); ?>
</td>
<td>
<td colspan="2">
<?php echo Ajax::button('?page=random&action=load_rules','cog',_('Load Saved Rules'),'load_random_rules'); ?><?php echo _('Load Saved Rules'); ?>
</td>
</tr>
<tr>
<td colspan="3">
<td colspan="4">
<div id="rule_status"></div>
</td>
</tr>

View file

@ -25,12 +25,14 @@
<col id="col_field" />
<col id="col_operator" />
<col id="col_value" />
<col id="col_method" />
<col id="col_action" />
</colgroup>
<tr class="th-top">
<th class="col_field"><?php echo _('Field'); ?></th>
<th class="col_operator"><?php echo _('Operator'); ?></th>
<th class="col_value"><?php echo _('Value'); ?></th>
<th class="col_method"><?php echo _('Method'); ?></th>
<th class="col_action"><?php echo _('Action'); ?></th>
</tr>
<tr>
@ -38,6 +40,7 @@
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<?php show_box_bottom(); ?>

View file

@ -21,7 +21,7 @@
show_box_top();
printf(_('Updating the %s catalog'), "<strong>[ $catalog->name ]</strong>");
echo "<br />\n" . $number . " " . _('songs found checking tag information.') . "<br />\n\n";
echo "<br />\n" . $number . " " . _('items found checking tag information.') . "<br />\n\n";
echo _('Verifed') . ":<span id=\"verify_count_$catalog_id\">$catalog_verify_found</span><br />";
echo _('Reading') . ":<span id=\"verify_dir_$catalog_id\">$catalog_verify_directory</span><br />";
show_box_bottom();