diff --git a/lam/HISTORY b/lam/HISTORY index 039e8df4..659f0a78 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -1,6 +1,7 @@ June 2017 - Support multiple configurations for same account type - PHP 7.1 compatibility + - Courier mail aliases - Samba 3: added account expiration date to PDF fields - Windows: Support unlocking of users with too many failed login attempts - LAM Pro: diff --git a/lam/graphics/courierMail.png b/lam/graphics/courierMail.png new file mode 100644 index 00000000..4c620eab Binary files /dev/null and b/lam/graphics/courierMail.png differ diff --git a/lam/lib/modules/courierMailAlias.inc b/lam/lib/modules/courierMailAlias.inc new file mode 100644 index 00000000..4c9a6b2a --- /dev/null +++ b/lam/lib/modules/courierMailAlias.inc @@ -0,0 +1,231 @@ +get_scope(), array('mailAlias')); + } + + /** + * {@inheritdoc} + */ + function get_metaData() { + $return = array(); + // icon + $return['icon'] = 'courierMail.png'; + // alias name + $return["alias"] = _("Courier"); + // LDAP filter + $return["ldap_filter"] = array( + 'or' => "(objectClass=courierMailAlias)" + ); + // RDN attribute + $return["RDN"] = array( + "mail" => "low" + ); + // module dependencies + $return['dependencies'] = array( + 'depends' => array('nisMailAlias'), + 'conflicts' => array() + ); + // managed object classes + $return['objectClasses'] = array('CourierMailAlias'); + // managed attributes + $return['attributes'] = array('mail', 'maildrop', 'mailsource', 'description'); + // help Entries + $return['help'] = array( + 'mail' => array( + "Headline" => _("Email address"), + "attr" => 'mail', + "Text" => _("This is the email address of the alias.") + ), + 'maildrop' => array( + "Headline" => _("Recipient address"), + "attr" => 'maildrop', + "Text" => _("This is the email address of the recipient user. There can be more than one.") + ), + 'mailsource' => array( + "Headline" => _("Mail source"), + "attr" => 'mailsource', + "Text" => _("The source of email allowed for this alias: local, estmp.") + ), + 'description' => array( + "Headline" => _("Description"), + "attr" => 'description', + "Text" => _('This is an optional description for this entry.') + ) + ); + $return['PDF_fields'] = array( + 'mail' => _('Email address'), + 'maildrop' => _('Recipient address'), + 'mailsource' => _('Mail source'), + 'description' => _('Description') + ); + $return['upload_columns'] = array( + array( + 'name' => 'courierMailAlias_mail', + 'description' => _('Email address'), + 'help' => 'mail', + 'example' => _('group@company.com'), + 'required' => true + ), + array( + 'name' => 'courierMailAlias_maildrop', + 'description' => _('Recipient address'), + 'help' => 'maildrop', + 'example' => _('group1@company.com,group2@company.com'), + 'required' => true + ), + array( + 'name' => 'courierMailAlias_mailsource', + 'description' => _('Mail source'), + 'help' => 'mailsource', + 'values' => 'esmtp, local' + ), + array( + 'name' => 'courierMailAlias_description', + 'description' => _('Description'), + 'help' => 'description', + ), + ); + return $return; + } + + /** + * {@inheritdoc} + */ + function load_Messages() { + $this->messages['maildrop'][0] = array('ERROR', _('Recipient address'), _('Please enter a valid email address!')); + $this->messages['maildrop'][1] = array('ERROR', _('Account %s:') . ' courierMailAlias_maildrop', _('Please enter a valid email address!')); + $this->messages['mailsource'][0] = array('ERROR', _('Account %s:') . ' courierMailAlias_maildrop', _('Please enter a valid mail source.')); + $this->messages['mail'][0] = array('ERROR', _('Email address'), _('Please enter a valid email address!')); + $this->messages['mail'][1] = array('ERROR', _('Account %s:') . ' courierMailAlias_mail', _('Please enter a valid email address!')); + } + + /** + * {@inheritdoc} + */ + function display_html_attributes() { + $return = new htmlTable(); + $mail = (!empty($this->attributes['mail'][0])) ? $this->attributes['mail'][0] : ''; + $boxInput = new htmlTableExtendedInputField (_('Email address'), 'mail', $mail, 'mail', true); + $boxInput->setFieldSize(40); + $boxInput->setFieldMaxLength(40); + $return->addElement($boxInput, true); + $this->addMultiValueInputTextField($return, 'maildrop', _('Recipient address'), true); + $return->addElement(new htmlOutputText(_('Mail source'))); + $selectedSource = (!empty($this->attributes['mailsource'][0])) ? $this->attributes['mailsource'][0] : "-"; + $return->addElement(new htmlSelect('mailsource', array('-', 'esmtp', 'local'), array($selectedSource))); + $return->addElement(new htmlHelpLink('mailsource'), true); + $description = (!empty($this->attributes['description'][0])) ? $this->attributes['description'][0] : ''; + $boxInput = new htmlTableExtendedInputField(_('Description'), 'description', $description, 'description'); + $boxInput->setFieldSize(40); + $boxInput->setFieldMaxLength(100); + $return->addElement($boxInput, true); + return $return; + } + + /** + * {@inheritdoc} + */ + function process_attributes($post = null) { + $errors = array(); + $this->attributes['mail'][0] = $_POST['mail']; + if (empty($this->attributes['mail'][0]) || !get_preg($this->attributes['mail'][0], 'email')) { + $errors[] = $this->messages['mail'][0]; + } + $this->processMultiValueInputTextField('maildrop', $errors, 'mailLocalAddress'); + if (empty($this->attributes['maildrop'])) { + $errors[] = $this->messages['maildrop'][0]; + } + $this->attributes['mailsource'] = array(); + if ($_POST['mailsource'] != "-") { + $this->attributes['mailsource'][0] = $_POST['mailsource']; + } elseif (isset($this->attributes['mailsource'])) { + unset($this->attributes['mailsource']); + } + $this->attributes['description'][0] = $_POST['description']; + return $errors; + } + + /** + * {@inheritdoc} + */ + function get_pdfEntries() { + $return = array(); + $this->addSimplePDFField($return, 'mail', _('Email address')); + $this->addSimplePDFField($return, 'maildrop', _('Recipient address')); + $this->addSimplePDFField($return, 'mailsource', _('Mail source')); + $this->addSimplePDFField($return, 'description', _('Description')); + return $return; + } + + /** + * {@inheritdoc} + */ + function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) { + $messages = array(); + $possibleSources = array('esmtp', 'local'); + for( $i = 0; $i < sizeof($rawAccounts); $i++) { + if (!in_array( "courierMailAlias", $partialAccounts[$i]['objectClass'] )) { + $partialAccounts[$i]['objectClass'][] = "courierMailAlias"; + } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'courierMailAlias_mail', 'mail', 'email', $this->messages['mail'][1], $messages); + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'courierMailAlias_maildrop', 'maildrop', 'mailLocalAddress', $this->messages['maildrop'][1], $messages, '/,[ ]?/'); + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'courierMailAlias_description', 'description'); + if (!empty($rawAccounts[$i][$ids['courierMailAlias_mailsource']])) { + if (in_array($rawAccounts[$i][$ids['courierMailAlias_mailsource']], $possibleSources)) { + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'courierMailAlias_mailsource', 'mailsource'); + } + else { + $error = $this->messages['mailsource'][0]; + array_push($error, array($i)); + $messages[] = $error; + } + } + } + return $messages; + } + +} + +?> \ No newline at end of file