Ejemplo n.º 1
0
 function run()
 {
     //find TO revision
     try {
         //retrieve pagegroup
         $nPageGroupId = (int) AnwEnv::_GET("pagegroup", AnwEnv::_POST("pagegroup"));
         if (!$nPageGroupId) {
             //special case: we may have passed a pageid (ie: from lastchanges, for better performances avoiding loading pagegroup info)
             $nPageId = (int) AnwEnv::_GET("page");
             if ($nPageId) {
                 $oExistingPageTmp = AnwPage::getLastPageRevision($nPageId);
                 //high queries consuming, not 100% cached...
                 if ($oExistingPageTmp->exists()) {
                     $nPageGroupId = $oExistingPageTmp->getPageGroup()->getId();
                 }
                 unset($oExistingPageTmp);
             }
             if (!$nPageGroupId) {
                 throw new AnwBadCallException();
             }
         }
         $oPageGroup = new AnwPageGroup($nPageGroupId);
         if (!$oPageGroup->exists()) {
             throw new AnwBadCallException("pagegroup not found for revert");
         }
         //get valid changeid
         $aoPageGroupChangesById = AnwStorage::getLastChanges(false, 0, null, null, null, null, $oPageGroup);
         $nRevToChangeId = (int) AnwEnv::_GET("revto", AnwEnv::_POST("revto"));
         //may be null when coming from action_revertpage
         if (!$nRevToChangeId || !array_key_exists($nRevToChangeId, $aoPageGroupChangesById)) {
             //get last changeid from this pagegroup
             $oChangeReference = reset($aoPageGroupChangesById);
             $nRevToChangeId = $oChangeReference->getChangeId();
         }
     } catch (AnwException $e) {
         throw new AnwBadCallException();
     }
     $this->setTitle($this->t_("title"));
     $aaRevertPlan = $this->generateRevertPlan($oPageGroup, $nRevToChangeId);
     if (AnwEnv::_POST("submit") && $nRevToChangeId > 0) {
         $this->doRevert($oPageGroup, $aaRevertPlan);
     } else {
         $this->showFormRevert($oPageGroup, $aaRevertPlan, $nRevToChangeId);
     }
 }
Ejemplo n.º 2
0
 /**
  * If we come from action "history", returns the page requested.
  */
 protected function getPageForHistory()
 {
     static $oPageForHistory = null, $bInitialized = false;
     // only initialize first time for performances saving
     if (!$bInitialized) {
         // only look for page if no pagegroup was requested - important for checkActionAllowed()
         if (!$this->getPageGroupForHistory()) {
             $nPageId = (int) AnwEnv::_GET("page");
             if ($nPageId > 0) {
                 try {
                     $oPageTmp = AnwPage::getLastPageRevision($nPageId);
                 } catch (AnwPageNotFoundException $e) {
                     throw new AnwBadCallException();
                 }
                 $oPageTmp->setSkipLoadingContent(true);
                 if ($oPageTmp->exists()) {
                     $oPageForHistory = $oPageTmp;
                 }
             }
         }
         $bInitialized = true;
     }
     return $oPageForHistory;
 }