* @author Daniel Collins <horde_dev@argentproductions.com>
* @package Vilma
*/
-class Vilma_Driver {
-
+abstract class Vilma_Driver
+{
/**
* A hash containing any parameters for the current 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.
return $domain['max_users'];
}
+ public function getUserFormAttributes()
+ {
+ }
+
/**
* Attempts to return a concrete Vilma_Driver instance based on $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;
}
die("deleteVirtual()");
}
- function getUserFormAttributes()
+ public function getUserFormAttributes()
{
- $attrs = array();
- $attrs[] = array(
+ return array(array(
'label' => _("Account Status"),
'name' => 'user_enabled',
'type' => 'enum',
),
),
'default' => 'active',
- );
-
- return $attrs;
+ ));
}
function _connect()
}
/**
+ * 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.
*