Allow completely disabling the edit history
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 16 Oct 2014 20:41:58 +0000 (22:41 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 16 Oct 2014 20:41:58 +0000 (22:41 +0200)
com.woltlab.wcf/option.xml
com.woltlab.wcf/userGroupOption.xml
wcfsetup/install/files/lib/acp/form/UserContentRevertChangesForm.class.php
wcfsetup/install/files/lib/data/edit/history/entry/EditHistoryEntryAction.class.php
wcfsetup/install/files/lib/page/EditHistoryPage.class.php
wcfsetup/install/files/lib/system/clipboard/action/UserContentClipboardAction.class.php
wcfsetup/install/files/lib/system/cronjob/DailyCleanUpCronjob.class.php
wcfsetup/install/files/lib/system/edit/EditHistoryManager.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index c68a390f9f8193d44092b239bb85b41c43de92ba..eeee94008dac5773c40255c5e1d02f828f1c4338 100644 (file)
@@ -917,6 +917,12 @@ memcached:cache_source_memcached_host]]></enableoptions>
                        <!-- /message.general -->
                        
                        <!-- message.general.edit -->
+                       <option name="module_edit_history">
+                               <categoryname>message.general.edit</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>1</defaultvalue>
+                               <enableoptions>edit_history_expiration</enableoptions>
+                       </option>
                        <option name="edit_history_expiration">
                                <categoryname>message.general.edit</categoryname>
                                <optiontype>integer</optiontype>
index d62b5d392cfa29acfa3d85fe431f2247ef21c101..e8290f32fe010f4e60283827f3566c72ff0fd4f2 100644 (file)
@@ -710,6 +710,7 @@ png]]></defaultvalue>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
                                <usersonly>1</usersonly>
+                               <options>module_edit_history</options>
                        </option>
                        
                        <option name="admin.content.label.canManageLabel">
