[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Antispam, a plugin for Dotclear 2. |
---|
| 5 | # |
---|
[270] | 6 | # Copyright (c) 2003-2011 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 | 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 | |
---|
[3] | 26 | $core->addBehavior('adminDashboardFavs','antispamDashboardFavs'); |
---|
[203] | 27 | $core->addBehavior('adminDashboardFavsIcon','antispamDashboardFavsIcon'); |
---|
[3] | 28 | |
---|
| 29 | function antispamDashboardFavs($core,$favs) |
---|
| 30 | { |
---|
[324] | 31 | $favs['antispam'] = new ArrayObject(array('antispam','Antispam','plugin.php?p=antispam', |
---|
[3] | 32 | 'index.php?pf=antispam/icon.png','index.php?pf=antispam/icon-big.png', |
---|
| 33 | 'admin',null,null)); |
---|
| 34 | } |
---|
| 35 | |
---|
[203] | 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 | |
---|
[0] | 48 | if (!DC_ANTISPAM_CONF_SUPER || $core->auth->isSuperAdmin()) { |
---|
| 49 | $core->addBehavior('adminBlogPreferencesForm',array('antispamBehaviors','adminBlogPreferencesForm')); |
---|
| 50 | $core->addBehavior('adminBeforeBlogSettingsUpdate',array('antispamBehaviors','adminBeforeBlogSettingsUpdate')); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | class antispamBehaviors |
---|
| 54 | { |
---|
| 55 | public static function adminBlogPreferencesForm($core,$settings) |
---|
| 56 | { |
---|
| 57 | $ttl = $settings->antispam->antispam_moderation_ttl; |
---|
| 58 | echo |
---|
| 59 | '<fieldset><legend>Antispam</legend>'. |
---|
[74] | 60 | '<p><label for="antispam_moderation_ttl" class="classic">'.__('Delete junk comments older than').' '. |
---|
[0] | 61 | form::field('antispam_moderation_ttl', 3, 3, $ttl). |
---|
| 62 | ' '.__('days'). |
---|
| 63 | '</label></p>'. |
---|
| 64 | '</fieldset>'; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | public static function adminBeforeBlogSettingsUpdate($settings) |
---|
| 68 | { |
---|
| 69 | $settings->addNamespace('antispam'); |
---|
| 70 | $settings->antispam->put('antispam_moderation_ttl',(integer)$_POST['antispam_moderation_ttl']); |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | ?> |
---|