aboutsummaryrefslogtreecommitdiffstats
path: root/install/upgrade_1.5.0.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2006-04-14 21:25:49 +0000
committerplegall <plg@piwigo.org>2006-04-14 21:25:49 +0000
commitafa5ab27a5e81ba32e797d7025fbb25a862bcfbe (patch)
treee6ebc20c0abe32a54e82cf1d62287df0c97797fa /install/upgrade_1.5.0.php
parent4e8f0f583fc7254500e9d765853e30db4f9e5b01 (diff)
new: upgrade script from release 1.5.0
improvement: ability to turn off dying on SQL queries failure. Could be useful for upgrades. git-svn-id: http://piwigo.org/svn/branches/branch-1_6@1174 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'install/upgrade_1.5.0.php')
-rw-r--r--install/upgrade_1.5.0.php300
1 files changed, 300 insertions, 0 deletions
diff --git a/install/upgrade_1.5.0.php b/install/upgrade_1.5.0.php
new file mode 100644
index 000000000..b386c14a4
--- /dev/null
+++ b/install/upgrade_1.5.0.php
@@ -0,0 +1,300 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch : BSF (Best So Far)
+// | file : $RCSfile$
+// | last update : $Date: 2005-10-23 23:02:21 +0200 (dim, 23 oct 2005) $
+// | last modifier : $Author: plg $
+// | revision : $Revision: 911 $
+// +-----------------------------------------------------------------------+
+// | 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 |
+// | |
+// | 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. |
+// +-----------------------------------------------------------------------+
+
+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!');
+ }
+}
+
+tag_replace_keywords();
+
+$queries = array(
+ "
+CREATE TABLE ".PREFIX_TABLE."search (
+ id int UNSIGNED NOT NULL AUTO_INCREMENT,
+ last_seen date DEFAULT NULL,
+ rules text,
+ PRIMARY KEY (id)
+);",
+
+ "
+CREATE TABLE ".PREFIX_TABLE."user_mail_notification (
+ user_id smallint(5) NOT NULL default '0',
+ check_key varchar(16) binary NOT NULL default '',
+ enabled enum('true','false') NOT NULL default 'false',
+ last_send datetime default NULL,
+ PRIMARY KEY (user_id),
+ UNIQUE KEY uidx_check_key (check_key)
+);",
+
+ "
+CREATE TABLE ".PREFIX_TABLE."upgrade (
+ id varchar(20) NOT NULL default '',
+ applied datetime NOT NULL default '0000-00-00 00:00:00',
+ description varchar(255) default NULL,
+ PRIMARY KEY (`id`)
+);",
+
+ "
+ALTER TABLE ".PREFIX_TABLE."config
+ MODIFY COLUMN value TEXT
+;",
+
+ "
+ALTER TABLE ".PREFIX_TABLE."images
+ ADD COLUMN has_high enum('true') default NULL
+;",
+
+ "
+ALTER TABLE ".PREFIX_TABLE."rate
+ ADD COLUMN anonymous_id varchar(45) NOT NULL default ''
+;",
+ "
+ALTER TABLE ".PREFIX_TABLE."rate
+ ADD COLUMN date date NOT NULL default '0000-00-00'
+;",
+ "
+ALTER TABLE ".PREFIX_TABLE."rate
+ DROP PRIMARY KEY
+;",
+ "
+ALTER TABLE ".PREFIX_TABLE."rate
+ ADD PRIMARY KEY (element_id,user_id,anonymous_id)
+;",
+ "
+UPDATE ".PREFIX_TABLE."rate
+ SET date = CURDATE()
+;",
+
+ "
+DELETE
+ FROM ".PREFIX_TABLE."sessions
+;",
+ "
+ALTER TABLE ".PREFIX_TABLE."sessions
+ DROP COLUMN user_id
+;",
+ "
+ALTER TABLE ".PREFIX_TABLE."sessions
+ ADD COLUMN data text NOT NULL
+;",
+
+ "
+ALTER TABLE ".PREFIX_TABLE."user_cache
+ ADD COLUMN nb_total_images mediumint(8) unsigned default NULL
+;",
+
+ "
+ALTER TABLE ".PREFIX_TABLE."user_infos
+ CHANGE COLUMN status
+ status enum('webmaster','admin','normal','generic','guest')
+ NOT NULL default 'guest'
+;",
+ "
+UPDATE ".PREFIX_TABLE."user_infos
+ SET status = 'normal'
+ WHERE status = 'guest'
+;",
+ "
+UPDATE ".PREFIX_TABLE."user_infos
+ SET status = 'guest'
+ WHERE user_id = ".$conf['guest_id']."
+;",
+ "
+UPDATE ".PREFIX_TABLE."user_infos
+ SET status = 'webmaster'
+ WHERE user_id = ".$conf['webmaster_id']."
+;",
+
+ "
+ALTER TABLE ".PREFIX_TABLE."user_infos
+ CHANGE COLUMN template template varchar(255) NOT NULL default 'yoga/clear'
+;",
+
+ "
+UPDATE ".PREFIX_TABLE."user_infos
+ SET template = 'yoga/dark'
+ WHERE template = 'yoga-dark'
+;",
+ "
+UPDATE ".PREFIX_TABLE."user_infos
+ SET template = 'yoga/clear'
+ WHERE template != 'yoga/dark'
+;",
+ "
+ALTER TABLE ".PREFIX_TABLE."user_infos
+ ADD COLUMN adviser enum('true','false') NOT NULL default 'false'
+;",
+ "
+ALTER TABLE ".PREFIX_TABLE."user_infos
+ ADD COLUMN enabled_high enum('true','false') NOT NULL default 'true'
+;",
+
+ // configuration table
+ "
+UPDATE ".PREFIX_TABLE."config
+ SET value = 'yoga/clear'
+ WHERE param = 'default_template'
+;"
+ );
+
+foreach ($queries as $query)
+{
+ pwg_query($query);
+}
+
+//
+// Move rate, rate_anonymous and gallery_url from config file to database
+//
+$params = array(
+ 'gallery_url' => 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);
+}
+
+$query = "
+ALTER TABLE ".PREFIX_TABLE."config MODIFY COLUMN `value` TEXT;";
+pwg_query($query);
+
+
+//
+// replace gallery_description by page_banner
+//
+$query = '
+SELECT value
+ FROM '.PREFIX_TABLE.'config
+ WHERE param=\'gallery_title\'
+;';
+list($t) = array_from_query($query, 'value');
+
+$query = '
+SELECT value
+ FROM '.PREFIX_TABLE.'config
+ WHERE param=\'gallery_description\'
+;';
+list($d) = array_from_query($query, 'value');
+
+$page_banner='<div id="theHeader"><h1>'.$t.'</h1><p>'.$d.'</p></div>';
+$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);
+
+//
+// configuration for notification by mail
+//
+$query = "
+INSERT INTO ".CONFIG_TABLE."
+ (param,value,comment)
+ VALUES
+ (
+ 'nbm_send_mail_as',
+ '',
+ 'Send mail as param value for notification by mail'
+ ),
+ (
+ 'nbm_send_detailed_content',
+ 'true',
+ 'Send detailed content for notification by mail'
+ ),
+ (
+ 'nbm_complementary_mail_content',
+ '',
+ 'Complementary mail content for notification by mail'
+ )
+;
+";
+pwg_query($query);
+
+?> \ No newline at end of file