aboutsummaryrefslogtreecommitdiff
path: root/lib/phplib/page_open.php
blob: 699d50d7314b82ee1af183201cc9b190c245171f (plain)
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
<?php
/*
* Session Management for PHP3
*
* Copyright (c) 1998-2000 NetUSE AG
*                    Boris Erdmann, Kristian Koehntopp
*
*
*/

function page_open($feature) {

    # enable sess and all dependent features.
    if (isset($feature["sess"])) {
        $GLOBALS['sess'] = new $feature["sess"];
        $GLOBALS['sess']->start();

        # the auth feature depends on sess
        if (isset($feature["auth"])) {

            if (isset($_SESSION['auth'])) {
                $_SESSION['auth'] = $_SESSION['auth']->check_feature($feature["auth"]);
            } else {
                $_SESSION['auth'] = new $feature["auth"];
            }
            $_SESSION['auth']->start();

            $GLOBALS['auth'] =& $_SESSION['auth'];

            # the perm feature depends on auth and sess
            if (isset($feature["perm"])) {

                if (!isset($GLOBALS['perm'])) {
                    $GLOBALS['perm'] = new $feature["perm"];
                }
            }

            # the user feature depends on auth and sess
            if (isset($feature["user"])) {
                if (!isset($GLOBALS['user'])) {
                    $GLOBALS['user'] = new $feature["user"]($GLOBALS['auth']->auth["uid"]);
                }
            }
        }
    }
}

function page_close() {
    try {
        NotificationCenter::postNotification('PageCloseWillExecute', null);
    } catch (NotificationVetoException $e) {
        return;
    }
    if (is_object($GLOBALS['sess'])) {
        @session_write_close();
    }

    if (is_object($GLOBALS['user'])) {
        $GLOBALS['user']->set_last_action();
    }
    NotificationCenter::postNotification('PageCloseDidExecute', null);
}