diff --git a/lam/lib/imageutils.inc b/lam/lib/imageutils.inc index 888fc0f1c..9f75ee082 100644 --- a/lam/lib/imageutils.inc +++ b/lam/lib/imageutils.inc @@ -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); } } diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index b9336adad..eed0412c4 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -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); @@ -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 { @@ -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') { diff --git a/lam/templates/lib/500_lam.js b/lam/templates/lib/500_lam.js index 179c6875a..752abc3a4 100644 --- a/lam/templates/lib/500_lam.js +++ b/lam/templates/lib/500_lam.js @@ -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;