16 import(
'classes.handler.Handler');
17 import(
'classes.notification.Notification');
29 $user = $request->getUser();
30 $userId = $user?$user->getId():
null;
31 $context = $request->getContext();
33 $notifications = array();
36 $notificationOptions = $request->getUserVar(
'requestOptions');
39 $notifications = array();
40 } elseif (is_array($notificationOptions)) {
45 $notifications = $notificationDao->getByUserId($userId, NOTIFICATION_LEVEL_TRIVIAL);
46 $notifications = $notifications->toArray();
49 import(
'lib.pkp.classes.core.JSONMessage');
52 if (is_array($notifications) && !empty($notifications)) {
53 $formattedNotificationsData = array();
57 $formattedNotificationsData[
'inPlace'] = $notificationManager->formatToInPlaceNotification($request, $notifications);
60 $formattedNotificationsData[
'general'] = $notificationManager->formatToGeneralNotification($request, $notifications);
63 $notificationManager->deleteTrivialNotifications($notifications);
65 $json->setContent($formattedNotificationsData);
80 $notificationsArray = array();
83 foreach ($notificationOptions as $level => $levelOptions) {
85 foreach ($levelOptions as $type => $typeOptions) {
87 $notificationMgr->isVisibleToAllUsers($type, $typeOptions[
'assocType'], $typeOptions[
'assocId']) ? $workingUserId = null : $workingUserId = $userId;
88 $notificationsResultFactory = $notificationDao->getByAssoc($typeOptions[
'assocType'], $typeOptions[
'assocId'], $workingUserId, $type, $contextId);
92 $notificationsResultFactory = $notificationDao->getByUserId($userId, $level, $type, $contextId);
99 $notificationsResultFactory = $notificationDao->getByUserId($userId, $level,
null, $contextId);
103 $notificationsResultFactory =
null;
106 return $notificationsArray;
116 if (!$resultFactory->wasEmpty()) {
117 $notificationArray = array_merge($notificationArray, $resultFactory->toArray());
120 return $notificationArray;
129 parent::setupTemplate($request);