@@ -30,42 +30,42 @@ |
||
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 | ?> |
@@ -30,51 +30,51 @@ |
||
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 | } |
@@ -43,38 +43,38 @@ |
||
43 | 43 | |
44 | 44 | foreach ($facts as $fact) { |
45 | 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; |
|
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 | 79 | } |
80 | 80 | } |
@@ -31,10 +31,10 @@ discard block |
||
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 |
||
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&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&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&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&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&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&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&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&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>'; |
@@ -49,72 +49,72 @@ discard block |
||
49 | 49 | echo '<div id="pending"><h2>', I18N::translate('Pending changes'), '</h2>'; |
50 | 50 | |
51 | 51 | switch ($action) { |
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; |
|
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; |
|
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; |
|
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; |
|
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; |
|
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; |
|
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; |
|
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; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | $changed_gedcoms = Database::prepare( |
@@ -146,27 +146,27 @@ discard block |
||
146 | 146 | |
147 | 147 | |
148 | 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; |
|
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 | 170 | } |
171 | 171 | if ($change->xref != $prev_xref || $change->gedcom_id != $prev_gedcom_id) { |
172 | 172 | if ($prev_xref) { |
@@ -31,8 +31,8 @@ discard block |
||
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 |
||
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 |
||
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 | ?> |
@@ -137,12 +137,12 @@ |
||
137 | 137 | // Datatables numbers columns 0, 1, 2 |
138 | 138 | // MySQL numbers columns 1, 2, 3 |
139 | 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; |
|
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 | 146 | } |
147 | 147 | } |
148 | 148 | } else { |
@@ -24,33 +24,33 @@ discard block |
||
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 |
||
67 | 67 | } |
68 | 68 | }); |
69 | 69 | ') |
70 | - ->pageHeader(); |
|
70 | + ->pageHeader(); |
|
71 | 71 | |
72 | 72 | ?> |
73 | 73 | <ol class="breadcrumb small"> |
@@ -98,8 +98,11 @@ |
||
98 | 98 | <td class="col-xs-1"> |
99 | 99 | <?php if ($module instanceof ModuleConfigInterface): ?> |
100 | 100 | <a href="<?php echo $module->getConfigLink(); ?>"><?php echo $module->getTitle(); ?> <i class="fa fa-cogs"></i></a> |
101 | - <?php else: ?> |
|
102 | - <?php echo $module->getTitle(); ?> |
|
101 | + <?php else { |
|
102 | + : ?> |
|
103 | + <?php echo $module->getTitle(); |
|
104 | +} |
|
105 | +?> |
|
103 | 106 | <?php endif; ?> |
104 | 107 | </td> |
105 | 108 | <td class="col-xs-5"><?php echo $module->getDescription(); ?></td> |
@@ -34,34 +34,34 @@ discard block |
||
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 |
||
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> |
@@ -33,25 +33,25 @@ discard block |
||
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 |
||
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>'; |
@@ -24,33 +24,33 @@ discard block |
||
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 |
||
67 | 67 | } |
68 | 68 | }); |
69 | 69 | ') |
70 | - ->pageHeader(); |
|
70 | + ->pageHeader(); |
|
71 | 71 | |
72 | 72 | ?> |
73 | 73 | <ol class="breadcrumb small"> |
@@ -98,8 +98,11 @@ |
||
98 | 98 | <td class="col-xs-1"> |
99 | 99 | <?php if ($module instanceof ModuleConfigInterface): ?> |
100 | 100 | <a href="<?php echo $module->getConfigLink(); ?>"><?php echo $module->getTitle(); ?> <i class="fa fa-cogs"></i></a> |
101 | - <?php else: ?> |
|
102 | - <?php echo $module->getTitle(); ?> |
|
101 | + <?php else { |
|
102 | + : ?> |
|
103 | + <?php echo $module->getTitle(); |
|
104 | +} |
|
105 | +?> |
|
103 | 106 | <?php endif; ?> |
104 | 107 | </td> |
105 | 108 | <td class="col-xs-5"><?php echo $module->getDescription(); ?></td> |
@@ -22,9 +22,9 @@ |
||
22 | 22 | |
23 | 23 | $controller = new PageController; |
24 | 24 | $controller |
25 | - ->restrictAccess(Auth::isAdmin()) |
|
26 | - ->setPageTitle(I18N::translate('Send broadcast messages')) |
|
27 | - ->pageHeader(); |
|
25 | + ->restrictAccess(Auth::isAdmin()) |
|
26 | + ->setPageTitle(I18N::translate('Send broadcast messages')) |
|
27 | + ->pageHeader(); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 |