Changeset 3725:b47f38c701ee for plugins/antispam
- Timestamp:
- 03/02/18 15:55:06 (7 years ago)
- Branch:
- default
- Location:
- plugins/antispam
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/antispam/_admin.php
r3333 r3725 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_CONTEXT_ADMIN')) { return;}12 if (!defined('DC_CONTEXT_ADMIN')) {return;} 13 13 14 14 if (!defined('DC_ANTISPAM_CONF_SUPER')) { 15 define('DC_ANTISPAM_CONF_SUPER',false);15 define('DC_ANTISPAM_CONF_SUPER', false); 16 16 } 17 17 18 18 $_menu['Plugins']->addItem(__('Antispam'), 19 20 21 preg_match('/'.preg_quote($core->adminurl->get('admin.plugin.antispam')).'(&.*)?$/',$_SERVER['REQUEST_URI']),22 $core->auth->check('admin',$core->blog->id));19 $core->adminurl->get('admin.plugin.antispam'), 20 dcPage::getPF('antispam/icon.png'), 21 preg_match('/' . preg_quote($core->adminurl->get('admin.plugin.antispam')) . '(&.*)?$/', $_SERVER['REQUEST_URI']), 22 $core->auth->check('admin', $core->blog->id)); 23 23 24 $core->addBehavior('coreAfterCommentUpdate', array('dcAntispam','trainFilters'));25 $core->addBehavior('adminAfterCommentDesc', array('dcAntispam','statusMessage'));26 $core->addBehavior('adminDashboardIcons', array('dcAntispam','dashboardIcon'));24 $core->addBehavior('coreAfterCommentUpdate', array('dcAntispam', 'trainFilters')); 25 $core->addBehavior('adminAfterCommentDesc', array('dcAntispam', 'statusMessage')); 26 $core->addBehavior('adminDashboardIcons', array('dcAntispam', 'dashboardIcon')); 27 27 28 $core->addBehavior('adminDashboardFavorites', 'antispamDashboardFavorites');29 $core->addBehavior('adminDashboardFavsIcon', 'antispamDashboardFavsIcon');28 $core->addBehavior('adminDashboardFavorites', 'antispamDashboardFavorites'); 29 $core->addBehavior('adminDashboardFavsIcon', 'antispamDashboardFavsIcon'); 30 30 31 function antispamDashboardFavorites($core, $favs)31 function antispamDashboardFavorites($core, $favs) 32 32 { 33 34 'title'=> __('Antispam'),35 'url'=> $core->adminurl->get('admin.plugin.antispam'),36 'small-icon'=> dcPage::getPF('antispam/icon.png'),37 'large-icon'=> dcPage::getPF('antispam/icon-big.png'),38 39 33 $favs->register('antispam', array( 34 'title' => __('Antispam'), 35 'url' => $core->adminurl->get('admin.plugin.antispam'), 36 'small-icon' => dcPage::getPF('antispam/icon.png'), 37 'large-icon' => dcPage::getPF('antispam/icon-big.png'), 38 'permissions' => 'admin') 39 ); 40 40 } 41 41 42 function antispamDashboardFavsIcon($core, $name,$icon)42 function antispamDashboardFavsIcon($core, $name, $icon) 43 43 { 44 45 46 47 48 49 50 51 44 // Check if it is comments favs 45 if ($name == 'comments') { 46 // Hack comments title if there is at least one spam 47 $str = dcAntispam::dashboardIconTitle($core); 48 if ($str != '') { 49 $icon[0] .= $str; 50 } 51 } 52 52 } 53 53 54 54 if (!DC_ANTISPAM_CONF_SUPER || $core->auth->isSuperAdmin()) { 55 $core->addBehavior('adminBlogPreferencesForm',array('antispamBehaviors','adminBlogPreferencesForm'));56 $core->addBehavior('adminBeforeBlogSettingsUpdate',array('antispamBehaviors','adminBeforeBlogSettingsUpdate'));57 $core->addBehavior('adminCommentsSpamForm',array('antispamBehaviors','adminCommentsSpamForm'));58 $core->addBehavior('adminPageHelpBlock',array('antispamBehaviors','adminPageHelpBlock'));55 $core->addBehavior('adminBlogPreferencesForm', array('antispamBehaviors', 'adminBlogPreferencesForm')); 56 $core->addBehavior('adminBeforeBlogSettingsUpdate', array('antispamBehaviors', 'adminBeforeBlogSettingsUpdate')); 57 $core->addBehavior('adminCommentsSpamForm', array('antispamBehaviors', 'adminCommentsSpamForm')); 58 $core->addBehavior('adminPageHelpBlock', array('antispamBehaviors', 'adminPageHelpBlock')); 59 59 } 60 60 61 61 class antispamBehaviors 62 62 { 63 64 65 66 foreach($blocks as $block) {67 68 69 70 71 72 73 return null;74 75 76 63 public static function adminPageHelpBlock($blocks) 64 { 65 $found = false; 66 foreach ($blocks as $block) { 67 if ($block == 'core_comments') { 68 $found = true; 69 break; 70 } 71 } 72 if (!$found) { 73 return; 74 } 75 $blocks[] = 'antispam_comments'; 76 } 77 77 78 79 80 81 if ($ttl != null && $ttl >=0) {82 echo '<p>'.sprintf(__('All spam comments older than %s day(s) will be automatically deleted.'), $ttl).' '.83 sprintf(__('You can modify this duration in the %s'),'<a href="'.$core->adminurl->get('admin.blog.pref').84 '#antispam_moderation_ttl"> '.__('Blog settings').'</a>').85 86 87 78 public static function adminCommentsSpamForm($core) 79 { 80 $ttl = $core->blog->settings->antispam->antispam_moderation_ttl; 81 if ($ttl != null && $ttl >= 0) { 82 echo '<p>' . sprintf(__('All spam comments older than %s day(s) will be automatically deleted.'), $ttl) . ' ' . 83 sprintf(__('You can modify this duration in the %s'), '<a href="' . $core->adminurl->get('admin.blog.pref') . 84 '#antispam_moderation_ttl"> ' . __('Blog settings') . '</a>') . 85 '.</p>'; 86 } 87 } 88 88 89 public static function adminBlogPreferencesForm($core,$settings)90 91 92 93 '<div class="fieldset"><h4 id="antispam_params">Antispam</h4>'.94 '<p><label for="antispam_moderation_ttl" class="classic">'.__('Delete junk comments older than').' '.95 form::field('antispam_moderation_ttl', 3, 3, $ttl).96 ' '.__('days').97 '</label></p>'.98 '<p><a href="'.$core->adminurl->get('admin.plugin.antispam').'">'.__('Set spam filters.').'</a></p>'.99 100 89 public static function adminBlogPreferencesForm($core, $settings) 90 { 91 $ttl = $settings->antispam->antispam_moderation_ttl; 92 echo 93 '<div class="fieldset"><h4 id="antispam_params">Antispam</h4>' . 94 '<p><label for="antispam_moderation_ttl" class="classic">' . __('Delete junk comments older than') . ' ' . 95 form::number('antispam_moderation_ttl', 0, 999, $ttl) . 96 ' ' . __('days') . 97 '</label></p>' . 98 '<p><a href="' . $core->adminurl->get('admin.plugin.antispam') . '">' . __('Set spam filters.') . '</a></p>' . 99 '</div>'; 100 } 101 101 102 103 104 105 $settings->antispam->put('antispam_moderation_ttl',(integer)$_POST['antispam_moderation_ttl']);106 102 public static function adminBeforeBlogSettingsUpdate($settings) 103 { 104 $settings->addNamespace('antispam'); 105 $settings->antispam->put('antispam_moderation_ttl', (integer) $_POST['antispam_moderation_ttl']); 106 } 107 107 } -
plugins/antispam/index.php
r3707 r3725 204 204 echo 205 205 '<tr class="line' . ($f->active ? '' : ' offline') . '" id="f_' . $fid . '">' . 206 '<td class="handle">' . form::field(array('f_order[' . $fid . ']'), 2, 5, (string) $i, 'position', '', false, 'title="' . __('position') . '"') . '</td>' . 206 '<td class="handle">' . form::number(array('f_order[' . $fid . ']'), array( 207 'min' => 0, 208 'default' => $i, 209 'class' => 'position', 210 'extra_html' => 'title="' . __('position') . '"' 211 )) . 212 '</td>' . 207 213 '<td class="nowrap">' . form::checkbox(array('filters_active[]'), $fid, 208 214 array(
Note: See TracChangeset
for help on using the changeset viewer.