Completed
Push — 1.7 ( 2f57da...5dea34 )
by
unknown
08:36
created
includes/session.php 1 patch
Switch Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -200,29 +200,29 @@  discard block
 block discarded – undo
200 200
 		$frame += array('args' => array(), 'file' => 'unknown', 'line' => 'unknown');
201 201
 		array_walk($frame['args'], function (&$arg) {
202 202
 			switch (gettype($arg)) {
203
-			case 'boolean':
204
-			case 'integer':
205
-			case 'double':
206
-			case 'null':
207
-				$arg = var_export($arg, true);
208
-				break;
209
-			case 'string':
210
-				if (mb_strlen($arg) > 30) {
211
-					$arg = substr($arg, 0, 30) . '…';
212
-				}
213
-				$arg = var_export($arg, true);
214
-				break;
215
-			case 'object':
216
-				$reflection = new \ReflectionClass($arg);
217
-				if (is_object($arg) && method_exists($arg, '__toString')) {
218
-					$arg = '[' . $reflection->getShortName() . ' ' . (string) $arg . ']';
219
-				} else {
220
-					$arg = '[' . $reflection->getShortName() . ']';
221
-				}
222
-				break;
223
-			default:
224
-				$arg = '[' . gettype($arg) . ']';
225
-				break;
203
+				case 'boolean':
204
+				case 'integer':
205
+				case 'double':
206
+				case 'null':
207
+					$arg = var_export($arg, true);
208
+					break;
209
+				case 'string':
210
+					if (mb_strlen($arg) > 30) {
211
+						$arg = substr($arg, 0, 30) . '…';
212
+					}
213
+					$arg = var_export($arg, true);
214
+					break;
215
+				case 'object':
216
+					$reflection = new \ReflectionClass($arg);
217
+					if (is_object($arg) && method_exists($arg, '__toString')) {
218
+						$arg = '[' . $reflection->getShortName() . ' ' . (string) $arg . ']';
219
+					} else {
220
+						$arg = '[' . $reflection->getShortName() . ']';
221
+					}
222
+					break;
223
+				default:
224
+					$arg = '[' . gettype($arg) . ']';
225
+					break;
226 226
 			}
227 227
 		});
228 228
 		$frame['file'] = str_replace(dirname(__DIR__), '', $frame['file']);
@@ -319,25 +319,25 @@  discard block
 block discarded – undo
319 319
 )->execute(array(WT_CLIENT_IP, Filter::server('HTTP_USER_AGENT', null, '')))->fetchOne();
320 320
 
321 321
 switch ($rule) {
322
-case 'allow':
323
-	$SEARCH_SPIDER = false;
324
-	break;
325
-case 'deny':
326
-	http_response_code(403);
327
-	exit;
328
-case 'robot':
329
-case 'unknown':
330
-	// Search engines don’t send cookies, and so create a new session with every visit.
331
-	// Make sure they always use the same one
332
-	Session::setId('search-engine-' . str_replace('.', '-', WT_CLIENT_IP));
333
-	$SEARCH_SPIDER = true;
334
-	break;
335
-case '':
336
-	Database::prepare(
337
-		"INSERT INTO `##site_access_rule` (ip_address_start, ip_address_end, user_agent_pattern, comment) VALUES (IFNULL(INET_ATON(?), 0), IFNULL(INET_ATON(?), 4294967295), ?, '')"
338
-	)->execute(array(WT_CLIENT_IP, WT_CLIENT_IP, Filter::server('HTTP_USER_AGENT', null, '')));
339
-	$SEARCH_SPIDER = true;
340
-	break;
322
+	case 'allow':
323
+		$SEARCH_SPIDER = false;
324
+		break;
325
+	case 'deny':
326
+		http_response_code(403);
327
+		exit;
328
+	case 'robot':
329
+	case 'unknown':
330
+		// Search engines don’t send cookies, and so create a new session with every visit.
331
+		// Make sure they always use the same one
332
+		Session::setId('search-engine-' . str_replace('.', '-', WT_CLIENT_IP));
333
+		$SEARCH_SPIDER = true;
334
+		break;
335
+	case '':
336
+		Database::prepare(
337
+			"INSERT INTO `##site_access_rule` (ip_address_start, ip_address_end, user_agent_pattern, comment) VALUES (IFNULL(INET_ATON(?), 0), IFNULL(INET_ATON(?), 4294967295), ?, '')"
338
+		)->execute(array(WT_CLIENT_IP, WT_CLIENT_IP, Filter::server('HTTP_USER_AGENT', null, '')));
339
+		$SEARCH_SPIDER = true;
340
+		break;
341 341
 }
342 342
 
343 343
 // Store our session data in the database.
Please login to merge, or discard this patch.
admin_site_config.php 1 patch
Switch Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -25,85 +25,85 @@
 block discarded – undo
25 25
 $controller->restrictAccess(Auth::isAdmin());
26 26
 
27 27
 switch (Filter::post('action')) {
28
-case 'site':
29
-	if (Filter::checkCsrf()) {
30
-		$INDEX_DIRECTORY = Filter::post('INDEX_DIRECTORY');
31
-		if (substr($INDEX_DIRECTORY, -1) !== '/') {
32
-			$INDEX_DIRECTORY .= '/';
28
+	case 'site':
29
+		if (Filter::checkCsrf()) {
30
+			$INDEX_DIRECTORY = Filter::post('INDEX_DIRECTORY');
31
+			if (substr($INDEX_DIRECTORY, -1) !== '/') {
32
+				$INDEX_DIRECTORY .= '/';
33
+			}
34
+			if (File::mkdir($INDEX_DIRECTORY)) {
35
+				Site::setPreference('INDEX_DIRECTORY', $INDEX_DIRECTORY);
36
+			} else {
37
+				FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Filter::escapeHtml($INDEX_DIRECTORY)), 'danger');
38
+			}
39
+			Site::setPreference('MEMORY_LIMIT', Filter::post('MEMORY_LIMIT'));
40
+			Site::setPreference('MAX_EXECUTION_TIME', Filter::post('MAX_EXECUTION_TIME'));
41
+			Site::setPreference('ALLOW_USER_THEMES', Filter::postBool('ALLOW_USER_THEMES'));
42
+			Site::setPreference('THEME_DIR', Filter::post('THEME_DIR'));
43
+			Site::setPreference('ALLOW_CHANGE_GEDCOM', Filter::postBool('ALLOW_CHANGE_GEDCOM'));
44
+			Site::setPreference('SESSION_TIME', Filter::post('SESSION_TIME'));
45
+			Site::setPreference('SERVER_URL', Filter::post('SERVER_URL'));
46
+			Site::setPreference('TIMEZONE', Filter::post('TIMEZONE'));
47
+			FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
33 48
 		}
34
-		if (File::mkdir($INDEX_DIRECTORY)) {
35
-			Site::setPreference('INDEX_DIRECTORY', $INDEX_DIRECTORY);
36
-		} else {
37
-			FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Filter::escapeHtml($INDEX_DIRECTORY)), 'danger');
49
+		header('Location: ' . WT_BASE_URL . 'admin.php');
50
+
51
+		return;
52
+
53
+	case 'email':
54
+		if (Filter::checkCsrf()) {
55
+			Site::setPreference('SMTP_ACTIVE', Filter::post('SMTP_ACTIVE'));
56
+			Site::setPreference('SMTP_FROM_NAME', Filter::post('SMTP_FROM_NAME'));
57
+			Site::setPreference('SMTP_HOST', Filter::post('SMTP_HOST'));
58
+			Site::setPreference('SMTP_PORT', Filter::post('SMTP_PORT'));
59
+			Site::setPreference('SMTP_AUTH', Filter::post('SMTP_AUTH'));
60
+			Site::setPreference('SMTP_AUTH_USER', Filter::post('SMTP_AUTH_USER'));
61
+			Site::setPreference('SMTP_SSL', Filter::post('SMTP_SSL'));
62
+			Site::setPreference('SMTP_HELO', Filter::post('SMTP_HELO'));
63
+			if (Filter::post('SMTP_AUTH_PASS')) {
64
+				Site::setPreference('SMTP_AUTH_PASS', Filter::post('SMTP_AUTH_PASS'));
65
+			}
66
+			FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
38 67
 		}
