common function to upload multi-value attributes
This commit is contained in:
parent
15570725e2
commit
224c4ede8d
|
@ -959,12 +959,15 @@ abstract class baseModule {
|
||||||
* @param String $regexID for get_preg() (e.g. 'ascii')
|
* @param String $regexID for get_preg() (e.g. 'ascii')
|
||||||
* @param array $message error message to add if regex does not match
|
* @param array $message error message to add if regex does not match
|
||||||
* @param array $errors list of error messages if any
|
* @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()) {
|
protected function mapSimpleUploadField(&$rawAccounts, &$ids, &$partialAccounts, $position, $colName, $attrName, $regex = null, &$message = array(), &$errors = array(), $regexSplit = null) {
|
||||||
if (!isset($ids[$colName])) {
|
if (!isset($ids[$colName])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!empty($rawAccounts[$position][$ids[$colName]])) {
|
if (!empty($rawAccounts[$position][$ids[$colName]])) {
|
||||||
|
// single value
|
||||||
|
if ($regexSplit == null) {
|
||||||
if (!empty($regex) && !get_preg($rawAccounts[$position][$ids[$colName]], $regex)) {
|
if (!empty($regex) && !get_preg($rawAccounts[$position][$ids[$colName]], $regex)) {
|
||||||
$errMsg = $message;
|
$errMsg = $message;
|
||||||
array_push($errMsg, array($position));
|
array_push($errMsg, array($position));
|
||||||
|
@ -972,6 +975,22 @@ abstract class baseModule {
|
||||||
}
|
}
|
||||||
$partialAccounts[$position][$attrName] = $rawAccounts[$position][$ids[$colName]];
|
$partialAccounts[$position][$attrName] = $rawAccounts[$position][$ids[$colName]];
|
||||||
}
|
}
|
||||||
|
// multi-value
|
||||||
|
else {
|
||||||
|
$list = preg_split($regexSplit, trim($rawAccounts[$position][$ids[$colName]]));
|
||||||
|
$partialAccounts[$position][$attrName] = $list;
|
||||||
|
if (!empty($regex)) {
|
||||||
|
for ($x = 0; $x < sizeof($list); $x++) {
|
||||||
|
if (!get_preg($list[$x], $regex)) {
|
||||||
|
$errMsg = $message;
|
||||||
|
array_push($errMsg, array($position));
|
||||||
|
$errors[] = $errMsg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2211,62 +2211,18 @@ class inetOrgPerson extends baseModule implements passwordService {
|
||||||
// description
|
// description
|
||||||
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_description', 'description');
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_description', 'description');
|
||||||
// title
|
// title
|
||||||
if (isset($ids['inetOrgPerson_title']) && ($rawAccounts[$i][$ids['inetOrgPerson_title']] != "")) {
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_title', 'title', 'title', $this->messages['title'][1], $errors, '/;[ ]*/');
|
||||||
$titleList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_title']]);
|
|
||||||
$partialAccounts[$i]['title'] = $titleList;
|
|
||||||
for ($x = 0; $x < sizeof($titleList); $x++) {
|
|
||||||
if (!get_preg($titleList[$x], 'title')) {
|
|
||||||
$errMsg = $this->messages['title'][1];
|
|
||||||
array_push($errMsg, array($i));
|
|
||||||
$errors[] = $errMsg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// employee number
|
// employee number
|
||||||
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_employeeNumber', 'employeeNumber');
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_employeeNumber', 'employeeNumber');
|
||||||
// employee type
|
// employee type
|
||||||
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_type', 'employeeType',
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_type', 'employeeType',
|
||||||
'employeeType', $this->messages['employeeType'][1], $errors);
|
'employeeType', $this->messages['employeeType'][1], $errors);
|
||||||
// business category
|
// business category
|
||||||
if (isset($ids['inetOrgPerson_businessCategory']) && ($rawAccounts[$i][$ids['inetOrgPerson_businessCategory']] != "")) {
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_businessCategory', 'businessCategory', 'businessCategory', $this->messages['businessCategory'][1], $errors, '/;[ ]*/');
|
||||||
$businessCategoryList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_businessCategory']]);
|
|
||||||
$partialAccounts[$i]['businessCategory'] = $businessCategoryList;
|
|
||||||
for ($x = 0; $x < sizeof($businessCategoryList); $x++) {
|
|
||||||
if (!get_preg($businessCategoryList[$x], 'businessCategory')) {
|
|
||||||
$errMsg = $this->messages['businessCategory'][1];
|
|
||||||
array_push($errMsg, array($i));
|
|
||||||
$errors[] = $errMsg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// manager
|
// manager
|
||||||
if (isset($ids['inetOrgPerson_manager']) && ($rawAccounts[$i][$ids['inetOrgPerson_manager']] != "")) {
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_manager', 'manager', 'dn', $this->messages['manager'][0], $errors, '/;[ ]*/');
|
||||||
$managerList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_manager']]);
|
|
||||||
$partialAccounts[$i]['manager'] = $managerList;
|
|
||||||
for ($x = 0; $x < sizeof($managerList); $x++) {
|
|
||||||
if (!get_preg($managerList[$x], 'dn')) {
|
|
||||||
$errMsg = $this->messages['manager'][0];
|
|
||||||
array_push($errMsg, array($i));
|
|
||||||
$errors[] = $errMsg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// street
|
// street
|
||||||
if (isset($ids['inetOrgPerson_street']) && ($rawAccounts[$i][$ids['inetOrgPerson_street']] != "")) {
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_street', 'street', 'street', $this->messages['street'][1], $errors, '/;[ ]*/');
|
||||||
$streetList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_street']]);
|
|
||||||
$partialAccounts[$i]['street'] = $streetList;
|
|
||||||
for ($x = 0; $x < sizeof($streetList); $x++) {
|
|
||||||
if (!get_preg($streetList[$x], 'street')) {
|
|
||||||
$errMsg = $this->messages['street'][1];
|
|
||||||
array_push($errMsg, array($i));
|
|
||||||
$errors[] = $errMsg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// post office box
|
// post office box
|
||||||
if (isset($ids['inetOrgPerson_postOfficeBox']) && ($rawAccounts[$i][$ids['inetOrgPerson_postOfficeBox']] != "")) {
|
if (isset($ids['inetOrgPerson_postOfficeBox']) && ($rawAccounts[$i][$ids['inetOrgPerson_postOfficeBox']] != "")) {
|
||||||
$partialAccounts[$i]['postOfficeBox'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_postOfficeBox']]);
|
$partialAccounts[$i]['postOfficeBox'] = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_postOfficeBox']]);
|
||||||
|
@ -2302,18 +2258,7 @@ class inetOrgPerson extends baseModule implements passwordService {
|
||||||
// carLicense
|
// carLicense
|
||||||
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_carLicense', 'carLicense');
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_carLicense', 'carLicense');
|
||||||
// postal code
|
// postal code
|
||||||
if (isset($ids['inetOrgPerson_postalCode']) && ($rawAccounts[$i][$ids['inetOrgPerson_postalCode']] != "")) {
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_postalCode', 'postalCode', 'postalCode', $this->messages['postalCode'][1], $errors, '/;[ ]*/');
|
||||||
$postalCodeList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['inetOrgPerson_postalCode']]);
|
|
||||||
$partialAccounts[$i]['postalCode'] = $postalCodeList;
|
|
||||||
for ($x = 0; $x < sizeof($postalCodeList); $x++) {
|
|
||||||
if (!get_preg($postalCodeList[$x], 'postalCode')) {
|
|
||||||
$errMsg = $this->messages['postalCode'][1];
|
|
||||||
array_push($errMsg, array($i));
|
|
||||||
$errors[] = $errMsg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// postal address
|
// postal address
|
||||||
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_address', 'postalAddress',
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_address', 'postalAddress',
|
||||||
'postalAddress',$this->messages['postalAddress'][1] , $errors);
|
'postalAddress',$this->messages['postalAddress'][1] , $errors);
|
||||||
|
@ -2321,70 +2266,15 @@ class inetOrgPerson extends baseModule implements passwordService {
|
||||||
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_registeredAddress', 'registeredAddress',
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_registeredAddress', 'registeredAddress',
|
||||||
'postalAddress',$this->messages['registeredAddress'][1] , $errors);
|
'postalAddress',$this->messages['registeredAddress'][1] , $errors);
|
||||||
// telephone
|
// telephone
|
||||||
if (isset($ids['inetOrgPerson_telephone']) && ($rawAccounts[$i][$ids['inetOrgPerson_telephone']] != "")) {
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_telephone', 'telephoneNumber', 'telephone', $this->messages['telephoneNumber'][1], $errors, '/;[ ]*/');
|
||||||
$telephoneList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_telephone']]));
|
|
||||||
$partialAccounts[$i]['telephoneNumber'] = $telephoneList;
|
|
||||||
for ($x = 0; $x < sizeof($telephoneList); $x++) {
|
|
||||||
if (!get_preg($telephoneList[$x], 'telephone')) {
|
|
||||||
$errMsg = $this->messages['telephoneNumber'][1];
|
|
||||||
array_push($errMsg, array($i));
|
|
||||||
$errors[] = $errMsg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// home telephone
|
// home telephone
|
||||||
if (isset($ids['inetOrgPerson_homePhone']) && ($rawAccounts[$i][$ids['inetOrgPerson_homePhone']] != "")) {
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_homePhone', 'homePhone', 'telephone', $this->messages['homePhone'][1], $errors, '/;[ ]*/');
|
||||||
$homePhoneList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_homePhone']]));
|
|
||||||
$partialAccounts[$i]['homePhone'] = $homePhoneList;
|
|
||||||
for ($x = 0; $x < sizeof($homePhoneList); $x++) {
|
|
||||||
if (!get_preg($homePhoneList[$x], 'telephone')) {
|
|
||||||
$errMsg = $this->messages['homePhone'][1];
|
|
||||||
array_push($errMsg, array($i));
|
|
||||||
$errors[] = $errMsg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// mobile
|
// mobile
|
||||||
if (isset($ids['inetOrgPerson_mobile']) && ($rawAccounts[$i][$ids['inetOrgPerson_mobile']] != "")) {
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_mobile', 'mobile', 'telephone', $this->messages['mobileTelephone'][1], $errors, '/;[ ]*/');
|
||||||
$mobileList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_mobile']]));
|
|
||||||
$partialAccounts[$i]['mobile'] = $mobileList;
|
|
||||||
for ($x = 0; $x < sizeof($mobileList); $x++) {
|
|
||||||
if (!get_preg($mobileList[$x], 'telephone')) {
|
|
||||||
$errMsg = $this->messages['mobileTelephone'][1];
|
|
||||||
array_push($errMsg, array($i));
|
|
||||||
$errors[] = $errMsg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// facsimile
|
// facsimile
|
||||||
if (isset($ids['inetOrgPerson_fax']) && ($rawAccounts[$i][$ids['inetOrgPerson_fax']] != "")) {
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_fax', 'facsimileTelephoneNumber', 'telephone', $this->messages['facsimileNumber'][1], $errors, '/;[ ]*/');
|
||||||
$facsimileTelephoneNumberList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_fax']]));
|
|
||||||
$partialAccounts[$i]['facsimileTelephoneNumber'] = $facsimileTelephoneNumberList;
|
|
||||||
for ($x = 0; $x < sizeof($facsimileTelephoneNumberList); $x++) {
|
|
||||||
if (!get_preg($facsimileTelephoneNumberList[$x], 'telephone')) {
|
|
||||||
$errMsg = $this->messages['facsimileNumber'][1];
|
|
||||||
array_push($errMsg, array($i));
|
|
||||||
$errors[] = $errMsg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// pager
|
// pager
|
||||||
if (isset($ids['inetOrgPerson_pager']) && ($rawAccounts[$i][$ids['inetOrgPerson_pager']] != "")) {
|
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'inetOrgPerson_pager', 'pager', 'telephone', $this->messages['pager'][1], $errors, '/;[ ]*/');
|
||||||
$pagerList = preg_split('/;[ ]*/', trim($rawAccounts[$i][$ids['inetOrgPerson_pager']]));
|
|
||||||
$partialAccounts[$i]['pager'] = $pagerList;
|
|
||||||
for ($x = 0; $x < sizeof($pagerList); $x++) {
|
|
||||||
if (!get_preg($pagerList[$x], 'telephone')) {
|
|
||||||
$errMsg = $this->messages['pager'][1];
|
|
||||||
array_push($errMsg, array($i));
|
|
||||||
$errors[] = $errMsg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// eMail
|
// eMail
|
||||||
if (isset($ids['inetOrgPerson_email']) && ($rawAccounts[$i][$ids['inetOrgPerson_email']] != "")) {
|
if (isset($ids['inetOrgPerson_email']) && ($rawAccounts[$i][$ids['inetOrgPerson_email']] != "")) {
|
||||||
foreach ($replacements as $wildcard => $value) {
|
foreach ($replacements as $wildcard => $value) {
|
||||||
|
|
Loading…
Reference in New Issue