summaryrefslogtreecommitdiff
path: root/includes/db_schema
diff options
context:
space:
mode:
authorfisharebest <fisharebest@gmail.com>2010-10-23 14:10:34 +0000
committerfisharebest <fisharebest@gmail.com>2010-10-23 14:10:34 +0000
commit2c1eea7cb82050382cf0c1e4d13936996d1d0a67 (patch)
tree9f43fe3c10516dcee77c4c1a0643a10e6ec471fd /includes/db_schema
parent31f9a1e414cd1d716a0e17d3260f6eea9085f579 (diff)
downloadwebtrees-2c1eea7cb82050382cf0c1e4d13936996d1d0a67.tar.gz
webtrees-2c1eea7cb82050382cf0c1e4d13936996d1d0a67.tar.bz2
webtrees-2c1eea7cb82050382cf0c1e4d13936996d1d0a67.zip
Relationship privacy - combine the separate gedcom-settings and user-settings into a user-gedcom-setting. This provides more flexibility and is much easier to understand.
Diffstat (limited to 'includes/db_schema')
-rw-r--r--includes/db_schema/db_schema_3_4.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/includes/db_schema/db_schema_3_4.php b/includes/db_schema/db_schema_3_4.php
new file mode 100644
index 0000000000..3dd5ee74e2
--- /dev/null
+++ b/includes/db_schema/db_schema_3_4.php
@@ -0,0 +1,73 @@
+<?php
+/**
+ * Update the database schema from version 3 to version 4
+ * - update the max_relation_path_length from a separate
+ * user setting and gedcom setting to a combined user-gedcom
+ * setting.
+ *
+ * Also clean out some old/unused values.
+ *
+ * The script should assume that it can be interrupted at
+ * any point, and be able to continue by re-running the script.
+ * Fatal errors, however, should be allowed to throw exceptions,
+ * which will be caught by the framework.
+ * It shouldn't do anything that might take more than a few
+ * seconds, for systems with low timeout values.
+ *
+ * phpGedView: Genealogy Viewer
+ * Copyright (C) 20010 Greg Roach
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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
+ *
+ * @version $Id$
+ */
+
+if (!defined('WT_WEBTREES')) {
+ header('HTTP/1.0 403 Forbidden');
+ exit;
+}
+
+define('WT_DB_SCHEMA_3_4', '');
+
+self::exec(
+ "INSERT IGNORE INTO wt_user_gedcom_setting (user_id, gedcom_id, setting_name, setting_value)".
+ " SELECT u.user_id, g.gedcom_id, 'RELATIONSHIP_PATH_LENGTH', LEAST(us1.setting_value, gs1.setting_value)".
+ " FROM wt_user u".
+ " CROSS JOIN wt_gedcom g".
+ " LEFT JOIN wt_user_setting us1 ON (u.user_id =us1.user_id AND us1.setting_name='max_relation_path')".
+ " LEFT JOIN wt_user_setting us2 ON (u.user_id =us2.user_id AND us2.setting_name='relationship_privacy')".
+ " LEFT JOIN wt_gedcom_setting gs1 ON (g.gedcom_id=gs1.gedcom_id AND gs1.setting_name='MAX_RELATION_PATH_LENGTH')".
+ " LEFT JOIN wt_gedcom_setting gs2 ON (g.gedcom_id=gs2.gedcom_id AND gs2.setting_name='USE_RELATIONSHIP_PRIVACY')".
+ " WHERE us2.setting_value AND gs2.setting_value"
+);
+
+// Delete old/unused settings
+self::exec(
+ "DELETE FROM `##site_setting` WHERE setting_name IN ('SESSION_SAVE_PATH')"
+);
+self::exec(
+ "DELETE FROM `##gedcom_setting` WHERE setting_name IN ('HOME_SITE_TEXT', 'HOME_SITE_URL', 'CHECK_MARRIAGE_RELATIONS', 'MAX_RELATION_PATH_LENGTH', 'USE_RELATIONSHIP_PRIVACY')"
+);
+self::exec(
+ "DELETE FROM `##user_setting` WHERE setting_name IN ('loggedin', 'relationship_privacy', 'max_relation_path_length')"
+);
+
+// Fix Mc/Mac problems - See SVN9701
+self::exec(
+ "UPDATE `##name` SET n_surn=CONCAT('MC', SUBSTRING(n_surn, 4)) WHERE n_surn LIKE 'MC0%'"
+);
+
+// Update the version to indicate success
+set_site_setting($schema_name, $next_version);