39
-		Site::setPreference('MEMORY_LIMIT', Filter::post('MEMORY_LIMIT'));
40
-		Site::setPreference('MAX_EXECUTION_TIME', Filter::post('MAX_EXECUTION_TIME'));
41
-		Site::setPreference('ALLOW_USER_THEMES', Filter::postBool('ALLOW_USER_THEMES'));
42
-		Site::setPreference('THEME_DIR', Filter::post('THEME_DIR'));
43
-		Site::setPreference('ALLOW_CHANGE_GEDCOM', Filter::postBool('ALLOW_CHANGE_GEDCOM'));
44
-		Site::setPreference('SESSION_TIME', Filter::post('SESSION_TIME'));
45
-		Site::setPreference('SERVER_URL', Filter::post('SERVER_URL'));
46
-		Site::setPreference('TIMEZONE', Filter::post('TIMEZONE'));
47
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
48
-	}
49
-	header('Location: ' . WT_BASE_URL . 'admin.php');
50
-
51
-	return;
52
-
53
-case 'email':
54
-	if (Filter::checkCsrf()) {
55
-		Site::setPreference('SMTP_ACTIVE', Filter::post('SMTP_ACTIVE'));
56
-		Site::setPreference('SMTP_FROM_NAME', Filter::post('SMTP_FROM_NAME'));
57
-		Site::setPreference('SMTP_HOST', Filter::post('SMTP_HOST'));
58
-		Site::setPreference('SMTP_PORT', Filter::post('SMTP_PORT'));
59
-		Site::setPreference('SMTP_AUTH', Filter::post('SMTP_AUTH'));
60
-		Site::setPreference('SMTP_AUTH_USER', Filter::post('SMTP_AUTH_USER'));
61
-		Site::setPreference('SMTP_SSL', Filter::post('SMTP_SSL'));
62
-		Site::setPreference('SMTP_HELO', Filter::post('SMTP_HELO'));
63
-		if (Filter::post('SMTP_AUTH_PASS')) {
64
-			Site::setPreference('SMTP_AUTH_PASS', Filter::post('SMTP_AUTH_PASS'));
68
+		header('Location: ' . WT_BASE_URL . 'admin.php');
69
+
70
+		return;
71
+	case 'login':
72
+		if (Filter::checkCsrf()) {
73
+			Site::setPreference('LOGIN_URL', Filter::post('LOGIN_URL'));
74
+			Site::setPreference('WELCOME_TEXT_AUTH_MODE', Filter::post('WELCOME_TEXT_AUTH_MODE'));
75
+			Site::setPreference('WELCOME_TEXT_AUTH_MODE_' . WT_LOCALE, Filter::post('WELCOME_TEXT_AUTH_MODE_4'));
76
+			Site::setPreference('USE_REGISTRATION_MODULE', Filter::post('USE_REGISTRATION_MODULE'));
77
+			Site::setPreference('SHOW_REGISTER_CAUTION', Filter::post('SHOW_REGISTER_CAUTION'));
78
+			FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
65 79
 		}
66
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
67
-	}
68
-	header('Location: ' . WT_BASE_URL . 'admin.php');
69
-
70
-	return;
71
-case 'login':
72
-	if (Filter::checkCsrf()) {
73
-		Site::setPreference('LOGIN_URL', Filter::post('LOGIN_URL'));
74
-		Site::setPreference('WELCOME_TEXT_AUTH_MODE', Filter::post('WELCOME_TEXT_AUTH_MODE'));
75
-		Site::setPreference('WELCOME_TEXT_AUTH_MODE_' . WT_LOCALE, Filter::post('WELCOME_TEXT_AUTH_MODE_4'));
76
-		Site::setPreference('USE_REGISTRATION_MODULE', Filter::post('USE_REGISTRATION_MODULE'));
77
-		Site::setPreference('SHOW_REGISTER_CAUTION', Filter::post('SHOW_REGISTER_CAUTION'));
78
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
79
-	}
80
-	header('Location: ' . WT_BASE_URL . 'admin.php');
81
-
82
-	return;
80
+		header('Location: ' . WT_BASE_URL . 'admin.php');
81
+
82
+		return;
83
+
84
+	case 'tracking':
85
+		if (Filter::checkCsrf()) {
86
+			Site::setPreference('BING_WEBMASTER_ID', Filter::post('BING_WEBMASTER_ID'));
87
+			Site::setPreference('GOOGLE_WEBMASTER_ID', Filter::post('GOOGLE_WEBMASTER_ID'));
88
+			Site::setPreference('GOOGLE_ANALYTICS_ID', Filter::post('GOOGLE_ANALYTICS_ID'));
89
+			Site::setPreference('PIWIK_URL', Filter::post('PIWIK_URL'));
90
+			Site::setPreference('PIWIK_SITE_ID', Filter::post('PIWIK_SITE_ID'));
91
+			Site::setPreference('STATCOUNTER_PROJECT_ID', Filter::post('STATCOUNTER_PROJECT_ID'));
92
+			Site::setPreference('STATCOUNTER_SECURITY_ID', Filter::post('STATCOUNTER_SECURITY_ID'));
93
+			FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
94
+		}
95
+		header('Location: ' . WT_BASE_URL . 'admin.php');
83 96
 
84
-case 'tracking':
85
-	if (Filter::checkCsrf()) {
86
-		Site::setPreference('BING_WEBMASTER_ID', Filter::post('BING_WEBMASTER_ID'));
87
-		Site::setPreference('GOOGLE_WEBMASTER_ID', Filter::post('GOOGLE_WEBMASTER_ID'));
88
-		Site::setPreference('GOOGLE_ANALYTICS_ID', Filter::post('GOOGLE_ANALYTICS_ID'));
89
-		Site::setPreference('PIWIK_URL', Filter::post('PIWIK_URL'));
90
-		Site::setPreference('PIWIK_SITE_ID', Filter::post('PIWIK_SITE_ID'));
91
-		Site::setPreference('STATCOUNTER_PROJECT_ID', Filter::post('STATCOUNTER_PROJECT_ID'));
92
-		Site::setPreference('STATCOUNTER_SECURITY_ID', Filter::post('STATCOUNTER_SECURITY_ID'));
93
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
94
-	}
95
-	header('Location: ' . WT_BASE_URL . 'admin.php');
97
+		return;
96 98
 
97
-	return;
98
-
99
-case 'languages':
100
-	if (Filter::checkCsrf()) {
101
-		Site::setPreference('LANGUAGES', implode(',', Filter::postArray('LANGUAGES')));
102
-		FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
103
-	}
104
-	header('Location: ' . WT_BASE_URL . 'admin.php');
99
+	case 'languages':
100
+		if (Filter::checkCsrf()) {
101
+			Site::setPreference('LANGUAGES', implode(',', Filter::postArray('LANGUAGES')));
102
+			FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
103
+		}
104
+		header('Location: ' . WT_BASE_URL . 'admin.php');
105 105
 
106
-	return;
106
+		return;
107 107
 }
108 108
 
109 109
 // Lists of options for <select> controls.
Please login to merge, or discard this patch.
admin_site_upgrade.php 1 patch
Switch Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -117,18 +117,18 @@  discard block
 block discarded – undo
117 117
 foreach (Module::getInstalledModules('disabled') as $module) {
118 118
 	if (!in_array($module->getName(), Module::getCoreModuleNames())) {
119 119
 		switch ($modules_action) {
120
-		case 'disable':
121
-			Database::prepare(
122
-				"UPDATE `##module` SET status = 'disabled' WHERE module_name = ?"
123
-			)->execute(array($module->getName()));
124
-			break;
125
-		case 'ignore':
126
-			echo '<br>', I18N::translate('Custom module'), ' — ', WT_MODULES_DIR, $module->getName(), ' — ', $module->getTitle(), $icon_success;
127
-			break;
128
-		default:
129
-			echo '<br>', I18N::translate('Custom module'), ' — ', WT_MODULES_DIR, $module->getName(), ' — ', $module->getTitle(), $icon_failure;
130
-			$custom_modules = true;
131
-			break;
120
+			case 'disable':
121
+				Database::prepare(
122
+					"UPDATE `##module` SET status = 'disabled' WHERE module_name = ?"
123
+				)->execute(array($module->getName()));
124
+				break;
125
+			case 'ignore':
126
+				echo '<br>', I18N::translate('Custom module'), ' — ', WT_MODULES_DIR, $module->getName(), ' — ', $module->getTitle(), $icon_success;
127
+				break;
128
+			default:
129
+				echo '<br>', I18N::translate('Custom module'), ' — ', WT_MODULES_DIR, $module->getName(), ' — ', $module->getTitle(), $icon_failure;
130
+				$custom_modules = true;
131
+				break;
132 132
 		}
133 133
 	}
134 134
 }
@@ -157,40 +157,40 @@  discard block
 block discarded – undo
157 157
 $custom_themes = false;
