use extended upload function

This commit is contained in:
Roland Gruber 2015-08-16 08:47:48 +00:00
parent b8f7d87864
commit 1f8d1445e8
6 changed files with 49 additions and 133 deletions

View File

@ -670,21 +670,7 @@ class kolabUser extends baseModule {
} }
} }
// add mail aliases // add mail aliases
if ($rawAccounts[$i][$ids['kolabUser_aliases']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabUser_aliases', 'alias', 'email', $this->messages['alias'][1], $messages, '/,[ ]*/');
$aliases = explode(',', $rawAccounts[$i][$ids['kolabUser_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;
}
}
}
// add delegates // add delegates
if ($rawAccounts[$i][$ids['kolabUser_delegates']] != "") { if ($rawAccounts[$i][$ids['kolabUser_delegates']] != "") {
$newDelegates = explode(',', $rawAccounts[$i][$ids['kolabUser_delegates']]); $newDelegates = explode(',', $rawAccounts[$i][$ids['kolabUser_delegates']]);
@ -702,35 +688,9 @@ class kolabUser extends baseModule {
} }
} }
// allowed recipients // allowed recipients
if (!empty($rawAccounts[$i][$ids['kolabUser_kolabAllowSMTPRecipient']])) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabUser_kolabAllowSMTPRecipient', 'kolabAllowSMTPRecipient', 'kolabEmailPrefix', $this->messages['kolabAllowSMTPRecipient'][1], $messages, '/;[ ]*/');
$mails = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['kolabUser_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;
}
}
}
// allowed senders // allowed senders
if (!empty($rawAccounts[$i][$ids['kolabUser_kolabAllowSMTPSender']])) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'kolabUser_kolabAllowSMTPSender', 'kolabAllowSMTPSender', 'kolabEmailPrefix', $this->messages['kolabAllowSMTPSender'][1], $messages, '/;[ ]*/');
$mails = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['kolabUser_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;
}
}
}
} }
return $messages; return $messages;
} }

View File

@ -190,13 +190,7 @@ class ldapPublicKey extends baseModule {
// add object class // add object class
if (!in_array("ldapPublicKey", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "ldapPublicKey"; if (!in_array("ldapPublicKey", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "ldapPublicKey";
// add keys // add keys
if ($rawAccounts[$i][$ids['ldapPublicKey_sshPublicKey']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'ldapPublicKey_sshPublicKey', 'sshPublicKey', null, null, $messages, '/,[ ]*/');
$keys = explode(',', $rawAccounts[$i][$ids['ldapPublicKey_sshPublicKey']]);
// check format
for ($m = 0; $m < sizeof($keys); $m++) {
$partialAccounts[$i]['sshPublicKey'][] = $keys[$m];
}
}
} }
return $messages; return $messages;
} }

View File

@ -443,7 +443,6 @@ class nisMailAlias extends baseModule {
// add object class // add object class
if (!in_array("nisMailAlias", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "nisMailAlias"; if (!in_array("nisMailAlias", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "nisMailAlias";
// add alias name // add alias name
// check format
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'nisMailAlias_alias', 'cn', $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'nisMailAlias_alias', 'cn',
'nis_alias', $this->messages['alias'][1], $messages); 'nis_alias', $this->messages['alias'][1], $messages);
// add recipients // add recipients

View File

@ -549,10 +549,7 @@ class nisnetgroup extends baseModule {
} }
} }
// members // members
if ($rawAccounts[$i][$ids['nisnetgroup_members']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'nisnetgroup_members', 'nisNetgroupTriple', null, null, $messages, '/;[ ]*/');
$members = explode(';', $rawAccounts[$i][$ids['nisnetgroup_members']]);
$partialAccounts[$i]['nisNetgroupTriple'] = $members;
}
} }
return $messages; return $messages;
} }

View File

@ -70,14 +70,7 @@ class posixGroup extends baseModule implements passwordService {
if (!in_array("posixGroup", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixGroup"; if (!in_array("posixGroup", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixGroup";
if ($this->manageCnAttribute) { if ($this->manageCnAttribute) {
// group name // group name
if (get_preg($rawAccounts[$i][$ids['posixGroup_cn']], 'groupname')) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'posixGroup_cn', 'cn', 'groupname', $this->messages['cn'][3], $error_messages);
$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['posixGroup_cn']];
}
else {
$errMsg = $this->messages['cn'][3];
array_push($errMsg, array($i));
$error_messages[] = $errMsg;
}
} }
// GID // GID
if ($rawAccounts[$i][$ids['posixGroup_gid']] == "") { if ($rawAccounts[$i][$ids['posixGroup_gid']] == "") {

View File

@ -381,38 +381,11 @@ class puppetClient extends baseModule {
} }
} }
// environment // environment
if ($rawAccounts[$i][$ids['puppetClient_environment']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'puppetClient_environment', 'environment', 'ascii', $this->messages['environment'][1], $messages, '/;[ ]*/');
if (get_preg($rawAccounts[$i][$ids['puppetClient_environment']], 'ascii')) {
$partialAccounts[$i]['environment'] = explode(';', $rawAccounts[$i][$ids['puppetClient_environment']]);
}
else {
$errMsg = $this->messages['environment'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
// classes // classes
if ($rawAccounts[$i][$ids['puppetClient_puppetclass']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'puppetClient_puppetclass', 'puppetclass', 'ascii', $this->messages['puppetclass'][1], $messages, '/;[ ]*/');
if (get_preg($rawAccounts[$i][$ids['puppetClient_puppetclass']], 'ascii')) {
$partialAccounts[$i]['puppetclass'] = explode(';', $rawAccounts[$i][$ids['puppetClient_puppetclass']]);
}
else {
$errMsg = $this->messages['puppetclass'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
// variables // variables
if ($rawAccounts[$i][$ids['puppetClient_puppetvar']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'puppetClient_puppetvar', 'puppetvar', 'ascii', $this->messages['puppetvar'][1], $messages, '/;[ ]*/');
if (get_preg($rawAccounts[$i][$ids['puppetClient_puppetvar']], 'ascii')) {
$partialAccounts[$i]['puppetvar'] = explode(';', $rawAccounts[$i][$ids['puppetClient_puppetvar']]);
}
else {
$errMsg = $this->messages['puppetvar'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
} }
return $messages; return $messages;
} }