Skip to content

Commit 760f54c

Browse files
committed
Fixed counter of inactive FAQs, closes thorsten#1489
1 parent bc37e64 commit 760f54c

File tree

2 files changed

+43
-41
lines changed

2 files changed

+43
-41
lines changed

phpmyfaq/admin/header.php

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -257,23 +257,23 @@
257257
<div id="wrapper">
258258

259259
<!-- Sidebar -->
260-
<?php if (isset($auth) && (count($user->perm->getAllUserRights($user->getUserId())) > 0 || $user->isSuperAdmin(
261-
))): ?>
262-
<ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">
263-
264-
<li>
265-
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="../">
266-
<div class="sidebar-brand-icon rotate-n-15">
267-
<i class="fas fa-laugh-wink"></i>
268-
</div>
269-
<div class="sidebar-brand-text mx-4">phpMyFAQ <?= System::getVersion() ?></div>
270-
</a>
271-
</li>
272-
273-
<li>
274-
<hr class="sidebar-divider my-0">
275-
</li>
276-
260+
<ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">
261+
262+
<li>
263+
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="../">
264+
<div class="sidebar-brand-icon rotate-n-15">
265+
<i class="fas fa-laugh-wink"></i>
266+
</div>
267+
<div class="sidebar-brand-text mx-4">phpMyFAQ <?= System::getVersion() ?></div>
268+
</a>
269+
</li>
270+
271+
<li>
272+
<hr class="sidebar-divider my-0">
273+
</li>
274+
275+
<?php if (isset($auth) && (count($user->perm->getAllUserRights($user->getUserId())) > 0 || $user->isSuperAdmin(
276+
))): ?>
277277
<li class="nav-item active">
278278
<a class="nav-link" href="index.php">
279279
<i class="fa fa-tachometer"></i>
@@ -377,9 +377,13 @@
377377
<hr class="sidebar-divider d-none d-md-block">
378378
</li>
379379

380-
</ul>
381-
<!-- End of Sidebar -->
382-
<?php endif; ?>
380+
<li>
381+
<div class="text-center small" id="saving_data_indicator"></div>
382+
</li>
383+
384+
<?php endif; ?>
385+
</ul>
386+
<!-- End of Sidebar -->
383387

384388
<!-- Content Wrapper -->
385389
<div id="content-wrapper" class="d-flex flex-column">

phpmyfaq/admin/record.show.php

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,11 @@ function verifyEntryURL_failure(XmlRequest)
220220
} else {
221221
$fdTable = Database::getTablePrefix().'faqdata';
222222
$fcrTable = Database::getTablePrefix().'faqcategoryrelations';
223-
$search = SearchFactory::create($faqConfig, array('database' => Database::getType()));
223+
$search = SearchFactory::create($faqConfig, ['database' => Database::getType()]);
224224

225225
$search->setTable($fdTable)
226-
->setResultColumns(array(
226+
->setResultColumns(
227+
[
227228
$fdTable.'.id AS id',
228229
$fdTable.'.lang AS lang',
229230
$fdTable.'.solution_id AS solution_id',
@@ -232,24 +233,29 @@ function verifyEntryURL_failure(XmlRequest)
232233
$fdTable.'.active AS active',
233234
$fdTable.'.thema AS thema',
234235
$fdTable.'.content AS content',
235-
$fdTable.'.updated AS updated',))
236+
$fdTable.'.updated AS updated',
237+
]
238+
)
236239
->setJoinedTable($fcrTable)
237-
->setJoinedColumns(array(
240+
->setJoinedColumns(
241+
[
238242
$fdTable.'.id = '.$fcrTable.'.record_id',
239-
$fdTable.'.lang = '.$fcrTable.'.record_lang',));
243+
$fdTable.'.lang = '.$fcrTable.'.record_lang',
244+
]
245+
);
240246

241247
if (is_numeric($searchTerm)) {
242-
$search->setMatchingColumns(array($fdTable.'.solution_id'));
248+
$search->setMatchingColumns([$fdTable.'.solution_id']);
243249
} else {
244-
$search->setMatchingColumns(array($fdTable.'.thema', $fdTable.'.content', $fdTable.'.keywords'));
250+
$search->setMatchingColumns([$fdTable.'.thema', $fdTable.'.content', $fdTable.'.keywords']);
245251
}
246252

247253
$result = $search->search($searchTerm);
248254
$laction = 'view';
249255
$internalSearch = '&search='.$searchTerm;
250256
$wasSearch = true;
251-
$idsFound = array();
252-
$faqsFound = array();
257+
$idsFound = [];
258+
$faqsFound = [];
253259

254260
while ($row = $faqConfig->getDb()->fetchObject($result)) {
255261
if ($searchCat != 0 && $searchCat != (int)$row->category_id) {
@@ -472,7 +478,7 @@ function verifyEntryURL_failure(XmlRequest)
472478
<?php if ($user->perm->checkRight($user->getUserId(),
473479
'approverec') && isset($numVisits[$record['id']])) { ?>
474480
<label>
475-
<input type="checkbox" lang="<?= $record['lang'] ?>"
481+
<input type="checkbox" lang="<?= $record['lang'] ?>" class="active-records-category-<?= $cid ?>"
476482
onclick="saveStatus(<?= $cid.', ['.$record['id'].']' ?>, 'active', '<?= $user->getCsrfTokenFromSession() ?>');"
477483
id="active_record_<?= $cid.'_'.$record['id'] ?>"
478484
<?= 'yes' == $record['active'] ? 'checked' : ' ' ?>>
@@ -580,27 +586,19 @@ function saveStatus(cid, ids, type, csrf) {
580586
if ('active' === type) {
581587
for (let j = 0; j < sameRecords.length; j++) {
582588
$('#' + sameRecords[j].id).attr('checked', status);
583-
584589
const catid = sameRecords[j].id.match(/active_record_(\d+)_\d+/)[1];
585-
const current_item_count = $('#js-active-records-' + catid).html();
586-
const delta = 'checked' === status ? -1 : 1;
587-
588-
$('#js-active-records-' + catid).html(current_item_count * 1 + delta);
590+
$('#js-active-records-' + catid).html($('.active-records-category-' + cid + ':not(:checked)').length);
589591
}
590592
} else {
591593
for (let j = 0; j < sameRecords.length; j++) {
592594
$('#' + sameRecords[j].id).attr('checked', status);
593-
594595
const catid = sameRecords[j].id.match(/active_record_(\d+)_\d+/)[1];
595-
const current_item_count = $('#js-active-records-' + catid).html();
596-
const delta = 'checked' === status ? -1 : 1;
597-
598-
$('#js-active-records-' + catid).html(current_item_count * 1 + delta);
596+
$('#js-active-records-' + catid).html($('.active-records-category-' + cid + ':not(:checked)').length);
599597
}
600598
}
601599
}
602600

603-
$.get("index.php", data, null);
601+
$.get('index.php', data, null);
604602
indicator.html('<?= $PMF_LANG['ad_entry_savedsuc'] ?>');
605603
}
606604

0 commit comments

Comments
 (0)