158 158
 foreach (Theme::themeNames() as $theme_id => $theme_name) {
159 159
 	switch ($theme_id) {
160
-	case 'clouds':
161
-	case 'colors':
162
-	case 'fab':
163
-	case 'minimal':
164
-	case 'webtrees':
165
-	case 'xenea':
166
-		break;
167
-	default:
168
-		$theme_used = Database::prepare(
169
-			"SELECT EXISTS (SELECT 1 FROM `##site_setting`   WHERE setting_name='THEME_DIR' AND setting_value=?)" .
170
-			" OR    EXISTS (SELECT 1 FROM `##gedcom_setting` WHERE setting_name='THEME_DIR' AND setting_value=?)" .
171
-			" OR    EXISTS (SELECT 1 FROM `##user_setting`   WHERE setting_name='theme'     AND setting_value=?)"
172
-		)->execute(array($theme_id, $theme_id, $theme_id))->fetchOne();
173
-		if ($theme_used) {
174
-			switch ($themes_action) {
175
-			case 'disable':
176
-				Database::prepare(
177
-					"DELETE FROM `##site_setting`   WHERE setting_name = 'THEME_DIR' AND setting_value = ?"
178
-				)->execute(array($theme_id));
179
-				Database::prepare(
180
-					"DELETE FROM `##gedcom_setting` WHERE setting_name = 'THEME_DIR' AND setting_value = ?"
181
-				)->execute(array($theme_id));
182
-				Database::prepare(
183
-					"DELETE FROM `##user_setting`   WHERE setting_name = 'theme'     AND setting_value = ?"
184
-				)->execute(array($theme_id));
185
-				break;
186
-			case 'ignore':
187
-				echo '<br>', I18N::translate('Custom theme'), ' — ', $theme_id, ' — ', $theme_name, $icon_success;
188
-				break;
189
-			default:
190
-				echo '<br>', I18N::translate('Custom theme'), ' — ', $theme_id, ' — ', $theme_name, $icon_failure;
191
-				$custom_themes = true;
192
-				break;
193
-			}
160
+		case 'clouds':
161
+		case 'colors':
162
+		case 'fab':
163
+		case 'minimal':
164
+		case 'webtrees':
165
+		case 'xenea':
166
+			break;
167
+		default:
168
+			$theme_used = Database::prepare(
169
+				"SELECT EXISTS (SELECT 1 FROM `##site_setting`   WHERE setting_name='THEME_DIR' AND setting_value=?)" .
170
+				" OR    EXISTS (SELECT 1 FROM `##gedcom_setting` WHERE setting_name='THEME_DIR' AND setting_value=?)" .
171
+				" OR    EXISTS (SELECT 1 FROM `##user_setting`   WHERE setting_name='theme'     AND setting_value=?)"
172
+			)->execute(array($theme_id, $theme_id, $theme_id))->fetchOne();
173
+			if ($theme_used) {
174
+				switch ($themes_action) {
175
+					case 'disable':
176
+						Database::prepare(
177
+							"DELETE FROM `##site_setting`   WHERE setting_name = 'THEME_DIR' AND setting_value = ?"
178
+						)->execute(array($theme_id));
179
+						Database::prepare(
180
+							"DELETE FROM `##gedcom_setting` WHERE setting_name = 'THEME_DIR' AND setting_value = ?"
181
+						)->execute(array($theme_id));
182
+						Database::prepare(
183
+							"DELETE FROM `##user_setting`   WHERE setting_name = 'theme'     AND setting_value = ?"
184
+						)->execute(array($theme_id));
185
+						break;
186
+					case 'ignore':
187
+						echo '<br>', I18N::translate('Custom theme'), ' — ', $theme_id, ' — ', $theme_name, $icon_success;
188
+						break;
189
+					default:
190
+						echo '<br>', I18N::translate('Custom theme'), ' — ', $theme_id, ' — ', $theme_name, $icon_failure;
191
+						$custom_themes = true;
192
+						break;
193
+				}
194 194
 		}
195 195
 		break;
196 196
 	}
Please login to merge, or discard this patch.
edit_interface.php 1 patch
Switch Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -278,40 +278,40 @@  discard block
 block discarded – undo
278 278
 
279 279
 	$level1type = $edit_fact->getTag();
280 280
 	switch ($record::RECORD_TYPE) {
281
-	case 'REPO':
282
-		// REPO:NAME facts may take a NOTE (but the REPO record may not).
283
-		if ($level1type === 'NAME') {
284
-			FunctionsEdit::printAddLayer('NOTE');
285
-			FunctionsEdit::printAddLayer('SHARED_NOTE');
286
-		}
287
-		break;
288
-	case 'FAM':
289
-	case 'INDI':
290
-		// FAM and INDI records have real facts. They can take NOTE/SOUR/OBJE/etc.
291
-		if ($level1type !== 'SEX' && $level1type !== 'NOTE' && $level1type !== 'ALIA') {
292
-			if ($level1type !== 'SOUR') {
293
-				FunctionsEdit::printAddLayer('SOUR');
294
-			}
295
-			if ($level1type !== 'OBJE') {
296
-				FunctionsEdit::printAddLayer('OBJE');
297
-			}
298
-			FunctionsEdit::printAddLayer('NOTE');
299
-			FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $level1type);
300
-			if ($level1type !== 'ASSO' && $level1type !== 'NOTE' && $level1type !== 'SOUR') {
301
-				FunctionsEdit::printAddLayer('ASSO');
302
-			}
303
-			// allow to add godfather and godmother for CHR fact or best man and bridesmaid  for MARR fact in one window
304
-			if (in_array($level1type, Config::twoAssociates())) {
305
-				FunctionsEdit::printAddLayer('ASSO2');
281
+		case 'REPO':
282
+			// REPO:NAME facts may take a NOTE (but the REPO record may not).
283
+			if ($level1type === 'NAME') {
284
+				FunctionsEdit::printAddLayer('NOTE');
285
+				FunctionsEdit::printAddLayer('SHARED_NOTE');
306 286
 			}
307
-			if ($level1type !== 'SOUR') {
308
-				FunctionsEdit::printAddLayer('RESN');
287
+			break;
288
+		case 'FAM':
289
+		case 'INDI':
290
+			// FAM and INDI records have real facts. They can take NOTE/SOUR/OBJE/etc.
291
+			if ($level1type !== 'SEX' && $level1type !== 'NOTE' && $level1type !== 'ALIA') {
292
+				if ($level1type !== 'SOUR') {
293
+					FunctionsEdit::printAddLayer('SOUR');
294
+				}
295
+				if ($level1type !== 'OBJE') {
296
+					FunctionsEdit::printAddLayer('OBJE');
297
+				}
298
+				FunctionsEdit::printAddLayer('NOTE');
299
+				FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $level1type);
300
+				if ($level1type !== 'ASSO' && $level1type !== 'NOTE' && $level1type !== 'SOUR') {
301
+					FunctionsEdit::printAddLayer('ASSO');
302
+				}
303
+				// allow to add godfather and godmother for CHR fact or best man and bridesmaid  for MARR fact in one window
304
+				if (in_array($level1type, Config::twoAssociates())) {
305
+					FunctionsEdit::printAddLayer('ASSO2');
306
+				}
307
+				if ($level1type !== 'SOUR') {
308
+					FunctionsEdit::printAddLayer('RESN');
309
+				}
309 310
 			}
310
-		}
311
-		break;
312
-	default:
313
-		// Other types of record do not have these lower-level records
314
-		break;
311
+			break;
312
+		default:
313
+			// Other types of record do not have these lower-level records
314
+			break;
315 315
 	}
316 316
 	if (Auth::isAdmin() || $WT_TREE->getPreference('SHOW_GEDCOM_RECORD')) {
317 317
 		echo
@@ -1905,9 +1905,9 @@  discard block
 block discarded – undo
1905 1905
 							<b>
1906 1906
 								<?php
1907 1907
 								switch ($father->getSex()) {
1908
-								case 'M': echo I18N::translate('husband'); break;
1909
-								case 'F': echo I18N::translate('wife'); break;
1910
-								default:  echo I18N::translate('spouse'); break;
1908
+									case 'M': echo I18N::translate('husband'); break;
1909
+									case 'F': echo I18N::translate('wife'); break;
1910
+									default:  echo I18N::translate('spouse'); break;
1911 1911
 								}
1912 1912
 								?>
1913 1913
 							</b>
@@ -1940,9 +1940,9 @@  discard block
 block discarded – undo
1940 1940
 							<b>
1941 1941
 								<?php
1942 1942
 								switch ($mother->getSex()) {
1943
-								case 'M': echo I18N::translate('husband'); break;
1944
-								case 'F': echo I18N::translate('wife'); break;
1945
-								default:  echo I18N::translate('spouse'); break;
1943
+									case 'M': echo I18N::translate('husband'); break;
1944
+									case 'F': echo I18N::translate('wife'); break;
1945
+									default:  echo I18N::translate('spouse'); break;
1946 1946
 								}
1947 1947
 								?>
1948 1948
 							</b>
@@ -1976,9 +1976,9 @@  discard block
 block discarded – undo
1976 1976
 							<b>
1977 1977
 								<?php
1978 1978
 								switch ($child->getSex()) {
1979
-								case 'M': echo I18N::translate('son'); break;
1980
-								case 'F': echo I18N::translate('daughter'); break;
1981
-								default:  echo I18N::translate('child'); break;
1979
+									case 'M': echo I18N::translate('son'); break;
1980
+									case 'F': echo I18N::translate('daughter'); break;
1981
+									default:  echo I18N::translate('child'); break;
1982 1982
 								}
1983 1983
 								?>
1984 1984
 							</b>
@@ -2354,35 +2354,35 @@  discard block
 block discarded – undo
2354 2354
 		}
2355 2355
 
2356 2356
 		switch ($nextaction) {
2357
-		case 'add_child_to_family_action':
2358
-			$name_fields = array_merge($name_fields, $surname_tradition->newChildNames($father_name, $mother_name, $gender));
2359
-			break;
2360
-		case 'add_child_to_individual_action':
2361
-			if ($person->getSex() === 'F') {
2362
-				$name_fields = array_merge($name_fields, $surname_tradition->newChildNames('', $indi_name, $gender));
2363
-			} else {
2364
-				$name_fields = array_merge($name_fields, $surname_tradition->newChildNames($indi_name, '', $gender));
2365
-			}
2366
-			break;
2367
-		case 'add_parent_to_individual_action':
2368
-			$name_fields = array_merge($name_fields, $surname_tradition->newParentNames($indi_name, $gender));
2369
-			break;
2370
-		case 'add_spouse_to_family_action':
2371
-			if ($father) {
2372
-				$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($father_name, $gender));
2373
-			} else {
2374
-				$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($mother_name, $gender));
2375
-			}
2376
-			break;
2377
-		case 'add_spouse_to_individual_action':
2378
-			$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($indi_name, $gender));
2379
-			break;
2380
-		case 'add_unlinked_indi_action':
2381
-		case 'update':
2382
-			if ($surname_tradition->hasSurnames()) {
2383
-				$name_fields['NAME'] = '//';
2384
-			}
2385
-			break;
2357
+			case 'add_child_to_family_action':
2358
+				$name_fields = array_merge($name_fields, $surname_tradition->newChildNames($father_name, $mother_name, $gender));
2359
+				break;
2360
+			case 'add_child_to_individual_action':
2361
+				if ($person->getSex() === 'F') {
2362
+					$name_fields = array_merge($name_fields, $surname_tradition->newChildNames('', $indi_name, $gender));
2363
+				} else {
2364
+					$name_fields = array_merge($name_fields, $surname_tradition->newChildNames($indi_name, '', $gender));
2365
+				}
2366
+				break;
2367
+			case 'add_parent_to_individual_action':
2368
+				$name_fields = array_merge($name_fields, $surname_tradition->newParentNames($indi_name, $gender));
2369
+				break;
2370
+			case 'add_spouse_to_family_action':
2371
+				if ($father) {
2372
+					$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($father_name, $gender));
2373
+				} else {
2374
+					$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($mother_name, $gender));
2375
+				}
2376
+				break;
2377
+			case 'add_spouse_to_individual_action':
2378
+				$name_fields = array_merge($name_fields, $surname_tradition->newSpouseNames($indi_name, $gender));
2379
+				break;
2380
+			case 'add_unlinked_indi_action':
2381
+			case 'update':
2382
+				if ($surname_tradition->hasSurnames()) {
2383
+					$name_fields['NAME'] = '//';
2384
+				}
2385
+				break;
2386 2386
 		}
2387 2387
 	}
2388 2388
 
@@ -2403,15 +2403,15 @@  discard block
 block discarded – undo
2403 2403
 	echo '<table class="facts_table">';
2404 2404
 
2405 2405
 	switch ($nextaction) {
2406
-	case 'add_child_to_family_action':
2407
-	case 'add_child_to_individual_action':
2408
-		// When adding a new child, specify the pedigree
2409
-		FunctionsEdit::addSimpleTag('0 PEDI');
2410
-		break;
2411
-	case 'update':
2412
-		// When adding/editing a name, specify the type
2413
-		FunctionsEdit::addSimpleTag('0 TYPE ' . $name_type, '', '', null, $person);
2414
-		break;
2406
+		case 'add_child_to_family_action':
2407
+		case 'add_child_to_individual_action':
2408
+			// When adding a new child, specify the pedigree
2409
+			FunctionsEdit::addSimpleTag('0 PEDI');
2410
+			break;
2411
+		case 'update':
2412
+			// When adding/editing a name, specify the type
2413
+			FunctionsEdit::addSimpleTag('0 TYPE ' . $name_type, '', '', null, $person);
2414
+			break;
2415 2415
 	}
