File: Session.php

package info (click to toggle)
ingo1 1.2.4%2Bdebian0-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 6,196 kB
  • ctags: 1,955
  • sloc: php: 8,375; xml: 2,846; sql: 168; makefile: 74; sh: 26
file content (73 lines) | stat: -rw-r--r-- 2,615 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
<?php
/**
 * Functions required to start a Ingo session.
 *
 * $Horde: ingo/lib/Session.php,v 1.2.10.11 2009/01/06 15:24:35 jan Exp $
 *
 * Copyright 2004-2009 The Horde Project (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (ASL).  If you
 * did not receive this file, see http://www.horde.org/licenses/asl.php.
 *
 * @author  Michael Slusarz <slusarz@horde.org>
 * @package Ingo
 */
class Ingo_Session {

    /**
     * Create an ingo session.
     * This function should only be called once, when the user first uses
     * Ingo in a session.
     *
     * Creates the $ingo session variable with the following entries:
     * 'backend' (array) - The backend configuration to use.
     * 'change' (integer) - The timestamp of the last time the rules were
     *                      altered.
     * 'storage' (array) - Used by Ingo_Storage:: for caching data.
     * 'script_categories' (array) - The list of available categories for the
     *                               Ingo_Script driver in use.
     * 'script_generate' (boolean) - Is the Ingo_Script::generate() call
     *                               available?
     *
     * @return boolean  True on success, false on failure.
     */
    function createSession()
    {
        global $prefs;

        $_SESSION['ingo'] = array(
            'change' => 0,
            'storage' => array(),
            /* Get the backend. */
            'backend' => Ingo::getBackend());

        /* Determine if the Ingo_Script:: generate() method is available. */
        $ingo_script = Ingo::loadIngoScript();
        $_SESSION['ingo']['script_generate'] = $ingo_script->generateAvailable();

        /* Disable categories as specified in preferences */
        $disabled = array();
        if ($prefs->isLocked('blacklist')) {
            $disabled[] = INGO_STORAGE_ACTION_BLACKLIST;
        }
        if ($prefs->isLocked('whitelist')) {
            $disabled[] = INGO_STORAGE_ACTION_WHITELIST;
        }
        if ($prefs->isLocked('vacation')) {
            $disabled[] = INGO_STORAGE_ACTION_VACATION;
        }
        if ($prefs->isLocked('forward')) {
            $disabled[] = INGO_STORAGE_ACTION_FORWARD;
        }
        if ($prefs->isLocked('spam')) {
            $disabled[] = INGO_STORAGE_ACTION_SPAM;
        }

        /* Set the list of categories this driver supports. */
        $_SESSION['ingo']['script_categories'] =
            array_merge($ingo_script->availableActions(),
                        array_diff($ingo_script->availableCategories(),
                                   $disabled));
    }

}