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 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. "/;[ ]?/") * @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])) { if (!isset($ids[$colName])) {
return; return;
} }

View File

@ -33,7 +33,7 @@ $Id$
* @package modules * @package modules
*/ */
class eduPerson extends baseModule { class eduPerson extends baseModule {
/** possible affiliation types */ /** possible affiliation types */
private $affiliationTypes = array('faculty', 'student', 'staff', 'alum', private $affiliationTypes = array('faculty', 'student', 'staff', 'alum',
'member', 'affiliate', 'employee', 'library-walk-in'); 'member', 'affiliate', 'employee', 'library-walk-in');
@ -50,7 +50,7 @@ class eduPerson extends baseModule {
/** /**
* Returns true if this module can manage accounts of the current type, otherwise false. * Returns true if this module can manage accounts of the current type, otherwise false.
* *
* @return boolean true if module fits * @return boolean true if module fits
*/ */
public function can_manage() { public function can_manage() {
@ -61,7 +61,7 @@ class eduPerson extends baseModule {
* Returns meta data that is interpreted by parent class * Returns meta data that is interpreted by parent class
* *
* @return array array with meta data * @return array array with meta data
* *
* @see baseModule::get_metaData() * @see baseModule::get_metaData()
*/ */
function get_metaData() { function get_metaData() {
@ -267,7 +267,7 @@ class eduPerson extends baseModule {
/** /**
* Returns the HTML meta data for the main account page. * Returns the HTML meta data for the main account page.
* *
* @return htmlElement HTML meta data * @return htmlElement HTML meta data
*/ */
function display_html_attributes() { function display_html_attributes() {
@ -530,15 +530,9 @@ class eduPerson extends baseModule {
} }
} }
// nick names // nick names
if ($rawAccounts[$i][$ids['eduPerson_nickname']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_nickname', 'eduPersonNickname', null, array(), $messages, '/,[ ]*/');
$parts = explode(', ', $rawAccounts[$i][$ids['eduPerson_nickname']]);
$partialAccounts[$i]['eduPersonNickname'] = $parts;
}
// entitlements // entitlements
if ($rawAccounts[$i][$ids['eduPerson_entitlement']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_entitlement', 'eduPersonEntitlement', null, array(), $messages, '/,[ ]*/');
$parts = explode(', ', $rawAccounts[$i][$ids['eduPerson_entitlement']]);
$partialAccounts[$i]['eduPersonEntitlement'] = $parts;
}
// organisation // organisation
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_orgDN', 'eduPersonOrgDN', $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_orgDN', 'eduPersonOrgDN',
'dn', $this->messages['eduPersonOrgDN'][1], $messages); 'dn', $this->messages['eduPersonOrgDN'][1], $messages);
@ -546,27 +540,9 @@ class eduPerson extends baseModule {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_primaryOrgUnitDN', 'eduPersonPrimaryOrgUnitDN', $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_primaryOrgUnitDN', 'eduPersonPrimaryOrgUnitDN',
'dn', $this->messages['eduPersonPrimaryOrgUnitDN'][1], $messages); 'dn', $this->messages['eduPersonPrimaryOrgUnitDN'][1], $messages);
// OUs // OUs
if ($rawAccounts[$i][$ids['eduPerson_orgUnitDN']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_orgUnitDN', 'eduPersonOrgUnitDN', 'dn', $this->messages['eduPersonOrgUnitDN'][1], $messages, '/;[ ]*/');
$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;
}
}
// assurance profiles // assurance profiles
if ($rawAccounts[$i][$ids['eduPerson_assurance']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_assurance', 'eduPersonAssurance', null, array(), $messages, '/,[ ]*/');
$parts = explode(', ', $rawAccounts[$i][$ids['eduPerson_assurance']]);
$partialAccounts[$i]['eduPersonAssurance'] = $parts;
}
} }
return $messages; return $messages;
} }

View File

@ -38,11 +38,11 @@ class freeRadius extends baseModule {
private static $monthList = array('01' => 'Jan', '02' => 'Feb', '03' => 'Mar', '04' => 'Apr', '05' => 'May', private static $monthList = array('01' => 'Jan', '02' => 'Feb', '03' => 'Mar', '04' => 'Apr', '05' => 'May',
'06' => 'Jun', '07' => 'Jul', '08' => 'Aug', '09' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec' '06' => 'Jun', '07' => 'Jul', '08' => 'Aug', '09' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'
); );
/** cache for profile DNs */ /** cache for profile DNs */
private $profileCache = null; private $profileCache = null;
/** /**
* Creates a new freeRadius object. * Creates a new freeRadius object.
* *
@ -55,7 +55,7 @@ class freeRadius extends baseModule {
/** /**
* Returns true if this module can manage accounts of the current type, otherwise false. * Returns true if this module can manage accounts of the current type, otherwise false.
* *
* @return boolean true if module fits * @return boolean true if module fits
*/ */
public function can_manage() { public function can_manage() {
@ -66,7 +66,7 @@ class freeRadius extends baseModule {
* Returns meta data that is interpreted by parent class * Returns meta data that is interpreted by parent class
* *
* @return array array with meta data * @return array array with meta data
* *
* @see baseModule::get_metaData() * @see baseModule::get_metaData()
*/ */
function get_metaData() { function get_metaData() {
@ -277,10 +277,10 @@ class freeRadius extends baseModule {
} }
return $return; return $return;
} }
/** /**
* Returns a list of configuration options. * Returns a list of configuration options.
* *
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br> * Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
* <br> * <br>
* The field names are used as keywords to load and save settings. * The field names are used as keywords to load and save settings.
@ -289,7 +289,7 @@ class freeRadius extends baseModule {
* @param array $scopes account types (user, group, host) * @param array $scopes account types (user, group, host)
* @param array $allScopes list of all active account modules and their scopes (module => array(scopes)) * @param array $allScopes list of all active account modules and their scopes (module => array(scopes))
* @return mixed htmlElement or array of htmlElement * @return mixed htmlElement or array of htmlElement
* *
* @see htmlElement * @see htmlElement
*/ */
public function get_configOptions($scopes, $allScopes) { public function get_configOptions($scopes, $allScopes) {
@ -344,7 +344,7 @@ class freeRadius extends baseModule {
/** /**
* Returns the HTML meta data for the main account page. * Returns the HTML meta data for the main account page.
* *
* @return htmlElement HTML meta data * @return htmlElement HTML meta data
*/ */
function display_html_attributes() { function display_html_attributes() {
@ -508,7 +508,7 @@ class freeRadius extends baseModule {
} }
return $errors; return $errors;
} }
/** /**
* This function will create the meta HTML code to show a page to change the expiration date. * This function will create the meta HTML code to show a page to change the expiration date.
* *
@ -566,7 +566,7 @@ class freeRadius extends baseModule {
$buttons->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'back' . $attr, _('Cancel'))); $buttons->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'back' . $attr, _('Cancel')));
$buttons->colspan = 6; $buttons->colspan = 6;
$return->addElement($buttons); $return->addElement($buttons);
return $return; return $return;
} }
/** /**
@ -627,18 +627,7 @@ class freeRadius extends baseModule {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'freeRadius_radiusRealm', 'radiusRealm', $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'freeRadius_radiusRealm', 'radiusRealm',
'DNSname', $this->messages['radiusRealm'][1], $errors); 'DNSname', $this->messages['radiusRealm'][1], $errors);
// group names // group names
if ($rawAccounts[$i][$ids['freeRadius_radiusGroupName']] != "") { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'freeRadius_radiusGroupName', 'radiusGroupName', 'groupname', $this->messages['radiusGroupName'][1], $errors, '/;[ ]*/');
$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;
}
}
}
// expiration date // expiration date
if ($rawAccounts[$i][$ids['freeRadius_radiusExpiration']] != "") { 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']])) { 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 // profile DN
if (!empty($rawAccounts[$i][$ids['freeRadius_radiusProfileDn']])) { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'freeRadius_radiusProfileDn', 'radiusProfileDn', 'dn', $this->messages['radiusProfileDn'][0], $errors);
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;
}
}
} }
return $errors; return $errors;
} }
@ -749,10 +729,10 @@ class freeRadius extends baseModule {
} }
} }
} }
/** /**
* Formats the expiration date attribute. * Formats the expiration date attribute.
* *
* @param String $date date value * @param String $date date value
*/ */
private function formatExpirationDate($date) { private function formatExpirationDate($date) {
@ -769,10 +749,10 @@ class freeRadius extends baseModule {
} }
return $date; return $date;
} }
/** /**
* Returns a list of possible profile DNs. * Returns a list of possible profile DNs.
* *
* @return array list of profile DNs * @return array list of profile DNs
*/ */
private function getProfiles() { private function getProfiles() {
@ -789,7 +769,7 @@ class freeRadius extends baseModule {
usort($this->profileCache, 'compareDN'); usort($this->profileCache, 'compareDN');
return $this->profileCache; return $this->profileCache;
} }
} }