2416 2416
 
2417 2417
 	// First - new/existing standard name fields
Please login to merge, or discard this patch.
admin_site_change.php 1 patch
Switch Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
 			// Datatables numbers columns 0, 1, 2
152 152
 			// MySQL numbers columns 1, 2, 3
153 153
 			switch ($value['dir']) {
154
-			case 'asc':
155
-				$order_by .= (1 + $value['column']) . " ASC ";
156
-				break;
157
-			case 'desc':
158
-				$order_by .= (1 + $value['column']) . " DESC ";
159
-				break;
154
+				case 'asc':
155
+					$order_by .= (1 + $value['column']) . " ASC ";
156
+					break;
157
+				case 'desc':
158
+					$order_by .= (1 + $value['column']) . " DESC ";
159
+					break;
160 160
 			}
161 161
 		}
162 162
 	} else {
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 
191 191
 		foreach ($differences as $difference) {
192 192
 			switch ($difference[1]) {
193
-			case MyersDiff::DELETE:
194
-				$diff_lines[] = '<del>' . $difference[0] . '</del>';
195
-				break;
196
-			case MyersDiff::INSERT:
197
-				$diff_lines[] = '<ins>' . $difference[0] . '</ins>';
198
-				break;
199
-			default:
200
-				$diff_lines[] = $difference[0];
193
+				case MyersDiff::DELETE:
194
+					$diff_lines[] = '<del>' . $difference[0] . '</del>';
195
+					break;
196
+				case MyersDiff::INSERT:
197
+					$diff_lines[] = '<ins>' . $difference[0] . '</ins>';
198
+					break;
199
+				default:
200
+					$diff_lines[] = $difference[0];
201 201
 			}
202 202
 		}
203 203
 
Please login to merge, or discard this patch.
mediafirewall.php 1 patch
Switch Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -126,53 +126,53 @@
 block discarded – undo
126 126
 
127 127
 	// vertical and horizontal position of the text
128 128
 	switch ($vpos) {
129
-	default:
130
-	case 'top':
131
-		$taille   = textlength($maxsize, $width, $text);
132
-		$pos_y    = $height * 0.15 + $taille;
133
-		$pos_x    = $width * 0.15;
134
-		$rotation = 0;
135
-		break;
136
-	case 'middle':
137
-		$taille   = textlength($maxsize, $width, $text);
138
-		$pos_y    = ($height + $taille) / 2;
139
-		$pos_x    = $width * 0.15;
140
-		$rotation = 0;
141
-		break;
142
-	case 'bottom':
143
-		$taille   = textlength($maxsize, $width, $text);
144
-		$pos_y    = ($height * .85 - $taille);
145
-		$pos_x    = $width * 0.15;
146
-		$rotation = 0;
147
-		break;
148
-	case 'across':
149
-		switch ($hpos) {
150 129
 		default:
151
-		case 'left':
152
-			$taille   = textlength($maxsize, $hypoth, $text);
153
-			$pos_y    = ($height * .85 - $taille);
130
+		case 'top':
131
+			$taille   = textlength($maxsize, $width, $text);
132
+			$pos_y    = $height * 0.15 + $taille;
154 133
 			$pos_x    = $width * 0.15;
155
-			$rotation = $calc_angle;
134
+			$rotation = 0;
156 135
 			break;
157
-		case 'right':
158
-			$taille   = textlength($maxsize, $hypoth, $text);
159
-			$pos_y    = ($height * .15 - $taille);
160
-			$pos_x    = $width * 0.85;
161
-			$rotation = $calc_angle + 180;
162
-			break;
163
-		case 'top2bottom':
164
-			$taille   = textlength($maxsize, $height, $text);
165
-			$pos_y    = ($height * .15 - $taille);
166
-			$pos_x    = ($width * .90 - $taille);
167
-			$rotation = -90;
136
+		case 'middle':
137
+			$taille   = textlength($maxsize, $width, $text);
138
+			$pos_y    = ($height + $taille) / 2;
139
+			$pos_x    = $width * 0.15;
140
+			$rotation = 0;
168 141
 			break;
169
-		case 'bottom2top':
170
-			$taille   = textlength($maxsize, $height, $text);
171
-			$pos_y    = $height * 0.85;
142
+		case 'bottom':
143
+			$taille   = textlength($maxsize, $width, $text);
144
+			$pos_y    = ($height * .85 - $taille);
172 145
 			$pos_x    = $width * 0.15;
173
-			$rotation = 90;
146
+			$rotation = 0;
174 147
 			break;
175
-		}
148
+		case 'across':
149
+			switch ($hpos) {
150
+				default:
151
+				case 'left':
152
+					$taille   = textlength($maxsize, $hypoth, $text);
153
+					$pos_y    = ($height * .85 - $taille);
154
+					$pos_x    = $width * 0.15;
155
+					$rotation = $calc_angle;
156
+					break;
157
+				case 'right':
158
+					$taille   = textlength($maxsize, $hypoth, $text);
159
+					$pos_y    = ($height * .15 - $taille);
160
+					$pos_x    = $width * 0.85;
161
+					$rotation = $calc_angle + 180;
162
+					break;
163
+				case 'top2bottom':
164
+					$taille   = textlength($maxsize, $height, $text);
165
+					$pos_y    = ($height * .15 - $taille);
166
+					$pos_x    = ($width * .90 - $taille);
167
+					$rotation = -90;
168
+					break;
169
+				case 'bottom2top':
170
+					$taille   = textlength($maxsize, $height, $text);
171
+					$pos_y    = $height * 0.85;
172
+					$pos_x    = $width * 0.15;
173
+					$rotation = 90;
174
+					break;
175
+			}
176 176
 		break;
177 177
 	}
178 178
 
Please login to merge, or discard this patch.
reportengine.php 1 patch
Switch Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -58,32 +58,32 @@  discard block
 block discarded – undo
58 58
 	$newvars[$name]['id'] = $var;
59 59
 	if (!empty($type[$name])) {
60 60
 		switch ($type[$name]) {
61
-		case 'INDI':
62
-			$record = Individual::getInstance($var, $WT_TREE);
63
-			if ($record && $record->canShowName()) {
64
-				$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
65
-			} else {
66
-				$action = 'setup';
67
-			}
68
-			break;
69
-		case 'FAM':
70
-			$record = Family::getInstance($var, $WT_TREE);
71
-			if ($record && $record->canShowName()) {
72
-				$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
73
-			} else {
74
-				$action = 'setup';
75
-			}
76
-			break;
77
-		case 'SOUR':
78
-			$record = Source::getInstance($var, $WT_TREE);
79
-			if ($record && $record->canShowName()) {
80
-				$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
81
-			} else {
82
-				$action = 'setup';
83
-			}
84
-			break;
85
-		default:
86
-			break;
61
+			case 'INDI':
62
+				$record = Individual::getInstance($var, $WT_TREE);
63
+				if ($record && $record->canShowName()) {
64
+					$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
65
+				} else {
66
+					$action = 'setup';
67
+				}
68
+				break;
69
+			case 'FAM':
70
+				$record = Family::getInstance($var, $WT_TREE);
71
+				if ($record && $record->canShowName()) {
72
+					$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
73
+				} else {
74
+					$action = 'setup';
75
+				}
76
+				break;
77
+			case 'SOUR':
78
+				$record = Source::getInstance($var, $WT_TREE);
79
+				if ($record && $record->canShowName()) {
80
+					$newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE));
81
+				} else {
82
+					$action = 'setup';
83
+				}
84
+				break;
85
+			default:
86
+				break;
87 87
 		}
88 88
 	}
89 89
 }
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
 
112 112
 //-- choose a report to run
