File: blacklist.php

package info (click to toggle)
horde-sam 0.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,292 kB
  • ctags: 363
  • sloc: php: 1,449; xml: 646; makefile: 64; sql: 60; sh: 30
file content (70 lines) | stat: -rw-r--r-- 2,532 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
 * $Horde: sam/blacklist.php,v 1.22 2006/01/01 21:11:49 jan Exp $
 *
 * Copyright 2002-2006 Chris Bowlby <excalibur@hub.org>
 *
 * See the enclosed file COPYING for license information (GPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

/* Determine base directory. */
@define('SAM_BASE', dirname(__FILE__));
require_once SAM_BASE . '/lib/base.php';
require_once 'Horde/Form.php';
require_once 'Horde/Form/Renderer.php';
require_once SAM_BASE . '/lib/BlacklistForm.php';
require_once 'Horde/Variables.php';

/* Request retrieval of related user data. */
$result = $sam_driver->retrieve();
if (is_a($result, 'PEAR_Error')) {
    $notification->push(sprintf(_("Cannot get options: %s"), $result->getMessage()), 'horde.error');
}

/* Initialize the form. */
$vars = &Variables::getDefaultVariables();
$form = &Horde_Form::singleton('BlacklistForm', $vars);
$renderer = &new Horde_Form_Renderer();
$renderer->setAttrColumnWidth('25%');
$defaults = false;

/* Page variables. */
$title = _("Black List Manager");

if ($form->isSubmitted() &&
    $vars->exists('global_defaults') && $vars->get('global_defaults')) {
    if (!Auth::isAdmin()) {
        $notification->push(_("Only an administrator may change the global defaults."), 'horde.error');
        $vars->remove('global_defaults');
        $form->setSubmitted(false);
    } elseif (!$sam_driver->hasCapability('global_defaults')) {
        $notification->push(_("The configured backend does not support global defaults."), 'horde.error');
        $vars->remove('global_defaults');
        $form->setSubmitted(false);
    } else {
        $defaults = true;
    }
}

if ($form->validate($vars)) {
    foreach (array('blacklist_from', 'blacklist_to') as $key) {
        if ($sam_driver->hasCapability($key) && $vars->exists($key)) {
            $sam_driver->setListOption($key, $vars->get($key), $defaults);
        }
    }

    $result = $sam_driver->store($defaults);
    if (is_a($result, 'PEAR_Error')) {
        $notification->push(sprintf(_("Cannot set options: %s"), $result->getMessage()), 'horde.error');
    } elseif ($defaults) {
        $notification->push(_("Updated global blacklists"), 'horde.success');
    } else {
        $notification->push(_("Updated user blacklists"), 'horde.success');
    }
}

require SAM_TEMPLATES . '/common-header.inc';
require SAM_TEMPLATES . '/menu.inc';
$form->renderActive($renderer, $vars, 'blacklist.php', 'post');
require $registry->get('templates', 'horde') . '/common-footer.inc';