PageRenderTime 95ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/phpmyfaq/admin/record.questions.php

https://github.com/cyrke/phpMyFAQ
PHP | 146 lines | 113 code | 14 blank | 19 comment | 13 complexity | 9ec6194199539d7a6a47dd82c9c97701 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * Delete open questions
  4. *
  5. * PHP Version 5.3
  6. *
  7. * This Source Code Form is subject to the terms of the Mozilla Public License,
  8. * v. 2.0. If a copy of the MPL was not distributed with this file, You can
  9. * obtain one at http://mozilla.org/MPL/2.0/.
  10. *
  11. * @category phpMyFAQ
  12. * @package Administration
  13. * @author Thorsten Rinne <thorsten@phpmyfaq.de>
  14. * @copyright 2003-2012 phpMyFAQ Team
  15. * @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
  16. * @link http://www.phpmyfaq.de
  17. * @since 2003-02-24
  18. */
  19. if (!defined('IS_VALID_PHPMYFAQ')) {
  20. header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']));
  21. exit();
  22. }
  23. printf("<header><h2>%s</h2></header>", $PMF_LANG['msgOpenQuestions']);
  24. if ($permission['delquestion']) {
  25. $category = new PMF_Category($faqConfig, false);
  26. $category->setUser($currentAdminUser);
  27. $category->setGroups($currentAdminGroups);
  28. $date = new PMF_Date($faqConfig);
  29. $questionId = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
  30. $toggle = PMF_Filter::filterInput(INPUT_GET, 'is_visible', FILTER_SANITIZE_STRING);
  31. if ($toggle == 'toggle') {
  32. $is_visible = $faq->getVisibilityOfQuestion($questionId);
  33. if (!is_null($is_visible)) {
  34. $faq->setVisibilityOfQuestion($questionId, ($is_visible == 'N' ? 'Y' : 'N'));
  35. }
  36. }
  37. print '<div id="returnMessage"></div>';
  38. $openquestions = $faq->getAllOpenQuestions();
  39. if (count($openquestions) > 0) {
  40. ?>
  41. <form id="questionSelection" name="questionSelection" method="post">
  42. <table class="table table-striped">
  43. <thead>
  44. <tr>
  45. <th></th>
  46. <th><?php print $PMF_LANG['ad_entry_author']; ?></th>
  47. <th><?php print $PMF_LANG['ad_entry_theme']; ?></th>
  48. <th colspan="2"><?php print $PMF_LANG['ad_entry_visibility']; ?>?</th>
  49. </tr>
  50. </thead>
  51. <tbody>
  52. <?php
  53. foreach ($openquestions as $question) {
  54. ?>
  55. <tr>
  56. <td>
  57. <input id="questions[]"
  58. name="questions[]"
  59. value="<?php print $question['id']; ?>" type="checkbox" />
  60. </td>
  61. <td>
  62. <?php print $date->format(PMF_Date::createIsoDate($question['created'])); ?>
  63. <br />
  64. <a href="mailto:<?php print $question['email']; ?>">
  65. <?php print $question['username']; ?>
  66. </a>
  67. </td>
  68. <td>
  69. <strong><?php print $category->categoryName[$question['category_id']]['name'] ?></strong>
  70. <br />
  71. <?php print $question['question'] ?>
  72. </td>
  73. <td>
  74. <a href="?action=question&amp;id=<?php print $question['id']; ?>&amp;is_visible=toggle"
  75. class="btn btn-info">
  76. <?php print ('Y' == $question['is_visible']) ? $PMF_LANG['ad_gen_no'] : $PMF_LANG['ad_gen_yes']; ?>
  77. </a>
  78. </td>
  79. <td>
  80. <?php if ($faqConfig->get('records.enableCloseQuestion') && $question['answer_id']) { ?>
  81. <a href="?action=editentry&amp;id=<?php print $question['answer_id']; ?>&amp;lang=<?php print $LANGCODE; ?>"
  82. class="btn btn-success">
  83. <?php print $PMF_LANG['msg2answerFAQ']; ?>
  84. </a>
  85. <?php } else { ?>
  86. <a href="?action=takequestion&amp;id=<?php print $question['id']; ?>" class="btn btn-success">
  87. <?php print $PMF_LANG['ad_ques_take']; ?>
  88. </a>
  89. <?php } ?>
  90. </td>
  91. </tr>
  92. <?php
  93. }
  94. ?>
  95. </tbody>
  96. </table>
  97. </form>
  98. <p>
  99. <button class="btn btn-danger" id="submitDeleteQuestions" type="submit">
  100. <?php print $PMF_LANG["ad_entry_delete"]; ?>
  101. </button>
  102. </p>
  103. <script type="text/javascript">
  104. /* <![CDATA[ */
  105. $('#submitDeleteQuestions').click(function() { deleteQuestions(); return false; });
  106. function deleteQuestions()
  107. {
  108. var questions = $('#questionSelection').serialize();
  109. $('#returnMessage').empty();
  110. $.ajax({
  111. type: 'POST',
  112. url: 'index.php?action=ajax&ajax=records&ajaxaction=delete_question',
  113. data: questions,
  114. success: function(msg) {
  115. $('#saving_data_indicator').html('<img src="images/indicator.gif" /> deleting ...');
  116. $('tr td input:checked').parent().parent().fadeOut('slow');
  117. $('#saving_data_indicator').fadeOut('slow');
  118. $('#returnMessage').
  119. html('<p class="alert alert-success">' + msg + '</p>');
  120. }
  121. });
  122. return false;
  123. }
  124. /* ]]> */
  125. </script>
  126. <?php
  127. } else {
  128. print $PMF_LANG['msgNoQuestionsAvailable'];
  129. }
  130. } else {
  131. print $PMF_LANG['err_NotAuth'];
  132. }