From 8789f41f8ccb31d0ec9f2c75996511e26abba8bc Mon Sep 17 00:00:00 2001 From: plegall Date: Wed, 19 Apr 2006 20:54:13 +0000 Subject: bug fixed: during installation, upgrades from install/db with complex identifier (X.x) were not correctly inserted. bug fixed: available upgrades from install/db need to be inserted in #upgrade table. deletion: all upgrades from install/db coming from trunk are removed. new: complete upgrade from any previous release from 1.3.0 to 1.5.2 with automatic detection detection of the previous release. git-svn-id: http://piwigo.org/svn/branches/branch-1_6@1209 68402e56-0260-453c-a942-63ccdbb3a9ee --- install/db/1-database.php | 46 ---- install/db/10-database.php | 56 ----- install/db/11-database.php | 69 ------ install/db/12-database.php | 103 -------- install/db/13-database.php | 73 ------ install/db/14-database.php | 63 ----- install/db/15-database.php | 50 ---- install/db/16-database.php | 54 ---- install/db/17-database.php | 64 ----- install/db/18-database.php | 92 ------- install/db/19-database.php | 153 ------------ install/db/2-database.php | 78 ------ install/db/20-database.php | 91 ------- install/db/21-database.php | 52 ---- install/db/22-database.php | 58 ----- install/db/3-database.php | 57 ----- install/db/4-database.php | 54 ---- install/db/5-database.php | 50 ---- install/db/6-database.php | 58 ----- install/db/7-database.php | 70 ------ install/db/8-database.php | 88 ------- install/db/9-database.php | 90 ------- install/upgrade_1.3.0.php | 130 ++++++++++ install/upgrade_1.3.1.php | 606 +++++++++++++++++++++++++++++++++++++++++++++ install/upgrade_1.4.0.php | 12 +- install/upgrade_1.4.1.php | 302 ---------------------- install/upgrade_1.5.0.php | 169 +++++++++++++ 27 files changed, 908 insertions(+), 1880 deletions(-) delete mode 100644 install/db/1-database.php delete mode 100644 install/db/10-database.php delete mode 100644 install/db/11-database.php delete mode 100644 install/db/12-database.php delete mode 100644 install/db/13-database.php delete mode 100644 install/db/14-database.php delete mode 100644 install/db/15-database.php delete mode 100644 install/db/16-database.php delete mode 100644 install/db/17-database.php delete mode 100644 install/db/18-database.php delete mode 100644 install/db/19-database.php delete mode 100644 install/db/2-database.php delete mode 100644 install/db/20-database.php delete mode 100644 install/db/21-database.php delete mode 100644 install/db/22-database.php delete mode 100644 install/db/3-database.php delete mode 100644 install/db/4-database.php delete mode 100644 install/db/5-database.php delete mode 100644 install/db/6-database.php delete mode 100644 install/db/7-database.php delete mode 100644 install/db/8-database.php delete mode 100644 install/db/9-database.php create mode 100644 install/upgrade_1.3.0.php create mode 100644 install/upgrade_1.3.1.php delete mode 100644 install/upgrade_1.4.1.php (limited to 'install') diff --git a/install/db/1-database.php b/install/db/1-database.php deleted file mode 100644 index 5bbb59d44..000000000 --- a/install/db/1-database.php +++ /dev/null @@ -1,46 +0,0 @@ - diff --git a/install/db/10-database.php b/install/db/10-database.php deleted file mode 100644 index 24a7f655e..000000000 --- a/install/db/10-database.php +++ /dev/null @@ -1,56 +0,0 @@ - diff --git a/install/db/11-database.php b/install/db/11-database.php deleted file mode 100644 index bb2ea8421..000000000 --- a/install/db/11-database.php +++ /dev/null @@ -1,69 +0,0 @@ - diff --git a/install/db/12-database.php b/install/db/12-database.php deleted file mode 100644 index 3e6ed0200..000000000 --- a/install/db/12-database.php +++ /dev/null @@ -1,103 +0,0 @@ - $row['user_id'], - 'status' => 'normal' - ) - ); -} - -mass_updates( - USER_INFOS_TABLE, - array( - 'primary' => array('user_id'), - 'update' => array('status') - ), - $datas - ); - -// +-----------------------------------------------------------------------+ -// | End notification | -// +-----------------------------------------------------------------------+ - -echo -"\n" -.'Column '.USER_INFOS_TABLE.'.status changed' -."\n" -; - -?> diff --git a/install/db/13-database.php b/install/db/13-database.php deleted file mode 100644 index ac35cc40c..000000000 --- a/install/db/13-database.php +++ /dev/null @@ -1,73 +0,0 @@ -

