mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°2039 - Rework view all notifications page (#617)
* N°2039 - Rework view all notifications page * N°2039 - Replace modals with toasts * N°2039 - Add bulk mode to view all notifications page * Apply suggestions from code review Co-authored-by: Molkobain <lajarige.guillaume@free.fr> * Apply suggestions from code review Co-authored-by: Molkobain <lajarige.guillaume@free.fr> * Apply suggestions from code review Co-authored-by: Molkobain <lajarige.guillaume@free.fr> * Apply suggestions from code review Co-authored-by: Molkobain <lajarige.guillaume@free.fr> * Apply suggestions from code review Co-authored-by: Molkobain <lajarige.guillaume@free.fr> * Update css/backoffice/pages/_notifications.scss * Update dictionaries/ui/application/newsroom/fr.dictionary.itop.newsroom.php * Apply suggestions from code review Co-authored-by: Molkobain <lajarige.guillaume@free.fr> * Add since in phpdoc * Change newsroom empty notification illustration * N°2039 - Refactor code to factorize logic --------- Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
This commit is contained in:
@@ -2,8 +2,12 @@
|
||||
|
||||
namespace Combodo\iTop\Service\Notification;
|
||||
|
||||
use BinaryExpression;
|
||||
use DBObjectSearch;
|
||||
use DBObjectSet;
|
||||
use Expression;
|
||||
use FieldExpression;
|
||||
use VariableExpression;
|
||||
|
||||
/**
|
||||
* Class NotificationsRepository
|
||||
@@ -44,6 +48,74 @@ class NotificationsRepository
|
||||
// Don't do anything, we don't want to be initialized
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iContactId ID of the contact to retrieve notifications for
|
||||
* @param array $aNotificationIds Optional IDs of the notifications to retrieve, if omitted all notifications will be retrieved
|
||||
*
|
||||
* @return \DBObjectSet Set of notifications for $iContactId, optionally limited to $aNotificationIds
|
||||
* @throws \CoreException
|
||||
* @throws \OQLException
|
||||
*/
|
||||
public function SearchNotificationsByContact(int $iContactId, array $aNotificationIds = []): DBObjectSet
|
||||
{
|
||||
$oSearch = DBObjectSearch::FromOQL("SELECT EventiTopNotification WHERE contact_id = :contact_id");
|
||||
$aParams = [
|
||||
"contact_id" => $iContactId,
|
||||
];
|
||||
|
||||
if (count($aNotificationIds) > 0) {
|
||||
$oSearch->AddConditionExpression(Expression::FromOQL("{$oSearch->GetClassAlias()}.id IN (:notification_ids)"));
|
||||
$aParams["notification_ids"] = $aNotificationIds;
|
||||
}
|
||||
|
||||
return new DBObjectSet($oSearch, [], $aParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iContactId ID of the contact to retrieve unread notifications for
|
||||
* @param array $aNotificationIds Optional IDs of the unread notifications to retrieve, if omitted all unread notifications will be retrieved
|
||||
*
|
||||
* @return \DBObjectSet Set of unread notifications for $iContactId, optionally limited to $aNotificationIds
|
||||
* @throws \CoreException
|
||||
* @throws \OQLException
|
||||
*/
|
||||
public function SearchNotificationsToMarkAsReadByContact(int $iContactId, array $aNotificationIds = []): DBObjectSet
|
||||
{
|
||||
$oSet = $this->SearchNotificationsByContact($iContactId, $aNotificationIds);
|
||||
$oSet->GetFilter()->AddCondition("read", "=", "no");
|
||||
|
||||
return $oSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iContactId ID of the contact to retrieve read notifications for
|
||||
* @param array $aNotificationIds Optional IDs of the read notifications to retrieve, if omitted all read notifications will be retrieved
|
||||
*
|
||||
* @return \DBObjectSet Set of read notifications for $iContactId, optionally limited to $aNotificationIds
|
||||
* @throws \CoreException
|
||||
* @throws \OQLException
|
||||
*/
|
||||
public function SearchNotificationsToMarkAsUnreadByContact(int $iContactId, array $aNotificationIds = []): DBObjectSet
|
||||
{
|
||||
$oSet = $this->SearchNotificationsByContact($iContactId, $aNotificationIds);
|
||||
$oSet->GetFilter()->AddCondition("read", "=", "yes");
|
||||
|
||||
return $oSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iContactId ID of the contact to retrieve read notifications for
|
||||
* @param array $aNotificationIds Optional IDs of the notifications to retrieve, if omitted all notifications will be retrieved
|
||||
*
|
||||
* @return \DBObjectSet Set of notifications for $iContactId, optionally limited to $aNotificationIds
|
||||
* @throws \CoreException
|
||||
* @throws \OQLException
|
||||
*/
|
||||
public function SearchNotificationsToDeleteByContact(int $iContactId, array $aNotificationIds = []): DBObjectSet
|
||||
{
|
||||
return $this->SearchNotificationsByContact($iContactId, $aNotificationIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for subscriptions by contact ID.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user