113 113
 switch ($action) {
114
-case 'choose':
115
-	$controller
116
-		->setPageTitle(I18N::translate('Choose a report to run'))
117
-		->pageHeader();
114
+	case 'choose':
115
+		$controller
116
+			->setPageTitle(I18N::translate('Choose a report to run'))
117
+			->pageHeader();
118 118
 
119
-	echo '<div id="reportengine-page">
119
+		echo '<div id="reportengine-page">
120 120
 		<h2 class="center">', I18N::translate('Choose a report to run'), '</h2>
121 121
 		<form name="choosereport" method="get" action="reportengine.php">
122 122
 		<input type="hidden" name="action" value="setup">
@@ -124,27 +124,27 @@  discard block
 block discarded – undo
124 124
 		<table class="facts_table width40">
125 125
 		<tr><td class="descriptionbox wrap width33 vmiddle">', I18N::translate('Report'), '</td>
126 126
 		<td class="optionbox"><select name="report">';
127
-	foreach ($reports as $file => $report) {
128
-		echo '<option value="', Filter::escapeHtml($file), '">', Filter::escapeHtml($report), '</option>';
129
-	}
130
-	echo '</select></td></tr>
127
+		foreach ($reports as $file => $report) {
128
+			echo '<option value="', Filter::escapeHtml($file), '">', Filter::escapeHtml($report), '</option>';
129
+		}
130
+		echo '</select></td></tr>
131 131
 		<tr><td class="topbottombar" colspan="2"><input type="submit" value="', I18N::translate('continue'), '"></td></tr>
132 132
 		</table></form></div>';
133
-	break;
133
+		break;
134 134
 
135
-case 'setup':
136
-	$report_setup = new ReportParserSetup($report);
137
-	$report_array = $report_setup->reportProperties();
135
+	case 'setup':
136
+		$report_setup = new ReportParserSetup($report);
137
+		$report_array = $report_setup->reportProperties();
138 138
 
139
-	$controller
140
-		->setPageTitle($report_array['title'])
141
-		->pageHeader()
142
-		->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
143
-		->addInlineJavascript('autocomplete();');
139
+		$controller
140
+			->setPageTitle($report_array['title'])
141
+			->pageHeader()
142
+			->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
143
+			->addInlineJavascript('autocomplete();');
144 144
 
145
-	FunctionsPrint::initializeCalendarPopup();
145
+		FunctionsPrint::initializeCalendarPopup();
146 146
 
147
-	echo '<div id="reportengine-page">
147
+		echo '<div id="reportengine-page">
148 148
 		<h2 class="center">', $report_array['title'], '</h2>
149 149
 		<form name="setupreport" method="get" action="reportengine.php">
150 150
 		<input type="hidden" name="action" value="run">
@@ -152,55 +152,55 @@  discard block
 block discarded – undo
152 152
 		<table class="facts_table width50">
153 153
 		<tr><td class="descriptionbox width30 wrap">', I18N::translate('Report'), '</td><td class="optionbox">', $report_array['description'], '</td></tr>';
154 154
 
155
-	if (!isset($report_array['inputs'])) {
156
-		$report_array['inputs'] = array();
157
-	}
158
-	foreach ($report_array['inputs'] as $input) {
159
-		echo '<tr><td class="descriptionbox wrap">';
160
-		echo '<input type="hidden" name="varnames[]" value="', Filter::escapeHtml($input["name"]), '">';
161
-		echo I18N::translate($input['value']), '</td><td class="optionbox">';
162
-		if (!isset($input['type'])) {
163
-			$input['type'] = 'text';
164
-		}
165
-		if (!isset($input['default'])) {
166
-			$input['default'] = '';
167
-		}
168
-		if (!isset($input['lookup'])) {
169
-			$input['lookup'] = '';
155
+		if (!isset($report_array['inputs'])) {
156
+			$report_array['inputs'] = array();
170 157
 		}
158
+		foreach ($report_array['inputs'] as $input) {
159
+			echo '<tr><td class="descriptionbox wrap">';
160
+			echo '<input type="hidden" name="varnames[]" value="', Filter::escapeHtml($input["name"]), '">';
161
+			echo I18N::translate($input['value']), '</td><td class="optionbox">';
162
+			if (!isset($input['type'])) {
163
+				$input['type'] = 'text';
164
+			}
165
+			if (!isset($input['default'])) {
166
+				$input['default'] = '';
167
+			}
168
+			if (!isset($input['lookup'])) {
169
+				$input['lookup'] = '';
170
+			}
171 171
 
172
-		if ($input['type'] == 'text') {
173
-			echo '<input';
172
+			if ($input['type'] == 'text') {
173
+				echo '<input';
174 174
 
175
-			switch ($input['lookup']) {
176
-			case 'INDI':
177
-				echo ' data-autocomplete-type="INDI"';
178
-				if (!empty($pid)) {
179
-					$input['default'] = $pid;
180
-				} else {
181
-					$input['default'] = $controller->getSignificantIndividual()->getXref();
182
-				}
183
-				break;
184
-			case 'FAM':
185
-				echo ' data-autocomplete-type="FAM"';
186
-				if (!empty($famid)) {
187
-					$input['default'] = $famid;
188
-				} else {
189
-					$input['default'] = $controller->getSignificantFamily()->getXref();
190
-				}
191
-				break;
192
-			case 'SOUR':
193
-				echo ' data-autocomplete-type="SOUR"';
194
-				if (!empty($sid)) {
195
-					$input['default'] = $sid;
196
-				}
197
-				break;
198
-			case 'DATE':
199
-				if (isset($input['default'])) {
200
-					$input['default'] = strtoupper($input['default']);
175
+				switch ($input['lookup']) {
176
+					case 'INDI':
177
+						echo ' data-autocomplete-type="INDI"';
178
+						if (!empty($pid)) {
179
+							$input['default'] = $pid;
180
+						} else {
181
+							$input['default'] = $controller->getSignificantIndividual()->getXref();
182
+						}
183
+						break;
184
+					case 'FAM':
185
+						echo ' data-autocomplete-type="FAM"';
186
+						if (!empty($famid)) {
187
+							$input['default'] = $famid;
188
+						} else {
189
+							$input['default'] = $controller->getSignificantFamily()->getXref();
190
+						}
191
+						break;
192
+					case 'SOUR':
193
+						echo ' data-autocomplete-type="SOUR"';
194
+						if (!empty($sid)) {
195
+							$input['default'] = $sid;
196
+						}
197
+						break;
198
+					case 'DATE':
199
+						if (isset($input['default'])) {
200
+							$input['default'] = strtoupper($input['default']);
201
+						}
202
+						break;
201 203
 				}
202
-				break;
203
-			}
204 204
 
205 205
 			echo ' type="text" name="vars[', Filter::escapeHtml($input['name']), ']" id="', Filter::escapeHtml($input['name']), '" value="', Filter::escapeHtml($input['default']), '" style="direction: ltr;">';
206 206
 		}
@@ -266,20 +266,20 @@  discard block
 block discarded – undo
266 266
 		</td></tr></table></form></div>';
267 267
 	break;
268 268
 
269
-case 'run':
270
-	if (strstr($report, 'report_singlepage.xml') !== false) {
271
-		// This is a custom module?
272
-		new \ReportPedigree;
273
-		break;
274
-	}
269
+	case 'run':
270
+		if (strstr($report, 'report_singlepage.xml') !== false) {
271
+			// This is a custom module?
272
+			new \ReportPedigree;
273
+			break;
274
+		}
275 275
 
276
-	switch ($output) {
277
-	case 'HTML':
278
-		header('Content-type: text/html; charset=UTF-8');
279
-		new ReportParserGenerate($report, new ReportHtml, $vars);
280
-		break;
281
-	case 'PDF':
282
-		new ReportParserGenerate($report, new ReportPdf, $vars);
283
-		break;
284
-	}
276
+		switch ($output) {
277
+			case 'HTML':
278
+				header('Content-type: text/html; charset=UTF-8');
279
+				new ReportParserGenerate($report, new ReportHtml, $vars);
280
+				break;
281
+			case 'PDF':
282
+				new ReportParserGenerate($report, new ReportPdf, $vars);
283
+				break;
284
+		}
285 285
 }
Please login to merge, or discard this patch.
addmedia.php 1 patch
Switch Indentation   +281 added lines, -281 removed lines patch added patch discarded remove patch
@@ -76,338 +76,338 @@
 block discarded – undo
76 76
 // …and also in the admin_media_upload.php script
77 77
 
78 78
 switch ($action) {
79
-case 'create': // Save the information from the “showcreateform” action
80
-	$controller->setPageTitle(I18N::translate('Create a media object'));
81
-
82
-	// Validate the media folder
83
-	$folderName = str_replace('\\', '/', $folder);
84
-	$folderName = trim($folderName, '/');
85
-	if ($folderName == '.') {
86
-		$folderName = '';
87
-	}
88
-	if ($folderName) {
89
-		$folderName .= '/';
90
-		// Not allowed to use “../”
91
-		if (strpos('/' . $folderName, '/../') !== false) {
92
-			FlashMessages::addMessage('Folder names are not allowed to include “../”');
93
-			break;
79
+	case 'create': // Save the information from the “showcreateform” action
80
+		$controller->setPageTitle(I18N::translate('Create a media object'));
81
+
82
+		// Validate the media folder
83
+		$folderName = str_replace('\\', '/', $folder);
84
+		$folderName = trim($folderName, '/');
85
+		if ($folderName == '.') {
86
+			$folderName = '';
94 87
 		}
95
-	}
96
-
97
-	// Make sure the media folder exists
98
-	if (!is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
99
-		if (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
100
-			FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)));
101
-		} else {
102
-			FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'danger');
103
-			break;
88
+		if ($folderName) {
89
+			$folderName .= '/';
90
+			// Not allowed to use “../”
91
+			if (strpos('/' . $folderName, '/../') !== false) {
92
+				FlashMessages::addMessage('Folder names are not allowed to include “../”');
93
+				break;
94
+			}
104 95
 		}
105
-	}
106 96
 
107
-	// Managers can create new media paths (subfolders). Users must use existing folders.
108
-	if ($folderName && !is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) {
109
-		if (Auth::isManager($WT_TREE)) {
110
-			if (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) {
111
-				FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)));
97
+		// Make sure the media folder exists
98
+		if (!is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
99
+			if (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
100
+				FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)));
112 101
 			} else {
113
-				FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)), 'danger');
102
+				FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'danger');
114 103
 				break;
115 104
 			}
116
-		} else {
117
-			// Regular users should not have seen this option - so no need for an error message.
118
-			break;
119 105
 		}
120
-	}
121 106
 
122
-	// The media folder exists. Now create a thumbnail folder to match it.
123
-	if (!is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)) {
124
-		if (!File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)) {
125
-			FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)), 'danger');
126
-			break;
107
+		// Managers can create new media paths (subfolders). Users must use existing folders.
108
+		if ($folderName && !is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) {
109
+			if (Auth::isManager($WT_TREE)) {
110
+				if (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) {
111
+					FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)));
112
+				} else {
113
+					FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)), 'danger');
114
+					break;
115
+				}
116
+			} else {
117
+				// Regular users should not have seen this option - so no need for an error message.
118
+				break;
119
+			}
127 120
 		}
128
-	}
129 121
 
130
-	// A thumbnail file with no main image?
131
-	if (!empty($_FILES['thumbnail']['name']) && empty($_FILES['mediafile']['name'])) {
132
-		// Assume the user used the wrong field, and treat this as a main image
133
-		$_FILES['mediafile'] = $_FILES['thumbnail'];
134
-		unset($_FILES['thumbnail']);
135
-	}
122
+		// The media folder exists. Now create a thumbnail folder to match it.
123
+		if (!is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)) {
124
+			if (!File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)) {
125
+				FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)), 'danger');
126
+				break;
127
+			}
128
+		}
136 129
 
137
-	// Thumbnail files must contain images.
138
-	if (!empty($_FILES['thumbnail']['name']) && !preg_match('/^image/', $_FILES['thumbnail']['type'])) {
139
-		FlashMessages::addMessage(I18N::translate('Thumbnail files must contain images.'));
140
-		break;
141
-	}
130
+		// A thumbnail file with no main image?
131
+		if (!empty($_FILES['thumbnail']['name']) && empty($_FILES['mediafile']['name'])) {
132
+			// Assume the user used the wrong field, and treat this as a main image
133
+			$_FILES['mediafile'] = $_FILES['thumbnail'];
134
+			unset($_FILES['thumbnail']);
135
+		}
142 136
 
