From: Jan Schneider Date: Wed, 8 Dec 2010 18:16:49 +0000 (+0100) Subject: Implement missing methods, abstraction. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=23749490bdfa8848ec9066898fc26e2dd5f0567b;p=horde.git Implement missing methods, abstraction. --- diff --git a/vilma/lib/Driver.php b/vilma/lib/Driver.php index c0b54bde4..7923c8e37 100644 --- a/vilma/lib/Driver.php +++ b/vilma/lib/Driver.php @@ -9,8 +9,8 @@ * @author Daniel Collins * @package Vilma */ -class Vilma_Driver { - +abstract class Vilma_Driver +{ /** * A hash containing any parameters for the current driver. * @@ -29,6 +29,40 @@ class Vilma_Driver { } /** + * Returns a list of all users, aliases, or groups and forwards for a + * domain. + * + * @param string $domain Domain on which to search. + * @param string $type Only return a specific type. One of 'all', + * 'user', 'alias','forward', or 'group'. + * @param string $key Sort list by this key. + * @param integer $direction Sort direction. + * + * @return array Account information for this domain + */ + public function getAddresses($domain, $type = 'all', $key = 'user_name', + $direction = 0) + { + $addresses = $this->_getAddresses($domain, $type); + Horde_Array::arraySort($addresses, $key, $direction, true); + return $addresses; + } + + /** + * Returns a list of all users, aliases, or groups and forwards for a + * domain. + * + * @param string $domain Domain on which to search. + * @param string $type Only return a specific type. One of 'all', + * 'user', 'alias','forward', or 'group'. + * @param string $key Sort list by this key. + * @param integer $direction Sort direction. + * + * @return array Account information for this domain + */ + abstract protected function _getAddresses($domain, $type = 'all'); + + /** * Returns all the users sorted by domain and as arrays of each domain. * * @return array An array of domains then users for each domain. @@ -420,6 +454,10 @@ class Vilma_Driver { return $domain['max_users']; } + public function getUserFormAttributes() + { + } + /** * Attempts to return a concrete Vilma_Driver instance based on $driver. * diff --git a/vilma/lib/Driver/qmailldap.php b/vilma/lib/Driver/qmailldap.php index f9a3ab6b0..43a811bec 100644 --- a/vilma/lib/Driver/qmailldap.php +++ b/vilma/lib/Driver/qmailldap.php @@ -108,30 +108,22 @@ class Vilma_Driver_qmailldap extends Vilma_Driver { * * @return array Account information for this domain */ - function getAddresses($domain, $type = 'all', $key = 'user_name', - $direction = 0) + protected function _getAddresses($domain, $type = 'all') { Horde::logMessage("Get Addresses Called for $domain with type $type and key $key", 'DEBUG'); $addresses = array(); if ($type == 'all' || $type == 'user') { - $users = $this->_getUsers($domain); - $addresses = array_merge($addresses, $users); + $addresses += $this->_getUsers($domain); } if ($type == 'all' || $type == 'alias') { - $aliases = $this->_getAliases($domain); - $addresses = array_merge($addresses, $aliases); + $addresses += $this->_getAliases($domain); } - if (($type == 'all') || ($type == 'forward')) { - $forwards = $this->_getGroupsAndForwards('forward',$domain); - $addresses = array_merge($addresses, $forwards); + if ($type == 'all' || $type == 'forward') { + $addresses += $this->_getGroupsAndForwards('forward', $domain); } - if (($type == 'all') || ($type == 'group')) { - $groups = $this->_getGroupsAndForwards('group',$domain); - $addresses = array_merge($addresses, $groups); + if ($type == 'all' || $type == 'group') { + $addresses += $this->_getGroupsAndForwards('group', $domain)); } - // Sort the results - require_once 'Horde/Array.php'; - Horde_Array::arraySort($addresses, $key, $direction, true); return $addresses; } @@ -1197,10 +1189,9 @@ class Vilma_Driver_qmailldap extends Vilma_Driver { die("deleteVirtual()"); } - function getUserFormAttributes() + public function getUserFormAttributes() { - $attrs = array(); - $attrs[] = array( + return array(array( 'label' => _("Account Status"), 'name' => 'user_enabled', 'type' => 'enum', @@ -1216,9 +1207,7 @@ class Vilma_Driver_qmailldap extends Vilma_Driver { ), ), 'default' => 'active', - ); - - return $attrs; + )); } function _connect() diff --git a/vilma/lib/Driver/sql.php b/vilma/lib/Driver/sql.php index 5d3f3dfaf..2aafc8b4b 100644 --- a/vilma/lib/Driver/sql.php +++ b/vilma/lib/Driver/sql.php @@ -197,6 +197,30 @@ class Vilma_Driver_sql extends Vilma_Driver { } /** + * Returns a list of all users, aliases, or groups and forwards for a + * domain. + * + * @param string $domain Domain on which to search. + * @param string $type Only return a specific type. One of 'all', + * 'user', 'alias','forward', or 'group'. + * @param string $key Sort list by this key. + * @param integer $direction Sort direction. + * + * @return array Account information for this domain + */ + protected function _getAddresses($domain, $type = 'all') + { + $addresses = array(); + if ($type == 'all' || $type == 'user') { + $addresses += $this->getUsers($domain); + } + if ($type == 'all' || $type == 'alias') { + $addresses += $this->getVirtuals($domain); + } + return $addresses; + } + + /** * Returns all available users, if a domain name is passed then limit the * list of users only to those users. *