1: <?php
2: /**
3: * This class provides the folder name requested from the free/busy system.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_FreeBusy
9: * @author Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
10: * @author Gunnar Wrobel <wrobel@pardus.de>
11: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
12: * @link http://pear.horde.org/index.php?package=Kolab_FreeBusy
13: */
14:
15: /**
16: * This class provides the folder name requested from the free/busy system.
17: *
18: * Copyright 2004-2007 Klarälvdalens Datakonsult AB
19: * Copyright 2009-2012 Horde LLC (http://www.horde.org/)
20: *
21: * See the enclosed file COPYING for license information (LGPL). If you did not
22: * receive this file, see
23: * http://www.horde.org/licenses/lgpl21.
24: *
25: * @category Kolab
26: * @package Kolab_FreeBusy
27: * @author Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
28: * @author Gunnar Wrobel <wrobel@pardus.de>
29: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
30: * @link http://pear.horde.org/index.php?package=Kolab_FreeBusy
31: */
32: class Horde_Kolab_FreeBusy_Freebusy_Params_Folder
33: implements Horde_Kolab_FreeBusy_Params_Owner,
34: Horde_Kolab_FreeBusy_Params_Resource
35: {
36: /**
37: * The owner of the folder.
38: *
39: * @var string
40: */
41: private $_owner;
42:
43: /**
44: * The extracted folder name.
45: *
46: * @var string
47: */
48: private $_folder;
49:
50: /**
51: * Constructor.
52: *
53: * @param string $folder_parameter The folder parameter.
54: */
55: public function __construct(
56: Horde_Kolab_FreeBusy_Controller_MatchDict $match_dict
57: )
58: {
59: $folder_param = $match_dict->getMatchDict()->folder;
60: if (!empty($folder_param)) {
61: $folder = explode('/', $folder_param);
62: if (count($folder) < 2) {
63: throw new Horde_Kolab_FreeBusy_Exception(
64: sprintf(
65: 'No such folder %s. A folder must have at least two components separated by "/".',
66: $folder_param
67: )
68: );
69: }
70:
71: $folder[0] = strtolower($folder[0]);
72: $this->_owner = $folder[0];
73: unset($folder[0]);
74: $this->_folder = join('/', $folder);
75: }
76: $owner_param = $match_dict->getMatchDict()->owner;
77: if (!empty($owner_param)) {
78: $this->_owner = $owner_param;
79: }
80: }
81:
82: /**
83: * Extract the folder name from the request.
84: *
85: * @return string The requested folder.
86: */
87: public function getResource()
88: {
89: if ($this->_folder === null) {
90: throw new Horde_Kolab_FreeBusy_Exception(
91: 'The resource parameter has not been provided!'
92: );
93: }
94: return $this->_folder;
95: }
96:
97: /**
98: * Extract the resource owner from the request.
99: *
100: * @return string The resource owner.
101: */
102: public function getOwner()
103: {
104: if ($this->_owner === null) {
105: throw new Horde_Kolab_FreeBusy_Exception(
106: 'The owner parameter has not been provided!'
107: );
108: }
109: return $this->_owner;
110: }
111: }