reduced upload code

This commit is contained in:
Roland Gruber 2014-04-12 17:52:33 +00:00
parent 3f830115f1
commit 6d726b9a4c
1 changed files with 43 additions and 173 deletions

View File

@ -1023,45 +1023,23 @@ class asteriskAccount extends baseModule implements passwordService {
// add object class // add object class
if (!in_array("AsteriskSIPUser", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "AsteriskSIPUser"; if (!in_array("AsteriskSIPUser", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "AsteriskSIPUser";
// add account caller id // add account caller id
if (get_preg($rawAccounts[$i][$ids['asteriskAccount_AstAccountCallerID']], 'username')) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountCallerID', 'AstAccountCallerID',
$partialAccounts[$i]['AstAccountCallerID'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountCallerID']]; 'username', $this->messages['AstAccountCallerID'][3], $messages);
}
else {
$errMsg = $this->messages['AstAccountCallerID'][3];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
// add host // add host
if ($rawAccounts[$i][$ids['asteriskAccount_AstAccountHost']] == "") { if (empty($rawAccounts[$i][$ids['asteriskAccount_AstAccountHost']])) {
// default value // default value
$partialAccounts[$i]['AstAccountHost'] = 'dynamic'; $partialAccounts[$i]['AstAccountHost'] = 'dynamic';
} }
elseif (get_preg($rawAccounts[$i][$ids['asteriskAccount_AstAccountHost']], 'realname')) {
$partialAccounts[$i]['AstAccountHost'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountHost']];
}
else { else {
$errMsg = $this->messages['AstAccountHost'][2]; $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountHost', 'AstAccountHost',
array_push($errMsg, array($i)); 'realname', $this->messages['AstAccountHost'][2], $messages);
$messages[] = $errMsg;
} }
//add context //add context
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountContext']] != "") && (get_preg($rawAccounts[$i][$ids['asteriskAccount_AstAccountContext']], 'realname')) ) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountContext', 'AstAccountContext',
$partialAccounts[$i]['AstAccountContext'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountContext']]; 'realname', $this->messages['AstAccountContext'][2], $messages);
}
else {
$errMsg = $this->messages['AstAccountContext'][2];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
//add account type //add account type
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountType']] != "") && (get_preg($rawAccounts[$i][$ids['asteriskAccount_AstAccountType']], 'username')) ) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountType', 'AstAccountType',
$partialAccounts[$i]['AstAccountType'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountType']]; 'username', $this->messages['AstAccountType'][2], $messages);
}
else {
$errMsg = $this->messages['AstAccountType'][2];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
//add password //add password
if ($rawAccounts[$i][$ids['asteriskAccount_AstAccountRealmedPassword']] != "") { if ($rawAccounts[$i][$ids['asteriskAccount_AstAccountRealmedPassword']] != "") {
$attributes = array('AstAccountCallerID' => array($partialAccounts[$i]['AstAccountCallerID'])); // fake attribute list for password building $attributes = array('AstAccountCallerID' => array($partialAccounts[$i]['AstAccountCallerID'])); // fake attribute list for password building
@ -1069,156 +1047,48 @@ class asteriskAccount extends baseModule implements passwordService {
$partialAccounts[$i]['AstAccountRealmedPassword'] = $pwdString; $partialAccounts[$i]['AstAccountRealmedPassword'] = $pwdString;
} }
if ($rawAccounts[$i][$ids['asteriskAccount_AstAccountUserAgent']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountUserAgent', 'AstAccountUserAgent');
$partialAccounts[$i]['AstAccountUserAgent'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountUserAgent']]; $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountAMAFlags', 'AstAccountAMAFlags');
} $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountCallGroup', 'AstAccountCallGroup');
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountDTMFMode', 'AstAccountDTMFMode');
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountAMAFlags']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountFromUser', 'AstAccountFromUser',
$partialAccounts[$i]['AstAccountAMAFlags'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountAMAFlags']]; 'username', $this->messages['AstAccountFromUser'][1], $messages);
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountCallGroup']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountFromDomain', 'AstAccountFromDomain',
$partialAccounts[$i]['AstAccountCallGroup'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountCallGroup']]; 'domainname', $this->messages['AstAccountFromDomain'][1], $messages);
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountDTMFMode']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountFullContact', 'AstAccountFullContact');
$partialAccounts[$i]['AstAccountDTMFMode'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountDTMFMode']]; $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountInsecure', 'AstAccountInsecure');
} $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountMailbox', 'AstAccountMailbox');
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountNAT', 'AstAccountNAT');
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountDeny', 'AstAccountDeny');
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountPermit', 'AstAccountPermit');
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountPickupGroup', 'AstAccountPickupGroup');
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountFromUser']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountPort', 'AstAccountPort',
if (get_preg($rawAccounts[$i][$ids['asteriskAccount_AstAccountFromUser']], 'username')) { 'digit', $this->messages['AstAccountPort'][1], $messages);
$partialAccounts[$i]['AstAccountFromUser'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountFromUser']];
}
else {
$errMsg = $this->messages['AstAccountFromUser'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountFromDomain']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountQualify', 'AstAccountQualify');
if (get_preg($rawAccounts[$i][$ids['asteriskAccount_AstAccountFromDomain']], 'domainname')) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountRestrictCID', 'AstAccountRestrictCID');
$partialAccounts[$i]['AstAccountFromDomain'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountFromDomain']]; $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountRTPTimeout', 'AstAccountRTPTimeout');
} $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountRTPHoldTimeout', 'AstAccountRTPHoldTimeout');
else { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountDisallowedCodec', 'AstAccountDisallowedCodec');
$errMsg = $this->messages['AstAccountFromDomain'][1]; $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountAllowedCodec', 'AstAccountAllowedCodec');
array_push($errMsg, array($i)); $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountMusicOnHold', 'AstAccountMusicOnHold');
$messages[] = $errMsg; $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountExpirationTimestamp', 'AstAccountExpirationTimestamp');
} $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountRegistrationContext', 'AstAccountRegistrationContext');
} $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountRegistrationExten', 'AstAccountRegistrationExten');
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountCanCallForward', 'AstAccountCanCallForward');
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountFullContact']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountIPAddress', 'AstAccountIPAddress',
$partialAccounts[$i]['AstAccountFullContact'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountFullContact']]; 'ip', $this->messages['AstAccountIPAddress'][1], $messages);
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountInsecure']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountDefaultUser', 'AstAccountDefaultUser',
$partialAccounts[$i]['AstAccountInsecure'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountInsecure']]; 'username', $this->messages['AstAccountDefaultUser'][1], $messages);
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountMailbox']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountRegistrationServer', 'AstAccountRegistrationServer');
$partialAccounts[$i]['AstAccountMailbox'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountMailbox']]; $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskAccount_AstAccountLastQualifyMilliseconds', 'AstAccountLastQualifyMilliseconds');
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountNAT']] != "")) {
$partialAccounts[$i]['AstAccountNAT'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountNAT']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountDeny']] != "")) {
$partialAccounts[$i]['AstAccountDeny'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountDeny']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountPermit']] != "")) {
$partialAccounts[$i]['AstAccountPermit'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountPermit']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountPickupGroup']] != "")) {
$partialAccounts[$i]['AstAccountPickupGroup'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountPickupGroup']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountPort']] != "")) {
if (get_preg($rawAccounts[$i][$ids['asteriskAccount_AstAccountPort']], 'digit')) {
$partialAccounts[$i]['AstAccountPort'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountPort']];
}
else {
$errMsg = $this->messages['AstAccountPort'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountQualify']] != "")) {
$partialAccounts[$i]['AstAccountQualify'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountQualify']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountRestrictCID']] != "")) {
$partialAccounts[$i]['AstAccountRestrictCID'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountRestrictCID']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountRTPTimeout']] != "")) {
$partialAccounts[$i]['AstAccountRTPTimeout'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountRTPTimeout']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountRTPHoldTimeout']] != "")) {
$partialAccounts[$i]['AstAccountRTPHoldTimeout'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountRTPHoldTimeout']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountDisallowedCodec']] != "")) {
$partialAccounts[$i]['AstAccountDisallowedCodec'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountDisallowedCodec']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountAllowedCodec']] != "")) {
$partialAccounts[$i]['AstAccountAllowedCodec'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountAllowedCodec']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountMusicOnHold']] != "")) {
$partialAccounts[$i]['AstAccountMusicOnHold'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountMusicOnHold']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountExpirationTimestamp']] != "")) {
$partialAccounts[$i]['AstAccountExpirationTimestamp'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountExpirationTimestamp']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountRegistrationContext']] != "")) {
$partialAccounts[$i]['AstAccountRegistrationContext'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountRegistrationContext']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountRegistrationExten']] != "")) {
$partialAccounts[$i]['AstAccountRegistrationExten'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountRegistrationExten']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountCanCallForward']] != "")) {
$partialAccounts[$i]['AstAccountCanCallForward'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountCanCallForward']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountIPAddress']] != "")) {
if (get_preg($rawAccounts[$i][$ids['asteriskAccount_AstAccountIPAddress']], 'ip')) {
$partialAccounts[$i]['AstAccountIPAddress'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountIPAddress']];
}
else {
$errMsg = $this->messages['AstAccountIPAddress'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountDefaultUser']] != "")) {
if (get_preg($rawAccounts[$i][$ids['asteriskAccount_AstAccountDefaultUser']], 'username')) {
$partialAccounts[$i]['AstAccountDefaultUser'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountDefaultUser']];
}
else {
$errMsg = $this->messages['AstAccountDefaultUser'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountRegistrationServer']] != "")) {
$partialAccounts[$i]['AstAccountRegistrationServer'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountRegistrationServer']];
}
if (($rawAccounts[$i][$ids['asteriskAccount_AstAccountLastQualifyMilliseconds']] != "")) {
$partialAccounts[$i]['AstAccountLastQualifyMilliseconds'] = $rawAccounts[$i][$ids['asteriskAccount_AstAccountLastQualifyMilliseconds']];
}
} }
return $messages; return $messages;
} }