예제 #1
0
 /**
  * Fetch the actual RSS feed
  * @param $args array
  * @param $request Request
  */
 function notificationFeed($args, &$request)
 {
     if (isset($args[0]) && isset($args[1])) {
         $type = $args[0];
         $token = $args[1];
     } else {
         return false;
     }
     $this->setupTemplate(true);
     $application = PKPApplication::getApplication();
     $appName = $application->getNameKey();
     $site =& $request->getSite();
     $siteTitle = $site->getLocalizedTitle();
     $notificationSubscriptionSettingsDao =& DAORegistry::getDAO('NotificationSubscriptionSettingsDAO');
     $context =& $request->getContext();
     $userId = $notificationSubscriptionSettingsDao->getUserIdByRSSToken($token, $context->getId());
     // Make sure the feed type is specified and valid
     $typeMap = array('rss' => 'rss.tpl', 'rss2' => 'rss2.tpl', 'atom' => 'atom.tpl');
     $contentTypeMap = array('rss' => 'rssContent.tpl', 'rss2' => 'rss2Content.tpl', 'atom' => 'atomContent.tpl');
     $mimeTypeMap = array('rss' => 'application/rdf+xml', 'rss2' => 'application/rss+xml', 'atom' => 'application/atom+xml');
     if (!isset($typeMap[$type])) {
         return false;
     }
     $notificationManager = new NotificationManager();
     $notifications = $notificationManager->getFormattedNotificationsForUser($request, $userId, NOTIFICATION_LEVEL_NORMAL, $context->getId(), null, 'notification/' . $contentTypeMap[$type]);
     $versionDao =& DAORegistry::getDAO('VersionDAO');
     $version = $versionDao->getCurrentVersion();
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('version', $version->getVersionString());
     $templateMgr->assign('selfUrl', $request->getCompleteUrl());
     $templateMgr->assign('locale', AppLocale::getPrimaryLocale());
     $templateMgr->assign('appName', $appName);
     $templateMgr->assign('siteTitle', $siteTitle);
     $templateMgr->assign_by_ref('formattedNotifications', $notifications);
     $templateMgr->display('notification/' . $typeMap[$type], $mimeTypeMap[$type]);
     return true;
 }