Completed
Push — 1.7 ( 825567...d605c0 )
by
unknown
08:15
created
admin_media.php 2 patches
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -648,16 +648,22 @@
 block discarded – undo
648 648
 					<div dir="ltr">
649 649
 						<?php if (count($media_folders) > 1): ?>
650 650
 						<?php echo WT_DATA_DIR, FunctionsEdit::selectEditControl('media_folder', $media_folders, null, $media_folder, 'onchange="this.form.submit();"'); ?>
651
-						<?php else: ?>
652
-						<?php echo WT_DATA_DIR, Filter::escapeHtml($media_folder); ?>
651
+						<?php else {
652
+	: ?>
653
+						<?php echo WT_DATA_DIR, Filter::escapeHtml($media_folder);
654
+}
655
+?>
653 656
 						<input type="hidden" name="media_folder" value="<?php echo Filter::escapeHtml($media_folder); ?>">
654 657
 						<?php endif; ?>
655 658
 					</div>
656 659
 
657 660
 					<?php if (count($media_paths) > 1): ?>
658 661
 					<?php echo FunctionsEdit::selectEditControl('media_path', $media_paths, null, $media_path, 'onchange="this.form.submit();"'); ?>
659
-					<?php else: ?>
660
-					<?php echo Filter::escapeHtml($media_path); ?>
662
+					<?php else {
663
+	: ?>
664
+					<?php echo Filter::escapeHtml($media_path);
665
+}
666
+?>
661 667
 					<input type="hidden" name="media_path" value="<?php echo Filter::escapeHtml($media_path); ?>">
662 668
 					<?php endif; ?>
663 669
 
Please login to merge, or discard this patch.
Switch Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -85,98 +85,98 @@  discard block
 block discarded – undo
85 85
 ////////////////////////////////////////////////////////////////////////////////
86 86
 
87 87
 switch ($action) {
88
-case 'load_json':
89
-	$search = Filter::get('search');
90
-	$search = $search['value'];
91
-	$start  = Filter::getInteger('start');
92
-	$length = Filter::getInteger('length');
93
-
94
-	switch ($files) {
95
-	case 'local':
96
-		// Filtered rows
97
-		$SELECT1 =
98
-			"SELECT SQL_CACHE SQL_CALC_FOUND_ROWS TRIM(LEADING :media_path_1 FROM m_filename) AS media_path, m_id AS xref, m_titl, m_file AS gedcom_id, m_gedcom AS gedcom" .
99
-			" FROM  `##media`" .
100
-			" JOIN  `##gedcom_setting` ON (m_file = gedcom_id AND setting_name = 'MEDIA_DIRECTORY')" .
101
-			" JOIN  `##gedcom` USING (gedcom_id)" .
102
-			" WHERE setting_value = :media_folder" .
103
-			" AND   m_filename LIKE CONCAT(:media_path_2, '%')" .
104
-			" AND   (SUBSTRING_INDEX(m_filename, '/', -1) LIKE CONCAT('%', :search_1, '%')" .
105
-			"  OR   m_titl LIKE CONCAT('%', :search_2, '%'))" .
106
-			" AND   m_filename NOT LIKE 'http://%'" .
107
-			" AND   m_filename NOT LIKE 'https://%'";
108
-		$ARGS1 = array(
109
-			'media_path_1' => $media_path,
110
-			'media_folder' => $media_folder,
111
-			'media_path_2' => Filter::escapeLike($media_path),
112
-			'search_1'     => Filter::escapeLike($search),
113
-			'search_2'     => Filter::escapeLike($search),
114
-		);
115
-		// Unfiltered rows
116
-		$SELECT2 =
117
-			"SELECT SQL_CACHE COUNT(*)" .
118
-			" FROM  `##media`" .
119
-			" JOIN  `##gedcom_setting` ON (m_file = gedcom_id AND setting_name = 'MEDIA_DIRECTORY')" .
120
-			" WHERE setting_value = :media_folder" .
121
-			" AND   m_filename LIKE CONCAT(:media_path_3, '%')" .
122
-			" AND   m_filename NOT LIKE 'http://%'" .
123
-			" AND   m_filename NOT LIKE 'https://%'";
124
-		$ARGS2 = array(
125
-			'media_folder' => $media_folder,
126
-			'media_path_3' => $media_path,
127
-		);
128
-
129
-		if ($subfolders == 'exclude') {
130
-			$SELECT1 .= " AND m_filename NOT LIKE CONCAT(:media_path_4, '%/%')";
131
-			$ARGS1['media_path_4'] = Filter::escapeLike($media_path);
132
-			$SELECT2 .= " AND m_filename NOT LIKE CONCAT(:media_path_4, '%/%')";
133
-			$ARGS2['media_path_4'] = Filter::escapeLike($media_path);
134
-		}
135
-
136
-		$order = Filter::getArray('order');
137
-		$SELECT1 .= " ORDER BY ";
138
-		if ($order) {
139
-			foreach ($order as $key => $value) {
140
-				if ($key > 0) {
141
-					$SELECT1 .= ',';
88
+	case 'load_json':
89
+		$search = Filter::get('search');
90
+		$search = $search['value'];
91
+		$start  = Filter::getInteger('start');
92
+		$length = Filter::getInteger('length');
93
+
94
+		switch ($files) {
95
+			case 'local':
96
+				// Filtered rows
97
+				$SELECT1 =
98
+					"SELECT SQL_CACHE SQL_CALC_FOUND_ROWS TRIM(LEADING :media_path_1 FROM m_filename) AS media_path, m_id AS xref, m_titl, m_file AS gedcom_id, m_gedcom AS gedcom" .
99
+					" FROM  `##media`" .
100
+					" JOIN  `##gedcom_setting` ON (m_file = gedcom_id AND setting_name = 'MEDIA_DIRECTORY')" .
101
+					" JOIN  `##gedcom` USING (gedcom_id)" .
102
+					" WHERE setting_value = :media_folder" .
103
+					" AND   m_filename LIKE CONCAT(:media_path_2, '%')" .
104
+					" AND   (SUBSTRING_INDEX(m_filename, '/', -1) LIKE CONCAT('%', :search_1, '%')" .
105
+					"  OR   m_titl LIKE CONCAT('%', :search_2, '%'))" .
106
+					" AND   m_filename NOT LIKE 'http://%'" .
107
+					" AND   m_filename NOT LIKE 'https://%'";
108
+				$ARGS1 = array(
109
+					'media_path_1' => $media_path,
110
+					'media_folder' => $media_folder,
111
+					'media_path_2' => Filter::escapeLike($media_path),
112
+					'search_1'     => Filter::escapeLike($search),
113
+					'search_2'     => Filter::escapeLike($search),
114
+				);
115
+				// Unfiltered rows
116
+				$SELECT2 =
117
+					"SELECT SQL_CACHE COUNT(*)" .
118
+					" FROM  `##media`" .
119
+					" JOIN  `##gedcom_setting` ON (m_file = gedcom_id AND setting_name = 'MEDIA_DIRECTORY')" .
120
+					" WHERE setting_value = :media_folder" .
121
+					" AND   m_filename LIKE CONCAT(:media_path_3, '%')" .
122
+					" AND   m_filename NOT LIKE 'http://%'" .
123
+					" AND   m_filename NOT LIKE 'https://%'";
124
+				$ARGS2 = array(
125
+					'media_folder' => $media_folder,
126
+					'media_path_3' => $media_path,
127
+				);
128
+
129
+				if ($subfolders == 'exclude') {
130
+					$SELECT1 .= " AND m_filename NOT LIKE CONCAT(:media_path_4, '%/%')";
131
+					$ARGS1['media_path_4'] = Filter::escapeLike($media_path);
132
+					$SELECT2 .= " AND m_filename NOT LIKE CONCAT(:media_path_4, '%/%')";
133
+					$ARGS2['media_path_4'] = Filter::escapeLike($media_path);
142 134
 				}
143
-				// Datatables numbers columns 0, 1, 2
144
-				// MySQL numbers columns 1, 2, 3
145
-				switch ($value['dir']) {
146
-				case 'asc':
147
-					$SELECT1 .= ":col_" . $key . " ASC";
148
-					break;
149
-				case 'desc':
150
-					$SELECT1 .= ":col_" . $key . " DESC";
151
-					break;
135
+
136
+				$order = Filter::getArray('order');
137
+				$SELECT1 .= " ORDER BY ";
138
+				if ($order) {
139
+					foreach ($order as $key => $value) {
140
+						if ($key > 0) {
141
+							$SELECT1 .= ',';
142
+						}
143
+						// Datatables numbers columns 0, 1, 2
144
+						// MySQL numbers columns 1, 2, 3
145
+						switch ($value['dir']) {
146
+							case 'asc':
147
+								$SELECT1 .= ":col_" . $key . " ASC";
148
+								break;
149
+							case 'desc':
150
+								$SELECT1 .= ":col_" . $key . " DESC";
151
+								break;
152
+						}
153
+					$ARGS1['col_' . $key] = 1 + $value['column'];
152 154
 				}
153
-				$ARGS1['col_' . $key] = 1 + $value['column'];
155
+			} else {
156
+				$SELECT1 = " 1 ASC";
154 157
 			}
155
-		} else {
156
-			$SELECT1 = " 1 ASC";
157
-		}
158 158
 
159
-		if ($length > 0) {
160
-			$SELECT1 .= " LIMIT :length OFFSET :start";
161
-			$ARGS1['length'] = $length;
162
-			$ARGS1['start']  = $start;
163
-		}
164
-
165
-		$rows = Database::prepare($SELECT1)->execute($ARGS1)->fetchAll();
166
-		// Total filtered/unfiltered rows
167
-		$recordsFiltered = Database::prepare("SELECT FOUND_ROWS()")->fetchOne();
168
-		$recordsTotal    = Database::prepare($SELECT2)->execute($ARGS2)->fetchOne();
159
+			if ($length > 0) {
160
+				$SELECT1 .= " LIMIT :length OFFSET :start";
161
+				$ARGS1['length'] = $length;
162
+				$ARGS1['start']  = $start;
163
+			}
169 164
 
170
-		$data = array();
171
-		foreach ($rows as $row) {
172
-			$media  = Media::getInstance($row->xref, Tree::findById($row->gedcom_id), $row->gedcom);
173
-			$data[] = array(
174
-				mediaFileInfo($media_folder, $media_path, $row->media_path),
175
-				$media->displayImage(),
176
-				mediaObjectInfo($media),
177
-			);
178
-		}
179
-		break;
165
+			$rows = Database::prepare($SELECT1)->execute($ARGS1)->fetchAll();
166
+			// Total filtered/unfiltered rows
167
+			$recordsFiltered = Database::prepare("SELECT FOUND_ROWS()")->fetchOne();
168
+			$recordsTotal    = Database::prepare($SELECT2)->execute($ARGS2)->fetchOne();
169
+
170
+			$data = array();
171
+			foreach ($rows as $row) {
172
+				$media  = Media::getInstance($row->xref, Tree::findById($row->gedcom_id), $row->gedcom);
173
+				$data[] = array(
174
+					mediaFileInfo($media_folder, $media_path, $row->media_path),
175
+					$media->displayImage(),
176
+					mediaObjectInfo($media),
177
+				);
178
+			}
179
+			break;
180 180
 
181 181
 	case 'external':
182 182
 		// Filtered rows
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 				// Datatables numbers columns 0, 1, 2
207 207
 				// MySQL numbers columns 1, 2, 3
208 208
 				switch ($value['dir']) {
209
-				case 'asc':
210
-					$SELECT1 .= ":col_" . $key . " ASC";
211
-					break;
212
-				case 'desc':
213
-					$SELECT1 .= ":col_" . $key . " DESC";
214
-					break;
209
+					case 'asc':
210
+						$SELECT1 .= ":col_" . $key . " ASC";
211
+						break;
212
+					case 'desc':
213
+						$SELECT1 .= ":col_" . $key . " DESC";
214
+						break;
215 215
 				}
216 216
 				$ARGS1['col_' . $key] = 1 + $value['column'];
217 217
 			}
Please login to merge, or discard this patch.
admin_module_blocks.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -81,8 +81,11 @@
 block discarded – undo
81 81
 				<td class="col-xs-2">
82 82
 					<?php if ($module instanceof ModuleConfigInterface): ?>
83 83
 						<a href="<?php echo $module->getConfigLink(); ?>"><?php echo $module->getTitle(); ?> <i class="fa fa-cogs"></i></a>
84
-					<?php else: ?>
85
-						<?php echo $module->getTitle(); ?>
84
+					<?php else {
85
+	: ?>
86
+						<?php echo $module->getTitle();
87
+}
88
+?>
86 89
 					<?php endif; ?>
87 90
 				</td>
88 91
 				<td class="col-xs-5"><?php echo $module->getDescription(); ?></td>
Please login to merge, or discard this patch.
admin_module_menus.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -98,8 +98,11 @@
 block discarded – undo
98 98
 				<td class="col-xs-1">
99 99
 					<?php if ($module instanceof ModuleConfigInterface): ?>
100 100
 					<a href="<?php echo $module->getConfigLink(); ?>"><?php echo $module->getTitle(); ?> <i class="fa fa-cogs"></i></a>
101
-					<?php else: ?>
102
-					<?php echo $module->getTitle(); ?>
101
+					<?php else {
102
+	: ?>
103
+					<?php echo $module->getTitle();
104
+}
105
+?>
103 106
 					<?php endif; ?>
104 107
 				</td>
105 108
 				<td class="col-xs-5"><?php echo $module->getDescription(); ?></td>
Please login to merge, or discard this patch.
admin_site_merge.php 1 patch
Braces   +20 added lines, -8 removed lines patch added patch discarded remove patch
@@ -232,9 +232,12 @@  discard block
 block discarded – undo
232 232
 				<?php endforeach; ?>
233 233
 				</tbody>
234 234
 			</table>
235
-			<?php else: ?>
235
+			<?php else {
236
+	: ?>
236 237
 			<p>
237
-				<?php echo I18N::translate('No matching facts found'); ?>
238
+				<?php echo I18N::translate('No matching facts found');
239
+}
240
+?>
238 241
 			</p>
239 242
 			<?php endif; ?>
240 243
 		</div>
@@ -279,9 +282,12 @@  discard block
 block discarded – undo
279 282
 							<?php endforeach; ?>
280 283
 							</tbody>
281 284
 						</table>
282
-					<?php else: ?>
285
+					<?php else {
286
+	: ?>
283 287
 						<p>
284
-							<?php echo I18N::translate('No matching facts found'); ?>
288
+							<?php echo I18N::translate('No matching facts found');
289
+}
290
+?>
285 291
 						</p>
286 292
 					<?php endif; ?>
287 293
 				</div>
@@ -325,9 +331,12 @@  discard block
 block discarded – undo
325 331
 							<?php endforeach; ?>
326 332
 							</tbody>
327 333
 						</table>
328
-					<?php else: ?>
334
+					<?php else {
335
+	: ?>
329 336
 						<p>
330
-							<?php echo I18N::translate('No matching facts found'); ?>
337
+							<?php echo I18N::translate('No matching facts found');
338
+}
339
+?>
331 340
 						</p>
332 341
 					<?php endif; ?>
333 342
 				</div>
@@ -341,10 +350,13 @@  discard block
 block discarded – undo
341 350
 	</button>
342 351
 </form>
343 352
 
344
-<?php else: ?>
353
+<?php else {
354
+	: ?>
345 355
 
346 356
 <form class="form form-horizontal">
347
-	<input type="hidden" name="ged" value="<?php echo $WT_TREE->getNameHtml(); ?>">
357
+	<input type="hidden" name="ged" value="<?php echo $WT_TREE->getNameHtml();
358
+}
359
+?>">
348 360
 	<p><?php echo /* I18N: Records are indviduals, sources, etc. */ I18N::translate('Select two records to merge.'); ?></p>
349 361
 
350 362
 	<div class="form-group">
Please login to merge, or discard this patch.
admin_trees_config.php 2 patches
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -554,18 +554,24 @@
 block discarded – undo
554 554
 					<div class="bg-danger text-danger">
555 555
 						<?php echo $resn->xref, ' — ', I18N::translate('this record does not exist'); ?>
556 556
 					</div>
557
-					<?php else: ?>
557
+					<?php else {
558
+	: ?>
558 559
 					<div class="text-muted">
559
-						<?php echo I18N::translate('All records'); ?>
560
+						<?php echo I18N::translate('All records');
561
+}
562
+?>
560 563
 					</div>
561 564
 					<?php endif; ?>
562 565
 				</td>
563 566
 				<td>
564 567
 					<?php if ($resn->tag_label): ?>
565 568
 					<?php echo $resn->tag_label; ?>
566
-					<?php else: ?>
569
+					<?php else {
570
+	: ?>
567 571
 					<div class="text-muted">
568
-						<?php echo I18N::translate('All facts and events'); ?>
572
+						<?php echo I18N::translate('All facts and events');
573
+}
574
+?>
569 575
 					</div>
570 576
 					<?php endif; ?>
571 577
 				</td>
Please login to merge, or discard this patch.
Switch Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -132,176 +132,176 @@
 block discarded – undo
132 132
 $relatives_events = explode(',', $WT_TREE->getPreference('SHOW_RELATIVES_EVENTS'));
133 133
 
134 134
 switch (Filter::post('action')) {
135
-case 'privacy':
136
-	foreach (Filter::postArray('delete', WT_REGEX_INTEGER) as $delete_resn) {
137
-		Database::prepare(
138
-			"DELETE FROM `##default_resn` WHERE default_resn_id=?"
139
-		)->execute(array($delete_resn));
140
-	}
135
+	case 'privacy':
136
+		foreach (Filter::postArray('delete', WT_REGEX_INTEGER) as $delete_resn) {
137
+			Database::prepare(
138
+				"DELETE FROM `##default_resn` WHERE default_resn_id=?"
139
+			)->execute(array($delete_resn));
140
+		}
141 141
 
142
-	$xrefs     = Filter::postArray('xref', WT_REGEX_XREF);
143
-	$tag_types = Filter::postArray('tag_type', WT_REGEX_TAG);
144
-	$resns     = Filter::postArray('resn');
142
+		$xrefs     = Filter::postArray('xref', WT_REGEX_XREF);
143
+		$tag_types = Filter::postArray('tag_type', WT_REGEX_TAG);
144
+		$resns     = Filter::postArray('resn');
145 145
 
146
-	foreach ($xrefs as $n => $xref) {
147
-		$tag_type = $tag_types[$n];
148
-		$resn     = $resns[$n];
146
+		foreach ($xrefs as $n => $xref) {
147
+			$tag_type = $tag_types[$n];
148
+			$resn     = $resns[$n];
149 149
 
150
-		if ($tag_type || $xref) {
151
-			// Delete any existing data
152
-			if ($xref === '') {
153
-				Database::prepare(
154
-					"DELETE FROM `##default_resn` WHERE gedcom_id=? AND tag_type=? AND xref IS NULL"
155
-				)->execute(array($WT_TREE->getTreeId(), $tag_type));
156
-			}
157
-			if ($tag_type === '') {
150
+			if ($tag_type || $xref) {
151
+				// Delete any existing data
152
+				if ($xref === '') {
153
+					Database::prepare(
154
+						"DELETE FROM `##default_resn` WHERE gedcom_id=? AND tag_type=? AND xref IS NULL"
155
+					)->execute(array($WT_TREE->getTreeId(), $tag_type));
156
+				}
157
+				if ($tag_type === '') {
158
+					Database::prepare(
159
+						"DELETE FROM `##default_resn` WHERE gedcom_id=? AND xref=? AND tag_type IS NULL"
160
+					)->execute(array($WT_TREE->getTreeId(), $xref));
161
+				}
162
+				// Add (or update) the new data
158 163
 				Database::prepare(
159
-					"DELETE FROM `##default_resn` WHERE gedcom_id=? AND xref=? AND tag_type IS NULL"
160
-				)->execute(array($WT_TREE->getTreeId(), $xref));
164
+					"REPLACE INTO `##default_resn` (gedcom_id, xref, tag_type, resn) VALUES (?, NULLIF(?, ''), NULLIF(?, ''), ?)"
165
+				)->execute(array($WT_TREE->getTreeId(), $xref, $tag_type, $resn));
161 166
 			}
162
-			// Add (or update) the new data
163
-			Database::prepare(
164
-				"REPLACE INTO `##default_resn` (gedcom_id, xref, tag_type, resn) VALUES (?, NULLIF(?, ''), NULLIF(?, ''), ?)"
165
-			)->execute(array($WT_TREE->getTreeId(), $xref, $tag_type, $resn));
166 167
 		}
167
-	}
168 168
 
169
-	$WT_TREE->setPreference('HIDE_LIVE_PEOPLE', Filter::postBool('HIDE_LIVE_PEOPLE'));
170
-	$WT_TREE->setPreference('KEEP_ALIVE_YEARS_BIRTH', Filter::post('KEEP_ALIVE_YEARS_BIRTH', WT_REGEX_INTEGER, 0));
171
-	$WT_TREE->setPreference('KEEP_ALIVE_YEARS_DEATH', Filter::post('KEEP_ALIVE_YEARS_DEATH', WT_REGEX_INTEGER, 0));
172
-	$WT_TREE->setPreference('MAX_ALIVE_AGE', Filter::post('MAX_ALIVE_AGE', WT_REGEX_INTEGER, 100));
173
-	$WT_TREE->setPreference('REQUIRE_AUTHENTICATION', Filter::postBool('REQUIRE_AUTHENTICATION'));
174
-	$WT_TREE->setPreference('SHOW_DEAD_PEOPLE', Filter::post('SHOW_DEAD_PEOPLE'));
175
-	$WT_TREE->setPreference('SHOW_LIVING_NAMES', Filter::post('SHOW_LIVING_NAMES'));
176
-	$WT_TREE->setPreference('SHOW_PRIVATE_RELATIONSHIPS', Filter::post('SHOW_PRIVATE_RELATIONSHIPS'));
169
+		$WT_TREE->setPreference('HIDE_LIVE_PEOPLE', Filter::postBool('HIDE_LIVE_PEOPLE'));
170
+		$WT_TREE->setPreference('KEEP_ALIVE_YEARS_BIRTH', Filter::post('KEEP_ALIVE_YEARS_BIRTH', WT_REGEX_INTEGER, 0));
171
+		$WT_TREE->setPreference('KEEP_ALIVE_YEARS_DEATH', Filter::post('KEEP_ALIVE_YEARS_DEATH', WT_REGEX_INTEGER, 0));
172
+		$WT_TREE->setPreference('MAX_ALIVE_AGE', Filter::post('MAX_ALIVE_AGE', WT_REGEX_INTEGER, 100));
173
+		$WT_TREE->setPreference('REQUIRE_AUTHENTICATION', Filter::postBool('REQUIRE_AUTHENTICATION'));
174
+		$WT_TREE->setPreference('SHOW_DEAD_PEOPLE', Filter::post('SHOW_DEAD_PEOPLE'));
175
+		$WT_TREE->setPreference('SHOW_LIVING_NAMES', Filter::post('SHOW_LIVING_NAMES'));
176
+		$WT_TREE->setPreference('SHOW_PRIVATE_RELATIONSHIPS', Filter::post('SHOW_PRIVATE_RELATIONSHIPS'));
177 177
 
178
-	FlashMessages::addMessage(I18N::translate('The preferences for the family tree “%s” have been updated.', $WT_TREE->getTitleHtml()), 'success');
179
-	header('Location: ' . WT_BASE_URL . 'admin_trees_manage.php?ged=' . $WT_TREE->getNameUrl());
178
+		FlashMessages::addMessage(I18N::translate('The preferences for the family tree “%s” have been updated.', $WT_TREE->getTitleHtml()), 'success');
179
+		header('Location: ' . WT_BASE_URL . 'admin_trees_manage.php?ged=' . $WT_TREE->getNameUrl());
180 180
 
181
-	return;
181
+		return;
182 182
 
183
-case 'general':
184
-	if (!Filter::checkCsrf()) {
185
-		break;
186
-	}
183
+	case 'general':
184
+		if (!Filter::checkCsrf()) {
185
+			break;
186
+		}
187 187
 
188
-	// Coming soon
189
-	if (Filter::postBool('all_trees')) {
190
-		FlashMessages::addMessage(I18N::translate('The preferences for all family trees have been updated.', $WT_TREE->getTitleHtml()), 'success');
191
-	}
192
-	if (Filter::postBool('new_trees')) {
193
-		FlashMessages::addMessage(I18N::translate('The preferences for new family trees have been updated.', $WT_TREE->getTitleHtml()), 'success');
194
-	}
188
+		// Coming soon
189
+		if (Filter::postBool('all_trees')) {
190
+			FlashMessages::addMessage(I18N::translate('The preferences for all family trees have been updated.', $WT_TREE->getTitleHtml()), 'success');
191
+		}
192
+		if (Filter::postBool('new_trees')) {
193
+			FlashMessages::addMessage(I18N::translate('The preferences for new family trees have been updated.', $WT_TREE->getTitleHtml()), 'success');
194
+		}
195 195
 
196
-	$WT_TREE->setPreference('ADVANCED_NAME_FACTS', Filter::post('ADVANCED_NAME_FACTS'));
197
-	$WT_TREE->setPreference('ADVANCED_PLAC_FACTS', Filter::post('ADVANCED_PLAC_FACTS'));
198
-	$WT_TREE->setPreference('ALLOW_THEME_DROPDOWN', Filter::postBool('ALLOW_THEME_DROPDOWN'));
199
-	// For backwards compatibility with webtrees 1.x we store the two calendar formats in one variable
200
-	// e.g. "gregorian_and_jewish"
201
-	$WT_TREE->setPreference('CALENDAR_FORMAT', implode('_and_', array_unique(array(
202
-		Filter::post('CALENDAR_FORMAT0', 'gregorian|julian|french|jewish|hijri|jalali', 'none'),
203
-		Filter::post('CALENDAR_FORMAT1', 'gregorian|julian|french|jewish|hijri|jalali', 'none'),
204
-	))));
205
-	$WT_TREE->setPreference('CHART_BOX_TAGS', Filter::post('CHART_BOX_TAGS'));
206
-	$WT_TREE->setPreference('CONTACT_USER_ID', Filter::post('CONTACT_USER_ID'));
207
-	$WT_TREE->setPreference('DEFAULT_PEDIGREE_GENERATIONS', Filter::post('DEFAULT_PEDIGREE_GENERATIONS'));
208
-	$WT_TREE->setPreference('EXPAND_NOTES', Filter::postBool('EXPAND_NOTES'));
209
-	$WT_TREE->setPreference('EXPAND_SOURCES', Filter::postBool('EXPAND_SOURCES'));
210
-	$WT_TREE->setPreference('FAM_FACTS_ADD', str_replace(' ', '', Filter::post('FAM_FACTS_ADD')));
211
-	$WT_TREE->setPreference('FAM_FACTS_QUICK', str_replace(' ', '', Filter::post('FAM_FACTS_QUICK')));
212
-	$WT_TREE->setPreference('FAM_FACTS_UNIQUE', str_replace(' ', '', Filter::post('FAM_FACTS_UNIQUE')));
213
-	$WT_TREE->setPreference('FAM_ID_PREFIX', Filter::post('FAM_ID_PREFIX'));
214
-	$WT_TREE->setPreference('FULL_SOURCES', Filter::postBool('FULL_SOURCES'));
215
-	$WT_TREE->setPreference('FORMAT_TEXT', Filter::post('FORMAT_TEXT'));
216
-	$WT_TREE->setPreference('GEDCOM_ID_PREFIX', Filter::post('GEDCOM_ID_PREFIX'));
217
-	$WT_TREE->setPreference('GEDCOM_MEDIA_PATH', Filter::post('GEDCOM_MEDIA_PATH'));
218
-	$WT_TREE->setPreference('GENERATE_UIDS', Filter::postBool('GENERATE_UIDS'));
219
-	$WT_TREE->setPreference('GEONAMES_ACCOUNT', Filter::post('GEONAMES_ACCOUNT'));
220
-	$WT_TREE->setPreference('HIDE_GEDCOM_ERRORS', Filter::postBool('HIDE_GEDCOM_ERRORS'));
221
-	$WT_TREE->setPreference('INDI_FACTS_ADD', str_replace(' ', '', Filter::post('INDI_FACTS_ADD')));
222
-	$WT_TREE->setPreference('INDI_FACTS_QUICK', str_replace(' ', '', Filter::post('INDI_FACTS_QUICK')));
223
-	$WT_TREE->setPreference('INDI_FACTS_UNIQUE', str_replace(' ', '', Filter::post('INDI_FACTS_UNIQUE')));
224
-	$WT_TREE->setPreference('LANGUAGE', Filter::post('LANGUAGE'));
225
-	$WT_TREE->setPreference('MAX_DESCENDANCY_GENERATIONS', Filter::post('MAX_DESCENDANCY_GENERATIONS'));
226
-	$WT_TREE->setPreference('MAX_PEDIGREE_GENERATIONS', Filter::post('MAX_PEDIGREE_GENERATIONS'));
227
-	$WT_TREE->setPreference('MEDIA_ID_PREFIX', Filter::post('MEDIA_ID_PREFIX'));
228
-	$WT_TREE->setPreference('MEDIA_UPLOAD', Filter::post('MEDIA_UPLOAD'));
229
-	$WT_TREE->setPreference('META_DESCRIPTION', Filter::post('META_DESCRIPTION'));
230
-	$WT_TREE->setPreference('META_TITLE', Filter::post('META_TITLE'));
231
-	$WT_TREE->setPreference('NOTE_ID_PREFIX', Filter::post('NOTE_ID_PREFIX'));
232
-	$WT_TREE->setPreference('NO_UPDATE_CHAN', Filter::postBool('NO_UPDATE_CHAN'));
233
-	$WT_TREE->setPreference('PEDIGREE_FULL_DETAILS', Filter::postBool('PEDIGREE_FULL_DETAILS'));
234
-	$WT_TREE->setPreference('PEDIGREE_LAYOUT', Filter::postBool('PEDIGREE_LAYOUT'));
235
-	$WT_TREE->setPreference('PEDIGREE_ROOT_ID', Filter::post('PEDIGREE_ROOT_ID', WT_REGEX_XREF));
236
-	$WT_TREE->setPreference('PEDIGREE_SHOW_GENDER', Filter::postBool('PEDIGREE_SHOW_GENDER'));
237
-	$WT_TREE->setPreference('PREFER_LEVEL2_SOURCES', Filter::post('PREFER_LEVEL2_SOURCES'));
238
-	$WT_TREE->setPreference('QUICK_REQUIRED_FACTS', Filter::post('QUICK_REQUIRED_FACTS'));
239
-	$WT_TREE->setPreference('QUICK_REQUIRED_FAMFACTS', Filter::post('QUICK_REQUIRED_FAMFACTS'));
240
-	$WT_TREE->setPreference('REPO_FACTS_ADD', str_replace(' ', '', Filter::post('REPO_FACTS_ADD')));
241
-	$WT_TREE->setPreference('REPO_FACTS_QUICK', str_replace(' ', '', Filter::post('REPO_FACTS_QUICK')));
242
-	$WT_TREE->setPreference('REPO_FACTS_UNIQUE', str_replace(' ', '', Filter::post('REPO_FACTS_UNIQUE')));
243
-	$WT_TREE->setPreference('REPO_ID_PREFIX', Filter::post('REPO_ID_PREFIX'));
244
-	$WT_TREE->setPreference('SAVE_WATERMARK_IMAGE', Filter::postBool('SAVE_WATERMARK_IMAGE'));
245
-	$WT_TREE->setPreference('SAVE_WATERMARK_THUMB', Filter::postBool('SAVE_WATERMARK_THUMB'));
246
-	$WT_TREE->setPreference('SHOW_COUNTER', Filter::postBool('SHOW_COUNTER'));
247
-	$WT_TREE->setPreference('SHOW_EST_LIST_DATES', Filter::postBool('SHOW_EST_LIST_DATES'));
248
-	$WT_TREE->setPreference('SHOW_FACT_ICONS', Filter::postBool('SHOW_FACT_ICONS'));
249
-	$WT_TREE->setPreference('SHOW_GEDCOM_RECORD', Filter::postBool('SHOW_GEDCOM_RECORD'));
250
-	$WT_TREE->setPreference('SHOW_HIGHLIGHT_IMAGES', Filter::postBool('SHOW_HIGHLIGHT_IMAGES'));
251
-	$WT_TREE->setPreference('SHOW_LAST_CHANGE', Filter::postBool('SHOW_LAST_CHANGE'));
252
-	$WT_TREE->setPreference('SHOW_LDS_AT_GLANCE', Filter::postBool('SHOW_LDS_AT_GLANCE'));
253
-	$WT_TREE->setPreference('SHOW_MEDIA_DOWNLOAD', Filter::post('SHOW_MEDIA_DOWNLOAD'));
254
-	$WT_TREE->setPreference('SHOW_NO_WATERMARK', Filter::post('SHOW_NO_WATERMARK'));
255
-	$WT_TREE->setPreference('SHOW_PARENTS_AGE', Filter::postBool('SHOW_PARENTS_AGE'));
256
-	$WT_TREE->setPreference('SHOW_PEDIGREE_PLACES', Filter::post('SHOW_PEDIGREE_PLACES'));
257
-	$WT_TREE->setPreference('SHOW_PEDIGREE_PLACES_SUFFIX', Filter::postBool('SHOW_PEDIGREE_PLACES_SUFFIX'));
258
-	$WT_TREE->setPreference('SHOW_RELATIVES_EVENTS', implode(',', Filter::postArray('SHOW_RELATIVES_EVENTS')));
259
-	$WT_TREE->setPreference('SOURCE_ID_PREFIX', Filter::post('SOURCE_ID_PREFIX'));
260
-	$WT_TREE->setPreference('SOUR_FACTS_ADD', str_replace(' ', '', Filter::post('SOUR_FACTS_ADD')));
261
-	$WT_TREE->setPreference('SOUR_FACTS_QUICK', str_replace(' ', '', Filter::post('SOUR_FACTS_QUICK')));
262
-	$WT_TREE->setPreference('SOUR_FACTS_UNIQUE', str_replace(' ', '', Filter::post('SOUR_FACTS_UNIQUE')));
263
-	$WT_TREE->setPreference('SUBLIST_TRIGGER_I', Filter::post('SUBLIST_TRIGGER_I', WT_REGEX_INTEGER, 200));
264
-	$WT_TREE->setPreference('SURNAME_LIST_STYLE', Filter::post('SURNAME_LIST_STYLE'));
265
-	$WT_TREE->setPreference('SURNAME_TRADITION', Filter::post('SURNAME_TRADITION'));
266
-	$WT_TREE->setPreference('THEME_DIR', Filter::post('THEME_DIR'));
267
-	$WT_TREE->setPreference('THUMBNAIL_WIDTH', Filter::post('THUMBNAIL_WIDTH'));
268
-	$WT_TREE->setPreference('USE_SILHOUETTE', Filter::postBool('USE_SILHOUETTE'));
269
-	$WT_TREE->setPreference('WATERMARK_THUMB', Filter::postBool('WATERMARK_THUMB'));
270
-	$WT_TREE->setPreference('WEBMASTER_USER_ID', Filter::post('WEBMASTER_USER_ID'));
271
-	$WT_TREE->setPreference('WEBTREES_EMAIL', Filter::post('WEBTREES_EMAIL'));
272
-	$WT_TREE->setPreference('title', Filter::post('title'));
273
-
274
-	// Only accept valid folders for MEDIA_DIRECTORY
275
-	$MEDIA_DIRECTORY = preg_replace('/[\/\\\\]+/', '/', Filter::post('MEDIA_DIRECTORY') . '/');
276
-	if (substr($MEDIA_DIRECTORY, 0, 1) === '/') {
277
-		$MEDIA_DIRECTORY = substr($MEDIA_DIRECTORY, 1);
278
-	}
196
+		$WT_TREE->setPreference('ADVANCED_NAME_FACTS', Filter::post('ADVANCED_NAME_FACTS'));
197
+		$WT_TREE->setPreference('ADVANCED_PLAC_FACTS', Filter::post('ADVANCED_PLAC_FACTS'));
198
+		$WT_TREE->setPreference('ALLOW_THEME_DROPDOWN', Filter::postBool('ALLOW_THEME_DROPDOWN'));
199
+		// For backwards compatibility with webtrees 1.x we store the two calendar formats in one variable
200
+		// e.g. "gregorian_and_jewish"
201
+		$WT_TREE->setPreference('CALENDAR_FORMAT', implode('_and_', array_unique(array(
202
+			Filter::post('CALENDAR_FORMAT0', 'gregorian|julian|french|jewish|hijri|jalali', 'none'),
203
+			Filter::post('CALENDAR_FORMAT1', 'gregorian|julian|french|jewish|hijri|jalali', 'none'),
204
+		))));
205
+		$WT_TREE->setPreference('CHART_BOX_TAGS', Filter::post('CHART_BOX_TAGS'));
206
+		$WT_TREE->setPreference('CONTACT_USER_ID', Filter::post('CONTACT_USER_ID'));
207
+		$WT_TREE->setPreference('DEFAULT_PEDIGREE_GENERATIONS', Filter::post('DEFAULT_PEDIGREE_GENERATIONS'));
208
+		$WT_TREE->setPreference('EXPAND_NOTES', Filter::postBool('EXPAND_NOTES'));
209
+		$WT_TREE->setPreference('EXPAND_SOURCES', Filter::postBool('EXPAND_SOURCES'));
210
+		$WT_TREE->setPreference('FAM_FACTS_ADD', str_replace(' ', '', Filter::post('FAM_FACTS_ADD')));
211
+		$WT_TREE->setPreference('FAM_FACTS_QUICK', str_replace(' ', '', Filter::post('FAM_FACTS_QUICK')));
212
+		$WT_TREE->setPreference('FAM_FACTS_UNIQUE', str_replace(' ', '', Filter::post('FAM_FACTS_UNIQUE')));
213
+		$WT_TREE->setPreference('FAM_ID_PREFIX', Filter::post('FAM_ID_PREFIX'));
214
+		$WT_TREE->setPreference('FULL_SOURCES', Filter::postBool('FULL_SOURCES'));
215
+		$WT_TREE->setPreference('FORMAT_TEXT', Filter::post('FORMAT_TEXT'));
216
+		$WT_TREE->setPreference('GEDCOM_ID_PREFIX', Filter::post('GEDCOM_ID_PREFIX'));
217
+		$WT_TREE->setPreference('GEDCOM_MEDIA_PATH', Filter::post('GEDCOM_MEDIA_PATH'));
218
+		$WT_TREE->setPreference('GENERATE_UIDS', Filter::postBool('GENERATE_UIDS'));
219
+		$WT_TREE->setPreference('GEONAMES_ACCOUNT', Filter::post('GEONAMES_ACCOUNT'));
220
+		$WT_TREE->setPreference('HIDE_GEDCOM_ERRORS', Filter::postBool('HIDE_GEDCOM_ERRORS'));
221
+		$WT_TREE->setPreference('INDI_FACTS_ADD', str_replace(' ', '', Filter::post('INDI_FACTS_ADD')));
222
+		$WT_TREE->setPreference('INDI_FACTS_QUICK', str_replace(' ', '', Filter::post('INDI_FACTS_QUICK')));
223
+		$WT_TREE->setPreference('INDI_FACTS_UNIQUE', str_replace(' ', '', Filter::post('INDI_FACTS_UNIQUE')));
224
+		$WT_TREE->setPreference('LANGUAGE', Filter::post('LANGUAGE'));
225
+		$WT_TREE->setPreference('MAX_DESCENDANCY_GENERATIONS', Filter::post('MAX_DESCENDANCY_GENERATIONS'));
226
+		$WT_TREE->setPreference('MAX_PEDIGREE_GENERATIONS', Filter::post('MAX_PEDIGREE_GENERATIONS'));
227
+		$WT_TREE->setPreference('MEDIA_ID_PREFIX', Filter::post('MEDIA_ID_PREFIX'));
228
+		$WT_TREE->setPreference('MEDIA_UPLOAD', Filter::post('MEDIA_UPLOAD'));
229
+		$WT_TREE->setPreference('META_DESCRIPTION', Filter::post('META_DESCRIPTION'));
230
+		$WT_TREE->setPreference('META_TITLE', Filter::post('META_TITLE'));
231
+		$WT_TREE->setPreference('NOTE_ID_PREFIX', Filter::post('NOTE_ID_PREFIX'));
232
+		$WT_TREE->setPreference('NO_UPDATE_CHAN', Filter::postBool('NO_UPDATE_CHAN'));
233
+		$WT_TREE->setPreference('PEDIGREE_FULL_DETAILS', Filter::postBool('PEDIGREE_FULL_DETAILS'));
234
+		$WT_TREE->setPreference('PEDIGREE_LAYOUT', Filter::postBool('PEDIGREE_LAYOUT'));
235
+		$WT_TREE->setPreference('PEDIGREE_ROOT_ID', Filter::post('PEDIGREE_ROOT_ID', WT_REGEX_XREF));
236
+		$WT_TREE->setPreference('PEDIGREE_SHOW_GENDER', Filter::postBool('PEDIGREE_SHOW_GENDER'));
237
+		$WT_TREE->setPreference('PREFER_LEVEL2_SOURCES', Filter::post('PREFER_LEVEL2_SOURCES'));
238
+		$WT_TREE->setPreference('QUICK_REQUIRED_FACTS', Filter::post('QUICK_REQUIRED_FACTS'));
239
+		$WT_TREE->setPreference('QUICK_REQUIRED_FAMFACTS', Filter::post('QUICK_REQUIRED_FAMFACTS'));
240
+		$WT_TREE->setPreference('REPO_FACTS_ADD', str_replace(' ', '', Filter::post('REPO_FACTS_ADD')));
241
+		$WT_TREE->setPreference('REPO_FACTS_QUICK', str_replace(' ', '', Filter::post('REPO_FACTS_QUICK')));
242
+		$WT_TREE->setPreference('REPO_FACTS_UNIQUE', str_replace(' ', '', Filter::post('REPO_FACTS_UNIQUE')));
243
+		$WT_TREE->setPreference('REPO_ID_PREFIX', Filter::post('REPO_ID_PREFIX'));
244
+		$WT_TREE->setPreference('SAVE_WATERMARK_IMAGE', Filter::postBool('SAVE_WATERMARK_IMAGE'));
245
+		$WT_TREE->setPreference('SAVE_WATERMARK_THUMB', Filter::postBool('SAVE_WATERMARK_THUMB'));
246
+		$WT_TREE->setPreference('SHOW_COUNTER', Filter::postBool('SHOW_COUNTER'));
247
+		$WT_TREE->setPreference('SHOW_EST_LIST_DATES', Filter::postBool('SHOW_EST_LIST_DATES'));
248
+		$WT_TREE->setPreference('SHOW_FACT_ICONS', Filter::postBool('SHOW_FACT_ICONS'));
249
+		$WT_TREE->setPreference('SHOW_GEDCOM_RECORD', Filter::postBool('SHOW_GEDCOM_RECORD'));
250
+		$WT_TREE->setPreference('SHOW_HIGHLIGHT_IMAGES', Filter::postBool('SHOW_HIGHLIGHT_IMAGES'));
251
+		$WT_TREE->setPreference('SHOW_LAST_CHANGE', Filter::postBool('SHOW_LAST_CHANGE'));
252
+		$WT_TREE->setPreference('SHOW_LDS_AT_GLANCE', Filter::postBool('SHOW_LDS_AT_GLANCE'));
253
+		$WT_TREE->setPreference('SHOW_MEDIA_DOWNLOAD', Filter::post('SHOW_MEDIA_DOWNLOAD'));
254
+		$WT_TREE->setPreference('SHOW_NO_WATERMARK', Filter::post('SHOW_NO_WATERMARK'));
255
+		$WT_TREE->setPreference('SHOW_PARENTS_AGE', Filter::postBool('SHOW_PARENTS_AGE'));
256
+		$WT_TREE->setPreference('SHOW_PEDIGREE_PLACES', Filter::post('SHOW_PEDIGREE_PLACES'));
257
+		$WT_TREE->setPreference('SHOW_PEDIGREE_PLACES_SUFFIX', Filter::postBool('SHOW_PEDIGREE_PLACES_SUFFIX'));
258
+		$WT_TREE->setPreference('SHOW_RELATIVES_EVENTS', implode(',', Filter::postArray('SHOW_RELATIVES_EVENTS')));
259
+		$WT_TREE->setPreference('SOURCE_ID_PREFIX', Filter::post('SOURCE_ID_PREFIX'));
260
+		$WT_TREE->setPreference('SOUR_FACTS_ADD', str_replace(' ', '', Filter::post('SOUR_FACTS_ADD')));
261
+		$WT_TREE->setPreference('SOUR_FACTS_QUICK', str_replace(' ', '', Filter::post('SOUR_FACTS_QUICK')));
262
+		$WT_TREE->setPreference('SOUR_FACTS_UNIQUE', str_replace(' ', '', Filter::post('SOUR_FACTS_UNIQUE')));
263
+		$WT_TREE->setPreference('SUBLIST_TRIGGER_I', Filter::post('SUBLIST_TRIGGER_I', WT_REGEX_INTEGER, 200));
264
+		$WT_TREE->setPreference('SURNAME_LIST_STYLE', Filter::post('SURNAME_LIST_STYLE'));
265
+		$WT_TREE->setPreference('SURNAME_TRADITION', Filter::post('SURNAME_TRADITION'));
266
+		$WT_TREE->setPreference('THEME_DIR', Filter::post('THEME_DIR'));
267
+		$WT_TREE->setPreference('THUMBNAIL_WIDTH', Filter::post('THUMBNAIL_WIDTH'));
268
+		$WT_TREE->setPreference('USE_SILHOUETTE', Filter::postBool('USE_SILHOUETTE'));
269
+		$WT_TREE->setPreference('WATERMARK_THUMB', Filter::postBool('WATERMARK_THUMB'));
270
+		$WT_TREE->setPreference('WEBMASTER_USER_ID', Filter::post('WEBMASTER_USER_ID'));
271
+		$WT_TREE->setPreference('WEBTREES_EMAIL', Filter::post('WEBTREES_EMAIL'));
272
+		$WT_TREE->setPreference('title', Filter::post('title'));
273
+
274
+		// Only accept valid folders for MEDIA_DIRECTORY
275
+		$MEDIA_DIRECTORY = preg_replace('/[\/\\\\]+/', '/', Filter::post('MEDIA_DIRECTORY') . '/');
276
+		if (substr($MEDIA_DIRECTORY, 0, 1) === '/') {
277
+			$MEDIA_DIRECTORY = substr($MEDIA_DIRECTORY, 1);
278
+		}
279 279
 
280
-	if ($MEDIA_DIRECTORY) {
281
-		if (is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
282
-			$WT_TREE->setPreference('MEDIA_DIRECTORY', $MEDIA_DIRECTORY);
283
-		} elseif (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
284
-			$WT_TREE->setPreference('MEDIA_DIRECTORY', $MEDIA_DIRECTORY);
285
-			FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'info');
286
-		} else {
287
-			FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'danger');
280
+		if ($MEDIA_DIRECTORY) {
281
+			if (is_dir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
282
+				$WT_TREE->setPreference('MEDIA_DIRECTORY', $MEDIA_DIRECTORY);
283
+			} elseif (File::mkdir(WT_DATA_DIR . $MEDIA_DIRECTORY)) {
284
+				$WT_TREE->setPreference('MEDIA_DIRECTORY', $MEDIA_DIRECTORY);
285
+				FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'info');
286
+			} else {
287
+				FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'danger');
288
+			}
288 289
 		}
289
-	}
290 290
 
291
-	$gedcom = Filter::post('gedcom');
292
-	if ($gedcom && $gedcom !== $WT_TREE->getName()) {
293
-		try {
294
-			Database::prepare("UPDATE `##gedcom` SET gedcom_name = ? WHERE gedcom_id = ?")->execute(array($gedcom, $WT_TREE->getTreeId()));
295
-			Database::prepare("UPDATE `##site_setting` SET setting_value = ? WHERE setting_name='DEFAULT_GEDCOM' AND setting_value = ?")->execute(array($gedcom, $WT_TREE->getName()));
296
-		} catch (\Exception $ex) {
297
-			// Probably a duplicate name.
291
+		$gedcom = Filter::post('gedcom');
292
+		if ($gedcom && $gedcom !== $WT_TREE->getName()) {
293
+			try {
294
+				Database::prepare("UPDATE `##gedcom` SET gedcom_name = ? WHERE gedcom_id = ?")->execute(array($gedcom, $WT_TREE->getTreeId()));
295
+				Database::prepare("UPDATE `##site_setting` SET setting_value = ? WHERE setting_name='DEFAULT_GEDCOM' AND setting_value = ?")->execute(array($gedcom, $WT_TREE->getName()));
296
+			} catch (\Exception $ex) {
297
+				// Probably a duplicate name.
298
+			}
298 299
 		}
299
-	}
300 300
 
301
-	FlashMessages::addMessage(I18N::translate('The preferences for the family tree “%s” have been updated.', $WT_TREE->getTitleHtml()), 'success');
302
-	header('Location: ' . WT_BASE_URL . 'admin_trees_manage.php');
301
+		FlashMessages::addMessage(I18N::translate('The preferences for the family tree “%s” have been updated.', $WT_TREE->getTitleHtml()), 'success');
302
+		header('Location: ' . WT_BASE_URL . 'admin_trees_manage.php');
303 303
 
304
-	return;
304
+		return;
305 305
 }
306 306
 
307 307
 switch (Filter::get('action')) {
Please login to merge, or discard this patch.
admin_trees_duplicates.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -177,8 +177,11 @@
 block discarded – undo
177 177
 	</li>
178 178
 <?php endforeach; ?>
179 179
 </ul>
180
-<?php else: ?>
181
-<p><?php echo I18N::translate('No duplicates have been found.'); ?></p>
180
+<?php else {
181
+	: ?>
182
+<p><?php echo I18N::translate('No duplicates have been found.');
183
+}
184
+?></p>
182 185
 <?php endif; ?>
183 186
 
184 187
 <?php endforeach; ?>
Please login to merge, or discard this patch.
admin_trees_manage.php 2 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -433,8 +433,11 @@
 block discarded – undo
433 433
 									<i class="fa fa-li fa-star"></i>
434 434
 									<?php if ($tree->getName() == Site::getPreference('DEFAULT_GEDCOM')): ?>
435 435
 										<?php echo I18N::translate('Default family tree'); ?>
436
-									<?php else: ?>
437
-										<a href="#" onclick="document.defaultform<?php echo $tree->getTreeId(); ?>.submit();">
436
+									<?php else {
437
+	: ?>
438
+										<a href="#" onclick="document.defaultform<?php echo $tree->getTreeId();
439
+}
440
+?>.submit();">
438 441
 											<?php echo I18N::translate('Set as default'); ?>
439 442
 											<span class="sr-only">
440 443
 										<?php echo $tree->getTitleHtml(); ?>
Please login to merge, or discard this patch.
Switch Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -50,116 +50,116 @@  discard block
 block discarded – undo
50 50
 }
51 51
 // Process POST actions
52 52
 switch (Filter::post('action')) {
53
-case 'delete':
54
-	$gedcom_id = Filter::postInteger('gedcom_id');
55
-	if (Filter::checkCsrf() && $gedcom_id) {
56
-		$tree = Tree::findById($gedcom_id);
57
-		FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success');
58
-		$tree->delete();
59
-	}
60
-	header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
61
-
62
-	return;
63
-case 'setdefault':
64
-	if (Filter::checkCsrf()) {
65
-		Site::setPreference('DEFAULT_GEDCOM', Filter::post('ged'));
66
-		FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” will be shown to visitors when they first arrive at this website.', $WT_TREE->getTitleHtml()), 'success');
67
-	}
68
-	header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
69
-
70
-	return;
71
-case 'new_tree':
72
-	$basename   = basename(Filter::post('tree_name'));
73
-	$tree_title = Filter::post('tree_title');
74
-
75
-	if (Filter::checkCsrf() && $basename && $tree_title) {
76
-		if (Tree::findByName($basename)) {
77
-			FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” already exists.', Filter::escapeHtml($basename)), 'danger');
78
-		} else {
79
-			Tree::create($basename, $tree_title);
80
-			FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been created.', Filter::escapeHtml($basename)), 'success');
53
+	case 'delete':
54
+		$gedcom_id = Filter::postInteger('gedcom_id');
55
+		if (Filter::checkCsrf() && $gedcom_id) {
56
+			$tree = Tree::findById($gedcom_id);
57
+			FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success');
58
+			$tree->delete();
81 59
 		}
82
-	}
83
-	header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?ged=' . Filter::escapeUrl($basename));
84
-
85
-	return;
86
-case 'replace_upload':
87
-	$gedcom_id          = Filter::postInteger('gedcom_id');
88
-	$keep_media         = Filter::post('keep_media', '1', '0');
89
-	$GEDCOM_MEDIA_PATH  = Filter::post('GEDCOM_MEDIA_PATH');
90
-	$WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0');
91
-	$tree               = Tree::findById($gedcom_id);
92
-
93
-	if (Filter::checkCsrf() && $tree) {
94
-		$tree->setPreference('keep_media', $keep_media);
95
-		$tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH);
96
-		$tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES);
97
-		if (isset($_FILES['tree_name'])) {
98
-			if ($_FILES['tree_name']['error'] == 0 && is_readable($_FILES['tree_name']['tmp_name'])) {
99
-				$tree->importGedcomFile($_FILES['tree_name']['tmp_name'], $_FILES['tree_name']['name']);
100
-			} else {
101
-				FlashMessages::addMessage(Functions::fileUploadErrorText($_FILES['tree_name']['error']), 'danger');
102
-			}
103
-		} else {
104
-			FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger');
105
-		}
106
-	}
107
-	header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
108
-
109
-	return;
110
-case 'replace_import':
111
-	$basename           = basename(Filter::post('tree_name'));
112
-	$gedcom_id          = Filter::postInteger('gedcom_id');
113
-	$keep_media         = Filter::post('keep_media', '1', '0');
114
-	$GEDCOM_MEDIA_PATH  = Filter::post('GEDCOM_MEDIA_PATH');
115
-	$WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0');
116
-	$tree               = Tree::findById($gedcom_id);
117
-
118
-	if (Filter::checkCsrf() && $tree) {
119
-		$tree->setPreference('keep_media', $keep_media);
120
-		$tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH);
121
-		$tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES);
122
-		if ($basename) {
123
-			$tree->importGedcomFile(WT_DATA_DIR . $basename, $basename);
124
-		} else {
125
-			FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger');
126
-		}
127
-	}
128
-	header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
129
-
130
-	return;
60
+		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
131 61
 
132
-case 'synchronize':
133
-	if (Filter::checkCsrf()) {
134
-		$basenames = array();
62
+		return;
63
+	case 'setdefault':
64
+		if (Filter::checkCsrf()) {
65
+			Site::setPreference('DEFAULT_GEDCOM', Filter::post('ged'));
66
+			FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” will be shown to visitors when they first arrive at this website.', $WT_TREE->getTitleHtml()), 'success');
67
+		}
68
+		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
135 69
 
136
-		foreach ($gedcom_files as $gedcom_file) {
137
-			$filemtime   = filemtime($gedcom_file); // Only import files that have changed
138
-			$basename    = basename($gedcom_file);
139
-			$basenames[] = $basename;
70
+		return;
71
+	case 'new_tree':
72
+		$basename   = basename(Filter::post('tree_name'));
73
+		$tree_title = Filter::post('tree_title');
140 74
 
141
-			$tree = Tree::findByName($basename);
142
-			if (!$tree) {
143
-				$tree = Tree::create($basename, $basename);
75
+		if (Filter::checkCsrf() && $basename && $tree_title) {
76
+			if (Tree::findByName($basename)) {
77
+				FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” already exists.', Filter::escapeHtml($basename)), 'danger');
78
+			} else {
79
+				Tree::create($basename, $tree_title);
80
+				FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been created.', Filter::escapeHtml($basename)), 'success');
144 81
 			}
145
-			if ($tree->getPreference('filemtime') != $filemtime) {
146
-				$tree->importGedcomFile($gedcom_file, $basename);
147
-				$tree->setPreference('filemtime', $filemtime);
148
-				FlashMessages::addMessage(I18N::translate('The GEDCOM file “%s” has been imported.', Filter::escapeHtml($basename)), 'success');
82
+		}
83
+		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?ged=' . Filter::escapeUrl($basename));
84
+
85
+		return;
86
+	case 'replace_upload':
87
+		$gedcom_id          = Filter::postInteger('gedcom_id');
88
+		$keep_media         = Filter::post('keep_media', '1', '0');
89
+		$GEDCOM_MEDIA_PATH  = Filter::post('GEDCOM_MEDIA_PATH');
90
+		$WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0');
91
+		$tree               = Tree::findById($gedcom_id);
92
+
93
+		if (Filter::checkCsrf() && $tree) {
94
+			$tree->setPreference('keep_media', $keep_media);
95
+			$tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH);
96
+			$tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES);
97
+			if (isset($_FILES['tree_name'])) {
98
+				if ($_FILES['tree_name']['error'] == 0 && is_readable($_FILES['tree_name']['tmp_name'])) {
99
+					$tree->importGedcomFile($_FILES['tree_name']['tmp_name'], $_FILES['tree_name']['name']);
100
+				} else {
101
+					FlashMessages::addMessage(Functions::fileUploadErrorText($_FILES['tree_name']['error']), 'danger');
102
+				}
103
+			} else {
104
+				FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger');
149 105
 			}
150 106
 		}
151
-
152
-		foreach (Tree::getAll() as $tree) {
153
-			if (!in_array($tree->getName(), $basenames)) {
154
-				FlashMessages::addMessage(I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success');
155
-				$tree->delete();
107
+		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
108
+
109
+		return;
110
+	case 'replace_import':
111
+		$basename           = basename(Filter::post('tree_name'));
112
+		$gedcom_id          = Filter::postInteger('gedcom_id');
113
+		$keep_media         = Filter::post('keep_media', '1', '0');
114
+		$GEDCOM_MEDIA_PATH  = Filter::post('GEDCOM_MEDIA_PATH');
115
+		$WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0');
116
+		$tree               = Tree::findById($gedcom_id);
117
+
118
+		if (Filter::checkCsrf() && $tree) {
119
+			$tree->setPreference('keep_media', $keep_media);
120
+			$tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH);
121
+			$tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES);
122
+			if ($basename) {
123
+				$tree->importGedcomFile(WT_DATA_DIR . $basename, $basename);
124
+			} else {
125
+				FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger');
156 126
 			}
157 127
 		}
128
+		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
129
+
130
+		return;
131
+
132
+	case 'synchronize':
133
+		if (Filter::checkCsrf()) {
134
+			$basenames = array();
135
+
136
+			foreach ($gedcom_files as $gedcom_file) {
137
+				$filemtime   = filemtime($gedcom_file); // Only import files that have changed
138
+				$basename    = basename($gedcom_file);
139
+				$basenames[] = $basename;
140
+
141
+				$tree = Tree::findByName($basename);
142
+				if (!$tree) {
143
+					$tree = Tree::create($basename, $basename);
144
+				}
145
+				if ($tree->getPreference('filemtime') != $filemtime) {
146
+					$tree->importGedcomFile($gedcom_file, $basename);
147
+					$tree->setPreference('filemtime', $filemtime);
148
+					FlashMessages::addMessage(I18N::translate('The GEDCOM file “%s” has been imported.', Filter::escapeHtml($basename)), 'success');
149
+				}
150
+			}
158 151
 
159
-	}
160
-	header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
152
+			foreach (Tree::getAll() as $tree) {
153
+				if (!in_array($tree->getName(), $basenames)) {
154
+					FlashMessages::addMessage(I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success');
155
+					$tree->delete();
156
+				}
157
+			}
158
+
159
+		}
160
+		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
161 161
 
162
-	return;
162
+		return;
163 163
 }
164 164
 
165 165
 $default_tree_title  = /* I18N: Default name for a new tree */ I18N::translate('My family tree');
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 
174 174
 // Process GET actions
175 175
 switch (Filter::get('action')) {
176
-case 'importform':
177
-	$controller
178
-		->setPageTitle($WT_TREE->getTitleHtml() . ' — ' . I18N::translate('Import a GEDCOM file'))
179
-		->pageHeader();
176
+	case 'importform':
177
+		$controller
178
+			->setPageTitle($WT_TREE->getTitleHtml() . ' — ' . I18N::translate('Import a GEDCOM file'))
179
+			->pageHeader();
180 180
 
181
-	?>
181
+		?>
182 182
 	<ol class="breadcrumb small">
183 183
 		<li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li>
184 184
 		<li><a href="admin_trees_manage.php"><?php echo I18N::translate('Manage family trees'); ?></a></li>
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
 	<h1><?php echo $controller->getPageTitle(); ?></h1>
189 189
 	<?php
190 190
 
191
-	$tree = Tree::findById(Filter::getInteger('gedcom_id'));
192
-	// Check it exists
193
-	if (!$tree) {
194
-		break;
195
-	}
196
-	$gedcom_filename = $tree->getPreference('gedcom_filename')
197
-	?>
198
-	<p>
191
+		$tree = Tree::findById(Filter::getInteger('gedcom_id'));
192
+		// Check it exists
193
+		if (!$tree) {
194
+			break;
195
+		}
196
+		$gedcom_filename = $tree->getPreference('gedcom_filename')
197
+		?>
198
+		<p>
199 199
 		<?php echo /* I18N: %s is the name of a family tree */ I18N::translate('This will delete all the genealogy data from “%s” and replace it with data from a GEDCOM file.', $tree->getTitleHtml()); ?>
200 200
 	</p>
201 201
 	<form class="form form-horizontal" name="gedcomimportform" method="post" enctype="multipart/form-data" onsubmit="return checkGedcomImportForm('<?php echo Filter::escapeHtml(I18N::translate('You have selected a GEDCOM file with a different name. Is this correct?')); ?>');">
@@ -228,35 +228,35 @@  discard block
 block discarded – undo
228 228
 						<div class="input-group">
229 229
 							<span class="input-group-addon">
230 230
 								<?php echo WT_DATA_DIR; ?>
231
-							</span>
231
+								</span>
232 232
 							<?php
233
-							$d     = opendir(WT_DATA_DIR);
234
-							$files = array();
235
-							while (($f = readdir($d)) !== false) {
236
-								if (!is_dir(WT_DATA_DIR . $f) && is_readable(WT_DATA_DIR . $f)) {
237
-									$fp     = fopen(WT_DATA_DIR . $f, 'rb');
238
-									$header = fread($fp, 64);
239
-									fclose($fp);
240
-									if (preg_match('/^(' . WT_UTF8_BOM . ')?0 *HEAD/', $header)) {
241
-										$files[] = $f;
233
+								$d     = opendir(WT_DATA_DIR);
234
+								$files = array();
235
+								while (($f = readdir($d)) !== false) {
236
+									if (!is_dir(WT_DATA_DIR . $f) && is_readable(WT_DATA_DIR . $f)) {
237
+										$fp     = fopen(WT_DATA_DIR . $f, 'rb');
238
+										$header = fread($fp, 64);
239
+										fclose($fp);
240
+										if (preg_match('/^(' . WT_UTF8_BOM . ')?0 *HEAD/', $header)) {
241
+											$files[] = $f;
242
+										}
243
+									}
244
+								}
245
+								echo '<select name="tree_name" class="form-control" id="import-server-file">';
246
+								echo '<option value=""></option>';
247
+								sort($files);
248
+								foreach ($files as $gedcom_file) {
249
+									echo '<option value="', Filter::escapeHtml($gedcom_file), '" ';
250
+									if ($gedcom_file === $gedcom_filename) {
251
+										echo ' selected';
242 252
 									}
253
+									echo'>', Filter::escapeHtml($gedcom_file), '</option>';
243 254
 								}
244
-							}
245
-							echo '<select name="tree_name" class="form-control" id="import-server-file">';
246
-							echo '<option value=""></option>';
247
-							sort($files);
248
-							foreach ($files as $gedcom_file) {
249
-								echo '<option value="', Filter::escapeHtml($gedcom_file), '" ';
250
-								if ($gedcom_file === $gedcom_filename) {
251
-									echo ' selected';
255
+								if (!$files) {
256
+									echo '<option disabled selected>', I18N::translate('No GEDCOM files found.'), '</option>';
252 257
 								}
253
-								echo'>', Filter::escapeHtml($gedcom_file), '</option>';
254
-							}
255
-							if (!$files) {
256
-								echo '<option disabled selected>', I18N::translate('No GEDCOM files found.'), '</option>';
257
-							}
258
-							echo '</select>';
259
-							?>
258
+								echo '</select>';
259
+								?>
260 260
 						</div>
261 261
 					</div>
262 262
 				</div>
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 					>
299 299
 				<p class="small text-muted">
300 300
 					<?php echo /* I18N: Help text for the “GEDCOM media path” configuration setting. A “path” is something like “C:\Documents\Genealogy\Photos\John_Smith.jpeg” */ I18N::translate('Some genealogy software creates GEDCOM files that contain media filenames with full paths. These paths will not exist on the web-server. To allow webtrees to find the file, the first part of the path must be removed.'); ?>
301
-					<?php echo /* I18N: Help text for the “GEDCOM media path” configuration setting. %s are all folder names */ I18N::translate('For example, if the GEDCOM file contains %1$s and webtrees expects to find %2$s in the media folder, then you would need to remove %3$s.', '<code>C:\\Documents\\family\\photo.jpeg</code>', '<code>family\\photo.jpeg</code>', '<code>C:\\Documents\\</code>'); ?>
301
+						<?php echo /* I18N: Help text for the “GEDCOM media path” configuration setting. %s are all folder names */ I18N::translate('For example, if the GEDCOM file contains %1$s and webtrees expects to find %2$s in the media folder, then you would need to remove %3$s.', '<code>C:\\Documents\\family\\photo.jpeg</code>', '<code>family\\photo.jpeg</code>', '<code>C:\\Documents\\</code>'); ?>
302 302
 				</p>
303 303
 			</div>
304 304
 		</fieldset>
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 	</form>
314 314
 	<?php
315 315
 
316
-	return;
316
+		return;
317 317
 }
318 318
 
319 319
 if (!Tree::getAll()) {
Please login to merge, or discard this patch.
admin_users.php 2 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -791,8 +791,11 @@
 block discarded – undo
791 791
 		<p>
792 792
 		<?php if ($ucnt): ?>
793 793
 			<input type="submit" value="<?php echo I18N::translate('delete'); ?>">
794
-			<?php else: ?>
795
-			<?php echo I18N::translate('Nothing found to cleanup'); ?>
794
+			<?php else {
795
+	: ?>
796
+			<?php echo I18N::translate('Nothing found to cleanup');
797
+}
798
+?>
796 799
 			<?php endif; ?>
797 800
 		</p>
798 801
 	</form>
Please login to merge, or discard this patch.
Switch Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -45,95 +45,95 @@  discard block
 block discarded – undo
45 45
 
46 46
 // Form actions
47 47
 switch (Filter::post('action')) {
48
-case 'save':
49
-	if (Filter::checkCsrf()) {
50
-		$user_id        = Filter::postInteger('user_id');
51
-		$user           = User::find($user_id);
52
-		$username       = Filter::post('username');
53
-		$real_name      = Filter::post('real_name');
54
-		$email          = Filter::postEmail('email');
55
-		$pass1          = Filter::post('pass1', WT_REGEX_PASSWORD);
56
-		$pass2          = Filter::post('pass2', WT_REGEX_PASSWORD);
57
-		$theme          = Filter::post('theme', implode('|', array_keys(Theme::themeNames())), '');
58
-		$language       = Filter::post('language');
59
-		$timezone       = Filter::post('timezone');
60
-		$contact_method = Filter::post('contact_method');
61
-		$comment        = Filter::post('comment');
62
-		$auto_accept    = Filter::postBool('auto_accept');
63
-		$canadmin       = Filter::postBool('canadmin');
64
-		$visible_online = Filter::postBool('visible_online');
65
-		$verified       = Filter::postBool('verified');
66
-		$approved       = Filter::postBool('approved');
67
-
68
-		if ($user_id === 0) {
69
-			// Create a new user
70
-			if (User::findByUserName($username)) {
71
-				FlashMessages::addMessage(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.'));
72
-			} elseif (User::findByEmail($email)) {
73
-				FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.'));
74
-			} elseif ($pass1 !== $pass2) {
75
-				FlashMessages::addMessage(I18N::translate('The passwords do not match.'));
48
+	case 'save':
49
+		if (Filter::checkCsrf()) {
50
+			$user_id        = Filter::postInteger('user_id');
51
+			$user           = User::find($user_id);
52
+			$username       = Filter::post('username');
53
+			$real_name      = Filter::post('real_name');
54
+			$email          = Filter::postEmail('email');
55
+			$pass1          = Filter::post('pass1', WT_REGEX_PASSWORD);
56
+			$pass2          = Filter::post('pass2', WT_REGEX_PASSWORD);
57
+			$theme          = Filter::post('theme', implode('|', array_keys(Theme::themeNames())), '');
58
+			$language       = Filter::post('language');
59
+			$timezone       = Filter::post('timezone');
60
+			$contact_method = Filter::post('contact_method');
61
+			$comment        = Filter::post('comment');
62
+			$auto_accept    = Filter::postBool('auto_accept');
63
+			$canadmin       = Filter::postBool('canadmin');
64
+			$visible_online = Filter::postBool('visible_online');
65
+			$verified       = Filter::postBool('verified');
66
+			$approved       = Filter::postBool('approved');
67
+
68
+			if ($user_id === 0) {
69
+				// Create a new user
70
+				if (User::findByUserName($username)) {
71
+					FlashMessages::addMessage(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.'));
72
+				} elseif (User::findByEmail($email)) {
73
+					FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.'));
74
+				} elseif ($pass1 !== $pass2) {
75
+					FlashMessages::addMessage(I18N::translate('The passwords do not match.'));
76
+				} else {
77
+					$user = User::create($username, $real_name, $email, $pass1);
78
+					$user->setPreference('reg_timestamp', date('U'))->setPreference('sessiontime', '0');
79
+					Log::addAuthenticationLog('User ->' . $username . '<- created');
80
+				}
76 81
 			} else {
77
-				$user = User::create($username, $real_name, $email, $pass1);
78
-				$user->setPreference('reg_timestamp', date('U'))->setPreference('sessiontime', '0');
79
-				Log::addAuthenticationLog('User ->' . $username . '<- created');
80
-			}
81
-		} else {
82
-			$user = User::find($user_id);
83
-			if ($user && $username && $real_name) {
84
-				$user->setEmail($email);
85
-				$user->setUserName($username);
86
-				$user->setRealName($real_name);
87
-				if ($pass1 !== null && $pass1 === $pass2) {
88
-					$user->setPassword($pass1);
82
+				$user = User::find($user_id);
83
+				if ($user && $username && $real_name) {
84
+					$user->setEmail($email);
85
+					$user->setUserName($username);
86
+					$user->setRealName($real_name);
87
+					if ($pass1 !== null && $pass1 === $pass2) {
88
+						$user->setPassword($pass1);
89
+					}
89 90
 				}
90 91
 			}
91
-		}
92 92
 
93
-		if ($user) {
94
-			// Approving for the first time? Send a confirmation email
95
-			if ($approved && !$user->getPreference('verified_by_admin') && $user->getPreference('sessiontime') == 0) {
96
-				I18N::init($user->getPreference('language'));
97
-				Mail::systemMessage(
98
-					$WT_TREE,
99
-					$user,
100
-					I18N::translate('Approval of account at %s', WT_BASE_URL),
101
-					I18N::translate('The administrator at the webtrees site %s has approved your application for an account. You may now sign in by accessing the following link: %s', WT_BASE_URL, WT_BASE_URL)
102
-				);
103
-			}
93
+			if ($user) {
94
+				// Approving for the first time? Send a confirmation email
95
+				if ($approved && !$user->getPreference('verified_by_admin') && $user->getPreference('sessiontime') == 0) {
96
+					I18N::init($user->getPreference('language'));
97
+					Mail::systemMessage(
98
+						$WT_TREE,
99
+						$user,
100
+						I18N::translate('Approval of account at %s', WT_BASE_URL),
101
+						I18N::translate('The administrator at the webtrees site %s has approved your application for an account. You may now sign in by accessing the following link: %s', WT_BASE_URL, WT_BASE_URL)
102
+					);
103
+				}
104 104
 
105
-			$user
106
-				->setPreference('theme', $theme)
107
-				->setPreference('language', $language)
108
-				->setPreference('TIMEZONE', $timezone)
109
-				->setPreference('contactmethod', $contact_method)
110
-				->setPreference('comment', $comment)
111
-				->setPreference('auto_accept', $auto_accept ? '1' : '0')
112
-				->setPreference('visibleonline', $visible_online ? '1' : '0')
113
-				->setPreference('verified', $verified ? '1' : '0')
114
-				->setPreference('verified_by_admin', $approved ? '1' : '0');
115
-
116
-			// We cannot change our own admin status. Another admin will need to do it.
117
-			if ($user->getUserId() !== Auth::id()) {
118
-				$user->setPreference('canadmin', $canadmin ? '1' : '0');
119
-			}
105
+				$user
106
+					->setPreference('theme', $theme)
107
+					->setPreference('language', $language)
108
+					->setPreference('TIMEZONE', $timezone)
109
+					->setPreference('contactmethod', $contact_method)
110
+					->setPreference('comment', $comment)
111
+					->setPreference('auto_accept', $auto_accept ? '1' : '0')
112
+					->setPreference('visibleonline', $visible_online ? '1' : '0')
113
+					->setPreference('verified', $verified ? '1' : '0')
114
+					->setPreference('verified_by_admin', $approved ? '1' : '0');
115
+
116
+				// We cannot change our own admin status. Another admin will need to do it.
117
+				if ($user->getUserId() !== Auth::id()) {
118
+					$user->setPreference('canadmin', $canadmin ? '1' : '0');
119
+				}
120 120
 
121
-			foreach (Tree::getAll() as $tree) {
122
-				$tree->setUserPreference($user, 'gedcomid', Filter::post('gedcomid' . $tree->getTreeId(), WT_REGEX_XREF));
123
-				$tree->setUserPreference($user, 'canedit', Filter::post('canedit' . $tree->getTreeId(), implode('|', array_keys($ALL_EDIT_OPTIONS))));
124
-				if (Filter::post('gedcomid' . $tree->getTreeId(), WT_REGEX_XREF)) {
125
-					$tree->setUserPreference($user, 'RELATIONSHIP_PATH_LENGTH', Filter::postInteger('RELATIONSHIP_PATH_LENGTH' . $tree->getTreeId(), 0, 10, 0));
126
-				} else {
127
-					// Do not allow a path length to be set if the individual ID is not
128
-					$tree->setUserPreference($user, 'RELATIONSHIP_PATH_LENGTH', null);
121
+				foreach (Tree::getAll() as $tree) {
122
+					$tree->setUserPreference($user, 'gedcomid', Filter::post('gedcomid' . $tree->getTreeId(), WT_REGEX_XREF));
123
+					$tree->setUserPreference($user, 'canedit', Filter::post('canedit' . $tree->getTreeId(), implode('|', array_keys($ALL_EDIT_OPTIONS))));
124
+					if (Filter::post('gedcomid' . $tree->getTreeId(), WT_REGEX_XREF)) {
125
+						$tree->setUserPreference($user, 'RELATIONSHIP_PATH_LENGTH', Filter::postInteger('RELATIONSHIP_PATH_LENGTH' . $tree->getTreeId(), 0, 10, 0));
126
+					} else {
127
+						// Do not allow a path length to be set if the individual ID is not
128
+						$tree->setUserPreference($user, 'RELATIONSHIP_PATH_LENGTH', null);
129
+					}
129 130
 				}
130 131
 			}
131 132
 		}
132
-	}
133 133
 
134
-	header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
134
+		header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
135 135
 
136
-	return;
136
+		return;
137 137
 }
138 138
 
139 139
 switch (Filter::get('action')) {
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 			// Datatables numbers columns 0, 1, 2
174 174
 			// MySQL numbers columns 1, 2, 3
175 175
 			switch ($value['dir']) {
176
-			case 'asc':
177
-				$sql_select .= (1 + $value['column']) . " ASC ";
178
-				break;
179
-			case 'desc':
180
-				$sql_select .= (1 + $value['column']) . " DESC ";
181
-				break;
176
+				case 'asc':
177
+					$sql_select .= (1 + $value['column']) . " ASC ";
178
+					break;
179
+				case 'desc':
180
+					$sql_select .= (1 + $value['column']) . " DESC ";
181
+					break;
182 182
 			}
183 183
 		}
184 184
 	} else {
Please login to merge, or discard this patch.
app/Database.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,8 +85,7 @@
 block discarded – undo
85 85
 		// Create the underlying PDO object
86 86
 		self::$pdo = new PDO(
87 87
 			(substr($DBHOST, 0, 1) === '/' ?
88
-				"mysql:unix_socket={$DBHOST};dbname={$DBNAME}" :
89
-				"mysql:host={$DBHOST};dbname={$DBNAME};port={$DBPORT}"
88
+				"mysql:unix_socket={$DBHOST};dbname={$DBNAME}" : "mysql:host={$DBHOST};dbname={$DBNAME};port={$DBPORT}"
90 89
 			),
91 90
 			$DBUSER, $DBPASS,
92 91
 			array(
Please login to merge, or discard this patch.