Add revert to EditHistoryEntryAction
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 2 Jul 2014 15:44:23 +0000 (17:44 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 9 Jul 2014 19:58:56 +0000 (21:58 +0200)
wcfsetup/install/files/lib/data/edit/history/entry/EditHistoryEntryAction.class.php

index d6c004ebeff892dc6c80ba84eee99082842af4f2..bec522d0a0e2be545c65caa42151e84bc4f63fe9 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\data\edit\history\entry;
+use wcf\data\object\type\ObjectTypeCache;
 use wcf\data\AbstractDatabaseObjectAction;
 
 /**
@@ -17,4 +18,23 @@ class EditHistoryEntryAction extends AbstractDatabaseObjectAction {
        * @see  \wcf\data\AbstractDatabaseObjectAction::$className
        */
        protected $className = 'wcf\data\edit\history\entry\EditHistoryEntryEditor';
+       
+       /**
+        * Checks permissions to revert.
+        */
+       public function validateRevert() {
+               $historyEntry = $this->getSingleObject();
+               
+               $objectType = ObjectTypeCache::getInstance()->getObjectType($historyEntry->objectTypeID);
+               $processor = $objectType->getProcessor();
+               $object = $this->getSingleObject()->getObject();
+               $processor->checkPermissions($object);
+       }
+       
+       /**
+        * Reverts the objects back to this history entry.
+        */
+       public function revert() {
+               $this->getSingleObject()->getObject()->revertVersion($this->getSingleObject()->getDecoratedObject());
+       }
 }