mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Fixing indentation
This commit is contained in:
parent
427d909783
commit
e46c3b10ec
3 changed files with 398 additions and 385 deletions
|
|
@ -43,7 +43,8 @@ class LdapConfig
|
|||
public $group_field_mail;
|
||||
public $group_sender_format;
|
||||
|
||||
public static function MakeConfig(Plugin $config) : LdapConfig {
|
||||
public static function MakeConfig(Plugin $config): LdapConfig
|
||||
{
|
||||
$ldap = new self();
|
||||
$ldap->server = trim($config->Get("plugin", self::CONFIG_SERVER));
|
||||
$ldap->protocol = (int)trim($config->Get("plugin", self::CONFIG_PROTOCOL_VERSION, 3));
|
||||
|
|
|
|||
|
|
@ -154,14 +154,17 @@ class LdapIdentities implements IIdentities
|
|||
}
|
||||
|
||||
/** @throws LdapException */
|
||||
private function EnsureConnected() : void {
|
||||
private function EnsureConnected(): void
|
||||
{
|
||||
if ($this->ldapConnected) return;
|
||||
|
||||
$res = $this->Connect();
|
||||
if (!$res)
|
||||
$this->HandleLdapError("Connect");
|
||||
}
|
||||
private function Connect() : bool {
|
||||
|
||||
private function Connect(): bool
|
||||
{
|
||||
// Set up connection
|
||||
$ldap = @ldap_connect($this->config->server);
|
||||
if ($ldap === false) {
|
||||
|
|
@ -182,7 +185,8 @@ class LdapIdentities implements IIdentities
|
|||
}
|
||||
|
||||
/** @throws LdapException */
|
||||
private function EnsureBound() : void {
|
||||
private function EnsureBound(): void
|
||||
{
|
||||
if ($this->ldapBound) return;
|
||||
$this->EnsureConnected();
|
||||
|
||||
|
|
@ -190,7 +194,9 @@ class LdapIdentities implements IIdentities
|
|||
if (!$res)
|
||||
$this->HandleLdapError("Bind");
|
||||
}
|
||||
private function Bind() : bool {
|
||||
|
||||
private function Bind(): bool
|
||||
{
|
||||
// Bind to LDAP here
|
||||
$bindResult = @ldap_bind($this->ldap, $this->config->bind_user, $this->config->bind_password);
|
||||
if (!$bindResult) {
|
||||
|
|
@ -206,7 +212,8 @@ class LdapIdentities implements IIdentities
|
|||
* @param string $op
|
||||
* @throws LdapException
|
||||
*/
|
||||
private function HandleLdapError(string $op = ""): void {
|
||||
private function HandleLdapError(string $op = ""): void
|
||||
{
|
||||
// Obtain LDAP error and write logs
|
||||
$errorNo = @ldap_errno($this->ldap);
|
||||
$errorMsg = @ldap_error($this->ldap);
|
||||
|
|
@ -226,7 +233,8 @@ class LdapIdentities implements IIdentities
|
|||
* @return LdapResult[]
|
||||
* @throws LdapException
|
||||
*/
|
||||
private function FindLdapResults(string $searchField, string $searchValue, string $searchBase, string $objectClass, string $nameField, string $mailField) : array {
|
||||
private function FindLdapResults(string $searchField, string $searchValue, string $searchBase, string $objectClass, string $nameField, string $mailField): array
|
||||
{
|
||||
$this->EnsureBound();
|
||||
|
||||
$nameField = strtolower($nameField);
|
||||
|
|
@ -267,7 +275,8 @@ class LdapIdentities implements IIdentities
|
|||
* @param bool $required
|
||||
* @return string|string[]
|
||||
*/
|
||||
private function LdapGetAttribute(array $entry, string $attribute, bool $single = true, bool $required = false) {
|
||||
private function LdapGetAttribute(array $entry, string $attribute, bool $single = true, bool $required = false)
|
||||
{
|
||||
if (!isset($entry[$attribute])) {
|
||||
if ($required)
|
||||
$this->logger->Write("Attribute $attribute not found on object {$entry['dn']} while required", Type::NOTICE, self::LOG_KEY);
|
||||
|
|
@ -288,7 +297,8 @@ class LdapIdentities implements IIdentities
|
|||
}
|
||||
}
|
||||
|
||||
class LdapResult {
|
||||
class LdapResult
|
||||
{
|
||||
/** @var string */
|
||||
public $dn;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,11 +13,13 @@ class LdapIdentitiesPlugin extends AbstractPlugin
|
|||
include_once __DIR__ . '/LdapException.php';
|
||||
}
|
||||
|
||||
public function Init() : void {
|
||||
public function Init(): void
|
||||
{
|
||||
$this->addHook("main.fabrica", 'MainFabrica');
|
||||
}
|
||||
|
||||
public function MainFabrica(string $name, &$result) {
|
||||
public function MainFabrica(string $name, &$result)
|
||||
{
|
||||
if ($name !== 'identities') return;
|
||||
|
||||
if (!is_array($result))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue