From 619d37861c136e6e31cf751f7055904d43040d82 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Mon, 29 May 2017 19:01:36 +0200 Subject: [PATCH] courier mail aliases --- lam/HISTORY | 1 + lam/graphics/courierMail.png | Bin 0 -> 1345 bytes lam/lib/modules/courierMailAlias.inc | 231 +++++++++++++++++++++++++++ 3 files changed, 232 insertions(+) create mode 100644 lam/graphics/courierMail.png create mode 100644 lam/lib/modules/courierMailAlias.inc 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 0000000000000000000000000000000000000000..4c620eabfef182d2eda1622b6753c59c7cacaa93 GIT binary patch literal 1345 zcmV-H1-|-;P)rKPq!3gum;h&Yg^vPK0bx`4*XvMtUSw?#L$glqv>h=0g1VTp5bBa6CC zlx$hpGBU;R)X{${rlt2*V%ONCQ0=%$4gg}Y_ozY|-WTo{eJeU3=0>1IJUE@jFxnZ| zWz_q*iGvN{a-aLQMY=h|q1Dtxl{X*DuFy1O@rn15rv8~8ol&G5D^+}a`|R;)e}npu zUHOsWrPi^;p%yZ>$%`(&^T`?Q{kQmM;+7)p+r!_jOWAAf@ou4!p6}!LT*y1u2PR-4 zU;w}!n6&kH0cjr=CB0f(c!evS!4l(&fDL6)@+GYvg7JT~BX`0Z`>VG0nk|uzLe2{` z((`2k7mU<%`|t0r-jn}KP}ns$z`{;FvbW>mPsvB>@=x3`TjKZvS&yM~fk04cJ*Ir4 zB~a(v?;*|KMl>Di=T*su&y{fZ5mNrhy>ZmP-#ZIK2qUmcS2GL)>!V!@$SQ1G z=I|_@6$!>Bm6~OZx&v-x9w1->O^@kWE>paM7_qa>^F;CLFOVDlA|?$%Pz@05zA6I5 z5>^b|FH8>_2L~uSN*V3k#%C?!jV(!^A-C`tx&d4wz`+Q12wjJ%3-=~0l&$nqx{5QS zwo}=(*VYEWUY7|7BsM+6AQJHkp9KS&OPtf*Rx+NE48wpB!ub>z7tfiW?lPeqenJ5{ z&D2KBON0=(a_FPKdtwM(W_k=w@GQ{P7UDIA2>!v1!6BYVu8Hn43j>p#7JsbM07~C^ z3tadvlPpDoJH0dC?7i)DC60&&BEd*ds3=?4Q-LoH^i0G&<;55H6_Mj5)mZjqYi6WAHJ5B{!gX?CU8>jBtYg9srrFG(K;!BZusGCFc} ztHV^ETEj691HN|6eV2r5O?Dn?XEwP2b-YklXBH(0oM+|=rI)Y z7c`z@Q-&9Onx930i37-1wU?jYcksc@kL;zTuc_XV6A}3%XJ#Aqc9*FOF1~lVlVMo9 zbb9jDmvWW{R!qOoxkIf_K6*Hj2=3ZTtE%7pL&o`|U$^M=^pu>@1bNh5ss5ni>C>;* zzj5H4Q84dd|Nw z42JWVFiFw}igy%6M7WU={y+dGhN?ree$BjM?+cw3BYU&HXlp_Gaxu|b`}}`47@Oq> z&TcEeY%p(j6(%jAJTo_T?N{_|*U`TpFp~PFL%R;Od~@6g$Q%WU3dt+VPI~*matYCJ z#W)BwrO5&D_4dlmRqf@kT^erPIajE!N7}g*)%KHHqEdfeDiP1SfH?=mf-{J;qus#+ zrXhs^auO^ujP{t|>n#iD_wx*S>?MS0{z4WKXo2+~$q)H}adFtj00000NkvXXu0mjf DSHgy2 literal 0 HcmV?d00001 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