File: blacklist.php

package info (click to toggle)
ingo1 1.1.2-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,112 kB
  • ctags: 1,142
  • sloc: php: 4,999; xml: 1,341; makefile: 60
file content (111 lines) | stat: -rw-r--r-- 3,663 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
 * $Horde: ingo/blacklist.php,v 1.34.8.8 2006/01/31 20:00:23 jan Exp $
 *
 * Copyright 2002-2006 Mike Cochrane <mike@graftonhall.co.nz>
 * Copyright 2003-2006 Michael Slusarz <slusarz@bigworm.colorado.edu>
 *
 * See the enclosed file LICENSE for license information (ASL).  If you
 * did not receive this file, see http://www.horde.org/licenses/asl.php.
 */

@define('INGO_BASE', dirname(__FILE__));
require_once INGO_BASE . '/lib/base.php';

/* Redirect if blacklist is not available. */
if (!in_array(INGO_STORAGE_ACTION_BLACKLIST, $_SESSION['ingo']['script_categories'])) {
    $notification->push(_("Blacklist is not supported in the current filtering driver."), 'horde.error');
    header('Location: ' . Horde::applicationUrl('filters.php', true));
    exit;
}

/* Get the backend. */
$have_mark = false;
$scriptor = &Ingo::loadIngoScript();
if ($scriptor) {
    /* Determine if this scriptor supports mark-as-deleted. */
    $avail_actions = $scriptor->availableActions();
    if (in_array(INGO_STORAGE_ACTION_FLAGONLY, $avail_actions)) {
        $have_mark = true;
    }
}

/* Get the blacklist object. */
$blacklist = &$ingo_storage->retrieve(INGO_STORAGE_ACTION_BLACKLIST);
if (is_a($blacklist, 'PEAR_Error')) {
    $notification->push($blacklist);
    $blacklist = new Ingo_Storage_Blacklist();
}

/* Perform requested actions. */
$actionID = Util::getFormData('actionID');
switch ($actionID) {
case 'create_folder':
    $blacklist_folder = Ingo::createFolder(Util::getFormData('new_folder_name'));
    break;

case 'rule_update':
    switch (Util::getFormData('action')) {
    case 'delete':
        $folder = '';
        break;

    case 'mark':
        $folder = INGO_BLACKLIST_MARKER;
        break;

    case 'folder':
        $folder = Util::getFormData('actionvalue');
        break;
    }

    if (($folder == INGO_BLACKLIST_MARKER) && !$have_mark) {
        $notification->push("Not supported by this script generator.", 'horde.error');
    } else {
        $ret = $blacklist->setBlacklist(Util::getFormData('blacklist'));
        if (is_a($ret, 'PEAR_Error')) {
            $notification->push($ret, $ret->getCode());
        } else {
            $blacklist->setBlacklistFolder($folder);
            if (!$ingo_storage->store($blacklist)) {
                $notification->push(_("Error saving changes."), 'horde.error');
            } else {
                $notification->push(_("Changes saved."), 'horde.success');
            }

            if ($prefs->getValue('auto_update')) {
                /* This does its own $notification->push() on error: */
                Ingo::updateScript();
            }
        }

        /* Update the timestamp for the rules. */
        $_SESSION['ingo']['change'] = time();
    }

    break;
}

/* Create the folder listing. */
if (!isset($blacklist_folder)) {
    $blacklist_folder = $blacklist->getBlacklistFolder();
}
$field_num = $have_mark ? 2 : 1;
$folder_list = Ingo::flistSelect($blacklist_folder, 'filters', 'actionvalue',
                                 'document.filters.action[' . $field_num .
                                 '].checked=true');

/* Get the blacklist rule. */
$filters = &$ingo_storage->retrieve(INGO_STORAGE_ACTION_FILTERS);
$bl_rule = $filters->findRule(INGO_STORAGE_ACTION_BLACKLIST);

/* Include new folder JS if necessary. */
if ($registry->hasMethod('mail/createFolder')) {
    Horde::addScriptFile('new_folder.js');
}

$title = _("Blacklist Edit");
require INGO_TEMPLATES . '/common-header.inc';
require INGO_TEMPLATES . '/menu.inc';
require INGO_TEMPLATES . '/blacklist/blacklist.inc';
require $registry->get('templates', 'horde') . '/common-footer.inc';