index 1415ad184b90ad4347c5127fa0af4da9ee00d214..a6ab8027da443d908900de18f1c62384538e68ba 100644 (file)
@@ -19,6 +19,11 @@ use wcf\system\WCF;
  * @category   Community Framework
  */
 class UserContentRevertChangesForm extends AbstractForm {
+       /**
+        * @see \wcf\page\AbstractPage::$neededModules
+        */
+       public $neededModules = array('MODULE_EDIT_HISTORY');
+
        /**
         * @see \wcf\page\AbstractPage::$neededPermissions
         */
index c6bc6ba0f22e06d696d63d0324190758711b2e53..5382c0bb3b83e038092201a0672710f8fd3d3f0d 100644 (file)
@@ -2,6 +2,7 @@
 namespace wcf\data\edit\history\entry;
 use wcf\data\object\type\ObjectTypeCache;
 use wcf\data\AbstractDatabaseObjectAction;
+use wcf\system\exception\IllegalLinkException;
 
 /**
  * Executes edit history entry-related actions.
@@ -23,6 +24,10 @@ class EditHistoryEntryAction extends AbstractDatabaseObjectAction {
         * Checks permissions to revert.
         */
        public function validateRevert() {
+               if (!MODULE_EDIT_HISTORY) {
+                       throw new IllegalLinkException();
+               }
+               
                $historyEntry = $this->getSingleObject();
                
                $objectType = ObjectTypeCache::getInstance()->getObjectType($historyEntry->objectTypeID);
index 8a8ff0370d7785cc3c0f27caf5482b304132b04b..7f6df4bb80ad5dc9f125e6399ff0e0760009eb38 100644 (file)
@@ -21,6 +21,11 @@ use wcf\util\StringUtil;
  * @category   Community Framework
  */
 class EditHistoryPage extends AbstractPage {
+       /**
+        * @see \wcf\page\AbstractPage::$neededModules
+        */
+       public $neededModules = array('MODULE_EDIT_HISTORY');
+       
        /**
         * DatabaseObjectList object
         * @var \wcf\data\DatabaseObjectList
index e43337b4e126f2866bcc0982b687594ad72b292f..a79e2e03f605b8302031198b8045fec0fa3be2c6 100644 (file)
@@ -55,11 +55,15 @@ class UserContentClipboardAction extends AbstractClipboardAction {
        }
        
        /**
-        * Returns the ids of the users which can be enabled.
+        * Returns the ids of the users whose edits can be reverted.
         * 
         * @return      array<integer>
         */
-       protected function validateRevertChanges() {
+       protected function validateRevertContentChanges() {
+               if (!MODULE_EDIT_HISTORY) {
+                       return array();
+               }
+               
                // check permissions
                if (!WCF::getSession()->getPermission('admin.content.canBulkRevertContentChanges')) {
                        return array();
index 7cf64836a7f9828eedaa8090eb2da3e9068c30c4..33f86b999b2f324b78ddde5926217c03900d009a 100644 (file)
@@ -126,13 +126,21 @@ class DailyCleanUpCronjob extends AbstractCronjob {
                ));
                
                // clean up expired edit history entries
-               if (EDIT_HISTORY_EXPIRATION) {
-                       $sql = "DELETE FROM     wcf".WCF_N."_edit_history_entry
-                               WHERE           obsoletedAt < ?";
+               if (MODULE_EDIT_HISTORY) {
+                       if (EDIT_HISTORY_EXPIRATION) {
+                               $sql = "DELETE FROM     wcf".WCF_N."_edit_history_entry
+                                       WHERE           obsoletedAt < ?";
                                $statement = WCF::getDB()->prepareStatement($sql);
                                $statement->execute(array(
                                        (TIME_NOW - 86400 * EDIT_HISTORY_EXPIRATION)
                                ));
+                       }
+               }
+               else {
+                       // edit history is disabled, prune old versions
+                       $sql = "DELETE FROM     wcf".WCF_N."_edit_history_entry";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       $statement->execute();
                }
                
                // clean up user authentication failure log
index cbfb8a2926a4a73967423ab4b624f35a20cf5ad5..d499f1cff3a49c05f528f0af3a0fcf56bf02bd69 100644 (file)
@@ -58,6 +58,9 @@ class EditHistoryManager extends SingletonFactory {
         * @param       integer         $obsoletedByUserID      The userID of the user that forced this entry to become outdated
         */
        public function add($objectType, $objectID, $message, $time, $userID, $username, $editReason, $obsoletedByUserID) {
+               // no op, if edit history is disabled
+               if (!MODULE_EDIT_HISTORY) return;
+               
                // save new entry
                $sql = "INSERT INTO     wcf".WCF_N."_edit_history_entry
                                        (objectTypeID, objectID, message, time, obsoletedAt, userID, username, editReason, obsoletedByUserID)
index 37d925f5c6758728da239a07655cf791aacab28a..4b75c172d771c199025b44bc042b33f751136bc0 100644 (file)
                <item name="wcf.acp.option.enable_share_buttons"><![CDATA[Buttons zum Teilen von Inhalten anzeigen]]></item>
                <item name="wcf.acp.option.share_buttons_show_count"><![CDATA[Anzahl der Teilungen anzeigen]]></item>
                <item name="wcf.acp.option.category.message.general.edit"><![CDATA[Bearbeitungen]]></item>
+               <item name="wcf.acp.option.module_edit_history"><![CDATA[Bearbeitungsverlauf aktivieren]]></item>
+               <item name="wcf.acp.option.module_edit_history.description"><![CDATA[Speichert die alten Versionen von Benutzerinhalten.]]]></item>
                <item name="wcf.acp.option.edit_history_expiration"><![CDATA[Speicherzeit]]></item>
                <item name="wcf.acp.option.edit_history_expiration.description"><![CDATA[Zeitraum, nachdem alte Einträge aus dem Bearbeitungsverlauf entfernt werden [Zeitraum in Tagen, 0 um die Entfernung gänzlich zu deaktivieren]]]></item>
                <item name="wcf.acp.option.github_public_key"><![CDATA[GitHub Client ID]]></item>
index f286b55b4102664a793ef3999c30c169d62b12e5..e3afdcbc3268fa794104342888f93e069abf6bea 100644 (file)
@@ -851,6 +851,8 @@ Examples for medium ID detection:
                <item name="wcf.acp.option.enable_share_buttons"><![CDATA[Show content share button]]></item>
                <item name="wcf.acp.option.share_buttons_show_count"><![CDATA[Show number of shares]]></item>
                <item name="wcf.acp.option.category.message.general.edit"><![CDATA[Edits]]></item>
+               <item name="wcf.acp.option.edit_history_enabled"><![CDATA[Enable Edit History]]></item>
+               <item name="wcf.acp.option.edit_history_enabled.description"><![CDATA[Stores old versions of user created items.]]]></item>
                <item name="wcf.acp.option.edit_history_expiration"><![CDATA[Storage time]]></item>
                <item name="wcf.acp.option.edit_history_expiration.description"><![CDATA[Items in the edit history will be discarded if they are older than the given period. [time in days, 0 to disable]]]></item>
                <item name="wcf.acp.option.github_public_key"><![CDATA[GitHub Client ID]]></item>