Construct a URL for the notification based on its type and associated object
public getNotificationUrl ( $request, $notification ) : string | ||
$request | PKPRequest | |
$notification | Notification | |
return | string |
/** * Mark notifications unread * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function markRead($args, $request) { $notificationDao = DAORegistry::getDAO('NotificationDAO'); $user = $request->getUser(); $selectedElements = (array) $request->getUserVar('selectedElements'); foreach ($selectedElements as $notificationId) { if ($notification = $notificationDao->getById($notificationId, $user->getId())) { $notificationDao->setDateRead($notificationId, Core::getCurrentDate()); } } if ($request->getUserVar('redirect')) { // In this case, the user has clicked on a notification // and wants to view it. Mark it read first and redirect $notificationMgr = new NotificationManager(); return $request->redirectUrlJson($notificationMgr->getNotificationUrl($request, $notification)); } else { // The notification has been marked read explicitly. // Update its status in the grid. return DAO::getDataChangedEvent(null, null, $selectedElements); } }