mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-06 03:49:56 +02:00
move render code to modules
This commit is contained in:
parent
876ae6c409
commit
76935df161
4 changed files with 57 additions and 25 deletions
|
@ -1595,7 +1595,7 @@ class moduleCache {
|
|||
* @return int random number
|
||||
*/
|
||||
function getRandomNumber() {
|
||||
return abs(hexdec(bin2hex(openssl_random_pseudo_bytes(5))));
|
||||
return abs(hexdec(bin2hex(openssl_random_pseudo_bytes(6))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4628,6 +4628,34 @@ class inetOrgPerson extends baseModule implements passwordService,AccountStatusP
|
|||
return $group;
|
||||
};
|
||||
}
|
||||
elseif ($attributeName === 'jpegphoto') {
|
||||
return function(array $entry, string $attribute): ?htmlElement {
|
||||
if (isset($entry[$attribute][0]) && ($entry[$attribute][0] !== '')) {
|
||||
if (strlen($entry[$attribute][0]) < 100) {
|
||||
// looks like we have read broken binary data, reread photo
|
||||
$result = @ldap_read($_SESSION['ldap']->server(), $entry['dn'], $attribute . "=*", array($attribute), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||
if ($result) {
|
||||
$tempEntry = @ldap_first_entry($_SESSION['ldap']->server(), $result);
|
||||
if ($tempEntry) {
|
||||
$binData = ldap_get_values_len($_SESSION['ldap']->server(), $tempEntry, $attribute);
|
||||
$entry[$attribute] = $binData;
|
||||
}
|
||||
}
|
||||
}
|
||||
$imgNumber = getRandomNumber();
|
||||
$jpeg_filename = 'jpg' . $imgNumber . '.jpg';
|
||||
$outjpeg = @fopen(dirname(__FILE__) . '/../../tmp/' . $jpeg_filename, "wb");
|
||||
fwrite($outjpeg, $entry[$attribute][0]);
|
||||
fclose ($outjpeg);
|
||||
$photoFile = '../../tmp/' . $jpeg_filename;
|
||||
$image = new htmlImage($photoFile);
|
||||
$image->enableLightbox();
|
||||
$image->setCSSClasses(array('thumbnail'));
|
||||
return $image;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -4536,6 +4536,34 @@ class windowsUser extends baseModule implements passwordService,AccountStatusPro
|
|||
return $group;
|
||||
};
|
||||
}
|
||||
elseif ($attributeName === 'jpegphoto') {
|
||||
return function(array $entry, string $attribute): ?htmlElement {
|
||||
if (isset($entry[$attribute][0]) && ($entry[$attribute][0] !== '')) {
|
||||
if (strlen($entry[$attribute][0]) < 100) {
|
||||
// looks like we have read broken binary data, reread photo
|
||||
$result = @ldap_read($_SESSION['ldap']->server(), $entry['dn'], $attribute . "=*", array($attribute), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||
if ($result) {
|
||||
$tempEntry = @ldap_first_entry($_SESSION['ldap']->server(), $result);
|
||||
if ($tempEntry) {
|
||||
$binData = ldap_get_values_len($_SESSION['ldap']->server(), $tempEntry, $attribute);
|
||||
$entry[$attribute] = $binData;
|
||||
}
|
||||
}
|
||||
}
|
||||
$imgNumber = getRandomNumber();
|
||||
$jpeg_filename = 'jpg' . $imgNumber . '.jpg';
|
||||
$outjpeg = @fopen(dirname(__FILE__) . '/../../tmp/' . $jpeg_filename, "wb");
|
||||
fwrite($outjpeg, $entry[$attribute][0]);
|
||||
fclose ($outjpeg);
|
||||
$photoFile = '../../tmp/' . $jpeg_filename;
|
||||
$image = new htmlImage($photoFile);
|
||||
$image->enableLightbox();
|
||||
$image->setCSSClasses(array('thumbnail'));
|
||||
return $image;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -506,30 +506,6 @@ class lamUserList extends lamList {
|
|||
return parent::getTableCellContent($entry, $attribute);
|
||||
}
|
||||
}
|
||||
// show user photos
|
||||
elseif (($attribute == "jpegphoto") && (!empty($entry[$attribute][0]))) {
|
||||
if (strlen($entry[$attribute][0]) < 100) {
|
||||
// looks like we have read broken binary data, reread photo
|
||||
$result = @ldap_read($_SESSION['ldap']->server(), $entry['dn'], $attribute . "=*", array($attribute), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||
if ($result) {
|
||||
$tempEntry = @ldap_first_entry($_SESSION['ldap']->server(), $result);
|
||||
if ($tempEntry) {
|
||||
$binData = ldap_get_values_len($_SESSION['ldap']->server(), $tempEntry, $attribute);
|
||||
$entry[$attribute] = $binData;
|
||||
}
|
||||
}
|
||||
}
|
||||
$imgNumber = getRandomNumber();
|
||||
$jpeg_filename = 'jpg' . $imgNumber . '.jpg';
|
||||
$outjpeg = @fopen(dirname(__FILE__) . '/../../tmp/' . $jpeg_filename, "wb");
|
||||
fwrite($outjpeg, $entry[$attribute][0]);
|
||||
fclose ($outjpeg);
|
||||
$photoFile = '../../tmp/' . $jpeg_filename;
|
||||
$image = new htmlImage($photoFile);
|
||||
$image->enableLightbox();
|
||||
$image->setCSSClasses(array('thumbnail'));
|
||||
return $image;
|
||||
}
|
||||
// account status
|
||||
elseif ($attribute == self::ATTR_ACCOUNT_STATUS) {
|
||||
return $this->getAccountStatus($entry);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue