comment : send notification only to project managers
This commit is contained in:
parent
4f60dc91d3
commit
14321b1e8d
8 changed files with 41 additions and 137 deletions
|
|
@ -7,132 +7,3 @@ Uuid: s0lNtRA0Z7ybTCWG
|
||||||
----
|
----
|
||||||
|
|
||||||
Template: document
|
Template: document
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
Comments:
|
|
||||||
|
|
||||||
-
|
|
||||||
page:
|
|
||||||
uri: projects/miss-dior-blooming-bouquet
|
|
||||||
title: Miss Dior Blooming Bouquet
|
|
||||||
file:
|
|
||||||
uuid: file://s0lNtRA0Z7ybTCWG
|
|
||||||
pageIndex: 1
|
|
||||||
replies: [ ]
|
|
||||||
text: Un certain commentaire
|
|
||||||
author:
|
|
||||||
name: Adrien Payet
|
|
||||||
email: adrien.payet@outlook.com
|
|
||||||
uuid: user://WWjXgPWk
|
|
||||||
role: admin
|
|
||||||
date: 2024-10-30T16:26:22+01:00
|
|
||||||
id: m2w14iph
|
|
||||||
type: comment
|
|
||||||
isRead: false
|
|
||||||
position:
|
|
||||||
x: null
|
|
||||||
y: null
|
|
||||||
-
|
|
||||||
page:
|
|
||||||
uri: projects/miss-dior-blooming-bouquet
|
|
||||||
title: Miss Dior Blooming Bouquet
|
|
||||||
file:
|
|
||||||
uuid: file://s0lNtRA0Z7ybTCWG
|
|
||||||
pageIndex: 1
|
|
||||||
replies:
|
|
||||||
-
|
|
||||||
page:
|
|
||||||
uri: projects/miss-dior-blooming-bouquet
|
|
||||||
title: Miss Dior Blooming Bouquet
|
|
||||||
file:
|
|
||||||
uuid: file://s0lNtRA0Z7ybTCWG
|
|
||||||
pageIndex: 1
|
|
||||||
replies: [ ]
|
|
||||||
text: Réponse
|
|
||||||
author:
|
|
||||||
name: Adrien Payet
|
|
||||||
email: adrien.payet@outlook.com
|
|
||||||
uuid: user://WWjXgPWk
|
|
||||||
role: admin
|
|
||||||
date: 2024-10-30T16:52:46+01:00
|
|
||||||
id: m2w22gxz
|
|
||||||
type: comment
|
|
||||||
isRead: false
|
|
||||||
parentId: m2w2252a
|
|
||||||
text: deuxième commentaire
|
|
||||||
author:
|
|
||||||
name: Adrien Payet
|
|
||||||
email: adrien.payet@outlook.com
|
|
||||||
uuid: user://WWjXgPWk
|
|
||||||
role: admin
|
|
||||||
date: 2024-10-30T16:52:31+01:00
|
|
||||||
id: m2w2252a
|
|
||||||
type: comment
|
|
||||||
isRead: false
|
|
||||||
position:
|
|
||||||
x: null
|
|
||||||
y: null
|
|
||||||
-
|
|
||||||
page:
|
|
||||||
uri: projects/miss-dior-blooming-bouquet
|
|
||||||
title: Miss Dior Blooming Bouquet
|
|
||||||
file:
|
|
||||||
uuid: file://s0lNtRA0Z7ybTCWG
|
|
||||||
pageIndex: 1
|
|
||||||
replies: [ ]
|
|
||||||
text: test
|
|
||||||
author:
|
|
||||||
name: Adrien Payet
|
|
||||||
email: adrien.payet@outlook.com
|
|
||||||
uuid: user://WWjXgPWk
|
|
||||||
role: admin
|
|
||||||
date: 2024-11-06T16:19:29+01:00
|
|
||||||
id: m360ymc1
|
|
||||||
type: comment
|
|
||||||
isRead: false
|
|
||||||
position:
|
|
||||||
x: "148.03332519531"
|
|
||||||
y: 162
|
|
||||||
-
|
|
||||||
page:
|
|
||||||
uri: projects/miss-dior-blooming-bouquet
|
|
||||||
title: Miss Dior Blooming Bouquet
|
|
||||||
file:
|
|
||||||
uuid: file://s0lNtRA0Z7ybTCWG
|
|
||||||
pageIndex: 1
|
|
||||||
replies: [ ]
|
|
||||||
text: Nouveau commentaire positionné
|
|
||||||
author:
|
|
||||||
name: Adrien Payet
|
|
||||||
email: adrien.payet@outlook.com
|
|
||||||
uuid: user://WWjXgPWk
|
|
||||||
role: admin
|
|
||||||
date: 2024-11-06T16:33:11+01:00
|
|
||||||
id: m361g8sk
|
|
||||||
type: comment
|
|
||||||
isRead: false
|
|
||||||
position:
|
|
||||||
x: "215.03332519531"
|
|
||||||
y: 181
|
|
||||||
-
|
|
||||||
page:
|
|
||||||
uri: projects/miss-dior-blooming-bouquet
|
|
||||||
title: Miss Dior Blooming Bouquet
|
|
||||||
file:
|
|
||||||
uuid: file://s0lNtRA0Z7ybTCWG
|
|
||||||
pageIndex: 1
|
|
||||||
replies: [ ]
|
|
||||||
text: ouveau commentaire
|
|
||||||
author:
|
|
||||||
name: Utilisateur Dior
|
|
||||||
email: utilisateur@dior.com
|
|
||||||
uuid: user://HfuumN8s
|
|
||||||
role: client
|
|
||||||
date: 2024-11-06T16:57:15+01:00
|
|
||||||
id: m362b71x
|
|
||||||
type: comment
|
|
||||||
isRead: false
|
|
||||||
position:
|
|
||||||
x: '59.033325195312'
|
|
||||||
y: 59
|
|
||||||
|
|
@ -10,7 +10,10 @@ Client: - page://G418qZ4ABsoWFx4i
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
Managers: - user://WWjXgPWk
|
Managers:
|
||||||
|
|
||||||
|
- user://WWjXgPWk
|
||||||
|
- user://HfuumN8s
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ tabs:
|
||||||
type: pages
|
type: pages
|
||||||
query: user.projects
|
query: user.projects
|
||||||
create: false
|
create: false
|
||||||
|
search: true
|
||||||
help: Projets pour lesquels vous êtes nommé chef de projet.
|
help: Projets pour lesquels vous êtes nommé chef de projet.
|
||||||
image:
|
image:
|
||||||
query: page.client.toPage.logo.toFile
|
query: page.client.toPage.logo.toFile
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,14 @@ tabs:
|
||||||
projects:
|
projects:
|
||||||
width: 1/2
|
width: 1/2
|
||||||
sections:
|
sections:
|
||||||
|
modifiedProjects:
|
||||||
|
extends: sections/projects
|
||||||
|
headline: Projets récement modifiés
|
||||||
|
parent: site.find("projects")
|
||||||
|
sortBy: modified desc
|
||||||
|
layout: list
|
||||||
|
image:
|
||||||
|
query: page.client.toPage.logo.toFile
|
||||||
settings:
|
settings:
|
||||||
label: Paramètres
|
label: Paramètres
|
||||||
icon: cog
|
icon: cog
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,11 @@ return [
|
||||||
'comments' => $comments
|
'comments' => $comments
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user->sendNotification($newComment);
|
try {
|
||||||
|
$user->sendNotification($page->parent()->uri(), $newComment->toArray());
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
throw new Exception($th->getMessage(), 1);
|
||||||
|
}
|
||||||
return getFileData($newFile);
|
return getFileData($newFile);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
@ -40,7 +40,7 @@ return [
|
||||||
'comments' => $comments
|
'comments' => $comments
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user->sendNotification($newReply);
|
$user->sendNotification($page->parent()->uri(), $newReply->toArray());
|
||||||
|
|
||||||
return getFileData($newFile);
|
return getFileData($newFile);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return function ($item) {
|
/**
|
||||||
foreach (kirby()->users()->not($this) as $otherUser) {
|
* Send a notification to all users who manage a specific project, excluding the user sending the notification.
|
||||||
|
*
|
||||||
|
* This function retrieves all users managing the project specified by `$projectUri` (excluding the current user)
|
||||||
|
* and adds a new notification to their `notifications` field, stored as a YAML-encoded array.
|
||||||
|
* If the `notifications` field is empty, an empty array is initialized before appending the new notification.
|
||||||
|
* In case of an error during update, an exception is thrown with the error message and line number.
|
||||||
|
*
|
||||||
|
* @param array $notificationData An associative array containing the notification data to be added.
|
||||||
|
* @param string $projectUri The URI of the project associated with this notification.
|
||||||
|
* @throws Exception If an error occurs while updating a user's notifications.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return function ($projectUri, $notificationData) {
|
||||||
|
$recipients = page($projectUri)->managers()->toUsers()->not($this);
|
||||||
|
|
||||||
|
if (!$recipients) return;
|
||||||
|
|
||||||
|
foreach ($recipients as $otherUser) {
|
||||||
try {
|
try {
|
||||||
$notifications = $otherUser->notifications()->isNotEmpty()
|
$notifications = $otherUser->notifications()->isNotEmpty()
|
||||||
? Yaml::decode($otherUser->notifications()->value())
|
? Yaml::decode($otherUser->notifications()->value())
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
$notifications[] = $item->toArray();
|
$notifications[] = $notificationData;
|
||||||
|
|
||||||
$otherUser->update([
|
$otherUser->update([
|
||||||
'notifications' => $notifications
|
'notifications' => $notifications
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,7 @@ function toggleCommentPositionMode(enable) {
|
||||||
|
|
||||||
function handleCommentPositionClick(event) {
|
function handleCommentPositionClick(event) {
|
||||||
const pageContainer = event.target.closest(".page-inner-container");
|
const pageContainer = event.target.closest(".page-inner-container");
|
||||||
|
if (!pageContainer) return;
|
||||||
|
|
||||||
const pageLabel = pageContainer
|
const pageLabel = pageContainer
|
||||||
.closest(".vpv-page-inner-container")
|
.closest(".vpv-page-inner-container")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue