allow uploading of images

This commit is contained in:
Roland Gruber 2007-02-18 18:37:15 +00:00
parent 1e05c1ae9c
commit ea4152cdbf
2 changed files with 56 additions and 1 deletions

View File

@ -1,5 +1,7 @@
??? 1.3.0 ??? 1.3.0
- improved design - improved design
- user list can now display jpegPhoto attributes
- LAM Pro: users may change their photos (jpegPhoto)
- fixed bugs: - fixed bugs:
-> ShadowAccount: PDF entry for expire date was wrong (1658868) -> ShadowAccount: PDF entry for expire date was wrong (1658868)
-> Debian package did not include lamdaemonOld.pl (1660493) -> Debian package did not include lamdaemonOld.pl (1660493)

View File

@ -113,7 +113,7 @@ class inetOrgPerson extends baseModule {
$return['selfServiceFieldSettings'] = array('firstName' => _('First name'), 'lastName' => _('Last name'), $return['selfServiceFieldSettings'] = array('firstName' => _('First name'), 'lastName' => _('Last name'),
'mail' => _('eMail address'), 'telephoneNumber' => _('Telephone number'), 'mobile' => _('Mobile number'), 'mail' => _('eMail address'), 'telephoneNumber' => _('Telephone number'), 'mobile' => _('Mobile number'),
'faxNumber' => _('Fax number'), 'street' => _('Street'), 'postalAddress' => _('Postal address'), 'faxNumber' => _('Fax number'), 'street' => _('Street'), 'postalAddress' => _('Postal address'),
'postalCode' => _('Postal code'), 'postOfficeBox' => _('Post office box')); 'postalCode' => _('Postal code'), 'postOfficeBox' => _('Post office box'), 'jpegPhoto' => _('Photo'));
// profile elements // profile elements
$return['profile_options'] = array( $return['profile_options'] = array(
array( array(
@ -1133,6 +1133,39 @@ class inetOrgPerson extends baseModule {
1 => array('kind' => 'input', 'name' => 'inetOrgPerson_postOfficeBox', 'type' => 'text', 'size' => '30', 1 => array('kind' => 'input', 'name' => 'inetOrgPerson_postOfficeBox', 'type' => 'text', 'size' => '30',
'maxlength' => '255', 'value' => $postOfficeBox)); 'maxlength' => '255', 'value' => $postOfficeBox));
} }
if (in_array('jpegPhoto', $fields)) {
if (isset($attributes['jpegPhoto'][0])) {
$jpeg_filename = 'jpegPhoto' . session_id() . '.jpg';
$outjpeg = fopen(realpath('../../') . '/tmp/' . $jpeg_filename, "wb");
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')
))),
)
))
);
}
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')
)))
);
}
}
return $return; return $return;
} }
@ -1239,6 +1272,26 @@ class inetOrgPerson extends baseModule {
} }
elseif (isset($attributes['postOfficeBox'])) unset($attributesNew['postOfficeBox']); elseif (isset($attributes['postOfficeBox'])) unset($attributesNew['postOfficeBox']);
} }
// photo
if (in_array('jpegPhoto', $fields)) {
if ($_FILES['photoFile'] && ($_FILES['photoFile']['size'] > 0)) {
$handle = fopen($_FILES['photoFile']['tmp_name'], "r");
$data = fread($handle, 1000000);
fclose($handle);
$return['add']['jpegPhoto'][0] = $data;
}
if ($_POST['removeReplacePhoto'] == 'on') {
if ($_FILES['replacePhotoFile'] && ($_FILES['replacePhotoFile']['size'] > 0)) {
$handle = fopen($_FILES['replacePhotoFile']['tmp_name'], "r");
$data = fread($handle, 1000000);
fclose($handle);
$return['mod']['jpegPhoto'][0] = $data;
}
else {
$return['mod']['jpegPhoto'] = array();
}
}
}
// find differences // find differences
for ($i = 0; $i < sizeof($attributeNames); $i++) { for ($i = 0; $i < sizeof($attributeNames); $i++) {
$attrName = $attributeNames[$i]; $attrName = $attributeNames[$i];