From 4e87782952820b7cd45308b03851188048b6b922 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Fri, 13 Jan 2012 17:14:24 +0100 Subject: [PATCH] constructor of AbstractDatabaseObjectAction is a bit more flexible now --- .../AbstractDatabaseObjectAction.class.php | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php b/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php index 11c551cbb6..85faa1b70e 100644 --- a/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php +++ b/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php @@ -2,6 +2,7 @@ namespace wcf\data; use wcf\system\event\EventHandler; use wcf\system\exception\PermissionDeniedException; +use wcf\system\exception\SystemException; use wcf\system\exception\ValidateActionException; use wcf\system\WCF; use wcf\util\ClassUtil; @@ -82,12 +83,36 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction { /** * Initialize a new DatabaseObject-related action. * - * @param array $objectIDs + * @param array $objects * @param string $action * @param array $parameters */ - public function __construct(array $objectIDs, $action, array $parameters = array()) { - $this->objectIDs = $objectIDs; + public function __construct(array $objects, $action, array $parameters = array()) { + $indexName = call_user_func(array($this->className, 'getDatabaseTableIndexName')); + $baseClass = call_user_func(array($this->className, 'getBaseClass')); + + foreach ($objects as $object) { + if (is_object($object)) { + if ($object instanceof $this->className) { + $this->objects[] = $object; + } + else if ($object instanceof $baseClass) { + $this->objects[] = new $this->className($object); + } + else { + throw new SystemException('invalid value of parameter objects given'); + } + + $this->objectIDs[] = $object->$indexName; + } + else if (is_int($object)) { + $this->objectIDs[] = $object; + } + else { + throw new SystemException('invalid value of parameter objects given'); + } + } + $this->action = $action; $this->parameters = $parameters; -- 2.20.1