[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 |
---|
[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 | |
---|
| 55 | /* Get comments |
---|
| 56 | -------------------------------------------------------- */ |
---|
[796] | 57 | $author = isset($_GET['author']) ? $_GET['author'] : ''; |
---|
| 58 | $status = isset($_GET['status']) ? $_GET['status'] : ''; |
---|
| 59 | $type = !empty($_GET['type']) ? $_GET['type'] : ''; |
---|
| 60 | $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'comment_dt'; |
---|
| 61 | $order = !empty($_GET['order']) ? $_GET['order'] : 'desc'; |
---|
| 62 | $ip = !empty($_GET['ip']) ? $_GET['ip'] : ''; |
---|
[0] | 63 | |
---|
| 64 | $with_spam = $author || $status || $type || $sortby != 'comment_dt' || $order != 'desc' || $ip; |
---|
| 65 | |
---|
| 66 | $show_filters = false; |
---|
| 67 | |
---|
[1912] | 68 | $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; |
---|
[0] | 69 | $nb_per_page = 30; |
---|
| 70 | |
---|
| 71 | if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) { |
---|
| 72 | if ($nb_per_page != $_GET['nb']) { |
---|
| 73 | $show_filters = true; |
---|
| 74 | } |
---|
| 75 | $nb_per_page = (integer) $_GET['nb']; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page); |
---|
| 79 | $params['no_content'] = true; |
---|
| 80 | |
---|
| 81 | # Author filter |
---|
| 82 | if ($author !== '') { |
---|
| 83 | $params['q_author'] = $author; |
---|
| 84 | $show_filters = true; |
---|
[796] | 85 | } else { |
---|
| 86 | $author=''; |
---|
[0] | 87 | } |
---|
| 88 | |
---|
| 89 | # - Type filter |
---|
| 90 | if ($type == 'tb' || $type == 'co') { |
---|
| 91 | $params['comment_trackback'] = ($type == 'tb'); |
---|
| 92 | $show_filters = true; |
---|
[796] | 93 | } else { |
---|
| 94 | $type=''; |
---|
[0] | 95 | } |
---|
| 96 | |
---|
| 97 | # - Status filter |
---|
| 98 | if ($status !== '' && in_array($status,$status_combo)) { |
---|
| 99 | $params['comment_status'] = $status; |
---|
| 100 | $show_filters = true; |
---|
| 101 | } elseif (!$with_spam) { |
---|
| 102 | $params['comment_status_not'] = -2; |
---|
[796] | 103 | $status=''; |
---|
| 104 | } else { |
---|
| 105 | $status=''; |
---|
[0] | 106 | } |
---|
| 107 | |
---|
| 108 | # - IP filter |
---|
| 109 | if ($ip) { |
---|
| 110 | $params['comment_ip'] = $ip; |
---|
| 111 | $show_filters = true; |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | # Sortby and order filter |
---|
| 115 | if ($sortby !== '' && in_array($sortby,$sortby_combo)) { |
---|
| 116 | if ($order !== '' && in_array($order,$order_combo)) { |
---|
| 117 | $params['order'] = $sortby.' '.$order; |
---|
[796] | 118 | } else { |
---|
| 119 | $order = 'desc'; |
---|
[0] | 120 | } |
---|
[2566] | 121 | |
---|
[0] | 122 | if ($sortby != 'comment_dt' || $order != 'desc') { |
---|
| 123 | $show_filters = true; |
---|
| 124 | } |
---|
[796] | 125 | } else { |
---|
| 126 | $sortby = 'comment_dt'; |
---|
| 127 | $order = 'desc'; |
---|
[0] | 128 | } |
---|
| 129 | |
---|
| 130 | # Actions combo box |
---|
| 131 | $combo_action = array(); |
---|
[476] | 132 | $default = ''; |
---|
[1905] | 133 | if ($core->auth->check('delete,contentadmin',$core->blog->id) && $status == -2) |
---|
[0] | 134 | { |
---|
[1905] | 135 | $default = 'delete'; |
---|
[0] | 136 | } |
---|
| 137 | |
---|
[1905] | 138 | $comments_actions_page = new dcCommentsActionsPage($core,'comments.php'); |
---|
| 139 | |
---|
[2498] | 140 | if ($comments_actions_page->process()) { |
---|
| 141 | return; |
---|
| 142 | } |
---|
[0] | 143 | |
---|
| 144 | /* Get comments |
---|
| 145 | -------------------------------------------------------- */ |
---|
| 146 | try { |
---|
| 147 | $comments = $core->blog->getComments($params); |
---|
| 148 | $counter = $core->blog->getComments($params,true); |
---|
| 149 | $comment_list = new adminCommentList($core,$comments,$counter->f(0)); |
---|
| 150 | } catch (Exception $e) { |
---|
| 151 | $core->error->add($e->getMessage()); |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | /* DISPLAY |
---|
| 155 | -------------------------------------------------------- */ |
---|
[2136] | 156 | |
---|
[2145] | 157 | $form_filter_title = __('Show filters and display options'); |
---|
[2135] | 158 | $starting_script = dcPage::jsLoad('js/_comments.js'); |
---|
| 159 | $starting_script .= dcPage::jsLoad('js/filter-controls.js'); |
---|
| 160 | $starting_script .= |
---|
| 161 | '<script type="text/javascript">'."\n". |
---|
| 162 | "//<![CDATA["."\n". |
---|
| 163 | dcPage::jsVar('dotclear.msg.show_filters', $show_filters ? 'true':'false')."\n". |
---|
| 164 | dcPage::jsVar('dotclear.msg.filter_posts_list',$form_filter_title)."\n". |
---|
[2145] | 165 | dcPage::jsVar('dotclear.msg.cancel_the_filter',__('Cancel filters and display options'))."\n". |
---|
[2135] | 166 | "//]]>". |
---|
| 167 | "</script>"; |
---|
| 168 | |
---|
[1358] | 169 | dcPage::open(__('Comments and trackbacks'),$starting_script, |
---|
| 170 | dcPage::breadcrumb( |
---|
| 171 | array( |
---|
| 172 | html::escapeHTML($core->blog->name) => '', |
---|
[2166] | 173 | __('Comments and trackbacks') => '' |
---|
[1358] | 174 | )) |
---|
| 175 | ); |
---|
[1905] | 176 | if (!empty($_GET['upd'])) { |
---|
| 177 | dcPage::success(__('Selected comments have been successfully updated.')); |
---|
| 178 | } elseif (!empty($_GET['del'])) { |
---|
| 179 | dcPage::success(__('Selected comments have been successfully deleted.')); |
---|
| 180 | } |
---|
[0] | 181 | |
---|
| 182 | if (!$core->error->flag()) |
---|
| 183 | { |
---|
[1054] | 184 | if (isset($_SESSION['comments_del_spam'])) { |
---|
[1052] | 185 | dcPage::message(__('Spam comments have been successfully deleted.')); |
---|
[1054] | 186 | unset($_SESSION['comments_del_spam']); |
---|
[1052] | 187 | } |
---|
[2566] | 188 | |
---|
[1143] | 189 | $spam_count = $core->blog->getComments(array('comment_status'=>-2),true)->f(0); |
---|
| 190 | if ($spam_count > 0) { |
---|
[2566] | 191 | |
---|
| 192 | echo |
---|
[1143] | 193 | '<form action="comments.php" method="post" class="fieldset">'; |
---|
[1052] | 194 | |
---|
[1143] | 195 | if (!$with_spam || ($status != -2)) { |
---|
[1049] | 196 | if ($spam_count == 1) { |
---|
[1424] | 197 | echo '<p>'.sprintf(__('You have one spam comment.'),'<strong>'.$spam_count.'</strong>').' '. |
---|
[1528] | 198 | '<a href="comments.php?status=-2">'.__('Show it.').'</a>.</p>'; |
---|
[1049] | 199 | } elseif ($spam_count > 1) { |
---|
| 200 | echo '<p>'.sprintf(__('You have %s spam comments.'),'<strong>'.$spam_count.'</strong>').' '. |
---|
[1528] | 201 | '<a href="comments.php?status=-2">'.__('Show them.').'</a>.</p>'; |
---|
[1049] | 202 | } |
---|
[1143] | 203 | } |
---|
[2566] | 204 | |
---|
[1143] | 205 | echo |
---|
[1424] | 206 | '<p class="no-margin">'. |
---|
[1143] | 207 | $core->formNonce(). |
---|
| 208 | '<input name="delete_all_spam" class="delete" type="submit" value="'.__('Delete all spams').'" /></p>'; |
---|
[1051] | 209 | |
---|
[1143] | 210 | # --BEHAVIOR-- adminCommentsSpamForm |
---|
| 211 | $core->callBehavior('adminCommentsSpamForm',$core); |
---|
[1051] | 212 | |
---|
[1143] | 213 | echo '</form>'; |
---|
[1424] | 214 | } |
---|
[2566] | 215 | |
---|
[1420] | 216 | echo |
---|
| 217 | '<form action="comments.php" method="get" id="filters-form">'. |
---|
[1514] | 218 | '<h3 class="hidden">'.__('Filter comments and trackbacks list').'</h3>'. |
---|
[1420] | 219 | '<div class="table">'. |
---|
| 220 | |
---|
| 221 | '<div class="cell">'. |
---|
[1514] | 222 | '<h4>'.__('Filters').'</h4>'. |
---|
[1420] | 223 | '<p><label for="type" class="ib">'.__('Type:').'</label> '. |
---|
| 224 | form::combo('type',$type_combo,$type).'</p> '. |
---|
| 225 | '<p><label for="status" class="ib">'.__('Status:').'</label> '. |
---|
| 226 | form::combo('status',$status_combo,$status).'</p>'. |
---|
| 227 | '</div>'. |
---|
[2566] | 228 | |
---|
[1514] | 229 | '<div class="cell filters-sibling-cell">'. |
---|
[1420] | 230 | '<p><label for="author" class="ib">'.__('Author:').'</label> '. |
---|
| 231 | form::field('author',20,255,html::escapeHTML($author)).'</p>'. |
---|
| 232 | '<p><label for="ip" class="ib">'.__('IP address:').'</label> '. |
---|
| 233 | form::field('ip',20,39,html::escapeHTML($ip)).'</p>'. |
---|
| 234 | '</div>'. |
---|
[2566] | 235 | |
---|
[1420] | 236 | '<div class="cell filters-options">'. |
---|
[1514] | 237 | '<h4>'.__('Display options').'</h4>'. |
---|
[1420] | 238 | '<p><label for="sortby" class="ib">'.__('Order by:').'</label> '. |
---|
| 239 | form::combo('sortby',$sortby_combo,$sortby).'</p>'. |
---|
| 240 | '<p><label for="order" class="ib">'.__('Sort:').'</label> '. |
---|
| 241 | form::combo('order',$order_combo,$order).'</p>'. |
---|
| 242 | '<p><span class="label ib">Afficher</span> <label for="nb" class="classic">'. |
---|
| 243 | form::field('nb',3,3,$nb_per_page).' '. |
---|
| 244 | __('comments per page').'</label></p>'. |
---|
| 245 | '</div>'. |
---|
[2566] | 246 | |
---|
[1420] | 247 | '</div>'. |
---|
[1514] | 248 | '<p><input type="submit" value="'.__('Apply filters and display options').'" />'. |
---|
[1424] | 249 | '<br class="clear" /></p>'. //Opera sucks |
---|
[1420] | 250 | '</form>'; |
---|
[2566] | 251 | |
---|
[0] | 252 | # Show comments |
---|
| 253 | $comment_list->display($page,$nb_per_page, |
---|
[1905] | 254 | '<form action="comments.php" method="post" id="form-comments">'. |
---|
[2566] | 255 | |
---|
[0] | 256 | '%s'. |
---|
[2566] | 257 | |
---|
[0] | 258 | '<div class="two-cols">'. |
---|
| 259 | '<p class="col checkboxes-helpers"></p>'. |
---|
[2566] | 260 | |
---|
[96] | 261 | '<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '. |
---|
[1905] | 262 | form::combo('action',$comments_actions_page->getCombo(),$default,'','','','title="'.__('Actions').'"'). |
---|
[0] | 263 | $core->formNonce(). |
---|
| 264 | '<input type="submit" value="'.__('ok').'" /></p>'. |
---|
| 265 | form::hidden(array('type'),$type). |
---|
| 266 | form::hidden(array('sortby'),$sortby). |
---|
| 267 | form::hidden(array('order'),$order). |
---|
| 268 | form::hidden(array('author'),preg_replace('/%/','%%',$author)). |
---|
| 269 | form::hidden(array('status'),$status). |
---|
| 270 | form::hidden(array('ip'),preg_replace('/%/','%%',$ip)). |
---|
| 271 | form::hidden(array('page'),$page). |
---|
| 272 | form::hidden(array('nb'),$nb_per_page). |
---|
| 273 | '</div>'. |
---|
[2566] | 274 | |
---|
[2135] | 275 | '</form>', |
---|
| 276 | $show_filters |
---|
[0] | 277 | ); |
---|
| 278 | } |
---|
| 279 | |
---|
| 280 | dcPage::helpBlock('core_comments'); |
---|
| 281 | dcPage::close(); |
---|