1: <?php
2: /**
3: * Copyright 2013-2014 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-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * Extends base Indices object by incorporating base mailbox information.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2013-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_Indices_Mailbox extends IMP_Indices
24: {
25: /**
26: * The BUIDs list.
27: *
28: * @var IMP_Indices
29: */
30: public $buids;
31:
32: /**
33: * Base mailbox name.
34: *
35: * @var IMP_Mailbox
36: */
37: public $mailbox;
38:
39: /**
40: * Constructor.
41: *
42: * @param mixed Two possible inputs:
43: * - 1 argument: Horde_Variables object. These GET/POST parameters are
44: * reserved in IMP:
45: * - buid: (string) BUID [Browser UID].
46: * - mailbox: (string) Base64url encoded mailbox.
47: * - muid: (string) MUID [Mailbox + UID].
48: * - uid: (string) UID [Actual mail UID].
49: * - 2 arguments: IMP_Mailbox object, IMP_Indices argument
50: */
51: public function __construct()
52: {
53: $args = func_get_args();
54:
55: switch (func_num_args()) {
56: case 1:
57: if ($args[0] instanceof Horde_Variables) {
58: if (isset($args[0]->mailbox) && strlen($args[0]->mailbox)) {
59: $this->mailbox = IMP_Mailbox::formFrom($args[0]->mailbox);
60:
61: if (isset($args[0]->buid)) {
62: $this->buids = new IMP_Indices($this->mailbox, $args[0]->buid);
63: parent::__construct($this->mailbox->fromBuids($this->buids));
64: } elseif (isset($args[0]->uid)) {
65: parent::__construct($this->mailbox, $args[0]->uid);
66: }
67: }
68:
69: if (isset($args[0]->muid)) {
70: parent::__construct($args[0]->muid);
71: }
72: }
73: break;
74:
75: case 2:
76: if (($args[0] instanceof IMP_Mailbox) &&
77: ($args[1] instanceof IMP_Indices)) {
78: $this->mailbox = $args[0];
79: $this->buids = $args[0]->toBuids($args[1]);
80: parent::__construct($args[1]);
81: }
82: break;
83: }
84:
85: if (!isset($this->buids)) {
86: $this->buids = new IMP_Indices();
87: }
88:
89: if (!isset($this->mailbox)) {
90: $this->mailbox = IMP_Mailbox::get('INBOX');
91: }
92: }
93:
94: }
95: