LDAPAccountManager/lam/lib/modules/eduPerson.inc

557 lines
24 KiB
PHP
Raw Normal View History

2009-02-10 19:41:20 +00:00
<?php
/*
2009-10-27 18:47:12 +00:00
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
2020-03-19 19:42:36 +00:00
Copyright (C) 2009 - 2020 Roland Gruber
2009-02-10 19:41:20 +00:00
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* Manages the eduPerson extension for user accounts.
*
* @package modules
* @author Roland Gruber
*/
/**
* Manages the eduPerson extension for user accounts.
*
* @package modules
*/
class eduPerson extends baseModule {
2015-07-13 18:05:39 +00:00
2012-07-15 12:05:47 +00:00
/** possible affiliation types */
2009-02-10 19:41:20 +00:00
private $affiliationTypes = array('faculty', 'student', 'staff', 'alum',
'member', 'affiliate', 'employee', 'library-walk-in');
/**
* Creates a new eduPerson object.
*
* @param string $scope account type (user, group, host)
*/
function __construct($scope) {
parent::__construct($scope);
$this->autoAddObjectClasses = false;
}
/**
* Returns true if this module can manage accounts of the current type, otherwise false.
2015-07-13 18:05:39 +00:00
*
* @return boolean true if module fits
*/
public function can_manage() {
return in_array($this->get_scope(), array('user'));
}
2009-02-10 19:41:20 +00:00
/**
* Returns meta data that is interpreted by parent class
*
* @return array array with meta data
2015-07-13 18:05:39 +00:00
*
2009-02-10 19:41:20 +00:00
* @see baseModule::get_metaData()
*/
function get_metaData() {
$return = array();
// icon
$return['icon'] = 'eduPerson.png';
2009-02-10 19:41:20 +00:00
// alias name
$return["alias"] = _("EDU person");
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('eduPerson');
// managed attributes
$return['attributes'] = array('eduPersonAffiliation', 'eduPersonNickname',
'eduPersonOrgDN', 'eduPersonOrgUnitDN',
'eduPersonPrimaryAffiliation', 'eduPersonPrincipalName',
'eduPersonEntitlement', 'eduPersonPrimaryOrgUnitDN',
2013-01-13 14:42:54 +00:00
'eduPersonScopedAffiliation', 'eduPersonAssurance');
2011-03-24 18:58:33 +00:00
// RDN attribute
$return["RDN"] = array('eduPersonPrincipalName' => 'low');
2009-02-10 19:41:20 +00:00
// help Entries
$return['help'] = array(
'primaryAffiliation' => array(
2012-02-04 15:56:31 +00:00
"Headline" => _("Primary affiliation"), 'attr' => 'eduPersonPrimaryAffiliation',
2009-02-10 19:41:20 +00:00
"Text" => _("Specifies the person's primary relationship to the institution in broad categories such as student, faculty, staff, alum, etc.")
),
'scopedAffiliation' => array(
2013-01-13 14:23:30 +00:00
"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.")
),
2013-01-13 14:23:30 +00:00
'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.')
),
2013-10-19 14:29:02 +00:00
'eduPersonNickname' => array(
2012-02-04 15:56:31 +00:00
"Headline" => _("Nick names"), 'attr' => 'eduPersonNickname',
2009-02-10 19:41:20 +00:00
"Text" => _("This is a list of nick names for this user.")
),
'affiliation' => array(
2012-02-04 15:56:31 +00:00
"Headline" => _("Affiliations"), 'attr' => 'eduPersonAffiliation',
2012-02-05 19:17:58 +00:00
"Text" => _("Specifies the person's relationships to the institution in broad categories such as student, faculty, staff, alum, etc.")
2009-02-10 19:41:20 +00:00
),
2009-03-06 19:17:22 +00:00
'affiliationUpload' => array(
2012-02-04 15:56:31 +00:00
"Headline" => _("Affiliations"), 'attr' => 'eduPersonAffiliation',
2012-02-05 19:17:58 +00:00
"Text" => _("Specifies the person's relationships to the institution in broad categories such as student, faculty, staff, alum, etc.") . " " .
2009-03-28 18:26:41 +00:00
_('Multiple values are separated by comma.')
2009-03-06 19:17:22 +00:00
),
2013-10-19 14:29:02 +00:00
'eduPersonPrincipalName' => array(
2012-02-04 15:56:31 +00:00
"Headline" => _("Principal name"), 'attr' => 'eduPersonPrincipalName',
2009-02-13 19:27:48 +00:00
"Text" => _("The \"NetID\" of the person for the purposes of inter-institutional authentication. It should be represented in the form \"user@scope\" where scope defines a local security domain.")
),
2013-10-19 14:29:02 +00:00
'eduPersonEntitlement' => array(
2012-02-04 15:56:31 +00:00
"Headline" => _("Entitlements"), 'attr' => 'eduPersonEntitlement',
"Text" => _("URI (either URN or URL) that indicates a set of rights to specific resources.")
2009-03-03 19:37:17 +00:00
),
2009-03-06 19:17:22 +00:00
'entitlementUpload' => array(
2012-02-04 15:56:31 +00:00
"Headline" => _("Entitlements"), 'attr' => 'eduPersonEntitlement',
2009-03-28 18:26:41 +00:00
"Text" => _("URI (either URN or URL) that indicates a set of rights to specific resources.") . " " . _('Multiple values are separated by comma.')
2009-03-06 19:17:22 +00:00
),
2013-10-19 14:29:02 +00:00
'eduPersonOrgDN' => array(
2012-02-04 15:56:31 +00:00
"Headline" => _("Organisation"), 'attr' => 'eduPersonOrgDN',
2009-03-03 19:37:17 +00:00
"Text" => _("The DN of the directory entry representing the institution with which the person is associated.")
),
2013-10-19 14:29:02 +00:00
'eduPersonPrimaryOrgUnitDN' => array(
2012-02-04 15:56:31 +00:00
"Headline" => _("Primary organisational unit"), 'attr' => 'eduPersonPrimaryOrgUnitDN',
2011-06-06 18:05:17 +00:00
"Text" => _("The DN of the directory entry representing the person's primary organisational unit.")
2009-03-03 19:37:17 +00:00
),
2013-10-19 14:29:02 +00:00
'eduPersonOrgUnitDN' => array(
2012-02-04 15:56:31 +00:00
"Headline" => _("Organisational units"), 'attr' => 'eduPersonOrgUnitDN',
2011-06-06 18:05:17 +00:00
"Text" => _("The DNs of the directory entries representing the person's organisational units.")
2009-03-06 19:17:22 +00:00
),
'orgUnitDNUpload' => array(
2012-02-04 15:56:31 +00:00
"Headline" => _("Organisational units"), 'attr' => 'eduPersonOrgUnitDN',
2011-06-06 18:05:17 +00:00
"Text" => _("The DNs of the directory entries representing the person's organisational units.") . ' ' . _('Multiple values are separated by comma.')
2009-12-20 14:35:42 +00:00
),
2013-01-13 14:42:54 +00:00
'eduPersonAssurance' => array(
"Headline" => _('Assurance profiles'), 'attr' => 'eduPersonAssurance',
"Text" => _('Assurance profiles are the set of standards that are met by an identity assertion.')
),
'eduPersonAssuranceUpload' => array(
"Headline" => _('Assurance profiles'), 'attr' => 'eduPersonAssurance',
"Text" => _('Assurance profiles are the set of standards that are met by an identity assertion.') . " " . _('Multiple values are separated by comma.')
),
2009-12-20 14:35:42 +00:00
'autoAdd' => array(
"Headline" => _("Automatically add this extension"),
"Text" => _("This will enable the extension automatically if this profile is loaded.")
2009-03-03 19:37:17 +00:00
));
2009-12-20 14:35:42 +00:00
// profile options
2018-05-19 06:15:34 +00:00
$profileContainer = new htmlResponsiveRow();
$profileContainer->add(new htmlResponsiveInputCheckbox('eduPerson_addExt', false, _('Automatically add this extension'), 'autoAdd'), 12);
2010-09-17 18:27:20 +00:00
$return['profile_options'] = $profileContainer;
2009-02-10 19:41:20 +00:00
// upload fields
$return['upload_columns'] = array(
array(
2009-03-06 19:17:22 +00:00
'name' => 'eduPerson_principalName',
'description' => _('Principal name'),
2013-10-19 14:29:02 +00:00
'help' => 'eduPersonPrincipalName',
2009-03-06 19:17:22 +00:00
'example' => _('user@company.com'),
2017-09-18 17:47:27 +00:00
'unique' => true
2009-03-06 19:17:22 +00:00
),
array(
'name' => 'eduPerson_primaryAffiliation',
'description' => _('Primary affiliation'),
'help' => 'primaryAffiliation',
'example' => 'student',
'values' => implode(", ", $this->affiliationTypes)
),
array(
'name' => 'eduPerson_scopedAffiliation',
2013-01-13 14:23:30 +00:00
'description' => _('Scoped affiliations'),
'help' => 'scopedAffiliationUpload',
'example' => 'student@domain, student@domain2'
2009-03-06 19:17:22 +00:00
),
array(
'name' => 'eduPerson_affiliation',
'description' => _('Affiliations'),
'help' => 'affiliationUpload',
'example' => 'student, employee',
'values' => implode(", ", $this->affiliationTypes)
),
array(
'name' => 'eduPerson_nickname',
'description' => _('Nick names'),
2013-10-19 14:29:02 +00:00
'help' => 'eduPersonNickname',
2009-03-06 19:17:22 +00:00
'example' => _('Steve, Stevo')
),
array(
'name' => 'eduPerson_entitlement',
'description' => _('Entitlements'),
'help' => 'entitlementUpload',
'example' => 'http://xstor.com/contracts/HEd123'
),
array(
'name' => 'eduPerson_orgDN',
2011-06-06 18:05:17 +00:00
'description' => _('Organisation'),
2013-10-19 14:29:02 +00:00
'help' => 'eduPersonOrgDN',
2009-03-06 19:17:22 +00:00
'example' => _('ou=accounts,dc=yourdomain,dc=org')
),
array(
'name' => 'eduPerson_primaryOrgUnitDN',
2011-06-06 18:05:17 +00:00
'description' => _('Primary organisational unit'),
2013-10-19 14:29:02 +00:00
'help' => 'eduPersonPrimaryOrgUnitDN',
2009-03-06 19:17:22 +00:00
'example' => _('ou=accounts,dc=yourdomain,dc=org')
),
array(
'name' => 'eduPerson_orgUnitDN',
2011-06-06 18:05:17 +00:00
'description' => _('Organisational units'),
2009-03-06 19:17:22 +00:00
'help' => 'orgUnitDNUpload',
'example' => _('ou=accounts,dc=yourdomain,dc=org')
2013-01-13 14:42:54 +00:00
),
array(
'name' => 'eduPerson_assurance',
'description' => _('Assurance profiles'),
'help' => 'eduPersonAssuranceUpload',
'example' => 'urn:mace:incommon:IAQ:sample, http://idm.example.org/LOA#sample'
),
2009-02-10 19:41:20 +00:00
);
// available PDF fields
$return['PDF_fields'] = array(
2010-04-05 12:38:23 +00:00
'affiliation' => _('Affiliations'),
'nickname' => _('Nick names'),
2011-06-06 18:05:17 +00:00
'orgDN' => _('Organisation'),
'orgUnitDN' => _('Organisational units'),
2010-04-05 12:38:23 +00:00
'primaryAffiliation' => _('Primary affiliation'),
'principalName' => _('Principal name'),
'entitlement' => _('Entitlements'),
2011-06-06 18:05:17 +00:00
'primaryOrgUnitDN' => _('Primary organisational unit'),
2013-01-13 14:42:54 +00:00
'scopedAffiliation' => _('Scoped affiliations'),
'eduPersonAssurance' => _('Assurance profiles'),
2009-02-10 19:41:20 +00:00
);
return $return;
}
/**
* This function fills the error message array with messages
*/
function load_Messages() {
2013-10-19 14:29:02 +00:00
$this->messages['eduPersonPrincipalName'][0] = array('ERROR', _('Principal name is invalid!'));
$this->messages['eduPersonPrincipalName'][1] = array('ERROR', _('Account %s:') . ' eduPerson_principalName', _('Principal name is invalid!'));
$this->messages['eduPersonOrgDN'][0] = array('ERROR', _('Please enter a valid DN in the field:') . ' ' . _("Organisation"));
$this->messages['eduPersonOrgDN'][1] = array('ERROR', _('Account %s:') . ' eduPerson_orgDN', _('This is not a valid DN!'));
$this->messages['eduPersonPrimaryOrgUnitDN'][0] = array('ERROR', _('Please enter a valid DN in the field:') . ' ' . _("Primary organisational unit"));
$this->messages['eduPersonPrimaryOrgUnitDN'][1] = array('ERROR', _('Account %s:') . ' eduPerson_primaryOrgUnitDN', _('This is not a valid DN!'));
$this->messages['eduPersonOrgUnitDN'][0] = array('ERROR', _('Organisational units contains an invalid entry.'));
$this->messages['eduPersonOrgUnitDN'][1] = array('ERROR', _('Account %s:') . ' eduPerson_orgUnitDN', _('This is not a valid list of DNs!'));
2009-03-06 19:17:22 +00:00
$this->messages['primaryAffiliation'][0] = array('ERROR', _('Account %s:') . ' eduPerson_primaryAffiliation', _('Please enter a valid primary affiliation.'));
$this->messages['scopedAffiliation'][0] = array('ERROR', _('Account %s:') . ' eduPerson_scopedAffiliation', _('Please enter a valid scoped affiliation.'));
$this->messages['affiliation'][0] = array('ERROR', _('Account %s:') . ' eduPerson_affiliation', _('Please enter a valid list of affiliations.'));
2009-02-10 19:41:20 +00:00
}
2011-03-26 12:47:30 +00:00
/**
* This functions return true if all needed settings are done.
*
* @return boolean true, if all is ok
*/
function module_complete() {
if (($this->getAccountContainer()->rdn == 'eduPersonPrincipalName') && !isset($this->attributes['eduPersonPrincipalName'][0])) {
return false;
}
return true;
}
2009-02-10 19:41:20 +00:00
/**
* Returns the HTML meta data for the main account page.
2015-07-13 18:05:39 +00:00
*
2010-09-18 11:37:22 +00:00
* @return htmlElement HTML meta data
2009-02-10 19:41:20 +00:00
*/
function display_html_attributes() {
2019-08-23 20:03:29 +00:00
$return = new htmlResponsiveRow();
2009-02-10 19:41:20 +00:00
if (in_array('eduPerson', $this->attributes['objectClass'])) {
// principal name
2013-10-19 14:29:02 +00:00
$this->addSimpleInputTextField($return, 'eduPersonPrincipalName', _('Principal name'));
2009-02-10 19:41:20 +00:00
// primary affiliation
$primaryAffiliation = array();
if (isset($this->attributes['eduPersonPrimaryAffiliation'][0])) {
$primaryAffiliation = array($this->attributes['eduPersonPrimaryAffiliation'][0]);
}
2019-08-23 20:03:29 +00:00
$return->add(new htmlResponsiveSelect('primaryAffiliation', $this->affiliationTypes, $primaryAffiliation, _('Primary affiliation'), 'primaryAffiliation'), 12);
2013-01-13 14:23:30 +00:00
// scoped affiliations
$scopedAffiliationLabel = new htmlOutputText(_('Scoped affiliations'));
$scopedAffiliationLabel->alignment = htmlElement::ALIGN_TOP;
2019-08-23 20:03:29 +00:00
$return->addLabel($scopedAffiliationLabel);
2013-01-13 14:23:30 +00:00
$scopedAffiliations = new htmlTable();
if (isset($this->attributes['eduPersonScopedAffiliation'][0])) {
2013-01-13 14:23:30 +00:00
for ($i = 0; $i < sizeof($this->attributes['eduPersonScopedAffiliation']); $i++) {
$parts = explode('@', $this->attributes['eduPersonScopedAffiliation'][$i]);
$scopedAffiliationPrefix = array($parts[0]);
$scopedAffiliation = substr($this->attributes['eduPersonScopedAffiliation'][$i], strlen($parts[0]) + 1);
2019-08-23 20:03:29 +00:00
$scopedAffiliationContainer = new htmlTable();
2013-01-13 14:23:30 +00:00
$scopedAffiliationContainer->addElement(new htmlSelect('scopedAffiliationPrefix' . $i, $this->affiliationTypes, $scopedAffiliationPrefix));
$scopedAffiliationContainer->addElement(new htmlOutputText('@'));
$scopedAffiliationContainer->addElement(new htmlInputField('scopedAffiliation' . $i, $scopedAffiliation));
$scopedAffiliationContainer->addElement(new htmlButton('deleduPersonScopedAffiliation' . $i, 'del.png', 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));
2019-08-23 20:03:29 +00:00
$scopedAffiliationContainer->addElement(new htmlButton('addeduPersonScopedAffiliation', 'add.png'));
$scopedAffiliationContainer->addElement(new htmlHelpLink('scopedAffiliation'), true);
2013-01-13 14:23:30 +00:00
$scopedAffiliations->addElement($scopedAffiliationContainer);
}
2019-08-23 20:03:29 +00:00
$return->addField($scopedAffiliations);
2009-02-10 19:41:20 +00:00
// affiliations
2010-09-17 18:27:20 +00:00
$affiliations = new htmlTable();
2009-02-10 19:41:20 +00:00
if (isset($this->attributes['eduPersonAffiliation'][0])) {
for ($i = 0; $i < sizeof($this->attributes['eduPersonAffiliation']); $i++) {
2010-09-17 18:27:20 +00:00
$affiliations->addElement(new htmlSelect('affiliation' . $i, $this->affiliationTypes, array($this->attributes['eduPersonAffiliation'][$i])));
$affiliationButton = new htmlButton('delAffiliation' . $i, 'del.png', true);
2019-08-23 20:03:29 +00:00
$affiliations->addElement($affiliationButton);
if ($i === 0) {
$affiliations->addElement(new htmlHelpLink('affiliation'));
}
$affiliations->addNewLine();
2009-02-10 19:41:20 +00:00
}
}
else {
2019-08-23 20:03:29 +00:00
$affiliations->addElement(new htmlOutputText('-'));
$affiliations->addElement(new htmlHelpLink('affiliation'), true);
2009-02-10 19:41:20 +00:00
}
2019-08-23 20:03:29 +00:00
$affiliations->addElement(new htmlSelect('affiliation', $this->affiliationTypes));
$affiliations->addElement(new htmlButton('newAffiliation', 'add.png', true));
2010-09-17 18:27:20 +00:00
$affiliationLabel = new htmlOutputText(_('Affiliations'));
$affiliationLabel->alignment = htmlElement::ALIGN_TOP;
2019-08-23 20:03:29 +00:00
$return->addLabel($affiliationLabel);
$return->addField($affiliations);
$return->addVerticalSpacer('0.5rem');
2009-02-10 19:41:20 +00:00
// nick names
2013-10-19 14:29:02 +00:00
$this->addMultiValueInputTextField($return, 'eduPersonNickname', _('Nick names'));
// entitlements
2013-10-19 14:29:02 +00:00
$this->addMultiValueInputTextField($return, 'eduPersonEntitlement', _('Entitlements'));
2009-03-03 19:37:17 +00:00
// org DN
2013-10-19 14:29:02 +00:00
$this->addSimpleInputTextField($return, 'eduPersonOrgDN', _('Organisation'));
2013-01-13 13:46:25 +00:00
// primary OU DN
2013-10-19 14:29:02 +00:00
$this->addSimpleInputTextField($return, 'eduPersonPrimaryOrgUnitDN', _('Primary organisational unit'));
2009-03-03 19:37:17 +00:00
// OUs
2013-10-19 14:29:02 +00:00
$this->addMultiValueInputTextField($return, 'eduPersonOrgUnitDN', _('Organisational units'));
2013-01-13 14:42:54 +00:00
// assurance profiles
2013-10-19 14:29:02 +00:00
$this->addMultiValueInputTextField($return, 'eduPersonAssurance', _('Assurance profiles'));
2013-01-13 13:46:25 +00:00
// remove button
2019-08-23 20:03:29 +00:00
$return->addVerticalSpacer('2rem');
2010-09-17 18:27:20 +00:00
$addButton = new htmlButton('remObjectClass', _('Remove EDU person extension'));
2019-08-23 20:03:29 +00:00
$return->add($addButton, 12, 12, 12, 'text-center');
}
2009-02-10 19:41:20 +00:00
else {
2019-08-23 20:03:29 +00:00
$return->add(new htmlButton('addObjectClass', _('Add EDU person extension')), 12);
2009-02-10 19:41:20 +00:00
}
return $return;
}
/**
* Processes user input of the primary module page.
* It checks if all input values are correct and updates the associated LDAP attributes.
*
* @return array list of info/error messages
*/
function process_attributes() {
2010-09-17 18:27:20 +00:00
if (isset($_POST['addObjectClass'])) {
2009-12-20 14:35:42 +00:00
$this->attributes['objectClass'][] = 'eduPerson';
return array();
}
2010-09-17 18:27:20 +00:00
elseif (isset($_POST['remObjectClass'])) {
2009-12-20 14:35:42 +00:00
$this->attributes['objectClass'] = array_delete(array('eduPerson'), $this->attributes['objectClass']);
for ($i = 0; $i < sizeof($this->meta['attributes']); $i++) {
if (isset($this->attributes[$this->meta['attributes'][$i]])) {
unset($this->attributes[$this->meta['attributes'][$i]]);
}
}
return array();
}
2010-05-19 19:22:29 +00:00
if (!in_array('eduPerson', $this->attributes['objectClass'])) {
return array();
}
2009-02-10 19:41:20 +00:00
$errors = array();
// primary affiliation
$this->attributes['eduPersonPrimaryAffiliation'][0] = $_POST['primaryAffiliation'];
2013-01-13 14:23:30 +00:00
// scoped affiliations
$scopedAffiliationCounter = 0;
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]);
}
$scopedAffiliationCounter++;
}
2013-01-13 14:23:30 +00:00
if (isset($_POST['addeduPersonScopedAffiliation'])) {
$this->attributes['eduPersonScopedAffiliation'][] = '';
}
2013-01-13 14:23:30 +00:00
$this->attributes['eduPersonScopedAffiliation'] = array_values(array_unique($this->attributes['eduPersonScopedAffiliation']));
2009-02-10 19:41:20 +00:00
// principal name
2013-10-19 14:29:02 +00:00
$this->attributes['eduPersonPrincipalName'][0] = $_POST['eduPersonPrincipalName'];
2020-03-19 19:42:36 +00:00
if (($_POST['eduPersonPrincipalName'] != '') && !preg_match('/^[0-9a-z_\\.@-]+$/i', $_POST['eduPersonPrincipalName'])) {
$errors[] = $this->messages['eduPersonPrincipalName'][0];
2009-02-10 19:41:20 +00:00
}
// affiliations
$this->attributes['eduPersonAffiliation'] = array();
$i = 0;
while (isset($_POST['affiliation' . $i])) {
if (!isset($_POST['delAffiliation' . $i]) && ($_POST['affiliation' . $i] != '')) {
$this->attributes['eduPersonAffiliation'][] = $_POST['affiliation' . $i];
}
$i++;
}
if (isset($_POST['newAffiliation']) && ($_POST['affiliation'] != '')) {
$this->attributes['eduPersonAffiliation'][] = $_POST['affiliation'];
}
$this->attributes['eduPersonAffiliation'] = array_unique($this->attributes['eduPersonAffiliation']);
// nick names
2013-10-19 14:29:02 +00:00
$this->processMultiValueInputTextField('eduPersonNickname', $errors);
// entitlements
2013-10-19 14:29:02 +00:00
$this->processMultiValueInputTextField('eduPersonEntitlement', $errors);
2009-03-03 19:37:17 +00:00
// org DN
2013-10-19 14:29:02 +00:00
$this->attributes['eduPersonOrgDN'][0] = $_POST['eduPersonOrgDN'];
2020-03-19 19:42:36 +00:00
if (($_POST['eduPersonOrgDN'] != '') && !get_preg($_POST['eduPersonOrgDN'], 'dn')) {
$errors[] = $this->messages['eduPersonOrgDN'][0];
2009-03-03 19:37:17 +00:00
}
// primary OU
2013-10-19 14:29:02 +00:00
$this->attributes['eduPersonPrimaryOrgUnitDN'][0] = $_POST['eduPersonPrimaryOrgUnitDN'];
2020-03-19 19:42:36 +00:00
if (($_POST['eduPersonPrimaryOrgUnitDN'] != '') && !get_preg($_POST['eduPersonPrimaryOrgUnitDN'], 'dn')) {
$errors[] = $this->messages['eduPersonPrimaryOrgUnitDN'][0];
2009-03-03 19:37:17 +00:00
}
// OUs
2013-10-19 14:29:02 +00:00
$this->processMultiValueInputTextField('eduPersonOrgUnitDN', $errors, 'dn');
2013-01-13 14:42:54 +00:00
// assurance profiles
2013-10-19 14:29:02 +00:00
$this->processMultiValueInputTextField('eduPersonAssurance', $errors);
2009-02-10 19:41:20 +00:00
return $errors;
}
2009-12-20 14:35:42 +00:00
/**
* Loads the values of an account profile into internal variables.
*
* @param array $profile hash array with profile values (identifier => value)
*/
function load_profile($profile) {
parent::load_profile($profile);
// add extension
2020-03-19 19:42:36 +00:00
if (isset($profile['eduPerson_addExt'][0])
&& ($profile['eduPerson_addExt'][0] == "true")
&& !in_array('eduPerson', $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = 'eduPerson';
2009-12-20 14:35:42 +00:00
}
}
2009-02-10 19:41:20 +00:00
/**
2017-05-20 09:46:49 +00:00
* {@inheritDoc}
* @see baseModule::build_uploadAccounts()
*/
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules, &$type) {
2009-02-10 19:41:20 +00:00
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
if (!in_array("eduPerson", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "eduPerson";
2009-03-06 19:17:22 +00:00
// principal name
if ($rawAccounts[$i][$ids['eduPerson_principalName']] != "") {
2009-08-13 18:57:26 +00:00
if (!preg_match('/^[0-9a-z_\\.@-]+$/i', $rawAccounts[$i][$ids['eduPerson_principalName']])) {
2013-10-19 14:29:02 +00:00
$error = $this->messages['eduPersonPrincipalName'][1];
2009-03-06 19:17:22 +00:00
array_push($error, $i);
$messages[] = $error;
}
else {
$partialAccounts[$i]['eduPersonPrincipalName'] = $rawAccounts[$i][$ids['eduPerson_principalName']];
}
}
2009-02-10 19:41:20 +00:00
// primary affiliation
if ($rawAccounts[$i][$ids['eduPerson_primaryAffiliation']] != "") {
2009-03-06 19:17:22 +00:00
if (!in_array($rawAccounts[$i][$ids['eduPerson_primaryAffiliation']], $this->affiliationTypes)) {
$error = $this->messages['primaryAffiliation'][0];
array_push($error, $i);
$messages[] = $error;
}
else {
$partialAccounts[$i]['eduPersonPrimaryAffiliation'] = $rawAccounts[$i][$ids['eduPerson_primaryAffiliation']];
}
}
2013-01-13 14:23:30 +00:00
// scoped affiliations
2009-03-06 19:17:22 +00:00
if ($rawAccounts[$i][$ids['eduPerson_scopedAffiliation']] != "") {
2013-01-13 14:23:30 +00:00
$parts = explode(', ', $rawAccounts[$i][$ids['eduPerson_scopedAffiliation']]);
for ($a = 0; $a < sizeof($parts); $a++) {
$subparts = explode('@', $parts[$a]);
if (!in_array($subparts[0], $this->affiliationTypes)) {
$error = $this->messages['scopedAffiliation'][0];
array_push($error, $i);
$messages[] = $error;
}
else {
$partialAccounts[$i]['eduPersonScopedAffiliation'] = $parts;
}
2009-03-06 19:17:22 +00:00
}
}
// affiliations
if ($rawAccounts[$i][$ids['eduPerson_affiliation']] != "") {
$parts = explode(', ', $rawAccounts[$i][$ids['eduPerson_affiliation']]);
$valid = true;
for ($a = 0; $a < sizeof($parts); $a++) {
if (!in_array($parts[$a], $this->affiliationTypes)) {
$valid = false;
$error = $this->messages['affiliation'][0];
array_push($error, $i);
$messages[] = $error;
break;
}
}
if ($valid) {
$partialAccounts[$i]['eduPersonAffiliation'] = $parts;
}
}
// nick names
2015-07-13 18:05:39 +00:00
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_nickname', 'eduPersonNickname', null, array(), $messages, '/,[ ]*/');
2009-03-06 19:17:22 +00:00
// entitlements
2015-07-13 18:05:39 +00:00
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_entitlement', 'eduPersonEntitlement', null, array(), $messages, '/,[ ]*/');
2011-06-06 18:05:17 +00:00
// organisation
2014-04-13 11:37:32 +00:00
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_orgDN', 'eduPersonOrgDN',
'dn', $this->messages['eduPersonOrgDN'][1], $messages);
2009-03-06 19:17:22 +00:00
// primary OU
2014-04-13 11:37:32 +00:00
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_primaryOrgUnitDN', 'eduPersonPrimaryOrgUnitDN',
'dn', $this->messages['eduPersonPrimaryOrgUnitDN'][1], $messages);
2009-03-06 19:17:22 +00:00
// OUs
2015-07-13 18:05:39 +00:00
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_orgUnitDN', 'eduPersonOrgUnitDN', 'dn', $this->messages['eduPersonOrgUnitDN'][1], $messages, '/;[ ]*/');
2013-01-13 14:42:54 +00:00
// assurance profiles
2015-07-13 18:05:39 +00:00
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'eduPerson_assurance', 'eduPersonAssurance', null, array(), $messages, '/,[ ]*/');
2009-02-10 19:41:20 +00:00
}
return $messages;
}
/**
2017-02-19 08:14:11 +00:00
* {@inheritDoc}
* @see baseModule::get_pdfEntries()
2015-01-07 17:16:35 +00:00
*/
2017-04-01 07:57:03 +00:00
function get_pdfEntries($pdfKeys, $typeId) {
2009-02-10 19:41:20 +00:00
$return = array();
2013-05-05 13:50:19 +00:00
$this->addSimplePDFField($return, 'primaryAffiliation', _('Primary affiliation'), 'eduPersonPrimaryAffiliation');
$this->addSimplePDFField($return, 'scopedAffiliation', _('Scoped affiliations'), 'eduPersonScopedAffiliation');
$this->addSimplePDFField($return, 'principalName', _('Principal name'), 'eduPersonPrincipalName');
$this->addSimplePDFField($return, 'nickname', _('Nick names'), 'eduPersonNickname');
$this->addSimplePDFField($return, 'affiliation', _('Affiliations'), 'eduPersonAffiliation');
$this->addSimplePDFField($return, 'entitlement', _('Entitlements'), 'eduPersonEntitlement');
$this->addSimplePDFField($return, 'orgDN', _('Organisation'), 'eduPersonOrgDN');
$this->addSimplePDFField($return, 'primaryOrgUnitDN', _('Primary organisational unit'), 'eduPersonPrimaryOrgUnitDN');
$this->addSimplePDFField($return, 'orgUnitDN', _('Organisational units'), 'eduPersonOrgUnitDN');
$this->addSimplePDFField($return, 'eduPersonAssurance', _('Assurance profiles'), 'eduPersonAssurance');
2009-02-10 19:41:20 +00:00
return $return;
}
}
?>