new type API
This commit is contained in:
parent
ccc2721f51
commit
7027522950
|
@ -36,7 +36,7 @@ class nisMailAliasUser extends baseModule {
|
||||||
|
|
||||||
/** alias cache */
|
/** alias cache */
|
||||||
private $cachedAliasList = null;
|
private $cachedAliasList = null;
|
||||||
|
|
||||||
/** recipient entries to delete (list of arrays: dn => attributes) */
|
/** recipient entries to delete (list of arrays: dn => attributes) */
|
||||||
private $recipientsToDelete = array();
|
private $recipientsToDelete = array();
|
||||||
/** complete alias entries to delete */
|
/** complete alias entries to delete */
|
||||||
|
@ -45,10 +45,10 @@ class nisMailAliasUser extends baseModule {
|
||||||
private $aliasesToAdd = array();
|
private $aliasesToAdd = array();
|
||||||
/** alias entries to extend with new recipients (list of arrays: dn => recipients) */
|
/** alias entries to extend with new recipients (list of arrays: dn => recipients) */
|
||||||
private $recipientsToAdd = array();
|
private $recipientsToAdd = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this module can manage accounts of the current type, otherwise false.
|
* Returns true if this module can manage accounts of the current type, otherwise false.
|
||||||
*
|
*
|
||||||
* @return boolean true if module fits
|
* @return boolean true if module fits
|
||||||
*/
|
*/
|
||||||
public function can_manage() {
|
public function can_manage() {
|
||||||
|
@ -59,7 +59,7 @@ class nisMailAliasUser extends baseModule {
|
||||||
* Returns meta data that is interpreted by parent class
|
* Returns meta data that is interpreted by parent class
|
||||||
*
|
*
|
||||||
* @return array array with meta data
|
* @return array array with meta data
|
||||||
*
|
*
|
||||||
* @see baseModule::get_metaData()
|
* @see baseModule::get_metaData()
|
||||||
*/
|
*/
|
||||||
function get_metaData() {
|
function get_metaData() {
|
||||||
|
@ -122,7 +122,7 @@ class nisMailAliasUser extends baseModule {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the HTML meta data for the main account page.
|
* Returns the HTML meta data for the main account page.
|
||||||
*
|
*
|
||||||
* @return htmlElement HTML meta data
|
* @return htmlElement HTML meta data
|
||||||
*/
|
*/
|
||||||
function display_html_attributes() {
|
function display_html_attributes() {
|
||||||
|
@ -247,10 +247,10 @@ class nisMailAliasUser extends baseModule {
|
||||||
}
|
}
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a recipient from the given DN.
|
* Removes a recipient from the given DN.
|
||||||
*
|
*
|
||||||
* @param String $recipient recipient as user name or email
|
* @param String $recipient recipient as user name or email
|
||||||
* @param String $dn alias DN
|
* @param String $dn alias DN
|
||||||
*/
|
*/
|
||||||
|
@ -300,7 +300,7 @@ class nisMailAliasUser extends baseModule {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an alias with the given DN.
|
* Removes an alias with the given DN.
|
||||||
*
|
*
|
||||||
* @param String $dn alias DN
|
* @param String $dn alias DN
|
||||||
*/
|
*/
|
||||||
private function deleteAlias($dn) {
|
private function deleteAlias($dn) {
|
||||||
|
@ -324,10 +324,10 @@ class nisMailAliasUser extends baseModule {
|
||||||
unset($this->recipientsToDelete[$dn]);
|
unset($this->recipientsToDelete[$dn]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the HTML meta data for the add page.
|
* Returns the HTML meta data for the add page.
|
||||||
*
|
*
|
||||||
* @return htmlElement HTML meta data
|
* @return htmlElement HTML meta data
|
||||||
*/
|
*/
|
||||||
function display_html_add() {
|
function display_html_add() {
|
||||||
|
@ -357,9 +357,18 @@ class nisMailAliasUser extends baseModule {
|
||||||
$return->addElement(new htmlHiddenInput('recipient', $recipient), true);
|
$return->addElement(new htmlHiddenInput('recipient', $recipient), true);
|
||||||
// new mail alias
|
// new mail alias
|
||||||
$return->addElement(new htmlSubTitle(_('Create new alias')), true);
|
$return->addElement(new htmlSubTitle(_('Create new alias')), true);
|
||||||
$typeObj = new mailAlias();
|
$typeManager = new \LAM\TYPES\TypeManager();
|
||||||
$ous = $typeObj->getSuffixList();
|
$mailAliasTypes = $typeManager->getConfiguredTypesForScope('mailAlias');
|
||||||
$return->addElement(new htmlTableExtendedSelect('new_ou', $ous, array(), _('Suffix'), 'suffix'), true);
|
$ous = array();
|
||||||
|
foreach ($mailAliasTypes as $type) {
|
||||||
|
$ous = array_merge($ous, $type->getBaseType()->getSuffixList());
|
||||||
|
}
|
||||||
|
$ous = array_unique($ous);
|
||||||
|
usort($ous, 'compareDN');
|
||||||
|
$suffixSelect = new htmlTableExtendedSelect('new_ou', $ous, array(), _('Suffix'), 'suffix');
|
||||||
|
$suffixSelect->setRightToLeftTextDirection(true);
|
||||||
|
$suffixSelect->setSortElements(false);
|
||||||
|
$return->addElement($suffixSelect, true);
|
||||||
$newAliasCn = empty($_POST['new_cn']) ? '' : $_POST['new_cn'];
|
$newAliasCn = empty($_POST['new_cn']) ? '' : $_POST['new_cn'];
|
||||||
$return->addElement(new htmlTableExtendedInputField(_('Alias name'), 'new_cn', $newAliasCn, 'newAlias'), true);
|
$return->addElement(new htmlTableExtendedInputField(_('Alias name'), 'new_cn', $newAliasCn, 'newAlias'), true);
|
||||||
$return->addVerticalSpace('5px');
|
$return->addVerticalSpace('5px');
|
||||||
|
@ -367,9 +376,9 @@ class nisMailAliasUser extends baseModule {
|
||||||
$addButton->setIconClass('createButton');
|
$addButton->setIconClass('createButton');
|
||||||
$addButton->colspan = 5;
|
$addButton->colspan = 5;
|
||||||
$return->addElement($addButton, true);
|
$return->addElement($addButton, true);
|
||||||
|
|
||||||
$return->addVerticalSpace('20px');
|
$return->addVerticalSpace('20px');
|
||||||
|
|
||||||
// add to existing alias
|
// add to existing alias
|
||||||
$return->addElement(new htmlSubTitle(_('Add to existing alias')), true);
|
$return->addElement(new htmlSubTitle(_('Add to existing alias')), true);
|
||||||
$aliasesToAdd = array();
|
$aliasesToAdd = array();
|
||||||
|
@ -388,7 +397,7 @@ class nisMailAliasUser extends baseModule {
|
||||||
$addButton->setIconClass('createButton');
|
$addButton->setIconClass('createButton');
|
||||||
$addButton->colspan = 5;
|
$addButton->colspan = 5;
|
||||||
$return->addElement($addButton, true);
|
$return->addElement($addButton, true);
|
||||||
|
|
||||||
$return->addElement(new htmlEqualWidth(array('new_ou', 'new_cn', 'ex_cn')));
|
$return->addElement(new htmlEqualWidth(array('new_ou', 'new_cn', 'ex_cn')));
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
@ -446,13 +455,13 @@ class nisMailAliasUser extends baseModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows the module to run commands after the LDAP entry is changed or created.
|
* Allows the module to run commands after the LDAP entry is changed or created.
|
||||||
*
|
*
|
||||||
* Calling this method requires the existence of an enclosing {@link accountContainer}.
|
* Calling this method requires the existence of an enclosing {@link accountContainer}.
|
||||||
*
|
*
|
||||||
* @param boolean $newAccount new account
|
* @param boolean $newAccount new account
|
||||||
|
@ -545,7 +554,7 @@ class nisMailAliasUser extends baseModule {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of configuration options.
|
* Returns a list of configuration options.
|
||||||
*
|
*
|
||||||
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
|
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
|
||||||
* <br>
|
* <br>
|
||||||
* The field names are used as keywords to load and save settings.
|
* The field names are used as keywords to load and save settings.
|
||||||
|
@ -554,7 +563,7 @@ class nisMailAliasUser extends baseModule {
|
||||||
* @param array $scopes account types (user, group, host)
|
* @param array $scopes account types (user, group, host)
|
||||||
* @param array $allScopes list of all active account modules and their scopes (module => array(scopes))
|
* @param array $allScopes list of all active account modules and their scopes (module => array(scopes))
|
||||||
* @return mixed htmlElement or array of htmlElement
|
* @return mixed htmlElement or array of htmlElement
|
||||||
*
|
*
|
||||||
* @see baseModule::get_metaData()
|
* @see baseModule::get_metaData()
|
||||||
* @see htmlElement
|
* @see htmlElement
|
||||||
*/
|
*/
|
||||||
|
@ -584,10 +593,10 @@ class nisMailAliasUser extends baseModule {
|
||||||
$this->cachedAliasList = searchLDAPByAttribute('cn', '*', 'nisMailAlias', array('dn', 'cn', 'rfc822MailMember'), array('mailAlias'));
|
$this->cachedAliasList = searchLDAPByAttribute('cn', '*', 'nisMailAlias', array('dn', 'cn', 'rfc822MailMember'), array('mailAlias'));
|
||||||
return $this->cachedAliasList;
|
return $this->cachedAliasList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the user name of this account.
|
* Returns the user name of this account.
|
||||||
*
|
*
|
||||||
* @return String user name
|
* @return String user name
|
||||||
*/
|
*/
|
||||||
private function getUserName() {
|
private function getUserName() {
|
||||||
|
@ -605,10 +614,10 @@ class nisMailAliasUser extends baseModule {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the email addresses of this account.
|
* Returns the email addresses of this account.
|
||||||
*
|
*
|
||||||
* @return String mail addresses
|
* @return String mail addresses
|
||||||
*/
|
*/
|
||||||
private function getMailAddresses() {
|
private function getMailAddresses() {
|
||||||
|
@ -620,10 +629,10 @@ class nisMailAliasUser extends baseModule {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the mail alias type is active. Otherwise, aliases cannot be managed.
|
* Returns if the mail alias type is active. Otherwise, aliases cannot be managed.
|
||||||
*
|
*
|
||||||
* @return boolean is active
|
* @return boolean is active
|
||||||
*/
|
*/
|
||||||
private function isMailAliasTypeActive() {
|
private function isMailAliasTypeActive() {
|
||||||
|
|
|
@ -389,6 +389,23 @@ class TypeManager {
|
||||||
return $configuredTypes;
|
return $configuredTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of configured types for this scope.
|
||||||
|
*
|
||||||
|
* @param string $scope scope (e.g. user)
|
||||||
|
* @return \LAM\TYPES\ConfiguredType[] list of ConfiguredType
|
||||||
|
*/
|
||||||
|
public function getConfiguredTypesForScope($scope) {
|
||||||
|
$allTypes = $this->getConfiguredTypes();
|
||||||
|
$scopedTypes = array();
|
||||||
|
foreach ($allTypes as $type) {
|
||||||
|
if ($type->getScope() == $scope) {
|
||||||
|
$scopedTypes[] = $type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $scopedTypes;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a configured account type.
|
* Builds a configured account type.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue