From 9b0e7123171d160c8971426a03d81e8172017ea1 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 18 Apr 2014 18:29:51 +0000 Subject: [PATCH] reduced upload code --- lam/lib/modules/sambaDomain.inc | 74 ++++++--------------------- lam/lib/modules/sambaSamAccount.inc | 78 ++++++----------------------- lam/lib/modules/shadowAccount.inc | 50 ++++-------------- lam/lib/modules/windowsGroup.inc | 40 ++++----------- lam/lib/modules/windowsHost.inc | 14 ++---- lam/lib/modules/windowsUser.inc | 72 ++++++-------------------- 6 files changed, 66 insertions(+), 262 deletions(-) diff --git a/lam/lib/modules/sambaDomain.inc b/lam/lib/modules/sambaDomain.inc index 2d09d8f6..c2fb0d52 100644 --- a/lam/lib/modules/sambaDomain.inc +++ b/lam/lib/modules/sambaDomain.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2005 - 2013 Roland Gruber + Copyright (C) 2005 - 2014 Roland Gruber 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 @@ -560,70 +560,24 @@ class sambaDomain extends baseModule { // add object class if (!in_array("sambaDomain", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "sambaDomain"; // domain name - if (get_preg($rawAccounts[$i][$ids['sambaDomain_domainName']], 'domainname')) { - $partialAccounts[$i]['sambaDomainName'] = $rawAccounts[$i][$ids['sambaDomain_domainName']]; - } - else { - $errMsg = $this->messages['domainName'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'sambaDomain_domainName', 'sambaDomainName', + 'domainname', $this->messages['domainName'][1], $messages); // domain SID - if (get_preg($rawAccounts[$i][$ids['sambaDomain_domainSID']], 'domainSID')) { - $partialAccounts[$i]['sambaSID'] = $rawAccounts[$i][$ids['sambaDomain_domainSID']]; - } - else { - $errMsg = $this->messages['domainSID'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'sambaDomain_domainSID', 'sambaSID', + 'domainSID', $this->messages['domainSID'][1], $messages); // RID base - if ($rawAccounts[$i][$ids['sambaDomain_RIDbase']]) { - if (get_preg($rawAccounts[$i][$ids['sambaDomain_RIDbase']], 'digit')) { - $partialAccounts[$i]['sambaAlgorithmicRidBase'] = $rawAccounts[$i][$ids['sambaDomain_RIDbase']]; - } - else { - $errMsg = $this->messages['RIDbase'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - } - else { - $partialAccounts[$i]['sambaAlgorithmicRidBase'] = '1000'; - } + $partialAccounts[$i]['sambaAlgorithmicRidBase'] = '1000'; + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'sambaDomain_RIDbase', 'sambaAlgorithmicRidBase', + 'digit', $this->messages['RIDbase'][1], $messages); // next RID - if ($rawAccounts[$i][$ids['sambaDomain_nextRID']]) { - if (get_preg($rawAccounts[$i][$ids['sambaDomain_nextRID']], 'digit')) { - $partialAccounts[$i]['sambaNextRid'] = $rawAccounts[$i][$ids['sambaDomain_nextRID']]; - } - else { - $errMsg = $this->messages['nextRID'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'sambaDomain_nextRID', 'sambaNextRid', + 'digit', $this->messages['nextRID'][1], $messages); // next user RID - if ($rawAccounts[$i][$ids['sambaDomain_nextUserRID']]) { - if (get_preg($rawAccounts[$i][$ids['sambaDomain_nextUserRID']], 'digit')) { - $partialAccounts[$i]['sambaNextUserRid'] = $rawAccounts[$i][$ids['sambaDomain_nextUserRID']]; - } - else { - $errMsg = $this->messages['nextUserRID'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'sambaDomain_nextUserRID', 'sambaNextUserRid', + 'digit', $this->messages['nextUserRID'][1], $messages); // next group RID - if ($rawAccounts[$i][$ids['sambaDomain_nextGroupRID']]) { - if (get_preg($rawAccounts[$i][$ids['sambaDomain_nextGroupRID']], 'digit')) { - $partialAccounts[$i]['sambaNextGroupRid'] = $rawAccounts[$i][$ids['sambaDomain_nextGroupRID']]; - } - else { - $errMsg = $this->messages['nextGroupRID'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'sambaDomain_nextGroupRID', 'sambaNextGroupRid', + 'digit', $this->messages['nextGroupRID'][1], $messages); } return $messages; } diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index 5d1761f6..c605a463 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -4,7 +4,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Tilo Lutz - 2005 - 2013 Roland Gruber + 2005 - 2014 Roland Gruber 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 @@ -1993,16 +1993,8 @@ class sambaSamAccount extends baseModule implements passwordService { for ($i = 0; $i < sizeof($rawAccounts); $i++) { if (!in_array("sambaSamAccount", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "sambaSamAccount"; // displayName - if ($rawAccounts[$i][$ids['sambaSamAccount_displayName']] != "") { - if (get_preg($rawAccounts[$i][$ids['sambaSamAccount_displayName']], 'realname')) { - $partialAccounts[$i]['displayName'] = $rawAccounts[$i][$ids['sambaSamAccount_displayName']]; - } - else { - $errMsg = $this->messages['displayName'][0]; - array_push($errMsg, array($i)); - $errors[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'sambaSamAccount_displayName', 'displayName', + 'realname', $this->messages['displayName'][0], $errors); // password $partialAccounts[$i]['sambaPwdLastSet'] = time(); if (!get_preg($rawAccounts[$i][$ids['sambaSamAccount_password']], 'password')) { @@ -2114,49 +2106,17 @@ class sambaSamAccount extends baseModule implements passwordService { } } // home path - if ($rawAccounts[$i][$ids['sambaSamAccount_homePath']] != "") { - if (get_preg($rawAccounts[$i][$ids['sambaSamAccount_homePath']], 'UNC')) { - $partialAccounts[$i]['sambaHomePath'] = $rawAccounts[$i][$ids['sambaSamAccount_homePath']]; - } - else { - $errMsg = $this->messages['homePath'][2]; - array_push($errMsg, array($i)); - $errors[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'sambaSamAccount_homePath', 'sambaHomePath', + 'UNC', $this->messages['homePath'][2], $errors); // profile path - if ($rawAccounts[$i][$ids['sambaSamAccount_profilePath']] != "") { - if (get_preg($rawAccounts[$i][$ids['sambaSamAccount_profilePath']], 'UNC')) { - $partialAccounts[$i]['sambaProfilePath'] = $rawAccounts[$i][$ids['sambaSamAccount_profilePath']]; - } - else { - $errMsg = $this->messages['profilePath'][2]; - array_push($errMsg, array($i)); - $errors[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'sambaSamAccount_profilePath', 'sambaProfilePath', + 'UNC', $this->messages['profilePath'][2], $errors); // logon script - if ($rawAccounts[$i][$ids['sambaSamAccount_logonScript']] != "") { - if (get_preg($rawAccounts[$i][$ids['sambaSamAccount_logonScript']], 'logonscript')) { - $partialAccounts[$i]['sambaLogonScript'] = $rawAccounts[$i][$ids['sambaSamAccount_logonScript']]; - } - else { - $errMsg = $this->messages['logonScript'][2]; - array_push($errMsg, array($i)); - $errors[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'sambaSamAccount_logonScript', 'sambaLogonScript', + 'logonscript', $this->messages['logonScript'][2], $errors); // workstations - if ($rawAccounts[$i][$ids['sambaSamAccount_workstations']] != "") { - if (get_preg($rawAccounts[$i][$ids['sambaSamAccount_workstations']], 'workstations')) { - $partialAccounts[$i]['sambaUserWorkstations'] = $rawAccounts[$i][$ids['sambaSamAccount_workstations']]; - } - else { - $errMsg = $this->messages['workstations'][1]; - array_push($errMsg, array($i)); - $errors[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'sambaSamAccount_workstations', 'sambaUserWorkstations', + 'workstations', $this->messages['workstations'][1], $errors); // domain $domIndex = -1; for ($d = 0; $d < sizeof($domains); $d++) { @@ -2219,19 +2179,9 @@ class sambaSamAccount extends baseModule implements passwordService { $partialAccounts[$i]['sambaSID'] .= '-' . ($partialAccounts[$i]['uidNumber']*2 + $domains[$domIndex]->RIDbase); } // logon hours - if ($rawAccounts[$i][$ids['sambaSamAccount_logonHours']] != "") { - if (get_preg($rawAccounts[$i][$ids['sambaSamAccount_logonHours']], 'sambaLogonHours')) { - $partialAccounts[$i]['sambaLogonHours'] = $rawAccounts[$i][$ids['sambaSamAccount_logonHours']]; - } - else { - $errMsg = $this->messages['logonHours'][1]; - array_push($errMsg, array($i)); - $errors[] = $errMsg; - } - } - else { - $partialAccounts[$i]['sambaLogonHours'] = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; - } + $partialAccounts[$i]['sambaLogonHours'] = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'sambaSamAccount_logonHours', 'sambaLogonHours', + 'sambaLogonHours', $this->messages['logonHours'][1], $errors); } } else { // hosts diff --git a/lam/lib/modules/shadowAccount.inc b/lam/lib/modules/shadowAccount.inc index fe3996ec..9a13e4f9 100644 --- a/lam/lib/modules/shadowAccount.inc +++ b/lam/lib/modules/shadowAccount.inc @@ -4,7 +4,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Tilo Lutz - Copyright (C) 2007 - 2013 Roland Gruber + Copyright (C) 2007 - 2014 Roland Gruber 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 @@ -515,49 +515,17 @@ class shadowAccount extends baseModule implements passwordService { // shadow last change $partialAccounts[$i]['shadowLastChange'] = array(intval(time()/3600/24)); // password warning - if ($rawAccounts[$i][$ids['shadowAccount_warning']] != '') { - if (get_preg($rawAccounts[$i][$ids['shadowAccount_warning']], 'digit')) { - $partialAccounts[$i]['shadowWarning'][] = $rawAccounts[$i][$ids['shadowAccount_warning']]; - } - else { - $errMsg = $this->messages['shadowWarning'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'shadowAccount_warning', 'shadowWarning', + 'digit', $this->messages['shadowWarning'][1], $messages); // password expire ignoration - if ($rawAccounts[$i][$ids['shadowAccount_ignoreExpire']] != '') { - if (get_preg($rawAccounts[$i][$ids['shadowAccount_ignoreExpire']], 'digit2')) { - $partialAccounts[$i]['shadowInactive'][] = $rawAccounts[$i][$ids['shadowAccount_ignoreExpire']]; - } - else { - $errMsg = $this->messages['inactive'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'shadowAccount_ignoreExpire', 'shadowInactive', + 'digit2', $this->messages['inactive'][1], $messages); // password minAge - if ($rawAccounts[$i][$ids['shadowAccount_minAge']] != '') { - if (get_preg($rawAccounts[$i][$ids['shadowAccount_minAge']], 'digit')) { - $partialAccounts[$i]['shadowMin'][] = $rawAccounts[$i][$ids['shadowAccount_minAge']]; - } - else { - $errMsg = $this->messages['shadowMin'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'shadowAccount_minAge', 'shadowMin', + 'digit', $this->messages['shadowMin'][1], $messages); // password maxAge - if ($rawAccounts[$i][$ids['shadowAccount_maxAge']] != '') { - if (get_preg($rawAccounts[$i][$ids['shadowAccount_maxAge']], 'digit')) { - $partialAccounts[$i]['shadowMax'][] = $rawAccounts[$i][$ids['shadowAccount_maxAge']]; - } - else { - $errMsg = $this->messages['shadowMax'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'shadowAccount_maxAge', 'shadowMax', + 'digit', $this->messages['shadowMax'][1], $messages); // minAge <= maxAge if ((($rawAccounts[$i][$ids['shadowAccount_minAge']] != '') || ($rawAccounts[$i][$ids['shadowAccount_maxAge']] != '')) && // if at least one is set (($rawAccounts[$i][$ids['shadowAccount_minAge']] == '') || ($rawAccounts[$i][$ids['shadowAccount_maxAge']] == '') || ( // and one is not set diff --git a/lam/lib/modules/windowsGroup.inc b/lam/lib/modules/windowsGroup.inc index b4e6f2ec..c1ec7236 100644 --- a/lam/lib/modules/windowsGroup.inc +++ b/lam/lib/modules/windowsGroup.inc @@ -661,27 +661,17 @@ class windowsGroup extends baseModule { } } // description - if ($rawAccounts[$i][$ids['windowsGroup_description']] != "") { - $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['windowsGroup_description']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsGroup_description', 'description'); // notes - if ($rawAccounts[$i][$ids['windowsGroup_notes']] != "") { - $partialAccounts[$i]['info'] = $rawAccounts[$i][$ids['windowsGroup_notes']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsGroup_notes', 'info'); // email - if (!$this->isBooleanConfigOptionSet('windowsGroup_hidemail') && ($rawAccounts[$i][$ids['windowsGroup_mail']] != "")) { - if (get_preg($rawAccounts[$i][$ids['windowsGroup_mail']], 'email')) { - $partialAccounts[$i]['mail'] = $rawAccounts[$i][$ids['windowsGroup_mail']]; - } - else { - $errMsg = $this->messages['mail'][1]; - array_push($errMsg, array($i)); - $errors[] = $errMsg; - } + if (!$this->isBooleanConfigOptionSet('windowsGroup_hidemail')) { + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsGroup_mail', 'mail', + 'email', $this->messages['mail'][1], $errors); } // managed by - if (!$this->isBooleanConfigOptionSet('windowsGroup_hidemanagedBy') && $rawAccounts[$i][$ids['windowsGroup_managedBy']] != "") { - $partialAccounts[$i]['managedBy'] = $rawAccounts[$i][$ids['windowsGroup_managedBy']]; + if (!$this->isBooleanConfigOptionSet('windowsGroup_hidemanagedBy')) { + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsGroup_managedBy', 'managedBy'); } // add members if ($rawAccounts[$i][$ids['windowsGroup_members']] != "") { @@ -729,22 +719,12 @@ class windowsGroup extends baseModule { } // NIS name if (!$this->isBooleanConfigOptionSet('windowsGroup_hidemsSFU30Name', true)) { - if (!empty($rawAccounts[$i][$ids['windowsGroup_msSFU30Name']])) { - if (get_preg($rawAccounts[$i][$ids['windowsGroup_msSFU30Name']], 'groupname')) { - $partialAccounts[$i]['msSFU30Name'] = $rawAccounts[$i][$ids['windowsGroup_msSFU30Name']]; - } - else { - $errMsg = $this->messages['msSFU30Name'][1]; - array_push($errMsg, array($i)); - $errors[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsGroup_msSFU30Name', 'msSFU30Name', + 'groupname', $this->messages['msSFU30Name'][1], $errors); } // NIS domain if (!$this->isBooleanConfigOptionSet('windowsGroup_hidemsSFU30NisDomain', true)) { - if (!empty($rawAccounts[$i][$ids['windowsGroup_msSFU30NisDomain']])) { - $partialAccounts[$i]['msSFU30NisDomain'] = $rawAccounts[$i][$ids['windowsGroup_msSFU30NisDomain']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsGroup_msSFU30NisDomain', 'msSFU30NisDomain'); } } return $errors; diff --git a/lam/lib/modules/windowsHost.inc b/lam/lib/modules/windowsHost.inc index 73ebf9b0..53cc4e35 100644 --- a/lam/lib/modules/windowsHost.inc +++ b/lam/lib/modules/windowsHost.inc @@ -3,7 +3,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2013 Roland Gruber + Copyright (C) 2013 - 2014 Roland Gruber 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 @@ -262,17 +262,11 @@ class windowsHost extends baseModule { } } // description - if ($rawAccounts[$i][$ids['windowsHost_description']] != "") { - $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['windowsHost_description']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsHost_description', 'description'); // location - if ($rawAccounts[$i][$ids['windowsHost_location']] != "") { - $partialAccounts[$i]['location'] = $rawAccounts[$i][$ids['windowsHost_location']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsHost_location', 'location'); // managed by - if ($rawAccounts[$i][$ids['windowsHost_managedBy']] != "") { - $partialAccounts[$i]['managedBy'] = $rawAccounts[$i][$ids['windowsHost_managedBy']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsHost_managedBy', 'managedBy'); // machine trust account, no password required $partialAccounts[$i]['userAccountControl'][0] = 4128; } diff --git a/lam/lib/modules/windowsUser.inc b/lam/lib/modules/windowsUser.inc index 5c792f98..3ad8870e 100644 --- a/lam/lib/modules/windowsUser.inc +++ b/lam/lib/modules/windowsUser.inc @@ -1268,44 +1268,22 @@ class windowsUser extends baseModule implements passwordService { $partialAccounts[$i]['displayName'] = $partialAccounts[$i]['cn']; } // initials - if ($rawAccounts[$i][$ids['windowsUser_initials']] != "") { - $partialAccounts[$i]['initials'] = $rawAccounts[$i][$ids['windowsUser_initials']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_initials', 'initials'); // description - if ($rawAccounts[$i][$ids['windowsUser_description']] != "") { - $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['windowsUser_description']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_description', 'description'); // street - if ($rawAccounts[$i][$ids['windowsUser_streetAddress']] != "") { - $partialAccounts[$i]['streetAddress'] = $rawAccounts[$i][$ids['windowsUser_streetAddress']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_streetAddress', 'streetAddress'); // post office box - if ($rawAccounts[$i][$ids['windowsUser_postOfficeBox']] != "") { - $partialAccounts[$i]['postOfficeBox'] = $rawAccounts[$i][$ids['windowsUser_postOfficeBox']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_postOfficeBox', 'postOfficeBox'); // postal code - if ($rawAccounts[$i][$ids['windowsUser_postalCode']] != "") { - if (get_preg($rawAccounts[$i][$ids['windowsUser_postalCode']], 'postalCode')) { - $partialAccounts[$i]['postalCode'] = $rawAccounts[$i][$ids['windowsUser_postalCode']]; - } - else { - $errMsg = $this->messages['postalCode'][1]; - array_push($errMsg, array($i)); - $errors[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_postalCode', 'postalCode', + 'postalCode', $this->messages['postalCode'][1], $errors); // location - if ($rawAccounts[$i][$ids['windowsUser_l']] != "") { - $partialAccounts[$i]['l'] = $rawAccounts[$i][$ids['windowsUser_l']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_l', 'l'); // state - if ($rawAccounts[$i][$ids['windowsUser_state']] != "") { - $partialAccounts[$i]['st'] = $rawAccounts[$i][$ids['windowsUser_state']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_state', 'st'); // office name - if ($rawAccounts[$i][$ids['windowsUser_officeName']] != "") { - $partialAccounts[$i]['physicalDeliveryOfficeName'] = $rawAccounts[$i][$ids['windowsUser_officeName']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_officeName', 'physicalDeliveryOfficeName'); // mail if ($rawAccounts[$i][$ids['windowsUser_mail']] != "") { foreach ($replacements as $wildcard => $value) { @@ -1337,16 +1315,8 @@ class windowsUser extends baseModule implements passwordService { } } // telephone - if ($rawAccounts[$i][$ids['windowsUser_telephoneNumber']] != "") { - if (get_preg($rawAccounts[$i][$ids['windowsUser_telephoneNumber']], 'telephone')) { - $partialAccounts[$i]['telephoneNumber'] = $rawAccounts[$i][$ids['windowsUser_telephoneNumber']]; - } - else { - $errMsg = $this->messages['telephoneNumber'][1]; - array_push($errMsg, array($i)); - $errors[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_telephoneNumber', 'telephoneNumber', + 'telephone', $this->messages['telephoneNumber'][1], $errors); // other telephone if (isset($ids['windowsUser_otherTelephone']) && ($rawAccounts[$i][$ids['windowsUser_otherTelephone']] != "")) { $valueList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['windowsUser_otherTelephone']]); @@ -1361,9 +1331,7 @@ class windowsUser extends baseModule implements passwordService { } } // website - if ($rawAccounts[$i][$ids['windowsUser_webSite']] != "") { - $partialAccounts[$i]['wWWHomePage'] = $rawAccounts[$i][$ids['windowsUser_webSite']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_webSite', 'wWWHomePage'); // other websites if (isset($ids['windowsUser_otherWebSites']) && ($rawAccounts[$i][$ids['windowsUser_otherWebSites']] != "")) { $valueList = preg_split('/;[ ]*/', $rawAccounts[$i][$ids['windowsUser_otherWebSites']]); @@ -1476,22 +1444,12 @@ class windowsUser extends baseModule implements passwordService { } // NIS name if (!$this->isBooleanConfigOptionSet('windowsUser_hidemsSFU30Name', true)) { - if (!empty($rawAccounts[$i][$ids['windowsUser_msSFU30Name']])) { - if (get_preg($rawAccounts[$i][$ids['windowsUser_msSFU30Name']], 'username')) { - $partialAccounts[$i]['msSFU30Name'] = $rawAccounts[$i][$ids['windowsUser_msSFU30Name']]; - } - else { - $errMsg = $this->messages['msSFU30Name'][1]; - array_push($errMsg, array($i)); - $errors[] = $errMsg; - } - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_msSFU30Name', 'msSFU30Name', + 'username', $this->messages['msSFU30Name'][1], $errors); } // NIS domain if (!$this->isBooleanConfigOptionSet('windowsUser_hidemsSFU30NisDomain', true)) { - if (!empty($rawAccounts[$i][$ids['windowsUser_msSFU30NisDomain']])) { - $partialAccounts[$i]['msSFU30NisDomain'] = $rawAccounts[$i][$ids['windowsUser_msSFU30NisDomain']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'windowsUser_msSFU30NisDomain', 'msSFU30NisDomain'); } } return $errors;