Passed
Push — 1.7 ( 23cbb7...8df8a8 )
by Greg
08:15
created
login.php 1 patch
Indentation   +388 added lines, -388 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 
32 32
 // If we are already logged in, then go to the “Home page”
33 33
 if (Auth::check() && $WT_TREE) {
34
-	header('Location: ' . WT_BASE_URL);
34
+    header('Location: ' . WT_BASE_URL);
35 35
 
36
-	return;
36
+    return;
37 37
 }
38 38
 
39 39
 $controller = new PageController;
@@ -53,104 +53,104 @@  discard block
 block discarded – undo
53 53
 
54 54
 // These parameters may come from the URL which is emailed to users.
55 55
 if (!$action) {
56
-	$action = Filter::get('action');
56
+    $action = Filter::get('action');
57 57
 }
58 58
 if (!$user_name) {
59
-	$user_name = Filter::get('user_name');
59
+    $user_name = Filter::get('user_name');
60 60
 }
61 61
 if (!$user_hashcode) {
62
-	$user_hashcode = Filter::get('user_hashcode');
62
+    $user_hashcode = Filter::get('user_hashcode');
63 63
 }
64 64
 if (!$url) {
65
-	$url = Filter::get('url');
65
+    $url = Filter::get('url');
66 66
 }
67 67
 
68 68
 $message = '';
69 69
 
70 70
 switch ($action) {
71 71
 case 'login':
72
-	try {
73
-		if (!$_COOKIE) {
74
-			Log::addAuthenticationLog('Login failed (no session cookies): ' . $username);
75
-			throw new \Exception(I18N::translate('You cannot sign in because your browser does not accept cookies.'));
76
-		}
77
-
78
-		$user = User::findByIdentifier($username);
79
-
80
-		if (!$user) {
81
-			Log::addAuthenticationLog('Login failed (no such user/email): ' . $username);
82
-			throw new \Exception(I18N::translate('The username or password is incorrect.'));
83
-		}
84
-
85
-		if (!$user->checkPassword($password)) {
86
-			Log::addAuthenticationLog('Login failed (incorrect password): ' . $username);
87
-			throw new \Exception(I18N::translate('The username or password is incorrect.'));
88
-		}
89
-
90
-		if (!$user->getPreference('verified')) {
91
-			Log::addAuthenticationLog('Login failed (not verified by user): ' . $username);
92
-			throw new \Exception(I18N::translate('This account has not been verified. Please check your email for a verification message.'));
93
-		}
94
-
95
-		if (!$user->getPreference('verified_by_admin')) {
96
-			Log::addAuthenticationLog('Login failed (not approved by admin): ' . $username);
97
-			throw new \Exception(I18N::translate('This account has not been approved. Please wait for an administrator to approve it.'));
98
-		}
99
-
100
-		Auth::login($user);
101
-		Log::addAuthenticationLog('Login: ' . Auth::user()->getUserName() . '/' . Auth::user()->getRealName());
102
-		Auth::user()->setPreference('sessiontime', WT_TIMESTAMP);
103
-
104
-		Session::put('locale', Auth::user()->getPreference('language'));
105
-		Session::put('theme_id', Auth::user()->getPreference('theme'));
106
-		I18N::init(Auth::user()->getPreference('language'));
107
-
108
-		// We're logging in as an administrator
109
-		if (Auth::isAdmin()) {
110
-			// Check for updates
111
-			$latest_version_txt = Functions::fetchLatestVersion();
112
-			if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) {
113
-				list($latest_version, $earliest_version, $download_url) = explode('|', $latest_version_txt);
114
-				if (version_compare(WT_VERSION, $latest_version) < 0) {
115
-					FlashMessages::addMessage(
116
-						I18N::translate('A new version of webtrees is available.') .
117
-						' <a href="admin_site_upgrade.php"><b>' .
118
-						I18N::translate('Upgrade to webtrees %s.', '<span dir="ltr">' . $latest_version . '</span>') .
119
-						'</b></a>'
120
-					);
121
-				}
122
-			}
123
-		}
124
-
125
-		// If we were on a "home page", redirect to "my page"
126
-		if ($url === '' || strpos($url, 'index.php?ctype=gedcom') === 0) {
127
-			$url = 'index.php?ctype=user';
128
-			// Switch to a tree where we have a genealogy record (or keep to the current/default).
129
-			$tree = Database::prepare(
130
-				"SELECT gedcom_name FROM `##gedcom` JOIN `##user_gedcom_setting` USING (gedcom_id)" .
131
-				" WHERE setting_name = 'gedcomid' AND user_id = :user_id" .
132
-				" ORDER BY gedcom_id = :tree_id DESC"
133
-			)->execute(array(
134
-				'user_id' => Auth::user()->getUserId(),
135
-				'tree_id' => $WT_TREE->getTreeId(),
136
-			))->fetchOne();
137
-			$url .= '&ged=' . Filter::escapeUrl($tree);
138
-		}
139
-
140
-		// Redirect to the target URL
141
-		header('Location: ' . WT_BASE_URL . $url);
142
-
143
-		return;
144
-	} catch (\Exception $ex) {
145
-		$message = $ex->getMessage();
146
-	}
147
-	// No break;
72
+    try {
73
+        if (!$_COOKIE) {
74
+            Log::addAuthenticationLog('Login failed (no session cookies): ' . $username);
75
+            throw new \Exception(I18N::translate('You cannot sign in because your browser does not accept cookies.'));
76
+        }
77
+
78
+        $user = User::findByIdentifier($username);
79
+
80
+        if (!$user) {
81
+            Log::addAuthenticationLog('Login failed (no such user/email): ' . $username);
82
+            throw new \Exception(I18N::translate('The username or password is incorrect.'));
83
+        }
84
+
85
+        if (!$user->checkPassword($password)) {
86
+            Log::addAuthenticationLog('Login failed (incorrect password): ' . $username);
87
+            throw new \Exception(I18N::translate('The username or password is incorrect.'));
88
+        }
89
+
90
+        if (!$user->getPreference('verified')) {
91
+            Log::addAuthenticationLog('Login failed (not verified by user): ' . $username);
92
+            throw new \Exception(I18N::translate('This account has not been verified. Please check your email for a verification message.'));
93
+        }
94
+
95
+        if (!$user->getPreference('verified_by_admin')) {
96
+            Log::addAuthenticationLog('Login failed (not approved by admin): ' . $username);
97
+            throw new \Exception(I18N::translate('This account has not been approved. Please wait for an administrator to approve it.'));
98
+        }
99
+
100
+        Auth::login($user);
101
+        Log::addAuthenticationLog('Login: ' . Auth::user()->getUserName() . '/' . Auth::user()->getRealName());
102
+        Auth::user()->setPreference('sessiontime', WT_TIMESTAMP);
103
+
104
+        Session::put('locale', Auth::user()->getPreference('language'));
105
+        Session::put('theme_id', Auth::user()->getPreference('theme'));
106
+        I18N::init(Auth::user()->getPreference('language'));
107
+
108
+        // We're logging in as an administrator
109
+        if (Auth::isAdmin()) {
110
+            // Check for updates
111
+            $latest_version_txt = Functions::fetchLatestVersion();
112
+            if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) {
113
+                list($latest_version, $earliest_version, $download_url) = explode('|', $latest_version_txt);
114
+                if (version_compare(WT_VERSION, $latest_version) < 0) {
115
+                    FlashMessages::addMessage(
116
+                        I18N::translate('A new version of webtrees is available.') .
117
+                        ' <a href="admin_site_upgrade.php"><b>' .
118
+                        I18N::translate('Upgrade to webtrees %s.', '<span dir="ltr">' . $latest_version . '</span>') .
119
+                        '</b></a>'
120
+                    );
121
+                }
122
+            }
123
+        }
124
+
125
+        // If we were on a "home page", redirect to "my page"
126
+        if ($url === '' || strpos($url, 'index.php?ctype=gedcom') === 0) {
127
+            $url = 'index.php?ctype=user';
128
+            // Switch to a tree where we have a genealogy record (or keep to the current/default).
129
+            $tree = Database::prepare(
130
+                "SELECT gedcom_name FROM `##gedcom` JOIN `##user_gedcom_setting` USING (gedcom_id)" .
131
+                " WHERE setting_name = 'gedcomid' AND user_id = :user_id" .
132
+                " ORDER BY gedcom_id = :tree_id DESC"
133
+            )->execute(array(
134
+                'user_id' => Auth::user()->getUserId(),
135
+                'tree_id' => $WT_TREE->getTreeId(),
136
+            ))->fetchOne();
137
+            $url .= '&ged=' . Filter::escapeUrl($tree);
138
+        }
139
+
140
+        // Redirect to the target URL
141
+        header('Location: ' . WT_BASE_URL . $url);
142
+
143
+        return;
144
+    } catch (\Exception $ex) {
145
+        $message = $ex->getMessage();
146
+    }
147
+    // No break;
148 148
 
149 149
 default:
