allow to relabel self service fields

This commit is contained in:
Roland Gruber 2013-11-30 15:02:06 +00:00
parent 6e3f499976
commit 04c0796f9e
16 changed files with 84 additions and 39 deletions

View File

@ -12,6 +12,7 @@ December 2013 4.4
-> Samba/Shadow: display password change date in self service
-> Custom fields: support custom label and icon, auto-completion
-> User self registration: support constant attribute values
-> Self service: allow to set custom field labels
- fixed bugs:
-> Format of photo in Personal tab (158)

View File

@ -6176,6 +6176,10 @@ objectclass: top
used to show your users additional data on the self service page that
must not be changed by themselves (e.g. first/last name).</para>
<para>Sometimes, you may want to set a custom label for an input
field. Click on the edit icon to set your own label text (Personal:
Department is relabeled as "Business unit" here).</para>
<screenshot>
<mediaobject>
<imageobject>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 75 KiB

BIN
lam/graphics/editNo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 965 B

View File

@ -1342,7 +1342,7 @@ abstract class baseModule {
}
}
$container[$name] = new htmlTableRow(array(
new htmlOutputText($label), $field
new htmlOutputText($this->getSelfServiceLabel($name, $label)), $field
));
}
@ -1476,6 +1476,7 @@ abstract class baseModule {
*
* @param String $fieldID field identifier
* @param selfServiceProfile $profile currently edited profile
* @return boolean may be set read-only
*/
public function canSelfServiceFieldBeReadOnly($fieldID, $profile) {
if (isset($this->meta['selfServiceReadOnlyFields']) && is_array($this->meta['selfServiceReadOnlyFields'])) {
@ -1483,6 +1484,35 @@ abstract class baseModule {
}
return false;
}
/**
* Returns if a self service field can be relabeled.
*
* @param String $fieldID field ID
* @param selfServiceProfile $profile currently edited profile
* @return boolean may be relabeled
*/
public function canSelfServiceFieldBeRelabeled($fieldID, $profile) {
if (isset($this->meta['selfServiceNoRelabelFields']) && is_array($this->meta['selfServiceNoRelabelFields'])) {
return !in_array($fieldID, $this->meta['selfServiceNoRelabelFields']);
}
return true;
}
/**
* Returns the field label. This can be either the given default label or an override value from profile.
*
* @param String $fieldID field ID
* @param String $defaultLabel default label text
* @return String label
*/
protected function getSelfServiceLabel($fieldID, $defaultLabel) {
if (!$this->canSelfServiceFieldBeRelabeled($fieldID, $this->selfServiceSettings)) {
return $defaultLabel;
}
$key = get_class($this) . '_' . $fieldID;
return empty($this->selfServiceSettings->relabelFields[$key]) ? $defaultLabel : $this->selfServiceSettings->relabelFields[$key];
}
/**
* Returns the meta HTML code for each input field.

View File

@ -88,6 +88,8 @@ class asteriskAccount extends baseModule implements passwordService {
$return['selfServiceFieldSettings'] = array(
'syncAsteriskPassword' => _('Sync Asterisk password with Unix password'),
);
// self service: fields that cannot be relabeled
$return['selfServiceNoRelabelFields'] = array('syncAsteriskPassword');
// help
$return['help'] = array(
'AstAccountCallerID' => array(

View File

@ -76,6 +76,8 @@ class asteriskVoicemail extends baseModule implements passwordService {
$return['selfServiceFieldSettings'] = array(
'syncAsteriskVoicemailPassword' => _('Sync Asterisk password with Unix password'),
);
// self service: fields that cannot be relabeled
$return['selfServiceNoRelabelFields'] = array('syncAsteriskVoicemailPassword');
// help
$return['help'] = array(
'AstContext' => array(

View File

@ -2417,7 +2417,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$firstNameField = new htmlOutputText($firstName);
}
$return['firstName'] = new htmlTableRow(array(
new htmlOutputText(_('First name')), $firstNameField
new htmlOutputText($this->getSelfServiceLabel('firstName', _('First name'))), $firstNameField
));
}
if (in_array('lastName', $fields)) {
@ -2428,7 +2428,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$lastNameField = new htmlOutputText($lastName);
}
$return['lastName'] = new htmlTableRow(array(
new htmlOutputText(_('Last name')), $lastNameField
new htmlOutputText($this->getSelfServiceLabel('lastName', _('Last name'))), $lastNameField
));
}
if (in_array('mail', $fields)) {
@ -2439,7 +2439,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$mailField = new htmlOutputText($mail);
}
$return['mail'] = new htmlTableRow(array(
new htmlOutputText(_('Email address')), $mailField
new htmlOutputText($this->getSelfServiceLabel('mail', _('Email address'))), $mailField
));
}
if (in_array('labeledURI', $fields)) {
@ -2450,7 +2450,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$labeledURIField = new htmlOutputText($labeledURI);
}
$return['labeledURI'] = new htmlTableRow(array(
new htmlOutputText(_('Web site')), $labeledURIField
new htmlOutputText($this->getSelfServiceLabel('labeledURI', _('Web site'))), $labeledURIField
));
}
if (in_array('telephoneNumber', $fields)) {
@ -2461,7 +2461,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$telephoneNumberField = new htmlOutputText($telephoneNumber);
}
$return['telephoneNumber'] = new htmlTableRow(array(
new htmlOutputText(_('Telephone number')), $telephoneNumberField
new htmlOutputText($this->getSelfServiceLabel('telephoneNumber', _('Telephone number'))), $telephoneNumberField
));
}
if (in_array('homePhone', $fields)) {
@ -2472,7 +2472,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$homePhoneField = new htmlOutputText($homePhone);
}
$return['homePhone'] = new htmlTableRow(array(
new htmlOutputText(_('Home telephone number')), $homePhoneField
new htmlOutputText($this->getSelfServiceLabel('homePhone', _('Home telephone number'))), $homePhoneField
));
}
if (in_array('mobile', $fields)) {
@ -2483,7 +2483,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$mobileField = new htmlOutputText($mobile);
}
$return['mobile'] = new htmlTableRow(array(
new htmlOutputText(_('Mobile telephone number')), $mobileField
new htmlOutputText($this->getSelfServiceLabel('mobile', _('Mobile telephone number'))), $mobileField
));
}
if (in_array('faxNumber', $fields)) {
@ -2494,7 +2494,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$faxNumberField = new htmlOutputText($faxNumber);
}
$return['faxNumber'] = new htmlTableRow(array(
new htmlOutputText(_('Fax number')), $faxNumberField
new htmlOutputText($this->getSelfServiceLabel('faxNumber', _('Fax number'))), $faxNumberField
));
}
if (in_array('street', $fields)) {
@ -2505,7 +2505,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$streetField = new htmlOutputText($street);
}
$return['street'] = new htmlTableRow(array(
new htmlOutputText(_('Street')), $streetField
new htmlOutputText($this->getSelfServiceLabel('street', _('Street'))), $streetField
));
}
if (in_array('postalAddress', $fields)) {
@ -2516,7 +2516,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$postalAddressField = new htmlOutputText($postalAddress);
}
$return['postalAddress'] = new htmlTableRow(array(
new htmlOutputText(_('Postal address')), $postalAddressField
new htmlOutputText($this->getSelfServiceLabel('postalAddress', _('Postal address'))), $postalAddressField
));
}
if (in_array('registeredAddress', $fields)) {
@ -2538,7 +2538,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$postalCodeField = new htmlOutputText($postalCode);
}
$return['postalCode'] = new htmlTableRow(array(
new htmlOutputText(_('Postal code')), $postalCodeField
new htmlOutputText($this->getSelfServiceLabel('postalCode', _('Postal code'))), $postalCodeField
));
}
if (in_array('postOfficeBox', $fields)) {
@ -2549,7 +2549,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$postOfficeBoxField = new htmlOutputText($postOfficeBox);
}
$return['postOfficeBox'] = new htmlTableRow(array(
new htmlOutputText(_('Post office box')), $postOfficeBoxField
new htmlOutputText($this->getSelfServiceLabel('postOfficeBox', _('Post office box'))), $postOfficeBoxField
));
}
if (in_array('roomNumber', $fields)) {
@ -2560,7 +2560,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$roomNumberField = new htmlOutputText($roomNumber);
}
$return['roomNumber'] = new htmlTableRow(array(
new htmlOutputText(_('Room number')), $roomNumberField
new htmlOutputText($this->getSelfServiceLabel('roomNumber', _('Room number'))), $roomNumberField
));
}
if (in_array('location', $fields)) {
@ -2571,7 +2571,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$lField = new htmlOutputText($l);
}
$return['location'] = new htmlTableRow(array(
new htmlOutputText(_('Location')), $lField
new htmlOutputText($this->getSelfServiceLabel('location', _('Location'))), $lField
));
}
if (in_array('state', $fields)) {
@ -2582,7 +2582,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$stField = new htmlOutputText($st);
}
$return['state'] = new htmlTableRow(array(
new htmlOutputText(_('State')), $stField
new htmlOutputText($this->getSelfServiceLabel('state', _('State'))), $stField
));
}
if (in_array('carLicense', $fields)) {
@ -2593,7 +2593,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$carLicenseField = new htmlOutputText($carLicense);
}
$return['carLicense'] = new htmlTableRow(array(
new htmlOutputText(_('Car license')), $carLicenseField
new htmlOutputText($this->getSelfServiceLabel('carLicense', _('Car license'))), $carLicenseField
));
}
if (in_array('officeName', $fields)) {
@ -2604,7 +2604,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$physicalDeliveryOfficeNameField = new htmlOutputText($physicalDeliveryOfficeName);
}
$return['officeName'] = new htmlTableRow(array(
new htmlOutputText(_('Office name')), $physicalDeliveryOfficeNameField
new htmlOutputText($this->getSelfServiceLabel('officeName', _('Office name'))), $physicalDeliveryOfficeNameField
));
}
if (in_array('businessCategory', $fields)) {
@ -2615,7 +2615,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$businessCategoryField = new htmlOutputText($businessCategory);
}
$return['businessCategory'] = new htmlTableRow(array(
new htmlOutputText(_('Business category')), $businessCategoryField
new htmlOutputText($this->getSelfServiceLabel('businessCategory', _('Business category'))), $businessCategoryField
));
}
if (in_array('jpegPhoto', $fields)) {
@ -2633,14 +2633,14 @@ class inetOrgPerson extends baseModule implements passwordService {
$photoSubSub->addElement(new htmlInputFileUpload('replacePhotoFile'));
$photoSub->addElement($photoSubSub);
}
$photoRowCells = array(new htmlOutputText(_('Photo')), $photoSub);
$photoRowCells = array(new htmlOutputText($this->getSelfServiceLabel('jpegPhoto', _('Photo'))), $photoSub);
$photoRow = new htmlTableRow($photoRowCells);
$return['jpegPhoto'] = $photoRow;
}
elseif (!in_array('jpegPhoto', $readOnlyFields)) {
$photoSub = new htmlTable();
$photoSub->addElement(new htmlTableExtendedInputFileUpload('photoFile', _('Add photo')));
$photoRowCells = array(new htmlOutputText(_('Photo')), $photoSub);
$photoRowCells = array(new htmlOutputText($this->getSelfServiceLabel('jpegPhoto', _('Photo'))), $photoSub);
$photoRow = new htmlTableRow($photoRowCells);
$return['jpegPhoto'] = $photoRow;
}
@ -2653,7 +2653,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$departmentNumberField = new htmlOutputText($departmentNumber);
}
$return['departmentNumber'] = new htmlTableRow(array(
new htmlOutputText(_('Department')), $departmentNumberField
new htmlOutputText($this->getSelfServiceLabel('departmentNumber', _('Department'))), $departmentNumberField
));
}
if (in_array('initials', $fields)) {
@ -2664,7 +2664,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$initialsField = new htmlOutputText($initials);
}
$return['initials'] = new htmlTableRow(array(
new htmlOutputText(_('Initials')), $initialsField
new htmlOutputText($this->getSelfServiceLabel('initials', _('Initials'))), $initialsField
));
}
if (in_array('title', $fields)) {
@ -2675,7 +2675,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$titleField = new htmlOutputText($title);
}
$return['title'] = new htmlTableRow(array(
new htmlOutputText(_('Job title')), $titleField
new htmlOutputText($this->getSelfServiceLabel('title', _('Job title'))), $titleField
));
}
if (in_array('userCertificate', $fields)) {
@ -2702,7 +2702,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$uploadStatus->setCSSClasses(array('qq-upload-list'));
$uploadStatus->colspan = 7;
$certTable->addElement($uploadStatus, true);
$certLabel = new htmlOutputText(_('User certificates'));
$certLabel = new htmlOutputText($this->getSelfServiceLabel('userCertificate', _('User certificates')));
$certLabel->alignment = htmlElement::ALIGN_TOP;
$userCertificatesCells = array($certLabel, $certTable);
$userCertificatesRow = new htmlTableRow($userCertificatesCells);

View File

@ -764,7 +764,7 @@ class kolabUser extends baseModule {
$delegateContainer->addElement(new htmlSelect('new_delegate_value', $delegates));
$delegateContainer->addElement(new htmlTableExtendedInputCheckbox('new_delegate', false, _("Add"), null, false), true);
}
$delegateLabel = new htmlOutputText(_('Delegates'));
$delegateLabel = new htmlOutputText($this->getSelfServiceLabel('kolabDelegate', _('Delegates')));
$delegateLabel->alignment = htmlElement::ALIGN_TOP;
$return['kolabDelegate'] = new htmlTableRow(array(
$delegateLabel, $delegateContainer
@ -812,7 +812,7 @@ class kolabUser extends baseModule {
$invitationContainer->addElement(new htmlSelect('invPol2', array_values($this->invitationPolicies)));
$invitationContainer->addElement(new htmlTableExtendedInputCheckbox('addInvPol', false, _("Add"), null, false), true);
}
$invitationLabel = new htmlOutputText(_('Invitation policy'));
$invitationLabel = new htmlOutputText($this->getSelfServiceLabel('kolabInvitationPolicy', _('Invitation policy')));
$invitationLabel->alignment = htmlElement::ALIGN_TOP;
$return['kolabInvitationPolicy'] = new htmlTableRow(array(
$invitationLabel, $invitationContainer

View File

@ -227,7 +227,7 @@ class ldapPublicKey extends baseModule {
$uploadStatus->setCSSClasses(array('qq-upload-list'));
$uploadStatus->colspan = 7;
$keyTable->addElement($uploadStatus, true);
$keyLabel = new htmlOutputText(_('SSH public keys'));
$keyLabel = new htmlOutputText($this->getSelfServiceLabel('sshPublicKey', _('SSH public keys')));
$keyLabel->alignment = htmlElement::ALIGN_TOP;
$keyCells = array($keyLabel, $keyTable);
$keyRow = new htmlTableRow($keyCells);

View File

@ -2432,7 +2432,7 @@ class posixAccount extends baseModule implements passwordService {
if (in_array('password', $fields)) {
$pwdTable = new htmlTable();
$pwdTable->colspan = 3;
$pwd1 = new htmlTableExtendedInputField(_('New password'), 'posixAccount_password');
$pwd1 = new htmlTableExtendedInputField($this->getSelfServiceLabel('password', _('New password')), 'posixAccount_password');
$pwd1->setIsPassword(true);
$pwdTable->addElement($pwd1, true);
$pwd2 = new htmlTableExtendedInputField(_('Reenter password'), 'posixAccount_password2');
@ -2453,7 +2453,7 @@ class posixAccount extends baseModule implements passwordService {
$cnField = new htmlOutputText($cn);
}
$return['cn'] = new htmlTableRow(array(
new htmlOutputText(_('Common name')), $cnField
new htmlOutputText($this->getSelfServiceLabel('cn', _('Common name'))), $cnField
));
}
if (in_array('loginShell', $fields)) {
@ -2465,7 +2465,7 @@ class posixAccount extends baseModule implements passwordService {
$loginShellField = new htmlOutputText($loginShell);
}
$return['loginShell'] = new htmlTableRow(array(
new htmlOutputText(_('Login shell')), $loginShellField
new htmlOutputText($this->getSelfServiceLabel('loginShell', _('Login shell'))), $loginShellField
));
}
return $return;

View File

@ -945,14 +945,14 @@ class pykotaUser extends baseModule {
$pykotaBalance = '';
if (isset($attributes['pykotaBalance'][0])) $pykotaBalance = $attributes['pykotaBalance'][0];
$return['pykotaBalance'] = new htmlTableRow(array(
new htmlOutputText(_('Balance')), new htmlOutputText($pykotaBalance)
new htmlOutputText($this->getSelfServiceLabel('pykotaBalance', _('Balance'))), new htmlOutputText($pykotaBalance)
));
}
if (in_array('pykotaLifeTimePaid', $fields)) {
$pykotaLifeTimePaid = '';
if (isset($attributes['pykotaLifeTimePaid'][0])) $pykotaLifeTimePaid = $attributes['pykotaLifeTimePaid'][0];
$return['pykotaLifeTimePaid'] = new htmlTableRow(array(
new htmlOutputText(_('Total paid')), new htmlOutputText($pykotaLifeTimePaid)
new htmlOutputText($this->getSelfServiceLabel('pykotaLifeTimePaid', _('Total paid'))), new htmlOutputText($pykotaLifeTimePaid)
));
}
// payment history
@ -981,7 +981,7 @@ class pykotaUser extends baseModule {
$pykotaPayments->addNewLine();
}
}
$pykotaPaymentsLabel = new htmlOutputText(_('Payment history'));
$pykotaPaymentsLabel = new htmlOutputText($this->getSelfServiceLabel('pykotaPayments', _('Payment history')));
$pykotaPaymentsLabel->alignment = htmlElement::ALIGN_TOP;
$return['pykotaPayments'] = new htmlTableRow(array(
$pykotaPaymentsLabel, $pykotaPayments
@ -1019,7 +1019,7 @@ class pykotaUser extends baseModule {
$pykotaJobs->addElement($spacer);
$pykotaJobs->addElement(new htmlOutputText($job['pykotatitle'][0]), true);
}
$pykotaJobsLabel = new htmlOutputText(_('Job history'));
$pykotaJobsLabel = new htmlOutputText($this->getSelfServiceLabel('pykotaJobHistory', _('Job history')));
$pykotaJobsLabel->alignment = htmlElement::ALIGN_TOP;
$return['pykotaJobHistory'] = new htmlTableRow(array(
$pykotaJobsLabel, $pykotaJobs

View File

@ -243,6 +243,8 @@ class sambaSamAccount extends baseModule implements passwordService {
'password' => _('Password'),
'sambaPwdLastSet' => _('Last password change (read-only)'),
);
// self service: fields that cannot be relabeled
$return['selfServiceNoRelabelFields'] = array('syncNTPassword', 'syncLMPassword', 'syncSambaPwdLastSet');
// help Entries
$return['help'] = array (
"displayName" => array(
@ -2303,7 +2305,7 @@ class sambaSamAccount extends baseModule implements passwordService {
if (in_array('password', $fields)) {
$pwdTable = new htmlTable();
$pwdTable->colspan = 3;
$pwd1 = new htmlTableExtendedInputField(_('New password'), 'sambaSamAccount_password');
$pwd1 = new htmlTableExtendedInputField($this->getSelfServiceLabel('password', _('New password')), 'sambaSamAccount_password');
$pwd1->setIsPassword(true);
$pwdTable->addElement($pwd1, true);
$pwd2 = new htmlTableExtendedInputField(_('Reenter password'), 'sambaSamAccount_password2');
@ -2319,7 +2321,7 @@ class sambaSamAccount extends baseModule implements passwordService {
$sambaPwdLastSet = date('d.m.Y H:i', $attributes['sambaPwdLastSet'][0]);
}
$return['sambaPwdLastSet'] = new htmlTableRow(array(
new htmlOutputText(_('Last password change')), new htmlOutputText($sambaPwdLastSet)
new htmlOutputText($this->getSelfServiceLabel('sambaPwdLastSet', _('Last password change'))), new htmlOutputText($sambaPwdLastSet)
));
}
return $return;

View File

@ -690,7 +690,7 @@ class shadowAccount extends baseModule implements passwordService {
$shadowLastChange = $date['mday'] . "." . $date['mon'] . "." . $date['year'];
}
$return['shadowLastChange'] = new htmlTableRow(array(
new htmlOutputText(_('Last password change')), new htmlOutputText($shadowLastChange)
new htmlOutputText($this->getSelfServiceLabel('shadowLastChange', _('Last password change'))), new htmlOutputText($shadowLastChange)
));
}
return $return;

View File

@ -1559,7 +1559,7 @@ class windowsUser extends baseModule implements passwordService {
if (in_array('unicodePwd', $fields)) {
$pwdTable = new htmlTable();
$pwdTable->colspan = 3;
$pwd1 = new htmlTableExtendedInputField(_('New password'), 'windowsUser_unicodePwd');
$pwd1 = new htmlTableExtendedInputField($this->getSelfServiceLabel('unicodePwd', _('New password')), 'windowsUser_unicodePwd');
$pwd1->setIsPassword(true);
$pwdTable->addElement($pwd1, true);
$pwd2 = new htmlTableExtendedInputField(_('Reenter password'), 'windowsUser_unicodePwd2');

View File

@ -352,6 +352,9 @@ class selfServiceProfile {
*/
public $readOnlyFields;
/** List of override values for field labels: array(<field ID> => label) */
public $relabelFields;
/** configuration settings of modules */
public $moduleSettings;
@ -386,6 +389,7 @@ class selfServiceProfile {
'fields' => array('posixAccount_password'))
);
$this->readOnlyFields = array();
$this->relabelFields = array();
}
}