1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class IMP_Factory_AuthImap extends Horde_Core_Factory_Injector
24: {
25: 26: 27: 28: 29: 30:
31: public function create(Horde_Injector $injector)
32: {
33: global $injector, $registry;
34:
35: $admin = $injector->getInstance('IMP_Factory_Imap')->create()->config->admin;
36: if (!$admin) {
37: throw new IMP_Exception('Admin access not enabled.');
38: }
39:
40: $params = $registry->callByPackage('imp', 'server');
41: if (is_null($params)) {
42: throw new IMP_Exception('No server parameters found.');
43: }
44:
45: $params_map = array(
46: 'password' => 'admin_password',
47: 'user' => 'admin_user',
48: 'userhierarchy' => 'userhierarchy'
49: );
50:
51: foreach ($admin as $key => $val) {
52: if (isset($params_map[$key])) {
53: $params[$params_map[$key]] = $val;
54: }
55: }
56:
57: $params['default_user'] = $registry->getAuth();
58: $params['logger'] = $injector->getInstance('Horde_Log_Logger');
59:
60: return Horde_Auth::factory('Imap', $params);
61: }
62:
63: }
64: