| 1 | <?php | 
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- | 
|---|
| 3 | # | 
|---|
| 4 | # This file is part of Dotclear 2. | 
|---|
| 5 | # | 
|---|
| 6 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear | 
|---|
| 7 | # Licensed under the GPL version 2.0 license. | 
|---|
| 8 | # See LICENSE file or | 
|---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | 
|---|
| 10 | # | 
|---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- | 
|---|
| 12 |  | 
|---|
| 13 | require dirname(__FILE__).'/../inc/admin/prepend.php'; | 
|---|
| 14 |  | 
|---|
| 15 | dcPage::check('usage,contentadmin'); | 
|---|
| 16 |  | 
|---|
| 17 | $params = array(); | 
|---|
| 18 | $redir = 'comments.php'; | 
|---|
| 19 |  | 
|---|
| 20 | if (!empty($_POST['action']) && !empty($_POST['comments'])) | 
|---|
| 21 | { | 
|---|
| 22 |      $comments = $_POST['comments']; | 
|---|
| 23 |      $action = $_POST['action']; | 
|---|
| 24 |       | 
|---|
| 25 |      if (isset($_POST['redir']) && strpos($_POST['redir'],'://') === false) | 
|---|
| 26 |      { | 
|---|
| 27 |           $redir = $_POST['redir']; | 
|---|
| 28 |      } | 
|---|
| 29 |      else | 
|---|
| 30 |      { | 
|---|
| 31 |           $redir = | 
|---|
| 32 |           'comments.php?type='.$_POST['type']. | 
|---|
| 33 |           '&author='.$_POST['author']. | 
|---|
| 34 |           '&status='.$_POST['status']. | 
|---|
| 35 |           '&sortby='.$_POST['sortby']. | 
|---|
| 36 |           '&ip='.$_POST['ip']. | 
|---|
| 37 |           '&order='.$_POST['order']. | 
|---|
| 38 |           '&page='.$_POST['page']. | 
|---|
| 39 |           '&nb='.(integer) $_POST['nb']; | 
|---|
| 40 |      } | 
|---|
| 41 |       | 
|---|
| 42 |      foreach ($comments as $k => $v) { | 
|---|
| 43 |           $comments[$k] = (integer) $v; | 
|---|
| 44 |      } | 
|---|
| 45 |       | 
|---|
| 46 |      $params['sql'] = 'AND C.comment_id IN('.implode(',',$comments).') '; | 
|---|
| 47 |       | 
|---|
| 48 |      if (!isset($_POST['full_content']) || empty($_POST['full_content'])) { | 
|---|
| 49 |           $params['no_content'] = true; | 
|---|
| 50 |      } | 
|---|
| 51 |       | 
|---|
| 52 |      $co = $core->blog->getComments($params); | 
|---|
| 53 |       | 
|---|
| 54 |      $co_ids = array(); | 
|---|
| 55 |      while ($co->fetch())     { | 
|---|
| 56 |           $co_ids[] = $co->comment_id; | 
|---|
| 57 |      } | 
|---|
| 58 |       | 
|---|
| 59 |      # --BEHAVIOR-- adminCommentsActions | 
|---|
| 60 |      $core->callBehavior('adminCommentsActions',$core,$co,$action,$redir); | 
|---|
| 61 |       | 
|---|
| 62 |      if (preg_match('/^(publish|unpublish|pending|junk)$/',$action)) | 
|---|
| 63 |      { | 
|---|
| 64 |           switch ($action) { | 
|---|
| 65 |                case 'unpublish' : $status = 0; break; | 
|---|
| 66 |                case 'pending' : $status = -1; break; | 
|---|
| 67 |                case 'junk' : $status = -2; break; | 
|---|
| 68 |                default : $status = 1; break; | 
|---|
| 69 |           } | 
|---|
| 70 |            | 
|---|
| 71 |           try { | 
|---|
| 72 |                $core->blog->updCommentsStatus($co_ids,$status); | 
|---|
| 73 |           } catch (Exception $e) { | 
|---|
| 74 |                $core->error->add($e->getMessage()); | 
|---|
| 75 |           } | 
|---|
| 76 |            | 
|---|
| 77 |           if (!$core->error->flag()) { | 
|---|
| 78 |                http::redirect($redir); | 
|---|
| 79 |           } | 
|---|
| 80 |      } | 
|---|
| 81 |      elseif ($action == 'delete') | 
|---|
| 82 |      { | 
|---|
| 83 |           try { | 
|---|
| 84 |                // Backward compatibility | 
|---|
| 85 |                foreach($co_ids as $comment_id) | 
|---|
| 86 |                { | 
|---|
| 87 |                     # --BEHAVIOR-- adminBeforeCommentDelete | 
|---|
| 88 |                     $core->callBehavior('adminBeforeCommentDelete',$comment_id);                     | 
|---|
| 89 |                } | 
|---|
| 90 |                 | 
|---|
| 91 |                # --BEHAVIOR-- adminBeforeCommentsDelete | 
|---|
| 92 |                $core->callBehavior('adminBeforeCommentsDelete',$co_ids); | 
|---|
| 93 |                 | 
|---|
| 94 |                $core->blog->delComments($co_ids); | 
|---|
| 95 |           } catch (Exception $e) { | 
|---|
| 96 |                $core->error->add($e->getMessage()); | 
|---|
| 97 |           } | 
|---|
| 98 |            | 
|---|
| 99 |           if (!$core->error->flag()) { | 
|---|
| 100 |                http::redirect($redir); | 
|---|
| 101 |           } | 
|---|
| 102 |      } | 
|---|
| 103 | } | 
|---|
| 104 |  | 
|---|
| 105 | /* DISPLAY | 
|---|
| 106 | -------------------------------------------------------- */ | 
|---|
| 107 | dcPage::open(__('Comments')); | 
|---|
| 108 |  | 
|---|
| 109 | if (!isset($action)) { | 
|---|
| 110 |      dcPage::close(); | 
|---|
| 111 |      exit; | 
|---|
| 112 | } | 
|---|
| 113 |  | 
|---|
| 114 | $hidden_fields = ''; | 
|---|
| 115 | while ($co->fetch()) { | 
|---|
| 116 |      $hidden_fields .= form::hidden(array('comments[]'),$co->comment_id); | 
|---|
| 117 | }  | 
|---|
| 118 |  | 
|---|
| 119 | if (isset($_POST['redir']) && strpos($_POST['redir'],'://') === false) | 
|---|
| 120 | { | 
|---|
| 121 |      $hidden_fields .= form::hidden(array('redir'),html::escapeURL($_POST['redir'])); | 
|---|
| 122 | } | 
|---|
| 123 | else | 
|---|
| 124 | { | 
|---|
| 125 |      $hidden_fields .= | 
|---|
| 126 |      form::hidden(array('type'),$_POST['type']). | 
|---|
| 127 |      form::hidden(array('author'),$_POST['author']). | 
|---|
| 128 |      form::hidden(array('status'),$_POST['status']). | 
|---|
| 129 |      form::hidden(array('sortby'),$_POST['sortby']). | 
|---|
| 130 |      form::hidden(array('ip'),$_POST['ip']). | 
|---|
| 131 |      form::hidden(array('order'),$_POST['order']). | 
|---|
| 132 |      form::hidden(array('page'),$_POST['page']). | 
|---|
| 133 |      form::hidden(array('nb'),$_POST['nb']); | 
|---|
| 134 | } | 
|---|
| 135 |  | 
|---|
| 136 | # --BEHAVIOR-- adminCommentsActionsContent | 
|---|
| 137 | $core->callBehavior('adminCommentsActionsContent',$core,$action,$hidden_fields); | 
|---|
| 138 |  | 
|---|
| 139 | echo '<p><a class="back" href="'.str_replace('&','&',$redir).'">'.__('back').'</a></p>'; | 
|---|
| 140 |  | 
|---|
| 141 | dcPage::close(); | 
|---|
| 142 | ?> | 
|---|