<interfacename>wcf\system\category\ICategoryType</interfacename>
<name>com.woltlab.wcf.category</name>
</definition>
+
+ <definition>
+ <name>com.woltlab.wcf.modifiableContent</name>
+ </definition>
</import>
</data>
\ No newline at end of file
--- /dev/null
+<?php
+namespace wcf\data\modification\log;
+use wcf\data\DatabaseObject;
+
+/**
+ * Represents a modification log.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2012 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage data.modification.log
+ * @category Community Framework
+ */
+class ModificationLog extends DatabaseObject {
+ /**
+ * @see wcf\data\DatabaseObject::$databaseTableName
+ */
+ protected static $databaseTableName = 'modification_log';
+
+ /**
+ * @see wcf\data\DatabaseObject::$databaseTableIndexName
+ */
+ protected static $databaseTableIndexName = 'logID';
+}
--- /dev/null
+<?php
+namespace wcf\data\modification\log;
+use wcf\data\AbstractDatabaseObjectAction;
+
+/**
+ * Executes modification log-related actions.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2012 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage data.modification.log
+ * @category Community Framework
+ */
+class ModificationLogAction extends AbstractDatabaseObjectAction { }
--- /dev/null
+<?php
+namespace wcf\data\modification\log;
+use wcf\data\DatabaseObjectEditor;
+
+/**
+ * Provides functions to edit modification logs.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2012 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage data.modification.log
+ * @category Community Framework
+ */
+class ModificationLogEditor extends DatabaseObjectEditor {
+ /**
+ * @see wcf\data\DatabaseObjectDecorator::$baseClass
+ */
+ protected static $baseClass = 'wcf\data\modification\log\ModificationLog';
+}
--- /dev/null
+<?php
+namespace wcf\data\modification\log;
+use wcf\data\DatabaseObjectList;
+
+/**
+ * Represents a list of modification logs.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2012 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage data.modification.log
+ * @category Community Framework
+ */
+class ModificationLogList extends DatabaseObjectList {
+ /**
+ * @see wcf\data\DatabaseObjectList::$className
+ */
+ public $className = 'wcf\data\modification\log\ModificationLog';
+}
--- /dev/null
+<?php
+namespace wcf\system\log\modification;
+use wcf\data\modification\log\ModificationLogEditor;
+use wcf\data\object\type\ObjectTypeCache;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\SystemException;
+use wcf\system\SingletonFactory;
+use wcf\system\WCF;
+
+/**
+ * Handles modification logs.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2012 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.log.modification
+ * @category Community Framework
+ */
+class ModificationLogHandler extends SingletonFactory {
+ /**
+ * list of object types
+ * @var array<wcf\data\object\type\ObjectType>
+ */
+ protected $cache = array();
+
+ /**
+ * @see wcf\system\SingletonFactory::init()
+ */
+ protected function init() {
+ $this->cache = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.modifiableContent');
+ }
+
+ /**
+ * Returns object type by object type name.
+ *
+ * @param string $objectType
+ * @return wcf\data\object\type\ObjectType
+ */
+ public function getObjectType($objectType) {
+ foreach ($this->cache as $objectTypeObj) {
+ if ($objectTypeObj->objectType == $objectType) {
+ return $objectTypeObj;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Adds a new entry to modification log.
+ *
+ * @param string $objectType
+ * @param integer $objectID
+ * @param string $action
+ * @param array $data
+ * @param integer $time
+ * @param integer $userID
+ * @param string $username
+ * @return wcf\data\modification\log\ModificationLog
+ */
+ public function add($objectType, $objectID, $action, array $data = array(), $time = TIME_NOW, $userID = null, $username = null) {
+ $objectType = $this->getObjectType($objectType);
+ if ($objectType === null) {
+ throw new SystemException("Object type '".$objectType."' not found within definition 'com.woltlab.wcf.modifiableContent'");
+ }
+
+ return ModificationLogEditor::create(array(
+ 'objectTypeID' => $objectType->objectTypeID,
+ 'objectID' => $objectID,
+ 'userID' => ($userID === null ? WCF::getUser()->userID : $userID),
+ 'username' => ($username === null ? WCF::getUser()->username : $username),
+ 'time' => $time,
+ 'data' => serialize($data)
+ ));
+ }
+
+ /**
+ * Removes log entries.
+ *
+ * @param string $objectType
+ * @param array<integer> $objectIDs
+ */
+ public function remove($objectType, array $objectIDs) {
+ $objectType = $this->getObjectType($objectType);
+ if ($objectType === null) {
+ throw new SystemException("Object type '".$objectType."' not found within definition 'com.woltlab.wcf.modifiableContent'");
+ }
+
+ $conditions = new PreparedStatementConditionBuilder();
+ $conditions->add("objectTypeID = ?", array($objectType->objectTypeID));
+ $conditions->add("objectID IN (?)", array($objectIDs));
+
+ $sql = "DELETE FROM wcf".WCF_N."_modification_log
+ ".$conditions;
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute($conditions->getParameters());
+ }
+}
\ No newline at end of file
UNIQUE KEY languageID (languageID, packageID)
);
+DROP TABLE IF EXISTS wcf1_modification_log;
+CREATE TABLE wcf1_modification_log (
+ logID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ objectTypeID INT(10) NOT NULL,
+ objectID INT(10) NOT NULL,
+ userID INT(10),
+ username VARCHAR(255) NOT NULL DEFAULT '',
+ time INT(10) NOT NULL DEFAULT 0,
+ action VARCHAR(80) NOT NULL,
+ additionalData MEDIUMTEXT
+);
+
DROP TABLE IF EXISTS wcf1_object_type;
CREATE TABLE wcf1_object_type (
objectTypeID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
ALTER TABLE wcf1_language_to_package ADD FOREIGN KEY (languageID) REFERENCES wcf1_language (languageID) ON DELETE CASCADE;
ALTER TABLE wcf1_language_to_package ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;
+ALTER TABLE wcf1_modification_log ADD FOREIGN KEY (objectTypeID) REFERENCES wcf1_object_type (objectTypeID) ON DELETE CASCADE;
+ALTER TABLE wcf1_modification_log ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
+
ALTER TABLE wcf1_object_type ADD FOREIGN KEY (definitionID) REFERENCES wcf1_object_type_definition (definitionID) ON DELETE CASCADE;
ALTER TABLE wcf1_object_type ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;