From 435604544bfe22225ac0eec7f907b9171a56285c Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Mon, 13 Jul 2015 16:33:56 +0000 Subject: [PATCH] use extended upload function --- lam/lib/modules/account.inc | 17 ++++---------- lam/lib/modules/asteriskExtension.inc | 2 +- lam/lib/modules/asteriskVoicemail.inc | 26 ++++++++++----------- lam/lib/modules/authorizedServiceObject.inc | 22 ++++------------- 4 files changed, 24 insertions(+), 43 deletions(-) diff --git a/lam/lib/modules/account.inc b/lam/lib/modules/account.inc index 11ce5e82..6899f6ea 100644 --- a/lam/lib/modules/account.inc +++ b/lam/lib/modules/account.inc @@ -40,7 +40,7 @@ class account 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() { @@ -51,7 +51,7 @@ class account extends baseModule { * Returns meta data that is interpreted by parent class * * @return array array with meta data - * + * * @see baseModule::get_metaData() */ function get_metaData() { @@ -199,7 +199,7 @@ class account extends baseModule { /** * Returns the HTML meta data for the main account page. - * + * * @return htmlElement HTML meta data */ function display_html_attributes() { @@ -259,7 +259,7 @@ class account extends baseModule { } return $return; } - + /** * In this function the LDAP account is built up. * @@ -286,14 +286,7 @@ class account extends baseModule { } if (!in_array('posixAccount', $selectedModules)) { // user name - if (get_preg($rawAccounts[$i][$ids['account_uid']], 'username')) { - $partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['account_uid']]; - } - else { - $errMsg = $this->messages['uid'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'account_uid', 'uid', 'username', $this->messages['uid'][1], $messages); } } return $messages; diff --git a/lam/lib/modules/asteriskExtension.inc b/lam/lib/modules/asteriskExtension.inc index 7c69a3b3..a54e14cc 100644 --- a/lam/lib/modules/asteriskExtension.inc +++ b/lam/lib/modules/asteriskExtension.inc @@ -860,7 +860,7 @@ class asteriskExtension extends baseModule { if (!in_array("groupOfNames", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "groupOfNames"; // attributes - $partialAccounts[$i]['AstExtension'] = $rawAccounts[$i][$ids['asteriskExtension_AstExtension']]; + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskExtension_AstExtension', 'AstExtension'); $extensionName = $partialAccounts[$i]['AstExtension']; $astPriorityTmp = 0; diff --git a/lam/lib/modules/asteriskVoicemail.inc b/lam/lib/modules/asteriskVoicemail.inc index 34aba12d..9bbccd95 100644 --- a/lam/lib/modules/asteriskVoicemail.inc +++ b/lam/lib/modules/asteriskVoicemail.inc @@ -52,7 +52,7 @@ class asteriskVoicemail extends baseModule implements passwordService { /** * Returns true if this module can manage accounts of the current type, otherwise false. - * + * * @return boolean true if module fits */ public function can_manage() { @@ -210,7 +210,7 @@ class asteriskVoicemail extends baseModule implements passwordService { $this->messages['AstVoicemailMailbox'][1] = array('ERROR', _('The mailbox format is invalid.')); $this->messages['AstVoicemailMailbox'][2] = array('ERROR', _('There is already another user with this mailbox name.')); $this->messages['AstVoicemailMailbox'][3] = array('ERROR', _('Account %s:') . ' asteriskVoicemail_AstVoicemailMailbox', _('The mailbox format is invalid.')); - + $this->messages['AstContext'][0] = array('ERROR', _('Please enter the account context.')); $this->messages['AstContext'][1] = array('ERROR', _('The account context is invalid.')); $this->messages['AstContext'][2] = array('ERROR', _('Account %s:') . ' asteriskVoicemail_AstContext', _('The account context is invalid.')); @@ -230,7 +230,7 @@ class asteriskVoicemail extends baseModule implements passwordService { /** * Returns the HTML meta data for the main account page. - * + * * @return htmlElement HTML meta data */ function display_html_attributes() { @@ -245,7 +245,7 @@ class asteriskVoicemail extends baseModule implements passwordService { $this->addSimpleInputTextField($return, 'AstVoicemailMailbox', _("Mailbox"), true); // account context $this->addSimpleInputTextField($return, 'AstContext', _("Account context"), true); - + $return->addElement(new htmlSpacer(null, '10px'), true); // full name @@ -393,7 +393,7 @@ class asteriskVoicemail extends baseModule implements passwordService { for ($i = 0; $i < sizeof($rawAccounts); $i++) { // add object class if (!in_array("AsteriskVoiceMail", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "AsteriskVoiceMail"; - + //add context if (empty($rawAccounts[$i][$ids['asteriskVoicemail_AstContext']])) { // default value @@ -403,10 +403,10 @@ class asteriskVoicemail extends baseModule implements passwordService { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskVoicemail_AstContext', 'AstContext', 'realname', $this->messages['AstContext'][2], $messages); } - + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskVoicemail_AstVoicemailMailbox', 'AstVoicemailMailbox', 'realname', $this->messages['AstVoicemailMailbox'][3], $messages); - + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskVoicemail_AstVoicemailEmail', 'AstVoicemailEmail', 'email', $this->messages['AstVoicemailEmail'][1], $messages); @@ -421,7 +421,7 @@ class asteriskVoicemail extends baseModule implements passwordService { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskVoicemail_AstVoicemailContext', 'AstVoicemailContext', 'realname', $this->messages['AstVoicemailContext'][1], $messages); - $partialAccounts[$i]['AstVoicemailPassword'] = $rawAccounts[$i][$ids['asteriskVoicemail_AstVoicemailPassword']]; + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskVoicemail_AstVoicemailPassword', 'AstVoicemailPassword'); } return $messages; } @@ -436,7 +436,7 @@ class asteriskVoicemail extends baseModule implements passwordService { if(!isset($this->attributes['AstVoicemailPassword'][0]) || $this->attributes['AstVoicemailPassword'][0] == "" ) { return false; } - } + } return true; } @@ -475,13 +475,13 @@ class asteriskVoicemail extends baseModule implements passwordService { /** * Specifies if this module supports to force that a user must change his password on next login. - * + * * @return boolean force password change supported */ public function supportsForcePasswordChange() { return false; } - + /** * This function is called whenever the password should be changed. Account modules * must change their password attributes only if the modules list contains their module name. @@ -500,7 +500,7 @@ class asteriskVoicemail extends baseModule implements passwordService { $this->attributes['AstVoicemailPassword'][0] = $password; return array(); } - + /** * Checks if all input values are correct and returns the LDAP attributes which should be changed. *
Return values: @@ -509,7 +509,7 @@ class asteriskVoicemail extends baseModule implements passwordService { *
del: array of attributes to remove *
mod: array of attributes to modify *
info: array of values with informational value (e.g. to be used later by pre/postModify actions) - * + * * Calling this method does not require the existence of an enclosing {@link accountContainer}. * * @param string $fields input fields diff --git a/lam/lib/modules/authorizedServiceObject.inc b/lam/lib/modules/authorizedServiceObject.inc index eaaa0f62..17d99885 100644 --- a/lam/lib/modules/authorizedServiceObject.inc +++ b/lam/lib/modules/authorizedServiceObject.inc @@ -51,7 +51,7 @@ class authorizedServiceObject 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() { @@ -98,7 +98,7 @@ class authorizedServiceObject extends baseModule { $configContainer = new htmlTable(); $configContainer->addElement(new htmlTableExtendedInputTextarea('authorizedServiceObject_services', "sshd\r\nimap", 30, 5, _('Predefined services'), 'predefinedServices')); $return['config_options']['all'] = $configContainer; - // upload fields + // upload fields $return['upload_columns'] = array( array( 'name' => 'authorizedService', @@ -152,7 +152,7 @@ class authorizedServiceObject extends baseModule { /** * Returns the HTML meta data for the main account page. - * + * * @return htmlElement HTML meta data */ function display_html_attributes() { @@ -175,7 +175,7 @@ class authorizedServiceObject extends baseModule { $return->addElement(new htmlAccountPageButton('authorizedServiceObject', 'attributes', 'addObjectClass', _('Add Authorized Service extension'))); } - + return $return; } @@ -215,19 +215,7 @@ class authorizedServiceObject extends baseModule { // add object class if (!in_array("authorizedServiceObject", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "authorizedServiceObject"; // add ASs - if ($rawAccounts[$i][$ids['authorizedService']] != "") { - $services = explode(', ', $rawAccounts[$i][$ids['authorizedService']]); - for ($m = 0; $m < sizeof($services); $m++) { - if (get_preg($services[$m], 'ascii')) { - $partialAccounts[$i]['authorizedService'][] = $services[$m]; - } - else { - $errMsg = $this->messages['authorizedService'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'authorizedService', 'authorizedService', 'ascii', $this->messages['authorizedService'][1], $messages, '/,[ ]*/'); } return $messages; }