1<?php
2/**
3 * Copyright 2013-2017 Horde LLC (http://www.horde.org/)
4 *
5 * See the enclosed file COPYING for license information (GPL). If you
6 * did not receive this file, see http://www.horde.org/licenses/gpl.
7 *
8 * @category  Horde
9 * @copyright 2013-2017 Horde LLC
10 * @license   http://www.horde.org/licenses/gpl GPL
11 * @package   IMP
12 */
13
14/**
15 * Manage the expanded folders list.
16 *
17 * @author    Michael Slusarz <slusarz@horde.org>
18 * @category  Horde
19 * @copyright 2013-2017 Horde LLC
20 * @license   http://www.horde.org/licenses/gpl GPL
21 * @package   IMP
22 */
23class IMP_Ftree_Prefs_Expanded extends IMP_Ftree_Prefs
24{
25    /* Constants for nav_expanded. */
26    const NO = 0;
27    const YES = 1;
28    const LAST = 2;
29
30    /**
31     * Value of nav_expanded pref.
32     *
33     * @var integer
34     */
35    protected $_expanded;
36
37    /**
38     * Constructor.
39     */
40    public function __construct()
41    {
42        global $prefs;
43
44        if (($folders = @unserialize($prefs->getValue('expanded_folders'))) &&
45            is_array($folders)) {
46            $this->_data = $folders;
47        }
48
49        $this->_expanded = $prefs->getValue('nav_expanded');
50        $this->_locked = $prefs->isLocked('expanded_folders');
51    }
52
53    /**
54     */
55    public function shutdown()
56    {
57        $GLOBALS['prefs']->setValue('expanded_folders', serialize($this->_data));
58    }
59
60    /**
61     */
62    public function offsetGet($offset)
63    {
64        switch ($this->_expanded) {
65        case self::NO:
66            return false;
67
68        case self::YES:
69            return true;
70
71        case self::LAST:
72            return parent::offsetGet($offset);
73        }
74    }
75
76}
77