1: <?php
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: class Horde_Core_Factory_KolabStorage extends Horde_Core_Factory_Base
29: {
30: 31:
32: public function __construct(Horde_Injector $injector)
33: {
34: parent::__construct($injector);
35: $this->_setup();
36: }
37:
38: 39: 40: 41: 42:
43: private function _setup()
44: {
45: $this->_setupConfiguration();
46: }
47:
48: 49: 50: 51: 52:
53: private function _setupConfiguration()
54: {
55: $configuration = array();
56:
57:
58: if (!empty($GLOBALS['conf']['kolab']['imap'])) {
59: $configuration = $GLOBALS['conf']['kolab']['imap'];
60: }
61: if (!empty($GLOBALS['conf']['kolab']['storage'])) {
62: $configuration = $GLOBALS['conf']['kolab']['storage'];
63: }
64:
65: $this->_injector->setInstance(
66: 'Horde_Kolab_Storage_Configuration', $configuration
67: );
68: }
69:
70: 71: 72: 73: 74:
75: public function create()
76: {
77: $configuration = $this->_injector->getInstance('Horde_Kolab_Storage_Configuration');
78:
79: $session = $this->_injector->getInstance('Horde_Kolab_Session');
80:
81: $mail = $session->getMail();
82: if (empty($mail)) {
83: return false;
84: }
85:
86: $params = array(
87: 'driver' => 'horde',
88: 'params' => array(
89: 'host' => $session->getImapServer(),
90: 'username' => $GLOBALS['registry']->getAuth(),
91: 'password' => $GLOBALS['registry']->getAuthCredential('password'),
92: 'port' => $configuration['port'],
93: 'secure' => 'tls'
94: ),
95: 'queryset' => array(
96: 'list' => array('queryset' => 'horde'),
97: 'data' => array('queryset' => 'horde'),
98: ),
99: 'logger' => $this->_injector->getInstance('Horde_Log_Logger'),
100: 'timelog' => $this->_injector->getInstance('Horde_Log_Logger'),
101: 'cache' => $this->_injector->getInstance('Horde_Cache'),
102: );
103:
104: $factory = new Horde_Kolab_Storage_Factory($params);
105: return $factory->create();
106: }
107: }
108: