notifications seems to work but new comments erase previous ones
This commit is contained in:
parent
44361e614d
commit
85537d3465
5 changed files with 16 additions and 130 deletions
|
|
@ -7,20 +7,20 @@ return [
|
|||
$json = file_get_contents('php://input');
|
||||
$data = json_decode($json);
|
||||
|
||||
// return json_encode($data->pageUri);
|
||||
|
||||
$page = page($data->pageUri);
|
||||
$file = $page->file($data->fileName);
|
||||
$user = kirby()->user($data->userUuid);
|
||||
|
||||
|
||||
$comments = $file->comments()->isEmpty() == true ? [] : Data::decode($file->comments()->toArray()['comments'], 'yaml');
|
||||
$comments = $file->comments()->isEmpty() == true ? [] : [];
|
||||
|
||||
$newComment = [
|
||||
'fileUuid' => (string )$file->uuid(),
|
||||
'page' => $data->targetPage,
|
||||
'text' => $data->text,
|
||||
'username' => $user->name()->isNotEmpty() ? (string) $user->name() : (string) $user->email(),
|
||||
'date' => (string) $data->date,
|
||||
'id' => $data->id
|
||||
'id' => $data->id,
|
||||
];
|
||||
|
||||
$comments[$data->targetPage][$data->id] = $newComment;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'pattern' => '(:all)logout.php',
|
||||
'pattern' => '(:all)logout',
|
||||
'action' => function () {
|
||||
$kirby = kirby();
|
||||
$user = $kirby->user();
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@ return function ($page, $kirby) {
|
|||
$data['template'] = (string) $page->template();
|
||||
|
||||
$userData = [
|
||||
"role" => $kirby->user()->role(),
|
||||
"uuid" => $kirby->user()->uuid(),
|
||||
"role" => (string) $kirby->user()->role(),
|
||||
"uuid" => (string) $kirby->user()->uuid(),
|
||||
"notifications" => Yaml::decode($kirby->user()->notifications()->value()),
|
||||
];
|
||||
|
||||
if ($kirby->user()->role() == 'client') {
|
||||
$userData['client'] = [
|
||||
"name" => $kirby->user()->client()->toPage()->title(),
|
||||
"uuid" => $kirby->user()->client()->toPage()->uuid()
|
||||
"name" => (string) $kirby->user()->client()->toPage()->title(),
|
||||
"uuid" => (string) $kirby->user()->client()->toPage()->uuid()
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue