[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; |
---|
[2852] | 22 | $core->adminurl->redirect("admin.comments"); |
---|
[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 |
---|
[1719] | 30 | $status_combo = array_merge( |
---|
| 31 | array('-' => ''), |
---|
| 32 | dcAdminCombos::getCommentStatusescombo() |
---|
[0] | 33 | ); |
---|
[1719] | 34 | |
---|
[0] | 35 | |
---|
| 36 | $type_combo = array( |
---|
| 37 | '-' => '', |
---|
[1480] | 38 | __('Comment') => 'co', |
---|
| 39 | __('Trackback') => 'tb' |
---|
[0] | 40 | ); |
---|
| 41 | |
---|
| 42 | $sortby_combo = array( |
---|
| 43 | __('Date') => 'comment_dt', |
---|
| 44 | __('Entry title') => 'post_title', |
---|
[3342] | 45 | __('Entry date') => 'post_dt', |
---|
[0] | 46 | __('Author') => 'comment_author', |
---|
| 47 | __('Status') => 'comment_status' |
---|
| 48 | ); |
---|
| 49 | |
---|
[3360] | 50 | $sortby_lex = array( |
---|
| 51 | // key in sorty_combo (see above) => field in SQL request |
---|
| 52 | 'post_title' => 'post_title', |
---|
| 53 | 'comment_author' => 'comment_author', |
---|
| 54 | 'comment_spam_filter' => 'comment_spam_filter'); |
---|
| 55 | |
---|
[0] | 56 | $order_combo = array( |
---|
| 57 | __('Descending') => 'desc', |
---|
| 58 | __('Ascending') => 'asc' |
---|
| 59 | ); |
---|
| 60 | |
---|
| 61 | /* Get comments |
---|
| 62 | -------------------------------------------------------- */ |
---|
[3263] | 63 | $author = isset($_GET['author']) ? $_GET['author'] : ''; |
---|
| 64 | $status = isset($_GET['status']) ? $_GET['status'] : ''; |
---|
| 65 | $type = !empty($_GET['type']) ? $_GET['type'] : ''; |
---|
| 66 | $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'comment_dt'; |
---|
| 67 | $order = !empty($_GET['order']) ? $_GET['order'] : 'desc'; |
---|
| 68 | $ip = !empty($_GET['ip']) ? $_GET['ip'] : ''; |
---|
| 69 | $email = !empty($_GET['email']) ? $_GET['email'] : ''; |
---|
| 70 | $site = !empty($_GET['site']) ? $_GET['site'] : ''; |
---|
[0] | 71 | |
---|
| 72 | $with_spam = $author || $status || $type || $sortby != 'comment_dt' || $order != 'desc' || $ip; |
---|
| 73 | |
---|
| 74 | $show_filters = false; |
---|
| 75 | |
---|
[2888] | 76 | $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; |
---|
[0] | 77 | $nb_per_page = 30; |
---|
| 78 | |
---|
[2888] | 79 | if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { |
---|
[3649] | 80 | if ($nb_per_page != (integer) $_GET['nb']) { |
---|
[0] | 81 | $show_filters = true; |
---|
| 82 | } |
---|
[2888] | 83 | $nb_per_page = (integer) $_GET['nb']; |
---|
[0] | 84 | } |
---|
| 85 | |
---|
| 86 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
| 87 | $params['no_content'] = true; |
---|
| 88 | |
---|
| 89 | # Author filter |
---|
| 90 | if ($author !== '') { |
---|
| 91 | $params['q_author'] = $author; |
---|
| 92 | $show_filters = true; |
---|
[796] | 93 | } else { |
---|
| 94 | $author=''; |
---|
[0] | 95 | } |
---|
| 96 | |
---|
| 97 | # - Type filter |
---|
| 98 | if ($type == 'tb' || $type == 'co') { |
---|
| 99 | $params['comment_trackback'] = ($type == 'tb'); |
---|
| 100 | $show_filters = true; |
---|
[796] | 101 | } else { |
---|
| 102 | $type=''; |
---|
[0] | 103 | } |
---|
| 104 | |
---|
| 105 | # - Status filter |
---|
| 106 | if ($status !== '' && in_array($status,$status_combo)) { |
---|
| 107 | $params['comment_status'] = $status; |
---|
| 108 | $show_filters = true; |
---|
| 109 | } elseif (!$with_spam) { |
---|
| 110 | $params['comment_status_not'] = -2; |
---|
[796] | 111 | $status=''; |
---|
| 112 | } else { |
---|
| 113 | $status=''; |
---|
[0] | 114 | } |
---|
| 115 | |
---|
| 116 | # - IP filter |
---|
| 117 | if ($ip) { |
---|
| 118 | $params['comment_ip'] = $ip; |
---|
| 119 | $show_filters = true; |
---|
| 120 | } |
---|
| 121 | |
---|
[3263] | 122 | # - email filter |
---|
| 123 | if ($email) { |
---|
| 124 | $params['comment_email'] = $email; |
---|
| 125 | $show_filters = true; |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | # - site filter |
---|
| 129 | if ($site) { |
---|
| 130 | $params['comment_site'] = $site; |
---|
| 131 | $show_filters = true; |
---|
| 132 | } |
---|
| 133 | |
---|
[3044] | 134 | // Add some sort order if spams displayed |
---|
| 135 | if ($with_spam || ($status == -2)) { |
---|
| 136 | $sortby_combo[__('IP')] = 'comment_ip'; |
---|
| 137 | $sortby_combo[__('Spam filter')] = 'comment_spam_filter'; |
---|
| 138 | } |
---|
| 139 | |
---|
[0] | 140 | # Sortby and order filter |
---|
| 141 | if ($sortby !== '' && in_array($sortby,$sortby_combo)) { |
---|
[3360] | 142 | if (array_key_exists($sortby,$sortby_lex)) { |
---|
| 143 | $params['order'] = $core->con->lexFields($sortby_lex[$sortby]); |
---|
| 144 | } else { |
---|
| 145 | $params['order'] = $sortby; |
---|
| 146 | } |
---|
[0] | 147 | if ($order !== '' && in_array($order,$order_combo)) { |
---|
[3360] | 148 | $params['order'] .= ' '.$order; |
---|
[796] | 149 | } else { |
---|
| 150 | $order = 'desc'; |
---|
[0] | 151 | } |
---|
[2566] | 152 | |
---|
[0] | 153 | if ($sortby != 'comment_dt' || $order != 'desc') { |
---|
| 154 | $show_filters = true; |
---|
| 155 | } |
---|
[796] | 156 | } else { |
---|
| 157 | $sortby = 'comment_dt'; |
---|
| 158 | $order = 'desc'; |
---|
[0] | 159 | } |
---|
| 160 | |
---|
| 161 | # Actions combo box |
---|
| 162 | $combo_action = array(); |
---|
[476] | 163 | $default = ''; |
---|
[1905] | 164 | if ($core->auth->check('delete,contentadmin',$core->blog->id) && $status == -2) |
---|
[0] | 165 | { |
---|
[1905] | 166 | $default = 'delete'; |
---|
[0] | 167 | } |
---|
| 168 | |
---|
[2888] | 169 | $comments_actions_page = new dcCommentsActionsPage($core,$core->adminurl->get("admin.comments")); |
---|
[1905] | 170 | |
---|
[2498] | 171 | if ($comments_actions_page->process()) { |
---|
| 172 | return; |
---|
| 173 | } |
---|
[0] | 174 | |
---|
| 175 | /* Get comments |
---|
| 176 | -------------------------------------------------------- */ |
---|
| 177 | try { |
---|
| 178 | $comments = $core->blog->getComments($params); |
---|
| 179 | $counter = $core->blog->getComments($params,true); |
---|
| 180 | $comment_list = new adminCommentList($core,$comments,$counter->f(0)); |
---|
| 181 | } catch (Exception $e) { |
---|
| 182 | $core->error->add($e->getMessage()); |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | /* DISPLAY |
---|
| 186 | -------------------------------------------------------- */ |
---|
[2136] | 187 | |
---|
[3397] | 188 | dcPage::open(__('Comments and trackbacks'), |
---|
| 189 | dcPage::jsLoad('js/_comments.js').dcPage::jsFilterControl($show_filters), |
---|
[1358] | 190 | dcPage::breadcrumb( |
---|
| 191 | array( |
---|
| 192 | html::escapeHTML($core->blog->name) => '', |
---|
[2166] | 193 | __('Comments and trackbacks') => '' |
---|
[1358] | 194 | )) |
---|
| 195 | ); |
---|
[2888] | 196 | if (!empty($_GET['upd'])) { |
---|
[1905] | 197 | dcPage::success(__('Selected comments have been successfully updated.')); |
---|
[2888] | 198 | } elseif (!empty($_GET['del'])) { |
---|
[1905] | 199 | dcPage::success(__('Selected comments have been successfully deleted.')); |
---|
| 200 | } |
---|
[0] | 201 | |
---|
| 202 | if (!$core->error->flag()) |
---|
| 203 | { |
---|
[1054] | 204 | if (isset($_SESSION['comments_del_spam'])) { |
---|
[1052] | 205 | dcPage::message(__('Spam comments have been successfully deleted.')); |
---|
[1054] | 206 | unset($_SESSION['comments_del_spam']); |
---|
[1052] | 207 | } |
---|
[2566] | 208 | |
---|
[1143] | 209 | $spam_count = $core->blog->getComments(array('comment_status'=>-2),true)->f(0); |
---|
| 210 | if ($spam_count > 0) { |
---|
[2566] | 211 | |
---|
| 212 | echo |
---|
[2720] | 213 | '<form action="'.$core->adminurl->get("admin.comments").'" method="post" class="fieldset">'; |
---|
[1052] | 214 | |
---|
[1143] | 215 | if (!$with_spam || ($status != -2)) { |
---|
[1049] | 216 | if ($spam_count == 1) { |
---|
[1424] | 217 | echo '<p>'.sprintf(__('You have one spam comment.'),'<strong>'.$spam_count.'</strong>').' '. |
---|
[2745] | 218 | '<a href="'.$core->adminurl->get("admin.comments",array('status' => -2)).'">'.__('Show it.').'</a></p>'; |
---|
[1049] | 219 | } elseif ($spam_count > 1) { |
---|
| 220 | echo '<p>'.sprintf(__('You have %s spam comments.'),'<strong>'.$spam_count.'</strong>').' '. |
---|
[2745] | 221 | '<a href="'.$core->adminurl->get("admin.comments",array('status' => -2)).'">'.__('Show them.').'</a></p>'; |
---|
[1049] | 222 | } |
---|
[1143] | 223 | } |
---|
[2566] | 224 | |
---|
[1143] | 225 | echo |
---|
[3053] | 226 | '<p>'. |
---|
[1143] | 227 | $core->formNonce(). |
---|
| 228 | '<input name="delete_all_spam" class="delete" type="submit" value="'.__('Delete all spams').'" /></p>'; |
---|
[1051] | 229 | |
---|
[1143] | 230 | # --BEHAVIOR-- adminCommentsSpamForm |
---|
| 231 | $core->callBehavior('adminCommentsSpamForm',$core); |
---|
[1051] | 232 | |
---|
[1143] | 233 | echo '</form>'; |
---|
[1424] | 234 | } |
---|
[2566] | 235 | |
---|
[1420] | 236 | echo |
---|
[2720] | 237 | '<form action="'.$core->adminurl->get("admin.comments").'" method="get" id="filters-form">'. |
---|
[3397] | 238 | '<h3 class="out-of-screen-if-js">'.__('Show filters and display options').'</h3>'. |
---|
| 239 | |
---|
[1420] | 240 | '<div class="table">'. |
---|
| 241 | '<div class="cell">'. |
---|
[1514] | 242 | '<h4>'.__('Filters').'</h4>'. |
---|
[1420] | 243 | '<p><label for="type" class="ib">'.__('Type:').'</label> '. |
---|
| 244 | form::combo('type',$type_combo,$type).'</p> '. |
---|
| 245 | '<p><label for="status" class="ib">'.__('Status:').'</label> '. |
---|
| 246 | form::combo('status',$status_combo,$status).'</p>'. |
---|
| 247 | '</div>'. |
---|
[2566] | 248 | |
---|
[1514] | 249 | '<div class="cell filters-sibling-cell">'. |
---|
[1420] | 250 | '<p><label for="author" class="ib">'.__('Author:').'</label> '. |
---|
| 251 | form::field('author',20,255,html::escapeHTML($author)).'</p>'. |
---|
| 252 | '<p><label for="ip" class="ib">'.__('IP address:').'</label> '. |
---|
| 253 | form::field('ip',20,39,html::escapeHTML($ip)).'</p>'. |
---|
[3263] | 254 | '<p><label for="email" class="ib">'.__('Email:').'</label> '. |
---|
| 255 | form::field('email',20,255,html::escapeHTML($email)).'</p>'. |
---|
| 256 | '<p><label for="site" class="ib">'.__('Web site:').'</label> '. |
---|
| 257 | form::field('site',20,255,html::escapeHTML($site)).'</p>'. |
---|
[1420] | 258 | '</div>'. |
---|
[2566] | 259 | |
---|
[1420] | 260 | '<div class="cell filters-options">'. |
---|
[1514] | 261 | '<h4>'.__('Display options').'</h4>'. |
---|
[1420] | 262 | '<p><label for="sortby" class="ib">'.__('Order by:').'</label> '. |
---|
| 263 | form::combo('sortby',$sortby_combo,$sortby).'</p>'. |
---|
| 264 | '<p><label for="order" class="ib">'.__('Sort:').'</label> '. |
---|
| 265 | form::combo('order',$order_combo,$order).'</p>'. |
---|
[3091] | 266 | '<p><span class="label ib">'.__('Show').'</span> <label for="nb" class="classic">'. |
---|
[1420] | 267 | form::field('nb',3,3,$nb_per_page).' '. |
---|
| 268 | __('comments per page').'</label></p>'. |
---|
| 269 | '</div>'. |
---|
[2566] | 270 | |
---|
[1420] | 271 | '</div>'. |
---|
[3560] | 272 | '<p><input type="submit" value="'.__('Apply filters and display options').'" />'. |
---|
| 273 | '<br class="clear" /></p>'. //Opera sucks |
---|
[1420] | 274 | '</form>'; |
---|
[2566] | 275 | |
---|
[0] | 276 | # Show comments |
---|
| 277 | $comment_list->display($page,$nb_per_page, |
---|
[2720] | 278 | '<form action="'.$core->adminurl->get("admin.comments").'" method="post" id="form-comments">'. |
---|
[2566] | 279 | |
---|
[0] | 280 | '%s'. |
---|
[2566] | 281 | |
---|
[0] | 282 | '<div class="two-cols">'. |
---|
| 283 | '<p class="col checkboxes-helpers"></p>'. |
---|
[2566] | 284 | |
---|
[96] | 285 | '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. |
---|
[1905] | 286 | form::combo('action',$comments_actions_page->getCombo(),$default,'','','','title="'.__('Actions').'"'). |
---|
[0] | 287 | $core->formNonce(). |
---|
[3182] | 288 | '<input id="do-action" type="submit" value="'.__('ok').'" /></p>'. |
---|
[0] | 289 | form::hidden(array('type'),$type). |
---|
| 290 | form::hidden(array('sortby'),$sortby). |
---|
| 291 | form::hidden(array('order'),$order). |
---|
[3121] | 292 | form::hidden(array('author'),html::escapeHTML(preg_replace('/%/','%%',$author))). |
---|
[0] | 293 | form::hidden(array('status'),$status). |
---|
| 294 | form::hidden(array('ip'),preg_replace('/%/','%%',$ip)). |
---|
| 295 | form::hidden(array('page'),$page). |
---|
| 296 | form::hidden(array('nb'),$nb_per_page). |
---|
[3263] | 297 | form::hidden(array('email'),html::escapeHTML(preg_replace('/%/','%%',$email))). |
---|
| 298 | form::hidden(array('site'),html::escapeHTML(preg_replace('/%/','%%',$site))). |
---|
[0] | 299 | '</div>'. |
---|
[2566] | 300 | |
---|
[2135] | 301 | '</form>', |
---|
[3044] | 302 | $show_filters, |
---|
| 303 | ($with_spam || ($status == -2)) |
---|
[0] | 304 | ); |
---|
| 305 | } |
---|
| 306 | |
---|
| 307 | dcPage::helpBlock('core_comments'); |
---|
| 308 | dcPage::close(); |
---|