users / notifications : temporary disabled notifications system
This commit is contained in:
parent
9167519388
commit
ef6375f4cc
15 changed files with 302 additions and 113 deletions
|
|
@ -23,7 +23,8 @@ tabs:
|
|||
fields:
|
||||
stepName:
|
||||
type: hidden
|
||||
value: test
|
||||
isSent:
|
||||
type: hidden
|
||||
pdf:
|
||||
label: PDF
|
||||
type: files
|
||||
|
|
|
|||
|
|
@ -5,13 +5,6 @@ tabs:
|
|||
label: Contenu
|
||||
columns:
|
||||
- width: 1/1
|
||||
sections:
|
||||
listed:
|
||||
extends: sections/projects
|
||||
headline: En cours
|
||||
status: listed
|
||||
sortBy: modified desc
|
||||
- width: 1/2
|
||||
sections:
|
||||
drafts:
|
||||
extends: sections/projects
|
||||
|
|
@ -23,17 +16,24 @@ tabs:
|
|||
extends: sections/projects
|
||||
headline: Archivés
|
||||
status: unlisted
|
||||
- width: 1/1
|
||||
- width: 1/2
|
||||
sections:
|
||||
yourProjects:
|
||||
label: Tous vos projets
|
||||
type: pages
|
||||
query: user.projects
|
||||
listed:
|
||||
extends: sections/projects
|
||||
headline: En cours
|
||||
status: listed
|
||||
sortBy: modified desc
|
||||
create: false
|
||||
search: true
|
||||
image:
|
||||
query: page.client.toPage.logo.toFile
|
||||
# - width: 1/1
|
||||
# sections:
|
||||
# yourProjects:
|
||||
# label: Tous vos projets
|
||||
# type: pages
|
||||
# query: user.projects
|
||||
# sortBy: modified desc
|
||||
# create: false
|
||||
# search: true
|
||||
# image:
|
||||
# query: page.client.toPage.logo.toFile
|
||||
|
||||
settings:
|
||||
label: Réglages
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ tabs:
|
|||
yourProjects:
|
||||
label: Vos projets
|
||||
type: pages
|
||||
query: user.projects
|
||||
help: Projets pour lesquels vous êtes nommé chef de projet.
|
||||
image:
|
||||
query: page.client.toPage.logo.toFile
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ return [
|
|||
require(__DIR__ . '/routes/save-file.php'),
|
||||
require(__DIR__ . '/routes/remove-file.php'),
|
||||
require(__DIR__ . '/routes/upload-pdf.php'),
|
||||
require(__DIR__ . '/routes/validate-brief.php'),
|
||||
],
|
||||
'hooks' => [
|
||||
'page.create:after' => require_once(__DIR__ . '/hooks/create-steps.php'),
|
||||
|
|
|
|||
32
public/site/config/routes/validate-brief.php
Normal file
32
public/site/config/routes/validate-brief.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'pattern' => '(:all)validate-brief.json',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
$json = file_get_contents('php://input');
|
||||
$data = json_decode($json);
|
||||
|
||||
$page = page($data->pageUri);
|
||||
try {
|
||||
$newPage = $page->update([
|
||||
'isValidated' => 'true'
|
||||
]);
|
||||
echo json_encode([
|
||||
"success" => "'" . $newPage->title()->value() . "' brief validated."
|
||||
]);
|
||||
|
||||
kirby()->user()->sendNotification($newPage->parent(), [
|
||||
'date' => $newPage->modified('YYYY-MM-DD'),
|
||||
'author' => kirby()->user()->name()->isNotEmpty() ? kirby()->user()->name() : kirby()->user()->email(),
|
||||
'url' => $newPage->url(),
|
||||
'type' => 'content'
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
return [
|
||||
"error" => "Can't validate '" . $page->title()->value() . "' brief.",
|
||||
'details' => $th->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
@ -35,6 +35,7 @@ class ProjectPage extends Page {
|
|||
'slug' => $child->slug(),
|
||||
'index' => intval($child->stepIndex()->value()),
|
||||
'modified' => $child->modified('Y-MM-dd'),
|
||||
'isValidated' => $child->isValidated()->value() ?? false,
|
||||
'uri' => $uri,
|
||||
'files' => $files,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ return [
|
|||
echo json_encode(getFileData($newFile));
|
||||
|
||||
try {
|
||||
$user->sendNotification($page->parent()->uri(), $newComment->toArray());
|
||||
$user->sendNotification($page->parent(), $newComment->toArray());
|
||||
} catch (\Throwable $th) {
|
||||
throw new Exception($th->getMessage(), 1);
|
||||
return $th->getMessage() . " in " . $th->getFile() . " line " . $th->getLine();
|
||||
}
|
||||
|
||||
exit;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ return [
|
|||
'comments' => $comments
|
||||
]);
|
||||
|
||||
$user->sendNotification($page->parent()->uri(), $newReply->toArray());
|
||||
$user->sendNotification($page->parent(), $newReply->toArray());
|
||||
|
||||
return getFileData($newFile);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,23 @@
|
|||
* @throws Exception If an error occurs while updating a user's notifications.
|
||||
*/
|
||||
|
||||
return function ($projectUri, $notificationData) {
|
||||
$recipients = page($projectUri)->managers()->toUsers()->not($this);
|
||||
return function ($project, $notificationData) {
|
||||
$recipients = kirby()->users()->filter(function($user) use ($project) {
|
||||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,5 @@
|
|||
<?php
|
||||
|
||||
Kirby::plugin('adrienpayet/pdc-your-projects', [
|
||||
'userMethods' => [
|
||||
'projects' => function() {
|
||||
$allProjects = page('projects')->children();
|
||||
|
||||
$managedProjects = $allProjects->filter(
|
||||
fn ($project) => $project->managers()->toUsers()->has($this)
|
||||
);
|
||||
|
||||
return $managedProjects;
|
||||
}
|
||||
]
|
||||
'userMethods' => []
|
||||
]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue