use extended upload function

This commit is contained in:
Roland Gruber 2015-07-13 18:05:39 +00:00
parent 435604544b
commit d74ade3b3a
3 changed files with 27 additions and 71 deletions

View File

@ -961,7 +961,7 @@ abstract class baseModule {
* @param array $errors list of error messages if any
* @param String $regexSplit multiple values are separated and can be split with this preg_split expression (e.g. "/;[ ]?/")
*/
protected function mapSimpleUploadField(&$rawAccounts, &$ids, &$partialAccounts, $position, $colName, $attrName, $regex = null, &$message = array(), &$errors = array(), $regexSplit = null) {
protected function mapSimpleUploadField(&$rawAccounts, &$ids, &$partialAccounts, $position, $colName, $attrName, $regex = null, $message = array(), &$errors = array(), $regexSplit = null) {
if (!isset($ids[$colName])) {
return;
}

View File

@ -530,15 +530,9 @@ class eduPerson extends baseModule {
}
}
// nick names
if ($rawAccounts[$i][$ids['eduPerson_nickname']] != "") {
$parts = explode(', ', $rawAccounts[$i][$ids['eduPerson_nickname']]);
$partialAccounts[$i]['eduPersonNickname'] = $parts;
}
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_nickname', 'eduPersonNickname', null, array(), $messages, '/,[ ]*/');
// entitlements
if ($rawAccounts[$i][$ids['eduPerson_entitlement']] != "") {
$parts = explode(', ', $rawAccounts[$i][$ids['eduPerson_entitlement']]);
$partialAccounts[$i]['eduPersonEntitlement'] = $parts;
}
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_entitlement', 'eduPersonEntitlement', null, array(), $messages, '/,[ ]*/');
// organisation
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_orgDN', 'eduPersonOrgDN',
'dn', $this->messages['eduPersonOrgDN'][1], $messages);
@ -546,27 +540,9 @@ class eduPerson extends baseModule {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_primaryOrgUnitDN', 'eduPersonPrimaryOrgUnitDN',
'dn', $this->messages['eduPersonPrimaryOrgUnitDN'][1], $messages);
// OUs
if ($rawAccounts[$i][$ids['eduPerson_orgUnitDN']] != "") {
$parts = explode(', ', $rawAccounts[$i][$ids['eduPerson_orgUnitDN']]);
$valid = true;
for ($a = 0; $a < sizeof($parts); $a++) {
if (!get_preg($parts[$a], 'dn')) {
$valid = false;
$error = $this->messages['eduPersonOrgUnitDN'][1];
array_push($error, $i);
$messages[] = $error;
break;
}
}
if ($valid) {
$partialAccounts[$i]['eduPersonOrgUnitDN'] = $parts;
}
}
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_orgUnitDN', 'eduPersonOrgUnitDN', 'dn', $this->messages['eduPersonOrgUnitDN'][1], $messages, '/;[ ]*/');
// assurance profiles
if ($rawAccounts[$i][$ids['eduPerson_assurance']] != "") {
$parts = explode(', ', $rawAccounts[$i][$ids['eduPerson_assurance']]);
$partialAccounts[$i]['eduPersonAssurance'] = $parts;
}
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_assurance', 'eduPersonAssurance', null, array(), $messages, '/,[ ]*/');
}
return $messages;
}

View File

@ -627,18 +627,7 @@ class freeRadius extends baseModule {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'freeRadius_radiusRealm', 'radiusRealm',
'DNSname', $this->messages['radiusRealm'][1], $errors);
// group names
if ($rawAccounts[$i][$ids['freeRadius_radiusGroupName']] != "") {
$groupList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['freeRadius_radiusGroupName']]);
$partialAccounts[$i]['radiusGroupName'] = $groupList;
for ($x = 0; $x < sizeof($groupList); $x++) {
if (!get_preg($groupList[$x], 'groupname')) {
$errMsg = $this->messages['radiusGroupName'][1];
array_push($errMsg, array($i));
$errors[] = $errMsg;
break;
}
}
}
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'freeRadius_radiusGroupName', 'radiusGroupName', 'groupname', $this->messages['radiusGroupName'][1], $errors, '/;[ ]*/');
// expiration date
if ($rawAccounts[$i][$ids['freeRadius_radiusExpiration']] != "") {
if (preg_match('/^[0-9]{1,2}.[0-9]{1,2}.[0-9]{4} [0-9]{1,2}:[0-9]{1,2}$/', $rawAccounts[$i][$ids['freeRadius_radiusExpiration']])) {
@ -670,16 +659,7 @@ class freeRadius extends baseModule {
}
}
// profile DN
if (!empty($rawAccounts[$i][$ids['freeRadius_radiusProfileDn']])) {
if (get_preg($rawAccounts[$i][$ids['freeRadius_radiusProfileDn']], 'dn')) {
$partialAccounts[$i]['radiusProfileDn'] = $rawAccounts[$i][$ids['freeRadius_radiusProfileDn']];
}
else {
$errMsg = $this->messages['radiusProfileDn'][0];
array_push($errMsg, array($i));
$errors[] = $errMsg;
}
}
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'freeRadius_radiusProfileDn', 'radiusProfileDn', 'dn', $this->messages['radiusProfileDn'][0], $errors);
}
return $errors;
}