Skip to content

Commit

Permalink
*7092* Introduced method for base announcement handler retrieve conte…
Browse files Browse the repository at this point in the history
…xt id
  • Loading branch information
beghelli committed Feb 14, 2012
1 parent bd4e879 commit 91abe69
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions pages/manager/AnnouncementHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,28 @@ function announcementTypes($args, &$request) {
parent::announcementTypes($args, $request);
}

/**
* @see PKPAnnouncementHandler::getContextId()
*/
function getContextId(&$request) {
$journal =& $request->getJournal();
if ($journal) {
return $journal->getId();
} else {
return null;
}

}

/**
* @see PKPAnnouncementHandler::_getAnnouncements
* @param $request PKPRequest
* @param $rangeInfo Object optional
*/
function &_getAnnouncements($request, $rangeInfo = null) {
$journal =& $request->getJournal();
$journalId = $this->getContextId($request);
$announcementDao =& DAORegistry::getDAO('AnnouncementDAO');
$announcements =& $announcementDao->getAnnouncementsByAssocId(ASSOC_TYPE_JOURNAL, $journal->getId(), $rangeInfo);
$announcements =& $announcementDao->getAnnouncementsByAssocId(ASSOC_TYPE_JOURNAL, $journalId, $rangeInfo);

return $announcements;
}
Expand All @@ -65,9 +78,9 @@ function &_getAnnouncements($request, $rangeInfo = null) {
* @param $rangeInfo object optional
*/
function &_getAnnouncementTypes(&$request, $rangeInfo = null) {
$journal =& $request->getJournal();
$journalId = $this->getContextId($request);
$announcementTypeDao =& DAORegistry::getDAO('AnnouncementTypeDAO');
$announcements =& $announcementTypeDao->getAnnouncementTypesByAssocId(ASSOC_TYPE_JOURNAL, $journal->getId(), $rangeInfo);
$announcements =& $announcementTypeDao->getAnnouncementTypesByAssocId(ASSOC_TYPE_JOURNAL, $journalId, $rangeInfo);

return $announcements;
}
Expand All @@ -84,10 +97,10 @@ function _announcementIsValid($request, $announcementId) {
$announcementDao =& DAORegistry::getDAO('AnnouncementDAO');
$announcement =& $announcementDao->getAnnouncement($announcementId);

$journal =& $request->getJournal();
if ( $announcement && $journal
$journalId = $this->getContextId($request);
if ( $announcement && $journalId
&& $announcement->getAssocType() == ASSOC_TYPE_JOURNAL
&& $announcement->getAssocId() == $journal->getId())
&& $announcement->getAssocId() == $journalId)
return true;

return false;
Expand All @@ -100,9 +113,9 @@ function _announcementIsValid($request, $announcementId) {
* return bool
*/
function _announcementTypeIsValid(&$request, $typeId) {
$journal =& $request->getJournal();
$journalId = $this->getContextId($request);
$announcementTypeDao =& DAORegistry::getDAO('AnnouncementTypeDAO');
return (($typeId != null && $announcementTypeDao->getAnnouncementTypeAssocId($typeId) == $journal->getId()) || $typeId == null);
return (($typeId != null && $announcementTypeDao->getAnnouncementTypeAssocId($typeId) == $journalId) || $typeId == null);
}
}

Expand Down

0 comments on commit 91abe69

Please sign in to comment.