'.$t.'

'.$d.'

'; -$page_banner=addslashes($page_banner); -$query = ' -INSERT INTO '.PREFIX_TABLE.'config (param,value,comment) VALUES (' . -"'page_banner','$page_banner','html displayed on the top each page of your gallery');"; -pwg_query($query); - -$query = ' -DELETE FROM '.PREFIX_TABLE.'config - WHERE param=\'gallery_description\' -;'; -pwg_query($query); - - -echo -"\n" -.'Table '.PREFIX_TABLE.'config updated' -."\n" -; -?> diff --git a/install/db/14-database.php b/install/db/14-database.php deleted file mode 100644 index e9f50174a..000000000 --- a/install/db/14-database.php +++ /dev/null @@ -1,63 +0,0 @@ - '".$conf['newuser_default_enabled_high']."' -;"; -pwg_query($query); - -echo -"\n" -.'"'.$upgrade_description.'"'.' ended' -."\n" -; - -?> diff --git a/install/db/15-database.php b/install/db/15-database.php deleted file mode 100644 index b5ff23a7c..000000000 --- a/install/db/15-database.php +++ /dev/null @@ -1,50 +0,0 @@ - diff --git a/install/db/16-database.php b/install/db/16-database.php deleted file mode 100644 index 4187b2cc4..000000000 --- a/install/db/16-database.php +++ /dev/null @@ -1,54 +0,0 @@ - diff --git a/install/db/17-database.php b/install/db/17-database.php deleted file mode 100644 index 820ca6194..000000000 --- a/install/db/17-database.php +++ /dev/null @@ -1,64 +0,0 @@ - diff --git a/install/db/18-database.php b/install/db/18-database.php deleted file mode 100644 index 13fb615bf..000000000 --- a/install/db/18-database.php +++ /dev/null @@ -1,92 +0,0 @@ - $row['user_id'], - 'check_key' => find_available_check_key() - ) - ); -} - -mass_updates( - USER_MAIL_NOTIFICATION_TABLE, - array( - 'primary' => array('user_id'), - 'update' => array('check_key') - ), - $datas - ); - -echo "Alter table ".USER_MAIL_NOTIFICATION_TABLE; -$query = " -alter table ".USER_MAIL_NOTIFICATION_TABLE." - modify column `check_key` varchar(16) binary NOT NULL default '' -;"; -pwg_query($query); - - -// +-----------------------------------------------------------------------+ -// | End notification | -// +-----------------------------------------------------------------------+ - -echo -"\n" -.'Column '.USER_MAIL_NOTIFICATION_TABLE.'.check_key changed' -."\n" -; - -?> diff --git a/install/db/19-database.php b/install/db/19-database.php deleted file mode 100644 index d1fdb4a74..000000000 --- a/install/db/19-database.php +++ /dev/null @@ -1,153 +0,0 @@ - $tag_id) -{ - array_push( - $datas, - array( - 'id' => $tag_id, - 'name' => $tag_name, - 'url_name' => str2url($tag_name), - ) - ); -} -if (!empty($datas)) -mass_inserts( - PREFIX_TABLE.'tags', - array_keys($datas[0]), - $datas - ); - -$datas = array(); -foreach ($tag_images as $tag_id => $images) -{ - foreach (array_unique($images) as $image_id) - { - array_push( - $datas, - array( - 'tag_id' => $tag_id, - 'image_id' => $image_id, - ) - ); - } -} - -if (!empty($datas)) -mass_inserts( - PREFIX_TABLE.'image_tag', - array_keys($datas[0]), - $datas - ); - -// +-----------------------------------------------------------------------+ -// | Delete images.keywords | -// +-----------------------------------------------------------------------+ - -$query = ' -ALTER TABLE '.PREFIX_TABLE.'images DROP COLUMN keywords -;'; -pwg_query($query); - -// +-----------------------------------------------------------------------+ -// | End notification | -// +-----------------------------------------------------------------------+ - -echo -"\n" -.'Table '.PREFIX_TABLE.'tags created and filled'."\n" -.'Table '.PREFIX_TABLE.'image_tag created and filled'."\n" -.'Column '.PREFIX_TABLE.'images.keywords dropped'."\n" -; -?> diff --git a/install/db/2-database.php b/install/db/2-database.php deleted file mode 100644 index 9a249703a..000000000 --- a/install/db/2-database.php +++ /dev/null @@ -1,78 +0,0 @@ - diff --git a/install/db/20-database.php b/install/db/20-database.php deleted file mode 100644 index 5dba69168..000000000 --- a/install/db/20-database.php +++ /dev/null @@ -1,91 +0,0 @@ - $row['image_id'], - 'storage_category_id' => $row['category_id'], - ) - ); -} -mass_updates( - PREFIX_TABLE.'images', - array( - 'primary' => array('id'), - 'update' => array('storage_category_id'), - ), - $datas - ); - -// +-----------------------------------------------------------------------+ -// | Delete obsolete column | -// +-----------------------------------------------------------------------+ - -$query = ' -ALTER TABLE '.PREFIX_TABLE.'image_category DROP COLUMN is_storage -;'; -pwg_query($query); - -// +-----------------------------------------------------------------------+ -// | End notification | -// +-----------------------------------------------------------------------+ - -echo -"\n" -.'Column '.PREFIX_TABLE.'image_category' -.' replaced by '.PREFIX_TABLE.'images.storage_category_id'."\n" -; -?> diff --git a/install/db/21-database.php b/install/db/21-database.php deleted file mode 100644 index cfd08c692..000000000 --- a/install/db/21-database.php +++ /dev/null @@ -1,52 +0,0 @@ - diff --git a/install/db/22-database.php b/install/db/22-database.php deleted file mode 100644 index fcead3cf2..000000000 --- a/install/db/22-database.php +++ /dev/null @@ -1,58 +0,0 @@ - diff --git a/install/db/3-database.php b/install/db/3-database.php deleted file mode 100644 index abcaa79aa..000000000 --- a/install/db/3-database.php +++ /dev/null @@ -1,57 +0,0 @@ - diff --git a/install/db/4-database.php b/install/db/4-database.php deleted file mode 100644 index c74486a46..000000000 --- a/install/db/4-database.php +++ /dev/null @@ -1,54 +0,0 @@ - diff --git a/install/db/5-database.php b/install/db/5-database.php deleted file mode 100644 index 0dc2006d0..000000000 --- a/install/db/5-database.php +++ /dev/null @@ -1,50 +0,0 @@ - diff --git a/install/db/6-database.php b/install/db/6-database.php deleted file mode 100644 index 08bcf6aea..000000000 --- a/install/db/6-database.php +++ /dev/null @@ -1,58 +0,0 @@ - diff --git a/install/db/7-database.php b/install/db/7-database.php deleted file mode 100644 index 5ad118506..000000000 --- a/install/db/7-database.php +++ /dev/null @@ -1,70 +0,0 @@ - diff --git a/install/db/8-database.php b/install/db/8-database.php deleted file mode 100644 index ecbc8bf5e..000000000 --- a/install/db/8-database.php +++ /dev/null @@ -1,88 +0,0 @@ - array('http://demo.phpwebgallery.net','URL given in RSS feed'), - 'rate' => array('true','Rating pictures feature is enabled') , - 'rate_anonymous' => array('true','Rating pictures feature is also enabled for visitors') - ); - - - -// +-Get real values from config file--------------------------------------+ - -$conf_save = $conf; -unset($conf); -@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php'); -if ( isset($conf['gallery_url']) ) -{ - $params['gallery_url'][0] = $conf['gallery_url']; -} -if ( isset($conf['rate']) and is_bool($conf['rate']) ) -{ - $params['rate'][0] = $conf['rate'] ? 'true' : 'false'; -} -if ( isset($conf['rate_anonymous']) and is_bool($conf['rate_anonymous']) ) -{ - $params['rate_anonymous'][0] = $conf['rate_anonymous'] ? 'true' : 'false'; -} -$conf = $conf_save; - - - -// +-Do I already have them in DB ?----------------------------------------+ -$query = 'SELECT param FROM '.PREFIX_TABLE.'config'; -$result = pwg_query($query); -while ($row = mysql_fetch_array($result)) -{ - unset( $params[ $row['param'] ] ); -} - -// +-Perform the insert query----------------------------------------------+ -foreach ($params as $param_key => $param_values) -{ - $query = ' -INSERT INTO '.PREFIX_TABLE.'config (param,value,comment) VALUES (' . -"'$param_key','$param_values[0]','$param_values[1]');"; - pwg_query($query); -} - - -echo -"\n" -.'Table '.PREFIX_TABLE.'config upgraded' -."\n" -; -?> diff --git a/install/db/9-database.php b/install/db/9-database.php deleted file mode 100644 index 3abf384a3..000000000 --- a/install/db/9-database.php +++ /dev/null @@ -1,90 +0,0 @@ - $row['id'], - 'category_id' => $row['storage_category_id'], - 'is_storage' => 'true', - ) - ); -} - -mass_updates( - PREFIX_TABLE.'image_category', - array( - 'primary' => array('image_id', 'category_id'), - 'update' => array('is_storage') - ), - $datas - ); - -$query = ' -ALTER TABLE '.PREFIX_TABLE.'images - DROP COLUMN storage_category_id -;'; -pwg_query($query); - -// +-----------------------------------------------------------------------+ -// | End notification | -// +-----------------------------------------------------------------------+ - -echo -"\n" -.'Column '.PREFIX_TABLE.'image_category.is_storage created and filled' -."\n" -; -?> diff --git a/install/upgrade_1.3.0.php b/install/upgrade_1.3.0.php new file mode 100644 index 000000000..f5d650e6b --- /dev/null +++ b/install/upgrade_1.3.0.php @@ -0,0 +1,130 @@ + array('id'), + 'update' => array('uppercats') + ), + $datas + ); + +// now we upgrade from 1.3.1 to 1.6.0 +include_once(PHPWG_ROOT_PATH.'install/upgrade_1.3.1.php'); +?> \ No newline at end of file diff --git a/install/upgrade_1.3.1.php b/install/upgrade_1.3.1.php new file mode 100644 index 000000000..3e1e42c14 --- /dev/null +++ b/install/upgrade_1.3.1.php @@ -0,0 +1,606 @@ += 1) to 1.4.0 + */ + +if (!defined('PHPWG_ROOT_PATH')) +{ + die ('This page cannot be loaded directly, load upgrade.php'); +} +else +{ + if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE) + { + die ('Hacking attempt!'); + } +} + +// save data before deletion +$query = ' +SELECT prefix_thumbnail, mail_webmaster + FROM '.PREFIX_TABLE.'config +;'; +$save = mysql_fetch_array(mysql_query($query)); + +$queries = array( + " +DROP TABLE phpwebgallery_config +;", + + " +CREATE TABLE phpwebgallery_config ( + param varchar(40) NOT NULL default '', + value varchar(255) default NULL, + comment varchar(255) default NULL, + PRIMARY KEY (param) +) TYPE=MyISAM COMMENT='configuration table' +;", + + " +ALTER TABLE phpwebgallery_categories + CHANGE COLUMN site_id site_id tinyint(4) unsigned default '1' +;", + + " +ALTER TABLE phpwebgallery_categories + ADD COLUMN commentable enum('true','false') NOT NULL default 'true' +;", + + " +ALTER TABLE phpwebgallery_categories + ADD COLUMN global_rank varchar(255) default NULL +;", + + " +ALTER TABLE phpwebgallery_categories + ADD INDEX categories_i2 (id_uppercat) +;", + + " +ALTER TABLE phpwebgallery_comments + ADD COLUMN date_temp int(11) unsigned +;", + + " +UPDATE phpwebgallery_comments + SET date_temp = date +;", + + " +ALTER TABLE phpwebgallery_comments + CHANGE COLUMN date date datetime NOT NULL default '0000-00-00 00:00:00' +;", + + " +UPDATE phpwebgallery_comments + SET date = FROM_UNIXTIME(date_temp) +;", + + " +ALTER TABLE phpwebgallery_comments + DROP COLUMN date_temp +;", + + " +ALTER TABLE phpwebgallery_favorites + DROP INDEX user_id +;", + + " +ALTER TABLE phpwebgallery_favorites + ADD PRIMARY KEY (user_id,image_id) +;", + + " +ALTER TABLE phpwebgallery_history + ADD COLUMN date_temp int(11) unsigned +;", + + " +UPDATE phpwebgallery_history + SET date_temp = date +;", + + " +ALTER TABLE phpwebgallery_history + CHANGE COLUMN date date datetime NOT NULL default '0000-00-00 00:00:00' +;", + + " +UPDATE phpwebgallery_history + SET date = FROM_UNIXTIME(date_temp) +;", + + " +ALTER TABLE phpwebgallery_history + DROP COLUMN date_temp +;", + + " +ALTER TABLE phpwebgallery_history + ADD INDEX history_i1 (date) +;", + + " +ALTER TABLE phpwebgallery_image_category + ADD INDEX image_category_i1 (image_id), + ADD INDEX image_category_i2 (category_id) +;", + + " +ALTER TABLE phpwebgallery_images + CHANGE COLUMN tn_ext tn_ext varchar(4) default '' +;", + + " +ALTER TABLE phpwebgallery_images + ADD COLUMN path varchar(255) NOT NULL default '' +;", + + " +ALTER TABLE phpwebgallery_images + ADD COLUMN date_metadata_update date default NULL +;", + + " +ALTER TABLE phpwebgallery_images + ADD COLUMN average_rate float(5,2) unsigned default NULL +;", + + " +ALTER TABLE phpwebgallery_images + ADD COLUMN representative_ext varchar(4) default NULL +;", + + " +ALTER TABLE phpwebgallery_images + DROP INDEX storage_category_id +;", + + " +ALTER TABLE phpwebgallery_images + ADD INDEX images_i1 (storage_category_id) +;", + + " +ALTER TABLE phpwebgallery_images + ADD INDEX images_i2 (date_available) +;", + + " +ALTER TABLE phpwebgallery_images + ADD INDEX images_i3 (average_rate) +;", + + " +ALTER TABLE phpwebgallery_images + ADD INDEX images_i4 (hit) +;", + + " +ALTER TABLE phpwebgallery_images + ADD INDEX images_i5 (date_creation) +;", + + " +ALTER TABLE phpwebgallery_sessions + DROP COLUMN ip +;", + + " +ALTER TABLE phpwebgallery_sessions + ADD COLUMN expiration_temp int(11) unsigned +;", + + " +UPDATE phpwebgallery_sessions + SET expiration_temp = expiration +;", + + " +ALTER TABLE phpwebgallery_sessions + CHANGE COLUMN expiration expiration datetime NOT NULL default '0000-00-00 00:00:00' +;", + + " +UPDATE phpwebgallery_sessions + SET expiration = FROM_UNIXTIME(expiration_temp) +;", + + " +ALTER TABLE phpwebgallery_sessions + DROP COLUMN expiration_temp +;", + + " +ALTER TABLE phpwebgallery_sites + DROP INDEX galleries_url +;", + + " +ALTER TABLE phpwebgallery_sites + ADD UNIQUE sites_ui1 (galleries_url) +;", + + " +DROP TABLE phpwebgallery_user_category +;", + + " +ALTER TABLE phpwebgallery_users + DROP COLUMN long_period +;", + + " +ALTER TABLE phpwebgallery_users + DROP COLUMN short_period +;", + + " +ALTER TABLE phpwebgallery_users + ADD COLUMN recent_period tinyint(3) unsigned NOT NULL default '7' +;", + + " +ALTER TABLE phpwebgallery_users + DROP INDEX username +;", + + " +ALTER TABLE phpwebgallery_users + ADD UNIQUE users_ui1 (username) +;", + + " +CREATE TABLE phpwebgallery_rate ( + user_id smallint(5) unsigned NOT NULL default '0', + element_id mediumint(8) unsigned NOT NULL default '0', + rate tinyint(2) unsigned NOT NULL default '0', + PRIMARY KEY (user_id,element_id) +) TYPE=MyISAM +;", + + " +CREATE TABLE phpwebgallery_user_forbidden ( + user_id smallint(5) unsigned NOT NULL default '0', + need_update enum('true','false') NOT NULL default 'true', + forbidden_categories text, + PRIMARY KEY (user_id) +) TYPE=MyISAM +;", + + " +UPDATE phpwebgallery_users + SET language = 'en_UK.iso-8859-1' + , template = 'default' +;", + + " +DELETE FROM phpwebgallery_user_access +;", + + " +DELETE FROM phpwebgallery_group_access +;" + + ); + +foreach ($queries as $query) +{ + $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query); + pwg_query($query); +} + +// +// check indexes +// +$indexes_of = array( + 'categories' => array( + 'categories_i2' => array( + 'columns' => array('id_uppercat'), + 'unique' => false, + ) + ), + 'image_category' => array( + 'image_category_i1' => array( + 'columns' => array('image_id'), + 'unique' => false, + ), + 'image_category_i2' => array( + 'columns' => array('category_id'), + 'unique' => false, + ), + ), + ); + +foreach (array_keys($indexes_of) as $table) +{ + $existing_indexes = array(); + + $query = ' +SHOW INDEX + FROM '.PREFIX_TABLE.$table.' +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + if ($row['Key_name'] != 'PRIMARY') + { + if (!in_array($row['Key_name'], array_keys($indexes_of[$table]))) + { + $query = ' +ALTER TABLE '.PREFIX_TABLE.$table.' + DROP INDEX '.$row['Key_name'].' +;'; + pwg_query($query); + } + else + { + array_push($existing_indexes, $row['Key_name']); + } + } + } + + foreach ($indexes_of[$table] as $index_name => $index) + { + if (!in_array($index_name, $existing_indexes)) + { + $query = ' +ALTER TABLE '.PREFIX_TABLE.$table.' + ADD '.($index['unique'] ? 'UNIQUE' : 'INDEX').' ' + .$index_name.' ('.implode(',', $index['columns']).') +;'; + pwg_query($query); + } + } +} + +// +// insert params in new configuration table +// +$params = array( + array( + 'param' => 'prefix_thumbnail', + 'value' => $save['prefix_thumbnail'], + 'comment' => 'thumbnails filename prefix' + ), + array( + 'param' => 'mail_webmaster', + 'value' => $save['mail_webmaster'], + 'comment' => 'webmaster mail' + ), + array( + 'param' => 'default_language', + 'value' => 'en_UK.iso-8859-1', + 'comment' => 'Default gallery language' + ), + array( + 'param' => 'default_template', + 'value' => 'default', + 'comment' => 'Default gallery style' + ), + array( + 'param' => 'default_maxwidth', + 'value' => '', + 'comment' => 'maximum width authorized for displaying images' + ), + array( + 'param' => 'default_maxheight', + 'value' => '', + 'comment' => 'maximum height authorized for the displaying images' + ), + array( + 'param' => 'nb_comment_page', + 'value' => '10', + 'comment' => 'number of comments to display on each page' + ), + array( + 'param' => 'upload_maxfilesize', + 'value' => '150', + 'comment' => 'maximum filesize for the uploaded pictures' + ), + array( + 'param' => 'upload_maxwidth', + 'value' => '800', + 'comment' => 'maximum width authorized for the uploaded images' + ), + array( + 'param' => 'upload_maxheight', + 'value' => '600', + 'comment' => 'maximum height authorized for the uploaded images' + ), + array( + 'param' => 'upload_maxwidth_thumbnail', + 'value' => '150', + 'comment' => 'maximum width authorized for the uploaded thumbnails' + ), + array( + 'param' => 'upload_maxheight_thumbnail', + 'value' => '100', + 'comment' => 'maximum height authorized for the uploaded thumbnails' + ), + array( + 'param' => 'log', + 'value' => 'false', + 'comment' => 'keep an history of visits on your website' + ), + array( + 'param' => 'comments_validation', + 'value' => 'false', + 'comment' => 'administrators validate users comments before becoming visible' + ), + array( + 'param' => 'comments_forall', + 'value' => 'false', + 'comment' => 'even guest not registered can post comments' + ), + array( + 'param' => 'mail_notification', + 'value' => 'false', + 'comment' => 'automated mail notification for adminsitrators' + ), + array( + 'param' => 'nb_image_line', + 'value' => '5', + 'comment' => 'Number of images displayed per row' + ), + array( + 'param' => 'nb_line_page', + 'value' => '3', + 'comment' => 'Number of rows displayed per page' + ), + array( + 'param' => 'recent_period', + 'value' => '7', + 'comment' => 'Period within which pictures are displayed as new (in days)' + ), + array( + 'param' => 'auto_expand', + 'value' => 'false', + 'comment' => 'Auto expand of the category tree' + ), + array( + 'param' => 'show_nb_comments', + 'value' => 'false', + 'comment' => 'Show the number of comments under the thumbnails' + ), + array( + 'param' => 'use_iptc', + 'value' => 'false', + 'comment' => 'Use IPTC data during database synchronization with files metadata' + ), + array( + 'param' => 'use_exif', + 'value' => 'false', + 'comment' => 'Use EXIF data during database synchronization with files metadata' + ), + array( + 'param' => 'show_iptc', + 'value' => 'false', + 'comment' => 'Show IPTC metadata on picture.php if asked by user' + ), + array( + 'param' => 'show_exif', + 'value' => 'true', + 'comment' => 'Show EXIF metadata on picture.php if asked by user' + ), + array( + 'param' => 'authorize_remembering', + 'value' => 'true', + 'comment' => 'Authorize users to be remembered, see $conf{remember_me_length}' + ), + array( + 'param' => 'gallery_locked', + 'value' => 'false', + 'comment' => 'Lock your gallery temporary for non admin users' + ), + ); + +mass_inserts( + CONFIG_TABLE, + array_keys($params[0]), + $params + ); + +// refresh calculated datas +ordering(); +update_global_rank(); +update_category(); + +// update calculated field "images.path" +$cat_ids = array(); + +$query = ' +SELECT DISTINCT(storage_category_id) AS unique_storage_category_id + FROM '.IMAGES_TABLE.' +;'; +$result = pwg_query($query); +while ($row = mysql_fetch_array($result)) +{ + array_push($cat_ids, $row['unique_storage_category_id']); +} +$fulldirs = get_fulldirs($cat_ids); + +foreach ($cat_ids as $cat_id) +{ + $query = ' +UPDATE '.IMAGES_TABLE.' + SET path = CONCAT(\''.$fulldirs[$cat_id].'\',\'/\',file) + WHERE storage_category_id = '.$cat_id.' +;'; + pwg_query($query); +} + +// all sub-categories of private categories become private +$cat_ids = array(); + +$query = ' +SELECT id + FROM '.CATEGORIES_TABLE.' + WHERE status = \'private\' +;'; +$result = pwg_query($query); +while ($row = mysql_fetch_array($result)) +{ + array_push($cat_ids, $row['id']); +} + +if (count($cat_ids) > 0) +{ + $privates = get_subcat_ids($cat_ids); + + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET status = \'private\' + WHERE id IN ('.implode(',', $privates).') +;'; + pwg_query($query); +} + +$page['infos'] = array_merge( + $page['infos'], + array( + 'all sub-categories of private categories become private', + + 'user permissions and group permissions have been erased', + + 'only thumbnails prefix and webmaster mail address have been saved from +previous configuration', + + 'in include/mysql.inc.php, before +
?>
+insert +
define(\'PHPWG_INSTALLED\', true);
'
+    )
+  );
+
+
+// now we upgrade from 1.4.0
+include_once(PHPWG_ROOT_PATH.'install/upgrade_1.4.0.php');
+?>
\ No newline at end of file
diff --git a/install/upgrade_1.4.0.php b/install/upgrade_1.4.0.php
index a5f8f38c6..fef961254 100644
--- a/install/upgrade_1.4.0.php
+++ b/install/upgrade_1.4.0.php
@@ -188,12 +188,6 @@ foreach ($queries as $query)
   pwg_query($query);
 }
 