143
-	// User-specified filename?
144
-	if ($tag[0] == 'FILE' && $text[0]) {
145
-		$filename = $text[0];
146
-	}
147
-	// Use the name of the uploaded file?
148
-	// If no filename specified, use the name of the uploaded file?
149
-	if (!$filename && !empty($_FILES['mediafile']['name'])) {
150
-		$filename = $_FILES['mediafile']['name'];
151
-	}
137
+		// Thumbnail files must contain images.
138
+		if (!empty($_FILES['thumbnail']['name']) && !preg_match('/^image/', $_FILES['thumbnail']['type'])) {
139
+			FlashMessages::addMessage(I18N::translate('Thumbnail files must contain images.'));
140
+			break;
141
+		}
152 142
 
153
-	// Validate the media path and filename
154
-	if (preg_match('/^https?:\/\//i', $text[0], $match)) {
155
-		// External media needs no further validation
156
-		$fileName   = $filename;
157
-		$folderName = '';
158
-		unset($_FILES['mediafile'], $_FILES['thumbnail']);
159
-	} elseif (preg_match('/([\/\\\\<>])/', $filename, $match)) {
160
-		// Local media files cannot contain certain special characters
161
-		FlashMessages::addMessage(I18N::translate('Filenames are not allowed to contain the character “%s”.', $match[1]));
162
-		break;
163
-	} elseif (preg_match('/(\.(php|pl|cgi|bash|sh|bat|exe|com|htm|html|shtml))$/i', $filename, $match)) {
164
-		// Do not allow obvious script files.
165
-		FlashMessages::addMessage(I18N::translate('Filenames are not allowed to have the extension “%s”.', $match[1]));
166
-		break;
167
-	} elseif (!$filename) {
168
-		FlashMessages::addMessage(I18N::translate('No media file was provided.'));
169
-		break;
170
-	} else {
171
-		$fileName = $filename;
172
-	}
143
+		// User-specified filename?
144
+		if ($tag[0] == 'FILE' && $text[0]) {
145
+			$filename = $text[0];
146
+		}
147
+		// Use the name of the uploaded file?
148
+		// If no filename specified, use the name of the uploaded file?
149
+		if (!$filename && !empty($_FILES['mediafile']['name'])) {
150
+			$filename = $_FILES['mediafile']['name'];
151
+		}
173 152
 
174
-	// Now copy the file to the correct location.
175
-	if (!empty($_FILES['mediafile']['name'])) {
176
-		$serverFileName = WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName . $fileName;
177
-		if (file_exists($serverFileName)) {
178
-			FlashMessages::addMessage(I18N::translate('The file %s already exists. Use another filename.', $folderName . $fileName));
153
+		// Validate the media path and filename
154
+		if (preg_match('/^https?:\/\//i', $text[0], $match)) {
155
+			// External media needs no further validation
156
+			$fileName   = $filename;
157
+			$folderName = '';
158
+			unset($_FILES['mediafile'], $_FILES['thumbnail']);
159
+		} elseif (preg_match('/([\/\\\\<>])/', $filename, $match)) {
160
+			// Local media files cannot contain certain special characters
161
+			FlashMessages::addMessage(I18N::translate('Filenames are not allowed to contain the character “%s”.', $match[1]));
179 162
 			break;
180
-		}
181
-		if (move_uploaded_file($_FILES['mediafile']['tmp_name'], $serverFileName)) {
182
-			Log::addMediaLog('Media file ' . $serverFileName . ' uploaded');
183
-		} else {
184
-			FlashMessages::addMessage(
185
-				I18N::translate('There was an error uploading your file.') .
186
-				'<br>' .
187
-				Functions::fileUploadErrorText($_FILES['mediafile']['error'])
188
-			);
163
+		} elseif (preg_match('/(\.(php|pl|cgi|bash|sh|bat|exe|com|htm|html|shtml))$/i', $filename, $match)) {
164
+			// Do not allow obvious script files.
165
+			FlashMessages::addMessage(I18N::translate('Filenames are not allowed to have the extension “%s”.', $match[1]));
166
+			break;
167
+		} elseif (!$filename) {
168
+			FlashMessages::addMessage(I18N::translate('No media file was provided.'));
189 169
 			break;
170
+		} else {
171
+			$fileName = $filename;
190 172
 		}
191 173
 
192
-		// Now copy the (optional) thumbnail
193
-		if (!empty($_FILES['thumbnail']['name']) && preg_match('/^image\/(png|gif|jpeg)/', $_FILES['thumbnail']['type'], $match)) {
194
-			// Thumbnails have either
195
-			// (a) the same filename as the main image
196
-			// (b) the same filename as the main image - but with a .png extension
197
-			if ($match[1] == 'png' && !preg_match('/\.(png)$/i', $fileName)) {
198
-				$thumbFile = preg_replace('/\.[a-z0-9]{3,5}$/', '.png', $fileName);
174
+		// Now copy the file to the correct location.
175
+		if (!empty($_FILES['mediafile']['name'])) {
176
+			$serverFileName = WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName . $fileName;
177
+			if (file_exists($serverFileName)) {
178
+				FlashMessages::addMessage(I18N::translate('The file %s already exists. Use another filename.', $folderName . $fileName));
179
+				break;
180
+			}
181
+			if (move_uploaded_file($_FILES['mediafile']['tmp_name'], $serverFileName)) {
182
+				Log::addMediaLog('Media file ' . $serverFileName . ' uploaded');
199 183
 			} else {
200
-				$thumbFile = $fileName;
184
+				FlashMessages::addMessage(
185
+					I18N::translate('There was an error uploading your file.') .
186
+					'<br>' .
187
+					Functions::fileUploadErrorText($_FILES['mediafile']['error'])
188
+				);
189
+				break;
201 190
 			}
202
-			$serverFileName = WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName . $thumbFile;
203
-			if (move_uploaded_file($_FILES['thumbnail']['tmp_name'], $serverFileName)) {
204
-				Log::addMediaLog('Thumbnail file ' . $serverFileName . ' uploaded');
191
+
192
+			// Now copy the (optional) thumbnail
193
+			if (!empty($_FILES['thumbnail']['name']) && preg_match('/^image\/(png|gif|jpeg)/', $_FILES['thumbnail']['type'], $match)) {
194
+				// Thumbnails have either
195
+				// (a) the same filename as the main image
196
+				// (b) the same filename as the main image - but with a .png extension
197
+				if ($match[1] == 'png' && !preg_match('/\.(png)$/i', $fileName)) {
198
+					$thumbFile = preg_replace('/\.[a-z0-9]{3,5}$/', '.png', $fileName);
199
+				} else {
200
+					$thumbFile = $fileName;
201
+				}
202
+				$serverFileName = WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName . $thumbFile;
203
+				if (move_uploaded_file($_FILES['thumbnail']['tmp_name'], $serverFileName)) {
204
+					Log::addMediaLog('Thumbnail file ' . $serverFileName . ' uploaded');
205
+				}
205 206
 			}
206 207
 		}
207
-	}
208 208
 
209
-	$controller->pageHeader();
210
-	// Build the gedcom record
211
-	$newged = "0 @new@ OBJE";
212
-	if ($tag[0] == 'FILE') {
213
-		// The admin has an edit field to change the filename
214
-		$text[0] = $folderName . $fileName;
215
-	} else {
216
-		// Users keep the original filename
217
-		$newged .= "\n1 FILE " . $folderName . $fileName;
218
-	}
209
+		$controller->pageHeader();
210
+		// Build the gedcom record
211
+		$newged = "0 @new@ OBJE";
212
+		if ($tag[0] == 'FILE') {
213
+			// The admin has an edit field to change the filename
214
+			$text[0] = $folderName . $fileName;
215
+		} else {
216
+			// Users keep the original filename
217
+			$newged .= "\n1 FILE " . $folderName . $fileName;
218
+		}
219 219
 
220
-	$newged = FunctionsEdit::handleUpdates($newged);
220
+		$newged = FunctionsEdit::handleUpdates($newged);
221 221
 
222
-	$new_media = $WT_TREE->createRecord($newged);
223
-	if ($linktoid) {
224
-		$record = GedcomRecord::getInstance($linktoid, $WT_TREE);
225
-		$record->createFact('1 OBJE @' . $new_media->getXref() . '@', true);
226
-		Log::addEditLog('Media ID ' . $new_media->getXref() . " successfully added to $linktoid.");
227
-		$controller->addInlineJavascript('closePopupAndReloadParent();');
228
-	} else {
229
-		Log::addEditLog('Media ID ' . $new_media->getXref() . ' successfully added.');
230
-		$controller->addInlineJavascript('openerpasteid("' . $new_media->getXref() . '");');
231
-	}
232
-	echo '<button onclick="closePopupAndReloadParent();">', I18N::translate('close'), '</button>';
222
+		$new_media = $WT_TREE->createRecord($newged);
223
+		if ($linktoid) {
224
+			$record = GedcomRecord::getInstance($linktoid, $WT_TREE);
225
+			$record->createFact('1 OBJE @' . $new_media->getXref() . '@', true);
226
+			Log::addEditLog('Media ID ' . $new_media->getXref() . " successfully added to $linktoid.");
227
+			$controller->addInlineJavascript('closePopupAndReloadParent();');
228
+		} else {
229
+			Log::addEditLog('Media ID ' . $new_media->getXref() . ' successfully added.');
230
+			$controller->addInlineJavascript('openerpasteid("' . $new_media->getXref() . '");');
231
+		}
232
+		echo '<button onclick="closePopupAndReloadParent();">', I18N::translate('close'), '</button>';
233 233
 
234
-	return;
234
+		return;
235 235
 
236
-case 'update': // Save the information from the “editmedia” action
237
-	$controller->setPageTitle(I18N::translate('Edit the media object'));
236
+	case 'update': // Save the information from the “editmedia” action
237
+		$controller->setPageTitle(I18N::translate('Edit the media object'));
238 238
 
239
-	// Validate the media folder
240
-	$folderName = str_replace('\\', '/', $folder);
241
-	$folderName = trim($folderName, '/');
242
-	if ($folderName == '.') {
243
-		$folderName = '';
244
-	}
245
-	if ($folderName) {
246
-		$folderName .= '/';
247
-		// Not allowed to use “../”
248
-		if (strpos('/' . $folderName, '/../') !== false) {
249
-			FlashMessages::addMessage('Folder names are not allowed to include “../”');
250
-			break;
239
+		// Validate the media folder
240
+		$folderName = str_replace('\\', '/', $folder);
241
+		$folderName = trim($folderName, '/');
242
+		if ($folderName == '.') {
243
+			$folderName = '';
251 244
 		}
252
-	}
253
-
254
-	// Make sure the media folder exists
255
-	if (!is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
256
-		if (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
257
-			FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)));
258
-		} else {
259
-			FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'danger');
260
-			break;
245
+		if ($folderName) {
246
+			$folderName .= '/';
247
+			// Not allowed to use “../”
248
+			if (strpos('/' . $folderName, '/../') !== false) {
249
+				FlashMessages::addMessage('Folder names are not allowed to include “../”');
250
+				break;
251
+			}
261 252
 		}
262
-	}
263 253
 
264
-	// Managers can create new media paths (subfolders). Users must use existing folders.
265
-	if ($folderName && !is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) {
266
-		if (Auth::isManager($WT_TREE)) {
267
-			if (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) {
268
-				FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)));
254
+		// Make sure the media folder exists
255
+		if (!is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
256
+			if (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
257
+				FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)));
269 258
 			} else {
270
-				FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)), 'danger');
259
+				FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'danger');
271 260
 				break;
