reduced upload code

This commit is contained in:
Roland Gruber 2014-04-13 11:37:32 +00:00
parent 4c38fa8564
commit fee3862dd2
4 changed files with 29 additions and 127 deletions

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2009 - 2013 Roland Gruber Copyright (C) 2009 - 2014 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -533,27 +533,11 @@ class eduPerson extends baseModule {
$partialAccounts[$i]['eduPersonEntitlement'] = $parts; $partialAccounts[$i]['eduPersonEntitlement'] = $parts;
} }
// organisation // organisation
if ($rawAccounts[$i][$ids['eduPerson_orgDN']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_orgDN', 'eduPersonOrgDN',
if (!get_preg($rawAccounts[$i][$ids['eduPerson_orgDN']], 'dn')) { 'dn', $this->messages['eduPersonOrgDN'][1], $messages);
$error = $this->messages['eduPersonOrgDN'][1];
array_push($error, $i);
$messages[] = $error;
}
else {
$partialAccounts[$i]['eduPersonOrgDN'] = $rawAccounts[$i][$ids['eduPerson_orgDN']];
}
}
// primary OU // primary OU
if ($rawAccounts[$i][$ids['eduPerson_primaryOrgUnitDN']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_primaryOrgUnitDN', 'eduPersonPrimaryOrgUnitDN',
if (!get_preg($rawAccounts[$i][$ids['eduPerson_primaryOrgUnitDN']], 'dn')) { 'dn', $this->messages['eduPersonPrimaryOrgUnitDN'][1], $messages);
$error = $this->messages['eduPersonPrimaryOrgUnitDN'][1];
array_push($error, $i);
$messages[] = $error;
}
else {
$partialAccounts[$i]['eduPersonPrimaryOrgUnitDN'] = $rawAccounts[$i][$ids['eduPerson_primaryOrgUnitDN']];
}
}
// OUs // OUs
if ($rawAccounts[$i][$ids['eduPerson_orgUnitDN']] != "") { if ($rawAccounts[$i][$ids['eduPerson_orgUnitDN']] != "") {
$parts = explode(', ', $rawAccounts[$i][$ids['eduPerson_orgUnitDN']]); $parts = explode(', ', $rawAccounts[$i][$ids['eduPerson_orgUnitDN']]);

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2011 - 2013 Roland Gruber Copyright (C) 2011 - 2014 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -476,38 +476,14 @@ class freeRadius extends baseModule {
// add object class // add object class
if (!in_array("radiusprofile", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "radiusprofile"; if (!in_array("radiusprofile", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "radiusprofile";
// IP address // IP address
if ($rawAccounts[$i][$ids['freeRadius_radiusFramedIPAddress']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'freeRadius_radiusFramedIPAddress', 'radiusFramedIPAddress',
if (get_preg($rawAccounts[$i][$ids['freeRadius_radiusFramedIPAddress']], 'ip')) { 'ip', $this->messages['radiusFramedIPAddress'][1], $errors);
$partialAccounts[$i]['radiusFramedIPAddress'] = $rawAccounts[$i][$ids['freeRadius_radiusFramedIPAddress']];
}
else {
$errMsg = $this->messages['radiusFramedIPAddress'][1];
array_push($errMsg, array($i));
$errors[] = $errMsg;
}
}
// net mask // net mask
if ($rawAccounts[$i][$ids['freeRadius_radiusFramedIPNetmask']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'freeRadius_radiusFramedIPNetmask', 'radiusFramedIPNetmask',
if (get_preg($rawAccounts[$i][$ids['freeRadius_radiusFramedIPNetmask']], 'ip')) { 'ip', $this->messages['radiusFramedIPNetmask'][1], $errors);
$partialAccounts[$i]['radiusFramedIPNetmask'] = $rawAccounts[$i][$ids['freeRadius_radiusFramedIPNetmask']];
}
else {
$errMsg = $this->messages['radiusFramedIPNetmask'][1];
array_push($errMsg, array($i));
$errors[] = $errMsg;
}
}
// realm // realm
if ($rawAccounts[$i][$ids['freeRadius_radiusRealm']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'freeRadius_radiusRealm', 'radiusRealm',
if (get_preg($rawAccounts[$i][$ids['freeRadius_radiusRealm']], 'DNSname')) { 'DNSname', $this->messages['radiusRealm'][1], $errors);
$partialAccounts[$i]['radiusRealm'] = $rawAccounts[$i][$ids['freeRadius_radiusRealm']];
}
else {
$errMsg = $this->messages['radiusRealm'][1];
array_push($errMsg, array($i));
$errors[] = $errMsg;
}
}
// group names // group names
if ($rawAccounts[$i][$ids['freeRadius_radiusGroupName']] != "") { if ($rawAccounts[$i][$ids['freeRadius_radiusGroupName']] != "") {
$groupList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['freeRadius_radiusGroupName']]); $groupList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['freeRadius_radiusGroupName']]);
@ -538,16 +514,8 @@ class freeRadius extends baseModule {
} }
} }
// idle timeout // idle timeout
if ($rawAccounts[$i][$ids['freeRadius_radiusIdleTimeout']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'freeRadius_radiusIdleTimeout', 'radiusIdleTimeout',
if (get_preg($rawAccounts[$i][$ids['freeRadius_radiusIdleTimeout']], 'digit')) { 'digit', $this->messages['radiusIdleTimeout'][1], $errors);
$partialAccounts[$i]['radiusIdleTimeout'] = $rawAccounts[$i][$ids['freeRadius_radiusIdleTimeout']];
}
else {
$errMsg = $this->messages['radiusIdleTimeout'][1];
array_push($errMsg, array($i));
$errors[] = $errMsg;
}
}
} }
return $errors; return $errors;
} }

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2004 - 2013 Roland Gruber Copyright (C) 2004 - 2014 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -266,29 +266,11 @@ class inetLocalMailRecipient extends baseModule {
} }
} }
// add routing address // add routing address
if ($rawAccounts[$i][$ids['inetLocalMailRecipient_routingAdr']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetLocalMailRecipient_routingAdr', 'mailRoutingAddress',
// check format 'email', $this->messages['mailRoutingAddress'][1], $messages);
if (get_preg($rawAccounts[$i][$ids['inetLocalMailRecipient_routingAdr']], 'email')) {
$partialAccounts[$i]['mailRoutingAddress'][] = $rawAccounts[$i][$ids['inetLocalMailRecipient_routingAdr']];
}
else {
$errMsg = $this->messages['mailRoutingAddress'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
// add mail server // add mail server
if ($rawAccounts[$i][$ids['inetLocalMailRecipient_server']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetLocalMailRecipient_server', 'mailHost',
// check format 'DNSname', $this->messages['mailHost'][1], $messages);
if (get_preg($rawAccounts[$i][$ids['inetLocalMailRecipient_server']], 'DNSname')) {
$partialAccounts[$i]['mailHost'][] = $rawAccounts[$i][$ids['inetLocalMailRecipient_server']];
}
else {
$errMsg = $this->messages['mailHost'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
} }
return $messages; return $messages;
} }

View File

@ -2118,9 +2118,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$partialAccounts[$i]['initials'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_initials']]); $partialAccounts[$i]['initials'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_initials']]);
} }
// description // description
if (isset($ids['inetOrgPerson_description']) && ($rawAccounts[$i][$ids['inetOrgPerson_description']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_description', 'description');
$partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['inetOrgPerson_description']];
}
// title // title
if (isset($ids['inetOrgPerson_title']) && ($rawAccounts[$i][$ids['inetOrgPerson_title']] != "")) { if (isset($ids['inetOrgPerson_title']) && ($rawAccounts[$i][$ids['inetOrgPerson_title']] != "")) {
$titleList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_title']]); $titleList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_title']]);
@ -2135,20 +2133,10 @@ class inetOrgPerson extends baseModule implements passwordService {
} }
} }
// employee number // employee number
if (isset($ids['inetOrgPerson_employeeNumber']) && ($rawAccounts[$i][$ids['inetOrgPerson_employeeNumber']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_employeeNumber', 'employeeNumber');
$partialAccounts[$i]['employeeNumber'] = $rawAccounts[$i][$ids['inetOrgPerson_employeeNumber']];
}
// employee type // employee type
if (isset($ids['inetOrgPerson_type']) && ($rawAccounts[$i][$ids['inetOrgPerson_type']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_type', 'employeeType',
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_type']], 'employeeType')) { 'employeeType', $this->messages['employeeType'][1], $errors);
$partialAccounts[$i]['employeeType'] = $rawAccounts[$i][$ids['inetOrgPerson_type']];
}
else {
$errMsg = $this->messages['employeeType'][1];
array_push($errMsg, array($i));
$errors[] = $errMsg;
}
}
// business category // business category
if (isset($ids['inetOrgPerson_businessCategory']) && ($rawAccounts[$i][$ids['inetOrgPerson_businessCategory']] != "")) { if (isset($ids['inetOrgPerson_businessCategory']) && ($rawAccounts[$i][$ids['inetOrgPerson_businessCategory']] != "")) {
$businessCategoryList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_businessCategory']]); $businessCategoryList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_businessCategory']]);
@ -2193,9 +2181,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$partialAccounts[$i]['postOfficeBox'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_postOfficeBox']]); $partialAccounts[$i]['postOfficeBox'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_postOfficeBox']]);
} }
// room number // room number
if (isset($ids['inetOrgPerson_roomNumber']) && ($rawAccounts[$i][$ids['inetOrgPerson_roomNumber']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_roomNumber', 'roomNumber');
$partialAccounts[$i]['roomNumber'] = $rawAccounts[$i][$ids['inetOrgPerson_roomNumber']];
}
// departments // departments
if (isset($ids['inetOrgPerson_departmentNumber']) && ($rawAccounts[$i][$ids['inetOrgPerson_departmentNumber']] != "")) { if (isset($ids['inetOrgPerson_departmentNumber']) && ($rawAccounts[$i][$ids['inetOrgPerson_departmentNumber']] != "")) {
$partialAccounts[$i]['departmentNumber'] = explode(';', $rawAccounts[$i][$ids['inetOrgPerson_departmentNumber']]); $partialAccounts[$i]['departmentNumber'] = explode(';', $rawAccounts[$i][$ids['inetOrgPerson_departmentNumber']]);
@ -2223,9 +2209,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$partialAccounts[$i]['physicalDeliveryOfficeName'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_physicalDeliveryOfficeName']]); $partialAccounts[$i]['physicalDeliveryOfficeName'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_physicalDeliveryOfficeName']]);
} }
// carLicense // carLicense
if (isset($ids['inetOrgPerson_carLicense']) && ($rawAccounts[$i][$ids['inetOrgPerson_carLicense']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_carLicense', 'carLicense');
$partialAccounts[$i]['carLicense'] = $rawAccounts[$i][$ids['inetOrgPerson_carLicense']];
}
// postal code // postal code
if (isset($ids['inetOrgPerson_postalCode']) && ($rawAccounts[$i][$ids['inetOrgPerson_postalCode']] != "")) { if (isset($ids['inetOrgPerson_postalCode']) && ($rawAccounts[$i][$ids['inetOrgPerson_postalCode']] != "")) {
$postalCodeList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_postalCode']]); $postalCodeList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_postalCode']]);
@ -2240,27 +2224,11 @@ class inetOrgPerson extends baseModule implements passwordService {
} }
} }
// postal address // postal address
if (isset($ids['inetOrgPerson_address']) && ($rawAccounts[$i][$ids['inetOrgPerson_address']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_address', 'postalAddress',
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_address']], 'postalAddress')) { 'postalAddress',$this->messages['postalAddress'][1] , $errors);
$partialAccounts[$i]['postalAddress'] = $rawAccounts[$i][$ids['inetOrgPerson_address']];
}
else {
$errMsg = $this->messages['postalAddress'][1];
array_push($errMsg, array($i));
$errors[] = $errMsg;
}
}
// registered address // registered address
if (isset($ids['inetOrgPerson_registeredAddress']) && ($rawAccounts[$i][$ids['inetOrgPerson_registeredAddress']] != "")) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_registeredAddress', 'registeredAddress',
if (get_preg($rawAccounts[$i][$ids['inetOrgPerson_registeredAddress']], 'postalAddress')) { 'postalAddress',$this->messages['registeredAddress'][1] , $errors);
$partialAccounts[$i]['registeredAddress'] = $rawAccounts[$i][$ids['inetOrgPerson_registeredAddress']];
}
else {
$errMsg = $this->messages['registeredAddress'][1];
array_push($errMsg, array($i));
$errors[] = $errMsg;
}
}
// telephone // telephone
if (isset($ids['inetOrgPerson_telephone']) && ($rawAccounts[$i][$ids['inetOrgPerson_telephone']] != "")) { if (isset($ids['inetOrgPerson_telephone']) && ($rawAccounts[$i][$ids['inetOrgPerson_telephone']] != "")) {
$telephoneList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_telephone']])); $telephoneList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_telephone']]));