added photo options
This commit is contained in:
parent
a6cc0d8a3e
commit
9edfe22754
|
@ -96,6 +96,7 @@ class inetOrgPerson extends baseModule implements passwordService {
|
||||||
$this->messages['file'][0] = array('ERROR', _('No file selected.'));
|
$this->messages['file'][0] = array('ERROR', _('No file selected.'));
|
||||||
$this->messages['file'][1] = array('ERROR', _('Please upload a .jpg/.jpeg file.'));
|
$this->messages['file'][1] = array('ERROR', _('Please upload a .jpg/.jpeg file.'));
|
||||||
$this->messages['file'][2] = array('ERROR', _('Unable to process this file.'));
|
$this->messages['file'][2] = array('ERROR', _('Unable to process this file.'));
|
||||||
|
$this->messages['file'][3] = array('ERROR', _('File is too large. Maximum allowed size is %s kB.'));
|
||||||
$this->messages['businessCategory'][0] = array('ERROR', _('Business category'), _('Please enter a valid business category!'));
|
$this->messages['businessCategory'][0] = array('ERROR', _('Business category'), _('Please enter a valid business category!'));
|
||||||
$this->messages['businessCategory'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_businessCategory', _('Please enter a valid business category!'));
|
$this->messages['businessCategory'][1] = array('ERROR', _('Account %s:') . ' inetOrgPerson_businessCategory', _('Please enter a valid business category!'));
|
||||||
$this->messages['userPassword'][0] = array('ERROR', _('Account %s:') . ' posixAccount_password', _('Password contains invalid characters. Valid characters are:') . ' a-z, A-Z, 0-9 and #*,.;:_-+!%&/|?{[()]}=@$ §°!');
|
$this->messages['userPassword'][0] = array('ERROR', _('Account %s:') . ' posixAccount_password', _('Password contains invalid characters. Valid characters are:') . ' a-z, A-Z, 0-9 and #*,.;:_-+!%&/|?{[()]}=@$ §°!');
|
||||||
|
@ -360,6 +361,8 @@ class inetOrgPerson extends baseModule implements passwordService {
|
||||||
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideLabeledURI', false, _('Web site'), null, false));
|
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideLabeledURI', false, _('Web site'), null, false));
|
||||||
$configContainerOptions->addElement(new htmlOutputText(' '));
|
$configContainerOptions->addElement(new htmlOutputText(' '));
|
||||||
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideuserCertificate', false, _('User certificates'), null, false));
|
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hideuserCertificate', false, _('User certificates'), null, false));
|
||||||
|
$configContainerOptions->addElement(new htmlOutputText(' '));
|
||||||
|
$configContainerOptions->addElement(new htmlTableExtendedInputCheckbox('inetOrgPerson_hidejpegPhoto', false, _('Photo'), null, false));
|
||||||
if (isset($_SESSION['conf_config'])) {
|
if (isset($_SESSION['conf_config'])) {
|
||||||
$confActiveUnixUserModules = $_SESSION['conf_config']->get_AccountModules('user');
|
$confActiveUnixUserModules = $_SESSION['conf_config']->get_AccountModules('user');
|
||||||
// option to hide uid
|
// option to hide uid
|
||||||
|
@ -369,6 +372,14 @@ class inetOrgPerson extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$configContainer->addElement($configContainerOptions, true);
|
$configContainer->addElement($configContainerOptions, true);
|
||||||
|
$advancedOptions = new htmlTable();
|
||||||
|
$advancedOptions->addElement(new htmlSubTitle(_('Photo')), true);
|
||||||
|
$advancedOptions->addElement(new htmlTableExtendedInputField(_('Maximum width (px)'), 'inetOrgPerson_jpegPhoto_maxWidth'), true);
|
||||||
|
$advancedOptions->addElement(new htmlTableExtendedInputField(_('Maximum height (px)'), 'inetOrgPerson_jpegPhoto_maxHeight'), true);
|
||||||
|
$advancedOptions->addElement(new htmlTableExtendedInputField(_('Maximum file size (kB)'), 'inetOrgPerson_jpegPhoto_maxSize'), true);
|
||||||
|
$advancedOptionsAccordion = new htmlAccordion('inetOrgPersonAdvancedOptions', array(_('Advanced options') => $advancedOptions), false);
|
||||||
|
$advancedOptionsAccordion->colspan = 5;
|
||||||
|
$configContainer->addElement($advancedOptionsAccordion);
|
||||||
$return['config_options']['all'] = $configContainer;
|
$return['config_options']['all'] = $configContainer;
|
||||||
// upload fields
|
// upload fields
|
||||||
$return['upload_columns'] = array(
|
$return['upload_columns'] = array(
|
||||||
|
@ -1170,7 +1181,7 @@ class inetOrgPerson extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['delPhoto'])) {
|
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidejpegPhoto') && isset($_POST['delPhoto'])) {
|
||||||
$this->attributes['jpegPhoto'] = array();
|
$this->attributes['jpegPhoto'] = array();
|
||||||
}
|
}
|
||||||
// Return error-messages
|
// Return error-messages
|
||||||
|
@ -1187,11 +1198,7 @@ class inetOrgPerson extends baseModule implements passwordService {
|
||||||
$equalWidthElements = array();
|
$equalWidthElements = array();
|
||||||
$container = new htmlTable();
|
$container = new htmlTable();
|
||||||
$fieldContainer = new htmlTable();
|
$fieldContainer = new htmlTable();
|
||||||
$imageContainer = new htmlTable();
|
|
||||||
$imageContainer->alignment = htmlElement::ALIGN_TOP;
|
|
||||||
$container->addElement($fieldContainer);
|
$container->addElement($fieldContainer);
|
||||||
$container->addElement(new htmlSpacer('50px', null));
|
|
||||||
$container->addElement($imageContainer, false);
|
|
||||||
$modules = $_SESSION['config']->get_AccountModules($this->get_scope());
|
$modules = $_SESSION['config']->get_AccountModules($this->get_scope());
|
||||||
if (!in_array('posixAccount', $modules) && !$this->isBooleanConfigOptionSet('inetOrgPerson_hideUID')) {
|
if (!in_array('posixAccount', $modules) && !$this->isBooleanConfigOptionSet('inetOrgPerson_hideUID')) {
|
||||||
$this->addSimpleInputTextField($fieldContainer, 'uid', _('User name'));
|
$this->addSimpleInputTextField($fieldContainer, 'uid', _('User name'));
|
||||||
|
@ -1560,6 +1567,9 @@ class inetOrgPerson extends baseModule implements passwordService {
|
||||||
$fieldContainer->addElement($pwdContainer);
|
$fieldContainer->addElement($pwdContainer);
|
||||||
}
|
}
|
||||||
// photo
|
// photo
|
||||||
|
if (!$this->isBooleanConfigOptionSet('inetOrgPerson_hidejpegPhoto')) {
|
||||||
|
$imageContainer = new htmlTable();
|
||||||
|
$imageContainer->alignment = htmlElement::ALIGN_TOP;
|
||||||
$photoFile = '../../graphics/userDefault.png';
|
$photoFile = '../../graphics/userDefault.png';
|
||||||
$noPhoto = true;
|
$noPhoto = true;
|
||||||
if (isset($this->attributes['jpegPhoto'][0])) {
|
if (isset($this->attributes['jpegPhoto'][0])) {
|
||||||
|
@ -1577,6 +1587,9 @@ class inetOrgPerson extends baseModule implements passwordService {
|
||||||
else {
|
else {
|
||||||
$imageContainer->addElement(new htmlButton('delPhoto', _('Delete photo')));
|
$imageContainer->addElement(new htmlButton('delPhoto', _('Delete photo')));
|
||||||
}
|
}
|
||||||
|
$container->addElement(new htmlSpacer('50px', null));
|
||||||
|
$container->addElement($imageContainer, false);
|
||||||
|
}
|
||||||
$container->addElement(new htmlEqualWidth($equalWidthElements));
|
$container->addElement(new htmlEqualWidth($equalWidthElements));
|
||||||
return $container;
|
return $container;
|
||||||
}
|
}
|
||||||
|
@ -1598,12 +1611,24 @@ class inetOrgPerson extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
$handle = fopen($_FILES['photoFile']['tmp_name'], "r");
|
$handle = fopen($_FILES['photoFile']['tmp_name'], "r");
|
||||||
$data = fread($handle, 10000000);
|
$data = fread($handle, 10000000);
|
||||||
|
if (!empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]) && (strlen($data) > (1024 * $this->moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]))) {
|
||||||
|
$errMsg = $this->messages['file'][3];
|
||||||
|
$errMsg[] = null;
|
||||||
|
$errMsg[] = array($this->moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]);
|
||||||
|
return array($errMsg);
|
||||||
|
}
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
if (extension_loaded('imagick')) {
|
if (extension_loaded('imagick')) {
|
||||||
// convert to JPG if imagick extension is available
|
// convert to JPG if imagick extension is available
|
||||||
$image = new Imagick();
|
$image = new Imagick();
|
||||||
try {
|
try {
|
||||||
$image->readImageBlob($data);
|
$image->readImageBlob($data);
|
||||||
|
// resize if maximum values specified
|
||||||
|
if (!empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0]) || !empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0])) {
|
||||||
|
$maxWidth = empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0]) ? $image->getimagewidth() : $this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0];
|
||||||
|
$maxHeight = empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0]) ? $image->getimageheight() : $this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0];
|
||||||
|
$image->thumbnailimage($maxWidth, $maxHeight, true);
|
||||||
|
}
|
||||||
$image->setImageCompression(Imagick::COMPRESSION_JPEG);
|
$image->setImageCompression(Imagick::COMPRESSION_JPEG);
|
||||||
$image->setImageFormat('jpeg');
|
$image->setImageFormat('jpeg');
|
||||||
$data = $image->getimageblob();
|
$data = $image->getimageblob();
|
||||||
|
|
Loading…
Reference in New Issue