[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[0] | 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 | |
---|
[1052] | 17 | if (!empty($_POST['delete_all_spam'])) |
---|
| 18 | { |
---|
| 19 | try { |
---|
| 20 | $core->blog->delJunkComments(); |
---|
[1054] | 21 | $_SESSION['comments_del_spam'] = true; |
---|
| 22 | http::redirect('comments.php'); |
---|
[1052] | 23 | } catch (Exception $e) { |
---|
| 24 | $core->error->add($e->getMessage()); |
---|
| 25 | } |
---|
| 26 | } |
---|
| 27 | |
---|
[0] | 28 | # Creating filter combo boxes |
---|
| 29 | # Filter form we'll put in html_block |
---|
| 30 | $status_combo = array( |
---|
| 31 | '-' => '' |
---|
| 32 | ); |
---|
| 33 | foreach ($core->blog->getAllCommentStatus() as $k => $v) { |
---|
| 34 | $status_combo[$v] = (string) $k; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | $type_combo = array( |
---|
| 38 | '-' => '', |
---|
[1480] | 39 | __('Comment') => 'co', |
---|
| 40 | __('Trackback') => 'tb' |
---|
[0] | 41 | ); |
---|
| 42 | |
---|
| 43 | $sortby_combo = array( |
---|
| 44 | __('Date') => 'comment_dt', |
---|
| 45 | __('Entry title') => 'post_title', |
---|
| 46 | __('Author') => 'comment_author', |
---|
| 47 | __('Status') => 'comment_status' |
---|
| 48 | ); |
---|
| 49 | |
---|
| 50 | $order_combo = array( |
---|
| 51 | __('Descending') => 'desc', |
---|
| 52 | __('Ascending') => 'asc' |
---|
| 53 | ); |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | /* Get comments |
---|
| 57 | -------------------------------------------------------- */ |
---|
[796] | 58 | $author = isset($_GET['author']) ? $_GET['author'] : ''; |
---|
| 59 | $status = isset($_GET['status']) ? $_GET['status'] : ''; |
---|
| 60 | $type = !empty($_GET['type']) ? $_GET['type'] : ''; |
---|
| 61 | $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'comment_dt'; |
---|
| 62 | $order = !empty($_GET['order']) ? $_GET['order'] : 'desc'; |
---|
| 63 | $ip = !empty($_GET['ip']) ? $_GET['ip'] : ''; |
---|
[0] | 64 | |
---|
| 65 | $with_spam = $author || $status || $type || $sortby != 'comment_dt' || $order != 'desc' || $ip; |
---|
| 66 | |
---|
| 67 | $show_filters = false; |
---|
| 68 | |
---|
| 69 | $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; |
---|
| 70 | $nb_per_page = 30; |
---|
| 71 | |
---|
| 72 | if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { |
---|
| 73 | if ($nb_per_page != $_GET['nb']) { |
---|
| 74 | $show_filters = true; |
---|
| 75 | } |
---|
| 76 | $nb_per_page = (integer) $_GET['nb']; |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
| 80 | $params['no_content'] = true; |
---|
| 81 | |
---|
| 82 | # Author filter |
---|
| 83 | if ($author !== '') { |
---|
| 84 | $params['q_author'] = $author; |
---|
| 85 | $show_filters = true; |
---|
[796] | 86 | } else { |
---|
| 87 | $author=''; |
---|
[0] | 88 | } |
---|
| 89 | |
---|
| 90 | # - Type filter |
---|
| 91 | if ($type == 'tb' || $type == 'co') { |
---|
| 92 | $params['comment_trackback'] = ($type == 'tb'); |
---|
| 93 | $show_filters = true; |
---|
[796] | 94 | } else { |
---|
| 95 | $type=''; |
---|
[0] | 96 | } |
---|
| 97 | |
---|
| 98 | # - Status filter |
---|
| 99 | if ($status !== '' && in_array($status,$status_combo)) { |
---|
| 100 | $params['comment_status'] = $status; |
---|
| 101 | $show_filters = true; |
---|
| 102 | } elseif (!$with_spam) { |
---|
| 103 | $params['comment_status_not'] = -2; |
---|
[796] | 104 | $status=''; |
---|
| 105 | } else { |
---|
| 106 | $status=''; |
---|
[0] | 107 | } |
---|
| 108 | |
---|
| 109 | # - IP filter |
---|
| 110 | if ($ip) { |
---|
| 111 | $params['comment_ip'] = $ip; |
---|
| 112 | $show_filters = true; |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | # Sortby and order filter |
---|
| 116 | if ($sortby !== '' && in_array($sortby,$sortby_combo)) { |
---|
| 117 | if ($order !== '' && in_array($order,$order_combo)) { |
---|
| 118 | $params['order'] = $sortby.' '.$order; |
---|
[796] | 119 | } else { |
---|
| 120 | $order = 'desc'; |
---|
[0] | 121 | } |
---|
| 122 | |
---|
| 123 | if ($sortby != 'comment_dt' || $order != 'desc') { |
---|
| 124 | $show_filters = true; |
---|
| 125 | } |
---|
[796] | 126 | } else { |
---|
| 127 | $sortby = 'comment_dt'; |
---|
| 128 | $order = 'desc'; |
---|
[0] | 129 | } |
---|
| 130 | |
---|
| 131 | # Actions combo box |
---|
| 132 | $combo_action = array(); |
---|
[476] | 133 | $default = ''; |
---|
[0] | 134 | if ($core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
| 135 | { |
---|
[1474] | 136 | $combo_action[__('Publish')] = 'publish'; |
---|
| 137 | $combo_action[__('Unpublish')] = 'unpublish'; |
---|
| 138 | $combo_action[__('Mark as pending')] = 'pending'; |
---|
| 139 | $combo_action[__('Mark as junk')] = 'junk'; |
---|
[0] | 140 | } |
---|
| 141 | if ($core->auth->check('delete,contentadmin',$core->blog->id)) |
---|
| 142 | { |
---|
[747] | 143 | $combo_action[__('Delete')] = 'delete'; |
---|
[476] | 144 | if ($status == -2) { |
---|
| 145 | $default = 'delete'; |
---|
| 146 | } |
---|
[0] | 147 | } |
---|
| 148 | |
---|
| 149 | # --BEHAVIOR-- adminCommentsActionsCombo |
---|
| 150 | $core->callBehavior('adminCommentsActionsCombo',array(&$combo_action)); |
---|
| 151 | |
---|
| 152 | /* Get comments |
---|
| 153 | -------------------------------------------------------- */ |
---|
| 154 | try { |
---|
| 155 | $comments = $core->blog->getComments($params); |
---|
| 156 | $counter = $core->blog->getComments($params,true); |
---|
| 157 | $comment_list = new adminCommentList($core,$comments,$counter->f(0)); |
---|
| 158 | } catch (Exception $e) { |
---|
| 159 | $core->error->add($e->getMessage()); |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | /* DISPLAY |
---|
| 163 | -------------------------------------------------------- */ |
---|
| 164 | $starting_script = dcPage::jsLoad('js/_comments.js'); |
---|
| 165 | if (!$show_filters) { |
---|
| 166 | $starting_script .= dcPage::jsLoad('js/filter-controls.js'); |
---|
| 167 | } |
---|
| 168 | # --BEHAVIOR-- adminCommentsHeaders |
---|
| 169 | $starting_script .= $core->callBehavior('adminCommentsHeaders'); |
---|
| 170 | |
---|
[1358] | 171 | dcPage::open(__('Comments and trackbacks'),$starting_script, |
---|
| 172 | dcPage::breadcrumb( |
---|
| 173 | array( |
---|
| 174 | html::escapeHTML($core->blog->name) => '', |
---|
| 175 | '<span class="page-title">'.__('Comments and trackbacks').'</span>' => '' |
---|
| 176 | )) |
---|
| 177 | ); |
---|
[0] | 178 | |
---|
| 179 | if (!$core->error->flag()) |
---|
| 180 | { |
---|
[1054] | 181 | if (isset($_SESSION['comments_del_spam'])) { |
---|
[1052] | 182 | dcPage::message(__('Spam comments have been successfully deleted.')); |
---|
[1054] | 183 | unset($_SESSION['comments_del_spam']); |
---|
[1052] | 184 | } |
---|
| 185 | |
---|
[1143] | 186 | $spam_count = $core->blog->getComments(array('comment_status'=>-2),true)->f(0); |
---|
| 187 | if ($spam_count > 0) { |
---|
| 188 | |
---|
| 189 | echo |
---|
| 190 | '<form action="comments.php" method="post" class="fieldset">'; |
---|
[1052] | 191 | |
---|
[1143] | 192 | if (!$with_spam || ($status != -2)) { |
---|
[1049] | 193 | if ($spam_count == 1) { |
---|
[1424] | 194 | echo '<p>'.sprintf(__('You have one spam comment.'),'<strong>'.$spam_count.'</strong>').' '. |
---|
[1528] | 195 | '<a href="comments.php?status=-2">'.__('Show it.').'</a>.</p>'; |
---|
[1049] | 196 | } elseif ($spam_count > 1) { |
---|
| 197 | echo '<p>'.sprintf(__('You have %s spam comments.'),'<strong>'.$spam_count.'</strong>').' '. |
---|
[1528] | 198 | '<a href="comments.php?status=-2">'.__('Show them.').'</a>.</p>'; |
---|
[1049] | 199 | } |
---|
[1143] | 200 | } |
---|
| 201 | |
---|
| 202 | echo |
---|
[1424] | 203 | '<p class="no-margin">'. |
---|
[1143] | 204 | $core->formNonce(). |
---|
| 205 | '<input name="delete_all_spam" class="delete" type="submit" value="'.__('Delete all spams').'" /></p>'; |
---|
[1051] | 206 | |
---|
[1143] | 207 | # --BEHAVIOR-- adminCommentsSpamForm |
---|
| 208 | $core->callBehavior('adminCommentsSpamForm',$core); |
---|
[1051] | 209 | |
---|
[1143] | 210 | echo '</form>'; |
---|
[1424] | 211 | } |
---|
[1420] | 212 | |
---|
| 213 | # Filters |
---|
| 214 | if (!$show_filters) { |
---|
| 215 | echo '<p><a id="filter-control" class="form-control" href="#">'. |
---|
| 216 | __('Filter comments and trackbacks list').'</a></p>'; |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | echo |
---|
| 220 | '<form action="comments.php" method="get" id="filters-form">'. |
---|
[1514] | 221 | '<h3 class="hidden">'.__('Filter comments and trackbacks list').'</h3>'. |
---|
[1420] | 222 | '<div class="table">'. |
---|
| 223 | |
---|
| 224 | '<div class="cell">'. |
---|
[1514] | 225 | '<h4>'.__('Filters').'</h4>'. |
---|
[1420] | 226 | '<p><label for="type" class="ib">'.__('Type:').'</label> '. |
---|
| 227 | form::combo('type',$type_combo,$type).'</p> '. |
---|
| 228 | '<p><label for="status" class="ib">'.__('Status:').'</label> '. |
---|
| 229 | form::combo('status',$status_combo,$status).'</p>'. |
---|
| 230 | '</div>'. |
---|
| 231 | |
---|
[1514] | 232 | '<div class="cell filters-sibling-cell">'. |
---|
[1420] | 233 | '<p><label for="author" class="ib">'.__('Author:').'</label> '. |
---|
| 234 | form::field('author',20,255,html::escapeHTML($author)).'</p>'. |
---|
| 235 | '<p><label for="ip" class="ib">'.__('IP address:').'</label> '. |
---|
| 236 | form::field('ip',20,39,html::escapeHTML($ip)).'</p>'. |
---|
| 237 | '</div>'. |
---|
| 238 | |
---|
| 239 | '<div class="cell filters-options">'. |
---|
[1514] | 240 | '<h4>'.__('Display options').'</h4>'. |
---|
[1420] | 241 | '<p><label for="sortby" class="ib">'.__('Order by:').'</label> '. |
---|
| 242 | form::combo('sortby',$sortby_combo,$sortby).'</p>'. |
---|
| 243 | '<p><label for="order" class="ib">'.__('Sort:').'</label> '. |
---|
| 244 | form::combo('order',$order_combo,$order).'</p>'. |
---|
| 245 | '<p><span class="label ib">Afficher</span> <label for="nb" class="classic">'. |
---|
| 246 | form::field('nb',3,3,$nb_per_page).' '. |
---|
| 247 | __('comments per page').'</label></p>'. |
---|
| 248 | '</div>'. |
---|
| 249 | |
---|
| 250 | '</div>'. |
---|
[1514] | 251 | '<p><input type="submit" value="'.__('Apply filters and display options').'" />'. |
---|
[1424] | 252 | '<br class="clear" /></p>'. //Opera sucks |
---|
[1420] | 253 | '</form>'; |
---|
| 254 | |
---|
[0] | 255 | # Show comments |
---|
| 256 | $comment_list->display($page,$nb_per_page, |
---|
| 257 | '<form action="comments_actions.php" method="post" id="form-comments">'. |
---|
| 258 | |
---|
| 259 | '%s'. |
---|
| 260 | |
---|
| 261 | '<div class="two-cols">'. |
---|
| 262 | '<p class="col checkboxes-helpers"></p>'. |
---|
| 263 | |
---|
[96] | 264 | '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. |
---|
[1480] | 265 | form::combo('action',$combo_action,$default,'','','','title="'.__('Actions').'"'). |
---|
[0] | 266 | $core->formNonce(). |
---|
| 267 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
| 268 | form::hidden(array('type'),$type). |
---|
| 269 | form::hidden(array('sortby'),$sortby). |
---|
| 270 | form::hidden(array('order'),$order). |
---|
| 271 | form::hidden(array('author'),preg_replace('/%/','%%',$author)). |
---|
| 272 | form::hidden(array('status'),$status). |
---|
| 273 | form::hidden(array('ip'),preg_replace('/%/','%%',$ip)). |
---|
| 274 | form::hidden(array('page'),$page). |
---|
| 275 | form::hidden(array('nb'),$nb_per_page). |
---|
| 276 | '</div>'. |
---|
| 277 | |
---|
| 278 | '</form>' |
---|
| 279 | ); |
---|
| 280 | } |
---|
| 281 | |
---|
| 282 | dcPage::helpBlock('core_comments'); |
---|
| 283 | dcPage::close(); |
---|
[1052] | 284 | ?> |
---|