Changeset View
Changeset View
Standalone View
Standalone View
lib/kolab_sync.php
Show All 39 Lines | class kolab_sync extends rcube | ||||
* | * | ||||
* @var rcube_user | * @var rcube_user | ||||
*/ | */ | ||||
public $user; | public $user; | ||||
public $username; | public $username; | ||||
public $password; | public $password; | ||||
public $task = null; | |||||
const CHARSET = 'UTF-8'; | const CHARSET = 'UTF-8'; | ||||
const VERSION = "2.3.22"; | const VERSION = "2.3.22"; | ||||
/** | /** | ||||
* This implements the 'singleton' design pattern | * This implements the 'singleton' design pattern | ||||
* | * | ||||
* @param int $mode Unused | * @param int $mode Unused | ||||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | public function authenticate($username, $password) | ||||
if (!$auth['abort'] && $cache) { | if (!$auth['abort'] && $cache) { | ||||
$cache->set($cache_key, array( | $cache->set($cache_key, array( | ||||
'user' => $auth['user'], | 'user' => $auth['user'], | ||||
'host' => $auth['host'], | 'host' => $auth['host'], | ||||
)); | )); | ||||
} | } | ||||
// LDAP server failure... send 503 error | // LDAP server failure... send 503 error | ||||
if ($auth['kolab_ldap_error']) { | if ($auth['kolab_ldap_error'] ?? null) { | ||||
self::server_error(); | self::server_error(); | ||||
} | } | ||||
// Close LDAP connection from kolab_auth plugin | // Close LDAP connection from kolab_auth plugin | ||||
if (class_exists('kolab_auth', false)) { | if (class_exists('kolab_auth', false)) { | ||||
if (method_exists('kolab_auth', 'ldap_close')) { | if (method_exists('kolab_auth', 'ldap_close')) { | ||||
kolab_auth::ldap_close(); | kolab_auth::ldap_close(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
else { | else { | ||||
$auth['pass'] = $password; | $auth['pass'] = $password; | ||||
} | } | ||||
// Authenticate - get Roundcube user ID | // Authenticate - get Roundcube user ID | ||||
if (!$auth['abort'] && ($userid = $this->login($auth['user'], $auth['pass'], $auth['host'], $err))) { | if (!($auth['abort'] ?? false) && ($userid = $this->login($auth['user'], $auth['pass'], $auth['host'], $err))) { | ||||
// set real username | // set real username | ||||
$this->username = $auth['user']; | $this->username = $auth['user']; | ||||
return $userid; | return $userid; | ||||
} | } | ||||
else if ($err) { | else if ($err) { | ||||
$err_str = $this->get_storage()->get_error_str(); | $err_str = $this->get_storage()->get_error_str(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | private function login($username, $password, $host, &$error = null) | ||||
return null; | return null; | ||||
} | } | ||||
$login_lc = $this->config->get('login_lc'); | $login_lc = $this->config->get('login_lc'); | ||||
$default_port = $this->config->get('default_port', 143); | $default_port = $this->config->get('default_port', 143); | ||||
// parse $host | // parse $host | ||||
$a_host = parse_url($host); | $a_host = parse_url($host); | ||||
$port = null; | |||||
if ($a_host['host']) { | if ($a_host['host']) { | ||||
$host = $a_host['host']; | $host = $a_host['host']; | ||||
$ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null; | $ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null; | ||||
if (!empty($a_host['port'])) { | if (!empty($a_host['port'])) { | ||||
$port = $a_host['port']; | $port = $a_host['port']; | ||||
} | } | ||||
else if ($ssl && $ssl != 'tls' && (!$default_port || $default_port == 143)) { | else if ($ssl && $ssl != 'tls' && (!$default_port || $default_port == 143)) { | ||||
$port = 993; | $port = 993; | ||||
▲ Show 20 Lines • Show All 217 Lines • Show Last 20 Lines |