Skip to content

Commit

Permalink
fix: corrected copy entry functionality and removed old code, closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Aug 11, 2024
1 parent 90fd812 commit e95c39e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 47 deletions.
50 changes: 6 additions & 44 deletions phpmyfaq/admin/faqs.editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
$userHelper = new UserHelper($user);
$tagging = new Tags($faqConfig);
$seo = new Seo($faqConfig);
$logging = new AdminLog($faqConfig);

$date = new Date($faqConfig);

Expand Down Expand Up @@ -119,47 +120,8 @@
$notifyEmail = '';
}

if ('editpreview' === $action) {
$faqData['id'] = Filter::filterInput(INPUT_POST, 'id', FILTER_VALIDATE_INT);
if (!is_null($faqData['id'])) {
$queryString = 'saveentry&id=' . $faqData['id'];
} else {
$queryString = 'insertentry';
}

$faqData['lang'] = Filter::filterInput(INPUT_POST, 'lang', FILTER_SANITIZE_SPECIAL_CHARS);
$selectedCategory = Filter::filterInputArray(
INPUT_POST,
[
'rubrik' => [
'filter' => FILTER_VALIDATE_INT,
'flags' => FILTER_REQUIRE_ARRAY,
],
]
);

if (is_array($selectedCategory)) {
foreach ($selectedCategory as $cats) {
$categories[] = ['category_id' => $cats, 'category_lang' => $faqData['lang']];
}
}

$faqData['active'] = Filter::filterInput(INPUT_POST, 'active', FILTER_SANITIZE_SPECIAL_CHARS);
$faqData['keywords'] = Filter::filterInput(INPUT_POST, 'keywords', FILTER_SANITIZE_SPECIAL_CHARS);
$faqData['title'] = Filter::filterInput(INPUT_POST, 'thema', FILTER_SANITIZE_SPECIAL_CHARS);
$faqData['content'] = Filter::filterInput(INPUT_POST, 'content', FILTER_SANITIZE_SPECIAL_CHARS);
$faqData['author'] = Filter::filterInput(INPUT_POST, 'author', FILTER_SANITIZE_SPECIAL_CHARS);
$faqData['email'] = Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
$faqData['comment'] = Filter::filterInput(INPUT_POST, 'comment', FILTER_SANITIZE_SPECIAL_CHARS);
$faqData['solution_id'] = Filter::filterInput(INPUT_POST, 'solution_id', FILTER_VALIDATE_INT);
$faqData['revision_id'] = Filter::filterInput(INPUT_POST, 'revision_id', FILTER_VALIDATE_INT, 0);
$faqData['sticky'] = Filter::filterInput(INPUT_POST, 'sticky', FILTER_VALIDATE_INT);
$faqData['tags'] = Filter::filterInput(INPUT_POST, 'tags', FILTER_SANITIZE_SPECIAL_CHARS);
$faqData['changed'] = Filter::filterInput(INPUT_POST, 'changed', FILTER_SANITIZE_SPECIAL_CHARS);
$faqData['dateStart'] = Filter::filterInput(INPUT_POST, 'dateStart', FILTER_SANITIZE_SPECIAL_CHARS);
$faqData['dateEnd'] = Filter::filterInput(INPUT_POST, 'dateEnd', FILTER_SANITIZE_SPECIAL_CHARS);
$faqData['content'] = html_entity_decode((string)$faqData['content']);
} elseif ('editentry' === $action) {
if ('editentry' === $action) {
$logging->log($user, 'admin-edit-faq');
$id = Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
$lang = Filter::filterInput(INPUT_GET, 'lang', FILTER_SANITIZE_SPECIAL_CHARS);
$translateTo = Filter::filterInput(INPUT_GET, 'translateTo', FILTER_SANITIZE_SPECIAL_CHARS);
Expand Down Expand Up @@ -188,15 +150,14 @@
$faqData['lang'] = $translateTo; // once again
}
$faqData['tags'] = implode(', ', $tagging->getAllTagsById($faqData['id']));

$queryString = 'saveentry&id=' . $faqData['id'];
} else {
$queryString = 'insertentry';
if (isset($categoryId)) {
$categories = ['category_id' => $categoryId, 'category_lang' => $lang];
}
}
} elseif ('copyentry' === $action) {
$logging->log($user, 'admin-copy-faq');
$faqData['id'] = Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
$faqData['lang'] = Filter::filterInput(INPUT_GET, 'lang', FILTER_SANITIZE_SPECIAL_CHARS);
$categories = $categoryRelation->getCategories($faqData['id'], $faqData['lang']);
Expand All @@ -205,9 +166,10 @@

$faqData = $faq->faqRecord;
$faqData['tags'] = implode(', ', $tagging->getAllTagsById($faqData['id']));
$faqData['id'] = 0;
$faqData['revision_id'] = 0;
$queryString = 'insertentry';
} else {
$logging = new AdminLog($faqConfig);
$logging->log($user, 'admin-add-faq');
$queryString = 'insertentry';
if (!is_array($categories)) {
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/admin/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
case 'showcategory':
case 'faqs-overview':
case 'editentry':
case 'saveentry':
case 'copyentry':
case 'glossary':
case 'saveglossary':
case 'updateglossary':
Expand Down
1 change: 0 additions & 1 deletion phpmyfaq/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@
case 'takequestion':
case 'editentry':
case 'copyentry':
case 'editpreview':
require 'faqs.editor.php';
break;
case 'question':
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/assets/templates/admin/content/faq.overview.twig
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
data-bs-target="#category-id-{{ category.id }}">

<span class="lead">{{ category.name }}</span>
<span class="badge bg-secondary mx-1">{{ numberOfRecords[category.id] ?? 0 }} {{ 'msgEntries' | translate }}</span>
<span class="badge bg-primary mx-1">{{ numberOfRecords[category.id] ?? 0 }} {{ 'msgEntries' | translate }}</span>
<span class="badge bg-info mx-1">{{ numberOfComments[category.id] ?? 0 }} {{ msgComments }}</span>

</button>
Expand Down

0 comments on commit e95c39e

Please sign in to comment.