updated layout

This commit is contained in:
Roland Gruber 2013-01-13 13:46:25 +00:00
parent feb20abbb4
commit 5b0504214b
1 changed files with 100 additions and 92 deletions

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2009 - 2012 Roland Gruber Copyright (C) 2009 - 2013 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -299,53 +299,65 @@ class eduPerson extends baseModule {
$return->addElement($newAffiliationContainer); $return->addElement($newAffiliationContainer);
$return->addElement(new htmlOutputText(''), true); $return->addElement(new htmlOutputText(''), true);
// nick names // nick names
$nicks = new htmlTable(); $nickNames = array();
if (isset($this->attributes['eduPersonNickname'][0])) { if (isset($this->attributes['eduPersonNickname'][0])) {
for ($i = 0; $i < sizeof($this->attributes['eduPersonNickname']); $i++) { $nickNames = $this->attributes['eduPersonNickname'];
$nicks->addElement(new htmlInputField('nickName' . $i, $this->attributes['eduPersonNickname'][$i]));
$nicks->addElement(new htmlButton('delNickName' . $i, 'del.png', true), true);
} }
if (sizeof($nickNames) == 0) {
$nickNames[] = '';
}
$nickNameLabel = new htmlOutputText(_('Nick names'));
$nickNameLabel->alignment = htmlElement::ALIGN_TOP;
$return->addElement($nickNameLabel);
$nickNameContainer = new htmlGroup();
for ($i = 0; $i < sizeof($nickNames); $i++) {
$nickNameField = new htmlInputField('eduPersonNickname' . $i, $nickNames[$i]);
$nickNameField->setFieldSize(40);
$nickNameContainer->addElement($nickNameField);
if ($nickNames[$i] != '') {
$nickNameContainer->addElement(new htmlButton('deleduPersonNickname' . $i, 'del.png', true));
}
if ($i < (sizeof($nickNames) - 1)) {
$nickNameContainer->addElement(new htmlOutputText('<br>', false));
} }
else { else {
$nicks->addElement(new htmlOutputText('-'), true); $nickNameContainer->addElement(new htmlButton('addeduPersonNickname', 'add.png', true));
} }
$nickLabel = new htmlOutputText(_('Nick names')); }
$nickLabel->alignment = htmlElement::ALIGN_TOP; $return->addElement($nickNameContainer);
$return->addElement($nickLabel); $nickNameHelp = new htmlHelpLink('nickName');
$return->addElement($nicks); $nickNameHelp->alignment = htmlElement::ALIGN_TOP;
$nickHelp = new htmlHelpLink('nickName'); $return->addElement($nickNameHelp, true);
$nickHelp->alignment = htmlElement::ALIGN_TOP;
$return->addElement($nickHelp, true);
$return->addElement(new htmlOutputText(''));
$newNickContainer = new htmlTable();
$newNickContainer->addElement(new htmlInputField('nickName', ''));
$newNickContainer->addElement(new htmlButton('newNickName', 'add.png', true));
$return->addElement($newNickContainer);
$return->addElement(new htmlOutputText(''), true);
// entitlements // entitlements
$entitlements = new htmlTable(); $entitlements = array();
if (isset($this->attributes['eduPersonEntitlement'][0])) { if (isset($this->attributes['eduPersonEntitlement'][0])) {
for ($i = 0; $i < sizeof($this->attributes['eduPersonEntitlement']); $i++) { $entitlements = $this->attributes['eduPersonEntitlement'];
$entitlements->addElement(new htmlInputField('entitlement' . $i, $this->attributes['eduPersonEntitlement'][$i]));
$entitlements->addElement(new htmlButton('delEntitlement' . $i, 'del.png', true), true);
} }
} if (sizeof($entitlements) == 0) {
else { $entitlements[] = '';
$entitlements->addElement(new htmlOutputText('-'));
} }
$entitlementLabel = new htmlOutputText(_('Entitlements')); $entitlementLabel = new htmlOutputText(_('Entitlements'));
$entitlementLabel->alignment = htmlElement::ALIGN_TOP; $entitlementLabel->alignment = htmlElement::ALIGN_TOP;
$return->addElement($entitlementLabel); $return->addElement($entitlementLabel);
$return->addElement($entitlements); $entitlementContainer = new htmlGroup();
for ($i = 0; $i < sizeof($entitlements); $i++) {
$entitlementField = new htmlInputField('eduPersonEntitlement' . $i, $entitlements[$i]);
$entitlementField->setFieldSize(40);
$entitlementContainer->addElement($entitlementField);
if ($entitlements[$i] != '') {
$entitlementContainer->addElement(new htmlButton('deleduPersonEntitlement' . $i, 'del.png', true));
}
if ($i < (sizeof($entitlements) - 1)) {
$entitlementContainer->addElement(new htmlOutputText('<br>', false));
}
else {
$entitlementContainer->addElement(new htmlButton('addeduPersonEntitlement', 'add.png', true));
}
}
$return->addElement($entitlementContainer);
$entitlementHelp = new htmlHelpLink('entitlement'); $entitlementHelp = new htmlHelpLink('entitlement');
$entitlementHelp->alignment = htmlElement::ALIGN_TOP; $entitlementHelp->alignment = htmlElement::ALIGN_TOP;
$return->addElement($entitlementHelp, true); $return->addElement($entitlementHelp, true);
$return->addElement(new htmlOutputText(''));
$newEntitlementContainer = new htmlTable();
$newEntitlementContainer->addElement(new htmlInputField('entitlement', ''));
$newEntitlementContainer->addElement(new htmlButton('newEntitlement', 'add.png', true));
$return->addElement($newEntitlementContainer);
$return->addElement(new htmlOutputText(''), true);
// org DN // org DN
$orgDN = ''; $orgDN = '';
if (isset($this->attributes['eduPersonOrgDN'][0])) { if (isset($this->attributes['eduPersonOrgDN'][0])) {
@ -354,7 +366,7 @@ class eduPerson extends baseModule {
$orgDNInput = new htmlTableExtendedInputField(_('Organisation'), 'orgDN', $orgDN, 'orgDN'); $orgDNInput = new htmlTableExtendedInputField(_('Organisation'), 'orgDN', $orgDN, 'orgDN');
$orgDNInput->setFieldSize(40); $orgDNInput->setFieldSize(40);
$return->addElement($orgDNInput, true); $return->addElement($orgDNInput, true);
// primare OU DN // primary OU DN
$primaryOrgUnitDN = ''; $primaryOrgUnitDN = '';
if (isset($this->attributes['eduPersonPrimaryOrgUnitDN'][0])) { if (isset($this->attributes['eduPersonPrimaryOrgUnitDN'][0])) {
$primaryOrgUnitDN = $this->attributes['eduPersonPrimaryOrgUnitDN'][0]; $primaryOrgUnitDN = $this->attributes['eduPersonPrimaryOrgUnitDN'][0];
@ -363,33 +375,36 @@ class eduPerson extends baseModule {
$primaryOUInput->setFieldSize(40); $primaryOUInput->setFieldSize(40);
$return->addElement($primaryOUInput, true); $return->addElement($primaryOUInput, true);
// OUs // OUs
$orgUnitDN = new htmlTable(); $orgUnitDNs = array();
if (isset($this->attributes['eduPersonOrgUnitDN'][0])) { if (isset($this->attributes['eduPersonOrgUnitDN'][0])) {
for ($i = 0; $i < sizeof($this->attributes['eduPersonOrgUnitDN']); $i++) { $orgUnitDNs = $this->attributes['eduPersonOrgUnitDN'];
$orgUnitDNInput = new htmlInputField('orgUnitDN' . $i, $this->attributes['eduPersonOrgUnitDN'][$i]);
$orgUnitDNInput->setFieldSize(40);
$orgUnitDN->addElement($orgUnitDNInput);
$orgUnitDN->addElement(new htmlButton('delOrgUnitDN' . $i, 'del.png', true), true);
} }
} if (sizeof($orgUnitDNs) == 0) {
else { $orgUnitDNs[] = '';
$orgUnitDN->addElement(new htmlOutputText('-'));
} }
$orgUnitDNLabel = new htmlOutputText(_('Organisational units')); $orgUnitDNLabel = new htmlOutputText(_('Organisational units'));
$orgUnitDNLabel->alignment = htmlElement::ALIGN_TOP; $orgUnitDNLabel->alignment = htmlElement::ALIGN_TOP;
$return->addElement($orgUnitDNLabel); $return->addElement($orgUnitDNLabel);
$return->addElement($orgUnitDN); $orgUnitDNContainer = new htmlGroup();
for ($i = 0; $i < sizeof($orgUnitDNs); $i++) {
$orgUnitDNField = new htmlInputField('eduPersonOrgUnitDN' . $i, $orgUnitDNs[$i]);
$orgUnitDNField->setFieldSize(40);
$orgUnitDNContainer->addElement($orgUnitDNField);
if ($orgUnitDNs[$i] != '') {
$orgUnitDNContainer->addElement(new htmlButton('deleduPersonOrgUnitDN' . $i, 'del.png', true));
}
if ($i < (sizeof($orgUnitDNs) - 1)) {
$orgUnitDNContainer->addElement(new htmlOutputText('<br>', false));
}
else {
$orgUnitDNContainer->addElement(new htmlButton('addeduPersonOrgUnitDN', 'add.png', true));
}
}
$return->addElement($orgUnitDNContainer);
$orgUnitDNHelp = new htmlHelpLink('orgUnitDN'); $orgUnitDNHelp = new htmlHelpLink('orgUnitDN');
$orgUnitDNHelp->alignment = htmlElement::ALIGN_TOP; $orgUnitDNHelp->alignment = htmlElement::ALIGN_TOP;
$return->addElement($orgUnitDNHelp, true); $return->addElement($orgUnitDNHelp, true);
$return->addElement(new htmlOutputText('')); // remove button
$newOrgUnitDN = new htmlTable();
$newOrgUnitDNInput = new htmlInputField('orgUnitDN', '');
$newOrgUnitDNInput->setFieldSize(40);
$newOrgUnitDN->addElement($newOrgUnitDNInput);
$newOrgUnitDN->addElement(new htmlButton('newOrgUnitDN', 'add.png', true));
$return->addElement($newOrgUnitDN);
$return->addElement(new htmlOutputText(''), true);
$return->addElement(new htmlSpacer(null, '10px'), true); $return->addElement(new htmlSpacer(null, '10px'), true);
$addButton = new htmlButton('remObjectClass', _('Remove EDU person extension')); $addButton = new htmlButton('remObjectClass', _('Remove EDU person extension'));
$addButton->colspan = 3; $addButton->colspan = 3;
@ -455,31 +470,31 @@ class eduPerson extends baseModule {
} }
$this->attributes['eduPersonAffiliation'] = array_unique($this->attributes['eduPersonAffiliation']); $this->attributes['eduPersonAffiliation'] = array_unique($this->attributes['eduPersonAffiliation']);
// nick names // nick names
$this->attributes['eduPersonNickname'] = array(); $nickNameCounter = 0;
$i = 0; while (isset($_POST['eduPersonNickname' . $nickNameCounter])) {
while (isset($_POST['nickName' . $i])) { $this->attributes['eduPersonNickname'][$nickNameCounter] = $_POST['eduPersonNickname' . $nickNameCounter];
if (!isset($_POST['delNickName' . $i]) && ($_POST['nickName' . $i] != '')) { if (($this->attributes['eduPersonNickname'][$nickNameCounter] == '') || isset($_POST['deleduPersonNickname' . $nickNameCounter])) {
$this->attributes['eduPersonNickname'][] = $_POST['nickName' . $i]; unset($this->attributes['eduPersonNickname'][$nickNameCounter]);
} }
$i++; $nickNameCounter++;
} }
if (isset($_POST['newNickName']) && ($_POST['nickName'] != '')) { if (isset($_POST['addeduPersonNickname'])) {
$this->attributes['eduPersonNickname'][] = $_POST['nickName']; $this->attributes['eduPersonNickname'][] = '';
} }
$this->attributes['eduPersonNickname'] = array_unique($this->attributes['eduPersonNickname']); $this->attributes['eduPersonNickname'] = array_values(array_unique($this->attributes['eduPersonNickname']));
// entitlements // entitlements
$this->attributes['eduPersonEntitlement'] = array(); $entitlementCounter = 0;
$i = 0; while (isset($_POST['eduPersonEntitlement' . $entitlementCounter])) {
while (isset($_POST['entitlement' . $i])) { $this->attributes['eduPersonEntitlement'][$entitlementCounter] = $_POST['eduPersonEntitlement' . $entitlementCounter];
if (!isset($_POST['delEntitlement' . $i]) && ($_POST['entitlement' . $i] != '')) { if (($this->attributes['eduPersonEntitlement'][$entitlementCounter] == '') || isset($_POST['deleduPersonEntitlement' . $entitlementCounter])) {
$this->attributes['eduPersonEntitlement'][] = $_POST['entitlement' . $i]; unset($this->attributes['eduPersonEntitlement'][$entitlementCounter]);
} }
$i++; $entitlementCounter++;
} }
if (isset($_POST['newEntitlement']) && ($_POST['entitlement'] != '')) { if (isset($_POST['addeduPersonEntitlement'])) {
$this->attributes['eduPersonEntitlement'][] = $_POST['entitlement']; $this->attributes['eduPersonEntitlement'][] = '';
} }
$this->attributes['eduPersonEntitlement'] = array_unique($this->attributes['eduPersonEntitlement']); $this->attributes['eduPersonEntitlement'] = array_values(array_unique($this->attributes['eduPersonEntitlement']));
// org DN // org DN
$this->attributes['eduPersonOrgDN'][0] = $_POST['orgDN']; $this->attributes['eduPersonOrgDN'][0] = $_POST['orgDN'];
if ($_POST['orgDN'] != '') { if ($_POST['orgDN'] != '') {
@ -495,28 +510,21 @@ class eduPerson extends baseModule {
} }
} }
// OUs // OUs
$this->attributes['eduPersonOrgUnitDN'] = array(); $orgUnitDNCounter = 0;
$i = 0; while (isset($_POST['eduPersonOrgUnitDN' . $orgUnitDNCounter])) {
while (isset($_POST['orgUnitDN' . $i])) { $this->attributes['eduPersonOrgUnitDN'][$orgUnitDNCounter] = $_POST['eduPersonOrgUnitDN' . $orgUnitDNCounter];
if (!isset($_POST['delOrgUnitDN' . $i]) && ($_POST['orgUnitDN' . $i] != '')) { if (($this->attributes['eduPersonOrgUnitDN'][$orgUnitDNCounter] == '') || isset($_POST['deleduPersonOrgUnitDN' . $orgUnitDNCounter])) {
$this->attributes['eduPersonOrgUnitDN'][] = $_POST['orgUnitDN' . $i]; unset($this->attributes['eduPersonOrgUnitDN'][$orgUnitDNCounter]);
if (!get_preg($_POST['orgUnitDN' . $i], 'dn')) {
$error = $this->messages['orgUnitDN'][0];
array_push($error, $_POST['orgUnitDN' . $i]);
$errors[] = $error;
} }
elseif (!get_preg($this->attributes['eduPersonOrgUnitDN'][$orgUnitDNCounter], 'dn')) {
$errors[] = $this->messages['eduPersonOrgUnitDN'][0];
} }
$i++; $orgUnitDNCounter++;
} }
if (isset($_POST['newOrgUnitDN']) && ($_POST['orgUnitDN'] != '')) { if (isset($_POST['addeduPersonOrgUnitDN'])) {
$this->attributes['eduPersonOrgUnitDN'][] = $_POST['orgUnitDN']; $this->attributes['eduPersonOrgUnitDN'][] = '';
if (!get_preg($_POST['orgUnitDN'], 'dn')) {
$error = $this->messages['orgUnitDN'][0];
array_push($error, $_POST['orgUnitDN']);
$errors[] = $error;
} }
} $this->attributes['eduPersonOrgUnitDN'] = array_values(array_unique($this->attributes['eduPersonOrgUnitDN']));
$this->attributes['eduPersonOrgUnitDN'] = array_unique($this->attributes['eduPersonOrgUnitDN']);
return $errors; return $errors;
} }
@ -664,7 +672,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>' . $this->attributes['eduPersonScopedAffiliation'][0] . '</value></block>'; $return['eduPerson_scopedAffiliation'][0] = '<block><key>' . _('Scoped affiliation') . '</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>';