diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index 2d866053..ff0b73c8 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -1380,130 +1380,114 @@ class inetOrgPerson extends baseModule implements passwordService { if (in_array('lastName', $fields)) { $lastName = ''; if (isset($attributes['sn'][0])) $lastName = $attributes['sn'][0]; - $return['lastName'] = array( - array('kind' => 'text', 'text' => _('Last name')), - array('kind' => 'input', 'name' => 'inetOrgPerson_lastName', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $lastName)); + $return['lastName'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Last name'), 'inetOrgPerson_lastName', $lastName) + )); } if (in_array('mail', $fields)) { $mail = ''; if (isset($attributes['mail'][0])) $mail = $attributes['mail'][0]; - $return['mail'] = array( - array('kind' => 'text', 'text' => _('Email address')), - array('kind' => 'input', 'name' => 'inetOrgPerson_mail', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $mail)); + $return['mail'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Email address'), 'inetOrgPerson_mail', $mail) + )); } if (in_array('telephoneNumber', $fields)) { $telephoneNumber = ''; if (isset($attributes['telephoneNumber'][0])) $telephoneNumber = $attributes['telephoneNumber'][0]; - $return['telephoneNumber'] = array( - array('kind' => 'text', 'text' => _('Telephone number')), - array('kind' => 'input', 'name' => 'inetOrgPerson_telephoneNumber', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $telephoneNumber)); + $return['telephoneNumber'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Telephone number'), 'inetOrgPerson_telephoneNumber', $telephoneNumber) + )); } if (in_array('homePhone', $fields)) { $homePhone = ''; if (isset($attributes['homePhone'][0])) $homePhone = $attributes['homePhone'][0]; - $return['homePhone'] = array( - array('kind' => 'text', 'text' => _('Home telephone number')), - array('kind' => 'input', 'name' => 'inetOrgPerson_homePhone', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $homePhone)); + $return['homePhone'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Home telephone number'), 'inetOrgPerson_homePhone', $homePhone) + )); } if (in_array('mobile', $fields)) { $mobile = ''; if (isset($attributes['mobile'][0])) $mobile = $attributes['mobile'][0]; - $return['mobile'] = array( - array('kind' => 'text', 'text' => _('Mobile telephone number')), - array('kind' => 'input', 'name' => 'inetOrgPerson_mobile', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $mobile)); + $return['mobile'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Mobile telephone number'), 'inetOrgPerson_mobile', $mobile) + )); } if (in_array('faxNumber', $fields)) { $faxNumber = ''; if (isset($attributes['facsimileTelephoneNumber'][0])) $faxNumber = $attributes['facsimileTelephoneNumber'][0]; - $return['faxNumber'] = array( - array('kind' => 'text', 'text' => _('Fax number')), - array('kind' => 'input', 'name' => 'inetOrgPerson_faxNumber', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $faxNumber)); + $return['faxNumber'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Fax number'), 'inetOrgPerson_faxNumber', $faxNumber) + )); } if (in_array('street', $fields)) { $street = ''; if (isset($attributes['street'][0])) $street = $attributes['street'][0]; - $return['street'] = array( - array('kind' => 'text', 'text' => _('Street')), - array('kind' => 'input', 'name' => 'inetOrgPerson_street', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $street)); + $return['street'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Street'), 'inetOrgPerson_street', $street) + )); } if (in_array('postalAddress', $fields)) { $postalAddress = ''; if (isset($attributes['postalAddress'][0])) $postalAddress = $attributes['postalAddress'][0]; - $return['postalAddress'] = array( - array('kind' => 'text', 'text' => _('Postal address')), - array('kind' => 'input', 'name' => 'inetOrgPerson_postalAddress', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $postalAddress)); + $return['postalAddress'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Postal address'), 'inetOrgPerson_postalAddress', $postalAddress) + )); } if (in_array('postalCode', $fields)) { $postalCode = ''; if (isset($attributes['postalCode'][0])) $postalCode = $attributes['postalCode'][0]; - $return['postalCode'] = array( - array('kind' => 'text', 'text' => _('Postal code')), - array('kind' => 'input', 'name' => 'inetOrgPerson_postalCode', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $postalCode)); + $return['postalCode'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Postal code'), 'inetOrgPerson_postalCode', $postalCode) + )); } if (in_array('postOfficeBox', $fields)) { $postOfficeBox = ''; if (isset($attributes['postOfficeBox'][0])) $postOfficeBox = $attributes['postOfficeBox'][0]; - $return['postOfficeBox'] = array( - array('kind' => 'text', 'text' => _('Post office box')), - array('kind' => 'input', 'name' => 'inetOrgPerson_postOfficeBox', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $postOfficeBox)); + $return['postOfficeBox'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Post office box'), 'inetOrgPerson_postOfficeBox', $postOfficeBox) + )); } if (in_array('roomNumber', $fields)) { $roomNumber = ''; if (isset($attributes['roomNumber'][0])) $roomNumber = $attributes['roomNumber'][0]; - $return['roomNumber'] = array( - array('kind' => 'text', 'text' => _('Room number')), - array('kind' => 'input', 'name' => 'inetOrgPerson_roomNumber', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $roomNumber)); + $return['roomNumber'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Room number'), 'inetOrgPerson_roomNumber', $roomNumber) + )); } if (in_array('location', $fields)) { $l = ''; if (isset($attributes['l'][0])) $l = $attributes['l'][0]; - $return['location'] = array( - array('kind' => 'text', 'text' => _('Location')), - array('kind' => 'input', 'name' => 'inetOrgPerson_location', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $l)); + $return['location'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Location'), 'inetOrgPerson_location', $l) + )); } if (in_array('state', $fields)) { $st = ''; if (isset($attributes['st'][0])) $st = $attributes['st'][0]; - $return['state'] = array( - array('kind' => 'text', 'text' => _('State')), - array('kind' => 'input', 'name' => 'inetOrgPerson_state', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $st)); + $return['state'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('State'), 'inetOrgPerson_state', $st) + )); } if (in_array('carLicense', $fields)) { $carLicense = ''; if (isset($attributes['carLicense'][0])) $carLicense = $attributes['carLicense'][0]; - $return['carLicense'] = array( - array('kind' => 'text', 'text' => _('Car license')), - array('kind' => 'input', 'name' => 'inetOrgPerson_carLicense', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $carLicense)); + $return['carLicense'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Car license'), 'inetOrgPerson_carLicense', $carLicense) + )); } if (in_array('officeName', $fields)) { $physicalDeliveryOfficeName = ''; if (isset($attributes['physicalDeliveryOfficeName'][0])) $physicalDeliveryOfficeName = $attributes['physicalDeliveryOfficeName'][0]; - $return['officeName'] = array( - array('kind' => 'text', 'text' => _('Office name')), - array('kind' => 'input', 'name' => 'inetOrgPerson_officeName', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $physicalDeliveryOfficeName)); + $return['officeName'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Office name'), 'inetOrgPerson_officeName', $physicalDeliveryOfficeName) + )); } if (in_array('businessCategory', $fields)) { $businessCategory = ''; if (isset($attributes['businessCategory'][0])) $businessCategory = $attributes['businessCategory'][0]; - $return['businessCategory'] = array( - array('kind' => 'text', 'text' => _('Business category')), - array('kind' => 'input', 'name' => 'inetOrgPerson_businessCategory', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $businessCategory)); + $return['businessCategory'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Business category'), 'inetOrgPerson_businessCategory', $businessCategory) + )); } if (in_array('jpegPhoto', $fields)) { if (isset($attributes['jpegPhoto'][0])) { @@ -1512,39 +1496,30 @@ class inetOrgPerson extends baseModule implements passwordService { fwrite($outjpeg, $attributes['jpegPhoto'][0]); fclose ($outjpeg); $photoFile = '../../tmp/' . $jpeg_filename; - $return['jpegPhoto'] = array( - array('kind' => 'text', 'text' => _('Photo')), - array('kind' => 'table', 'value' => array( - array( - array('kind' => 'image', 'alt' => _('Photo'), 'path' => $photoFile) - ), - array( - array('kind' => 'table', 'value' => array(array( - array('kind' => 'input', 'type' => 'checkbox', 'name' => 'removeReplacePhoto'), - array('kind' => 'text', 'text' => _('Remove/replace photo')), - array('kind' => 'input', 'name' => 'replacePhotoFile', 'type' => 'file') - ))), - ) - )) - ); + $photoSub = new htmlTable(); + $photoSub->addElement(new htmlImage($photoFile), true); + $photoSubSub = new htmlTable(); + $photoSubSub->addElement(new htmlTableExtendedInputCheckbox('removeReplacePhoto', false, _('Remove/replace photo'), null, false)); + $photoSubSub->addElement(new htmlInputFileUpload('replacePhotoFile')); + $photoSub->addElement($photoSubSub); + $photoRowCells = array(new htmlOutputText(_('Photo')), $photoSub); + $photoRow = new htmlTableRow($photoRowCells); + $return['jpegPhoto'] = $photoRow; } else { - $return['jpegPhoto'] = array( - array('kind' => 'text', 'text' => _('Photo')), - array('kind' => 'table', 'value' => array(array( - array('kind' => 'text', 'text' => _('Add photo')), - array('kind' => 'input', 'name' => 'photoFile', 'type' => 'file') - ))) - ); + $photoSub = new htmlTable(); + $photoSub->addElement(new htmlTableExtendedInputFileUpload('photoFile', _('Add photo'))); + $photoRowCells = array(new htmlOutputText(_('Photo')), $photoSub); + $photoRow = new htmlTableRow($photoRowCells); + $return['jpegPhoto'] = $photoRow; } } if (in_array('departmentNumber', $fields)) { $departmentNumber = ''; if (isset($attributes['departmentNumber'][0])) $departmentNumber = implode(';', $attributes['departmentNumber']); - $return['departmentNumber'] = array( - array('kind' => 'text', 'text' => _('Department(s)')), - array('kind' => 'input', 'name' => 'inetOrgPerson_departmentNumber', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $departmentNumber)); + $return['departmentNumber'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Department(s)'), 'inetOrgPerson_departmentNumber', $departmentNumber) + )); } return $return; } @@ -1716,7 +1691,7 @@ class inetOrgPerson extends baseModule implements passwordService { } // photo if (in_array('jpegPhoto', $fields)) { - if ($_FILES['photoFile'] && ($_FILES['photoFile']['size'] > 0)) { + if (isset($_FILES['photoFile']) && ($_FILES['photoFile']['size'] > 0)) { $handle = fopen($_FILES['photoFile']['tmp_name'], "r"); $data = fread($handle, 1000000); fclose($handle); diff --git a/lam/lib/modules/kolabUser.inc b/lam/lib/modules/kolabUser.inc index 19f0dffb..f542861a 100644 --- a/lam/lib/modules/kolabUser.inc +++ b/lam/lib/modules/kolabUser.inc @@ -284,9 +284,13 @@ class kolabUser extends baseModule { return $return; } // country + $country = ''; + if (isset($this->attributes['c'][0])) { + $country = $this->attributes['c'][0]; + } $return[] = array( array('kind' => 'text', 'text' => _('Country')), - array('kind' => 'input', 'name' => 'country', 'type' => 'text', 'value' => $this->attributes['c'][0]), + array('kind' => 'input', 'name' => 'country', 'type' => 'text', 'value' => $country), array('kind' => 'help', 'value' => 'country')); // mailbox server if (!isset($this->orig['kolabHomeServer'][0])) { // value currently not set @@ -302,14 +306,22 @@ class kolabUser extends baseModule { array('kind' => 'help', 'value' => 'homeServer')); } // Cyrus mail quota + $userquota = ''; + if (isset($this->attributes['cyrus-userquota'][0])) { + $userquota = $this->attributes['cyrus-userquota'][0]; + } $return[] = array( array('kind' => 'text', 'text' => _('Mail quota')), - array('kind' => 'input', 'name' => 'quota', 'type' => 'text', 'value' => $this->attributes['cyrus-userquota'][0]), + array('kind' => 'input', 'name' => 'quota', 'type' => 'text', 'value' => $userquota), array('kind' => 'help', 'value' => 'quota')); // free/busy future + $freebusyfuture = ''; + if (isset($this->attributes['kolabFreeBusyFuture'][0])) { + $freebusyfuture = $this->attributes['kolabFreeBusyFuture'][0]; + } $return[] = array( array('kind' => 'text', 'text' => _('Free/Busy interval')), - array('kind' => 'input', 'name' => 'freeBusy', 'type' => 'text', 'value' => $this->attributes['kolabFreeBusyFuture'][0]), + array('kind' => 'input', 'name' => 'freeBusy', 'type' => 'text', 'value' => $freebusyfuture), array('kind' => 'help', 'value' => 'freeBusy')); // invitation policies $returnPol = array(); @@ -351,11 +363,13 @@ class kolabUser extends baseModule { $return[] = $returnPol; // mail aliases $returnAliases = array(); - for ($i = 0; $i < sizeof($this->attributes['alias']); $i++) { - $returnAliases[] = array( - array('kind' => 'input', 'name' => 'alias' . $i, 'type' => 'text', 'value' => $this->attributes['alias'][$i]), - array('kind' => 'input', 'type' => 'submit', 'name' => 'delAlias' . $i, 'value' => _("Remove")), - array('kind' => 'help', 'value' => 'alias')); + if (isset($this->attributes['alias'])) { + for ($i = 0; $i < sizeof($this->attributes['alias']); $i++) { + $returnAliases[] = array( + array('kind' => 'input', 'name' => 'alias' . $i, 'type' => 'text', 'value' => $this->attributes['alias'][$i]), + array('kind' => 'input', 'type' => 'submit', 'name' => 'delAlias' . $i, 'value' => _("Remove")), + array('kind' => 'help', 'value' => 'alias')); + } } // input box for new mail alias $returnAliases[] = array( @@ -377,11 +391,13 @@ class kolabUser extends baseModule { sort($delegates); } $returnDelegates = array(); - for ($i = 0; $i < sizeof($this->attributes['kolabDelegate']); $i++) { - $returnDelegates[] = array( - array('kind' => 'select', 'name' => 'delegate' . $i, 'options' => $delegates, 'options_selected' => array($this->attributes['kolabDelegate'][$i])), - array('kind' => 'input', 'type' => 'submit', 'name' => 'delDelegate' . $i, 'value' => _("Remove")), - array('kind' => 'help', 'value' => 'delegate')); + if (isset($this->attributes['kolabDelegate'])) { + for ($i = 0; $i < sizeof($this->attributes['kolabDelegate']); $i++) { + $returnDelegates[] = array( + array('kind' => 'select', 'name' => 'delegate' . $i, 'options' => $delegates, 'options_selected' => array($this->attributes['kolabDelegate'][$i])), + array('kind' => 'input', 'type' => 'submit', 'name' => 'delDelegate' . $i, 'value' => _("Remove")), + array('kind' => 'help', 'value' => 'delegate')); + } } // input box for new delegate $returnDelegates[] = array( @@ -823,10 +839,9 @@ class kolabUser extends baseModule { if (isset($attributes['kolabFreeBusyFuture'][0])) { $kolabFreeBusyFuture = $attributes['kolabFreeBusyFuture'][0]; } - $return['kolabFreeBusyFuture'] = array( - array('kind' => 'text', 'text' => _('Free/Busy interval')), - array('kind' => 'input', 'name' => 'kolabUser_kolabFreeBusyFuture', 'type' => 'text', 'size' => '30', - 'maxlength' => '255', 'value' => $kolabFreeBusyFuture)); + $return['kolabFreeBusyFuture'] = new htmlTableRow(array( + new htmlTableExtendedInputField(_('Free/Busy interval'), 'kolabUser_kolabFreeBusyFuture', $kolabFreeBusyFuture) + )); } // delegates if (in_array('kolabDelegate', $fields)) { @@ -856,25 +871,22 @@ class kolabUser extends baseModule { sort($kolabDelegate); $_SESSION['kolabUser_kolabDelegate'] = $kolabDelegate; $delegateFields = array(); + $delegateContainer = new htmlTable(); for ($i = 0; $i < sizeof($kolabDelegate); $i++) { - $delegateFields[] = array( - array('kind' => 'text', 'text' => $kolabDelegate[$i]), - array('kind' => 'input', 'type' => 'checkbox', 'name' => 'delDelegate_' . $i), - array('kind' => 'text', 'text' => _('Delete')) - ); + $delegateContainer->addElement(new htmlTableExtendedInputCheckbox('delDelegate_' . $i, false, $kolabDelegate[$i])); + $delegateContainer->addElement(new htmlOutputText(_('Delete')), true); } - $delegateFields[] = array( - array('kind' => 'select', 'name' => 'new_delegate_value', 'options' => $delegates), - array('kind' => 'input', 'type' => 'checkbox', 'name' => 'new_delegate'), - array('kind' => 'text', 'text' => _("Add")) - ); - $return['kolabDelegate'] = array( - array('kind' => 'fieldset', 'value' => $delegateFields, 'legend' => _('Delegates'), 'td' => array('colspan' => 2)) - ); + $delegateContainer->addElement(new htmlSelect('new_delegate_value', $delegates, null)); + $delegateContainer->addElement(new htmlTableExtendedInputCheckbox('new_delegate', false, _("Add"), null, false), true); + $delegateLabel = new htmlOutputText(_('Delegates')); + $delegateLabel->alignment = htmlElement::ALIGN_TOP; + $return['kolabDelegate'] = new htmlTableRow(array( + $delegateLabel, $delegateContainer + )); } // invitation policies if (in_array('kolabInvitationPolicy', $fields)) { - $returnPol = array(); + $invitationContainer = new htmlTable(); // default invitation policy $defaultInvPol = $this->invitationPolicies['ACT_MANUAL']; for ($i = 0; $i < sizeof($attributes['kolabInvitationPolicy']); $i++) { @@ -886,19 +898,14 @@ class kolabUser extends baseModule { break; } } - $returnPol[] = array( - array('kind' => 'text', 'text' => _('Anyone')), - array('kind' => 'select', 'name' => 'defaultInvPol', 'options' => array_values($this->invitationPolicies), 'options_selected' => $defaultInvPol), - array('kind' => 'text', 'text' => '')); + $invitationContainer->addElement(new htmlTableExtendedSelect('defaultInvPol', array_values($this->invitationPolicies), array($defaultInvPol), _('Anyone')), true); // other invitation policies for ($i = 0; $i < sizeof($attributes['kolabInvitationPolicy']); $i++) { $parts = explode(":", $attributes['kolabInvitationPolicy'][$i]); if (sizeof($parts) == 2) { - $returnPol[] = array( - array('kind' => 'input', 'name' => 'invPol1' . $i, 'type' => 'text', 'value' => $parts[0]), - array('kind' => 'select', 'name' => 'invPol2' . $i, 'options' => array_values($this->invitationPolicies), 'options_selected' => $this->invitationPolicies[$parts[1]]), - array('kind' => 'input', 'type' => 'checkbox', 'name' => 'delInvPol' . $i), - array('kind' => 'text', 'text' => _("Remove"))); + $invitationContainer->addElement(new htmlInputField('invPol1' . $i, $parts[0])); + $invitationContainer->addElement(new htmlSelect('invPol2' . $i, array_values($this->invitationPolicies), array($this->invitationPolicies[$parts[1]]))); + $invitationContainer->addElement(new htmlTableExtendedInputCheckbox('delInvPol' . $i, false, _("Remove"), null, false), true); } } // input box for new invitation policy @@ -907,10 +914,11 @@ class kolabUser extends baseModule { array('kind' => 'select', 'name' => 'invPol2', 'options' => array_values($this->invitationPolicies)), array('kind' => 'input', 'type' => 'checkbox', 'name' => 'addInvPol'), array('kind' => 'text', 'text' => _("Add"))); - $returnPol = array( - array('kind' => 'fieldset', 'legend' => _('Invitation policy'), 'value' => $returnPol, 'td' => array('colspan' => 3)) - ); - $return['kolabInvitationPolicy'] = $returnPol; + $invitationLabel = new htmlOutputText(_('Invitation policy')); + $invitationLabel->alignment = htmlElement::ALIGN_TOP; + $return['kolabInvitationPolicy'] = new htmlTableRow(array( + $invitationLabel, $invitationContainer + )); } return $return; } diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 0a77ece4..5a2d37e1 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -1704,12 +1704,11 @@ class posixAccount extends baseModule implements passwordService { function getSelfServiceOptions($fields, $attributes) { $return = array(); if (in_array('password', $fields)) { - $return['password'] = array( - array('kind' => 'text', 'text' => _('New password')), - array('kind' => 'input', 'name' => 'posixAccount_password', 'type' => 'password', 'size' => '30', 'maxlength' => '255'), - array('kind' => 'text', 'text' => _('Reenter password')), - array('kind' => 'input', 'name' => 'posixAccount_password2', 'type' => 'password', 'size' => '30', 'maxlength' => '255') - ); + $pwd1 = new htmlTableExtendedInputField(_('New password'), 'posixAccount_password'); + $pwd2 = new htmlTableExtendedInputField(_('Reenter password'), 'posixAccount_password2'); + $return['password'] = new htmlTableRow(array( + $pwd1, $pwd2 + )); } return $return; }