Passed
Push — 1.7 ( e46e7d...c17e55 )
by Greg
14:32 queued 07:46
created
relationship.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -103,7 +103,8 @@  discard block
 block discarded – undo
103 103
                     <?php if ($ancestors_only === '1'): ?>
104 104
                         <input type="hidden" name="ancestors" value="1">
105 105
                         <?php echo I18N::translate('Find relationships via ancestors') ?>
106
-                    <?php else: ?>
106
+                    <?php else {
107
+    : ?>
107 108
                         <label>
108 109
                             <input type="radio" name="ancestors" value="0" <?php echo $ancestors == 0 ? 'checked' : '' ?>>
109 110
                             <?php echo I18N::translate('Find any relationship') ?>
@@ -113,14 +114,17 @@  discard block
 block discarded – undo
113 114
                             <input type="radio" name="ancestors" value="1" <?php echo $ancestors == 1 ? 'checked' : '' ?>>
114 115
                             <?php echo I18N::translate('Find relationships via ancestors') ?>
115 116
                         </label>
116
-                    <?php endif; ?>
117
+                    <?php endif;
118
+}
119
+?>
117 120
 
118 121
                     <hr>
119 122
 
120 123
                     <?php if ($max_recursion == 0): ?>
121 124
                         <?php echo I18N::translate('Find the closest relationships') ?>
122 125
                         <input type="hidden" name="recursion" value="0">
123
-                    <?php else: ?>
126
+                    <?php else {
127
+    : ?>
124 128
                         <label>
125 129
                             <input type="radio" name="recursion" value="0" <?php echo $recursion == 0 ? 'checked' : '' ?>>
126 130
                             <?php echo I18N::translate('Find the closest relationships') ?>
@@ -132,7 +136,9 @@  discard block
 block discarded – undo
132 136
                                 <?php echo I18N::translate('Find all possible relationships') ?>
133 137
                             <?php else: ?>
134 138
                                 <?php echo I18N::translate('Find other relationships') ?>
135
-                            <?php endif; ?>
139
+                            <?php endif;
140
+}
141
+?>
136 142
                         </label>
137 143
                     <?php endif; ?>
138 144
                 </td>
Please login to merge, or discard this patch.
admin_modules.php 1 patch
Braces   +40 added lines, -16 removed lines patch added patch discarded remove patch
@@ -176,9 +176,12 @@  discard block
 block discarded – undo
176 176
                             <a href="<?php echo $module->getConfigLink() ?>">
177 177
                                 <?php echo $module->getTitle() ?> <i class="fa fa-cogs"></i>
178 178
                             </a>
179
-                        <?php else: ?>
179
+                        <?php else {
180
+    : ?>
180 181
                             <?php echo $module->getTitle() ?>
181
-                        <?php endif; ?>
182
+                        <?php endif;
183
+}
184
+?>
182 185
                         <?php if (!in_array($module->getName(), Module::getCoreModuleNames())): ?>
183 186
                             <br>
184 187
                         <?php endif; ?>
@@ -202,23 +205,32 @@  discard block
 block discarded – undo
202 205
                     <td class="text-center text-muted hidden-xs">
203 206
                         <?php if ($module instanceof ModuleMenuInterface): ?>
204 207
                             <i class="fa fa-list-ul" title="<?php echo I18N::translate('Menu') ?>"></i>
205
-                        <?php else: ?>
208
+                        <?php else {
209
+    : ?>
206 210
                             -
207
-                        <?php endif; ?>
211
+                        <?php endif;
212
+}
213
+?>
208 214
                     </td>
209 215
                     <td class="text-center text-muted hidden-xs">
210 216
                         <?php if ($module instanceof ModuleTabInterface): ?>
211 217
                             <i class="fa fa-folder" title="<?php echo I18N::translate('Tab') ?>"></i>
212
-                        <?php else: ?>
218
+                        <?php else {
219
+    : ?>
213 220
                             -
214
-                        <?php endif; ?>
221
+                        <?php endif;
222
+}
223
+?>
215 224
                     </td>
216 225
                     <td class="text-center text-muted hidden-xs">
217 226
                         <?php if ($module instanceof ModuleSidebarInterface): ?>
218 227
                             <i class="fa fa-th-large" title="<?php echo I18N::translate('Sidebar') ?>"></i>
219
-                        <?php else: ?>
228
+                        <?php else {
229
+    : ?>
220 230
                             -
221
-                        <?php endif; ?>
231
+                        <?php endif;
232
+}
233
+?>
222 234
                     </td>
223 235
                     <td class="text-center text-muted hidden-xs">
224 236
                         <?php if ($module instanceof ModuleBlockInterface): ?>
@@ -228,30 +240,42 @@  discard block
 block discarded – undo
228 240
                             <?php if ($module->isUserBlock()): ?>
229 241
                                 <i class="fa fa-tree" title="<?php echo I18N::translate('Home page') ?>"></i>
230 242
                             <?php endif; ?>
231
-                        <?php else: ?>
243
+                        <?php else {
244
+    : ?>
232 245
                             -
233
-                        <?php endif; ?>
246
+                        <?php endif;
247
+}
248
+?>
234 249
                     </td>
235 250
                     <td class="text-center text-muted hidden-xs">
236 251
                         <?php if ($module instanceof ModuleChartInterface): ?>
237 252
                             <i class="fa fa-share-alt" title="<?php echo I18N::translate('Chart') ?>"></i>
238
-                        <?php else: ?>
253
+                        <?php else {
254
+    : ?>
239 255
                             -
240
-                        <?php endif; ?>
256
+                        <?php endif;
257
+}
258
+?>
241 259
                     </td>
242 260
                     <td class="text-center text-muted hidden-xs">
243 261
                         <?php if ($module instanceof ModuleReportInterface): ?>
244 262
                             <i class="fa fa-file" title="<?php echo I18N::translate('Report') ?>"></i>
245
-                        <?php else: ?>
263
+                        <?php else {
264
+    : ?>
246 265
                             -
247
-                        <?php endif; ?>
266
+                        <?php endif;
267
+}
268
+?>
248 269
                     </td>
249 270
                     <td class="text-center text-muted hidden">
250 271
                         <?php if ($module instanceof ModuleThemeInterface): ?>
251 272
                             <i class="fa fa-check" title="<?php echo I18N::translate('Theme') ?>"></i>
252
-                        <?php else: ?>
273
+                        <?php else {
274
+    : ?>
253 275
                             -
254
-                        <?php endif; ?>
276
+                        <?php endif;
277
+}
278
+?>
255 279
                     </td>
256 280
                 </tr>
257 281
             <?php endforeach; ?>
Please login to merge, or discard this patch.
ancestry.php 1 patch
Switch Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -129,46 +129,46 @@
 block discarded – undo
129 129
     return;
130 130
 }
131 131
 switch ($controller->chart_style) {
132
-    case 0:
133
-        // List
134
-        echo '<ul id="ancestry_chart" class="chart_common">';
135
-        $controller->printChildAscendancy($controller->root, 1, $controller->generations - 1);
136
-        echo '</ul>';
137
-        echo '<br>';
138
-        break;
139
-    case 1:
140
-        echo '<div id="ancestry_booklet">';
141
-        // Booklet
142
-        // first page : show indi facts
143
-        FunctionsPrint::printPedigreePerson($controller->root, $controller->showFull());
144
-        // process the tree
145
-        $ancestors = $controller->sosaAncestors($controller->generations - 1);
146
-        $ancestors = array_filter($ancestors); // The SOSA array includes empty placeholders
132
+        case 0:
133
+            // List
134
+            echo '<ul id="ancestry_chart" class="chart_common">';
135
+            $controller->printChildAscendancy($controller->root, 1, $controller->generations - 1);
136
+            echo '</ul>';
137
+            echo '<br>';
138
+            break;
139
+        case 1:
140
+            echo '<div id="ancestry_booklet">';
141
+            // Booklet
142
+            // first page : show indi facts
143
+            FunctionsPrint::printPedigreePerson($controller->root, $controller->showFull());
144
+            // process the tree
145
+            $ancestors = $controller->sosaAncestors($controller->generations - 1);
146
+            $ancestors = array_filter($ancestors); // The SOSA array includes empty placeholders
147 147
 
148
-        foreach ($ancestors as $sosa => $individual) {
149
-            foreach ($individual->getChildFamilies() as $family) {
150
-                FunctionsCharts::printSosaFamily($family->getXref(), $individual->getXref(), $sosa, '', '', '', $controller->show_cousins, $controller->showFull());
148
+            foreach ($ancestors as $sosa => $individual) {
149
+                foreach ($individual->getChildFamilies() as $family) {
150
+                    FunctionsCharts::printSosaFamily($family->getXref(), $individual->getXref(), $sosa, '', '', '', $controller->show_cousins, $controller->showFull());
151
+                }
151 152
             }
152
-        }
153
-        echo '</div>';
154
-        break;
155
-    case 2:
156
-        // Individual list
157
-        $ancestors = $controller->sosaAncestors($controller->generations);
158
-        $ancestors = array_filter($ancestors); // The SOSA array includes empty placeholders
159
-        echo '<div id="ancestry-list">', FunctionsPrintLists::individualTable($ancestors, 'sosa'), '</div>';
160
-        break;
161
-    case 3:
162
-        // Family list
163
-        $ancestors = $controller->sosaAncestors($controller->generations - 1);
164
-        $ancestors = array_filter($ancestors); // The SOSA array includes empty placeholders
165
-        $families  = array();
166
-        foreach ($ancestors as $individual) {
167
-            foreach ($individual->getChildFamilies() as $family) {
168
-                $families[$family->getXref()] = $family;
153
+            echo '</div>';
154
+            break;
155
+        case 2:
156
+            // Individual list
157
+            $ancestors = $controller->sosaAncestors($controller->generations);
158
+            $ancestors = array_filter($ancestors); // The SOSA array includes empty placeholders
159
+            echo '<div id="ancestry-list">', FunctionsPrintLists::individualTable($ancestors, 'sosa'), '</div>';
160
+            break;
161
+        case 3:
162
+            // Family list
163
+            $ancestors = $controller->sosaAncestors($controller->generations - 1);
164
+            $ancestors = array_filter($ancestors); // The SOSA array includes empty placeholders
165
+            $families  = array();
166
+            foreach ($ancestors as $individual) {
167
+                foreach ($individual->getChildFamilies() as $family) {
168
+                    $families[$family->getXref()] = $family;
169
+                }
169 170
             }
170
-        }
171
-        echo '<div id="ancestry-list">', FunctionsPrintLists::familyTable($families), '</div>';
172
-        break;
171
+            echo '<div id="ancestry-list">', FunctionsPrintLists::familyTable($families), '</div>';
172
+            break;
173 173
 }
174 174
 echo '</div>';
Please login to merge, or discard this patch.
action.php 1 patch
Switch Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -38,34 +38,34 @@  discard block
 block discarded – undo
38 38
 }
39 39
 
40 40
 switch (Filter::post('action')) {
41
-    case 'accept-changes':
42
-        // Accept all the pending changes for a record
43
-        $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
44
-        if ($record && Auth::isModerator($record->getTree()) && $record->canShow() && $record->canEdit()) {
45
-            if ($record->isPendingDeletion()) {
46
-                FlashMessages::addMessage(/* I18N: %s is the name of a genealogy record */
47
-                I18N::translate('“%s” has been deleted.', $record->getFullName()));
41
+        case 'accept-changes':
42
+            // Accept all the pending changes for a record
43
+            $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
44
+            if ($record && Auth::isModerator($record->getTree()) && $record->canShow() && $record->canEdit()) {
45
+                if ($record->isPendingDeletion()) {
46
+                    FlashMessages::addMessage(/* I18N: %s is the name of a genealogy record */
47
+                    I18N::translate('“%s” has been deleted.', $record->getFullName()));
48
+                } else {
49
+                    FlashMessages::addMessage(/* I18N: %s is the name of a genealogy record */
50
+                    I18N::translate('The changes to “%s” have been accepted.', $record->getFullName()));
51
+                }
52
+                FunctionsImport::acceptAllChanges($record->getXref(), $record->getTree()->getTreeId());
48 53
             } else {
49
-                FlashMessages::addMessage(/* I18N: %s is the name of a genealogy record */
50
-                I18N::translate('The changes to “%s” have been accepted.', $record->getFullName()));
54
+                http_response_code(406);
51 55
             }
52
-            FunctionsImport::acceptAllChanges($record->getXref(), $record->getTree()->getTreeId());
53
-        } else {
54
-            http_response_code(406);
55
-        }
56
-        break;
56
+            break;
57 57
 
58
-    case 'copy-fact':
59
-        // Copy a fact to the clipboard
60
-        $xref    = Filter::post('xref', WT_REGEX_XREF);
61
-        $fact_id = Filter::post('fact_id');
58
+        case 'copy-fact':
59
+            // Copy a fact to the clipboard
60
+            $xref    = Filter::post('xref', WT_REGEX_XREF);
61
+            $fact_id = Filter::post('fact_id');
62 62
 
63
-        $record = GedcomRecord::getInstance($xref, $WT_TREE);
63
+            $record = GedcomRecord::getInstance($xref, $WT_TREE);
64 64
 
65
-        if ($record && $record->canEdit()) {
66
-            foreach ($record->getFacts() as $fact) {
67
-                if ($fact->getFactId() == $fact_id) {
68
-                    switch ($fact->getTag()) {
65
+            if ($record && $record->canEdit()) {
66
+                foreach ($record->getFacts() as $fact) {
67
+                    if ($fact->getFactId() == $fact_id) {
68
+                        switch ($fact->getTag()) {
69 69
                         case 'NOTE':
70 70
                         case 'SOUR':
71 71
                         case 'OBJE':
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                         default:
75 75
                             $type = $record::RECORD_TYPE; // paste only to the same record type
76 76
                         break;
77
-                    }
77
+                        }
78 78
                     $clipboard = Session::get('clipboard');
79 79
                     if (!is_array($clipboard)) {
80 80
                         $clipboard = array();
@@ -96,158 +96,158 @@  discard block
 block discarded – undo
96 96
         }
97 97
         break;
98 98
 
99
-    case 'paste-fact':
100
-        // Paste a fact from the clipboard
101
-        $xref      = Filter::post('xref', WT_REGEX_XREF);
102
-        $fact_id   = Filter::post('fact_id');
103
-        $record    = GedcomRecord::getInstance($xref, $WT_TREE);
104
-        $clipboard = Session::get('clipboard');
99
+        case 'paste-fact':
100
+            // Paste a fact from the clipboard
101
+            $xref      = Filter::post('xref', WT_REGEX_XREF);
102
+            $fact_id   = Filter::post('fact_id');
103
+            $record    = GedcomRecord::getInstance($xref, $WT_TREE);
104
+            $clipboard = Session::get('clipboard');
105 105
 
106
-        if ($record && $record->canEdit() && isset($clipboard[$fact_id])) {
107
-            $record->createFact($clipboard[$fact_id]['factrec'], true);
108
-        }
109
-        break;
110
-
111
-    case 'delete-fact':
112
-        $xref    = Filter::post('xref', WT_REGEX_XREF);
113
-        $fact_id = Filter::post('fact_id');
114
-
115
-        $record = GedcomRecord::getInstance($xref, $WT_TREE);
116
-        if ($record && $record->canShow() && $record->canEdit()) {
117
-            foreach ($record->getFacts() as $fact) {
118
-                if ($fact->getFactId() == $fact_id && $fact->canShow() && $fact->canEdit()) {
119
-                    $record->deleteFact($fact_id, true);
120
-                    break 2;
106
+            if ($record && $record->canEdit() && isset($clipboard[$fact_id])) {
107
+                $record->createFact($clipboard[$fact_id]['factrec'], true);
108
+            }
109
+            break;
110
+
111
+        case 'delete-fact':
112
+            $xref    = Filter::post('xref', WT_REGEX_XREF);
113
+            $fact_id = Filter::post('fact_id');
114
+
115
+            $record = GedcomRecord::getInstance($xref, $WT_TREE);
116
+            if ($record && $record->canShow() && $record->canEdit()) {
117
+                foreach ($record->getFacts() as $fact) {
118
+                    if ($fact->getFactId() == $fact_id && $fact->canShow() && $fact->canEdit()) {
119
+                        $record->deleteFact($fact_id, true);
120
+                        break 2;
121
+                    }
121 122
                 }
122 123
             }
123
-        }
124
-
125
-        // Can’t find the record/fact, or don’t have permission to delete it.
126
-        http_response_code(406);
127
-        break;
128 124
 
129
-    case 'delete-record':
130
-        $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
131
-        if ($record && Auth::isEditor($record->getTree()) && $record->canShow() && $record->canEdit()) {
132
-            // Delete links to this record
133
-            foreach (FunctionsDb::fetchAllLinks($record->getXref(), $record->getTree()->getTreeId()) as $xref) {
134
-                $linker     = GedcomRecord::getInstance($xref, $WT_TREE);
135
-                $old_gedcom = $linker->getGedcom();
136
-                $new_gedcom = FunctionsEdit::removeLinks($old_gedcom, $record->getXref());
137
-                // FunctionsDb::fetch_all_links() does not take account of pending changes. The links (or even the
138
-                // record itself) may have already been deleted.
139
-                if ($old_gedcom !== $new_gedcom) {
140
-                    // If we have removed a link from a family to an individual, and it has only one member
141
-                    if (preg_match('/^0 @' . WT_REGEX_XREF . '@ FAM/', $new_gedcom) && preg_match_all('/\n1 (HUSB|WIFE|CHIL) @(' . WT_REGEX_XREF . ')@/', $new_gedcom, $match) == 1) {
142
-                        // Delete the family
143
-                        $family = GedcomRecord::getInstance($xref, $WT_TREE);
144
-                        FlashMessages::addMessage(/* I18N: %s is the name of a family group, e.g. “Husband name + Wife name” */ I18N::translate('The family “%s” has been deleted because it only has one member.', $family->getFullName()));
145
-                        $family->deleteRecord();
146
-                        // Delete any remaining link to this family
147
-                        if ($match) {
148
-                            $relict     = GedcomRecord::getInstance($match[2][0], $WT_TREE);
149
-                            $new_gedcom = $relict->getGedcom();
150
-                            $new_gedcom = FunctionsEdit::removeLinks($new_gedcom, $linker->getXref());
151
-                            $relict->updateRecord($new_gedcom, false);
152
-                            FlashMessages::addMessage(/* I18N: %s are names of records, such as sources, repositories or individuals */ I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $relict->getFullName(), $family->getFullName()));
125
+            // Can’t find the record/fact, or don’t have permission to delete it.
126
+            http_response_code(406);
127
+            break;
128
+
129
+        case 'delete-record':
130
+            $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
131
+            if ($record && Auth::isEditor($record->getTree()) && $record->canShow() && $record->canEdit()) {
132
+                // Delete links to this record
133
+                foreach (FunctionsDb::fetchAllLinks($record->getXref(), $record->getTree()->getTreeId()) as $xref) {
134
+                    $linker     = GedcomRecord::getInstance($xref, $WT_TREE);
135
+                    $old_gedcom = $linker->getGedcom();
136
+                    $new_gedcom = FunctionsEdit::removeLinks($old_gedcom, $record->getXref());
137
+                    // FunctionsDb::fetch_all_links() does not take account of pending changes. The links (or even the
138
+                    // record itself) may have already been deleted.
139
+                    if ($old_gedcom !== $new_gedcom) {
140
+                        // If we have removed a link from a family to an individual, and it has only one member
141
+                        if (preg_match('/^0 @' . WT_REGEX_XREF . '@ FAM/', $new_gedcom) && preg_match_all('/\n1 (HUSB|WIFE|CHIL) @(' . WT_REGEX_XREF . ')@/', $new_gedcom, $match) == 1) {
142
+                            // Delete the family
143
+                            $family = GedcomRecord::getInstance($xref, $WT_TREE);
144
+                            FlashMessages::addMessage(/* I18N: %s is the name of a family group, e.g. “Husband name + Wife name” */ I18N::translate('The family “%s” has been deleted because it only has one member.', $family->getFullName()));
145
+                            $family->deleteRecord();
146
+                            // Delete any remaining link to this family
147
+                            if ($match) {
148
+                                $relict     = GedcomRecord::getInstance($match[2][0], $WT_TREE);
149
+                                $new_gedcom = $relict->getGedcom();
150
+                                $new_gedcom = FunctionsEdit::removeLinks($new_gedcom, $linker->getXref());
151
+                                $relict->updateRecord($new_gedcom, false);
152
+                                FlashMessages::addMessage(/* I18N: %s are names of records, such as sources, repositories or individuals */ I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $relict->getFullName(), $family->getFullName()));
153
+                            }
154
+                        } else {
155
+                            // Remove links from $linker to $record
156
+                            FlashMessages::addMessage(/* I18N: %s are names of records, such as sources, repositories or individuals */ I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $linker->getFullName(), $record->getFullName()));
157
+                            $linker->updateRecord($new_gedcom, false);
153 158
                         }
154
-                    } else {
155
-                        // Remove links from $linker to $record
156
-                        FlashMessages::addMessage(/* I18N: %s are names of records, such as sources, repositories or individuals */ I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $linker->getFullName(), $record->getFullName()));
157
-                        $linker->updateRecord($new_gedcom, false);
158 159
                     }
159 160
                 }
161
+                // Delete the record itself
162
+                $record->deleteRecord();
163
+            } else {
164
+                http_response_code(406);
160 165
             }
161
-            // Delete the record itself
162
-            $record->deleteRecord();
163
-        } else {
164
-            http_response_code(406);
165
-        }
166
-        break;
167
-
168
-    case 'delete-user':
169
-        $user = User::find(Filter::postInteger('user_id'));
166
+            break;
170 167
 
171
-        if ($user && Auth::isAdmin() && Auth::user() !== $user) {
172
-            Log::addAuthenticationLog('Deleted user: ' . $user->getUserName());
173
-            $user->delete();
174
-        }
175
-        break;
168
+        case 'delete-user':
169
+            $user = User::find(Filter::postInteger('user_id'));
176 170
 
177
-    case 'language':
178
-        // Change the current language
179
-        $language = Filter::post('language');
180
-        try {
181
-            I18N::init($language);
182
-            Session::put('locale', $language);
183
-            // Remember our selection
184
-            Auth::user()->setPreference('language', $language);
185
-        } catch (\Exception $ex) {
186
-            // Request for a non-existant language.
187
-            http_response_code(406);
188
-        }
189
-        break;
190
-
191
-    case 'masquerade':
192
-        $user = User::find(Filter::postInteger('user_id'));
171
+            if ($user && Auth::isAdmin() && Auth::user() !== $user) {
172
+                Log::addAuthenticationLog('Deleted user: ' . $user->getUserName());
173
+                $user->delete();
174
+            }
175
+            break;
176
+
177
+        case 'language':
178
+            // Change the current language
179
+            $language = Filter::post('language');
180
+            try {
181
+                I18N::init($language);
182
+                Session::put('locale', $language);
183
+                // Remember our selection
184
+                Auth::user()->setPreference('language', $language);
185
+            } catch (\Exception $ex) {
186
+                // Request for a non-existant language.
187
+                http_response_code(406);
188
+            }
189
+            break;
193 190
 
194
-        if ($user && Auth::isAdmin() && Auth::user() !== $user) {
195
-            Log::addAuthenticationLog('Masquerade as user: ' . $user->getUserName());
196
-            Auth::login($user);
197
-            Session::put('masquerade', '1');
198
-        } else {
199
-            http_response_code(406);
200
-        }
201
-        break;
191
+        case 'masquerade':
192
+            $user = User::find(Filter::postInteger('user_id'));
202 193
 
203
-    case 'unlink-media':
204
-        // Remove links from an individual and their spouse-family records to a media object.
205
-        // Used by the "unlink" option on the album (lightbox) tab.
206
-        $source = Individual::getInstance(Filter::post('source', WT_REGEX_XREF), $WT_TREE);
207
-        $target = Filter::post('target', WT_REGEX_XREF);
208
-        if ($source && $source->canShow() && $source->canEdit() && $target) {
209
-            // Consider the individual and their spouse-family records
210
-            $sources   = $source->getSpouseFamilies();
211
-            $sources[] = $source;
212
-            foreach ($sources as $source) {
213
-                foreach ($source->getFacts() as $fact) {
214
-                    if (!$fact->isPendingDeletion()) {
215
-                        if ($fact->getValue() == '@' . $target . '@') {
216
-                            // Level 1 links
217
-                            $source->deleteFact($fact->getFactId(), true);
218
-                        } elseif (strpos($fact->getGedcom(), ' @' . $target . '@')) {
219
-                            // Level 2-3 links
220
-                            $source->updateFact($fact->getFactId(), preg_replace(array('/\n2 OBJE @' . $target . '@(\n[3-9].*)*/', '/\n3 OBJE @' . $target . '@(\n[4-9].*)*/'), '', $fact->getGedcom()), true);
194
+            if ($user && Auth::isAdmin() && Auth::user() !== $user) {
195
+                Log::addAuthenticationLog('Masquerade as user: ' . $user->getUserName());
196
+                Auth::login($user);
197
+                Session::put('masquerade', '1');
198
+            } else {
199
+                http_response_code(406);
200
+            }
201
+            break;
202
+
203
+        case 'unlink-media':
204
+            // Remove links from an individual and their spouse-family records to a media object.
205
+            // Used by the "unlink" option on the album (lightbox) tab.
206
+            $source = Individual::getInstance(Filter::post('source', WT_REGEX_XREF), $WT_TREE);
207
+            $target = Filter::post('target', WT_REGEX_XREF);
208
+            if ($source && $source->canShow() && $source->canEdit() && $target) {
209
+                // Consider the individual and their spouse-family records
210
+                $sources   = $source->getSpouseFamilies();
211
+                $sources[] = $source;
212
+                foreach ($sources as $source) {
213
+                    foreach ($source->getFacts() as $fact) {
214
+                        if (!$fact->isPendingDeletion()) {
215
+                            if ($fact->getValue() == '@' . $target . '@') {
216
+                                // Level 1 links
217
+                                $source->deleteFact($fact->getFactId(), true);
218
+                            } elseif (strpos($fact->getGedcom(), ' @' . $target . '@')) {
219
+                                // Level 2-3 links
220
+                                $source->updateFact($fact->getFactId(), preg_replace(array('/\n2 OBJE @' . $target . '@(\n[3-9].*)*/', '/\n3 OBJE @' . $target . '@(\n[4-9].*)*/'), '', $fact->getGedcom()), true);
221
+                            }
221 222
                         }
222 223
                     }
223 224
                 }
225
+            } else {
226
+                http_response_code(406);
224 227
             }
225
-        } else {
226
-            http_response_code(406);
227
-        }
228
-        break;
229
-
230
-    case 'reject-changes':
231
-        // Reject all the pending changes for a record
232
-        $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
233
-        if ($record && $record->canEdit() && Auth::isModerator($record->getTree())) {
234
-            FlashMessages::addMessage(/* I18N: %s is the name of an individual, source or other record */ I18N::translate('The changes to “%s” have been rejected.', $record->getFullName()));
235
-            FunctionsImport::rejectAllChanges($record);
236
-        } else {
237
-            http_response_code(406);
238
-        }
239
-        break;
240
-
241
-    case 'theme':
242
-        // Change the current theme
243
-        $theme = Filter::post('theme');
244
-        if (Site::getPreference('ALLOW_USER_THEMES') && array_key_exists($theme, Theme::themeNames())) {
245
-            Session::put('theme_id', $theme);
246
-            // Remember our selection
247
-            Auth::user()->setPreference('theme', $theme);
248
-        } else {
249
-            // Request for a non-existant theme.
250
-            http_response_code(406);
251
-        }
252
-        break;
228
+            break;
229
+
230
+        case 'reject-changes':
231
+            // Reject all the pending changes for a record
232
+            $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
233
+            if ($record && $record->canEdit() && Auth::isModerator($record->getTree())) {
234
+                FlashMessages::addMessage(/* I18N: %s is the name of an individual, source or other record */ I18N::translate('The changes to “%s” have been rejected.', $record->getFullName()));
235
+                FunctionsImport::rejectAllChanges($record);
236
+            } else {
237
+                http_response_code(406);
238
+            }
239
+            break;
240
+
241
+        case 'theme':
242
+            // Change the current theme
243
+            $theme = Filter::post('theme');
244
+            if (Site::getPreference('ALLOW_USER_THEMES') && array_key_exists($theme, Theme::themeNames())) {
245
+                Session::put('theme_id', $theme);
246
+                // Remember our selection
247
+                Auth::user()->setPreference('theme', $theme);
248
+            } else {
249
+                // Request for a non-existant theme.
250
+                http_response_code(406);
251
+            }
252
+            break;
253 253
 }
Please login to merge, or discard this patch.
admin_trees_duplicates.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -177,8 +177,11 @@
 block discarded – undo
177 177
     </li>
178 178
 <?php endforeach; ?>
179 179
 </ul>
180
-<?php else: ?>
181
-<p><?php echo I18N::translate('No duplicates have been found.'); ?></p>
180
+<?php else {
181
+    : ?>
182
+<p><?php echo I18N::translate('No duplicates have been found.');
183
+}
184
+?></p>
182 185
 <?php endif; ?>
183 186
 
184 187
 <?php endforeach; ?>
Please login to merge, or discard this patch.
admin_trees_manage.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -436,8 +436,11 @@
 block discarded – undo
436 436
                                     <i class="fa fa-li fa-star"></i>
437 437
                                     <?php if ($tree->getName() == Site::getPreference('DEFAULT_GEDCOM')): ?>
438 438
                                         <?php echo I18N::translate('Default family tree'); ?>
439
-                                    <?php else: ?>
440
-                                        <a href="#" onclick="document.defaultform<?php echo $tree->getTreeId(); ?>.submit();">
439
+                                    <?php else {
440
+    : ?>
441
+                                        <a href="#" onclick="document.defaultform<?php echo $tree->getTreeId();
442
+}
443
+?>.submit();">
441 444
                                             <?php echo I18N::translate('Set as default'); ?>
442 445
                                             <span class="sr-only">
443 446
                                         <?php echo $tree->getTitleHtml(); ?>
Please login to merge, or discard this patch.
admin_site_merge.php 1 patch
Braces   +20 added lines, -8 removed lines patch added patch discarded remove patch
@@ -236,9 +236,12 @@  discard block
 block discarded – undo
236 236
                 <?php endforeach; ?>
237 237
                 </tbody>
238 238
             </table>
239
-            <?php else: ?>
239
+            <?php else {
240
+    : ?>
240 241
             <p>
241
-                <?php echo I18N::translate('No matching facts found'); ?>
242
+                <?php echo I18N::translate('No matching facts found');
243
+}
244
+?>
242 245
             </p>
243 246
             <?php endif; ?>
244 247
         </div>
@@ -283,9 +286,12 @@  discard block
 block discarded – undo
283 286
                             <?php endforeach; ?>
284 287
                             </tbody>
285 288
                         </table>
286
-                    <?php else: ?>
289
+                    <?php else {
290
+    : ?>
287 291
                         <p>
288
-                            <?php echo I18N::translate('No matching facts found'); ?>
292
+                            <?php echo I18N::translate('No matching facts found');
293
+}
294
+?>
289 295
                         </p>
290 296
                     <?php endif; ?>
291 297
                 </div>
@@ -329,9 +335,12 @@  discard block
 block discarded – undo
329 335
                             <?php endforeach; ?>
330 336
                             </tbody>
331 337
                         </table>
332
-                    <?php else: ?>
338
+                    <?php else {
339
+    : ?>
333 340
                         <p>
334
-                            <?php echo I18N::translate('No matching facts found'); ?>
341
+                            <?php echo I18N::translate('No matching facts found');
342
+}
343
+?>
335 344
                         </p>
336 345
                     <?php endif; ?>
337 346
                 </div>
@@ -345,10 +354,13 @@  discard block
 block discarded – undo
345 354
     </button>
346 355
 </form>
347 356
 
348
-<?php else: ?>
357
+<?php else {
358
+    : ?>
349 359
 
350 360
 <form class="form form-horizontal">
351
-    <input type="hidden" name="ged" value="<?php echo $WT_TREE->getNameHtml(); ?>">
361
+    <input type="hidden" name="ged" value="<?php echo $WT_TREE->getNameHtml();
362
+}
363
+?>">
352 364
     <p><?php echo /* I18N: Records are indviduals, sources, etc. */ I18N::translate('Select two records to merge.'); ?></p>
353 365
 
354 366
     <div class="form-group">
Please login to merge, or discard this patch.
admin_media.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -657,16 +657,22 @@
 block discarded – undo
657 657
                     <div dir="ltr">
658 658
                         <?php if (count($media_folders) > 1): ?>
659 659
                             <?php echo WT_DATA_DIR, FunctionsEdit::selectEditControl('media_folder', $media_folders, null, $media_folder, 'onchange="this.form.submit();"'); ?>
660
-                        <?php else: ?>
661
-                        <?php echo WT_DATA_DIR, Filter::escapeHtml($media_folder); ?>
660
+                        <?php else {
661
+    : ?>
662
+                        <?php echo WT_DATA_DIR, Filter::escapeHtml($media_folder);
663
+}
664
+?>
662 665
                         <input type="hidden" name="media_folder" value="<?php echo Filter::escapeHtml($media_folder); ?>">
663 666
                         <?php endif; ?>
664 667
                     </div>
665 668
 
666 669
                         <?php if (count($media_paths) > 1): ?>
667 670
                             <?php echo FunctionsEdit::selectEditControl('media_path', $media_paths, null, $media_path, 'onchange="this.form.submit();"'); ?>
668
-                    <?php else: ?>
669
-                    <?php echo Filter::escapeHtml($media_path); ?>
671
+                    <?php else {
672
+    : ?>
673
+                    <?php echo Filter::escapeHtml($media_path);
674
+}
675
+?>
670 676
                     <input type="hidden" name="media_path" value="<?php echo Filter::escapeHtml($media_path); ?>">
671 677
                     <?php endif; ?>
672 678
 
Please login to merge, or discard this patch.
admin_site_change.php 1 patch
Switch Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -111,53 +111,53 @@
 block discarded – undo
111 111
 }
112 112
 
113 113
 switch ($action) {
114
-    case 'delete':
115
-        $sql_delete =
116
-        "DELETE `##change` FROM `##change`" .
117
-        " LEFT JOIN `##user` USING (user_id)" . // user may be deleted
118
-        " LEFT JOIN `##gedcom` USING (gedcom_id)"; // gedcom may be deleted
119
-
120
-        Database::prepare($sql_delete . $where)->execute($args);
121
-        break;
122
-
123
-    case 'export':
124
-        header('Content-Type: text/csv');
125
-        header('Content-Disposition: attachment; filename="webtrees-changes.csv"');
126
-        $rows = Database::prepare($sql_select . $where . ' ORDER BY change_id')->execute($args)->fetchAll();
127
-        foreach ($rows as $row) {
128
-            echo
129
-            '"', $row->change_time, '",',
130
-            '"', $row->status, '",',
131
-            '"', $row->xref, '",',
132
-            '"', str_replace('"', '""', $row->old_gedcom), '",',
133
-            '"', str_replace('"', '""', $row->new_gedcom), '",',
134
-            '"', str_replace('"', '""', $row->user_name), '",',
135
-            '"', str_replace('"', '""', $row->gedcom_name), '"',
136
-            "\n";
137
-        }
114
+        case 'delete':
115
+            $sql_delete =
116
+            "DELETE `##change` FROM `##change`" .
117
+            " LEFT JOIN `##user` USING (user_id)" . // user may be deleted
118
+            " LEFT JOIN `##gedcom` USING (gedcom_id)"; // gedcom may be deleted
119
+
120
+            Database::prepare($sql_delete . $where)->execute($args);
121
+            break;
122
+
123
+        case 'export':
124
+            header('Content-Type: text/csv');
125
+            header('Content-Disposition: attachment; filename="webtrees-changes.csv"');
126
+            $rows = Database::prepare($sql_select . $where . ' ORDER BY change_id')->execute($args)->fetchAll();
127
+            foreach ($rows as $row) {
128
+                echo
129
+                '"', $row->change_time, '",',
130
+                '"', $row->status, '",',
131
+                '"', $row->xref, '",',
132
+                '"', str_replace('"', '""', $row->old_gedcom), '",',
133
+                '"', str_replace('"', '""', $row->new_gedcom), '",',
134
+                '"', str_replace('"', '""', $row->user_name), '",',
135
+                '"', str_replace('"', '""', $row->gedcom_name), '"',
136
+                "\n";
137
+            }
138 138
 
139
-        return;
140
-    case 'load_json':
141
-        $start  = Filter::getInteger('start');
142
-        $length = Filter::getInteger('length');
143
-        $order  = Filter::getArray('order');
144
-
145
-        if ($order) {
146
-            $order_by = " ORDER BY ";
147
-            foreach ($order as $key => $value) {
148
-                if ($key > 0) {
149
-                    $order_by .= ',';
150
-                }
151
-                // Datatables numbers columns 0, 1, 2
152
-                // MySQL numbers columns 1, 2, 3
153
-                switch ($value['dir']) {
139
+            return;
140
+        case 'load_json':
141
+            $start  = Filter::getInteger('start');
142
+            $length = Filter::getInteger('length');
143
+            $order  = Filter::getArray('order');
144
+
145
+            if ($order) {
146
+                $order_by = " ORDER BY ";
147
+                foreach ($order as $key => $value) {
148
+                    if ($key > 0) {
149
+                        $order_by .= ',';
150
+                    }
151
+                    // Datatables numbers columns 0, 1, 2
152
+                    // MySQL numbers columns 1, 2, 3
153
+                    switch ($value['dir']) {
154 154
                     case 'asc':
155 155
                         $order_by .= (1 + $value['column']) . " ASC ";
156 156
                         break;
157 157
                     case 'desc':
158 158
                         $order_by .= (1 + $value['column']) . " DESC ";
159 159
                     break;
160
-                }
160
+                    }
161 161
             }
162 162
         } else {
163 163
             $order_by = " ORDER BY 1 DESC";
Please login to merge, or discard this patch.