new: [inbox:index] Added support of various context filtering

- My notification includes message without user_ids
- User registration
- Inter-connection requests
- Data changed
- severity:*
pull/121/head
Sami Mokaddem 2022-11-15 11:21:26 +01:00
parent 407f827e24
commit d23cf2e2c6
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 86 additions and 1 deletions

View File

@ -43,9 +43,94 @@ class InboxController extends AppController
[
'default' => true,
'label' => __('My Notifications'),
'filterConditionFunction' => function ($query) {
return $query->where(function(QueryExpression $exp) {
return $exp->or(['user_id' => $this->ACL->getUser()['id']])
->isNull('user_id');
});
}
],
[
'label' => __('User Registration'),
'filterConditionFunction' => function ($query) {
return $query->where([
'user_id' => $this->ACL->getUser()['id'],
'scope' => 'User',
'action' => 'Registration',
]);
}
],
[
'label' => __('Inter-connection Requests'),
'filterConditionFunction' => function ($query) {
return $query->where([
'scope' => 'LocalTool',
'action IN' => ['IncomingConnectionRequest', 'AcceptedRequest', 'DeclinedRequest'],
]);
}
],
[
'label' => __('Data changed'),
'filterConditionFunction' => function ($query) {
return $query->where([
'user_id' => $this->ACL->getUser()['id'], // Each admin get a message about data changes
'scope' => 'Notification',
'action' => 'DataChange',
]);
}
],
[
'label' => 'severity:primary',
'viewElement' => 'bootstrapUI',
'viewElementParams' => [
'element' => 'badge',
'text' => $this->Inbox->severityVariant[$this->Inbox::SEVERITY_PRIMARY],
'variant' => $this->Inbox->severityVariant[$this->Inbox::SEVERITY_PRIMARY],
],
'filterConditionFunction' => function ($query) {
return $query->where([
'severity' => $this->Inbox::SEVERITY_PRIMARY,
]);
}
],
[
'label' => 'severity:info',
'viewElement' => 'bootstrapUI',
'viewElementParams' => [
'element' => 'badge',
'text' => $this->Inbox->severityVariant[$this->Inbox::SEVERITY_INFO],
'variant' => $this->Inbox->severityVariant[$this->Inbox::SEVERITY_INFO],
],
'filterConditionFunction' => function ($query) {
return $query->where([
'severity' => $this->Inbox::SEVERITY_INFO,
]);
}
],
[
'label' => 'severity:warning',
'viewElement' => 'bootstrapUI',
'viewElementParams' => [
'element' => 'badge',
'text' => $this->Inbox->severityVariant[$this->Inbox::SEVERITY_WARNING],
'variant' => $this->Inbox->severityVariant[$this->Inbox::SEVERITY_WARNING],
],
'filterConditionFunction' => function ($query) {
return $query->where([
'severity' => $this->Inbox::SEVERITY_WARNING,
]);
}
],
[
'label' => 'severity:danger',
'viewElement' => 'bootstrapUI',
'viewElementParams' => [
'element' => 'badge',
'text' => $this->Inbox->severityVariant[$this->Inbox::SEVERITY_DANGER],
'variant' => $this->Inbox->severityVariant[$this->Inbox::SEVERITY_DANGER],
],
'filterConditionFunction' => function ($query) {
return $query->where([
'severity' => $this->Inbox::SEVERITY_DANGER,
]);
}
],