/**
  * @see	\wcf\system\edit\IHistorySavingObjectTypeProvider::checkPermissions()
  */
 public function checkPermissions(IHistorySavingObject $object)
 {
     if (!$object instanceof HistorySavingEntry) {
         return false;
     }
     if (!$object->canEdit()) {
         throw new PermissionDeniedException();
     }
 }
Пример #2
0
 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['oldID'])) {
         $this->oldID = intval($_REQUEST['oldID']);
         $this->old = new EditHistoryEntry($this->oldID);
         if (!$this->old->entryID) {
             throw new IllegalLinkException();
         }
         if (isset($_REQUEST['newID']) && $_REQUEST['newID'] !== 'current') {
             $this->newID = intval($_REQUEST['newID']);
             $this->new = new EditHistoryEntry($this->newID);
             if (!$this->new->entryID) {
                 throw new IllegalLinkException();
             }
         }
         // if new version isn't 'current' check whether they are comparable
         if ($this->new) {
             // different objectTypes cannot be compared
             if ($this->old->objectTypeID != $this->new->objectTypeID) {
                 throw new IllegalLinkException();
             }
             // different items cannot be compared
             if ($this->old->objectID != $this->new->objectID) {
                 throw new IllegalLinkException();
             }
         }
         $this->objectID = $this->old->objectID;
         $this->objectType = ObjectTypeCache::getInstance()->getObjectType($this->old->objectTypeID);
     } else {
         if (isset($_REQUEST['objectID']) && isset($_REQUEST['objectType'])) {
             $this->objectID = intval($_REQUEST['objectID']);
             $this->objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.edit.historySavingObject', $_REQUEST['objectType']);
         } else {
             throw new IllegalLinkException();
         }
     }
     if (!$this->objectType) {
         throw new IllegalLinkException();
     }
     $processor = $this->objectType->getProcessor();
     $this->object = $processor->getObjectByID($this->objectID);
     if (!$this->object->getObjectID()) {
         throw new IllegalLinkException();
     }
     $processor->checkPermissions($this->object);
     $this->activeMenuItem = $processor->getActivePageMenuItem();
     $this->object->addBreadcrumbs();
     if (isset($_REQUEST['newID']) && !$this->new) {
         $this->new = $this->object;
         $this->newID = 'current';
     }
     if (!empty($_POST)) {
         HeaderUtil::redirect(LinkHandler::getInstance()->getLink('EditHistory', array('objectID' => $this->objectID, 'objectType' => $this->objectType->objectType, 'newID' => $this->newID, 'oldID' => $this->oldID)));
         exit;
     }
 }