Add edit history entry expiration
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 9 Jul 2014 18:43:45 +0000 (20:43 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 9 Jul 2014 19:59:03 +0000 (21:59 +0200)
com.woltlab.wcf/option.xml
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
wcfsetup/setup/db/install.sql

index fbedf945fa3e86761b12574c38d7269ec3f262ab..6cf09935d5093b7ebc619c34715b1b1b194f7444 100644 (file)
                                                <parent>message.general</parent>
                                                <options>module_poll</options>
                                        </category>
+                                       <category name="message.general.edit">
+                                               <parent>message.general</parent>
+                                       </category>
                                
                                <category name="message.attachment">
                                        <parent>message</parent>
@@ -851,6 +854,15 @@ no:!cache_source_memcached_host]]></enableoptions>
                        </option>
                        <!-- /message.general -->
                        
+                       <!-- message.general.edit -->
+                       <option name="edit_history_expiration">
+                               <categoryname>message.general.edit</categoryname>
+                               <optiontype>integer</optiontype>
+                               <defaultvalue>90</defaultvalue>
+                               <minvalue>0</minvalue>
+                       </option>
+                       <!-- /message.general.edit -->
+                       
                        <!-- message.general.share -->
                        <option name="enable_share_buttons">
                                <categoryname>message.general.share</categoryname>
index fcecee03d8b76f71e44d46d8f99314623d6f6867..2c6dbfc57b21e22afadcf95b894a28e42305bf44 100644 (file)
@@ -125,6 +125,16 @@ class DailyCleanUpCronjob extends AbstractCronjob {
                        (TIME_NOW - 86400)
                ));
                
+               // clean up expired edit history entries
+               if (EDIT_HISTORY_EXPIRATION) {
+                       $sql = "DELETE FROM     wcf".WCF_N."_edit_history_entry
+                               WHERE           insertionTime < ?";
+                               $statement = WCF::getDB()->prepareStatement($sql);
+                               $statement->execute(array(
+                                       (TIME_NOW - 86400 * EDIT_HISTORY_EXPIRATION)
+                               ));
+               }
+               
                // clean up user authentication failure log
                if (ENABLE_USER_AUTHENTICATION_FAILURE) {
                        $sql = "DELETE FROM     wcf".WCF_N."_user_authentication_failure
index a52f118a31174ec2bd56ab652f8986c65df180d3..2748a837ffbd8e496144c615efe452606ba39650 100644 (file)
@@ -58,10 +58,10 @@ class EditHistoryManager extends SingletonFactory {
        public function add($objectType, $objectID, $message, $time, $userID, $username, $editReason) {
                // save new entry
                $sql = "INSERT INTO     wcf".WCF_N."_edit_history_entry
-                                       (objectTypeID, objectID, message, time, userID, username, editReason)
-                       VALUES          (?, ?, ?, ?, ?, ?, ?)";
+                                       (objectTypeID, objectID, message, time, insertionTime, userID, username, editReason)
+                       VALUES          (?, ?, ?, ?, ?, ?, ?, ?)";
                $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array($this->getObjectTypeID($objectType), $objectID, $message, $time, $userID, $username, $editReason));
+               $statement->execute(array($this->getObjectTypeID($objectType), $objectID, $message, $time, TIME_NOW, $userID, $username, $editReason));
        }
        
        /**
index e584042b22894cf0c3299125767dae10f2484857..c5cf9d5a1698fe5a56d0ec0d22f9d0b334240674 100644 (file)
                <item name="wcf.acp.option.show_signature_default_value"><![CDATA[Signatur anzeigen [Vorgabewert]]]></item>
                <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>
+               <iten name="wcf.acp.option.edit_history_expiration"><![CDATA[Speicherzeit]]></item>
+               <iten name="wcf.acp.option.edit_history_expiration.description"><![CDATA[Zeitraum, nachdem alte Einträge aus dem Bearbeitungsverlauf entfernt werden [Zeitraum in Tagen]]]></item>
                <item name="wcf.acp.option.github_public_key"><![CDATA[GitHub Client ID]]></item>
                <item name="wcf.acp.option.github_public_key.description"><![CDATA[Sie können Ihre Client ID und Ihr Client Secret bei <a href="{@$__wcf->getPath()}acp/dereferrer.php?url={'https://github.com/settings/applications'|rawurlencode}" class="externalURL">GitHub</a> anfordern. Die Callback URL ist: {link controller="GithubAuth" forceFrontend=true appendSession=false}{/link}]]></item>
                <item name="wcf.acp.option.github_private_key"><![CDATA[GitHub Client Secret]]></item>
index 7ee1079eccb96bf7b7b137e3b64b59ab873d5cf0..0c5c8c073c9e7a84b90c25aa42911741047bf94d 100644 (file)
@@ -842,6 +842,9 @@ Examples for medium ID detection:
                <item name="wcf.acp.option.show_signature_default_value"><![CDATA[Show signatures [default value]]]></item>
                <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>
+               <iten name="wcf.acp.option.edit_history_expiration"><![CDATA[Storage time]]></item>
+               <iten 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]]]></item>
                <item name="wcf.acp.option.github_public_key"><![CDATA[GitHub Client ID]]></item>
                <item name="wcf.acp.option.github_public_key.description"><![CDATA[You can obtain both your Client ID and Client Secret at <a href="{@$__wcf->getPath()}acp/dereferrer.php?url={'https://github.com/settings/applications'|rawurlencode}" class="externalURL">GitHub</a>. The Callback URL is: {link controller="GithubAuth" forceFrontend=true appendSession=false}{/link}]]></item>
                <item name="wcf.acp.option.github_private_key"><![CDATA[GitHub Client Secret]]></item>
index 59b4f6d5d6d71cbd24b771bed7c153a0ac25c77c..ac4dae266cfbfb55c211202fdfee11323a74b7d2 100644 (file)
@@ -357,7 +357,8 @@ CREATE TABLE wcf1_edit_history_entry (
        objectID INT(10) NOT NULL,
        userID INT(10),
        username VARCHAR(255) NOT NULL DEFAULT '',
-       time INT(10) NOT NULL DEFAULT 0,
+       time INT(10) NOT NULL DEFAULT 0, -- time the version was created, displayed to the user
+       insertionTime INT(10) NOT NULL DEFAULT 0, -- time the version was inserted into the edit history, used for clean up
        message MEDIUMTEXT,
        editReason TEXT,