From 1372c4645aaba9f9eb0b62af5218e5ccbdb56d0b Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 18 Apr 2014 09:03:31 +0000 Subject: [PATCH] reduced upload code --- lam/lib/modules/pykotaBillingCode.inc | 6 ++---- lam/lib/modules/pykotaGroup.inc | 6 ++---- lam/lib/modules/pykotaPrinter.inc | 23 +++++------------------ lam/lib/modules/pykotaUser.inc | 16 ++++------------ 4 files changed, 13 insertions(+), 38 deletions(-) diff --git a/lam/lib/modules/pykotaBillingCode.inc b/lam/lib/modules/pykotaBillingCode.inc index a1ee2cd5..b2ea5b93 100644 --- a/lam/lib/modules/pykotaBillingCode.inc +++ b/lam/lib/modules/pykotaBillingCode.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 @@ -236,9 +236,7 @@ class pykotaBillingCode extends baseModule { $partialAccounts[$i]['pykotaBillingCode'] = $rawAccounts[$i][$ids['pykotaBillingCode_pykotaBillingCode']]; } // description - if (!empty($rawAccounts[$i][$ids['pykotaBillingCode_description']])) { - $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['pykotaBillingCode_description']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'pykotaBillingCode_description', 'description'); // balance $partialAccounts[$i]['pykotaBalance'] = '0.0'; // page count diff --git a/lam/lib/modules/pykotaGroup.inc b/lam/lib/modules/pykotaGroup.inc index 13786a9e..458201b4 100644 --- a/lam/lib/modules/pykotaGroup.inc +++ b/lam/lib/modules/pykotaGroup.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 @@ -416,9 +416,7 @@ class pykotaGroup extends baseModule { } } // description - if ($this->manageDescription() && !empty($rawAccounts[$i][$ids['pykotaGroup_description']])) { - $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['pykotaGroup_description']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'pykotaGroup_description', 'description'); // PyKota group name if (!empty($rawAccounts[$i][$ids['pykotaGroup_pykotaGroupName']])) { if (!get_preg($rawAccounts[$i][$ids['pykotaGroup_pykotaGroupName']], 'groupname')) { diff --git a/lam/lib/modules/pykotaPrinter.inc b/lam/lib/modules/pykotaPrinter.inc index 6bfc713e..61e9821d 100644 --- a/lam/lib/modules/pykotaPrinter.inc +++ b/lam/lib/modules/pykotaPrinter.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 @@ -480,24 +480,11 @@ class pykotaPrinter extends baseModule { } } // description - if (!empty($rawAccounts[$i][$ids['pykotaPrinter_description']])) { - $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['pykotaPrinter_description']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'pykotaPrinter_description', 'description'); // job size - if (!empty($rawAccounts[$i][$ids['pykotaPrinter_pykotaMaxJobSize']])) { - $pykotaMaxJobSize = $rawAccounts[$i][$ids['pykotaPrinter_pykotaMaxJobSize']]; - if (!get_preg($pykotaMaxJobSize, 'digit')) { - $errMsg = $this->messages['pykotaMaxJobSize'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - else { - $partialAccounts[$i]['pykotaMaxJobSize'] = $pykotaMaxJobSize; - } - } - else { - $partialAccounts[$i]['pykotaMaxJobSize'] = '0.0'; - } + $partialAccounts[$i]['pykotaMaxJobSize'] = '0.0'; + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'pykotaPrinter_pykotaMaxJobSize', 'pykotaMaxJobSize', + 'digit', $this->messages['pykotaMaxJobSize'][1], $messages); // price per job if (!empty($rawAccounts[$i][$ids['pykotaPrinter_pykotaPricePerJob']])) { $pykotaPricePerJob = $rawAccounts[$i][$ids['pykotaPrinter_pykotaPricePerJob']]; diff --git a/lam/lib/modules/pykotaUser.inc b/lam/lib/modules/pykotaUser.inc index 24bb8075..48476b9e 100644 --- a/lam/lib/modules/pykotaUser.inc +++ b/lam/lib/modules/pykotaUser.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 @@ -795,19 +795,11 @@ class pykotaUser extends baseModule { } // mail if ($this->manageUid() && !empty($rawAccounts[$i][$ids['pykotaUser_mail']])) { - if (!get_preg($rawAccounts[$i][$ids['pykotaUser_mail']], 'email')) { - $errMsg = $this->messages['mail'][1]; - array_push($errMsg, array($i)); - $messages[] = $errMsg; - } - else { - $partialAccounts[$i]['mail'] = $rawAccounts[$i][$ids['pykotaUser_mail']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'pykotaUser_mail', 'mail', + 'email', $this->messages['mail'][1], $messages); } // description - if ($this->manageDescription() && !empty($rawAccounts[$i][$ids['pykotaUser_description']])) { - $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['pykotaUser_description']]; - } + $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'pykotaUser_description', 'description'); // PyKota user name if (!empty($rawAccounts[$i][$ids['pykotaUser_pykotaUserName']])) { if (!get_preg($rawAccounts[$i][$ids['pykotaUser_pykotaUserName']], 'username')) {