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_KolabSession extends Horde_Core_Factory_Base
29: {
30: 31:
32: public function __construct(Horde_Injector $injector)
33: {
34: parent::__construct($injector);
35: $this->_injector->bindImplementation(
36: 'Horde_Kolab_Session_Storage',
37: 'Horde_Kolab_Session_Storage_Session'
38: );
39: }
40:
41: 42: 43: 44: 45: 46: 47: 48: 49: 50:
51: public function createSessionValidator(
52: Horde_Kolab_Session $session,
53: $auth
54: ) {
55: $validator = new Horde_Kolab_Session_Valid_Base(
56: $session, $auth
57: );
58:
59: if (isset($GLOBALS['conf']['kolab']['session']['debug'])) {
60: $validator = new Horde_Kolab_Session_Valid_Decorator_Logged(
61: $validator, $this->_injector->getInstance('Horde_Log_Logger')
62: );
63: }
64:
65: return $validator;
66: }
67:
68: 69: 70: 71: 72:
73: public function createSession()
74: {
75: if (!isset($GLOBALS['conf']['kolab']['users'])) {
76: $session = new Horde_Kolab_Session_Base(
77: $this->_injector->getInstance('Horde_Kolab_Server_Composite'),
78: $GLOBALS['conf']['kolab']
79: );
80: } else {
81: $session = new Horde_Kolab_Session_Imap(
82: new Horde_Kolab_Session_Factory_Imap(),
83: $GLOBALS['conf']['kolab']
84: );
85: }
86:
87: if (isset($GLOBALS['conf']['kolab']['session']['debug'])) {
88: $session = new Horde_Kolab_Session_Decorator_Logged(
89: $session, $this->_injector->getInstance('Horde_Log_Logger')
90: );
91: }
92:
93: $session = new Horde_Kolab_Session_Decorator_Stored(
94: $session,
95: $this->_injector->getInstance('Horde_Kolab_Session_Storage')
96: );
97:
98: return $session;
99: }
100:
101: 102: 103: 104: 105:
106: public function create()
107: {
108: $session = $this->createSession();
109:
110: $this->createSessionValidator(
111: $session,
112: $this->_injector->getInstance('Horde_Registry')->getAuth()
113: )->validate();
114:
115: if (isset($GLOBALS['conf']['kolab']['session']['anonymous']['user'])
116: && isset($GLOBALS['conf']['kolab']['session']['anonymous']['pass'])
117: ) {
118: $session = new Horde_Kolab_Session_Decorator_Anonymous(
119: $session,
120: $GLOBALS['conf']['kolab']['session']['anonymous']['user'],
121: $GLOBALS['conf']['kolab']['session']['anonymous']['pass']
122: );
123: }
124:
125: return $session;
126: }
127: }
128: