PageRenderTime 48ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/phpmyfaq/admin/record.comments.php

https://github.com/cyrke/phpMyFAQ
PHP | 172 lines | 140 code | 13 blank | 19 comment | 12 complexity | 25cf2f832b099f45333732e6c9b96b5c MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * Shows all comments in the categories and provides a link to delete comments
  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 2007-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 2007-03-04
  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>\n", $PMF_LANG['ad_comment_administration']);
  24. print '<div id="returnMessage"></div>';
  25. if ($permission['delcomment']) {
  26. $comment = new PMF_Comment($faqConfig);
  27. $category = new PMF_Category($faqConfig, false);
  28. $category->setUser($currentAdminUser);
  29. $category->setGroups($currentAdminGroups);
  30. $faq = new PMF_Faq($faqConfig);
  31. $date = new PMF_Date($faqConfig);
  32. $category->buildTree();
  33. $faqcomments = $comment->getAllComments('faq');
  34. printf("<header><h3>%s</h3></header>\n", $PMF_LANG['ad_comment_faqs']);
  35. if (count($faqcomments)) {
  36. ?>
  37. <form id="faqCommentSelection" name="faqCommentSelection" method="post">
  38. <input type="hidden" name="ajax" value="comment" />
  39. <input type="hidden" name="ajaxaction" value="delete" />
  40. <table class="table table-striped">
  41. <?php
  42. $lastCommentId = 0;
  43. foreach ($faqcomments as $faqcomment) {
  44. if ($faqcomment['comment_id'] == $lastCommentId) {
  45. continue;
  46. }
  47. ?>
  48. <tr id="comments_<?php print $faqcomment['comment_id']; ?>">
  49. <td width="20">
  50. <input id="faq_comments[<?php print $faqcomment['comment_id']; ?>]"
  51. name="faq_comments[<?php print $faqcomment['comment_id']; ?>]"
  52. value="<?php print $faqcomment['record_id']; ?>" type="checkbox" />
  53. </td>
  54. <td>
  55. <span style="font-weight: bold;">
  56. <a href="mailto:<?php print $faqcomment['email']; ?>">
  57. <?php print $faqcomment['username']; ?>
  58. </a> |
  59. <?php print $date->format(date('Y-m-d H:i', $faqcomment['date'])); ?> |
  60. <a href="<?php printf("../?action=artikel&cat=%d&id=%d&artlang=%s",
  61. $faqcomment['category_id'],
  62. $faqcomment['record_id'],
  63. $LANGCODE); ?>">
  64. <?php print $faq->getRecordTitle($faqcomment['record_id']); ?>
  65. </a>
  66. </span><br/>
  67. <?php print PMF_String::htmlspecialchars($faqcomment['content']); ?>
  68. </td>
  69. </tr>
  70. <?php
  71. $lastCommentId = $faqcomment['comment_id'];
  72. }
  73. ?>
  74. </table>
  75. <p>
  76. <button class="btn btn-danger" id="submitFaqComments" type="submit" name="submit">
  77. <?php print $PMF_LANG["ad_entry_delete"]; ?>
  78. </button>
  79. </p>
  80. </form>
  81. <?php
  82. } else {
  83. print '<p><strong>n/a</strong></p>';
  84. }
  85. $newscomments = $comment->getAllComments('news');
  86. printf("<header><h3>%s</h3></header>\n", $PMF_LANG['ad_comment_news']);
  87. if (count($newscomments)) {
  88. ?>
  89. <form id="newsCommentSelection" name="newsCommentSelection" method="post">
  90. <input type="hidden" name="ajax" value="comment" />
  91. <input type="hidden" name="ajaxaction" value="delete" />
  92. <table class="table table-striped">
  93. <?php
  94. foreach ($newscomments as $newscomment) {
  95. ?>
  96. <tr id="comments_<?php print $newscomment['comment_id']; ?>">
  97. <td width="20">
  98. <input id="news_comments[<?php print $newscomment['comment_id']; ?>]"
  99. name="news_comments[<?php print $newscomment['comment_id']; ?>]"
  100. value="<?php print $newscomment['record_id']; ?>" type="checkbox" />
  101. </td>
  102. <td>
  103. <span style="font-weight: bold;">
  104. <a href="mailto:<?php print $newscomment['email']; ?>">
  105. <?php print $newscomment['username']; ?>
  106. </a>
  107. </span><br/>
  108. <?php print PMF_String::htmlspecialchars($newscomment['content']); ?>
  109. </td>
  110. </tr>
  111. <?php
  112. }
  113. ?>
  114. </table>
  115. <p>
  116. <button class="btn btn-danger" id="submitNewsComments" type="submit" name="submit">
  117. <?php print $PMF_LANG["ad_entry_delete"]; ?>
  118. </button>
  119. </p>
  120. </form>
  121. <?php
  122. } else {
  123. print '<p><strong>n/a</strong></p>';
  124. }
  125. ?>
  126. </form>
  127. <script type="text/javascript">
  128. /* <![CDATA[ */
  129. $('#submitFaqComments').click(function() { deleteComments('faq'); return false; });
  130. $('#submitNewsComments').click(function() { deleteComments('news'); return false; });
  131. function deleteComments(type)
  132. {
  133. var comments = $('#' + type + 'CommentSelection').serialize();
  134. $('#returnMessage').empty();
  135. $.ajax({
  136. type: 'POST',
  137. url: 'index.php?action=ajax&ajax=comment',
  138. data: comments,
  139. success: function(msg) {
  140. if (msg == 1) {
  141. $('#saving_data_indicator').html('<img src="images/indicator.gif" /> deleting ...');
  142. $('tr td input:checked').parent().parent().fadeOut('slow');
  143. $('#saving_data_indicator').fadeOut('slow');
  144. $('#returnMessage').
  145. html('<p class="alert alert-success"><?php print $PMF_LANG['ad_entry_commentdelsuc']; ?></p>');
  146. } else {
  147. $('#returnMessage').
  148. html('<p class="alert alert-error"><?php print $PMF_LANG["ad_entry_commentdelfail"] ?></p>');
  149. }
  150. }
  151. });
  152. return false;
  153. }
  154. /* ]]> */
  155. </script>
  156. <?php
  157. } else {
  158. print $PMF_LANG['err_NotAuth'];
  159. }