Dotclear

source: plugins/antispam/_admin.php @ 2230:e63e48e1c53b

Revision 2230:e63e48e1c53b, 3.2 KB checked in by Dsls, 12 years ago (diff)
  • New adminDashboardFavorites behavior introduced, adapted several plugins to it
  • Added ability to move the whole favorite with title_cb, now renamed dashboard_cb
  • new pages and pages shortcuts are now functional, closes #1727
  • Moved preferences.php to new notifications system
Line 
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 -----------------------------------------
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
26$core->addBehavior('adminDashboardFavorites','antispamDashboardFavorites');
27$core->addBehavior('adminDashboardFavsIcon','antispamDashboardFavsIcon');
28
29function antispamDashboardFavorites($core,$favs)
30{
31     $favs->register('antispam', array(
32          'title' => __('Antispam'),
33          'url' => 'plugin.php?p=antispam',
34          'small-icon' => 'index.php?pf=antispam/icon.png',
35          'large-icon' => 'index.php?pf=antispam/icon-big.png',
36          'permissions' => 'admin',
37          'dashboard_cb' => 'antispamDashboard')
38     );
39}
40
41function antispamDashboardFavsIcon($core,$name,$icon)
42{
43     // Check if it is comments favs
44     if ($name == 'comments') {
45          // Hack comments title if there is at least one spam
46          $str = dcAntispam::dashboardIconTitle($core);
47          if ($str != '') {
48               $icon[0] .= $str;
49          }
50     }
51}
52
53if (!DC_ANTISPAM_CONF_SUPER || $core->auth->isSuperAdmin()) {
54     $core->addBehavior('adminBlogPreferencesForm',array('antispamBehaviors','adminBlogPreferencesForm'));
55     $core->addBehavior('adminBeforeBlogSettingsUpdate',array('antispamBehaviors','adminBeforeBlogSettingsUpdate'));
56     $core->addBehavior('adminCommentsSpamForm',array('antispamBehaviors','adminCommentsSpamForm'));
57}
58
59class antispamBehaviors
60{
61     public static function adminCommentsSpamForm($core)
62     {
63          $ttl = $core->blog->settings->antispam->antispam_moderation_ttl;
64          if ($ttl != null && $ttl >=0) {
65               echo '<p>'.sprintf(__('All spam comments older than %s day(s) will be automatically deleted.'), $ttl).' '.
66               sprintf(__('You can modify this duration in the %s'),'<a href="blog_pref.php#antispam_moderation_ttl"> '.__('Blog settings').'</a>').
67               '.</p>';
68          }
69     }
70
71     public static function adminBlogPreferencesForm($core,$settings)
72     {
73          $ttl = $settings->antispam->antispam_moderation_ttl;
74          echo
75          '<div class="fieldset"><h4>Antispam</h4>'.
76          '<p><label for="antispam_moderation_ttl" class="classic">'.__('Delete junk comments older than').' '.
77          form::field('antispam_moderation_ttl', 3, 3, $ttl).
78          ' '.__('days').
79          '</label></p>'.
80          '<p><a href="plugin.php?p=antispam">'.__('Set spam filters.').'</a></p>'.
81          '</div>';
82     }
83     
84     public static function adminBeforeBlogSettingsUpdate($settings)
85     {
86          $settings->addNamespace('antispam');
87          $settings->antispam->put('antispam_moderation_ttl',(integer)$_POST['antispam_moderation_ttl']);
88     }
89}
90?>
Note: See TracBrowser for help on using the repository browser.

Sites map