Dotclear

source: plugins/antispam/_admin.php @ 2022:e8a786ec10bf

Revision 2022:e8a786ec10bf, 3.1 KB checked in by Anne Kozlika <kozlika@…>, 12 years ago (diff)

Fuzzy go home!

RevLine 
[0]1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Antispam, a plugin for 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 -----------------------------------------
12if (!defined('DC_CONTEXT_ADMIN')) { return; }
13
14if (!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
29function 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]36function 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]48if (!DC_ANTISPAM_CONF_SUPER || $core->auth->isSuperAdmin()) {
49     $core->addBehavior('adminBlogPreferencesForm',array('antispamBehaviors','adminBlogPreferencesForm'));
50     $core->addBehavior('adminBeforeBlogSettingsUpdate',array('antispamBehaviors','adminBeforeBlogSettingsUpdate'));
[1052]51     $core->addBehavior('adminCommentsSpamForm',array('antispamBehaviors','adminCommentsSpamForm'));
[0]52}
53
54class antispamBehaviors
55{
[1052]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).' '.
[1474]61               sprintf(__('You can modify this duration in the %s'),'<a href="blog_pref.php#antispam_moderation_ttl"> '.__('Blog settings').'</a>').
[1519]62               '.</p>';
[1052]63          }
64     }
65
[0]66     public static function adminBlogPreferencesForm($core,$settings)
67     {
68          $ttl = $settings->antispam->antispam_moderation_ttl;
69          echo
[1499]70          '<div class="fieldset"><h4>Antispam</h4>'.
[74]71          '<p><label for="antispam_moderation_ttl" class="classic">'.__('Delete junk comments older than').' '.
[0]72          form::field('antispam_moderation_ttl', 3, 3, $ttl).
73          ' '.__('days').
74          '</label></p>'.
[2022]75          '<p><a href="plugin.php?p=antispam">'.__('Set spam filters.').'</a></p>'.
[1499]76          '</div>';
[0]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?>
Note: See TracBrowser for help on using the repository browser.

Sites map