Changeset 1052:de274bbd7b80
- Timestamp:
- 12/03/12 14:14:58 (13 years ago)
- Branch:
- default
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/comments.php
r1051 r1052 15 15 dcPage::check('usage,contentadmin'); 16 16 17 if (!empty($_POST['delete_all_spam'])) 18 { 19 try { 20 $core->blog->delJunkComments(); 21 http::redirect('comments.php?delspam=1'); 22 } catch (Exception $e) { 23 $core->error->add($e->getMessage()); 24 } 25 } 26 17 27 # Creating filter combo boxes 18 28 # Filter form we'll put in html_block … … 164 174 if (!$core->error->flag()) 165 175 { 176 if (!empty($_GET['delspam'])) { 177 dcPage::message(__('Spam comments have been successfully deleted.')); 178 } 179 166 180 # Filters 167 181 if (!$show_filters) { … … 210 224 211 225 if (!$with_spam) { 226 212 227 $spam_count = $core->blog->getComments(array('comment_status'=>-2),true)->f(0); 213 214 if (!empty($_GET['delspam'])) {215 dcPage::message(__('Spam comments have been successfully deleted.'));216 }217 228 218 229 if ($spam_count > 0) { 219 230 220 if ($core->plugins->moduleExists('antispam')) { 221 echo 222 '<form action="plugin.php?p=antispam" method="post" class="fieldset">'; 223 } 231 echo 232 '<form action="comments.php" method="post" class="fieldset">'; 224 233 225 234 if ($spam_count == 1) { … … 231 240 } 232 241 233 if ($core->plugins->moduleExists('antispam')) { 234 235 $moderationTTL = $core->blog->settings->antispam->antispam_moderation_ttl; 236 $spam_redir = 237 'comments.php?type='.$type. 238 '&author='.preg_replace('/%/','%%',$author). 239 '&status='.$status. 240 '&sortby='.$sortby. 241 '&ip='.preg_replace('/%/','%%',$ip). 242 '&order='.$order. 243 '&page='.$page. 244 '&nb='.$nb_per_page; 245 246 echo 242 echo 247 243 $core->formNonce(). 248 form::hidden('ts',time()).249 form::hidden('redir',$spam_redir).250 244 '<input name="delete_all_spam" class="delete" type="submit" value="'.__('Delete all spams').'" /></p>'; 251 245 252 if ($moderationTTL != null && $moderationTTL >=0) { 253 echo '<p>'.sprintf(__('All spam comments older than %s day(s) will be automatically deleted.'), $moderationTTL).' '. 254 sprintf(__('You can modify this duration in the %s'),'<a href="blog_pref.php"> '.__('Blog preferences').'</a>'). 255 '</p>'; 256 } 257 258 echo '</form>'; 259 } 246 # --BEHAVIOR-- adminCommentsSpamForm 247 $core->callBehavior('adminCommentsSpamForm',$core); 248 249 echo '</form>'; 260 250 } 261 251 } -
inc/core/class.dc.blog.php
r1042 r1052 2215 2215 $this->triggerBlog(); 2216 2216 } 2217 2218 public function delJunkComments() 2219 { 2220 if (!$this->core->auth->check('delete,contentadmin',$this->id)) { 2221 throw new Exception(__('You are not allowed to delete comments')); 2222 } 2223 2224 # mySQL uses "INNER JOIN" synthax 2225 if ($this->con->driver() == 'mysql') { 2226 $strReq = 2227 'DELETE FROM tc '. 2228 'USING '.$this->prefix.'comment tc '. 2229 'INNER JOIN '.$this->prefix.'post tp '; 2230 } 2231 # pgSQL uses nothing special 2232 else { 2233 $strReq = 2234 'DELETE FROM '.$this->prefix.'comment tc '. 2235 'USING '.$this->prefix.'post tp '; 2236 } 2237 2238 $strReq .= 2239 'WHERE tc.post_id = tp.post_id '. 2240 "AND tp.blog_id = '".$this->con->escape($this->id)."' ". 2241 'AND comment_status = -2'; 2242 2243 #If user can only delete, we need to check the post's owner 2244 if (!$this->core->auth->check('contentadmin',$this->id)) 2245 { 2246 $strReq .= 2247 "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 2248 } 2249 2250 $this->con->execute($strReq); 2251 $this->triggerBlog(); 2252 } 2217 2253 2218 2254 private function getCommentCursor($cur) -
plugins/antispam/_admin.php
r324 r1052 49 49 $core->addBehavior('adminBlogPreferencesForm',array('antispamBehaviors','adminBlogPreferencesForm')); 50 50 $core->addBehavior('adminBeforeBlogSettingsUpdate',array('antispamBehaviors','adminBeforeBlogSettingsUpdate')); 51 $core->addBehavior('adminCommentsSpamForm',array('antispamBehaviors','adminCommentsSpamForm')); 51 52 } 52 53 53 54 class antispamBehaviors 54 55 { 56 public static function adminCommentsSpamForm($core) 57 { 58 $ttl = $core->blog->settings->antispam->antispam_moderation_ttl; 59 if ($ttl != null && $ttl >=0) { 60 echo '<p>'.sprintf(__('All spam comments older than %s day(s) will be automatically deleted.'), $ttl).' '. 61 sprintf(__('You can modify this duration in the %s'),'<a href="blog_pref.php"> '.__('Blog preferences').'</a>'). 62 '</p>'; 63 } 64 } 65 55 66 public static function adminBlogPreferencesForm($core,$settings) 56 67 { -
plugins/antispam/antispam.js
r1049 r1052 4 4 dragsort.makeTableSortable(this,dotclear.sortable.setHandle, dotclear.sortable.saveOrder); 5 5 }); 6 $('form input[type=submit][name=delete_all _spam]').click(function(){6 $('form input[type=submit][name=delete_all]').click(function(){ 7 7 return window.confirm(dotclear.msg.confirm_spam_delete); 8 8 }); -
plugins/antispam/index.php
r1049 r1052 20 20 $default_tab = null; 21 21 22 $redir = isset($_POST['redir']) && strpos($_POST['redir'],'://') === false ?23 $_POST['redir'] : $p_url;24 25 22 try 26 23 { … … 41 38 42 39 # Remove all spam 43 if (!empty($_POST['delete_all _spam']))40 if (!empty($_POST['delete_all'])) 44 41 { 45 42 $ts = dt::str('%Y-%m-%d %H:%M:%S',$_POST['ts'],$core->blog->settings->system->blog_timezone); 46 43 47 44 dcAntispam::delAllSpam($core,$ts); 48 http::redirect($ redir.'&delspam=1');45 http::redirect($p_url.'&del=1'); 49 46 } 50 47 … … 141 138 '<h3>'.__('Information').'</h3>'; 142 139 143 if (!empty($_GET['del spam'])) {140 if (!empty($_GET['del'])) { 144 141 dcPage::message(__('Spam comments have been successfully deleted.')); 145 142 } … … 158 155 '<p>'.$core->formNonce(). 159 156 form::hidden('ts',time()). 160 '<input name="delete_all _spam" class="delete" type="submit" value="'.__('Delete all spams').'" /></p>';157 '<input name="delete_all" class="delete" type="submit" value="'.__('Delete all spams').'" /></p>'; 161 158 } 162 159 if ($moderationTTL != null && $moderationTTL >=0) {
Note: See TracChangeset
for help on using the changeset viewer.