272 261
 			}
273
-		} else {
274
-			// Regular users should not have seen this option - so no need for an error message.
275
-			break;
276 262
 		}
277
-	}
278 263
 
279
-	// The media folder exists. Now create a thumbnail folder to match it.
280
-	if (!is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)) {
281
-		if (!File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)) {
282
-			FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)), 'danger');
283
-			break;
264
+		// Managers can create new media paths (subfolders). Users must use existing folders.
265
+		if ($folderName && !is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) {
266
+			if (Auth::isManager($WT_TREE)) {
267
+				if (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)) {
268
+					FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)));
269
+				} else {
270
+					FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . $folderName)), 'danger');
271
+					break;
272
+				}
273
+			} else {
274
+				// Regular users should not have seen this option - so no need for an error message.
275
+				break;
276
+			}
284 277
 		}
285
-	}
286
-
287
-	// Validate the media path and filename
288
-	if (preg_match('/^https?:\/\//i', $filename, $match)) {
289
-		// External media needs no further validation
290
-		$fileName   = $filename;
291
-		$folderName = '';
292
-		unset($_FILES['mediafile'], $_FILES['thumbnail']);
293
-	} elseif (preg_match('/([\/\\\\<>])/', $filename, $match)) {
294
-		// Local media files cannot contain certain special characters
295
-		FlashMessages::addMessage(I18N::translate('Filenames are not allowed to contain the character “%s”.', $match[1]));
296
-		break;
297
-	} elseif (preg_match('/(\.(php|pl|cgi|bash|sh|bat|exe|com|htm|html|shtml))$/i', $filename, $match)) {
298
-		// Do not allow obvious script files.
299
-		FlashMessages::addMessage(I18N::translate('Filenames are not allowed to have the extension “%s”.', $match[1]));
300
-		break;
301
-	} elseif (!$filename) {
302
-		FlashMessages::addMessage(I18N::translate('No media file was provided.'));
303
-		break;
304
-	} else {
305
-		$fileName = $filename;
306
-	}
307 278
 
308
-	$oldFilename = $media->getFilename();
309
-	$newFilename = $folderName . $fileName;
310
-
311
-	// Cannot rename local to external or vice-versa
312
-	if (Functions::isFileExternal($oldFilename) != Functions::isFileExternal($filename)) {
313
-		FlashMessages::addMessage(I18N::translate('The media file %1$s could not be renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
314
-		break;
315
-	}
279
+		// The media folder exists. Now create a thumbnail folder to match it.
280
+		if (!is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)) {
281
+			if (!File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)) {
282
+				FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY . 'thumbs/' . $folderName)), 'danger');
283
+				break;
284
+			}
285
+		}
316 286
 
317
-	$messages  = false;
318
-	$move_file = false;
287
+		// Validate the media path and filename
288
+		if (preg_match('/^https?:\/\//i', $filename, $match)) {
289
+			// External media needs no further validation
290
+			$fileName   = $filename;
291
+			$folderName = '';
292
+			unset($_FILES['mediafile'], $_FILES['thumbnail']);
293
+		} elseif (preg_match('/([\/\\\\<>])/', $filename, $match)) {
294
+			// Local media files cannot contain certain special characters
295
+			FlashMessages::addMessage(I18N::translate('Filenames are not allowed to contain the character “%s”.', $match[1]));
296
+			break;
297
+		} elseif (preg_match('/(\.(php|pl|cgi|bash|sh|bat|exe|com|htm|html|shtml))$/i', $filename, $match)) {
298
+			// Do not allow obvious script files.
299
+			FlashMessages::addMessage(I18N::translate('Filenames are not allowed to have the extension “%s”.', $match[1]));
300
+			break;
301
+		} elseif (!$filename) {
302
+			FlashMessages::addMessage(I18N::translate('No media file was provided.'));
303
+			break;
304
+		} else {
305
+			$fileName = $filename;
306
+		}
319 307
 
