notifications working
This commit is contained in:
parent
699c0bfa1d
commit
8ae00d7657
8 changed files with 28 additions and 202 deletions
|
|
@ -28,8 +28,8 @@ Comments:
|
||||||
url: file://s0lNtRA0Z7ybTCWG
|
url: file://s0lNtRA0Z7ybTCWG
|
||||||
position:
|
position:
|
||||||
pageIndex: 1
|
pageIndex: 1
|
||||||
x: "64.481176977282"
|
x: '27.05459466102'
|
||||||
y: "14.478764478764"
|
y: '35.135135135135'
|
||||||
replies: [ ]
|
replies: [ ]
|
||||||
text: test
|
text: test
|
||||||
author:
|
author:
|
||||||
|
|
@ -37,181 +37,7 @@ Comments:
|
||||||
email: adrien.payet@outlook.com
|
email: adrien.payet@outlook.com
|
||||||
uuid: user://WWjXgPWk
|
uuid: user://WWjXgPWk
|
||||||
role: admin
|
role: admin
|
||||||
date: 2024-11-21T19:18:40+01:00
|
date: 2024-11-22T07:49:45+01:00
|
||||||
id: m3rmytqk
|
id: m3sdsq23
|
||||||
type: comment
|
|
||||||
isRead: false
|
|
||||||
-
|
|
||||||
location:
|
|
||||||
page:
|
|
||||||
uri: >
|
|
||||||
projects/miss-dior-blooming-bouquet/client-brief
|
|
||||||
title: Brief client
|
|
||||||
href: >
|
|
||||||
/projects/miss-dior-blooming-bouquet?dialog=client-brief
|
|
||||||
project:
|
|
||||||
title: Miss Dior Blooming Bouquet
|
|
||||||
uri: projects/miss-dior-blooming-bouquet
|
|
||||||
file:
|
|
||||||
uuid: file://s0lNtRA0Z7ybTCWG
|
|
||||||
url: file://s0lNtRA0Z7ybTCWG
|
|
||||||
position:
|
|
||||||
pageIndex: 1
|
|
||||||
x: "64.481176977282"
|
|
||||||
y: "14.478764478764"
|
|
||||||
replies: [ ]
|
|
||||||
text: test
|
|
||||||
author:
|
|
||||||
name: Adrien Payet
|
|
||||||
email: adrien.payet@outlook.com
|
|
||||||
uuid: user://WWjXgPWk
|
|
||||||
role: admin
|
|
||||||
date: 2024-11-21T19:19:27+01:00
|
|
||||||
id: m3rmzu2u
|
|
||||||
type: comment
|
|
||||||
isRead: false
|
|
||||||
-
|
|
||||||
location:
|
|
||||||
page:
|
|
||||||
uri: >
|
|
||||||
projects/miss-dior-blooming-bouquet/client-brief
|
|
||||||
title: Brief client
|
|
||||||
href: >
|
|
||||||
/projects/miss-dior-blooming-bouquet?dialog=client-brief
|
|
||||||
project:
|
|
||||||
title: Miss Dior Blooming Bouquet
|
|
||||||
uri: projects/miss-dior-blooming-bouquet
|
|
||||||
file:
|
|
||||||
uuid: file://s0lNtRA0Z7ybTCWG
|
|
||||||
url: file://s0lNtRA0Z7ybTCWG
|
|
||||||
position:
|
|
||||||
pageIndex: 1
|
|
||||||
x: "64.481176977282"
|
|
||||||
y: "14.478764478764"
|
|
||||||
replies: [ ]
|
|
||||||
text: test
|
|
||||||
author:
|
|
||||||
name: Adrien Payet
|
|
||||||
email: adrien.payet@outlook.com
|
|
||||||
uuid: user://WWjXgPWk
|
|
||||||
role: admin
|
|
||||||
date: 2024-11-21T19:19:33+01:00
|
|
||||||
id: m3rmzyl9
|
|
||||||
type: comment
|
|
||||||
isRead: false
|
|
||||||
-
|
|
||||||
location:
|
|
||||||
page:
|
|
||||||
uri: >
|
|
||||||
projects/miss-dior-blooming-bouquet/client-brief
|
|
||||||
title: Brief client
|
|
||||||
href: >
|
|
||||||
/projects/miss-dior-blooming-bouquet?dialog=client-brief
|
|
||||||
project:
|
|
||||||
title: Miss Dior Blooming Bouquet
|
|
||||||
uri: projects/miss-dior-blooming-bouquet
|
|
||||||
file:
|
|
||||||
uuid: file://s0lNtRA0Z7ybTCWG
|
|
||||||
url: file://s0lNtRA0Z7ybTCWG
|
|
||||||
position:
|
|
||||||
pageIndex: 1
|
|
||||||
x: "64.481176977282"
|
|
||||||
y: "14.478764478764"
|
|
||||||
replies: [ ]
|
|
||||||
text: test
|
|
||||||
author:
|
|
||||||
name: Adrien Payet
|
|
||||||
email: adrien.payet@outlook.com
|
|
||||||
uuid: user://WWjXgPWk
|
|
||||||
role: admin
|
|
||||||
date: 2024-11-21T19:19:44+01:00
|
|
||||||
id: m3rn07nl
|
|
||||||
type: comment
|
|
||||||
isRead: false
|
|
||||||
-
|
|
||||||
location:
|
|
||||||
page:
|
|
||||||
uri: >
|
|
||||||
projects/miss-dior-blooming-bouquet/client-brief
|
|
||||||
title: Brief client
|
|
||||||
href: >
|
|
||||||
/projects/miss-dior-blooming-bouquet?dialog=client-brief
|
|
||||||
project:
|
|
||||||
title: Miss Dior Blooming Bouquet
|
|
||||||
uri: projects/miss-dior-blooming-bouquet
|
|
||||||
file:
|
|
||||||
uuid: file://s0lNtRA0Z7ybTCWG
|
|
||||||
url: file://s0lNtRA0Z7ybTCWG
|
|
||||||
position:
|
|
||||||
pageIndex: 1
|
|
||||||
x: "64.481176977282"
|
|
||||||
y: "14.478764478764"
|
|
||||||
replies: [ ]
|
|
||||||
text: test
|
|
||||||
author:
|
|
||||||
name: Adrien Payet
|
|
||||||
email: adrien.payet@outlook.com
|
|
||||||
uuid: user://WWjXgPWk
|
|
||||||
role: admin
|
|
||||||
date: 2024-11-21T19:20:04+01:00
|
|
||||||
id: m3rn0mf4
|
|
||||||
type: comment
|
|
||||||
isRead: false
|
|
||||||
-
|
|
||||||
location:
|
|
||||||
page:
|
|
||||||
uri: >
|
|
||||||
projects/miss-dior-blooming-bouquet/client-brief
|
|
||||||
title: Brief client
|
|
||||||
href: >
|
|
||||||
/projects/miss-dior-blooming-bouquet?dialog=client-brief
|
|
||||||
project:
|
|
||||||
title: Miss Dior Blooming Bouquet
|
|
||||||
uri: projects/miss-dior-blooming-bouquet
|
|
||||||
file:
|
|
||||||
uuid: file://s0lNtRA0Z7ybTCWG
|
|
||||||
url: file://s0lNtRA0Z7ybTCWG
|
|
||||||
position:
|
|
||||||
pageIndex: 1
|
|
||||||
x: "60.383375993749"
|
|
||||||
y: "31.660231660232"
|
|
||||||
replies: [ ]
|
|
||||||
text: test
|
|
||||||
author:
|
|
||||||
name: Adrien Payet
|
|
||||||
email: adrien.payet@outlook.com
|
|
||||||
uuid: user://WWjXgPWk
|
|
||||||
role: admin
|
|
||||||
date: 2024-11-21T19:35:48+01:00
|
|
||||||
id: m3rnkvcn
|
|
||||||
type: comment
|
|
||||||
isRead: false
|
|
||||||
-
|
|
||||||
location:
|
|
||||||
page:
|
|
||||||
uri: >
|
|
||||||
projects/miss-dior-blooming-bouquet/client-brief
|
|
||||||
title: Brief client
|
|
||||||
href: >
|
|
||||||
/projects/miss-dior-blooming-bouquet?dialog=client-brief
|
|
||||||
project:
|
|
||||||
title: Miss Dior Blooming Bouquet
|
|
||||||
uri: projects/miss-dior-blooming-bouquet
|
|
||||||
file:
|
|
||||||
uuid: file://s0lNtRA0Z7ybTCWG
|
|
||||||
url: file://s0lNtRA0Z7ybTCWG
|
|
||||||
position:
|
|
||||||
pageIndex: 1
|
|
||||||
x: '64.481176977282'
|
|
||||||
y: '50.772200772201'
|
|
||||||
replies: [ ]
|
|
||||||
text: test
|
|
||||||
author:
|
|
||||||
name: Adrien Payet
|
|
||||||
email: adrien.payet@outlook.com
|
|
||||||
uuid: user://WWjXgPWk
|
|
||||||
role: admin
|
|
||||||
date: 2024-11-21T19:36:11+01:00
|
|
||||||
id: m3rnld52
|
|
||||||
type: comment
|
type: comment
|
||||||
isRead: false
|
isRead: false
|
||||||
|
|
@ -112,7 +112,17 @@ class ProjectPage extends Page {
|
||||||
return $stepsLabel[$this->currentStep()->value()];
|
return $stepsLabel[$this->currentStep()->value()];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function printManagers() {
|
// public function printManagers() {
|
||||||
return A::implode($this->managers()->toUsers()->pluck('name'), ', ');
|
// return A::implode($this->managers()->toUsers()->pluck('name'), ', ');
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function managers() {
|
||||||
|
return kirby()->users()->filter(function($user) {
|
||||||
|
if ($user->projects()->isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $user->role() === 'admin' || $user->projects()->toPages()->has($this);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -53,7 +53,9 @@ return [
|
||||||
try {
|
try {
|
||||||
$user->sendNotification($page->parent(), $newComment->toArray());
|
$user->sendNotification($page->parent(), $newComment->toArray());
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
return $th->getMessage() . " in " . $th->getFile() . " line " . $th->getLine();
|
echo json_encode([
|
||||||
|
"error" => $th->getMessage() . " in " . $th->getFile() . " line " . $th->getLine(),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ return [
|
||||||
|
|
||||||
echo json_encode(getFileData($newFile));
|
echo json_encode(getFileData($newFile));
|
||||||
|
|
||||||
kirby()->user()->deleteNotification($project->managers()->toUsers(), $data->id);
|
kirby()->user()->deleteNotification($project, $data->id);
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
load([
|
||||||
|
'ProjectPage' => 'models/ProjectPage.php',
|
||||||
|
], __DIR__);
|
||||||
|
|
||||||
Kirby::plugin('adrienpayet/pdc-notifications', [
|
Kirby::plugin('adrienpayet/pdc-notifications', [
|
||||||
'routes' => [
|
'routes' => [
|
||||||
require(__DIR__ . '/routes/readAll.php'),
|
require(__DIR__ . '/routes/readAll.php'),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return function($projectManagers, $notificationId) {
|
return function($project, $notificationId) {
|
||||||
foreach ($projectManagers as $projectManager) {
|
foreach ($project->managers() as $projectManager) {
|
||||||
try {
|
try {
|
||||||
$notifications = $projectManager->notifications()->isNotEmpty()
|
$notifications = $projectManager->notifications()->isNotEmpty()
|
||||||
? Yaml::decode($projectManager->notifications()->value())
|
? Yaml::decode($projectManager->notifications()->value())
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return function($notificationId) {
|
return function($notificationId) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$notifications = $this->notifications()->isNotEmpty()
|
$notifications = $this->notifications()->isNotEmpty()
|
||||||
? Yaml::decode($this->notifications()->value())
|
? Yaml::decode($this->notifications()->value())
|
||||||
|
|
|
||||||
|
|
@ -14,22 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return function ($project, $notificationData) {
|
return function ($project, $notificationData) {
|
||||||
$recipients = kirby()->users()->filter(function($user) use ($project) {
|
$recipients = $project->managers()->without($this);
|
||||||
if ($user === $this || $user->projects()->isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
throw new Exception(json_encode($user->name()), 1);
|
|
||||||
|
|
||||||
$projects = $user->projects();
|
|
||||||
if ($projects && ($user->role() == 'admin' || $projects->has($project))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// $recipients = page($projectUri)->managers()->toUsers()->not($this);
|
|
||||||
|
|
||||||
if (!$recipients) return;
|
if (!$recipients) return;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue