diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2009-03-01 02:35:42 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2009-03-01 02:35:42 +0000 |
commit | e474991d13f41a56e85b4966e156973d33833e6c (patch) | |
tree | 690e3e2b9b2c009153d8d319ba8e4a15de6499c9 | |
parent | c9ccb05a40c08aadc2defeaf48e84032ae5c0a0c (diff) | |
download | ampache-e474991d13f41a56e85b4966e156973d33833e6c.tar.gz ampache-e474991d13f41a56e85b4966e156973d33833e6c.tar.bz2 ampache-e474991d13f41a56e85b4966e156973d33833e6c.zip |
Resolve #401 new database update, reset album thumbs and use resized art...
-rw-r--r-- | image.php | 6 | ||||
-rw-r--r-- | lib/class/catalog.class.php | 31 | ||||
-rw-r--r-- | lib/class/playlist.class.php | 13 | ||||
-rw-r--r-- | lib/class/update.class.php | 32 | ||||
-rw-r--r-- | lib/class/vauth.class.php | 4 | ||||
-rw-r--r-- | lib/ui.lib.php | 5 | ||||
-rw-r--r-- | server/playlist.ajax.php | 14 | ||||
-rw-r--r-- | templates/show_album_art.inc.php | 4 | ||||
-rw-r--r-- | templates/show_catalog_row.inc.php | 1 | ||||
-rw-r--r-- | templates/show_catalogs.inc.php | 3 | ||||
-rw-r--r-- | templates/show_playlist.inc.php | 1 | ||||
-rw-r--r-- | templates/show_random.inc.php | 13 | ||||
-rw-r--r-- | templates/show_random_rules.inc.php | 3 | ||||
-rw-r--r-- | templates/show_verify_catalog.inc.php | 2 |
14 files changed, 94 insertions, 38 deletions
@@ -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 diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 86dfc91e..7e7030a5 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -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,15 +919,27 @@ 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; diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php index 6fdc1bb5..f3e31c56 100644 --- a/lib/class/playlist.class.php +++ b/lib/class/playlist.class.php @@ -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 diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 7778c673..87b1a76f 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -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'); diff --git a/lib/class/vauth.class.php b/lib/class/vauth.class.php index 89702a80..045a10a8 100644 --- a/lib/class/vauth.class.php +++ b/lib/class/vauth.class.php @@ -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); diff --git a/lib/ui.lib.php b/lib/ui.lib.php index 6ee09789..1fd49d1f 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -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); diff --git a/server/playlist.ajax.php b/server/playlist.ajax.php index 032ffb22..18424bf4 100644 --- a/server/playlist.ajax.php +++ b/server/playlist.ajax.php @@ -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 diff --git a/templates/show_album_art.inc.php b/templates/show_album_art.inc.php index 0ce49909..373f662d 100644 --- a/templates/show_album_art.inc.php +++ b/templates/show_album_art.inc.php @@ -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&image=<?php echo $key; ?>&album_id=<?php echo intval($_REQUEST['album_id']); ?>"><?php echo _('Select'); ?></a>] </p> diff --git a/templates/show_catalog_row.inc.php b/templates/show_catalog_row.inc.php index c6646fe4..000579d7 100644 --- a/templates/show_catalog_row.inc.php +++ b/templates/show_catalog_row.inc.php @@ -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&catalogs[]=<?php echo $catalog->id; ?>"><?php echo _('Add'); ?></a> | <a href="<?php echo $web_path; ?>/admin/catalog.php?action=update_catalog&catalogs[]=<?php echo $catalog->id; ?>"><?php echo _('Verify'); ?></a> diff --git a/templates/show_catalogs.inc.php b/templates/show_catalogs.inc.php index 44b233be..dedfa8f2 100644 --- a/templates/show_catalogs.inc.php +++ b/templates/show_catalogs.inc.php @@ -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> diff --git a/templates/show_playlist.inc.php b/templates/show_playlist.inc.php index 310be805..eff58442 100644 --- a/templates/show_playlist.inc.php +++ b/templates/show_playlist.inc.php @@ -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); ?> diff --git a/templates/show_random.inc.php b/templates/show_random.inc.php index 7bef5db8..ecef8904 100644 --- a/templates/show_random.inc.php +++ b/templates/show_random.inc.php @@ -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> diff --git a/templates/show_random_rules.inc.php b/templates/show_random_rules.inc.php index 4e9d30c3..4593ee82 100644 --- a/templates/show_random_rules.inc.php +++ b/templates/show_random_rules.inc.php @@ -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(); ?> diff --git a/templates/show_verify_catalog.inc.php b/templates/show_verify_catalog.inc.php index a915d681..71dc4c0b 100644 --- a/templates/show_verify_catalog.inc.php +++ b/templates/show_verify_catalog.inc.php @@ -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(); |