diff options
Diffstat (limited to 'app/Group')
-rw-r--r-- | app/Group/DatabaseBackendGroupProvider.php | 34 | ||||
-rw-r--r-- | app/Group/DatabaseGroupProvider.php | 66 | ||||
-rw-r--r-- | app/Group/LdapBackendGroupProvider.php | 54 | ||||
-rw-r--r-- | app/Group/LdapGroupProvider.php | 76 |
4 files changed, 230 insertions, 0 deletions
diff --git a/app/Group/DatabaseBackendGroupProvider.php b/app/Group/DatabaseBackendGroupProvider.php new file mode 100644 index 00000000..a53516a0 --- /dev/null +++ b/app/Group/DatabaseBackendGroupProvider.php @@ -0,0 +1,34 @@ +<?php + +namespace Kanboard\Group; + +use Kanboard\Core\Base; +use Kanboard\Core\Group\GroupBackendProviderInterface; + +/** + * Database Backend Group Provider + * + * @package group + * @author Frederic Guillot + */ +class DatabaseBackendGroupProvider extends Base implements GroupBackendProviderInterface +{ + /** + * Find a group from a search query + * + * @access public + * @param string $input + * @return []DatabaseGroupProvider + */ + public function find($input) + { + $result = array(); + $groups = $this->group->search($input); + + foreach ($groups as $group) { + $result[] = new DatabaseGroupProvider($group); + } + + return $result; + } +} diff --git a/app/Group/DatabaseGroupProvider.php b/app/Group/DatabaseGroupProvider.php new file mode 100644 index 00000000..e00f36ba --- /dev/null +++ b/app/Group/DatabaseGroupProvider.php @@ -0,0 +1,66 @@ +<?php + +namespace Kanboard\Group; + +use Kanboard\Core\Group\GroupProviderInterface; + +/** + * Database Group Provider + * + * @package group + * @author Frederic Guillot + */ +class DatabaseGroupProvider implements GroupProviderInterface +{ + /** + * Group properties + * + * @access private + * @var array + */ + private $group = array(); + + /** + * Constructor + * + * @access public + * @param array $group + */ + public function __construct(array $group) + { + $this->group = $group; + } + + /** + * Get internal id + * + * @access public + * @return integer + */ + public function getInternalId() + { + return $this->group['id']; + } + + /** + * Get external id + * + * @access public + * @return string + */ + public function getExternalId() + { + return ''; + } + + /** + * Get group name + * + * @access public + * @return string + */ + public function getName() + { + return $this->group['name']; + } +} diff --git a/app/Group/LdapBackendGroupProvider.php b/app/Group/LdapBackendGroupProvider.php new file mode 100644 index 00000000..40273466 --- /dev/null +++ b/app/Group/LdapBackendGroupProvider.php @@ -0,0 +1,54 @@ +<?php + +namespace Kanboard\Group; + +use LogicException; +use Kanboard\Core\Base; +use Kanboard\Core\Group\GroupBackendProviderInterface; +use Kanboard\Core\Ldap\Client as LdapClient; +use Kanboard\Core\Ldap\ClientException as LdapException; +use Kanboard\Core\Ldap\Group as LdapGroup; + +/** + * LDAP Backend Group Provider + * + * @package group + * @author Frederic Guillot + */ +class LdapBackendGroupProvider extends Base implements GroupBackendProviderInterface +{ + /** + * Find a group from a search query + * + * @access public + * @param string $input + * @return []LdapGroupProvider + */ + public function find($input) + { + try { + $ldap = LdapClient::connect(); + return LdapGroup::getGroups($ldap, $this->getLdapGroupPattern($input)); + + } catch (LdapException $e) { + $this->logger->error($e->getMessage()); + return array(); + } + } + + /** + * Get LDAP group pattern + * + * @access public + * @param string $input + * @return string + */ + public function getLdapGroupPattern($input) + { + if (empty(LDAP_GROUP_FILTER)) { + throw new LogicException('LDAP group filter empty, check the parameter LDAP_GROUP_FILTER'); + } + + return sprintf(LDAP_GROUP_FILTER, $input); + } +} diff --git a/app/Group/LdapGroupProvider.php b/app/Group/LdapGroupProvider.php new file mode 100644 index 00000000..b497d485 --- /dev/null +++ b/app/Group/LdapGroupProvider.php @@ -0,0 +1,76 @@ +<?php + +namespace Kanboard\Group; + +use Kanboard\Core\Group\GroupProviderInterface; + +/** + * LDAP Group Provider + * + * @package group + * @author Frederic Guillot + */ +class LdapGroupProvider implements GroupProviderInterface +{ + /** + * Group DN + * + * @access private + * @var string + */ + private $dn = ''; + + /** + * Group Name + * + * @access private + * @var string + */ + private $name = ''; + + /** + * Constructor + * + * @access public + * @param string $dn + * @param string $name + */ + public function __construct($dn, $name) + { + $this->dn = $dn; + $this->name = $name; + } + + /** + * Get internal id + * + * @access public + * @return integer + */ + public function getInternalId() + { + return ''; + } + + /** + * Get external id + * + * @access public + * @return string + */ + public function getExternalId() + { + return $this->dn; + } + + /** + * Get group name + * + * @access public + * @return string + */ + public function getName() + { + return $this->name; + } +} |