| 1: | |
| 2: | <?php |
| 3: | |
| 4: | require_once APP_PATH.'modules/sievefilters/functions.php'; |
| 5: | |
| 6: | class Hm_Sieve_Client_Factory { |
| 7: | public function init($user_config = null, $imap_account = null, $is_nux_supported = false) |
| 8: | { |
| 9: | if ($imap_account && ! empty($imap_account['sieve_config_host'])) { |
| 10: | |
| 11: | if($is_nux_supported && $sieve_config = get_sieve_host_from_services($imap_account['server'])) { |
| 12: | $sieve_host = $sieve_config['host']; |
| 13: | $sieve_port = $sieve_config['port']; |
| 14: | $sieve_tls = $sieve_config['tls']; |
| 15: | } else { |
| 16: | list($sieve_host, $sieve_port, $sieve_tls) = parse_sieve_config_host($imap_account); |
| 17: | } |
| 18: | $client = new PhpSieveManager\ManageSieve\Client($sieve_host, $sieve_port); |
| 19: | $client->connect($imap_account['user'], $imap_account['pass'], $sieve_tls, "", "PLAIN"); |
| 20: | return $client; |
| 21: | } else { |
| 22: | $errorMsg = 'Invalid config host'; |
| 23: | if (isset($imap_account['name'])) { |
| 24: | $errorMsg .= ' for ' . $imap_account['name']; |
| 25: | } |
| 26: | throw new Exception($errorMsg); |
| 27: | } |
| 28: | } |
| 29: | } |
| 30: | |