Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberroland committed Jan 2, 2024
1 parent 1454e92 commit 2244144
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lam/lib/imageutils.inc
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class ImageManipulatorGd implements ImageManipulator {
* Destructor
*/
public function __destruct() {
if ($this->image != null) {
if (($this->image !== null) && ($this->image !== false)) {
imagedestroy($this->image);
}
}
Expand Down
36 changes: 22 additions & 14 deletions lam/lib/modules/inetOrgPerson.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2942,18 +2942,19 @@ class inetOrgPerson extends baseModule implements passwordService,AccountStatusP
}
$content = '
function inetOrgPersonUploadPhoto() {
var params = { action: \'ajaxPhotoUpload\' };
params["' . getSecurityTokenName() . '"] = "' . getSecurityTokenValue() . '";
let params = new FormData();
params.append("action", "ajaxPhotoUpload");
params.append("' . getSecurityTokenName() . '", "' . getSecurityTokenValue() . '");
let reader = new FileReader();
reader.onload = function () {
const content = reader.result;
params["file"] = btoa(content);
jQuery.ajax({
url: \'../misc/ajax.php?selfservice=1&module=inetOrgPerson&scope=user\',
method: \'POST\',
data: params
params.append("file", btoa(content));
fetch("../misc/ajax.php?selfservice=1&module=inetOrgPerson&scope=user", {
method: "POST",
body: params
})
.done(function(data) {
.then(async response => {
const data = await response.json();
if (data.success) {
if (data.html) {
jQuery(\'#inetOrgPersonPhotoUploadContent\').html(data.html);
Expand All @@ -2977,15 +2978,22 @@ class inetOrgPerson extends baseModule implements passwordService,AccountStatusP
"action": "deletePhoto",
"id": id
};
var data = {jsonInput: actionJSON};
data["' . getSecurityTokenName() . '"] = "' . getSecurityTokenValue() . '";
jQuery.post(\'../misc/ajax.php?selfservice=1&module=inetOrgPerson&scope=user\',
data, function(data) {inetOrgPersonDeletePhotoHandleReply(data);}, \'json\');
let data = new FormData();
data.append("jsonInput", JSON.stringify(actionJSON));
data.append("' . getSecurityTokenName() . '", "' . getSecurityTokenValue() . '");
fetch("../misc/ajax.php?selfservice=1&module=inetOrgPerson&scope=user", {
method: "POST",
body: data
})
.then(async response => {
const data = await response.json();
inetOrgPersonDeletePhotoHandleReply(data);
});
}
function inetOrgPersonDeletePhotoHandleReply(data) {
if (data.errorsOccurred == "false") {
jQuery(\'#inetOrgPersonPhotoUploadContent\').html(data.html);
document.getElementById(\'inetOrgPersonPhotoUploadContent\').innerHTML = data.html;
window.lam.tools.webcam.init();
}
else {
Expand Down Expand Up @@ -3344,7 +3352,7 @@ class inetOrgPerson extends baseModule implements passwordService,AccountStatusP
$this->ajaxUploadPhoto();
return;
}
$jsonInput = $_POST['jsonInput'];
$jsonInput = json_decode($_POST['jsonInput'], true);
$jsonReturn = self::invalidAjaxRequest();
if (isset($jsonInput['action'])) {
if ($jsonInput['action'] == 'deleteCert') {
Expand Down
3 changes: 1 addition & 2 deletions lam/templates/lib/500_lam.js
Original file line number Diff line number Diff line change
Expand Up @@ -1393,10 +1393,9 @@ window.lam.tools.webcam.uploadSelfService = function(event, tokenName, tokenValu
const jsonData = await response.json();
if (jsonData.success) {
if (jsonData.html) {
document.getElementById(contentId).innerHTML = jsonData.html;
jQuery('#' + contentId).html(jsonData.html);
window.lam.tools.webcam.init();
}
return false;
}
else if (jsonData.error) {
msg.querySelector('.statusTitle').innerText = jsonData.error;
Expand Down

0 comments on commit 2244144

Please sign in to comment.