| 1 | <?php |
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
|---|
| 3 | # |
|---|
| 4 | # This file is part of Antispam, a plugin for Dotclear 2. |
|---|
| 5 | # |
|---|
| 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
|---|
| 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 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
|---|
| 13 | |
|---|
| 14 | if (!defined('DC_ANTISPAM_CONF_SUPER')) { |
|---|
| 15 | define('DC_ANTISPAM_CONF_SUPER',false); |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | $_menu['Plugins']->addItem(__('Antispam'),'plugin.php?p=antispam','index.php?pf=antispam/icon.png', |
|---|
| 19 | preg_match('/plugin.php\?p=antispam(&.*)?$/',$_SERVER['REQUEST_URI']), |
|---|
| 20 | $core->auth->check('admin',$core->blog->id)); |
|---|
| 21 | |
|---|
| 22 | $core->addBehavior('coreAfterCommentUpdate',array('dcAntispam','trainFilters')); |
|---|
| 23 | $core->addBehavior('adminAfterCommentDesc',array('dcAntispam','statusMessage')); |
|---|
| 24 | $core->addBehavior('adminDashboardIcons',array('dcAntispam','dashboardIcon')); |
|---|
| 25 | |
|---|
| 26 | $core->addBehavior('adminDashboardFavs','antispamDashboardFavs'); |
|---|
| 27 | $core->addBehavior('adminDashboardFavsIcon','antispamDashboardFavsIcon'); |
|---|
| 28 | |
|---|
| 29 | function antispamDashboardFavs($core,$favs) |
|---|
| 30 | { |
|---|
| 31 | $favs['antispam'] = new ArrayObject(array('antispam','Antispam','plugin.php?p=antispam', |
|---|
| 32 | 'index.php?pf=antispam/icon.png','index.php?pf=antispam/icon-big.png', |
|---|
| 33 | 'admin',null,null)); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | function antispamDashboardFavsIcon($core,$name,$icon) |
|---|
| 37 | { |
|---|
| 38 | // Check if it is comments favs |
|---|
| 39 | if ($name == 'comments') { |
|---|
| 40 | // Hack comments title if there is at least one spam |
|---|
| 41 | $str = dcAntispam::dashboardIconTitle($core); |
|---|
| 42 | if ($str != '') { |
|---|
| 43 | $icon[0] .= $str; |
|---|
| 44 | } |
|---|
| 45 | } |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | if (!DC_ANTISPAM_CONF_SUPER || $core->auth->isSuperAdmin()) { |
|---|
| 49 | $core->addBehavior('adminBlogPreferencesForm',array('antispamBehaviors','adminBlogPreferencesForm')); |
|---|
| 50 | $core->addBehavior('adminBeforeBlogSettingsUpdate',array('antispamBehaviors','adminBeforeBlogSettingsUpdate')); |
|---|
| 51 | $core->addBehavior('adminCommentsSpamForm',array('antispamBehaviors','adminCommentsSpamForm')); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | class antispamBehaviors |
|---|
| 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#antispam_moderation_ttl"> '.__('Blog settings').'</a>'). |
|---|
| 62 | '.</p>'; |
|---|
| 63 | } |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | public static function adminBlogPreferencesForm($core,$settings) |
|---|
| 67 | { |
|---|
| 68 | $ttl = $settings->antispam->antispam_moderation_ttl; |
|---|
| 69 | echo |
|---|
| 70 | '<div class="fieldset"><h4>Antispam</h4>'. |
|---|
| 71 | '<p><label for="antispam_moderation_ttl" class="classic">'.__('Delete junk comments older than').' '. |
|---|
| 72 | form::field('antispam_moderation_ttl', 3, 3, $ttl). |
|---|
| 73 | ' '.__('days'). |
|---|
| 74 | '</label></p>'. |
|---|
| 75 | '<p><a href="plugin.php?p=antispam">'.__('Set spam filters on it\'s page.').'</a></p>'. |
|---|
| 76 | '</div>'; |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | public static function adminBeforeBlogSettingsUpdate($settings) |
|---|
| 80 | { |
|---|
| 81 | $settings->addNamespace('antispam'); |
|---|
| 82 | $settings->antispam->put('antispam_moderation_ttl',(integer)$_POST['antispam_moderation_ttl']); |
|---|
| 83 | } |
|---|
| 84 | } |
|---|
| 85 | ?> |
|---|