/**
* Checks fields, prunes given array and returns it
- *
- * @return array
+ *
+ * @return array
*/
protected function prune(IRESTfulResponse $object) {
$prunedArray = array();
/**
* Tries to find class and returns class name and controller.
- *
- * @return array<string>
+ *
+ * @return array<string>
*/
protected function getClassData($controller, $application = 'wcf') {
$className = $application.'\\data\\'.$controller.'\\'.ucfirst($controller);
* @subpackage data
* @category Community Framework
*/
-abstract class VersionableDatabaseObject extends DatabaseObject {
+abstract class VersionableDatabaseObject extends DatabaseObject {
/**
* name of the versionable object type
* @var string
public $versionableObjectTypeName = '';
/**
- * Returns suffix of database tables.
+ * Returns suffix of the version database table.
*
* @return string
*/
}
/**
- * Returns name of index in version table.
+ * Returns name of index in version database table.
*
* @return string
*/
}
/**
- * Returns all versions of this database object
+ * Returns all versions of this database object.
*
* @return array<wcf\data\VersionableDatabaseObject>
*/
*/
abstract class VersionableDatabaseObjectAction extends AbstractDatabaseObjectAction {
/**
- * Validates restoring a version
+ * Validates restoring a version.
*/
public function validateRestoreRevision() {
parent::validateUpdate();
$this->readObjects();
}
- // get index name
- $indexName = call_user_func(array($this->className, 'getDatabaseTableIndexName'));
-
// get ids
$objectIDs = array();
foreach ($this->objects as $object) {
$this->readObjects();
}
- // get index name
- $indexName = call_user_func(array($this->className, 'getDatabaseTableIndexName'));
-
if (isset($this->parameters['data'])) {
foreach ($this->objects as $object) {
- $this->update($this->parameters['data']);
+ $object->update($this->parameters['data']);
+
// create revision retroactively
$this->createRevision();
}
*/
protected function createRevision() {
$indexName = call_user_func(array($this->className, 'getDatabaseTableIndexName'));
-
+
foreach ($this->objects as $object) {
call_user_func(array($this->className, 'createRevision'), array_merge($object->getData(), array($indexName => $object->getObjectID())));
}
$this->readObjects();
}
- // get index name
- $indexName = call_user_func(array($this->className, 'getDatabaseTableIndexName'));
-
// get ids
$objectIDs = array();
foreach ($this->objects as $object) {
if (empty($this->objects)) {
$this->readObjects();
}
-
+
// currently we only support restoring one version
foreach ($this->objects as $object) {
$objectType = VersionHandler::getInstance()->getObjectTypeByName($object->versionableObjectTypeName);
$restoreObject = VersionHandler::getInstance()->getVersionByID($objectType->objectTypeID, $this->parameters['restoreObjectID']);
-
+
$this->parameters['data'] = $restoreObject->getData();
}
* Abstract class for all versionable editor classes.
*
* @author Jeffrey Reichardt
- * @copyright 2001-2012 WoltLab GmbH
+ * @copyright 2001-2013 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage data
// return new object
$id = WCF::getDB()->getInsertID(static::getDatabaseVersionTableName(), static::getDatabaseVersionTableIndexName());
-
+
return new static::$baseClass($id);
}
-
+
/**
* @see wcf\data\IEditableObject::delete()
*/
$sql = "DELETE FROM ".static::getDatabaseVersionTableName()."
WHERE ".static::getDatabaseTableIndexName()." = ?";
$statement = WCF::getDB()->prepareStatement($sql);
-
+
WCF::getDB()->beginTransaction();
foreach ($objectIDs as $objectID) {
$statement->execute(array($objectID));
/**
* Returns the database object with the given version id.
*
- * @param integer $objectTypeID
- * @param integer $versionID
+ * @param integer $objectTypeID
+ * @param integer $versionID
* @return wcf\data\VersionableDatabaseObject
*/
public function getVersionByID($objectTypeID, $versionID) {
}
/**
- * Gets the object type with the given id.
+ * Returns the object type with the given id.
*
* @param integer $objectTypeID
* @return wcf\data\object\type\ObjectType
}
/**
- * Gets the object type with the given name.
+ * Returns the object type with the given name.
*
- * @param string $objectTypeName
+ * @param string $objectTypeName
* @return wcf\data\object\type\ObjectType
*/
public function getObjectTypeByName($objectTypeName) {