From b8f7d87864289a5b6db4a5834983f674e580cd21 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 15 Aug 2015 18:11:54 +0000 Subject: [PATCH] use extended upload function --- lam/lib/modules/ieee802device.inc | 25 +++----- lam/lib/modules/inetLocalMailRecipient.inc | 21 ++----- lam/lib/modules/kolabGroup.inc | 54 +++++------------- lam/lib/modules/kolabSharedFolder.inc | 66 +++++----------------- 4 files changed, 38 insertions(+), 128 deletions(-) diff --git a/lam/lib/modules/ieee802device.inc b/lam/lib/modules/ieee802device.inc index 72006da5..f6868274 100644 --- a/lam/lib/modules/ieee802device.inc +++ b/lam/lib/modules/ieee802device.inc @@ -36,7 +36,7 @@ class ieee802device extends baseModule { /** * Returns true if this module can manage accounts of the current type, otherwise false. - * + * * @return boolean true if module fits */ public function can_manage() { @@ -47,7 +47,7 @@ class ieee802device extends baseModule { * Returns meta data that is interpreted by parent class * * @return array array with meta data - * + * * @see baseModule::get_metaData() */ function get_metaData() { @@ -98,7 +98,7 @@ class ieee802device extends baseModule { /** * Returns the HTML meta data for the main account page. - * + * * @return htmlElement HTML meta data */ function display_html_attributes() { @@ -132,22 +132,11 @@ class ieee802device extends baseModule { $messages = array(); for ($i = 0; $i < sizeof($rawAccounts); $i++) { // add object class - if (!in_array("ieee802Device", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "ieee802Device"; - // add MACs - if ($rawAccounts[$i][$ids['ieee802Device_mac']] != "") { - $macs = explode(',', $rawAccounts[$i][$ids['ieee802Device_mac']]); - // check format - for ($m = 0; $m < sizeof($macs); $m++) { - if (get_preg($macs[$m], 'macAddress')) { - $partialAccounts[$i]['macAddress'][] = $macs[$m]; - } - else { - $errMsg = $this->messages['macAddress'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - } + if (!in_array("ieee802Device", $partialAccounts[$i]['objectClass'])) { + $partialAccounts[$i]['objectClass'][] = "ieee802Device"; } + // add MACs + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'ieee802Device_mac', 'macAddress', 'macAddress', $this->messages['macAddress'][1], $messages, '/,[ ]*/'); } return $messages; } diff --git a/lam/lib/modules/inetLocalMailRecipient.inc b/lam/lib/modules/inetLocalMailRecipient.inc index 330eb21a..dfff213b 100644 --- a/lam/lib/modules/inetLocalMailRecipient.inc +++ b/lam/lib/modules/inetLocalMailRecipient.inc @@ -36,7 +36,7 @@ class inetLocalMailRecipient extends baseModule { /** * Returns true if this module can manage accounts of the current type, otherwise false. - * + * * @return boolean true if module fits */ public function can_manage() { @@ -47,7 +47,7 @@ class inetLocalMailRecipient extends baseModule { * Returns meta data that is interpreted by parent class * * @return array array with meta data - * + * * @see baseModule::get_metaData() */ function get_metaData() { @@ -137,7 +137,7 @@ class inetLocalMailRecipient extends baseModule { /** * Returns the HTML meta data for the main account page. - * + * * @return htmlElement HTML meta data */ function display_html_attributes() { @@ -258,20 +258,7 @@ class inetLocalMailRecipient extends baseModule { // add object class if (!in_array("inetLocalMailRecipient", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "inetLocalMailRecipient"; // add local addresses - if ($rawAccounts[$i][$ids['inetLocalMailRecipient_localAdr']] != "") { - $adrs = explode(',', $rawAccounts[$i][$ids['inetLocalMailRecipient_localAdr']]); - // check format - for ($a = 0; $a < sizeof($adrs); $a++) { - if (get_preg($adrs[$a], 'mailLocalAddress')) { - $partialAccounts[$i]['mailLocalAddress'][] = $adrs[$a]; - } - else { - $errMsg = $this->messages['localAdr'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetLocalMailRecipient_localAdr', 'mailLocalAddress', 'mailLocalAddress', $this->messages['localAdr'][1], $messages, '/,[ ]*/'); // add routing address $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetLocalMailRecipient_routingAdr', 'mailRoutingAddress', 'email', $this->messages['mailRoutingAddress'][1], $messages); diff --git a/lam/lib/modules/kolabGroup.inc b/lam/lib/modules/kolabGroup.inc index 0dbd3c3e..4402dd53 100644 --- a/lam/lib/modules/kolabGroup.inc +++ b/lam/lib/modules/kolabGroup.inc @@ -33,12 +33,12 @@ $Id$ * @package modules */ class kolabGroup extends baseModule { - + /** cache for mail attribute */ private $mailCache = null; /** cache for mailHost values */ private $mailHostCache = null; - + /** * Creates a new kolabGroup object. * @@ -52,7 +52,7 @@ class kolabGroup extends baseModule { /** * Returns true if this module can manage accounts of the current type, otherwise false. - * + * * @return boolean true if module fits */ public function can_manage() { @@ -63,7 +63,7 @@ class kolabGroup extends baseModule { * Returns meta data that is interpreted by parent class * * @return array array with meta data - * + * * @see baseModule::get_metaData() */ function get_metaData() { @@ -186,7 +186,7 @@ class kolabGroup extends baseModule { /** * Returns the HTML meta data for the main account page. - * + * * @return htmlElement HTML meta data */ function display_html_attributes() { @@ -277,7 +277,7 @@ class kolabGroup extends baseModule { /** * This function will create the meta HTML code to show a page to mark an account for deletion. - * + * * @return htmlElement HTML meta data */ function display_html_deleteFlag() { @@ -341,7 +341,7 @@ class kolabGroup extends baseModule { } } } - + /** * In this function the LDAP account is built up. * @@ -382,39 +382,13 @@ class kolabGroup extends baseModule { } } // allowed recipients - if (!empty($rawAccounts[$i][$ids['kolabGroup_kolabAllowSMTPRecipient']])) { - $mails = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['kolabGroup_kolabAllowSMTPRecipient']]); - for ($m = 0; $m < sizeof($mails); $m++) { - if (get_preg($mails[$m], 'kolabEmailPrefix')) { - $partialAccounts[$i]['kolabAllowSMTPRecipient'][] = $mails[$m]; - } - else { - $errMsg = $this->messages['kolabAllowSMTPRecipient'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - break; - } - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabGroup_kolabAllowSMTPRecipient', 'kolabAllowSMTPRecipient', 'kolabEmailPrefix', $this->messages['kolabAllowSMTPRecipient'][1], $messages, '/;[ ]*/'); // allowed senders - if (!empty($rawAccounts[$i][$ids['kolabGroup_kolabAllowSMTPSender']])) { - $mails = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['kolabGroup_kolabAllowSMTPSender']]); - for ($m = 0; $m < sizeof($mails); $m++) { - if (get_preg($mails[$m], 'kolabEmailPrefix')) { - $partialAccounts[$i]['kolabAllowSMTPSender'][] = $mails[$m]; - } - else { - $errMsg = $this->messages['kolabAllowSMTPSender'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - break; - } - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabGroup_kolabAllowSMTPSender', 'kolabAllowSMTPSender', 'kolabEmailPrefix', $this->messages['kolabAllowSMTPSender'][1], $messages, '/;[ ]*/'); } return $messages; } - + /** * Returns a list of possible PDF entries for this account. * @@ -428,10 +402,10 @@ class kolabGroup extends baseModule { $this->addSimplePDFField($return, 'kolabAllowSMTPSender', _('Allowed senders')); return $return; } - + /** * Returns if the mail attribute should be managed. - * + * * @return boolean manage mail attribute */ private function manageMail() { @@ -462,7 +436,7 @@ class kolabGroup extends baseModule { } } } - + /** * Loads the list of mail hosts into the cache. */ @@ -478,7 +452,7 @@ class kolabGroup extends baseModule { } } } - + } diff --git a/lam/lib/modules/kolabSharedFolder.inc b/lam/lib/modules/kolabSharedFolder.inc index 49e622dc..649588e7 100644 --- a/lam/lib/modules/kolabSharedFolder.inc +++ b/lam/lib/modules/kolabSharedFolder.inc @@ -33,13 +33,13 @@ $Id$ * @package modules */ class kolabSharedFolder extends baseModule { // TODO folder type - + /** cache for mailHost values */ private $mailHostCache = null; - + /** list of folder types (label => id) */ private $folderTypes = array(); - + /** * Creates a new kolabSharedFolder object. * @@ -60,7 +60,7 @@ class kolabSharedFolder extends baseModule { // TODO folder type /** * Returns true if this module can manage accounts of the current type, otherwise false. - * + * * @return boolean true if module fits */ public function can_manage() { @@ -71,7 +71,7 @@ class kolabSharedFolder extends baseModule { // TODO folder type * Returns meta data that is interpreted by parent class * * @return array array with meta data - * + * * @see baseModule::get_metaData() */ function get_metaData() { @@ -264,7 +264,7 @@ class kolabSharedFolder extends baseModule { // TODO folder type /** * Returns the HTML meta data for the main account page. - * + * * @return htmlElement HTML meta data */ function display_html_attributes() { @@ -417,7 +417,7 @@ class kolabSharedFolder extends baseModule { // TODO folder type /** * This function will create the meta HTML code to show a page to mark an account for deletion. - * + * * @return htmlElement HTML meta data */ function display_html_deleteFlag() { @@ -484,51 +484,11 @@ class kolabSharedFolder extends baseModule { // TODO folder type // folder type $partialAccounts[$i]['kolabFolderType'] = $rawAccounts[$i][$ids['kolabSharedFolder_kolabFolderType']]; // allowed recipients - if (!empty($rawAccounts[$i][$ids['kolabSharedFolder_kolabAllowSMTPRecipient']])) { - $mails = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['kolabSharedFolder_kolabAllowSMTPRecipient']]); - for ($m = 0; $m < sizeof($mails); $m++) { - if (get_preg($mails[$m], 'kolabEmailPrefix')) { - $partialAccounts[$i]['kolabAllowSMTPRecipient'][] = $mails[$m]; - } - else { - $errMsg = $this->messages['kolabAllowSMTPRecipient'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - break; - } - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabSharedFolder_kolabAllowSMTPRecipient', 'kolabAllowSMTPRecipient', 'kolabEmailPrefix', $this->messages['kolabAllowSMTPRecipient'][1], $messages, '/;[ ]*/'); // allowed senders - if (!empty($rawAccounts[$i][$ids['kolabSharedFolder_kolabAllowSMTPSender']])) { - $mails = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['kolabSharedFolder_kolabAllowSMTPSender']]); - for ($m = 0; $m < sizeof($mails); $m++) { - if (get_preg($mails[$m], 'kolabEmailPrefix')) { - $partialAccounts[$i]['kolabAllowSMTPSender'][] = $mails[$m]; - } - else { - $errMsg = $this->messages['kolabAllowSMTPSender'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - break; - } - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabSharedFolder_kolabAllowSMTPSender', 'kolabAllowSMTPSender', 'kolabEmailPrefix', $this->messages['kolabAllowSMTPSender'][1], $messages, '/;[ ]*/'); // add mail aliases - if ($rawAccounts[$i][$ids['kolabSharedFolder_aliases']] != "") { - $aliases = explode(',', $rawAccounts[$i][$ids['kolabSharedFolder_aliases']]); - // check format - for ($a = 0; $a < sizeof($aliases); $a++) { - if (get_preg($aliases[$a], 'email')) { - $partialAccounts[$i]['alias'][] = $aliases[$a]; - } - // invalid format - else { - $errMsg = $this->messages['alias'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabSharedFolder_aliases', 'alias', 'email', $this->messages['alias'][1], $messages, '/,[ ]*/'); // add delegates if ($rawAccounts[$i][$ids['kolabSharedFolder_delegates']] != "") { $newDelegates = explode(',', $rawAccounts[$i][$ids['kolabSharedFolder_delegates']]); @@ -548,7 +508,7 @@ class kolabSharedFolder extends baseModule { // TODO folder type } return $messages; } - + /** * Returns a list of possible PDF entries for this account. * @@ -575,7 +535,7 @@ class kolabSharedFolder extends baseModule { // TODO folder type } return $return; } - + /** * Loads the list of mail hosts into the cache. */ @@ -591,7 +551,7 @@ class kolabSharedFolder extends baseModule { // TODO folder type } } } - + }