-$new_time = get_moment();
-echo '
['.get_elapsed_time($last_time, $new_time).']';
-echo ' Basic database structure upgrade done
'; -flush(); -$last_time = $new_time; - // user datas migration from phpwebgallery_users to phpwebgallery_user_infos $query = ' SELECT * @@ -287,16 +281,16 @@ foreach ($queries as $query) pwg_query($query); } -$infos = array(); - if ($prefix_thumbnail != 'TN-') { array_push( - $infos, + $page['infos'], 'the thumbnail prefix configuration parameter was moved to configuration file, copy config_local.inc.php from "tools" directory to "include" directory and edit $conf[\'prefix_thumbnail\'] = '.$prefix_thumbnail ); } +// now we upgrade from 1.5.0 to 1.6.0 +include_once(PHPWG_ROOT_PATH.'install/upgrade_1.5.0.php'); ?> \ No newline at end of file diff --git a/install/upgrade_1.4.1.php b/install/upgrade_1.4.1.php deleted file mode 100644 index a5f8f38c6..000000000 --- a/install/upgrade_1.4.1.php +++ /dev/null @@ -1,302 +0,0 @@ -['.get_elapsed_time($last_time, $new_time).']'; -echo ' Basic database structure upgrade done
'; -flush(); -$last_time = $new_time; - -// user datas migration from phpwebgallery_users to phpwebgallery_user_infos -$query = ' -SELECT * - FROM '.USERS_TABLE.' -;'; - -$datas = array(); -list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); - -$result = pwg_query($query); -while ($row = mysql_fetch_array($result)) -{ - $row['user_id'] = $row['id']; - $row['registration_date'] = $dbnow; - array_push($datas, $row); -} - -include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); -mass_inserts( - USER_INFOS_TABLE, - array( - 'user_id', - 'nb_image_line', - 'nb_line_page', - 'status', - 'language', - 'maxwidth', - 'maxheight', - 'expand', - 'show_nb_comments', - 'recent_period', - 'template', - 'registration_date' - ), - $datas - ); - -$queries = array( - - " -UPDATE ".USER_INFOS_TABLE." - SET template = 'yoga' -;", - - " -UPDATE ".USER_INFOS_TABLE." - SET language = 'en_UK.iso-8859-1' - WHERE language NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1') -;", - - " -UPDATE ".CONFIG_TABLE." - SET value = 'en_UK.iso-8859-1' - WHERE param = 'default_language' - AND value NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1') -;", - - " -UPDATE ".CONFIG_TABLE." - SET value = 'yoga' - WHERE param = 'default_template' -;", - - " -INSERT INTO ".CONFIG_TABLE." - (param,value,comment) - VALUES - ( - 'gallery_title', - 'PhpWebGallery demonstration site', - 'Title at top of each page and for RSS feed' - ) -;", - - " -INSERT INTO ".CONFIG_TABLE." - (param,value,comment) - VALUES - ( - 'gallery_description', - 'My photos web site', - 'Short description displayed with gallery title' - ) -;" - - ); - -foreach ($queries as $query) -{ - $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query); - pwg_query($query); -} - -$infos = array(); - -if ($prefix_thumbnail != 'TN-') -{ - array_push( - $infos, - 'the thumbnail prefix configuration parameter was moved to configuration -file, copy config_local.inc.php from "tools" directory to "include" directory -and edit $conf[\'prefix_thumbnail\'] = '.$prefix_thumbnail - ); -} - -?> \ No newline at end of file diff --git a/install/upgrade_1.5.0.php b/install/upgrade_1.5.0.php index b386c14a4..711625183 100644 --- a/install/upgrade_1.5.0.php +++ b/install/upgrade_1.5.0.php @@ -37,6 +37,146 @@ else } } +/** + * replace old style #images.keywords by #tags. Requires a big data + * migration. + * + * @return void + */ +function tag_replace_keywords() +{ + // code taken from upgrades 19 and 22 + + $query = ' +CREATE TABLE '.PREFIX_TABLE.'tags ( + id smallint(5) UNSIGNED NOT NULL auto_increment, + name varchar(255) BINARY NOT NULL, + url_name varchar(255) BINARY NOT NULL, + PRIMARY KEY (id) +) +;'; + pwg_query($query); + + $query = ' +CREATE TABLE '.PREFIX_TABLE.'image_tag ( + image_id mediumint(8) UNSIGNED NOT NULL, + tag_id smallint(5) UNSIGNED NOT NULL, + PRIMARY KEY (image_id,tag_id) +) +;'; + pwg_query($query); + + // + // Move keywords to tags + // + + // each tag label is associated to a numeric identifier + $tag_id = array(); + // to each tag id (key) a list of image ids (value) is associated + $tag_images = array(); + + $current_id = 1; + + $query = ' +SELECT id, keywords + FROM '.PREFIX_TABLE.'images + WHERE keywords IS NOT NULL +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_array($result)) + { + foreach(preg_split('/[,]+/', $row['keywords']) as $keyword) + { + if (!isset($tag_id[$keyword])) + { + $tag_id[$keyword] = $current_id++; + } + + if (!isset($tag_images[ $tag_id[$keyword] ])) + { + $tag_images[ $tag_id[$keyword] ] = array(); + } + + array_push( + $tag_images[ $tag_id[$keyword] ], + $row['id'] + ); + } + } + + $datas = array(); + foreach ($tag_id as $tag_name => $tag_id) + { + array_push( + $datas, + array( + 'id' => $tag_id, + 'name' => $tag_name, + 'url_name' => str2url($tag_name), + ) + ); + } + + if (!empty($datas)) + { + mass_inserts( + PREFIX_TABLE.'tags', + array_keys($datas[0]), + $datas + ); + } + + $datas = array(); + foreach ($tag_images as $tag_id => $images) + { + foreach (array_unique($images) as $image_id) + { + array_push( + $datas, + array( + 'tag_id' => $tag_id, + 'image_id' => $image_id, + ) + ); + } + } + + if (!empty($datas)) + { + mass_inserts( + PREFIX_TABLE.'image_tag', + array_keys($datas[0]), + $datas + ); + } + + // + // Delete images.keywords + // + $query = ' +ALTER TABLE '.PREFIX_TABLE.'images DROP COLUMN keywords +;'; + pwg_query($query); + + // + // Add useful indexes + // + $query = ' +ALTER TABLE '.PREFIX_TABLE.'tags + ADD INDEX tags_i1(url_name) +;'; + pwg_query($query); + + + $query = ' +ALTER TABLE '.PREFIX_TABLE.'image_tag + ADD INDEX image_tag_i1(tag_id) +;'; + pwg_query($query); + + // print_time('tags have replaced keywords'); +} + tag_replace_keywords(); $queries = array( @@ -297,4 +437,33 @@ INSERT INTO ".CONFIG_TABLE." "; pwg_query($query); +// depending on the way the 1.5.0 was installed (from scratch or by upgrade) +// the database structure has small differences that should be corrected. + +$query = ' +ALTER TABLE '.PREFIX_TABLE.'users + CHANGE COLUMN password password varchar(32) default NULL +;'; +pwg_query($query); + +$to_keep = array('id', 'username', 'password', 'mail_address'); + +$query = ' +DESC '.PREFIX_TABLE.'users +;'; + +$result = pwg_query($query); + +while ($row = mysql_fetch_array($result)) +{ + if (!in_array($row['Field'], $to_keep)) + { + $query = ' +ALTER TABLE '.PREFIX_TABLE.'users + DROP COLUMN '.$row['Field'].' +;'; + pwg_query($query); + } +} + ?> \ No newline at end of file -- cgit v1.2.3