xref: /webtrees/app/Schema/Migration30.php (revision 6bdf767435631ad1dc27ec1ffd855d43dbdce907)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2017 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16namespace Fisharebest\Webtrees\Schema;
17
18use Fisharebest\Webtrees\Auth;
19use Fisharebest\Webtrees\Database;
20use Fisharebest\Webtrees\Filter;
21
22/**
23 * Upgrade the database schema from version 30 to version 31.
24 */
25class Migration30 implements MigrationInterface {
26	/**
27	 * Upgrade to to the next version
28	 */
29	public function upgrade() {
30		$WEBTREES_EMAIL = 'webtrees-noreply@' . preg_replace('/^www\./i', '', Filter::server('SERVER_NAME'));
31
32		// Default settings for new trees. No defaults for:
33		// imported, title, CONTACT_USER_ID, WEBMASTER_USER_ID
34		// The following settings have defaults, but may need overwriting:
35		// LANGUAGE, SURNAME_TRADITION
36		Database::prepare(
37			"INSERT IGNORE INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value) VALUES" .
38			"(-1, 'ADVANCED_NAME_FACTS', 'NICK,_AKA')," .
39			"(-1, 'ADVANCED_PLAC_FACTS', '')," .
40			"(-1, 'ALLOW_THEME_DROPDOWN', '1')," .
41			"(-1, 'CALENDAR_FORMAT', 'gregorian')," .
42			"(-1, 'CHART_BOX_TAGS', '')," .
43			"(-1, 'COMMON_NAMES_ADD', '')," .
44			"(-1, 'COMMON_NAMES_REMOVE', '')," .
45			"(-1, 'COMMON_NAMES_THRESHOLD', '40')," .
46			"(-1, 'DEFAULT_PEDIGREE_GENERATIONS', '4')," .
47			"(-1, 'EXPAND_RELATIVES_EVENTS', '0')," .
48			"(-1, 'EXPAND_SOURCES', '0')," .
49			"(-1, 'FAM_FACTS_ADD', 'CENS,MARR,RESI,SLGS,MARR_CIVIL,MARR_RELIGIOUS,MARR_PARTNERS,RESN')," .
50			"(-1, 'FAM_FACTS_QUICK', 'MARR,DIV,_NMR')," .
51			"(-1, 'FAM_FACTS_UNIQUE', 'NCHI,MARL,DIV,ANUL,DIVF,ENGA,MARB,MARC,MARS,_NMR')," .
52			"(-1, 'FAM_ID_PREFIX', 'F')," .
53			"(-1, 'FORMAT_TEXT', 'markdown')," .
54			"(-1, 'FULL_SOURCES', '0')," .
55			"(-1, 'GEDCOM_ID_PREFIX', 'I')," .
56			"(-1, 'GEDCOM_MEDIA_PATH', '')," .
57			"(-1, 'GENERATE_UIDS', '0')," .
58			"(-1, 'HIDE_GEDCOM_ERRORS', '1')," .
59			"(-1, 'HIDE_LIVE_PEOPLE', '1')," .
60			"(-1, 'INDI_FACTS_ADD', 'AFN,BIRT,DEAT,BURI,CREM,ADOP,BAPM,BARM,BASM,BLES,CHRA,CONF,FCOM,ORDN,NATU,EMIG,IMMI,CENS,PROB,WILL,GRAD,RETI,DSCR,EDUC,IDNO,NATI,NCHI,NMR,OCCU,PROP,RELI,RESI,SSN,TITL,BAPL,CONL,ENDL,SLGC,_MILI,ASSO,RESN')," .
61			"(-1, 'INDI_FACTS_QUICK', 'BIRT,BURI,BAPM,CENS,DEAT,OCCU,RESI')," .
62			"(-1, 'INDI_FACTS_UNIQUE', '')," .
63			"(-1, 'KEEP_ALIVE_YEARS_BIRTH', '')," .
64			"(-1, 'KEEP_ALIVE_YEARS_DEATH', '')," .
65			"(-1, 'LANGUAGE', 'en-US')," .
66			"(-1, 'MAX_ALIVE_AGE', '120')," .
67			"(-1, 'MAX_DESCENDANCY_GENERATIONS', '15')," .
68			"(-1, 'MAX_PEDIGREE_GENERATIONS', '10')," .
69			"(-1, 'MEDIA_DIRECTORY', 'media/')," .
70			"(-1, 'MEDIA_ID_PREFIX', 'M')," .
71			"(-1, 'MEDIA_UPLOAD', :MEDIA_UPLOAD)," .
72			"(-1, 'META_DESCRIPTION', '')," .
73			"(-1, 'META_TITLE', :META_TITLE)," .
74			"(-1, 'NOTE_FACTS_ADD', 'SOUR,RESN')," .
75			"(-1, 'NOTE_FACTS_QUICK', '')," .
76			"(-1, 'NOTE_FACTS_UNIQUE', '')," .
77			"(-1, 'NOTE_ID_PREFIX', 'N')," .
78			"(-1, 'NO_UPDATE_CHAN', '0')," .
79			"(-1, 'PEDIGREE_FULL_DETAILS', '1')," .
80			"(-1, 'PEDIGREE_LAYOUT', '1')," .
81			"(-1, 'PEDIGREE_ROOT_ID', '')," .
82			"(-1, 'PEDIGREE_SHOW_GENDER', '0')," .
83			"(-1, 'PREFER_LEVEL2_SOURCES', '1')," .
84			"(-1, 'QUICK_REQUIRED_FACTS', 'BIRT,DEAT')," .
85			"(-1, 'QUICK_REQUIRED_FAMFACTS', 'MARR')," .
86			"(-1, 'REPO_FACTS_ADD', 'PHON,EMAIL,FAX,WWW,RESN')," .
87			"(-1, 'REPO_FACTS_QUICK', '')," .
88			"(-1, 'REPO_FACTS_UNIQUE', 'NAME,ADDR')," .
89			"(-1, 'REPO_ID_PREFIX', 'R')," .
90			"(-1, 'REQUIRE_AUTHENTICATION', '0')," .
91			"(-1, 'SAVE_WATERMARK_IMAGE', '0')," .
92			"(-1, 'SAVE_WATERMARK_THUMB', '0')," .
93			"(-1, 'SHOW_AGE_DIFF', '0')," .
94			"(-1, 'SHOW_COUNTER', '1')," .
95			"(-1, 'SHOW_DEAD_PEOPLE', :SHOW_DEAD_PEOPLE)," .
96			"(-1, 'SHOW_EST_LIST_DATES', '0')," .
97			"(-1, 'SHOW_FACT_ICONS', '1')," .
98			"(-1, 'SHOW_GEDCOM_RECORD', '0')," .
99			"(-1, 'SHOW_HIGHLIGHT_IMAGES', '1')," .
100			"(-1, 'SHOW_LDS_AT_GLANCE', '0')," .
101			"(-1, 'SHOW_LEVEL2_NOTES', '1')," .
102			"(-1, 'SHOW_LIVING_NAMES', :SHOW_LIVING_NAMES)," .
103			"(-1, 'SHOW_MEDIA_DOWNLOAD', '0')," .
104			"(-1, 'SHOW_NO_WATERMARK', :SHOW_NO_WATERMARK)," .
105			"(-1, 'SHOW_PARENTS_AGE', '1')," .
106			"(-1, 'SHOW_PEDIGREE_PLACES', '9')," .
107			"(-1, 'SHOW_PEDIGREE_PLACES_SUFFIX', '0')," .
108			"(-1, 'SHOW_PRIVATE_RELATIONSHIPS', '1')," .
109			"(-1, 'SHOW_RELATIVES_EVENTS', '_BIRT_CHIL,_BIRT_SIBL,_MARR_CHIL,_MARR_PARE,_DEAT_CHIL,_DEAT_PARE,_DEAT_GPAR,_DEAT_SIBL,_DEAT_SPOU')," .
110			"(-1, 'SOURCE_ID_PREFIX', 'S')," .
111			"(-1, 'SOUR_FACTS_ADD', 'NOTE,REPO,SHARED_NOTE,RESN')," .
112			"(-1, 'SOUR_FACTS_QUICK', 'TEXT,NOTE,REPO')," .
113			"(-1, 'SOUR_FACTS_UNIQUE', 'AUTH,ABBR,TITL,PUBL,TEXT')," .
114			"(-1, 'SUBLIST_TRIGGER_I', '200')," .
115			"(-1, 'SURNAME_LIST_STYLE', 'style2')," .
116			"(-1, 'SURNAME_TRADITION', 'paternal')," .
117			"(-1, 'THUMBNAIL_WIDTH', '100')," .
118			"(-1, 'USE_RIN', '0')," .
119			"(-1, 'USE_SILHOUETTE', '1')," .
120			"(-1, 'WATERMARK_THUMB', '0')," .
121			"(-1, 'WEBTREES_EMAIL', :WEBTREES_EMAIL)," .
122			"(-1, 'WORD_WRAPPED_NOTES', '0')"
123		)->execute([
124			'MEDIA_UPLOAD'      => Auth::PRIV_USER,
125			'META_TITLE'        => WT_WEBTREES,
126			'SHOW_DEAD_PEOPLE'  => Auth::PRIV_PRIVATE,
127			'SHOW_LIVING_NAMES' => Auth::PRIV_USER,
128			'SHOW_NO_WATERMARK' => Auth::PRIV_USER,
129			'WEBTREES_EMAIL'    => $WEBTREES_EMAIL,
130		]);
131
132		// Previous versions of webtrees allowed this setting to be empty.
133		Database::prepare(
134			"DELETE FROM `##gedcom_setting` WHERE setting_name  ='WEBTREES_EMAIL' AND setting_value = ''"
135		)->execute();
136
137		Database::prepare(
138			"INSERT IGNORE INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value)" .
139			" SELECT gedcom_id, 'WEBTREES_EMAIL', :WEBTREES_EMAIL" .
140			" FROM `##gedcom` WHERE gedcom_id > 0"
141		)->execute([
142			'WEBTREES_EMAIL' => $WEBTREES_EMAIL,
143		]);
144
145		// Default restrictions
146		Database::prepare(
147			"INSERT IGNORE INTO `##default_resn` (gedcom_id, tag_type, resn) VALUES " .
148			"(-1, 'SSN', 'confidential')," .
149			"(-1, 'SOUR', 'privacy')," .
150			"(-1, 'REPO', 'privacy')," .
151			"(-1, 'SUBM', 'confidential')," .
152			"(-1, 'SUBN', 'confidential')"
153		)->execute();
154	}
155}
156