diff --git a/lam/HISTORY b/lam/HISTORY
index a86a8763..84db0271 100644
--- a/lam/HISTORY
+++ b/lam/HISTORY
@@ -2,6 +2,9 @@ December 2015 5.2
- Windows: support for additional attributes
- SSH public key: added possibility to add/remove SSH extension
- MIT Kerberos: set krbExtraData for new accounts
+ - IMAP: allow to specify initial folders to create
+ - LAM Pro:
+ -> Users: allow to manage IP addresses with ipHost module
31.08.2015 5.1
diff --git a/lam/docs/manual-sources/howto.xml b/lam/docs/manual-sources/howto.xml
index 74a0eee2..d2244038 100644
--- a/lam/docs/manual-sources/howto.xml
+++ b/lam/docs/manual-sources/howto.xml
@@ -1286,7 +1286,7 @@ Have fun!
Open LAM (Pro) login page on new server and verify
- installation.
+ installation.
@@ -3819,6 +3819,9 @@ mysql> GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
"user/myUser"). Select the values depending on your IMAP server
settings.
+ You can specify a list of initial folder names to create for new
+ mailboxes. LAM will then create them with each new mailbox.
+
@@ -3840,6 +3843,33 @@ mysql> GRANT ALL PRIVILEGES ON lam_cron.* TO 'lam_cron'@'localhost';
+
+ IP addresses (LAM Pro)
+
+ You can manage the IP addresses of user accounts (e.g. assigned
+ by DHCP) with the ipHost module.
+
+ Configuration
+
+
+
+
+
+
+
+
+
+ User editing
+
+
+
+
+
+
+
+
+
+
Account
diff --git a/lam/docs/manual-sources/images/imapAccess2.png b/lam/docs/manual-sources/images/imapAccess2.png
index 59ffd921..7f1c3a81 100644
Binary files a/lam/docs/manual-sources/images/imapAccess2.png and b/lam/docs/manual-sources/images/imapAccess2.png differ
diff --git a/lam/docs/manual-sources/images/ipHostUser.png b/lam/docs/manual-sources/images/ipHostUser.png
new file mode 100644
index 00000000..43509051
Binary files /dev/null and b/lam/docs/manual-sources/images/ipHostUser.png differ
diff --git a/lam/docs/manual-sources/images/ipHostUser1.png b/lam/docs/manual-sources/images/ipHostUser1.png
new file mode 100644
index 00000000..e506e046
Binary files /dev/null and b/lam/docs/manual-sources/images/ipHostUser1.png differ
diff --git a/lam/lib/modules/imapAccess.inc b/lam/lib/modules/imapAccess.inc
index d99368c6..34c3f723 100644
--- a/lam/lib/modules/imapAccess.inc
+++ b/lam/lib/modules/imapAccess.inc
@@ -116,41 +116,10 @@ class imapAccess extends baseModule {
'pathSeparator' => array(
"Headline" => _("Path separator"),
"Text" => _("This is the separator for the mailbox path. Usually, this is \".\" but e.g. Cyrus with \"unixhierarchysep\" will require \"/\".")),
+ 'initialFolders' => array(
+ "Headline" => _("Initial folders"),
+ "Text" => _("Use this to provide a list of folders (e.g. Trash) to add for new accounts.")),
);
- // configuration settings
- $configContainer = new htmlTable();
- $configServer = new htmlTableExtendedInputField(_('Server address'), 'ImapAccess_ImapServerAddress', '', 'ImapServerAddress');
- $configServer->setRequired(true);
- $configContainer->addElement($configServer, true);
- $configContainer->addElement(new htmlTableExtendedSelect('ImapAccess_ImapServerEncriptionProtocol', array('TLS', 'SSL'), array('TLS'), _("Encryption protocol"), 'ImapServerEncryptionProtocol'), true);
- $configCertValidate = new htmlTableExtendedSelect('ImapAccess_ImapValidateServerCert', array(_('Yes') => 'validate-cert', _('No') => 'novalidate-cert'), array('validate-cert'), _("Validate server certificate"), 'ImapValidateServerCert');
- $configCertValidate->setHasDescriptiveElements(true);
- $configContainer->addElement($configCertValidate, true);
- $configUser = new htmlTableExtendedInputField(_('IMAP admin user'), 'ImapAccess_ImapAdmin', '', 'ImapAdmin');
- $configUser->setRequired(true);
- $configContainer->addElement($configUser, true);
- $pwdSelectOptions = array(
- _('LAM user password') => 'lam_user_pass',
- _('Ask') => 'ask_pass',
- _('Server profile') => 'config');
- $configPasswordType = new htmlTableExtendedSelect('ImapAccess_ImapAdminPasswordSelect', $pwdSelectOptions, array('ask_pass'), _("IMAP password input"), 'ImapAdminPasswordSelect');
- $configPasswordType->setHasDescriptiveElements(true);
- $configPasswordType->setTableRowsToShow(array('config' => array('ImapAccess_ImapAdminPassword')));
- $configPasswordType->setTableRowsToHide(array('lam_user_pass' => array('ImapAccess_ImapAdminPassword'), 'ask_pass' => array('ImapAccess_ImapAdminPassword')));
- $configContainer->addElement($configPasswordType, true);
- $adminPwdInput = new htmlTableExtendedInputField(_('Admin password'), 'ImapAccess_ImapAdminPassword', null, 'ImapAdminPasswordSelect');
- $adminPwdInput->setIsPassword(true);
- $adminPwdInput->setObfuscate(true);
- $configContainer->addElement($adminPwdInput, true);
- $mailDomainsInput = new htmlTableExtendedInputField(_('Mail domains'), 'ImapAccess_ImapDomain', '', 'ImapMailDomain');
- $mailDomainsInput->setRequired(true);
- $configContainer->addElement($mailDomainsInput, true);
- $configContainer->addElement(new htmlTableExtendedInputField(_('Prefix for mailboxes'), 'ImapAccess_ImapUserPrefix', '', 'ImapUserPrefix'), true);
- $configUserName = new htmlTableExtendedSelect('ImapAccess_UserNameAttribute', array('mail', 'uid', 'userPrincipalName'), array('mail'), _("User name attribute"), 'ImapUserNameAttr');
- $configContainer->addElement($configUserName, true);
- $configPathSeparator = new htmlTableExtendedSelect('ImapAccess_pathSeparator', array('.', '/'), array('.'), _("Path separator"), 'pathSeparator');
- $configContainer->addElement($configPathSeparator, true);
- $return['config_options']['all'] = $configContainer;
// configuration checks
$return['config_checks']['all']['ImapAccess_ImapServerAddress'] = array (
'type' => 'ext_preg',
@@ -418,12 +387,18 @@ class imapAccess extends baseModule {
$create_mailbox_arg = "{" . $imap_server_address . "}" . $prefix . $this->getSep() . $this->user;
if (imap_createmailbox($mbox, imap_utf7_encode($create_mailbox_arg))) {
$list = imap_list($mbox, "{" . $imap_server_address . "}", $prefix . $this->getSep() . $this->user);
- if (is_array($list) && sizeof($list) == 1) {
-
- }
- else {
+ if (!is_array($list) || (sizeof($list) != 1)) {
$errors[] = $this->messages['managemailbox'][3];
}
+ // create initial folders
+ foreach ($this->getInitialFolders() as $folder) {
+ $created = imap_createmailbox($mbox, imap_utf7_encode($create_mailbox_arg . $this->getSep() . $folder));
+ if (!$created) {
+ $error = $this->messages['managemailbox'][2];
+ $error[] = htmlspecialchars($folder);
+ $errors[] = $error;
+ }
+ }
}
else {
$errors[] = $this->messages['managemailbox'][2];
@@ -474,6 +449,57 @@ class imapAccess extends baseModule {
}
}
+ /**
+ * Returns a list of configuration options.
+ *
+ * @param array $scopes account types (user, group, host)
+ * @param array $allScopes list of all active account modules and their scopes (module => array(scopes))
+ * @return mixed htmlElement or array of htmlElement
+ *
+ * @see htmlElement
+ */
+ public function get_configOptions($scopes, $allScopes) {
+ // configuration settings
+ $configContainer = new htmlTable();
+ $configServer = new htmlTableExtendedInputField(_('Server address'), 'ImapAccess_ImapServerAddress', '', 'ImapServerAddress');
+ $configServer->setRequired(true);
+ $configContainer->addElement($configServer, true);
+ $configContainer->addElement(new htmlTableExtendedSelect('ImapAccess_ImapServerEncriptionProtocol', array('TLS', 'SSL'), array('TLS'), _("Encryption protocol"), 'ImapServerEncryptionProtocol'), true);
+ $configCertValidate = new htmlTableExtendedSelect('ImapAccess_ImapValidateServerCert', array(_('Yes') => 'validate-cert', _('No') => 'novalidate-cert'), array('validate-cert'), _("Validate server certificate"), 'ImapValidateServerCert');
+ $configCertValidate->setHasDescriptiveElements(true);
+ $configContainer->addElement($configCertValidate, true);
+ $configUser = new htmlTableExtendedInputField(_('IMAP admin user'), 'ImapAccess_ImapAdmin', '', 'ImapAdmin');
+ $configUser->setRequired(true);
+ $configContainer->addElement($configUser, true);
+ $pwdSelectOptions = array(
+ _('LAM user password') => 'lam_user_pass',
+ _('Ask') => 'ask_pass',
+ _('Server profile') => 'config');
+ $configPasswordType = new htmlTableExtendedSelect('ImapAccess_ImapAdminPasswordSelect', $pwdSelectOptions, array('ask_pass'), _("IMAP password input"), 'ImapAdminPasswordSelect');
+ $configPasswordType->setHasDescriptiveElements(true);
+ $configPasswordType->setTableRowsToShow(array('config' => array('ImapAccess_ImapAdminPassword')));
+ $configPasswordType->setTableRowsToHide(array('lam_user_pass' => array('ImapAccess_ImapAdminPassword'), 'ask_pass' => array('ImapAccess_ImapAdminPassword')));
+ $configContainer->addElement($configPasswordType, true);
+ $adminPwdInput = new htmlTableExtendedInputField(_('Admin password'), 'ImapAccess_ImapAdminPassword', null, 'ImapAdminPasswordSelect');
+ $adminPwdInput->setIsPassword(true);
+ $adminPwdInput->setObfuscate(true);
+ $configContainer->addElement($adminPwdInput, true);
+ $mailDomainsInput = new htmlTableExtendedInputField(_('Mail domains'), 'ImapAccess_ImapDomain', '', 'ImapMailDomain');
+ $mailDomainsInput->setRequired(true);
+ $configContainer->addElement($mailDomainsInput, true);
+ $configContainer->addElement(new htmlTableExtendedInputField(_('Prefix for mailboxes'), 'ImapAccess_ImapUserPrefix', '', 'ImapUserPrefix'), true);
+ $configContainer->addElement(new htmlTableExtendedInputTextarea('ImapAccess_initialFolders', '', 10, 3, _('Initial folders'), 'initialFolders'), true);
+ $configUserName = new htmlTableExtendedSelect('ImapAccess_UserNameAttribute', array('mail', 'uid', 'userPrincipalName'), array('mail'), _("User name attribute"), 'ImapUserNameAttr');
+ $configContainer->addElement($configUserName, true);
+ $configPathSeparator = new htmlTableExtendedSelect('ImapAccess_pathSeparator', array('.', '/'), array('.'), _("Path separator"), 'pathSeparator');
+ $configContainer->addElement($configPathSeparator, true);
+ $configContainer->addElement(new htmlEqualWidth(array('ImapAccess_ImapServerAddress', 'ImapAccess_initialFolders', 'ImapAccess_UserNameAttribute',
+ 'ImapAccess_ImapServerEncriptionProtocol', 'ImapAccess_ImapValidateServerCert', 'ImapAccess_ImapAdminPasswordSelect',
+ 'ImapAccess_pathSeparator'
+ )));
+ return $configContainer;
+ }
+
/**
* Checks input values of module settings.
*
@@ -673,6 +699,24 @@ class imapAccess extends baseModule {
return '.'; // default
}
+ /**
+ * Returns the list of initial folders to create for a new mailbox.
+ *
+ * @return array list of folders
+ */
+ private function getInitialFolders() {
+ $list = array();
+ if (!empty($this->moduleSettings['ImapAccess_initialFolders'])) {
+ foreach ($this->moduleSettings['ImapAccess_initialFolders'] as $folder) {
+ $folder = trim($folder);
+ if (!empty($folder)) {
+ $list[] = $folder;
+ }
+ }
+ }
+ return $list;
+ }
+
}
?>