From: Tim Düsterhus Date: Thu, 26 Jun 2014 19:29:19 +0000 (+0200) Subject: Add EditHistoryManager X-Git-Tag: 2.1.0_Alpha_1~590^2~12 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fb5d4992f5121ef814d81d7d94b22aa3349458da;p=GitHub%2FWoltLab%2FWCF.git Add EditHistoryManager --- 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)); + } +}