1<?php 2/** 3 * Delete open questions. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public License, 6 * v. 2.0. If a copy of the MPL was not distributed with this file, You can 7 * obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * @package phpMyFAQ 10 * @author Thorsten Rinne <thorsten@phpmyfaq.de> 11 * @copyright 2003-2020 phpMyFAQ Team 12 * @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 13 * @link https://www.phpmyfaq.de 14 * @since 2003-02-24 15 */ 16 17use phpMyFAQ\Category; 18use phpMyFAQ\Date; 19use phpMyFAQ\Filter; 20use phpMyFAQ\Question; 21 22if (!defined('IS_VALID_PHPMYFAQ')) { 23 http_response_code(400); 24 exit(); 25} 26?> 27<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"> 28 <h1 class="h2"> 29 <i aria-hidden="true" class="fa fa-question-circle-o"></i> 30 <?= $PMF_LANG['msgOpenQuestions'] ?> 31 </h1> 32</div> 33 34<div class="row"> 35 <div class="col-lg-12"> 36 <?php 37 if ($user->perm->checkRight($user->getUserId(), 'delquestion')) { 38 $category = new Category($faqConfig, [], false); 39 $question = new Question($faqConfig); 40 $category->setUser($currentAdminUser); 41 $category->setGroups($currentAdminGroups); 42 $date = new Date($faqConfig); 43 $questionId = Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT); 44 45 $toggle = Filter::filterInput(INPUT_GET, 'is_visible', FILTER_SANITIZE_STRING); 46 if ($toggle == 'toggle') { 47 $isVisible = $question->getVisibility($questionId); 48 if (!is_null($isVisible)) { 49 $question->setVisibility($questionId, ($isVisible == 'N' ? 'Y' : 'N')); 50 } 51 } 52 53 echo '<div id="returnMessage"></div>'; 54 55 $openQuestions = $question->getAllOpenQuestions(); 56 57 if (count($openQuestions) > 0) { 58 ?> 59 <form id="questionSelection" name="questionSelection" method="post" accept-charset="utf-8"> 60 <input type="hidden" name="csrf" value="<?= $user->getCsrfTokenFromSession() ?>"> 61 <table class="table table-striped"> 62 <thead> 63 <tr> 64 <th></th> 65 <th><?= $PMF_LANG['ad_entry_author'] ?></th> 66 <th><?= $PMF_LANG['ad_entry_theme'] ?></th> 67 <th colspan="2"><?= $PMF_LANG['ad_entry_visibility'] ?>?</th> 68 </tr> 69 </thead> 70 <tbody> 71 <?php 72 foreach ($openQuestions as $openQuestion) { 73 ?> 74 <tr> 75 <td> 76 <label> 77 <input id="questions[]" name="questions[]" value="<?= $openQuestion->getId() ?>" type="checkbox"> 78 </label> 79 </td> 80 <td> 81 <?= $date->format(Date::createIsoDate($openQuestion->getCreated())) ?> 82 <br> 83 <a href="mailto:<?= $openQuestion->getEmail() ?>"> 84 <?= $openQuestion->getUsername() ?> 85 </a> 86 </td> 87 <td> 88 <strong><?= $category->categoryName[$openQuestion->getCategoryId()]['name'] ?></strong> 89 <br> 90 <?= $openQuestion->getQuestion() ?> 91 </td> 92 <td> 93 <a href="?action=question&id=<?= $openQuestion->getId() ?>&is_visible=toggle" 94 class="btn btn-info"> 95 <?= ('Y' === $openQuestion->isVisible()) ? $PMF_LANG['ad_gen_yes'] : $PMF_LANG['ad_gen_no'] ?> 96 </a> 97 </td> 98 <td> 99 <?php if ($faqConfig->get('records.enableCloseQuestion') && $openQuestion['answer_id']) { ?> 100 <a href="?action=editentry&id=<?= $openQuestion->getAnswerId() ?>&lang=<?= $faqLangCode ?>" 101 class="btn btn-success"> 102 <?= $PMF_LANG['msg2answerFAQ'] ?> 103 </a> 104 <?php } else { ?> 105 <a href="?action=takequestion&id=<?= $openQuestion->getId() ?>" class="btn btn-success"> 106 <?= $PMF_LANG['ad_ques_take'] ?> 107 </a> 108 <?php } ?> 109 </td> 110 </tr> 111 <?php } ?> 112 </tbody> 113 </table> 114 115 <div class="text-right"> 116 <button class="btn btn-danger" id="submitDeleteQuestions" type="submit"> 117 <?= $PMF_LANG['ad_entry_delete'] ?> 118 </button> 119 </div> 120 121 </form> 122 <script src="assets/js/record.js"></script> 123 <?php 124 125 } else { 126 echo $PMF_LANG['msgNoQuestionsAvailable']; 127 } 128 } else { 129 echo $PMF_LANG['err_NotAuth']; 130 } 131 ?> 132 </div> 133</div> 134