|
19 | 19 | * IMAP connection manager |
20 | 20 | * @subpackage imap/lib |
21 | 21 | */ |
22 | | -class Hm_IMAP_List { |
| 22 | +if (!class_exists('Hm_IMAP_List')) { |
| 23 | + class Hm_IMAP_List { |
23 | 24 |
|
24 | | - use Hm_Server_List; |
| 25 | + use Hm_Server_List; |
25 | 26 |
|
26 | | - public static $use_cache = false; |
27 | | - protected static $user_config; |
28 | | - protected static $session; |
| 27 | + public static $use_cache = false; |
| 28 | + protected static $user_config; |
| 29 | + protected static $session; |
29 | 30 |
|
30 | | - public static function init($user_config, $session) { |
31 | | - self::initRepo('imap_servers', $user_config, $session, self::$server_list); |
32 | | - self::$user_config = $user_config; |
33 | | - self::$session = $session; |
34 | | - } |
| 31 | + public static function init($user_config, $session) { |
| 32 | + self::initRepo('imap_servers', $user_config, $session, self::$server_list); |
| 33 | + self::$user_config = $user_config; |
| 34 | + self::$session = $session; |
| 35 | + } |
35 | 36 |
|
36 | | - public static function service_connect($id, $server, $user, $pass, $cache=false) { |
37 | | - $config = array( |
38 | | - 'server' => $server['server'], |
39 | | - 'port' => $server['port'], |
40 | | - 'tls' => $server['tls'], |
41 | | - 'type' => array_key_exists('type', $server) ? $server['type'] : 'imap', |
42 | | - 'username' => $user, |
43 | | - 'password' => $pass, |
44 | | - 'use_cache' => self::$use_cache |
45 | | - ); |
| 37 | + public static function service_connect($id, $server, $user, $pass, $cache=false) { |
| 38 | + $config = array( |
| 39 | + 'server' => $server['server'], |
| 40 | + 'port' => $server['port'], |
| 41 | + 'tls' => $server['tls'], |
| 42 | + 'type' => array_key_exists('type', $server) ? $server['type'] : 'imap', |
| 43 | + 'username' => $user, |
| 44 | + 'password' => $pass, |
| 45 | + 'use_cache' => self::$use_cache |
| 46 | + ); |
46 | 47 |
|
47 | | - if (array_key_exists('auth', $server)) { |
48 | | - $config['auth'] = $server['auth']; |
49 | | - } |
| 48 | + if (array_key_exists('auth', $server)) { |
| 49 | + $config['auth'] = $server['auth']; |
| 50 | + } |
50 | 51 |
|
51 | | - self::$server_list[$id]['object'] = new Hm_Mailbox($id, self::$user_config, self::$session, $config); |
52 | | - if (self::$use_cache && $cache && is_array($cache)) { |
53 | | - self::$server_list[$id]['object']->get_connection()->load_cache($cache, 'array'); |
| 52 | + self::$server_list[$id]['object'] = new Hm_Mailbox($id, self::$user_config, self::$session, $config); |
| 53 | + if (self::$use_cache && $cache && is_array($cache)) { |
| 54 | + self::$server_list[$id]['object']->get_connection()->load_cache($cache, 'array'); |
| 55 | + } |
| 56 | + |
| 57 | + return self::$server_list[$id]['object']->connect(); |
54 | 58 | } |
55 | | - |
56 | | - return self::$server_list[$id]['object']->connect(); |
57 | | - } |
58 | 59 |
|
59 | | - public static function get_cache($hm_cache, $id) { |
60 | | - if (!self::$use_cache) { |
61 | | - return false; |
| 60 | + public static function get_cache($hm_cache, $id) { |
| 61 | + if (!self::$use_cache) { |
| 62 | + return false; |
| 63 | + } |
| 64 | + $res = $hm_cache->get('imap'.$id); |
| 65 | + return $res; |
62 | 66 | } |
63 | | - $res = $hm_cache->get('imap'.$id); |
64 | | - return $res; |
65 | | - } |
66 | 67 |
|
67 | | - public static function get_connected_mailbox($id, $hm_cache = null) { |
68 | | - if ($hm_cache) { |
69 | | - $cache = self::get_cache($hm_cache, $id); |
70 | | - } else { |
71 | | - $cache = false; |
| 68 | + public static function get_connected_mailbox($id, $hm_cache = null) { |
| 69 | + if ($hm_cache) { |
| 70 | + $cache = self::get_cache($hm_cache, $id); |
| 71 | + } else { |
| 72 | + $cache = false; |
| 73 | + } |
| 74 | + return self::connect($id, $cache); |
72 | 75 | } |
73 | | - return self::connect($id, $cache); |
74 | | - } |
75 | 76 |
|
76 | | - public static function get_mailbox_without_connection($config) { |
77 | | - $config['type'] = array_key_exists('type', $config) ? $config['type'] : 'imap'; |
78 | | - return new Hm_Mailbox($config['id'], self::$user_config, self::$session, $config); |
| 77 | + public static function get_mailbox_without_connection($config) { |
| 78 | + $config['type'] = array_key_exists('type', $config) ? $config['type'] : 'imap'; |
| 79 | + return new Hm_Mailbox($config['id'], self::$user_config, self::$session, $config); |
| 80 | + } |
79 | 81 | } |
80 | 82 | } |
81 | 83 |
|
@@ -178,7 +180,7 @@ class Hm_IMAP extends Hm_IMAP_Cache { |
178 | 180 | ); |
179 | 181 |
|
180 | 182 | /* holds the current IMAP connection state */ |
181 | | - private $state = 'disconnected'; |
| 183 | + public $state = 'disconnected'; |
182 | 184 |
|
183 | 185 | /* used for message part content streaming */ |
184 | 186 | private $stream_size = 0; |
|
0 commit comments