private function showFormRevert($oPageGroup, $aaRevertPlan, $nRevToChangeId) { $aoChanges = array(); $aoChangesUnfiltered = AnwStorage::getLastChanges(false, 0, null, null, null, null, $oPageGroup); foreach ($aoChangesUnfiltered as $oChange) { // only keep "revertable" changes if ($oChange->isRevertAvailable()) { $aoChanges[] = $oChange; } } $sHistoryPageGroupLink = false; if (AnwCurrentSession::isActionGlobalAllowed("lastchanges")) { $sHistoryPageGroupLink = AnwUtils::aLink("lastchanges", array("pagegroup" => $oPageGroup->getId())); } $this->out .= $this->tpl()->formRevert($this->linkMe(array("pagegroup" => $oPageGroup->getId())), $aoChanges, $nRevToChangeId, $sHistoryPageGroupLink); foreach ($aaRevertPlan['DELETE'] as $oPageForDelete) { $this->out .= $this->tpl()->simulateDelete($oPageForDelete->getLang(), $oPageForDelete->getName()); } foreach ($aaRevertPlan['REVERT'] as $aoRevertPages) { $oPageCurrent = $aoRevertPages[0]; $oPageForRevert = $aoRevertPages[1]; if ($oPageCurrent->isGlobalAndViewActionAllowed('diff')) { $sImgDiff = AnwUtils::xQuote(AnwUtils::pathImg("diff.gif")); $sAltDiff = AnwUtils::xQuote(self::g_("change_diff_link")); $sLnkDiff = AnwUtils::xQuote(AnwUtils::link($oPageCurrent, "diff", array("page" => $oPageCurrent->getId(), "revfrom" => $oPageCurrent->getChangeId(), "revto" => $oPageForRevert->getChangeId()))); $sLnkDiff = <<<EOF <a href="{$sLnkDiff}" title="{$sAltDiff}" target="_blank"><img src="{$sImgDiff}" alt="{$sAltDiff}"/></a> EOF; } else { $sLnkDiff = ''; } $this->out .= $this->tpl()->simulateRevert($oPageCurrent->getLang(), $oPageCurrent->getName(), $oPageForRevert, $sLnkDiff); } foreach ($aaRevertPlan['RESTORE'] as $oPageForRestore) { $this->out .= $this->tpl()->simulateCreate($oPageForRestore); } foreach ($aaRevertPlan['KEEP'] as $oPageForKeep) { $this->out .= $this->tpl()->simulateKeep($oPageForKeep->getLang(), $oPageForKeep->getName()); } $this->out .= $this->tpl()->end(); }
function showHtml($aoChanges, $amAllChangeTypes, $amDisplayChangeTypes, $asAllLangs, $asDisplayLangs, $asAllClasses, $asDisplayClasses, $nStartPrev, $nStartNext, $sTitle, $bGrouped, $oPage, $oPageGroup) { $this->out .= $this->tpl()->lastchangesHeader($sTitle); $sUrl = AnwEnv::_SERVER('REQUEST_URI'); $sUrl = preg_replace("/&s=([0-9]*)/", "", $sUrl); //rss link $sRssLink = $sUrl; $sRssLink .= '&feed=rss2'; //without start $this->head($this->tpl()->headRss($sRssLink)); $this->out .= $this->tpl()->filterBefore($this->linkMe()); $nPageId = $oPage ? $oPage->getId() : null; $nPageGroupId = $oPageGroup ? $oPageGroup->getId() : null; $bShowHistoryColumn = $oPage ? false : true; //disable filters if a page is selected if (!$nPageId) { //filter lang $this->out .= $this->tpl()->filterLangs($asAllLangs, $asDisplayLangs); } if (!$nPageId && !$nPageGroupId) { //filter contentclass $this->out .= $this->tpl()->filterClass($asAllClasses, $asDisplayClasses); } //filter changes types $this->out .= $this->tpl()->filterChangeTypes($amAllChangeTypes, $amDisplayChangeTypes); //display mode $sHistoryPageGroupLink = false; if ($oPage && AnwCurrentSession::isActionGlobalAllowed($this->getName())) { $sHistoryPageGroupLink = AnwEnv::_SERVER('REQUEST_URI'); $sHistoryPageGroupLink = preg_replace("\$&page=([0-9]*)\$", "", $sHistoryPageGroupLink); $sHistoryPageGroupLink = preg_replace("\$&pagegroup=([0-9]*)\$", "", $sHistoryPageGroupLink); $sHistoryPageGroupLink .= '&pagegroup=' . $oPage->getPageGroup()->getId(); } $this->out .= $this->tpl()->filterAfter($bGrouped, $nPageId, $nPageGroupId, $sRssLink, $sHistoryPageGroupLink); //nav $sLatestLink = ""; $sPrevLink = ""; if ($nStartPrev >= 0) { $sPrevLink = $sUrl . '&s=' . $nStartPrev; if ($nStartPrev > 0) { $sLatestLink = $sUrl . '&s=0'; } } $sNextLink = $sUrl . '&s=' . $nStartNext; $this->out .= $this->tpl()->nav($sLatestLink, $sPrevLink, $sNextLink, $bShowHistoryColumn); foreach ($aoChanges as $i => $oChange) { $sType = AnwChange::changeTypei18n($oChange->getType()); //links $sLnkPage = '<span class="pageid">#' . $oChange->getPageId() . '</span>'; $sLnkDiff = '-'; if ($oChange->activePageExists()) { $sLnkPage = $oChange->getActivePage()->link(); //active link, if it exists } //diffs link if ($oChange->isGlobalAndViewActionAllowed('diff')) { if ($oChange->isDiffAvailable()) { $sImgDiff = AnwUtils::xQuote(AnwUtils::pathImg("diff.gif")); $sAltDiff = AnwUtils::xQuote(self::g_("change_diff_link")); $sLnkDiff = AnwUtils::xQuote(AnwUtils::alink("diff", array("page" => $oChange->getPageId(), "revto" => $oChange->getChangeId()))); $sLnkDiff = <<<EOF <a href="{$sLnkDiff}" title="{$sAltDiff}"><img src="{$sImgDiff}" alt="{$sAltDiff}"/></a> EOF; } } //history link $sLnkHistory = false; if ($bShowHistoryColumn) { $sLnkHistory = " - "; if ($oChange->isActionAllowed('history')) { $sImgHistory = AnwUtils::xQuote(AnwUtils::pathImg("history.gif")); $sAltHistory = AnwUtils::xQuote($this->t_("change_history_link")); $sLnkHistory = AnwUtils::xQuote(AnwUtils::alink("lastchanges", array("page" => $oChange->getPageId()))); $sLnkHistory = <<<EOF <a href="{$sLnkHistory}" title="{$sAltHistory}"><img src="{$sImgHistory}" alt="{$sAltHistory}"/></a> EOF; } } //revert link $sLnkRevert = " - "; if ($oChange->isGlobalAndViewActionAllowed('revert')) { if ($oChange->isRevertAvailable()) { $sImgRevert = AnwUtils::xQuote(AnwUtils::pathImg("revert.gif")); $sAltRevert = AnwUtils::xQuote(self::t_("change_revert_link")); $sLnkRevert = AnwUtils::xQuote(AnwUtils::alink("revert", array("page" => $oChange->getPageId(), "revto" => $oChange->getChangeId()))); //we pass pageid instead of pagegroupid for better performances... $sLnkRevert = <<<EOF <a href="{$sLnkRevert}" title="{$sAltRevert}"><img src="{$sImgRevert}" alt="{$sAltRevert}"/></a> EOF; } } //output $this->out .= $this->tpl()->lastchangesLine(Anwi18n::dateTime($oChange->getTime()), $sType, $oChange->getComment(), $oChange->getInfo(), $oChange->getUser()->getDisplayName(), $sLnkPage, $sLnkDiff, $sLnkHistory, $sLnkRevert, $oChange->getPageName(), $oChange->getPageLang()); } $this->out .= $this->tpl()->lastchangesFooter(); }
protected function checkActionAllowed() { if (!AnwCurrentSession::isActionGlobalAllowed($this->getName())) { throw new AnwAclException("You are not allowed to execute this action"); } }
function checkGlobalAndViewActionAllowed($sGlobalAction) { // check global action allowed // important: ask directly AnwCurrentSession, as getPage() may be null if (!AnwCurrentSession::isActionGlobalAllowed($sGlobalAction)) { throw new AnwAclException("permission denied on global action: " . $sGlobalAction); } // check view action allowed $this->checkActionAllowed('view'); }
/** * Special case for global actions which also require with the "view" right on a specific page. */ function checkGlobalAndViewActionAllowed($sGlobalAction) { // check global action allowed if (!AnwCurrentSession::isActionGlobalAllowed($sGlobalAction)) { throw new AnwAclException("permission denied on global action: " . $sGlobalAction); } // check view action allowed - skip translated percent permission $this->checkActionAllowed('view', true); }
function isActionAllowed() { return AnwCurrentSession::isActionGlobalAllowed($this->sActionName); }