1: <?php
2: /**
3: * Specific factory methods for the free/busy export from a Kolab backend.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_FreeBusy
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Kolab_FreeBusy
12: */
13:
14: /**
15: * Specific factory methods for the free/busy export from a Kolab backend.
16: *
17: * Copyright 2009-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you did not
20: * receive this file, see
21: * http://www.horde.org/licenses/lgpl21.
22: *
23: * @category Kolab
24: * @package Kolab_FreeBusy
25: * @author Gunnar Wrobel <wrobel@pardus.de>
26: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
27: * @link http://pear.horde.org/index.php?package=Kolab_FreeBusy
28: * @since Horde 3.2
29: */
30: class Horde_Kolab_FreeBusy_Freebusy_Factory_Kolab
31: extends Horde_Kolab_FreeBusy_Freebusy_Factory_Base
32: {
33: /**
34: * Constructor.
35: *
36: * @param Horde_Injector $injector The injector providing required dependencies.
37: */
38: public function __construct(Horde_Injector $injector)
39: {
40: $injector->bindImplementation(
41: 'Horde_Kolab_FreeBusy_UserDb',
42: 'Horde_Kolab_FreeBusy_UserDb_Kolab'
43: );
44: parent::__construct($injector);
45: }
46:
47: /**
48: * Create the object representing the current user requesting the export.
49: *
50: * @return Horde_Kolab_FreeBusy_User_Interface The current user.
51: *
52: * @throws Horde_Exception
53: */
54: public function getUser()
55: {
56: }
57:
58: /**
59: * Provide configuration settings for Horde_Kolab_Storage.
60: *
61: * @return NULL
62: */
63: public function getStorageConfiguration()
64: {
65: $configuration = array();
66:
67: //@todo: Update configuration parameters
68: if (!empty($GLOBALS['conf']['kolab']['imap'])) {
69: $configuration = $GLOBALS['conf']['kolab']['imap'];
70: }
71: if (!empty($GLOBALS['conf']['kolab']['storage'])) {
72: $configuration = $GLOBALS['conf']['kolab']['storage'];
73: }
74: return $configuration;
75: }
76:
77: /**
78: * Return the Horde_Kolab_Storage:: instance.
79: *
80: * @return Horde_Kolab_Storage The storage handler.
81: */
82: public function getStorage()
83: {
84: $configuration = $this->_injector->getInstance('Horde_Kolab_Storage_Configuration');
85:
86: $owner = $this->_injector->getInstance('Horde_Kolab_FreeBusy_Owner');
87: $user = $this->_injector->getInstance('Horde_Kolab_FreeBusy_Param_User');
88:
89: list($user, $pass) = $user->getCredentials();
90:
91: $params = array(
92: 'hostspec' => $owner->getResourceServer(),
93: 'username' => $user,
94: 'password' => $pass,
95: 'secure' => true
96: );
97:
98: $imap = Horde_Imap_Client::factory('socket', $params);
99:
100: //@todo: The Group package needs to be converted to H4
101: require_once 'Horde/Group.php';
102:
103: $master = new Horde_Kolab_Storage_Driver_Imap(
104: $imap,
105: Group::singleton()
106: );
107:
108: return new Horde_Kolab_Storage(
109: $master,
110: $params
111: );
112: }
113:
114: /**
115: * Create the folder that provides our data.
116: *
117: * @return Horde_Kolab_Storage_Folder The folder.
118: */
119: public function getFolder()
120: {
121: $name = $this->_injector
122: ->getInstance('Horde_Kolab_FreeBusy_Params_Freebusy_Resource_Kolab')
123: ->getResourceId();
124:
125: }
126:
127: /**
128: * Create the backend resource handler
129: *
130: * @return Horde_Kolab_FreeBusy_Resource The resource.
131: */
132: public function getResource()
133: {
134: return new Horde_Kolab_FreeBusy_Resource_Event_Kolab(
135: $this->_injector->getInstance('Horde_Kolab_Storage_Folder')
136: );
137: }
138:
139: }