/**
  * View announcement details.
  * @param $args array optional, first parameter is the ID of the announcement to display 
  */
 function view($args = array())
 {
     AnnouncementHandler::setupTemplate();
     $journal =& Request::getJournal();
     $announcementsEnabled = $journal->getSetting('enableAnnouncements');
     $announcementId = !isset($args) || empty($args) ? null : (int) $args[0];
     $announcementDao =& DAORegistry::getDAO('AnnouncementDAO');
     if ($announcementsEnabled && $announcementId != null && $announcementDao->getAnnouncementJournalId($announcementId) == $journal->getJournalId()) {
         $announcement =& $announcementDao->getAnnouncement($announcementId);
         if ($announcement->getDateExpire() == null || strtotime($announcement->getDateExpire()) > time()) {
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->assign('announcement', $announcement);
             if ($announcement->getTypeId() == null) {
                 $templateMgr->assign('announcementTitle', $announcement->getAnnouncementTitle());
             } else {
                 $templateMgr->assign('announcementTitle', $announcement->getAnnouncementTypeName() . ": " . $announcement->getAnnouncementTitle());
             }
             $templateMgr->append('pageHierarchy', array(Request::url(null, 'announcement'), 'announcement.announcements'));
             $templateMgr->display('announcement/view.tpl');
         } else {
             Request::redirect(null, null, 'announcement');
         }
     } else {
         Request::redirect(null, null, 'announcement');
     }
 }
Ejemplo n.º 2
0
 /**
  * Display a list of announcement types for the current context.
  */
 function announcementTypes()
 {
     $this->validate();
     AnnouncementHandler::setupTemplate(true);
     $rangeInfo =& Handler::getRangeInfo('announcementTypes', array());
     while (true) {
         $announcementTypes =& $this->_getAnnouncementTypes($rangeInfo);
         if ($announcementTypes->isInBounds()) {
             break;
         }
         unset($rangeInfo);
         $rangeInfo =& $announcementTypes->getLastPageRangeInfo();
     }
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('announcementTypes', $announcementTypes);
     $templateMgr->display('manager/announcement/announcementTypes.tpl');
 }
 /**
  * Save changes to an announcement type.
  */
 function updateAnnouncementType()
 {
     parent::validate();
     import('manager.form.AnnouncementTypeForm');
     $journal =& Request::getJournal();
     $typeId = Request::getUserVar('typeId') == null ? null : (int) Request::getUserVar('typeId');
     $announcementTypeDao =& DAORegistry::getDAO('AnnouncementTypeDAO');
     if ($typeId != null && $announcementTypeDao->getAnnouncementTypeJournalId($typeId) == $journal->getJournalId() || $typeId == null) {
         $announcementTypeForm =& new AnnouncementTypeForm($typeId);
         $announcementTypeForm->readInputData();
         if ($announcementTypeForm->validate()) {
             $announcementTypeForm->execute();
             if (Request::getUserVar('createAnother')) {
                 Request::redirect(null, null, 'createAnnouncementType');
             } else {
                 Request::redirect(null, null, 'announcementTypes');
             }
         } else {
             AnnouncementHandler::setupTemplate(true);
             $templateMgr =& TemplateManager::getManager();
             $templateMgr->append('pageHierarchy', array(Request::url(null, 'manager', 'announcementTypes'), 'manager.announcementTypes'));
             if ($typeId == null) {
                 $templateMgr->assign('announcementTypeTitle', 'manager.announcementTypes.createTitle');
             } else {
                 $templateMgr->assign('announcementTypeTitle', 'manager.announcementTypes.editTitle');
             }
             $announcementTypeForm->display();
         }
     } else {
         Request::redirect(null, null, 'announcementTypes');
     }
 }
 /**
  * Display a list of announcement types for the current context.
  */
 function announcementTypes()
 {
     // FIXME: Remove call to validate() when all ManagerHandler implementations
     // (across all apps) have been migrated to the authorize() authorization approach.
     $this->validate();
     AnnouncementHandler::setupTemplate(true);
     $rangeInfo =& Handler::getRangeInfo('announcementTypes', array());
     while (true) {
         $announcementTypes =& $this->_getAnnouncementTypes($rangeInfo);
         if ($announcementTypes->isInBounds()) {
             break;
         }
         unset($rangeInfo);
         $rangeInfo =& $announcementTypes->getLastPageRangeInfo();
     }
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('announcementTypes', $announcementTypes);
     $templateMgr->display('manager/announcement/announcementTypes.tpl');
 }