comment.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # This file is part of DotClear.
  4. # Copyright (c) 2004 Olivier Meunier and contributors. All rights
  5. # reserved.
  6. #
  7. # DotClear is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # DotClear is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with DotClear; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. require dirname(__FILE__).'/inc/prepend.php';
  23. $auth->check(1);
  24. include dirname(__FILE__).'/inc/connexion.php';
  25. $err = '';
  26. $is_editable = false;
  27. $comment_id = '';
  28. $comment_dt = '';
  29. $comment_auteur = '';
  30. $comment_email = '';
  31. $comment_site = '';
  32. $comment_content = '';
  33. $comment_pub = '';
  34. $comment_ip = '';
  35. $post_titre = '';
  36. $post_id = '';
  37. $user_id = '';
  38. if (!empty($_REQUEST['comment_id']))
  39. {
  40. $comment = $blog->getComment($_REQUEST['comment_id']);
  41. if ($comment->isEmpty()) {
  42. $err = '<ul><li>'.__('No comment yet.').'</li></ul>';
  43. } else {
  44. $comment_id = $comment->f('comment_id');
  45. $comment_ldate = dt::str(__('On %A %e %B %Y, %I:%M %p'),$comment->getTS());
  46. $comment_auteur = $comment->f('comment_auteur');
  47. $comment_email = $comment->f('comment_email');
  48. $comment_site = $comment->f('comment_site');
  49. $comment_content = $comment->f('comment_content');
  50. $comment_pub = (integer) $comment->f('comment_pub');
  51. $comment_ip = $comment->f('comment_ip');
  52. $post_titre = $comment->f('post_titre');
  53. $post_id = $comment->f('post_id');
  54. if ($comment->f('user_id') == $_SESSION['sess_user_id'] || $_SESSION['sess_user_level'] == 9)
  55. {
  56. $is_editable = true;
  57. }
  58. }
  59. }
  60. # On arrête tout si le commentaire est pas éditable
  61. if (!$is_editable)
  62. {
  63. $err = '<ul><li>'.__('You are not allowed to edit a comment').'</li></ul>';
  64. }
  65. # Modification du commentaire
  66. if (!empty($_POST['update']) && $is_editable)
  67. {
  68. $comment_auteur = $_POST['c_auteur'];
  69. $comment_email = $_POST['c_email'];
  70. $comment_site = preg_replace('|^http://|','',$_POST['c_site']);
  71. $comment_content = $_POST['c_content'];
  72. $comment_pub = $_POST['c_pub'];
  73. if ($blog->updComment($comment_id,$comment_auteur,$comment_email,
  74. $comment_site,$comment_content,$comment_pub) !== false) {
  75. header('Location: poster.php?post_id='.$post_id.'#c'.$comment_id);
  76. exit;
  77. } else {
  78. $err = $blog->error(1);
  79. }
  80. }
  81. # Suppression du commentaire
  82. if (!empty($_POST['delete']) && $is_editable)
  83. {
  84. if ($blog->delComment($comment_id) !== false) {
  85. header('Location: poster.php?post_id='.$post_id.'#comments');
  86. exit;
  87. } else {
  88. $err = $blog->error(1);
  89. }
  90. }
  91. if ($comment_id)
  92. {
  93. $mySubMenu->addItem(
  94. __('XHTML validation'),
  95. array('validpost.php?co_id='.$comment_id,'onclick="popup(this.href); return false;"'),
  96. 'images/ico_ok.png',false);
  97. }
  98. openPage(__('Comment'));
  99. if ($err != '')
  100. {
  101. echo '<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'.
  102. $err.'</div>';
  103. }
  104. if ($is_editable)
  105. {
  106. ?>
  107. <h2><?php echo __('Edit a comment'); ?></h2>
  108. <p><strong><?php echo __('Entry'); ?> :</strong>
  109. <a href="poster.php?post_id=<?php echo $post_id; ?>"><?php echo $post_titre; ?></a></p>
  110. <form action="comment.php" method="post">
  111. <p class="field"><label class="float" for="c_auteur"><?php echo __('Name'); ?>&nbsp;:</label>
  112. <?php echo form::field('c_auteur',30,255,htmlspecialchars($comment_auteur)); ?></p>
  113. <p class="field"><label class="float" for="c_email"><?php echo __('Email'); ?>&nbsp;:</label>
  114. <?php echo form::field('c_email',30,255,htmlspecialchars($comment_email)); ?></p>
  115. <p class="field"><label class="float" for="c_site"><?php echo __('Site'); ?>&nbsp;:</label>
  116. <?php echo form::field('c_site',30,255,'http://'.htmlspecialchars($comment_site)); ?></p>
  117. <p class="field"><span class="label">@IP&nbsp;:</span>
  118. <span><?php echo $comment_ip; ?></span></p>
  119. <p class="field"><span class="label"><?php echo __('Date'); ?>&nbsp;:</span>
  120. <span><?php echo $comment_ldate; ?></span></p>
  121. <p class="field"><label class="float" for=""><?php echo __('Status'); ?>&nbsp;:</label>
  122. <?php echo form::combo('c_pub',array(__('Online')=>'1',__('Offline')=>'0'),$comment_pub); ?>
  123. <p class="field"><label for="c_content"><?php echo __('Comment'); ?>&nbsp;:</label>
  124. <?php echo form::textArea('c_content',40,10,htmlspecialchars($comment_content),'','class="max"'); ?>
  125. </p>
  126. <p class="field"><input type="submit" class="submit" name="update" value="<?php echo __('save'); ?>" />&nbsp;
  127. <input type="submit" class="submit" name="delete" value="<?php echo __('delete'); ?>"
  128. onclick="return window.confirm('<?php echo __('Are you sure you want to delete this comment?'); ?>')" />
  129. <input type="hidden" name="comment_id" id="comment_id"
  130. value="<?php echo $comment_id; ?>" /></p>
  131. </form>
  132. <p><strong><?php echo __('Notice'); ?></strong>&nbsp;:
  133. <?php echo __('This comment has to be in HTML format'); ?></p>
  134. <?php } ?>
  135. <?php closePage(); ?>