Changeset View
Changeset View
Standalone View
Standalone View
lib/Kolab/FreeBusy/DirectoryStatic.php
Show All 25 Lines | |||||
/** | /** | ||||
* Implementation of a static address directory for Free/Busy user lookups. | * Implementation of a static address directory for Free/Busy user lookups. | ||||
* | * | ||||
* This directory basically pipes the username through with an optional check | * This directory basically pipes the username through with an optional check | ||||
* whether it matches the configured filter rule | * whether it matches the configured filter rule | ||||
*/ | */ | ||||
class DirectoryStatic extends Directory | class DirectoryStatic extends Directory | ||||
{ | { | ||||
/** | /** | ||||
* Default constructor loading directory configuration | * Default constructor loading directory configuration | ||||
*/ | */ | ||||
public function __construct($config) | public function __construct($config) | ||||
{ | { | ||||
$this->config = $config; | $this->config = $config; | ||||
} | } | ||||
/** | /** | ||||
* @see Directory::resolve() | * @see Directory::resolve() | ||||
*/ | */ | ||||
public function resolve($user) | public function resolve($user) | ||||
{ | { | ||||
$result = array('s' => $user); | $result = array('s' => $user); | ||||
// check if user matches the filter property (if configured) | // check if user matches the filter property (if configured) | ||||
if (!empty($this->config['filter'])) { | if (!empty($this->config['filter'])) { | ||||
if (!preg_match('!'.$this->config['filter'].'!i', $user)) | if (!preg_match('!'.$this->config['filter'].'!i', $user)) { | ||||
$result = false; | $result = false; | ||||
} | } | ||||
} | |||||
return $result; | return $result; | ||||
} | } | ||||
} | } | ||||