multiple scoped affiliations
This commit is contained in:
parent
29268e381c
commit
f99a900258
|
@ -82,9 +82,14 @@ class eduPerson extends baseModule {
|
||||||
"Text" => _("Specifies the person's primary relationship to the institution in broad categories such as student, faculty, staff, alum, etc.")
|
"Text" => _("Specifies the person's primary relationship to the institution in broad categories such as student, faculty, staff, alum, etc.")
|
||||||
),
|
),
|
||||||
'scopedAffiliation' => array(
|
'scopedAffiliation' => array(
|
||||||
"Headline" => _("Scoped affiliation"), 'attr' => 'eduPersonScopedAffiliation',
|
"Headline" => _("Scoped affiliations"), 'attr' => 'eduPersonScopedAffiliation',
|
||||||
"Text" => _("Specifies the person's affiliation within a particular security domain in broad categories such as student, faculty, staff, alum, etc.")
|
"Text" => _("Specifies the person's affiliation within a particular security domain in broad categories such as student, faculty, staff, alum, etc.")
|
||||||
),
|
),
|
||||||
|
'scopedAffiliationUpload' => array(
|
||||||
|
"Headline" => _("Scoped affiliations"), 'attr' => 'eduPersonScopedAffiliation',
|
||||||
|
"Text" => _("Specifies the person's affiliation within a particular security domain in broad categories such as student, faculty, staff, alum, etc.") . " " .
|
||||||
|
_('Multiple values are separated by comma.')
|
||||||
|
),
|
||||||
'nickName' => array(
|
'nickName' => array(
|
||||||
"Headline" => _("Nick names"), 'attr' => 'eduPersonNickname',
|
"Headline" => _("Nick names"), 'attr' => 'eduPersonNickname',
|
||||||
"Text" => _("This is a list of nick names for this user.")
|
"Text" => _("This is a list of nick names for this user.")
|
||||||
|
@ -152,9 +157,9 @@ class eduPerson extends baseModule {
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'eduPerson_scopedAffiliation',
|
'name' => 'eduPerson_scopedAffiliation',
|
||||||
'description' => _('Scoped affiliation'),
|
'description' => _('Scoped affiliations'),
|
||||||
'help' => 'scopedAffiliation',
|
'help' => 'scopedAffiliationUpload',
|
||||||
'example' => 'student@domain'
|
'example' => 'student@domain, student@domain2'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'name' => 'eduPerson_affiliation',
|
'name' => 'eduPerson_affiliation',
|
||||||
|
@ -204,7 +209,7 @@ class eduPerson extends baseModule {
|
||||||
'principalName' => _('Principal name'),
|
'principalName' => _('Principal name'),
|
||||||
'entitlement' => _('Entitlements'),
|
'entitlement' => _('Entitlements'),
|
||||||
'primaryOrgUnitDN' => _('Primary organisational unit'),
|
'primaryOrgUnitDN' => _('Primary organisational unit'),
|
||||||
'scopedAffiliation' => _('Scoped affiliation')
|
'scopedAffiliation' => _('Scoped affiliations')
|
||||||
);
|
);
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
@ -258,21 +263,38 @@ class eduPerson extends baseModule {
|
||||||
$primaryAffiliation = array($this->attributes['eduPersonPrimaryAffiliation'][0]);
|
$primaryAffiliation = array($this->attributes['eduPersonPrimaryAffiliation'][0]);
|
||||||
}
|
}
|
||||||
$return->addElement(new htmlTableExtendedSelect('primaryAffiliation', $this->affiliationTypes, $primaryAffiliation, _('Primary affiliation'), 'primaryAffiliation'), true);
|
$return->addElement(new htmlTableExtendedSelect('primaryAffiliation', $this->affiliationTypes, $primaryAffiliation, _('Primary affiliation'), 'primaryAffiliation'), true);
|
||||||
// scoped affiliation
|
// scoped affiliations
|
||||||
$scopedAffiliation = '';
|
$scopedAffiliationLabel = new htmlOutputText(_('Scoped affiliations'));
|
||||||
$scopedAffiliationPrefix = array();
|
$scopedAffiliationLabel->alignment = htmlElement::ALIGN_TOP;
|
||||||
|
$return->addElement($scopedAffiliationLabel);
|
||||||
|
$scopedAffiliations = new htmlTable();
|
||||||
if (isset($this->attributes['eduPersonScopedAffiliation'][0])) {
|
if (isset($this->attributes['eduPersonScopedAffiliation'][0])) {
|
||||||
$parts = explode('@', $this->attributes['eduPersonScopedAffiliation'][0]);
|
for ($i = 0; $i < sizeof($this->attributes['eduPersonScopedAffiliation']); $i++) {
|
||||||
|
$parts = explode('@', $this->attributes['eduPersonScopedAffiliation'][$i]);
|
||||||
$scopedAffiliationPrefix = array($parts[0]);
|
$scopedAffiliationPrefix = array($parts[0]);
|
||||||
$scopedAffiliation = substr($this->attributes['eduPersonScopedAffiliation'][0], strlen($parts[0]) + 1);
|
$scopedAffiliation = substr($this->attributes['eduPersonScopedAffiliation'][$i], strlen($parts[0]) + 1);
|
||||||
}
|
$scopedAffiliationContainer = new htmlGroup();
|
||||||
$return->addElement(new htmlOutputText(_('Scoped affiliation')));
|
$scopedAffiliationContainer->addElement(new htmlSelect('scopedAffiliationPrefix' . $i, $this->affiliationTypes, $scopedAffiliationPrefix));
|
||||||
$scopedAffiliationContainer = new htmlTable();
|
|
||||||
$scopedAffiliationContainer->addElement(new htmlSelect('scopedAffiliationPrefix', $this->affiliationTypes, $scopedAffiliationPrefix));
|
|
||||||
$scopedAffiliationContainer->addElement(new htmlOutputText('@'));
|
$scopedAffiliationContainer->addElement(new htmlOutputText('@'));
|
||||||
$scopedAffiliationContainer->addElement(new htmlInputField('scopedAffiliation', $scopedAffiliation));
|
$scopedAffiliationContainer->addElement(new htmlInputField('scopedAffiliation' . $i, $scopedAffiliation));
|
||||||
$return->addElement($scopedAffiliationContainer);
|
$scopedAffiliationContainer->addElement(new htmlButton('deleduPersonScopedAffiliation' . $i, 'del.png', true));
|
||||||
$return->addElement(new htmlHelpLink('scopedAffiliation'), true);
|
if ($i == (sizeof($this->attributes['eduPersonScopedAffiliation']) - 1)) {
|
||||||
|
$scopedAffiliationContainer->addElement(new htmlButton('addeduPersonScopedAffiliation', 'add.png', true));
|
||||||
|
}
|
||||||
|
$scopedAffiliations->addElement($scopedAffiliationContainer, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$scopedAffiliationContainer = new htmlGroup();
|
||||||
|
$scopedAffiliationContainer->addElement(new htmlOutputText('-'));
|
||||||
|
$scopedAffiliationContainer->addElement(new htmlSpacer('10px', null));
|
||||||
|
$scopedAffiliationContainer->addElement(new htmlButton('addeduPersonScopedAffiliation', 'add.png', true));
|
||||||
|
$scopedAffiliations->addElement($scopedAffiliationContainer);
|
||||||
|
}
|
||||||
|
$return->addElement($scopedAffiliations);
|
||||||
|
$scopedAffiliationHelp = new htmlHelpLink('scopedAffiliation');
|
||||||
|
$scopedAffiliationHelp->alignment = htmlElement::ALIGN_TOP;
|
||||||
|
$return->addElement($scopedAffiliationHelp, true);
|
||||||
// affiliations
|
// affiliations
|
||||||
$affiliations = new htmlTable();
|
$affiliations = new htmlTable();
|
||||||
if (isset($this->attributes['eduPersonAffiliation'][0])) {
|
if (isset($this->attributes['eduPersonAffiliation'][0])) {
|
||||||
|
@ -442,13 +464,19 @@ class eduPerson extends baseModule {
|
||||||
$errors = array();
|
$errors = array();
|
||||||
// primary affiliation
|
// primary affiliation
|
||||||
$this->attributes['eduPersonPrimaryAffiliation'][0] = $_POST['primaryAffiliation'];
|
$this->attributes['eduPersonPrimaryAffiliation'][0] = $_POST['primaryAffiliation'];
|
||||||
// scoped affiliation
|
// scoped affiliations
|
||||||
if (isset($_POST['scopedAffiliation']) && ($_POST['scopedAffiliation'] != '')) {
|
$scopedAffiliationCounter = 0;
|
||||||
$this->attributes['eduPersonScopedAffiliation'][0] = $_POST['scopedAffiliationPrefix'] . '@' . $_POST['scopedAffiliation'];
|
while (isset($_POST['scopedAffiliation' . $scopedAffiliationCounter])) {
|
||||||
|
$this->attributes['eduPersonScopedAffiliation'][$scopedAffiliationCounter] = $_POST['scopedAffiliationPrefix' . $scopedAffiliationCounter] . '@' . $_POST['scopedAffiliation' . $scopedAffiliationCounter];
|
||||||
|
if (($_POST['scopedAffiliation' . $scopedAffiliationCounter] == '') || isset($_POST['deleduPersonScopedAffiliation' . $scopedAffiliationCounter])) {
|
||||||
|
unset($this->attributes['eduPersonScopedAffiliation'][$scopedAffiliationCounter]);
|
||||||
}
|
}
|
||||||
elseif (isset($this->attributes['eduPersonScopedAffiliation'][0])) {
|
$scopedAffiliationCounter++;
|
||||||
unset($this->attributes['eduPersonScopedAffiliation']);
|
|
||||||
}
|
}
|
||||||
|
if (isset($_POST['addeduPersonScopedAffiliation'])) {
|
||||||
|
$this->attributes['eduPersonScopedAffiliation'][] = '';
|
||||||
|
}
|
||||||
|
$this->attributes['eduPersonScopedAffiliation'] = array_values(array_unique($this->attributes['eduPersonScopedAffiliation']));
|
||||||
// principal name
|
// principal name
|
||||||
$this->attributes['eduPersonPrincipalName'][0] = $_POST['principalName'];
|
$this->attributes['eduPersonPrincipalName'][0] = $_POST['principalName'];
|
||||||
if ($_POST['principalName'] != '') {
|
if ($_POST['principalName'] != '') {
|
||||||
|
@ -579,16 +607,19 @@ class eduPerson extends baseModule {
|
||||||
$partialAccounts[$i]['eduPersonPrimaryAffiliation'] = $rawAccounts[$i][$ids['eduPerson_primaryAffiliation']];
|
$partialAccounts[$i]['eduPersonPrimaryAffiliation'] = $rawAccounts[$i][$ids['eduPerson_primaryAffiliation']];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// scoped affiliation
|
// scoped affiliations
|
||||||
if ($rawAccounts[$i][$ids['eduPerson_scopedAffiliation']] != "") {
|
if ($rawAccounts[$i][$ids['eduPerson_scopedAffiliation']] != "") {
|
||||||
$parts = explode('@', $rawAccounts[$i][$ids['eduPerson_scopedAffiliation']]);
|
$parts = explode(', ', $rawAccounts[$i][$ids['eduPerson_scopedAffiliation']]);
|
||||||
if (!in_array($parts[0], $this->affiliationTypes)) {
|
for ($a = 0; $a < sizeof($parts); $a++) {
|
||||||
|
$subparts = explode('@', $parts[$a]);
|
||||||
|
if (!in_array($subparts[0], $this->affiliationTypes)) {
|
||||||
$error = $this->messages['scopedAffiliation'][0];
|
$error = $this->messages['scopedAffiliation'][0];
|
||||||
array_push($error, $i);
|
array_push($error, $i);
|
||||||
$messages[] = $error;
|
$messages[] = $error;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$partialAccounts[$i]['eduPersonScopedAffiliation'] = $rawAccounts[$i][$ids['eduPerson_scopedAffiliation']];
|
$partialAccounts[$i]['eduPersonScopedAffiliation'] = $parts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// affiliations
|
// affiliations
|
||||||
|
@ -672,7 +703,7 @@ class eduPerson extends baseModule {
|
||||||
$return['eduPerson_primaryAffiliation'][0] = '<block><key>' . _('Primary affiliation') . '</key><value>' . $this->attributes['eduPersonPrimaryAffiliation'][0] . '</value></block>';
|
$return['eduPerson_primaryAffiliation'][0] = '<block><key>' . _('Primary affiliation') . '</key><value>' . $this->attributes['eduPersonPrimaryAffiliation'][0] . '</value></block>';
|
||||||
}
|
}
|
||||||
if (isset($this->attributes['eduPersonScopedAffiliation'][0])) {
|
if (isset($this->attributes['eduPersonScopedAffiliation'][0])) {
|
||||||
$return['eduPerson_scopedAffiliation'][0] = '<block><key>' . _('Scoped affiliation') . '</key><value>' . implode(', ', $this->attributes['eduPersonScopedAffiliation']) . '</value></block>';
|
$return['eduPerson_scopedAffiliation'][0] = '<block><key>' . _('Scoped affiliations') . '</key><value>' . implode(', ', $this->attributes['eduPersonScopedAffiliation']) . '</value></block>';
|
||||||
}
|
}
|
||||||
if (isset($this->attributes['eduPersonPrincipalName'][0])) {
|
if (isset($this->attributes['eduPersonPrincipalName'][0])) {
|
||||||
$return['eduPerson_principalName'][0] = '<block><key>' . _('Principal name') . '</key><value>' . $this->attributes['eduPersonPrincipalName'][0] . '</value></block>';
|
$return['eduPerson_principalName'][0] = '<block><key>' . _('Principal name') . '</key><value>' . $this->attributes['eduPersonPrincipalName'][0] . '</value></block>';
|
||||||
|
|
Loading…
Reference in New Issue