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