From fb5d4992f5121ef814d81d7d94b22aa3349458da Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 26 Jun 2014 21:29:19 +0200 Subject: [PATCH] Add EditHistoryManager --- .../system/edit/EditHistoryManager.class.php | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 wcfsetup/install/files/lib/system/edit/EditHistoryManager.class.php diff --git a/wcfsetup/install/files/lib/system/edit/EditHistoryManager.class.php b/wcfsetup/install/files/lib/system/edit/EditHistoryManager.class.php new file mode 100644 index 0000000000..7565eeeacb --- /dev/null +++ b/wcfsetup/install/files/lib/system/edit/EditHistoryManager.class.php @@ -0,0 +1,66 @@ + +* @package com.woltlab.wcf +* @subpackage system.search +* @category Community Framework +*/ +class EditHistoryManager extends SingletonFactory { + /** + * list of available object types + * @var array + */ + protected $availableObjectTypes = array(); + + /** + * @see \wcf\system\SingletonFactory::init() + */ + protected function init() { + // get available object types + $this->availableObjectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.edit.historySavingObject'); + } + + /** + * Returns the id of the object type with the given name. + * + * @param string $objectType + * @return integer + */ + public function getObjectTypeID($objectType) { + if (!isset($this->availableObjectTypes[$objectType])) { + throw new SystemException("unknown object type '".$objectType."'"); + } + + return $this->availableObjectTypes[$objectType]->objectTypeID; + } + + /** + * Adds a new entry. + * + * @param string $objectType + * @param integer $objectID + * @param string $message + * @param integer $time + * @param integer $userID + * @param string $username + * @param string $editReason + */ + 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 (?, ?, ?, ?, ?, ?, ?)"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($this->getObjectTypeID($objectType), $objectID, $message, $time, $userID, $username, $editReason)); + } +} -- 2.20.1