improved logging
This commit is contained in:
@@ -1112,6 +1112,22 @@ class ConstructionConsentController extends mfBaseController {
|
|||||||
$projectId = $this->request->project_id;
|
$projectId = $this->request->project_id;
|
||||||
$importData = json_decode(file_get_contents('php://input'), true);
|
$importData = json_decode(file_get_contents('php://input'), true);
|
||||||
|
|
||||||
|
// save full post request and project id to file as log with metadata like user id etc as json file
|
||||||
|
// MFUPLOAD_FILE_SAVE_PATH . /ConstructionConsentImports
|
||||||
|
|
||||||
|
$logData = [
|
||||||
|
"user_id" => $this->me->id,
|
||||||
|
"project_id" => $projectId,
|
||||||
|
"import_data" => $importData,
|
||||||
|
"timestamp" => date("Y-m-d H:i:s")
|
||||||
|
];
|
||||||
|
$logFileName = MFUPLOAD_FILE_SAVE_PATH . "/ConstructionConsentImports/import_" . date("Ymd_His") . "_user_{$this->me->id}_project_{$projectId}.json";
|
||||||
|
if (!file_exists(dirname($logFileName))) {
|
||||||
|
mkdir(dirname($logFileName), 0777, true);
|
||||||
|
}
|
||||||
|
file_put_contents($logFileName, json_encode($logData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
||||||
|
|
||||||
|
|
||||||
if (empty($importData) || !is_array($importData)) { $this->layout()->setFlash("Keine Daten gefunden", "error"); return $this->redirect("ConstructionConsent"); }
|
if (empty($importData) || !is_array($importData)) { $this->layout()->setFlash("Keine Daten gefunden", "error"); return $this->redirect("ConstructionConsent"); }
|
||||||
if (!is_numeric($projectId) || $projectId < 1) { $this->layout()->setFlash("Projekt nicht gefunden", "error"); return $this->redirect("ConstructionConsent"); }
|
if (!is_numeric($projectId) || $projectId < 1) { $this->layout()->setFlash("Projekt nicht gefunden", "error"); return $this->redirect("ConstructionConsent"); }
|
||||||
if (!($consentProject = new ConstructionConsentProject($projectId))->id) { $this->layout()->setFlash("Projekt nicht gefunden", "error"); return $this->redirect("ConstructionConsent"); }
|
if (!($consentProject = new ConstructionConsentProject($projectId))->id) { $this->layout()->setFlash("Projekt nicht gefunden", "error"); return $this->redirect("ConstructionConsent"); }
|
||||||
@@ -1178,7 +1194,10 @@ class ConstructionConsentController extends mfBaseController {
|
|||||||
|
|
||||||
$journal = ConstructionConsentJournal::create([
|
$journal = ConstructionConsentJournal::create([
|
||||||
"constructionconsent_id" => $consentRecord->id,
|
"constructionconsent_id" => $consentRecord->id,
|
||||||
"text" => "Import: Eigentümer $firstname $lastname wurde hinzugefügt"
|
"text" =>
|
||||||
|
$ownerRecord->company ?
|
||||||
|
"Import: Eigentümer $ownerRecord->company wurde hinzugefügt" :
|
||||||
|
"Import: Eigentümer $firstname $lastname wurde hinzugefügt"
|
||||||
]);
|
]);
|
||||||
$journal->save();
|
$journal->save();
|
||||||
|
|
||||||
|
|||||||
@@ -156,6 +156,15 @@ class ConstructionConsentOwnerController extends mfBaseController
|
|||||||
$file->delete();
|
$file->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$journal = ConstructionConsentJournal::create([
|
||||||
|
"constructionconsent_id" => $consent->id,
|
||||||
|
"text" =>
|
||||||
|
$owner->company ?
|
||||||
|
"Eigentümer $owner->company wurde gelöscht" :
|
||||||
|
"Eigentümer $owner->firstname $owner->lastname wurde gelöscht"
|
||||||
|
]);
|
||||||
|
$journal->save();
|
||||||
|
|
||||||
$owner->delete();
|
$owner->delete();
|
||||||
|
|
||||||
$this->layout()->setFlash("Besitzer gelöscht!", "success");
|
$this->layout()->setFlash("Besitzer gelöscht!", "success");
|
||||||
|
|||||||
Reference in New Issue
Block a user