150
-	$controller
151
-		->setPageTitle(I18N::translate('Sign in'))
152
-		->pageHeader()
153
-		->addInlineJavascript('
150
+    $controller
151
+        ->setPageTitle(I18N::translate('Sign in'))
152
+        ->pageHeader()
153
+        ->addInlineJavascript('
154 154
 			jQuery("#new_passwd_form").hide();
155 155
 			jQuery("#passwd_click").click(function() {
156 156
 				jQuery("#new_passwd_form").slideToggle(100, function() {
@@ -160,247 +160,247 @@  discard block
 block discarded – undo
160 160
 			});
161 161
 		');
162 162
 
163
-	echo '<div id="login-page">';
164
-	echo '<div id="login-text">';
165
-
166
-	echo '<p class="center"><strong>' . I18N::translate('Welcome to this genealogy website') . '</strong></p>';
167
-
168
-	switch (Site::getPreference('WELCOME_TEXT_AUTH_MODE')) {
169
-	case 1:
170
-		echo '<p>' . I18N::translate('Anyone with a user account can access this website.') . ' ' . I18N::translate('You can apply for an account using the link below.') . '</p>';
171
-		break;
172
-	case 2:
173
-		echo '<p>' . I18N::translate('You need to be an authorized user to access this website.') . ' ' . I18N::translate('You can apply for an account using the link below.') . '</p>';
174
-		break;
175
-	case 3:
176
-		echo '<p>' . I18N::translate('You need to be a family member to access this website.') . ' ' . I18N::translate('You can apply for an account using the link below.') . '</p>';
177
-		break;
178
-	case 4:
179
-		echo '<p style="white-space: pre-wrap;">', Site::getPreference('WELCOME_TEXT_AUTH_MODE_' . WT_LOCALE), '</p>';
180
-		break;
181
-	}
182
-
183
-	echo '</div>';
184
-	echo '<div id="login-box">';
185
-		if ($message) {
186
-			echo '<p class="error">', $message, '</p>';
187
-		}
188
-	echo '<form id="login-form" name="login-form" method="post" action="', WT_LOGIN_URL, '">
163
+    echo '<div id="login-page">';
164
+    echo '<div id="login-text">';
165
+
166
+    echo '<p class="center"><strong>' . I18N::translate('Welcome to this genealogy website') . '</strong></p>';
167
+
168
+    switch (Site::getPreference('WELCOME_TEXT_AUTH_MODE')) {
169
+    case 1:
170
+        echo '<p>' . I18N::translate('Anyone with a user account can access this website.') . ' ' . I18N::translate('You can apply for an account using the link below.') . '</p>';
171
+        break;
172
+    case 2:
173
+        echo '<p>' . I18N::translate('You need to be an authorized user to access this website.') . ' ' . I18N::translate('You can apply for an account using the link below.') . '</p>';
174
+        break;
175
+    case 3:
176
+        echo '<p>' . I18N::translate('You need to be a family member to access this website.') . ' ' . I18N::translate('You can apply for an account using the link below.') . '</p>';
177
+        break;
178
+    case 4:
179
+        echo '<p style="white-space: pre-wrap;">', Site::getPreference('WELCOME_TEXT_AUTH_MODE_' . WT_LOCALE), '</p>';
180
+        break;
181
+    }
182
+
183
+    echo '</div>';
184
+    echo '<div id="login-box">';
185
+        if ($message) {
186
+            echo '<p class="error">', $message, '</p>';
187
+        }
188
+    echo '<form id="login-form" name="login-form" method="post" action="', WT_LOGIN_URL, '">
189 189
 		<input type="hidden" name="action" value="login">
190 190
 		<input type="hidden" name="url" value="', Filter::escapeHtml($url), '">';
191
-		echo '<div>
191
+        echo '<div>
192 192
 			<label for="username">', I18N::translate('Username'),
193
-			'<input type="text" id="username" name="username" value="', Filter::escapeHtml($username), '" class="formField" autofocus>
193
+            '<input type="text" id="username" name="username" value="', Filter::escapeHtml($username), '" class="formField" autofocus>
194 194
 			</label>
195 195
 		</div>
196 196
 		<div>
197 197
 			<label for="password">', I18N::translate('Password'),
198
-				'<input type="password" id="password" name="password" class="formField">
198
+                '<input type="password" id="password" name="password" class="formField">
199 199
 			</label>
200 200
 		</div>
201 201
 		<div>
202 202
 			<input type="submit" value="', /* I18N: A button label. */ I18N::translate('sign in'), '">
203 203
 		</div>
204 204
 		';
205
-		// Emails are sent from a TREE, not from a SITE. Therefore if there is no
206
-		// tree available (initial setup or all trees private), then we can't send email.
207
-		if ($WT_TREE) {
208
-			echo '
205
+        // Emails are sent from a TREE, not from a SITE. Therefore if there is no
206
+        // tree available (initial setup or all trees private), then we can't send email.
207
+        if ($WT_TREE) {
208
+            echo '
209 209
 			<div>
210 210
 				<a href="#" id="passwd_click">', I18N::translate('Forgot password?'), '</a>
211 211
 			</div>';
212
-			if (Site::getPreference('USE_REGISTRATION_MODULE')) {
213
-				echo '<div><a href="' . WT_LOGIN_URL . '?action=register">', I18N::translate('Request a new user account'), '</a></div>';
214
-			}
215
-		}
216
-	echo '</form>';
217
-
218
-	// hidden New Password block
219
-	echo '<div id="new_passwd">
212
+            if (Site::getPreference('USE_REGISTRATION_MODULE')) {
213
+                echo '<div><a href="' . WT_LOGIN_URL . '?action=register">', I18N::translate('Request a new user account'), '</a></div>';
214
+            }
215
+        }
216
+    echo '</form>';
217
+
218
+    // hidden New Password block
219
+    echo '<div id="new_passwd">
220 220
 		<form id="new_passwd_form" name="new_passwd_form" action="' . WT_LOGIN_URL . '" method="post">
221 221
 		<input type="hidden" name="action" value="requestpw">
222 222
 		<h4>', I18N::translate('Request a new password'), '</h4>
223 223
 		<div>
224 224
 			<label for="new_passwd_username">', I18N::translate('Username or email address'),
225
-				'<input type="text" id="new_passwd_username" name="new_passwd_username" value="">
225
+                '<input type="text" id="new_passwd_username" name="new_passwd_username" value="">
226 226
 			</label>
227 227
 		</div>
228 228
 		<div><input type="submit" value="', /* I18N: A button label. */ I18N::translate('continue'), '"></div>
229 229
 		</form>
230 230
 	</div>';
231
-	echo '</div>';
231
+    echo '</div>';
232 232
 
233
-	echo '</div>';
234
-	break;
233
+    echo '</div>';
234
+    break;
235 235
 
236 236
 case 'requestpw':
237
-	$user_name = Filter::post('new_passwd_username');
238
-	$user      = User::findByIdentifier($user_name);
239
-
240
-	if ($user) {
241
-		$passchars   = 'abcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
242
-		$user_new_pw = '';
243
-		$max         = strlen($passchars) - 1;
244
-		for ($i = 0; $i < 8; $i++) {
245
-			$index = rand(0, $max);
246
-			$user_new_pw .= $passchars{$index};
247
-		}
248
-
249
-		$user->setPassword($user_new_pw);
250
-		Log::addAuthenticationLog('Password request was sent to user: ' . $user->getUserName());
251
-
252
-		Mail::systemMessage(
253
-			$WT_TREE,
254
-			$user,
255
-			I18N::translate('Lost password request'),
256
-			I18N::translate('Hello %s…', $user->getRealNameHtml()) . Mail::EOL . Mail::EOL .
257
-			I18N::translate('A new password has been requested for your username.') . Mail::EOL . Mail::EOL .
258
-			I18N::translate('Username') . ": " . Filter::escapeHtml($user->getUserName()) . Mail::EOL .
259
-			I18N::translate('Password') . ": " . $user_new_pw . Mail::EOL . Mail::EOL .
260
-			I18N::translate('After you have signed in, select the “My account” link under the “My pages” menu and fill in the password fields to change your password.') . Mail::EOL . Mail::EOL .
261
-			'<a href="' . WT_BASE_URL . 'login.php?ged=' . $WT_TREE->getNameUrl() . '">' . WT_BASE_URL . 'login.php?ged=' . $WT_TREE->getNameUrl() . '</a>'
262
-		);
263
-
264
-		FlashMessages::addMessage(I18N::translate('A new password has been created and emailed to %s. You can change this password after you sign in.', Filter::escapeHtml($user_name)), 'success');
265
-	} else {
266
-		FlashMessages::addMessage(I18N::translate('There is no account with the username or email “%s”.', Filter::escapeHtml($user_name)), 'danger');
267
-	}
268
-	header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
269
-
270
-	return;
271
-	break;
237
+    $user_name = Filter::post('new_passwd_username');
238
+    $user      = User::findByIdentifier($user_name);
239
+
240
+    if ($user) {
241
+        $passchars   = 'abcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
242
+        $user_new_pw = '';
243
+        $max         = strlen($passchars) - 1;
244
+        for ($i = 0; $i < 8; $i++) {
245
+            $index = rand(0, $max);
246
+            $user_new_pw .= $passchars{$index};
247
+        }
248
+
249
+        $user->setPassword($user_new_pw);
250
+        Log::addAuthenticationLog('Password request was sent to user: ' . $user->getUserName());
251
+
252
+        Mail::systemMessage(
253
+            $WT_TREE,
254
+            $user,
255
+            I18N::translate('Lost password request'),
256
+            I18N::translate('Hello %s…', $user->getRealNameHtml()) . Mail::EOL . Mail::EOL .
257
+            I18N::translate('A new password has been requested for your username.') . Mail::EOL . Mail::EOL .
258
+            I18N::translate('Username') . ": " . Filter::escapeHtml($user->getUserName()) . Mail::EOL .
259
+            I18N::translate('Password') . ": " . $user_new_pw . Mail::EOL . Mail::EOL .
260
+            I18N::translate('After you have signed in, select the “My account” link under the “My pages” menu and fill in the password fields to change your password.') . Mail::EOL . Mail::EOL .
261
+            '<a href="' . WT_BASE_URL . 'login.php?ged=' . $WT_TREE->getNameUrl() . '">' . WT_BASE_URL . 'login.php?ged=' . $WT_TREE->getNameUrl() . '</a>'
262
+        );
263
+
264
+        FlashMessages::addMessage(I18N::translate('A new password has been created and emailed to %s. You can change this password after you sign in.', Filter::escapeHtml($user_name)), 'success');
265
+    } else {
266
+        FlashMessages::addMessage(I18N::translate('There is no account with the username or email “%s”.', Filter::escapeHtml($user_name)), 'danger');
267
+    }
268
+    header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
269
+
270
+    return;
271
+    break;
272 272
 
273 273
 case 'register':
274
-	if (!Site::getPreference('USE_REGISTRATION_MODULE')) {
275
-		header('Location: ' . WT_BASE_URL);
276
-
277
-		return;
278
-	}
279
-
280
-	$controller->setPageTitle(I18N::translate('Request a new user account'));
281
-
282
-	// The form parameters are mandatory, and the validation errors are shown in the client.
283
-	if (Session::get('good_to_send') && $user_name && $user_password01 && $user_password01 == $user_password02 && $user_realname && $user_email && $user_comments) {
284
-
285
-		// These validation errors cannot be shown in the client.
286
-		if (User::findByUserName($user_name)) {
287
-			FlashMessages::addMessage(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.'));
288
-		} elseif (User::findByEmail($user_email)) {
289
-			FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.'));
290
-		} elseif (preg_match('/(?!' . preg_quote(WT_BASE_URL, '/') . ')(((?:ftp|http|https):\/\/)[a-zA-Z0-9.-]+)/', $user_comments, $match)) {
291
-			FlashMessages::addMessage(
292
-				I18N::translate('You are not allowed to send messages that contain external links.') . ' ' .
293
-				I18N::translate('You should delete the “%1$s” from “%2$s” and try again.', $match[2], $match[1])
294
-			);
295
-			Log::addAuthenticationLog('Possible spam registration from "' . $user_name . '"/"' . $user_email . '" comments="' . $user_comments . '"');
296
-		} else {
297
-			// Everything looks good - create the user
298
-			$controller->pageHeader();
299
-			Log::addAuthenticationLog('User registration requested for: ' . $user_name);
300
-
301
-			$user = User::create($user_name, $user_realname, $user_email, $user_password01);
302
-			$user
303
-				->setPreference('language', WT_LOCALE)
304
-				->setPreference('verified', '0')
305
-				->setPreference('verified_by_admin', 0)
306
-				->setPreference('reg_timestamp', date('U'))
307
-				->setPreference('reg_hashcode', md5(Uuid::uuid4()))
308
-				->setPreference('contactmethod', 'messaging2')
309
-				->setPreference('comment', $user_comments)
310
-				->setPreference('visibleonline', '1')
311
-				->setPreference('auto_accept', '0')
312
-				->setPreference('canadmin', '0')
313
-				->setPreference('sessiontime', '0');
314
-
315
-			// Generate an email in the admin’s language
316
-			$webmaster = User::find($WT_TREE->getPreference('WEBMASTER_USER_ID'));
317
-			I18N::init($webmaster->getPreference('language'));
318
-
319
-			$mail1_body =
320
-				I18N::translate('Hello administrator…') . Mail::EOL . Mail::EOL .
321
-				/* I18N: %s is a server name/URL */
322
-				I18N::translate('A prospective user has registered with webtrees at %s.', WT_BASE_URL . ' ' . $WT_TREE->getTitleHtml()) . Mail::EOL . Mail::EOL .
323
-				I18N::translate('Username') . ' ' . Filter::escapeHtml($user->getUserName()) . Mail::EOL .
324
-				I18N::translate('Real name') . ' ' . $user->getRealNameHtml() . Mail::EOL .
325
-				I18N::translate('Email address') . ' ' . Filter::escapeHtml($user->getEmail()) . Mail::EOL .
326
-				I18N::translate('Comments') . ' ' . Filter::escapeHtml($user_comments) . Mail::EOL . Mail::EOL .
327
-				I18N::translate('The user has been sent an email with the information necessary to confirm the access request.') . Mail::EOL . Mail::EOL .
328
-				I18N::translate('You will be informed by email when this prospective user has confirmed the request. You can then complete the process by activating the username. The new user will not be able to sign in until you activate the account.');
329
-
330
-			$mail1_subject = /* I18N: %s is a server name/URL */ I18N::translate('New registration at %s', WT_BASE_URL . ' ' . $WT_TREE->getTitle());
331
-			I18N::init(WT_LOCALE);
332
-
333
-			echo '<div id="login-register-page">';
334
-
335
-			// Generate an email in the user’s language
336
-			$mail2_body =
337
-				I18N::translate('Hello %s…', $user->getRealNameHtml()) .
338
-				Mail::EOL . Mail::EOL .
339
-				/* I18N: %1$s is the site URL and %2$s is an email address */
340
-				I18N::translate('You (or someone claiming to be you) has requested an account at %1$s using the email address %2$s.', WT_BASE_URL . ' ' . $WT_TREE->getTitleHtml(), $user->getEmail()) .
341
-				Mail::EOL . Mail::EOL .
342
-				I18N::translate('Follow this link to verify your email address.') .
343
-				Mail::EOL . Mail::EOL .
344
-				'<a href="' . WT_LOGIN_URL . '?user_name=' . Filter::escapeUrl($user->getUserName()) . '&amp;user_hashcode=' . $user->getPreference('reg_hashcode') . '&amp;action=userverify&amp;ged=' . $WT_TREE->getNameUrl() . '">' .
345
-				WT_LOGIN_URL . "?user_name=" . Filter::escapeHtml($user->getUserName()) . "&amp;user_hashcode=" . urlencode($user->getPreference('reg_hashcode')) . '&amp;action=userverify&amp;ged=' . $WT_TREE->getNameHtml() .
346
-				'</a>' . Mail::EOL . Mail::EOL .
347
-				I18N::translate('Username') . " - " . Filter::escapeHtml($user->getUserName()) . Mail::EOL .
348
-				I18N::translate('Comments') . " - " . $user->getPreference('comment') . Mail::EOL .
349
-				I18N::translate('If you didn’t request an account, you can just delete this message.') . Mail::EOL;
350
-			$mail2_subject = /* I18N: %s is a server name/URL */ I18N::translate('Your registration at %s', WT_BASE_URL);
351
-			$mail2_to      = $user->getEmail();
352
-			$mail2_from    = $WT_TREE->getPreference('WEBTREES_EMAIL');
353
-
354
-			// Send user message by email only
355
-			Mail::send(
356
-				// “From:” header
357
-				$WT_TREE,
358
-				// “To:” header
359
-				$mail2_to,
360
-				$mail2_to,
361
-				// “Reply-To:” header
362
-				$mail2_from,
363
-				$mail2_from,
364
-				// Message body
365
-				$mail2_subject,
366
-				$mail2_body
367
-			);
368
-
369
-			// Send admin message by email and/or internal messaging
370
-			Mail::send(
371
-				// “From:” header
372
-				$WT_TREE,
373
-				// “To:” header
374
-				$webmaster->getEmail(),
375
-				$webmaster->getRealName(),
376
-				// “Reply-To:” header
377
-				$user->getEmail(),
378
-				$user->getRealName(),
379
-				// Message body
380
-				$mail1_subject,
381
-				$mail1_body
382
-			);
383
-			$mail1_method = $webmaster->getPreference('contact_method');
384
-			if ($mail1_method != 'messaging3' && $mail1_method != 'mailto' && $mail1_method != 'none') {
385
-				Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")
386
-					->execute(array($user->getEmail(), WT_CLIENT_IP, $webmaster->getUserId(), $mail1_subject, Filter::unescapeHtml($mail1_body)));
387
-			}
388
-
389
-			echo '<div class="confirm"><p>', I18N::translate('Hello %s…<br>Thank you for your registration.', $user->getRealNameHtml()), '</p>';
390
-			echo '<p>', I18N::translate('We will now send a confirmation email to the address <b>%s</b>. You must verify your account request by following instructions in the confirmation email. If you do not confirm your account request within seven days, your application will be rejected automatically. You will have to apply again.<br><br>After you have followed the instructions in the confirmation email, the administrator still has to approve your request before your account can be used.<br><br>To sign in to this website, you will need to know your username and password.', $user->getEmail()), '</p>';
391
-			echo '</div>';
392
-			echo '</div>';
393
-
394
-			return;
395
-		}
396
-	}
397
-
398
-	Session::put('good_to_send', true);
399
-	$controller
400
-		->pageHeader()
401
-		->addInlineJavascript('function regex_quote(str) {return str.replace(/[\\\\.?+*()[\](){}|]/g, "\\\\$&");}');
402
-
403
-	?>
274
+    if (!Site::getPreference('USE_REGISTRATION_MODULE')) {
275
+        header('Location: ' . WT_BASE_URL);
276
+
277
+        return;
278
+    }
279
+
280
+    $controller->setPageTitle(I18N::translate('Request a new user account'));
281
+
282
+    // The form parameters are mandatory, and the validation errors are shown in the client.
283
+    if (Session::get('good_to_send') && $user_name && $user_password01 && $user_password01 == $user_password02 && $user_realname && $user_email && $user_comments) {
284
+
285
+        // These validation errors cannot be shown in the client.
286
+        if (User::findByUserName($user_name)) {
287
+            FlashMessages::addMessage(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.'));
288
+        } elseif (User::findByEmail($user_email)) {
289
+            FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.'));
290
+        } elseif (preg_match('/(?!' . preg_quote(WT_BASE_URL, '/') . ')(((?:ftp|http|https):\/\/)[a-zA-Z0-9.-]+)/', $user_comments, $match)) {
291
+            FlashMessages::addMessage(
292
+                I18N::translate('You are not allowed to send messages that contain external links.') . ' ' .
293
+                I18N::translate('You should delete the “%1$s” from “%2$s” and try again.', $match[2], $match[1])
294
+            );
295
+            Log::addAuthenticationLog('Possible spam registration from "' . $user_name . '"/"' . $user_email . '" comments="' . $user_comments . '"');
296
+        } else {
297
+            // Everything looks good - create the user
298
+            $controller->pageHeader();
299
+            Log::addAuthenticationLog('User registration requested for: ' . $user_name);
300
+
301
+            $user = User::create($user_name, $user_realname, $user_email, $user_password01);
302
+            $user
303
+                ->setPreference('language', WT_LOCALE)
304
+                ->setPreference('verified', '0')
305
+                ->setPreference('verified_by_admin', 0)
306
+                ->setPreference('reg_timestamp', date('U'))
307
+                ->setPreference('reg_hashcode', md5(Uuid::uuid4()))
308
+                ->setPreference('contactmethod', 'messaging2')
309
+                ->setPreference('comment', $user_comments)
310
+                ->setPreference('visibleonline', '1')
311
+                ->setPreference('auto_accept', '0')
312
+                ->setPreference('canadmin', '0')
313
+                ->setPreference('sessiontime', '0');
314
+
315
+            // Generate an email in the admin’s language
316
+            $webmaster = User::find($WT_TREE->getPreference('WEBMASTER_USER_ID'));
317
+            I18N::init($webmaster->getPreference('language'));
318
+
319
+            $mail1_body =
320
+                I18N::translate('Hello administrator…') . Mail::EOL . Mail::EOL .
321
+                /* I18N: %s is a server name/URL */
322
+                I18N::translate('A prospective user has registered with webtrees at %s.', WT_BASE_URL . ' ' . $WT_TREE->getTitleHtml()) . Mail::EOL . Mail::EOL .
323
+                I18N::translate('Username') . ' ' . Filter::escapeHtml($user->getUserName()) . Mail::EOL .
324
+                I18N::translate('Real name') . ' ' . $user->getRealNameHtml() . Mail::EOL .
325
+                I18N::translate('Email address') . ' ' . Filter::escapeHtml($user->getEmail()) . Mail::EOL .
326
+                I18N::translate('Comments') . ' ' . Filter::escapeHtml($user_comments) . Mail::EOL . Mail::EOL .
327
+                I18N::translate('The user has been sent an email with the information necessary to confirm the access request.') . Mail::EOL . Mail::EOL .
328
+                I18N::translate('You will be informed by email when this prospective user has confirmed the request. You can then complete the process by activating the username. The new user will not be able to sign in until you activate the account.');
329
+
330
+            $mail1_subject = /* I18N: %s is a server name/URL */ I18N::translate('New registration at %s', WT_BASE_URL . ' ' . $WT_TREE->getTitle());
331
+            I18N::init(WT_LOCALE);
332
+
333
+            echo '<div id="login-register-page">';
334
+
335
+            // Generate an email in the user’s language
336
+            $mail2_body =
337
+                I18N::translate('Hello %s…', $user->getRealNameHtml()) .
338
+                Mail::EOL . Mail::EOL .
339
+                /* I18N: %1$s is the site URL and %2$s is an email address */
340
+                I18N::translate('You (or someone claiming to be you) has requested an account at %1$s using the email address %2$s.', WT_BASE_URL . ' ' . $WT_TREE->getTitleHtml(), $user->getEmail()) .
341
+                Mail::EOL . Mail::EOL .
342
+                I18N::translate('Follow this link to verify your email address.') .
343
+                Mail::EOL . Mail::EOL .
344
+                '<a href="' . WT_LOGIN_URL . '?user_name=' . Filter::escapeUrl($user->getUserName()) . '&amp;user_hashcode=' . $user->getPreference('reg_hashcode') . '&amp;action=userverify&amp;ged=' . $WT_TREE->getNameUrl() . '">' .
345
+                WT_LOGIN_URL . "?user_name=" . Filter::escapeHtml($user->getUserName()) . "&amp;user_hashcode=" . urlencode($user->getPreference('reg_hashcode')) . '&amp;action=userverify&amp;ged=' . $WT_TREE->getNameHtml() .
346
+                '</a>' . Mail::EOL . Mail::EOL .
347
+                I18N::translate('Username') . " - " . Filter::escapeHtml($user->getUserName()) . Mail::EOL .
348
+                I18N::translate('Comments') . " - " . $user->getPreference('comment') . Mail::EOL .
349
+                I18N::translate('If you didn’t request an account, you can just delete this message.') . Mail::EOL;
350
+            $mail2_subject = /* I18N: %s is a server name/URL */ I18N::translate('Your registration at %s', WT_BASE_URL);
351
+            $mail2_to      = $user->getEmail();
352
+            $mail2_from    = $WT_TREE->getPreference('WEBTREES_EMAIL');
353
+
354
+            // Send user message by email only
355
+            Mail::send(
356
+                // “From:” header
357
+                $WT_TREE,
358
+                // “To:” header
359
+                $mail2_to,
360
+                $mail2_to,
361
+                // “Reply-To:” header
362
+                $mail2_from,
363
+                $mail2_from,
364
+                // Message body
365
+                $mail2_subject,
366
+                $mail2_body
367
+            );
368
+
369
+            // Send admin message by email and/or internal messaging
370
+            Mail::send(
371
+                // “From:” header
372
+                $WT_TREE,
373
+                // “To:” header
374
+                $webmaster->getEmail(),
375
+                $webmaster->getRealName(),
376
+                // “Reply-To:” header
377
+                $user->getEmail(),
378
+                $user->getRealName(),
379
+                // Message body
380
+                $mail1_subject,
381
+                $mail1_body
382
+            );
383
+            $mail1_method = $webmaster->getPreference('contact_method');
384
+            if ($mail1_method != 'messaging3' && $mail1_method != 'mailto' && $mail1_method != 'none') {
385
+                Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")
386
+                    ->execute(array($user->getEmail(), WT_CLIENT_IP, $webmaster->getUserId(), $mail1_subject, Filter::unescapeHtml($mail1_body)));
387
+            }
388
+
389
+            echo '<div class="confirm"><p>', I18N::translate('Hello %s…<br>Thank you for your registration.', $user->getRealNameHtml()), '</p>';
390
+            echo '<p>', I18N::translate('We will now send a confirmation email to the address <b>%s</b>. You must verify your account request by following instructions in the confirmation email. If you do not confirm your account request within seven days, your application will be rejected automatically. You will have to apply again.<br><br>After you have followed the instructions in the confirmation email, the administrator still has to approve your request before your account can be used.<br><br>To sign in to this website, you will need to know your username and password.', $user->getEmail()), '</p>';
391
+            echo '</div>';
392
+            echo '</div>';
393
+
394
+            return;
395
+        }
396
+    }
397
+
398
+    Session::put('good_to_send', true);
399
+    $controller
400
+        ->pageHeader()
401
+        ->addInlineJavascript('function regex_quote(str) {return str.replace(/[\\\\.?+*()[\](){}|]/g, "\\\\$&");}');
402
+
403
+    ?>
404 404
 	<div id="login-register-page">
405 405
 		<h2><?php echo $controller->getPageTitle(); ?></h2>
406 406
 
@@ -501,24 +501,24 @@  discard block
 block discarded – undo
501 501
 		</div>
502 502
 	</div>
503 503
 	<?php
504
-	break;
504
+    break;
505 505
 
506 506
 case 'userverify':
507
-	if (!Site::getPreference('USE_REGISTRATION_MODULE')) {
508
-		header('Location: ' . WT_BASE_URL);
507
+    if (!Site::getPreference('USE_REGISTRATION_MODULE')) {
508
+        header('Location: ' . WT_BASE_URL);
509 509
 
510
-		return;
511
-	}
510
+        return;
511
+    }
512 512
 
513
-	// Change to the new user’s language
514
-	$user = User::findByUserName($user_name);
513
+    // Change to the new user’s language
514
+    $user = User::findByUserName($user_name);
515 515
 
516
-	I18N::init($user->getPreference('language'));
516
+    I18N::init($user->getPreference('language'));
517 517
 
518
-	$controller->setPageTitle(I18N::translate('User verification'));
519
-	$controller->pageHeader();
518
+    $controller->setPageTitle(I18N::translate('User verification'));
519
+    $controller->pageHeader();
520 520
 
521
-	echo '<div id="login-register-page">
521
+    echo '<div id="login-register-page">
522 522
 		<form id="verify-form" name="verify-form" method="post" action="', WT_LOGIN_URL, '">
523 523
 			<input type="hidden" name="action" value="verify_hash">
524 524
 			<h4>', I18N::translate('User verification'), '</h4>
@@ -539,87 +539,87 @@  discard block
 block discarded – undo
539 539
 			</div>
540 540
 		</form>
541 541
 	</div>';
542
-	break;
542
+    break;
543 543
 
544 544
 case 'verify_hash':
545
-	if (!Site::getPreference('USE_REGISTRATION_MODULE')) {
546
-		header('Location: ' . WT_BASE_URL);
547
-
548
-		return;
549
-	}
550
-
551
-	// switch language to webmaster settings
552
-	$webmaster = User::find($WT_TREE->getPreference('WEBMASTER_USER_ID'));
553
-	I18N::init($webmaster->getPreference('language'));
554
-
555
-	$user          = User::findByUserName($user_name);
556
-	$edit_user_url = WT_BASE_URL . "admin_users.php?action=edit&amp;user_id=" . $user->getUserId();
557
-	$mail1_body    =
558
-		I18N::translate('Hello administrator…') .
559
-		Mail::EOL . Mail::EOL .
560
-		/* I18N: %1$s is a real-name, %2$s is a username, %3$s is an email address */ I18N::translate(
561
-			'A new user (%1$s) has requested an account (%2$s) and verified an email address (%3$s).',
562
-			$user->getRealNameHtml(),
563
-			Filter::escapeHtml($user->getUserName()),
564
-			Filter::escapeHtml($user->getEmail())
565
-		) .
566
-		Mail::EOL . Mail::EOL .
567
-		I18N::translate('You need to review the account details.') .
568
-		Mail::EOL . Mail::EOL .
569
-		'<a href="' . $edit_user_url . '">' . $edit_user_url . '</a>' .
570
-		Mail::EOL . Mail::EOL .
571
-		/* I18N: You need to: */ I18N::translate('Set the status to “approved”.') .
572
-		Mail::EOL .
573
-		/* I18N: You need to: */ I18N::translate('Set the access level for each tree.') .
574
-		Mail::EOL .
575
-		/* I18N: You need to: */ I18N::translate('Link the user account to an individual.');
576
-
577
-	$mail1_subject = /* I18N: %s is a server name/URL */ I18N::translate('New user at %s', WT_BASE_URL . ' ' . $WT_TREE->getTitle());
578
-
579
-	// Change to the new user’s language
580
-	I18N::init($user->getPreference('language'));
581
-
582
-	$controller->setPageTitle(I18N::translate('User verification'));
583
-	$controller->pageHeader();
584
-
585
-	echo '<div id="login-register-page">';
586
-	echo '<h2>' . I18N::translate('User verification') . '</h2>';
587
-	echo '<div id="user-verify">';
588
-	if ($user && $user->checkPassword($user_password) && $user->getPreference('reg_hashcode') === $user_hashcode) {
589
-		Mail::send(
590
-		// “From:” header
591
-			$WT_TREE,
592
-			// “To:” header
593
-			$webmaster->getEmail(),
594
-			$webmaster->getRealName(),
595
-			// “Reply-To:” header
596
-			$WT_TREE->getPreference('WEBTREES_EMAIL'),
597
-			$WT_TREE->getPreference('WEBTREES_EMAIL'),
598
-			// Message body
599
-			$mail1_subject,
600
-			$mail1_body
601
-		);
602
-		$mail1_method = $webmaster->getPreference('CONTACT_METHOD');
603
-		if ($mail1_method != 'messaging3' && $mail1_method != 'mailto' && $mail1_method != 'none') {
604
-			Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")
605
-				->execute(array($user_name, WT_CLIENT_IP, $webmaster->getUserId(), $mail1_subject, Filter::unescapeHtml($mail1_body)));
606
-		}
607
-
608
-		$user
609
-			->setPreference('verified', '1')
610
-			->setPreference('reg_timestamp', date('U'))
611
-			->deletePreference('reg_hashcode');
612
-
613
-		Log::addAuthenticationLog('User ' . $user_name . ' verified their email address');
614
-
615
-		echo '<p>', I18N::translate('You have confirmed your request to become a registered user.'), '</p>';
616
-		echo '<p>', I18N::translate('The administrator has been informed. As soon as they give you permission to sign in, you can sign in with your username and password.'), '</p>';
617
-	} else {
618
-		echo '<p class="warning">';
619
-		echo I18N::translate('Could not verify the information you entered. Please try again or contact the site administrator for more information.');
620
-		echo '</p>';
621
-	}
622
-	echo '</div>';
623
-	echo '</div>';
624
-	break;
545
+    if (!Site::getPreference('USE_REGISTRATION_MODULE')) {
546
+        header('Location: ' . WT_BASE_URL);
547
+
548
+        return;
549
+    }
550
+
551
+    // switch language to webmaster settings
552
+    $webmaster = User::find($WT_TREE->getPreference('WEBMASTER_USER_ID'));
553
+    I18N::init($webmaster->getPreference('language'));
554
+
555
+    $user          = User::findByUserName($user_name);
556
+    $edit_user_url = WT_BASE_URL . "admin_users.php?action=edit&amp;user_id=" . $user->getUserId();
557
+    $mail1_body    =
558
+        I18N::translate('Hello administrator…') .
559
+        Mail::EOL . Mail::EOL .
560
+        /* I18N: %1$s is a real-name, %2$s is a username, %3$s is an email address */ I18N::translate(
561
+            'A new user (%1$s) has requested an account (%2$s) and verified an email address (%3$s).',
562
+            $user->getRealNameHtml(),
563
+            Filter::escapeHtml($user->getUserName()),
564
+            Filter::escapeHtml($user->getEmail())
565
+        ) .
566
+        Mail::EOL . Mail::EOL .
567
+        I18N::translate('You need to review the account details.') .
568
+        Mail::EOL . Mail::EOL .
569
+        '<a href="' . $edit_user_url . '">' . $edit_user_url . '</a>' .
570
+        Mail::EOL . Mail::EOL .
571
+        /* I18N: You need to: */ I18N::translate('Set the status to “approved”.') .
572
+        Mail::EOL .
573
+        /* I18N: You need to: */ I18N::translate('Set the access level for each tree.') .
574
+        Mail::EOL .
575
+        /* I18N: You need to: */ I18N::translate('Link the user account to an individual.');
576
+
577
+    $mail1_subject = /* I18N: %s is a server name/URL */ I18N::translate('New user at %s', WT_BASE_URL . ' ' . $WT_TREE->getTitle());
578
+
579
+    // Change to the new user’s language
580
+    I18N::init($user->getPreference('language'));
581
+
582
+    $controller->setPageTitle(I18N::translate('User verification'));
583
+    $controller->pageHeader();
584
+
585
+    echo '<div id="login-register-page">';
586
+    echo '<h2>' . I18N::translate('User verification') . '</h2>';
587
+    echo '<div id="user-verify">';
588
+    if ($user && $user->checkPassword($user_password) && $user->getPreference('reg_hashcode') === $user_hashcode) {
589
+        Mail::send(
590
+        // “From:” header
591
+            $WT_TREE,
592
+            // “To:” header
593
+            $webmaster->getEmail(),
594
+            $webmaster->getRealName(),
595
+            // “Reply-To:” header
596
+            $WT_TREE->getPreference('WEBTREES_EMAIL'),
597
+            $WT_TREE->getPreference('WEBTREES_EMAIL'),
598
+            // Message body
599
+            $mail1_subject,
600
+            $mail1_body
601
+        );
602
+        $mail1_method = $webmaster->getPreference('CONTACT_METHOD');
603
+        if ($mail1_method != 'messaging3' && $mail1_method != 'mailto' && $mail1_method != 'none') {
604
+            Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")
605
+                ->execute(array($user_name, WT_CLIENT_IP, $webmaster->getUserId(), $mail1_subject, Filter::unescapeHtml($mail1_body)));
606
+        }
607
+
608
+        $user
609
+            ->setPreference('verified', '1')
610
+            ->setPreference('reg_timestamp', date('U'))
611
+            ->deletePreference('reg_hashcode');
612
+
613
+        Log::addAuthenticationLog('User ' . $user_name . ' verified their email address');
614
+
615
+        echo '<p>', I18N::translate('You have confirmed your request to become a registered user.'), '</p>';
616
+        echo '<p>', I18N::translate('The administrator has been informed. As soon as they give you permission to sign in, you can sign in with your username and password.'), '</p>';
617
+    } else {
618
+        echo '<p class="warning">';
619
+        echo I18N::translate('Could not verify the information you entered. Please try again or contact the site administrator for more information.');
620
+        echo '</p>';
621
+    }
622
+    echo '</div>';
623
+    echo '</div>';
624
+    break;
625 625
 }
Please login to merge, or discard this patch.
block_edit.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -30,42 +30,42 @@
 block discarded – undo
30 30
 
31 31
 $block_id = Filter::getInteger('block_id');
32 32
 $block    = Database::prepare(
33
-	"SELECT * FROM `##block` WHERE block_id=?"
33
+    "SELECT * FROM `##block` WHERE block_id=?"
34 34
 )->execute(array($block_id))->fetchOneRow();
35 35
 
36 36
 // Check access. (1) the block must exist and be enabled, (2) gedcom blocks require
37 37
 // managers, (3) user blocks require the user or an admin
38 38
 $blocks = Module::getActiveBlocks($WT_TREE);
39 39
 if (
40
-	!$block ||
41
-	!array_key_exists($block->module_name, $blocks) ||
42
-	$block->gedcom_id && !Auth::isManager(Tree::findById($block->gedcom_id)) ||
43
-	$block->user_id && $block->user_id != Auth::id() && !Auth::isAdmin()
40
+    !$block ||
41
+    !array_key_exists($block->module_name, $blocks) ||
42
+    $block->gedcom_id && !Auth::isManager(Tree::findById($block->gedcom_id)) ||
43
+    $block->user_id && $block->user_id != Auth::id() && !Auth::isAdmin()
44 44
 ) {
45
-	header('Location: ' . WT_BASE_URL);
45
+    header('Location: ' . WT_BASE_URL);
46 46
 
47
-	return;
47
+    return;
48 48
 }
49 49
 
50 50
 $block = $blocks[$block->module_name];
51 51
 
52 52
 if (Filter::post('save')) {
53
-	$ctype = Filter::post('ctype', 'user', 'gedcom');
54
-	header('Location: ' . WT_BASE_URL . 'index.php?ctype=' . $ctype . '&ged=' . $WT_TREE->getNameUrl());
55
-	$block->configureBlock($block_id);
53
+    $ctype = Filter::post('ctype', 'user', 'gedcom');
54
+    header('Location: ' . WT_BASE_URL . 'index.php?ctype=' . $ctype . '&ged=' . $WT_TREE->getNameUrl());
55
+    $block->configureBlock($block_id);
56 56
 
57
-	return;
57
+    return;
58 58
 }
59 59
 
60 60
 $ctype = Filter::get('ctype', 'user', 'gedcom');
61 61
 
62 62
 $controller = new PageController;
63 63
 $controller
64
-	->setPageTitle($block->getTitle() . ' — ' . I18N::translate('Preferences'))
65
-	->pageHeader();
64
+    ->setPageTitle($block->getTitle() . ' — ' . I18N::translate('Preferences'))
65
+    ->pageHeader();
66 66
 
67 67
 if (Module::getModuleByName('ckeditor')) {
68
-	CkeditorModule::enableEditor($controller);
68
+    CkeditorModule::enableEditor($controller);
69 69
 }
70 70
 
71 71
 ?>
Please login to merge, or discard this patch.
expand_view.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -30,51 +30,51 @@
 block discarded – undo
30 30
 header('Content-Type: text/html; charset=UTF-8');
31 31
 $individual = Individual::getInstance(Filter::get('pid', WT_REGEX_XREF), $WT_TREE);
32 32
 if (!$individual || !$individual->canShow()) {
33
-	return I18N::translate('Private');
33
+    return I18N::translate('Private');
34 34
 }
35 35
 
36 36
 $facts = $individual->getFacts();
37 37
 foreach ($individual->getSpouseFamilies() as $family) {
38
-	foreach ($family->getFacts() as $fact) {
39
-		$facts[] = $fact;
40
-	}
38
+    foreach ($family->getFacts() as $fact) {
39
+        $facts[] = $fact;
40
+    }
41 41
 }
42 42
 Functions::sortFacts($facts);
43 43
 
44 44
 foreach ($facts as $fact) {
45
-	switch ($fact->getTag()) {
46
-	case 'ADDR':
47
-	case 'ALIA':
48
-	case 'ASSO':
49
-	case 'CHAN':
50
-	case 'CHIL':
51
-	case 'EMAIL':
52
-	case 'FAMC':
53
-	case 'FAMS':
54
-	case 'HUSB':
55
-	case 'NAME':
56
-	case 'NOTE':
57
-	case 'OBJE':
58
-	case 'PHON':
59
-	case 'RESI':
60
-	case 'RESN':
61
-	case 'SEX':
62
-	case 'SOUR':
63
-	case 'SSN':
64
-	case 'SUBM':
65
-	case 'TITL':
66
-	case 'URL':
67
-	case 'WIFE':
68
-	case 'WWW':
69
-	case '_EMAIL':
70
-	case '_TODO':
71
-	case '_UID':
72
-	case '_WT_OBJE_SORT':
73
-		// Do not show these
74
-		break;
75
-	default:
76
-		// Simple version of FunctionsPrintFacts::print_fact()
77
-		echo $fact->summary();
78
-		break;
79
-	}
45
+    switch ($fact->getTag()) {
46
+    case 'ADDR':
47
+    case 'ALIA':
48
+    case 'ASSO':
49
+    case 'CHAN':
50
+    case 'CHIL':
51
+    case 'EMAIL':
52
+    case 'FAMC':
53
+    case 'FAMS':
54
+    case 'HUSB':
55
+    case 'NAME':
56
+    case 'NOTE':
57
+    case 'OBJE':
58
+    case 'PHON':
59
+    case 'RESI':
60
+    case 'RESN':
61
+    case 'SEX':
62
+    case 'SOUR':
63
+    case 'SSN':
64
+    case 'SUBM':
65
+    case 'TITL':
66
+    case 'URL':
67
+    case 'WIFE':
68
+    case 'WWW':
69
+    case '_EMAIL':
70
+    case '_TODO':
71
+    case '_UID':
72
+    case '_WT_OBJE_SORT':
73
+        // Do not show these
74
+        break;
75
+    default:
76
+        // Simple version of FunctionsPrintFacts::print_fact()
77
+        echo $fact->summary();
78
+        break;
79
+    }
80 80
 }
Please login to merge, or discard this patch.
edit_changes.php 1 patch
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 
32 32
 $controller = new SimpleController;
33 33
 $controller
34
-	->restrictAccess(Auth::isModerator($WT_TREE))
35
-	->setPageTitle(I18N::translate('Pending changes'))
36
-	->pageHeader()
37
-	->addInlineJavascript("
34
+    ->restrictAccess(Auth::isModerator($WT_TREE))
35
+    ->setPageTitle(I18N::translate('Pending changes'))
36
+    ->pageHeader()
37
+    ->addInlineJavascript("
38 38
 		function show_diff(diffurl) {
39 39
 			window.opener.location = diffurl;
40 40
 			return false;
@@ -50,203 +50,203 @@  discard block
 block discarded – undo
50 50
 
51 51
 switch ($action) {
52 52
 case 'undo':
53
-	$gedcom_id = Database::prepare("SELECT gedcom_id FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne();
54
-	$xref      = Database::prepare("SELECT xref      FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne();
55
-	// Undo a change, and subsequent changes to the same record
56
-	Database::prepare(
57
-		"UPDATE `##change`" .
58
-		" SET   status     = 'rejected'" .
59
-		" WHERE status     = 'pending'" .
60
-		" AND   gedcom_id  = ?" .
61
-		" AND   xref       = ?" .
62
-		" AND   change_id >= ?"
63
-	)->execute(array($gedcom_id, $xref, $change_id));
64
-	break;
53
+    $gedcom_id = Database::prepare("SELECT gedcom_id FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne();
54
+    $xref      = Database::prepare("SELECT xref      FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne();
55
+    // Undo a change, and subsequent changes to the same record
56
+    Database::prepare(
57
+        "UPDATE `##change`" .
58
+        " SET   status     = 'rejected'" .
59
+        " WHERE status     = 'pending'" .
60
+        " AND   gedcom_id  = ?" .
61
+        " AND   xref       = ?" .
62
+        " AND   change_id >= ?"
63
+    )->execute(array($gedcom_id, $xref, $change_id));
64
+    break;
65 65
 case 'accept':
66
-	$gedcom_id = Database::prepare("SELECT gedcom_id FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne();
67
-	$xref      = Database::prepare("SELECT xref      FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne();
68
-	// Accept a change, and all previous changes to the same record
69
-	$changes = Database::prepare(
70
-		"SELECT change_id, gedcom_id, gedcom_name, xref, old_gedcom, new_gedcom" .
71
-		" FROM  `##change` c" .
72
-		" JOIN  `##gedcom` g USING (gedcom_id)" .
73
-		" WHERE c.status   = 'pending'" .
74
-		" AND   gedcom_id  = ?" .
75
-		" AND   xref       = ?" .
76
-		" AND   change_id <= ?" .
77
-		" ORDER BY change_id"
78
-	)->execute(array($gedcom_id, $xref, $change_id))->fetchAll();
79
-	foreach ($changes as $change) {
80
-		if (empty($change->new_gedcom)) {
81
-			// delete
82
-			FunctionsImport::updateRecord($change->old_gedcom, $gedcom_id, true);
83
-		} else {
84
-			// add/update
85
-			FunctionsImport::updateRecord($change->new_gedcom, $gedcom_id, false);
86
-		}
87
-		Database::prepare("UPDATE `##change` SET status='accepted' WHERE change_id=?")->execute(array($change->change_id));
88
-		Log::addEditLog("Accepted change {$change->change_id} for {$change->xref} / {$change->gedcom_name} into database");
89
-	}
90
-	break;
66
+    $gedcom_id = Database::prepare("SELECT gedcom_id FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne();
67
+    $xref      = Database::prepare("SELECT xref      FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne();
68
+    // Accept a change, and all previous changes to the same record
69
+    $changes = Database::prepare(
70
+        "SELECT change_id, gedcom_id, gedcom_name, xref, old_gedcom, new_gedcom" .
71
+        " FROM  `##change` c" .
72
+        " JOIN  `##gedcom` g USING (gedcom_id)" .
73
+        " WHERE c.status   = 'pending'" .
74
+        " AND   gedcom_id  = ?" .
75
+        " AND   xref       = ?" .
76
+        " AND   change_id <= ?" .
77
+        " ORDER BY change_id"
78
+    )->execute(array($gedcom_id, $xref, $change_id))->fetchAll();
79
+    foreach ($changes as $change) {
80
+        if (empty($change->new_gedcom)) {
81
+            // delete
82
+            FunctionsImport::updateRecord($change->old_gedcom, $gedcom_id, true);
83
+        } else {
84
+            // add/update
85
+            FunctionsImport::updateRecord($change->new_gedcom, $gedcom_id, false);
86
+        }
87
+        Database::prepare("UPDATE `##change` SET status='accepted' WHERE change_id=?")->execute(array($change->change_id));
88
+        Log::addEditLog("Accepted change {$change->change_id} for {$change->xref} / {$change->gedcom_name} into database");
89
+    }
90
+    break;
91 91
 case 'undoall':
92
-	Database::prepare(
93
-		"UPDATE `##change`" .
94
-		" SET status='rejected'" .
95
-		" WHERE status='pending' AND gedcom_id=?"
96
-	)->execute(array($WT_TREE->getTreeId()));
97
-	break;
92
+    Database::prepare(
93
+        "UPDATE `##change`" .
94
+        " SET status='rejected'" .
95
+        " WHERE status='pending' AND gedcom_id=?"
96
+    )->execute(array($WT_TREE->getTreeId()));
97
+    break;
98 98
 case 'acceptall':
99
-	$changes = Database::prepare(
100
-		"SELECT change_id, gedcom_id, gedcom_name, xref, old_gedcom, new_gedcom" .
101
-		" FROM `##change` c" .
102
-		" JOIN `##gedcom` g USING (gedcom_id)" .
103
-		" WHERE c.status='pending' AND gedcom_id=?" .
104
-		" ORDER BY change_id"
105
-	)->execute(array($WT_TREE->getTreeId()))->fetchAll();
106
-	foreach ($changes as $change) {
107
-		if (empty($change->new_gedcom)) {
108
-			// delete
109
-			FunctionsImport::updateRecord($change->old_gedcom, $change->gedcom_id, true);
110
-		} else {
111
-			// add/update
112
-			FunctionsImport::updateRecord($change->new_gedcom, $change->gedcom_id, false);
113
-		}
114
-		Database::prepare("UPDATE `##change` SET status='accepted' WHERE change_id=?")->execute(array($change->change_id));
115
-		Log::addEditLog("Accepted change {$change->change_id} for {$change->xref} / {$change->gedcom_name} into database");
116
-	}
117
-	break;
99
+    $changes = Database::prepare(
100
+        "SELECT change_id, gedcom_id, gedcom_name, xref, old_gedcom, new_gedcom" .
101
+        " FROM `##change` c" .
102
+        " JOIN `##gedcom` g USING (gedcom_id)" .
103
+        " WHERE c.status='pending' AND gedcom_id=?" .
104
+        " ORDER BY change_id"
105
+    )->execute(array($WT_TREE->getTreeId()))->fetchAll();
106
+    foreach ($changes as $change) {
107
+        if (empty($change->new_gedcom)) {
108
+            // delete
109
+            FunctionsImport::updateRecord($change->old_gedcom, $change->gedcom_id, true);
110
+        } else {
111
+            // add/update
112
+            FunctionsImport::updateRecord($change->new_gedcom, $change->gedcom_id, false);
113
+        }
114
+        Database::prepare("UPDATE `##change` SET status='accepted' WHERE change_id=?")->execute(array($change->change_id));
115
+        Log::addEditLog("Accepted change {$change->change_id} for {$change->xref} / {$change->gedcom_name} into database");
116
+    }
117
+    break;
118 118
 }
119 119
 
120 120
 $changed_gedcoms = Database::prepare(
121
-	"SELECT g.gedcom_name" .
122
-	" FROM `##change` c" .
123
-	" JOIN `##gedcom` g USING (gedcom_id)" .
124
-	" WHERE c.status='pending'" .
125
-	" GROUP BY g.gedcom_name"
121
+    "SELECT g.gedcom_name" .
122
+    " FROM `##change` c" .
123
+    " JOIN `##gedcom` g USING (gedcom_id)" .
124
+    " WHERE c.status='pending'" .
125
+    " GROUP BY g.gedcom_name"
126 126
 )->fetchOneColumn();
127 127
 
128 128
 if ($changed_gedcoms) {
129
-	$changes = Database::prepare(
130
-		"SELECT c.*, UNIX_TIMESTAMP(c.change_time) + :offset AS change_timestamp, u.user_name, u.real_name, g.gedcom_name, new_gedcom, old_gedcom" .
131
-		" FROM `##change` c" .
132
-		" JOIN `##user`   u USING (user_id)" .
133
-		" JOIN `##gedcom` g USING (gedcom_id)" .
134
-		" WHERE c.status='pending'" .
135
-		" ORDER BY gedcom_id, c.xref, c.change_id"
136
-	)
137
-	->execute(array('offset' => WT_TIMESTAMP_OFFSET))
138
-	->fetchAll();
139
-
140
-	$output         = '<br><br><table class="list_table">';
141
-	$prev_xref      = null;
142
-	$prev_gedcom_id = null;
143
-	foreach ($changes as $change) {
144
-		$tree = Tree::findById($change->gedcom_id);
145
-		preg_match('/^0 (?:@' . WT_REGEX_XREF . '@ )?(' . WT_REGEX_TAG . ')/', $change->old_gedcom . $change->new_gedcom, $match);
146
-
147
-
148
-		switch ($match[1]) {
149
-		case 'INDI':
150
-			$record = new Individual($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
151
-			break;
152
-		case 'FAM':
153
-			$record = new Family($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
154
-			break;
155
-		case 'SOUR':
156
-			$record = new Source($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
157
-			break;
158
-		case 'REPO':
159
-			$record = new Repository($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
160
-			break;
161
-		case 'OBJE':
162
-			$record = new Media($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
163
-			break;
164
-		case 'NOTE':
165
-			$record = new Note($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
166
-			break;
167
-		default:
168
-			$record = new GedcomRecord($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
169
-			break;
170
-		}
171
-		if ($change->xref != $prev_xref || $change->gedcom_id != $prev_gedcom_id) {
172
-			if ($prev_xref) {
173
-				$output .= '</table></td></tr>';
174
-			}
175
-			$prev_xref      = $change->xref;
176
-			$prev_gedcom_id = $change->gedcom_id;
177
-			$output .= '<tr><td class="list_value">';
178
-			$output .= '<b><a href="#" onclick="return show_diff(\'' . $record->getHtmlUrl() . '\');"> ' . $record->getFullName() . '</a></b>';
179
-			$output .= '<div class="indent">';
180
-			$output .= '<table class="list_table"><tr>';
181
-			$output .= '<td class="list_label">' . I18N::translate('Accept') . '</td>';
182
-			$output .= '<td class="list_label">' . I18N::translate('Changes') . '</td>';
183
-			$output .= '<td class="list_label">' . I18N::translate('User') . '</td>';
184
-			$output .= '<td class="list_label">' . I18N::translate('Date') . '</td>';
185
-			$output .= '<td class="list_label">' . I18N::translate('Family tree') . '</td>';
186
-			$output .= '<td class="list_label">' . I18N::translate('Reject') . '</td>';
187
-			$output .= '</tr>';
188
-		}
189
-		$output .= '<td class="list_value"><a href="edit_changes.php?action=accept&amp;change_id=' . $change->change_id . '">' . I18N::translate('Accept') . '</a></td>';
190
-		$output .= '<td class="list_value">';
191
-		foreach ($record->getFacts() as $fact) {
192
-			if ($fact->getTag() != 'CHAN') {
193
-				if ($fact->isPendingAddition()) {
194
-					$output .= '<div class="new" title="' . strip_tags($fact->summary()) . '">' . $fact->getLabel() . '</div>';
195
-				} elseif ($fact->isPendingDeletion()) {
196
-					$output .= '<div class="old" title="' . strip_tags($fact->summary()) . '">' . $fact->getLabel() . '</div>';
197
-				}
198
-			}
199
-		}
200
-		echo '</td>';
201
-		$output .= '<td class="list_value"><a href="#" onclick="return reply(\'' . $change->user_name . '\', \'' . I18N::translate('Moderate pending changes') . '\')" title="' . I18N::translate('Send a message') . '">';
202
-		$output .= Filter::escapeHtml($change->real_name);
203
-		$output .= ' - ' . Filter::escapeHtml($change->user_name) . '</a></td>';
204
-		$output .= '<td class="list_value">' . FunctionsDate::formatTimestamp($change->change_timestamp) . '</td>';
205
-		$output .= '<td class="list_value">' . $change->gedcom_name . '</td>';
206
-		$output .= '<td class="list_value"><a href="edit_changes.php?action=undo&amp;change_id=' . $change->change_id . '">' . I18N::translate('Reject') . '</a></td>';
207
-		$output .= '</tr>';
208
-	}
209
-	$output .= '</table></td></tr></td></tr></table>';
210
-
211
-	//-- Now for the global Action bar:
212
-	$output2 = '<br><table class="list_table">';
213
-	// Row 1 column 1: title "Accept all"
214
-	$output2 .= '<tr><td class="list_label">' . I18N::translate('Accept all changes') . '</td>';
215
-	// Row 1 column 2: title "Undo all"
216
-	$output2 .= '<td class="list_label">' . I18N::translate('Reject all changes') . '</td></tr>';
217
-
218
-	// Row 2 column 1: action "Accept all"
219
-	$output2 .= '<tr><td class="list_value">';
220
-	$count = 0;
221
-	foreach ($changed_gedcoms as $gedcom_name) {
222
-		if ($count != 0) {
223
-			$output2 .= '<br>';
224
-		}
225
-		$output2 .= $gedcom_name . ' — ' . '<a href="edit_changes.php?action=acceptall&amp;ged=' . rawurlencode($gedcom_name) . '">' . I18N::translate('Accept all changes') . '</a>';
226
-		$count++;
227
-	}
228
-	$output2 .= '</td>';
229
-	// Row 2 column 2: action "Undo all"
230
-	$output2 .= '<td class="list_value">';
231
-	$count = 0;
232
-	foreach ($changed_gedcoms as $gedcom_name) {
233
-		if ($count != 0) {
234
-			$output2 .= '<br>';
235
-		}
236
-		$output2 .= $gedcom_name . ' — ' . '<a href="edit_changes.php?action=undoall&amp;ged=' . rawurlencode($gedcom_name) . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to reject all the changes to this family tree?') . '\');">' . I18N::translate('Reject all changes') . '</a>';
237
-		$count++;
238
-	}
239
-	$output2 .= '</td></tr></table>';
240
-
241
-	echo
242
-		$output2, $output, $output2,
243
-		'<br><br><br><br>',
244
-		'<p id="save-cancel">',
245
-		'<input type="button" class="cancel" value="', I18N::translate('close'), '" onclick="closePopupAndReloadParent();">',
246
-		'</p>';
129
+    $changes = Database::prepare(
130
+        "SELECT c.*, UNIX_TIMESTAMP(c.change_time) + :offset AS change_timestamp, u.user_name, u.real_name, g.gedcom_name, new_gedcom, old_gedcom" .
131
+        " FROM `##change` c" .
132
+        " JOIN `##user`   u USING (user_id)" .
133
+        " JOIN `##gedcom` g USING (gedcom_id)" .
134
+        " WHERE c.status='pending'" .
135
+        " ORDER BY gedcom_id, c.xref, c.change_id"
136
+    )
137
+    ->execute(array('offset' => WT_TIMESTAMP_OFFSET))
138
+    ->fetchAll();
139
+
140
+    $output         = '<br><br><table class="list_table">';
141
+    $prev_xref      = null;
142
+    $prev_gedcom_id = null;
143
+    foreach ($changes as $change) {
144
+        $tree = Tree::findById($change->gedcom_id);
145
+        preg_match('/^0 (?:@' . WT_REGEX_XREF . '@ )?(' . WT_REGEX_TAG . ')/', $change->old_gedcom . $change->new_gedcom, $match);
146
+
147
+
148
+        switch ($match[1]) {
149
+        case 'INDI':
150
+            $record = new Individual($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
151
+            break;
152
+        case 'FAM':
153
+            $record = new Family($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
154
+            break;
155
+        case 'SOUR':
156
+            $record = new Source($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
157
+            break;
158
+        case 'REPO':
159
+            $record = new Repository($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
160
+            break;
161
+        case 'OBJE':
162
+            $record = new Media($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
163
+            break;
164
+        case 'NOTE':
165
+            $record = new Note($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
166
+            break;
167
+        default:
168
+            $record = new GedcomRecord($change->xref, $change->old_gedcom, $change->new_gedcom, $tree);
169
+            break;
170
+        }
171
+        if ($change->xref != $prev_xref || $change->gedcom_id != $prev_gedcom_id) {
172
+            if ($prev_xref) {
173
+                $output .= '</table></td></tr>';
174
+            }
175
+            $prev_xref      = $change->xref;
176
+            $prev_gedcom_id = $change->gedcom_id;
177
+            $output .= '<tr><td class="list_value">';
178
+            $output .= '<b><a href="#" onclick="return show_diff(\'' . $record->getHtmlUrl() . '\');"> ' . $record->getFullName() . '</a></b>';
179
+            $output .= '<div class="indent">';
180
+            $output .= '<table class="list_table"><tr>';
181
+            $output .= '<td class="list_label">' . I18N::translate('Accept') . '</td>';
182
+            $output .= '<td class="list_label">' . I18N::translate('Changes') . '</td>';
183
+            $output .= '<td class="list_label">' . I18N::translate('User') . '</td>';
184
+            $output .= '<td class="list_label">' . I18N::translate('Date') . '</td>';
185
+            $output .= '<td class="list_label">' . I18N::translate('Family tree') . '</td>';
186
+            $output .= '<td class="list_label">' . I18N::translate('Reject') . '</td>';
187
+            $output .= '</tr>';
188
+        }
189
+        $output .= '<td class="list_value"><a href="edit_changes.php?action=accept&amp;change_id=' . $change->change_id . '">' . I18N::translate('Accept') . '</a></td>';
190
+        $output .= '<td class="list_value">';
191
+        foreach ($record->getFacts() as $fact) {
192
+            if ($fact->getTag() != 'CHAN') {
193
+                if ($fact->isPendingAddition()) {
194
+                    $output .= '<div class="new" title="' . strip_tags($fact->summary()) . '">' . $fact->getLabel() . '</div>';
195
+                } elseif ($fact->isPendingDeletion()) {
196
+                    $output .= '<div class="old" title="' . strip_tags($fact->summary()) . '">' . $fact->getLabel() . '</div>';
197
+                }
198
+            }
199
+        }
200
+        echo '</td>';
201
+        $output .= '<td class="list_value"><a href="#" onclick="return reply(\'' . $change->user_name . '\', \'' . I18N::translate('Moderate pending changes') . '\')" title="' . I18N::translate('Send a message') . '">';
202
+        $output .= Filter::escapeHtml($change->real_name);
203
+        $output .= ' - ' . Filter::escapeHtml($change->user_name) . '</a></td>';
204
+        $output .= '<td class="list_value">' . FunctionsDate::formatTimestamp($change->change_timestamp) . '</td>';
205
+        $output .= '<td class="list_value">' . $change->gedcom_name . '</td>';
206
+        $output .= '<td class="list_value"><a href="edit_changes.php?action=undo&amp;change_id=' . $change->change_id . '">' . I18N::translate('Reject') . '</a></td>';
207
+        $output .= '</tr>';
208
+    }
209
+    $output .= '</table></td></tr></td></tr></table>';
210
+
211
+    //-- Now for the global Action bar:
212
+    $output2 = '<br><table class="list_table">';
213
+    // Row 1 column 1: title "Accept all"
214
+    $output2 .= '<tr><td class="list_label">' . I18N::translate('Accept all changes') . '</td>';
215
+    // Row 1 column 2: title "Undo all"
216
+    $output2 .= '<td class="list_label">' . I18N::translate('Reject all changes') . '</td></tr>';
217
+
218
+    // Row 2 column 1: action "Accept all"
219
+    $output2 .= '<tr><td class="list_value">';
220
+    $count = 0;
221
+    foreach ($changed_gedcoms as $gedcom_name) {
222
+        if ($count != 0) {
223
+            $output2 .= '<br>';
224
+        }
225
+        $output2 .= $gedcom_name . ' — ' . '<a href="edit_changes.php?action=acceptall&amp;ged=' . rawurlencode($gedcom_name) . '">' . I18N::translate('Accept all changes') . '</a>';
226
+        $count++;
227
+    }
228
+    $output2 .= '</td>';
229
+    // Row 2 column 2: action "Undo all"
230
+    $output2 .= '<td class="list_value">';
231
+    $count = 0;
232
+    foreach ($changed_gedcoms as $gedcom_name) {
233
+        if ($count != 0) {
234
+            $output2 .= '<br>';
235
+        }
236
+        $output2 .= $gedcom_name . ' — ' . '<a href="edit_changes.php?action=undoall&amp;ged=' . rawurlencode($gedcom_name) . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to reject all the changes to this family tree?') . '\');">' . I18N::translate('Reject all changes') . '</a>';
237
+        $count++;
238
+    }
239
+    $output2 .= '</td></tr></table>';
240
+
241
+    echo
242
+        $output2, $output, $output2,
243
+        '<br><br><br><br>',
244
+        '<p id="save-cancel">',
245
+        '<input type="button" class="cancel" value="', I18N::translate('close'), '" onclick="closePopupAndReloadParent();">',
246
+        '</p>';
247 247
 } else {
248
-	// No pending changes - refresh the parent window and close this one
249
-	$controller->addInlineJavascript('closePopupAndReloadParent();');
248
+    // No pending changes - refresh the parent window and close this one
249
+    $controller->addInlineJavascript('closePopupAndReloadParent();');
250 250
 }
251 251
 
252 252
 echo '</div>';
Please login to merge, or discard this patch.
admin_site_logs.php 1 patch
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 
32 32
 $controller = new PageController;
33 33
 $controller
34
-	->restrictAccess(Auth::isManager($WT_TREE))
35
-	->setPageTitle(I18N::translate('Website logs'));
34
+    ->restrictAccess(Auth::isManager($WT_TREE))
35
+    ->setPageTitle(I18N::translate('Website logs'));
36 36
 
37 37
 $earliest = Database::prepare("SELECT IFNULL(DATE(MIN(log_time)), CURDATE()) FROM `##log`")->execute(array())->fetchOne();
38 38
 $latest   = Database::prepare("SELECT IFNULL(DATE(MAX(log_time)), CURDATE()) FROM `##log`")->execute(array())->fetchOne();
@@ -49,148 +49,148 @@  discard block
 block discarded – undo
49 49
 $search = isset($search['value']) ? $search['value'] : null;
50 50
 
51 51
 if (Auth::isAdmin()) {
52
-	// Administrators can see all logs
53
-	$gedc = Filter::get('gedc');
52
+    // Administrators can see all logs
53
+    $gedc = Filter::get('gedc');
54 54
 } else {
55
-	// Managers can only see logs relating to this gedcom
56
-	$gedc = $WT_TREE->getName();
55
+    // Managers can only see logs relating to this gedcom
56
+    $gedc = $WT_TREE->getName();
57 57
 }
58 58
 
59 59
 $sql_select =
60
-	"SELECT SQL_CALC_FOUND_ROWS log_id, log_time, log_type, log_message, ip_address, IFNULL(user_name, '<none>') AS user_name, IFNULL(gedcom_name, '<none>') AS gedcom_name" .
61
-	" FROM `##log`" .
62
-	" LEFT JOIN `##user` USING (user_id)" . // user may be deleted
63
-	" LEFT JOIN `##gedcom` USING (gedcom_id)"; // gedcom may be deleted
60
+    "SELECT SQL_CALC_FOUND_ROWS log_id, log_time, log_type, log_message, ip_address, IFNULL(user_name, '<none>') AS user_name, IFNULL(gedcom_name, '<none>') AS gedcom_name" .
61
+    " FROM `##log`" .
62
+    " LEFT JOIN `##user` USING (user_id)" . // user may be deleted
63
+    " LEFT JOIN `##gedcom` USING (gedcom_id)"; // gedcom may be deleted
64 64
 
65 65
 $where = " WHERE 1";
66 66
 $args  = array();
67 67
 if ($search) {
68
-	$where .= " AND log_message LIKE CONCAT('%', :search, '%')";
69
-	$args['search'] = $search;
68
+    $where .= " AND log_message LIKE CONCAT('%', :search, '%')";
69
+    $args['search'] = $search;
70 70
 }
71 71
 if ($from) {
72
-	$where .= " AND log_time >= :from";
73
-	$args['from'] = $from;
72
+    $where .= " AND log_time >= :from";
73
+    $args['from'] = $from;
74 74
 }
75 75
 if ($to) {
76
-	$where .= " AND log_time < TIMESTAMPADD(DAY, 1 , :to)"; // before end of the day
77
-	$args['to'] = $to;
76
+    $where .= " AND log_time < TIMESTAMPADD(DAY, 1 , :to)"; // before end of the day
77
+    $args['to'] = $to;
78 78
 }
79 79
 if ($type) {
80
-	$where .= " AND log_type = :type";
81
-	$args['type'] = $type;
80
+    $where .= " AND log_type = :type";
81
+    $args['type'] = $type;
82 82
 }
83 83
 if ($text) {
84
-	$where .= " AND log_message LIKE CONCAT('%', :text, '%')";
85
-	$args['text'] = $text;
84
+    $where .= " AND log_message LIKE CONCAT('%', :text, '%')";
85
+    $args['text'] = $text;
86 86
 }
87 87
 if ($ip) {
88
-	$where .= " AND ip_address LIKE CONCAT('%', :ip, '%')";
89
-	$args['ip'] = $ip;
88
+    $where .= " AND ip_address LIKE CONCAT('%', :ip, '%')";
89
+    $args['ip'] = $ip;
90 90
 }
91 91
 if ($user) {
92
-	$where .= " AND user_name LIKE CONCAT('%', :user, '%')";
93
-	$args['user'] = $user;
92
+    $where .= " AND user_name LIKE CONCAT('%', :user, '%')";
93
+    $args['user'] = $user;
94 94
 }
95 95
 if ($gedc) {
96
-	$where .= " AND gedcom_name LIKE CONCAT('%', :gedc, '%')";
97
-	$args['gedc'] = $gedc;
96
+    $where .= " AND gedcom_name LIKE CONCAT('%', :gedc, '%')";
97
+    $args['gedc'] = $gedc;
98 98
 }
99 99
 
100 100
 switch ($action) {
101 101
 case 'delete':
102
-	$sql_delete =
103
-		"DELETE `##log` FROM `##log`" .
104
-		" LEFT JOIN `##user` USING (user_id)" . // user may be deleted
105
-		" LEFT JOIN `##gedcom` USING (gedcom_id)"; // gedcom may be deleted
102
+    $sql_delete =
103
+        "DELETE `##log` FROM `##log`" .
104
+        " LEFT JOIN `##user` USING (user_id)" . // user may be deleted
105
+        " LEFT JOIN `##gedcom` USING (gedcom_id)"; // gedcom may be deleted
106 106
 
107
-	Database::prepare($sql_delete . $where)->execute($args);
108
-	break;
107
+    Database::prepare($sql_delete . $where)->execute($args);
108
+    break;
109 109
 
110 110
 case 'export':
111
-	header('Content-Type: text/csv');
112
-	header('Content-Disposition: attachment; filename="webtrees-logs.csv"');
113
-	$rows = Database::prepare($sql_select . $where . ' ORDER BY log_id')->execute($args)->fetchAll();
114
-	foreach ($rows as $row) {
115
-		echo
116
-			'"', $row->log_time, '",',
117
-			'"', $row->log_type, '",',
118
-			'"', str_replace('"', '""', $row->log_message), '",',
119
-			'"', $row->ip_address, '",',
120
-			'"', str_replace('"', '""', $row->user_name), '",',
121
-			'"', str_replace('"', '""', $row->gedcom_name), '"',
122
-			"\n";
123
-	}
124
-
125
-	return;
111
+    header('Content-Type: text/csv');
112
+    header('Content-Disposition: attachment; filename="webtrees-logs.csv"');
113
+    $rows = Database::prepare($sql_select . $where . ' ORDER BY log_id')->execute($args)->fetchAll();
114
+    foreach ($rows as $row) {
115
+        echo
116
+            '"', $row->log_time, '",',
117
+            '"', $row->log_type, '",',
118
+            '"', str_replace('"', '""', $row->log_message), '",',
119
+            '"', $row->ip_address, '",',
120
+            '"', str_replace('"', '""', $row->user_name), '",',
121
+            '"', str_replace('"', '""', $row->gedcom_name), '"',
122
+            "\n";
123
+    }
124
+
125
+    return;
126 126
 case 'load_json':
127
-	$start  = Filter::getInteger('start');
128
-	$length = Filter::getInteger('length');
129
-	$order  = Filter::getArray('order');
130
-
131
-	if ($order) {
132
-		$order_by = " ORDER BY ";
133
-		foreach ($order as $key => $value) {
134
-			if ($key > 0) {
135
-				$order_by .= ',';
136
-			}
137
-			// Datatables numbers columns 0, 1, 2
138
-			// MySQL numbers columns 1, 2, 3
139
-			switch ($value['dir']) {
140
-			case 'asc':
141
-				$order_by .= (1 + $value['column']) . " ASC ";
142
-				break;
143
-			case 'desc':
144
-				$order_by .= (1 + $value['column']) . " DESC ";
145
-				break;
146
-			}
147
-		}
148
-	} else {
149
-		$order_by = " ORDER BY 1 ASC";
150
-	}
151
-
152
-	if ($length) {
153
-		Auth::user()->setPreference('admin_site_log_page_size', $length);
154
-		$limit          = " LIMIT :limit OFFSET :offset";
155
-		$args['limit']  = $length;
156
-		$args['offset'] = $start;
157
-	} else {
158
-		$limit = "";
159
-	}
160
-
161
-	// This becomes a JSON list, not array, so need to fetch with numeric keys.
162
-	$data = Database::prepare($sql_select . $where . $order_by . $limit)->execute($args)->fetchAll(PDO::FETCH_NUM);
163
-	foreach ($data as &$datum) {
164
-		$datum[2] = Filter::escapeHtml($datum[2]);
165
-		$datum[3] = '<span dir="auto">' . Filter::escapeHtml($datum[3]) . '</span>';
166
-		$datum[4] = '<span dir="auto">' . Filter::escapeHtml($datum[4]) . '</span>';
167
-		$datum[5] = '<span dir="auto">' . Filter::escapeHtml($datum[5]) . '</span>';
168
-		$datum[6] = '<span dir="auto">' . Filter::escapeHtml($datum[6]) . '</span>';
169
-	}
170
-
171
-	// Total filtered/unfiltered rows
172
-	$recordsFiltered = (int) Database::prepare("SELECT FOUND_ROWS()")->fetchOne();
173
-	$recordsTotal    = (int) Database::prepare("SELECT COUNT(*) FROM `##log`")->fetchOne();
174
-
175
-	header('Content-type: application/json');
176
-	// See http://www.datatables.net/usage/server-side
177
-	echo json_encode(array(
178
-		'draw'            => Filter::getInteger('draw'),
179
-		'recordsTotal'    => $recordsTotal,
180
-		'recordsFiltered' => $recordsFiltered,
181
-		'data'            => $data,
182
-	));
183
-
184
-	return;
127
+    $start  = Filter::getInteger('start');
128
+    $length = Filter::getInteger('length');
129
+    $order  = Filter::getArray('order');
130
+
131
+    if ($order) {
132
+        $order_by = " ORDER BY ";
133
+        foreach ($order as $key => $value) {
134
+            if ($key > 0) {
135
+                $order_by .= ',';
136
+            }
137
+            // Datatables numbers columns 0, 1, 2
138
+            // MySQL numbers columns 1, 2, 3
139
+            switch ($value['dir']) {
140
+            case 'asc':
141
+                $order_by .= (1 + $value['column']) . " ASC ";
142
+                break;
143
+            case 'desc':
144
+                $order_by .= (1 + $value['column']) . " DESC ";
145
+                break;
146
+            }
147
+        }
148
+    } else {
149
+        $order_by = " ORDER BY 1 ASC";
150
+    }
151
+
152
+    if ($length) {
153
+        Auth::user()->setPreference('admin_site_log_page_size', $length);
154
+        $limit          = " LIMIT :limit OFFSET :offset";
155
+        $args['limit']  = $length;
156
+        $args['offset'] = $start;
157
+    } else {
158
+        $limit = "";
159
+    }
160
+
161
+    // This becomes a JSON list, not array, so need to fetch with numeric keys.
162
+    $data = Database::prepare($sql_select . $where . $order_by . $limit)->execute($args)->fetchAll(PDO::FETCH_NUM);
163
+    foreach ($data as &$datum) {
164
+        $datum[2] = Filter::escapeHtml($datum[2]);
165
+        $datum[3] = '<span dir="auto">' . Filter::escapeHtml($datum[3]) . '</span>';
166
+        $datum[4] = '<span dir="auto">' . Filter::escapeHtml($datum[4]) . '</span>';
167
+        $datum[5] = '<span dir="auto">' . Filter::escapeHtml($datum[5]) . '</span>';
168
+        $datum[6] = '<span dir="auto">' . Filter::escapeHtml($datum[6]) . '</span>';
169
+    }
170
+
171
+    // Total filtered/unfiltered rows
172
+    $recordsFiltered = (int) Database::prepare("SELECT FOUND_ROWS()")->fetchOne();
173
+    $recordsTotal    = (int) Database::prepare("SELECT COUNT(*) FROM `##log`")->fetchOne();
174
+
175
+    header('Content-type: application/json');
176
+    // See http://www.datatables.net/usage/server-side
177
+    echo json_encode(array(
178
+        'draw'            => Filter::getInteger('draw'),
179
+        'recordsTotal'    => $recordsTotal,
180
+        'recordsFiltered' => $recordsFiltered,
181
+        'data'            => $data,
182
+    ));
183
+
184
+    return;
185 185
 }
186 186
 
187 187
 $controller
188
-	->pageHeader()
189
-	->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
190
-	->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
191
-	->addExternalJavascript(WT_MOMENT_JS_URL)
192
-	->addExternalJavascript(WT_BOOTSTRAP_DATETIMEPICKER_JS_URL)
193
-	->addInlineJavascript('
188
+    ->pageHeader()
189
+    ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
190
+    ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
191
+    ->addExternalJavascript(WT_MOMENT_JS_URL)
192
+    ->addExternalJavascript(WT_BOOTSTRAP_DATETIMEPICKER_JS_URL)
193
+    ->addInlineJavascript('
194 194
 		jQuery(".table-site-logs").dataTable( {
195 195
 			processing: true,
196 196
 			serverSide: true,
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
 $users_array = array();
230 230
 foreach (User::all() as $tmp_user) {
231
-	$users_array[$tmp_user->getUserName()] = $tmp_user->getUserName();
231
+    $users_array[$tmp_user->getUserName()] = $tmp_user->getUserName();
232 232
 }
233 233
 
234 234
 ?>
Please login to merge, or discard this patch.
admin_module_tabs.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -24,33 +24,33 @@  discard block
 block discarded – undo
24 24
 
25 25
 $controller = new PageController;
26 26
 $controller
27
-	->restrictAccess(Auth::isAdmin())
28
-	->setPageTitle(I18N::translate('Tabs'));
27
+    ->restrictAccess(Auth::isAdmin())
28
+    ->setPageTitle(I18N::translate('Tabs'));
29 29
 
30 30
 $action  = Filter::post('action');
31 31
 $modules = Module::getAllModulesByComponent('tab');
32 32
 
33 33
 if ($action === 'update_mods' && Filter::checkCsrf()) {
34
-	foreach ($modules as $module) {
35
-		foreach (Tree::getAll() as $tree) {
36
-			$access_level = Filter::post('access-' . $module->getName() . '-' . $tree->getTreeId(), WT_REGEX_INTEGER, $module->defaultAccessLevel());
37
-			Database::prepare(
38
-				"REPLACE INTO `##module_privacy` (module_name, gedcom_id, component, access_level) VALUES (?, ?, 'tab', ?)"
39
-			)->execute(array($module->getName(), $tree->getTreeId(), $access_level));
40
-		}
41
-		$order = Filter::post('order-' . $module->getName());
42
-		Database::prepare(
43
-			"UPDATE `##module` SET tab_order=? WHERE module_name=?"
44
-		)->execute(array($order, $module->getName()));
45
-	}
34
+    foreach ($modules as $module) {
35
+        foreach (Tree::getAll() as $tree) {
36
+            $access_level = Filter::post('access-' . $module->getName() . '-' . $tree->getTreeId(), WT_REGEX_INTEGER, $module->defaultAccessLevel());
37
+            Database::prepare(
38
+                "REPLACE INTO `##module_privacy` (module_name, gedcom_id, component, access_level) VALUES (?, ?, 'tab', ?)"
39
+            )->execute(array($module->getName(), $tree->getTreeId(), $access_level));
40
+        }
41
+        $order = Filter::post('order-' . $module->getName());
42
+        Database::prepare(
43
+            "UPDATE `##module` SET tab_order=? WHERE module_name=?"
44
+        )->execute(array($order, $module->getName()));
45
+    }
46 46
 
47
-	header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
47
+    header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
48 48
 
49
-	return;
49
+    return;
50 50
 }
51 51
 
52 52
 $controller
53
-	->addInlineJavascript('
53
+    ->addInlineJavascript('
54 54
 		jQuery("#module_table").sortable({
55 55
 			items: ".sortme",
56 56
 			forceHelperSize: true,
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			}
68 68
 		});
69 69
 	')
70
-	->pageHeader();
70
+    ->pageHeader();
71 71
 
72 72
 ?>
73 73
 <ol class="breadcrumb small">
Please login to merge, or discard this patch.
mediaviewer.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -34,34 +34,34 @@  discard block
 block discarded – undo
34 34
 $controller = new MediaController($record);
35 35
 
36 36
 if ($controller->record && $controller->record->canShow()) {
37
-	if ($controller->record->isPendingDeletion()) {
38
-		if (Auth::isModerator($controller->record->getTree())) {
39
-			FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate(
40
-				'This media object has been deleted. You should review the deletion and then %1$s or %2$s it.',
41
-				'<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>',
42
-				'<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>'
43
-			) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
44
-		} elseif (Auth::isEditor($controller->record->getTree())) {
45
-			FlashMessages::addMessage(I18N::translate('This media object has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
46
-		}
47
-	} elseif ($controller->record->isPendingAddtion()) {
48
-		if (Auth::isModerator($controller->record->getTree())) {
49
-			FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate(
50
-				'This media object has been edited. You should review the changes and then %1$s or %2$s them.',
51
-				'<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>',
52
-				'<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>'
53
-			) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
54
-		} elseif (Auth::isEditor($controller->record->getTree())) {
55
-			FlashMessages::addMessage(I18N::translate('This media object has been edited. The changes need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
56
-		}
57
-	}
58
-	$controller->pageHeader();
37
+    if ($controller->record->isPendingDeletion()) {
38
+        if (Auth::isModerator($controller->record->getTree())) {
39
+            FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate(
40
+                'This media object has been deleted. You should review the deletion and then %1$s or %2$s it.',
41
+                '<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>',
42
+                '<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>'
43
+            ) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
44
+        } elseif (Auth::isEditor($controller->record->getTree())) {
45
+            FlashMessages::addMessage(I18N::translate('This media object has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
46
+        }
47
+    } elseif ($controller->record->isPendingAddtion()) {
48
+        if (Auth::isModerator($controller->record->getTree())) {
49
+            FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate(
50
+                'This media object has been edited. You should review the changes and then %1$s or %2$s them.',
51
+                '<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>',
52
+                '<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>'
53
+            ) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
54
+        } elseif (Auth::isEditor($controller->record->getTree())) {
55
+            FlashMessages::addMessage(I18N::translate('This media object has been edited. The changes need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
56
+        }
57
+    }
58
+    $controller->pageHeader();
59 59
 } else {
60
-	FlashMessages::addMessage(I18N::translate('This media object does not exist or you do not have permission to view it.'), 'danger');
61
-	http_response_code(404);
62
-	$controller->pageHeader();
60
+    FlashMessages::addMessage(I18N::translate('This media object does not exist or you do not have permission to view it.'), 'danger');
61
+    http_response_code(404);
62
+    $controller->pageHeader();
63 63
 
64
-	return;
64
+    return;
65 65
 }
66 66
 
67 67
 $controller->addInlineJavascript('
@@ -132,29 +132,29 @@  discard block
 block discarded – undo
132 132
 			<tr>
133 133
 				<td style="text-align:center; width:150px;">
134 134
 				<?php
135
-					// When we have a pending edit, $controller->record shows the *old* data.
136
-					// As a temporary kludge, fetch a "normal" version of the record - which includes pending changes
137
-					// Perhaps check both, and use RED/BLUE boxes.
138
-					$tmp = Media::getInstance($controller->record->getXref(), $WT_TREE);
139
-					echo $tmp->displayImage();
140
-					if (!$tmp->isExternal()) {
141
-						if ($tmp->fileExists('main')) {
142
-							if ($WT_TREE->getPreference('SHOW_MEDIA_DOWNLOAD') >= Auth::accessLevel($WT_TREE)) {
143
-								echo '<p><a href="' . $tmp->getHtmlUrlDirect('main', true) . '">' . I18N::translate('Download file') . '</a></p>';
144
-							}
145
-						} else {
146
-							echo '<p class="ui-state-error">' . I18N::translate('The file “%s” does not exist.', $tmp->getFilename()) . '</p>';
147
-						}
148
-					}
149
-				?>
135
+                    // When we have a pending edit, $controller->record shows the *old* data.
136
+                    // As a temporary kludge, fetch a "normal" version of the record - which includes pending changes
137
+                    // Perhaps check both, and use RED/BLUE boxes.
138
+                    $tmp = Media::getInstance($controller->record->getXref(), $WT_TREE);
139
+                    echo $tmp->displayImage();
140
+                    if (!$tmp->isExternal()) {
141
+                        if ($tmp->fileExists('main')) {
142
+                            if ($WT_TREE->getPreference('SHOW_MEDIA_DOWNLOAD') >= Auth::accessLevel($WT_TREE)) {
143
+                                echo '<p><a href="' . $tmp->getHtmlUrlDirect('main', true) . '">' . I18N::translate('Download file') . '</a></p>';
144
+                            }
145
+                        } else {
146
+                            echo '<p class="ui-state-error">' . I18N::translate('The file “%s” does not exist.', $tmp->getFilename()) . '</p>';
147
+                        }
148
+                    }
149
+                ?>
150 150
 					</td>
151 151
 					<td>
152 152
 						<table class="facts_table">
153 153
 							<?php
154
-							foreach ($facts as $fact) {
155
-								FunctionsPrintFacts::printFact($fact, $controller->record);
156
-							}
157
-							?>
154
+                            foreach ($facts as $fact) {
155
+                                FunctionsPrintFacts::printFact($fact, $controller->record);
156
+                            }
157
+                            ?>
158 158
 						</table>
159 159
 					</td>
160 160
 				</tr>
Please login to merge, or discard this patch.
site-offline.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -33,25 +33,25 @@  discard block
 block discarded – undo
33 33
 define('WT_LOCALE', I18N::init());
34 34
 
35 35
 if (file_exists(WT_DATA_DIR . 'offline.txt')) {
36
-	$offline_txt = file_get_contents(WT_DATA_DIR . 'offline.txt');
36
+    $offline_txt = file_get_contents(WT_DATA_DIR . 'offline.txt');
37 37
 } else {
38
-	// offline.txt has gone - we're back online!
39
-	header('Location: index.php');
38
+    // offline.txt has gone - we're back online!
39
+    header('Location: index.php');
40 40
 
41
-	return;
41
+    return;
42 42
 }
43 43
 
44 44
 http_response_code(503);
45 45
 header('Content-Type: text/html; charset=UTF-8');
46 46
 
47 47
 echo
48
-	'<!DOCTYPE html>',
49
-	'<html ', I18N::htmlAttributes(), '>',
50
-	'<head>',
51
-	'<meta charset="UTF-8">',
52
-	'<title>', WT_WEBTREES, '</title>',
53
-	'<meta name="robots" content="noindex,follow">',
54
-	'<style type="text/css">
48
+    '<!DOCTYPE html>',
49
+    '<html ', I18N::htmlAttributes(), '>',
50
+    '<head>',
51
+    '<meta charset="UTF-8">',
52
+    '<title>', WT_WEBTREES, '</title>',
53
+    '<meta name="robots" content="noindex,follow">',
54
+    '<style type="text/css">
55 55
 		body {color: gray; background-color: white; font: 14px tahoma, arial, helvetica, sans-serif; padding:10px; }
56 56
 		a {color: #81A9CB; font-weight: bold; text-decoration: none;}
57 57
 		a:hover {text-decoration: underline;}
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 		.content { /*margin:auto; width:800px;*/ border:1px solid gray; padding:15px; border-radius:15px;}
62 62
 		.good {color: green;}
63 63
 	</style>',
64
-	'</head><body>',
65
-	'<h1>', I18N::translate('This website is temporarily unavailable'), '</h1>',
66
-	'<div class="content"><p>';
64
+    '</head><body>',
65
+    '<h1>', I18N::translate('This website is temporarily unavailable'), '</h1>',
66
+    '<div class="content"><p>';
67 67
 
68 68
 if ($offline_txt) {
69
-	echo $offline_txt;
69
+    echo $offline_txt;
70 70
 } else {
71
-	echo I18N::translate('This website is down for maintenance. You should <a href="index.php">try again</a> in a few minutes.');
71
+    echo I18N::translate('This website is down for maintenance. You should <a href="index.php">try again</a> in a few minutes.');
72 72
 }
73 73
 echo '</p>';
74 74
 echo '</div>';
Please login to merge, or discard this patch.
admin_module_menus.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -24,33 +24,33 @@  discard block
 block discarded – undo
24 24
 
25 25
 $controller = new PageController;
26 26
 $controller
27
-	->restrictAccess(Auth::isAdmin())
28
-	->setPageTitle(I18N::translate('Menus'));
27
+    ->restrictAccess(Auth::isAdmin())
28
+    ->setPageTitle(I18N::translate('Menus'));
29 29
 
30 30
 $action  = Filter::post('action');
31 31
 $modules = Module::getAllModulesByComponent('menu');
32 32
 
33 33
 if ($action === 'update_mods' && Filter::checkCsrf()) {
34
-	foreach ($modules as $module) {
35
-		foreach (Tree::getAll() as $tree) {
36
-			$access_level = Filter::post('access-' . $module->getName() . '-' . $tree->getTreeId(), WT_REGEX_INTEGER, $module->defaultAccessLevel());
37
-			Database::prepare(
38
-				"REPLACE INTO `##module_privacy` (module_name, gedcom_id, component, access_level) VALUES (?, ?, 'menu', ?)"
39
-			)->execute(array($module->getName(), $tree->getTreeId(), $access_level));
40
-		}
41
-		$order = Filter::post('order-' . $module->getName());
42
-		Database::prepare(
43
-			"UPDATE `##module` SET menu_order = ? WHERE module_name = ?"
44
-		)->execute(array($order, $module->getName()));
45
-	}
34
+    foreach ($modules as $module) {
35
+        foreach (Tree::getAll() as $tree) {
36
+            $access_level = Filter::post('access-' . $module->getName() . '-' . $tree->getTreeId(), WT_REGEX_INTEGER, $module->defaultAccessLevel());
37
+            Database::prepare(
38
+                "REPLACE INTO `##module_privacy` (module_name, gedcom_id, component, access_level) VALUES (?, ?, 'menu', ?)"
39
+            )->execute(array($module->getName(), $tree->getTreeId(), $access_level));
40
+        }
41
+        $order = Filter::post('order-' . $module->getName());
42
+        Database::prepare(
43
+            "UPDATE `##module` SET menu_order = ? WHERE module_name = ?"
44
+        )->execute(array($order, $module->getName()));
45
+    }
46 46
 
47
-	header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
47
+    header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
48 48
 
49
-	return;
49
+    return;
50 50
 }
51 51
 
52 52
 $controller
53
-	->addInlineJavascript('
53
+    ->addInlineJavascript('
54 54
 		jQuery("#module_table").sortable({
55 55
 			items: ".sortme",
56 56
 			forceHelperSize: true,
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			}
68 68
 		});
69 69
 	')
70
-	->pageHeader();
70
+    ->pageHeader();
71 71
 
72 72
 ?>
73 73
 <ol class="breadcrumb small">
Please login to merge, or discard this patch.