320
-	// Move files on disk (if we can) to reflect the change to the GEDCOM data
321
-	if (!$media->isExternal()) {
322
-		$oldServerFile  = $media->getServerFilename('main');
323
-		$oldServerThumb = $media->getServerFilename('thumb');
308
+		$oldFilename = $media->getFilename();
309
+		$newFilename = $folderName . $fileName;
324 310
 
325
-		$newmedia       = new Media("xxx", "0 @xxx@ OBJE\n1 FILE " . $newFilename, null, $WT_TREE);
326
-		$newServerFile  = $newmedia->getServerFilename('main');
327
-		$newServerThumb = $newmedia->getServerFilename('thumb');
311
+		// Cannot rename local to external or vice-versa
312
+		if (Functions::isFileExternal($oldFilename) != Functions::isFileExternal($filename)) {
313
+			FlashMessages::addMessage(I18N::translate('The media file %1$s could not be renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
314
+			break;
315
+		}
328 316
 
329
-		// We could be either renaming an existing file, or updating a record (with no valid file) to point to a new file
330
-		if ($oldServerFile !== $newServerFile) {
331
-			//-- check if the file is used in more than one gedcom
332
-			//-- do not allow it to be moved or renamed if it is
333
-			if (!$media->isExternal() && FunctionsDb::isMediaUsedInOtherTree($media->getFilename(), $WT_TREE->getTreeId())) {
334
-				FlashMessages::addMessage(I18N::translate('This file is linked to another family tree on this server. It cannot be deleted, moved, or renamed until these links have been removed.'));
335
-				break;
336
-			}
317
+		$messages  = false;
318
+		$move_file = false;
319
+
320
+		// Move files on disk (if we can) to reflect the change to the GEDCOM data
321
+		if (!$media->isExternal()) {
322
+			$oldServerFile  = $media->getServerFilename('main');
323
+			$oldServerThumb = $media->getServerFilename('thumb');
324
+
325
+			$newmedia       = new Media("xxx", "0 @xxx@ OBJE\n1 FILE " . $newFilename, null, $WT_TREE);
326
+			$newServerFile  = $newmedia->getServerFilename('main');
327
+			$newServerThumb = $newmedia->getServerFilename('thumb');
328
+
329
+			// We could be either renaming an existing file, or updating a record (with no valid file) to point to a new file
330
+			if ($oldServerFile !== $newServerFile) {
331
+				//-- check if the file is used in more than one gedcom
332
+				//-- do not allow it to be moved or renamed if it is
333
+				if (!$media->isExternal() && FunctionsDb::isMediaUsedInOtherTree($media->getFilename(), $WT_TREE->getTreeId())) {
334
+					FlashMessages::addMessage(I18N::translate('This file is linked to another family tree on this server. It cannot be deleted, moved, or renamed until these links have been removed.'));
335
+					break;
336
+				}
337 337
 
338
-			$move_file = true;
339
-			if (!file_exists($newServerFile) || md5_file($oldServerFile) === md5_file($newServerFile)) {
340
-				try {
341
-					rename($oldServerFile, $newServerFile);
342
-					FlashMessages::addMessage(I18N::translate('The media file %1$s has been renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
343
-				} catch (\ErrorException $ex) {
344
-					FlashMessages::addMessage(I18N::translate('The media file %1$s could not be renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
338
+				$move_file = true;
339
+				if (!file_exists($newServerFile) || md5_file($oldServerFile) === md5_file($newServerFile)) {
340
+					try {
341
+						rename($oldServerFile, $newServerFile);
342
+						FlashMessages::addMessage(I18N::translate('The media file %1$s has been renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
343
+					} catch (\ErrorException $ex) {
344
+						FlashMessages::addMessage(I18N::translate('The media file %1$s could not be renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
345
+					}
346
+					$messages = true;
345 347
 				}
346
-				$messages = true;
347
-			}
348
-			if (!file_exists($newServerFile)) {
349
-				FlashMessages::addMessage(I18N::translate('The media file %s does not exist.', Html::filename($newFilename)));
350
-				$messages = true;
351
-			}
352
-		}
353
-		if ($oldServerThumb != $newServerThumb) {
354
-			$move_file = true;
355
-			if (!file_exists($newServerThumb) || md5_file($oldServerFile) == md5_file($newServerThumb)) {
356
-				try {
357
-					rename($oldServerThumb, $newServerThumb);
358
-					FlashMessages::addMessage(I18N::translate('The thumbnail file %1$s has been renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
359
-				} catch (\ErrorException $ex) {
360
-					FlashMessages::addMessage(I18N::translate('The thumbnail file %1$s could not be renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
348
+				if (!file_exists($newServerFile)) {
349
+					FlashMessages::addMessage(I18N::translate('The media file %s does not exist.', Html::filename($newFilename)));
350
+					$messages = true;
361 351
 				}
362
-				$messages = true;
363 352
 			}
364
-			if (!file_exists($newServerThumb)) {
365
-				FlashMessages::addMessage(I18N::translate('The thumbnail file %s does not exist.', Html::filename($newFilename)));
366
-				$messages = true;
353
+			if ($oldServerThumb != $newServerThumb) {
354
+				$move_file = true;
355
+				if (!file_exists($newServerThumb) || md5_file($oldServerFile) == md5_file($newServerThumb)) {
356
+					try {
357
+						rename($oldServerThumb, $newServerThumb);
358
+						FlashMessages::addMessage(I18N::translate('The thumbnail file %1$s has been renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
359
+					} catch (\ErrorException $ex) {
360
+						FlashMessages::addMessage(I18N::translate('The thumbnail file %1$s could not be renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
361
+					}
362
+					$messages = true;
363
+				}
364
+				if (!file_exists($newServerThumb)) {
365
+					FlashMessages::addMessage(I18N::translate('The thumbnail file %s does not exist.', Html::filename($newFilename)));
366
+					$messages = true;
367
+				}
367 368
 			}
368 369
 		}
369
-	}
370 370
 
371
-	// Insert the 1 FILE xxx record into the arrays used by function FunctionsEdit::handle_updatesges()
372
-	$glevels = array_merge(array('1'), $glevels);
373
-	$tag     = array_merge(array('FILE'), $tag);
374
-	$islink  = array_merge(array(0), $islink);
375
-	$text    = array_merge(array($newFilename), $text);
376
-
377
-	$record = GedcomRecord::getInstance($pid, $WT_TREE);
378
-	$newrec = "0 @$pid@ OBJE\n";
379
-	$newrec = FunctionsEdit::handleUpdates($newrec);
380
-	$record->updateRecord($newrec, $update_CHAN);
381
-
382
-	if ($move_file) {
383
-		// We've moved a file. Therefore we must approve the change, as rejecting
384
-		// the change will create broken references.
385
-		FunctionsImport::acceptAllChanges($record->getXref(), $record->getTree()->getTreeId());
386
-	}
371
+		// Insert the 1 FILE xxx record into the arrays used by function FunctionsEdit::handle_updatesges()
372
+		$glevels = array_merge(array('1'), $glevels);
373
+		$tag     = array_merge(array('FILE'), $tag);
374
+		$islink  = array_merge(array(0), $islink);
375
+		$text    = array_merge(array($newFilename), $text);
376
+
377
+		$record = GedcomRecord::getInstance($pid, $WT_TREE);
378
+		$newrec = "0 @$pid@ OBJE\n";
379
+		$newrec = FunctionsEdit::handleUpdates($newrec);
380
+		$record->updateRecord($newrec, $update_CHAN);
381
+
382
+		if ($move_file) {
383
+			// We've moved a file. Therefore we must approve the change, as rejecting
384
+			// the change will create broken references.
385
+			FunctionsImport::acceptAllChanges($record->getXref(), $record->getTree()->getTreeId());
386
+		}
387 387
 
388
-	if ($pid && $linktoid) {
389
-		$record = GedcomRecord::getInstance($linktoid, $WT_TREE);
390
-		$record->createFact('1 OBJE @' . $pid . '@', true);
391
-		Log::addEditLog('Media ID ' . $pid . " successfully added to $linktoid.");
392
-	}
393
-	$controller->pageHeader();
394
-	if ($messages) {
395
-		echo '<button onclick="closePopupAndReloadParent();">', I18N::translate('close'), '</button>';
396
-	} else {
397
-		$controller->addInlineJavascript('closePopupAndReloadParent();');
398
-	}
388
+		if ($pid && $linktoid) {
389
+			$record = GedcomRecord::getInstance($linktoid, $WT_TREE);
390
+			$record->createFact('1 OBJE @' . $pid . '@', true);
391
+			Log::addEditLog('Media ID ' . $pid . " successfully added to $linktoid.");
392
+		}
393
+		$controller->pageHeader();
394
+		if ($messages) {
395
+			echo '<button onclick="closePopupAndReloadParent();">', I18N::translate('close'), '</button>';
396
+		} else {
397
+			$controller->addInlineJavascript('closePopupAndReloadParent();');
398
+		}
399 399
 
400
-	return;
401
-case 'showmediaform':
402
-	$controller->setPageTitle(I18N::translate('Create a media object'));
403
-	$action = 'create';
404
-	break;
405
-case 'editmedia':
406
-	$controller->setPageTitle(I18N::translate('Edit the media object'));
407
-	$action = 'update';
408
-	break;
409
-default:
410
-	throw new \Exception('Bad $action (' . $action . ') in addmedia.php');
400
+		return;
401
+	case 'showmediaform':
402
+		$controller->setPageTitle(I18N::translate('Create a media object'));
403
+		$action = 'create';
404
+		break;
405
+	case 'editmedia':
406
+		$controller->setPageTitle(I18N::translate('Edit the media object'));
407
+		$action = 'update';
408
+		break;
409
+	default:
410
+		throw new \Exception('Bad $action (' . $action . ') in addmedia.php');
411 411
 }
412 412
 
413 413
 $controller->pageHeader();
Please login to merge, or discard this patch.
editnews.php 1 patch
Switch Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -44,44 +44,44 @@
 block discarded – undo
44 44
 $text      = Filter::post('text');
45 45
 
46 46
 switch ($action) {
47
-case 'compose':
48
-	if (Module::getModuleByName('ckeditor')) {
49
-		CkeditorModule::enableEditor($controller);
50
-	}
47
+	case 'compose':
48
+		if (Module::getModuleByName('ckeditor')) {
49
+			CkeditorModule::enableEditor($controller);
50
+		}
51 51
 
52
-	echo '<h3>' . I18N::translate('Add/edit a journal/news entry') . '</h3>';
53
-	echo '<form style="overflow: hidden;" name="messageform" method="post" action="editnews.php?action=save&news_id=' . $news_id . '">';
54
-	if ($news_id) {
55
-		$news = Database::prepare("SELECT SQL_CACHE news_id AS id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS date, subject, body FROM `##news` WHERE news_id=?")->execute(array($news_id))->fetchOneRow(PDO::FETCH_ASSOC);
56
-	} else {
57
-		$news              = array();
58
-		$news['user_id']   = $user_id;
59
-		$news['gedcom_id'] = $gedcom_id;
60
-		$news['date']      = WT_TIMESTAMP;
61
-		$news['subject']   = '';
62
-		$news['body']      = '';
63
-	}
64
-	echo '<input type="hidden" name="user_id" value="' . $news['user_id'] . '">';
65
-	echo '<input type="hidden" name="gedcom_id" value="' . $news['gedcom_id'] . '">';
66
-	echo '<input type="hidden" name="date" value="' . $news['date'] . '">';
67
-	echo '<table>';
68
-	echo '<tr><th style="text-align:start;">' . I18N::translate('Title') . '</th><tr>';
69
-	echo '<tr><td><input type="text" name="title" size="50" dir="auto" autofocus value="' . $news['subject'] . '"></td></tr>';
70
-	echo '<tr><th style="text-align:start;">' . I18N::translate('Content') . '</th></tr>';
71
-	echo '<tr><td>';
72
-	echo '<textarea name="text" class="html-edit" cols="80" rows="10" dir="auto">' . Filter::escapeHtml($news['body']) . '</textarea>';
73
-	echo '</td></tr>';
74
-	echo '<tr><td><input type="submit" value="' . I18N::translate('save') . '"></td></tr>';
75
-	echo '</table>';
76
-	echo '</form>';
77
-	break;
78
-case 'save':
79
-	if ($news_id) {
80
-		Database::prepare("UPDATE `##news` SET subject=?, body=?, updated=FROM_UNIXTIME(?) WHERE news_id=?")->execute(array($title, $text, $date, $news_id));
81
-	} else {
82
-		Database::prepare("INSERT INTO `##news` (user_id, gedcom_id, subject, body, updated) VALUES (NULLIF(?, ''), NULLIF(?, '') ,? ,?, CURRENT_TIMESTAMP)")->execute(array($user_id, $gedcom_id, $title, $text));
83
-	}
52
+		echo '<h3>' . I18N::translate('Add/edit a journal/news entry') . '</h3>';
53
+		echo '<form style="overflow: hidden;" name="messageform" method="post" action="editnews.php?action=save&news_id=' . $news_id . '">';
54
+		if ($news_id) {
55
+			$news = Database::prepare("SELECT SQL_CACHE news_id AS id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS date, subject, body FROM `##news` WHERE news_id=?")->execute(array($news_id))->fetchOneRow(PDO::FETCH_ASSOC);
56
+		} else {
57
+			$news              = array();
58
+			$news['user_id']   = $user_id;
59
+			$news['gedcom_id'] = $gedcom_id;
60
+			$news['date']      = WT_TIMESTAMP;
61
+			$news['subject']   = '';
62
+			$news['body']      = '';
63
+		}
64
+		echo '<input type="hidden" name="user_id" value="' . $news['user_id'] . '">';
65
+		echo '<input type="hidden" name="gedcom_id" value="' . $news['gedcom_id'] . '">';
66
+		echo '<input type="hidden" name="date" value="' . $news['date'] . '">';
67
+		echo '<table>';
68
+		echo '<tr><th style="text-align:start;">' . I18N::translate('Title') . '</th><tr>';
69
+		echo '<tr><td><input type="text" name="title" size="50" dir="auto" autofocus value="' . $news['subject'] . '"></td></tr>';
70
+		echo '<tr><th style="text-align:start;">' . I18N::translate('Content') . '</th></tr>';
71
+		echo '<tr><td>';
72
+		echo '<textarea name="text" class="html-edit" cols="80" rows="10" dir="auto">' . Filter::escapeHtml($news['body']) . '</textarea>';
73
+		echo '</td></tr>';
74
+		echo '<tr><td><input type="submit" value="' . I18N::translate('save') . '"></td></tr>';
75
+		echo '</table>';
76
+		echo '</form>';
77
+		break;
78
+	case 'save':
79
+		if ($news_id) {
80
+			Database::prepare("UPDATE `##news` SET subject=?, body=?, updated=FROM_UNIXTIME(?) WHERE news_id=?")->execute(array($title, $text, $date, $news_id));
81
+		} else {
82
+			Database::prepare("INSERT INTO `##news` (user_id, gedcom_id, subject, body, updated) VALUES (NULLIF(?, ''), NULLIF(?, '') ,? ,?, CURRENT_TIMESTAMP)")->execute(array($user_id, $gedcom_id, $title, $text));
83
+		}
84 84
 
85
-	$controller->addInlineJavascript('window.opener.location.reload();window.close();');
86
-	break;
85
+		$controller->addInlineJavascript('window.opener.location.reload();window.close();');
86
+		break;
87 87
 }
Please login to merge, or discard this patch.