예제 #1
0
 /**
  * Loads the active dashboard boxes for the given object type and page.
  * 
  * @param	string		$objectType
  * @param	\wcf\page\IPage	$page
  */
 public function loadBoxes($objectType, IPage $page)
 {
     $objectTypeObj = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.user.dashboardContainer', $objectType);
     if ($objectTypeObj === null) {
         throw new SystemException("Unable to find object type '" . $objectType . "' for definition 'com.woltlab.wcf.user.dashboardContainer'");
     }
     $boxIDs = array();
     if (isset($this->pageCache[$objectTypeObj->objectTypeID]) && is_array($this->pageCache[$objectTypeObj->objectTypeID])) {
         foreach ($this->pageCache[$objectTypeObj->objectTypeID] as $boxID) {
             $boxIDs[] = $boxID;
         }
     }
     $contentTemplate = $sidebarTemplate = '';
     foreach ($boxIDs as $boxID) {
         $className = $this->boxCache[$boxID]->className;
         if (!ClassUtil::isInstanceOf($className, 'wcf\\system\\dashboard\\box\\IDashboardBox')) {
             throw new SystemException("'" . $className . "' does not implement 'wcf\\system\\dashboard\\box\\IDashboardBox'");
         }
         $boxObject = new $className();
         $boxObject->init($this->boxCache[$boxID], $page);
         if ($this->boxCache[$boxID]->boxType == 'content') {
             $contentTemplate .= $boxObject->getTemplate();
         } else {
             $sidebarTemplate .= $boxObject->getTemplate();
         }
     }
     WCF::getTPL()->assign(array('__boxContent' => $contentTemplate, '__boxSidebar' => $sidebarTemplate));
 }
예제 #2
0
 /**
  * @see	wcf\data\ProcessibleDatabaseObject::getProcessor()
  */
 public function getProcessor()
 {
     if ($this->processor === null) {
         if ($this->className) {
             if (!class_exists($this->className)) {
                 throw new SystemException("Unable to find class '" . $this->className . "'");
             }
             /*
             	TODO:
             	Why should the class implement IDatabaseObjectProcessor? Given the fact,
             	that the default implementation IObjectTypeProvider does not decorate the
             	objects itself - instead it provides methods to receive the required objects.
             
             if (!ClassUtil::isInstanceOf($this->className, 'wcf\data\IDatabaseObjectProcessor')) {
             	throw new SystemException("'".$this->className."' should implement wcf\data\IDatabaseObjectProcessor");
             }
             */
             if (($definitionInterface = ObjectTypeCache::getInstance()->getDefinition($this->definitionID)->interfaceName) && !ClassUtil::isInstanceOf($this->className, $definitionInterface)) {
                 throw new SystemException("'" . $this->className . "' should implement " . $definitionInterface);
             }
             if (ClassUtil::isInstanceOf($this->className, 'wcf\\system\\SingletonFactory')) {
                 $this->processor = call_user_func(array($this->className, 'getInstance'));
             } else {
                 $this->processor = new $this->className($this);
             }
         }
     }
     return $this->processor;
 }
	/**
	 * Returns the processor this database object.
	 * 
	 * @return	object
	 */
	public function getProcessor() {
		if ($this->processor === null) {
			if ($this->className) {
				if (!class_exists($this->className)) {
					throw new SystemException("Unable to find class '".$this->className."'");
				}
				if (!ClassUtil::isInstanceOf($this->className, static::$processorInterface)) {
					throw new SystemException("'".$this->className."' does not implement '".static::$processorInterface."'");
				}
				
				if (ClassUtil::isInstanceOf($this->className, 'wcf\system\SingletonFactory')) {
					$this->processor = call_user_func(array($this->className, 'getInstance'));
				}
				else {
					if (!ClassUtil::isInstanceOf($this->className, 'wcf\data\IDatabaseObjectProcessor')) {
						throw new SystemException("'".$this->className."' does not implement 'wcf\data\IDatabaseObjectProcessor'");
					}
					
					$this->processor = new $this->className($this);
				}
			}
		}
		
		return $this->processor;
	}
예제 #4
0
	/**
	 * Validates class name.
	 */
	protected function validate() {
		if (empty($this->className)) {
			throw new SystemException("class name cannot be empty.");
		}
		
		if (!ClassUtil::isInstanceOf($this->className, 'wcf\system\worker\IWorker')) {
			throw new SystemException("'".$this->className."' does not implement 'wcf\system\worker\IWorker'");
		}
	}
예제 #5
0
 /**
  * Validates class name.
  */
 protected function validate()
 {
     if (empty($this->className)) {
         throw new SystemException("class name cannot be empty.");
     }
     if (!ClassUtil::isInstanceOf($this->className, 'wcf\\system\\worker\\IWorker')) {
         throw new SystemException("class '" . $this->className . "' should implement the interface 'wcf\\system\\worker\\IWorker'");
     }
 }
 /**
  * @see	\wcf\system\SingletonFactory
  */
 protected function init()
 {
     // call loadInstance event
     EventHandler::getInstance()->fireAction($this, 'init');
     if (!ClassUtil::isInstanceOf($this->className, 'wcf\\system\\user\\authentication\\IUserAuthentication')) {
         throw new SystemException("'" . $this->className . "' does not implement 'wcf\\system\\user\\authentication\\IUserAuthentication'");
     }
     $this->userAuthentication = call_user_func(array($this->className, 'getInstance'));
 }
예제 #7
0
 /**
  * Returns a list of search result collections for given query.
  * 
  * @param	string		$query
  * @param	integer		$limit
  * @return	array<\wcf\system\search\acp\ACPSearchResultList>
  */
 public function search($query, $limit = 10)
 {
     $data = array();
     $maxResultsPerProvider = ceil($limit / 2);
     $totalResultCount = 0;
     foreach ($this->cache as $acpSearchProvider) {
         $className = $acpSearchProvider->className;
         if (!ClassUtil::isInstanceOf($className, 'wcf\\system\\search\\acp\\IACPSearchResultProvider')) {
             throw new SystemException("'" . $className . "' does not implement 'wcf\\system\\search\\acp\\IACPSearchResultProvider'");
         }
         $provider = new $className();
         $results = $provider->search($query, $maxResultsPerProvider);
         if (!empty($results)) {
             $resultList = new ACPSearchResultList($acpSearchProvider->providerName);
             foreach ($results as $result) {
                 $resultList->addResult($result);
             }
             // sort list and reduce results
             $resultList->sort();
             $resultList->reduceResultsTo($maxResultsPerProvider);
             $data[] = $resultList;
             $totalResultCount += count($resultList);
         }
     }
     // reduce results per collection until we match the limit
     while ($totalResultCount > $limit) {
         // calculate highest value
         $max = 0;
         foreach ($data as $resultList) {
             $max = max($max, count($resultList));
         }
         // remove one result per result list with hits the $max value
         foreach ($data as $index => $resultList) {
             // break if we hit the $limit during reduction
             if ($totalResultCount == $limit) {
                 break;
             }
             $count = count($resultList);
             if ($count == $max) {
                 $resultList->reduceResults(1);
                 $totalResultCount--;
                 // the last element of this result was removed
                 if ($count == 1) {
                     unset($data[$index]);
                 }
             }
         }
     }
     // sort all result lists
     foreach ($data as $resultList) {
         $resultList->sort();
     }
     return $data;
 }
 /**
  * @see	\wcf\system\option\OptionHandler::getClassName()
  */
 protected function getClassName($type)
 {
     $className = 'wcf\\system\\option\\user\\group\\' . ucfirst($type) . 'UserGroupOptionType';
     // validate class
     if (!class_exists($className)) {
         return null;
     }
     if (!ClassUtil::isInstanceOf($className, 'wcf\\system\\option\\user\\group\\IUserGroupOptionType')) {
         throw new SystemException("'" . $className . "' does not implement 'wcf\\system\\option\\user\\group\\IUserGroupOptionType'");
     }
     return $className;
 }
예제 #9
0
 protected function init()
 {
     // first load shop items
     $items = \wcf\system\cache\builder\JCoinsShopItemTypeCacheBuilder::getInstance()->getData();
     foreach ($items as $i) {
         if (\wcf\util\ClassUtil::isInstanceOf($i->className, 'wcf\\system\\jcoins\\shop\\item\\type\\IShopItem')) {
             $this->items[$i->getObjectID()] = new $i->className();
             $this->identiferToItems[$i->identifer] = $i->getObjectID();
         } else {
             throw new \wcf\system\exception\SystemException('"' . $i->class . '" is not an instance of \\wcf\\system\\jcoins\\shop\\item\\type\\IShopItem');
         }
     }
 }
예제 #10
0
 /**
  * Returns parsed template for current sitemap.
  * 
  * @return	string
  */
 public function getTemplate()
 {
     if ($this->sitemapObj === null) {
         if (empty($this->className) || !class_exists($this->className)) {
             throw new SystemException("Unable to find class '" . $this->className . "' for sitemap '" . $this->sitemapName . "'");
         }
         if (!ClassUtil::isInstanceOf($this->className, 'wcf\\system\\sitemap\\ISitemapProvider')) {
             throw new SystemException("'" . $this->className . "' does not implement 'wcf\\system\\sitemap\\ISitemapProvider'");
         }
         $this->sitemapObj = new $this->className();
     }
     return $this->sitemapObj->getTemplate();
 }
예제 #11
0
 /**
  * Returns the output object for current user option.
  * 
  * @return	\wcf\system\option\user\IUserOptionOutput
  */
 public function getOutputObject()
 {
     if (!isset(self::$outputObjects[$this->outputClass])) {
         // create instance
         if (!class_exists($this->outputClass)) {
             throw new SystemException("unable to find class '" . $this->outputClass . "'");
         }
         // validate interface
         if (!ClassUtil::isInstanceOf($this->outputClass, 'wcf\\system\\option\\user\\IUserOptionOutput')) {
             throw new SystemException("'" . $this->outputClass . "' does not implement 'wcf\\system\\option\\user\\IUserOptionOutput'");
         }
         self::$outputObjects[$this->outputClass] = new $this->outputClass();
     }
     return self::$outputObjects[$this->outputClass];
 }
예제 #12
0
 /**
  * Returns the content manager for this menu item.
  * 
  * @return	\wcf\system\menu\user\profile\content\IUserProfileMenuContent
  */
 public function getContentManager()
 {
     if ($this->contentManager === null) {
         if (!class_exists($this->className)) {
             throw new SystemException("Unable to find class '" . $this->className . "'");
         }
         if (!ClassUtil::isInstanceOf($this->className, 'wcf\\system\\SingletonFactory')) {
             throw new SystemException("'" . $this->className . "' does not extend 'wcf\\system\\SingletonFactory'");
         }
         if (!ClassUtil::isInstanceOf($this->className, 'wcf\\system\\menu\\user\\profile\\content\\IUserProfileMenuContent')) {
             throw new SystemException("'" . $this->className . "' does not implement 'wcf\\system\\menu\\user\\profile\\content\\IUserProfileMenuContent'");
         }
         $this->contentManager = call_user_func(array($this->className, 'getInstance'));
     }
     return $this->contentManager;
 }
 /**
  * @see	\wcf\system\moderation\queue\IModerationQueueHandler::identifyOrphans()
  */
 public function identifyOrphans(array $queues)
 {
     if (empty($this->className) || !class_exists($this->className) || !ClassUtil::isInstanceOf($this->className, 'wcf\\data\\DatabaseObject')) {
         throw new SystemException("DatabaseObject class name '" . $this->className . "' is missing or invalid");
     }
     $indexName = call_user_func(array($this->className, 'getDatabaseTableIndexName'));
     $tableName = call_user_func(array($this->className, 'getDatabaseTableName'));
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add($indexName . " IN (?)", array(array_keys($queues)));
     $sql = "SELECT\t" . $indexName . "\n\t\t\tFROM\t" . $tableName . "\n\t\t\t" . $conditions;
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     while ($row = $statement->fetchArray()) {
         unset($queues[$row[$indexName]]);
     }
     return array_values($queues);
 }
예제 #14
0
 /**
  * @see	\wcf\data\ProcessibleDatabaseObject::getProcessor()
  */
 public function getProcessor()
 {
     if ($this->processor === null) {
         if ($this->className) {
             if (!class_exists($this->className)) {
                 throw new SystemException("Unable to find class '" . $this->className . "'");
             }
             if (($definitionInterface = ObjectTypeCache::getInstance()->getDefinition($this->definitionID)->interfaceName) && !ClassUtil::isInstanceOf($this->className, $definitionInterface)) {
                 throw new SystemException("'" . $this->className . "' does not implement '" . $definitionInterface . "'");
             }
             if (ClassUtil::isInstanceOf($this->className, 'wcf\\system\\SingletonFactory')) {
                 $this->processor = call_user_func(array($this->className, 'getInstance'));
             } else {
                 $this->processor = new $this->className($this);
             }
         }
     }
     return $this->processor;
 }
예제 #15
0
 /**
  * Validates parameters.
  */
 protected function validate()
 {
     // validate required parameters
     if (!isset($this->parameters['className']) || empty($this->parameters['className'])) {
         throw new AJAXException("missing class name");
     }
     if (!isset($this->parameters['actionName']) || empty($this->parameters['actionName'])) {
         throw new AJAXException("missing action name");
     }
     if (empty($this->typeName)) {
         throw new AJAXException("type name cannot be empty");
     }
     // validate class name
     if (!class_exists($this->parameters['className'])) {
         throw new AJAXException("unknown class '" . $this->parameters['className'] . "'");
     }
     if (!ClassUtil::isInstanceOf($this->parameters['className'], 'wcf\\data\\IDatabaseObjectAction')) {
         throw new AJAXException("'" . $this->parameters['className'] . "' should implement wcf\\system\\IDatabaseObjectAction");
     }
 }
예제 #16
0
 /**
  * @see	\wcf\action\IAction::execute()
  */
 protected function invoke()
 {
     if (!ClassUtil::isInstanceOf($this->className, 'wcf\\data\\IDatabaseObjectAction')) {
         throw new SystemException("'" . $this->className . "' does not implement 'wcf\\data\\IDatabaseObjectAction'");
     }
     if (!empty($this->interfaceName)) {
         if (!ClassUtil::isInstanceOf($this->className, $this->interfaceName)) {
             throw new SystemException("'" . $this->className . "' does not implement '" . $this->interfaceName . "'");
         }
     }
     // create object action instance
     $this->objectAction = new $this->className($this->objectIDs, $this->actionName, $this->parameters);
     // validate action
     $this->objectAction->validateAction();
     // execute action
     $this->response = $this->objectAction->executeAction();
     if (isset($this->response['returnValues'])) {
         $this->response['returnValues'] = $this->getData($this->response['returnValues']);
     }
 }
 /**
  * @see	wcf\system\worker\IWorker::validate()
  */
 public function validate()
 {
     if (!isset($this->parameters['faker'])) {
         throw new SystemException("Missing 'faker' parameter");
     }
     if (!class_exists($this->parameters['faker'])) {
         throw new SystemException("Unable to find faker '" . $this->parameters['faker']);
     }
     if (!\wcf\util\ClassUtil::isInstanceOf($this->parameters['faker'], '\\wcf\\system\\faker\\IFaker')) {
         throw new SystemException("'" . $this->parameters['faker'] . "' does not implement '\\wcf\\system\faker\\IFaker'");
     }
     if (!isset($this->parameters['amount'])) {
         throw new SystemException("Missing 'amount' parameter");
     }
     if (!isset($this->parameters['fakerLocale'])) {
         $this->parameters['fakerLocale'] = 'en_US';
     }
     if (!isset($this->parameters['proceedController'])) {
         throw new SystemException("Missing 'proceedController' parameter");
     }
 }
예제 #18
0
 /**
  * @see	wcf\action\IAction::execute()
  */
 public function execute()
 {
     parent::execute();
     // validate class name
     if (!class_exists($this->className)) {
         throw new SystemException("unknown class '" . $this->className . "'");
     }
     if (!ClassUtil::isInstanceOf($this->className, 'wcf\\data\\IDatabaseObjectAction')) {
         throw new SystemException("'" . $this->className . "' should implement wcf\\system\\IDatabaseObjectAction");
     }
     // create object action instance
     $this->objectAction = new $this->className($this->objectIDs, $this->actionName, $this->parameters);
     // validate action
     try {
         $this->objectAction->validateAction();
     } catch (UserInputException $e) {
         $this->throwException($e);
     } catch (ValidateActionException $e) {
         $this->throwException($e);
     }
     // execute action
     try {
         $this->response = $this->objectAction->executeAction();
     } catch (\Exception $e) {
         $this->throwException($e);
     }
     $this->executed();
     // send JSON-encoded response
     header('Content-type: application/json');
     echo JSON::encode($this->response);
     exit;
 }
예제 #19
0
	/**
	 * Invokes action method.
	 */
	protected function invoke() {
		// check for interface and inheritance of SingletonFactory
		if (!ClassUtil::isInstanceOf($this->className, 'wcf\system\IAJAXInvokeAction')) {
			throw new SystemException("'".$this->className."' does not implement 'wcf\system\IAJAXInvokeAction'");
		}
		else if (!ClassUtil::isInstanceOf($this->className, 'wcf\system\SingletonFactory')) {
			throw new SystemException("'".$this->className."' does not extend 'wcf\system\SingletonFactory'");
		}
		
		$this->actionObject = call_user_func(array($this->className, 'getInstance'));
		
		// validate action name
		if (empty($this->actionName) || !method_exists($this->actionObject, $this->actionName)) {
			throw new UserInputException('actionName');
		}
		
		$this->response = $this->actionObject->{$this->actionName}();
	}
예제 #20
0
	/**
	 * Returns class name for option type.
	 * 
	 * @param	string		$optionType
	 * @return	string
	 */
	protected function getClassName($optionType) {
		$optionType = StringUtil::firstCharToUpperCase($optionType);
		
		// attempt to validate against WCF first
		$isValid = false;
		$className = 'wcf\system\option\\'.$optionType.'OptionType';
		if (class_exists($className)) {
			$isValid = true;
		}
		else {
			if ($this->abbreviations === null) {
				$this->abbreviations = array();
				
				$applications = ApplicationHandler::getInstance()->getApplications();
				foreach ($applications as $application) {
					$this->abbreviations[] = ApplicationHandler::getInstance()->getAbbreviation($application->packageID);
				}
			}
			
			foreach ($this->abbreviations as $abbreviation) {
				$className = $abbreviation.'\system\option\\'.$optionType.'OptionType';
				if (class_exists($className)) {
					$isValid = true;
					break;
				}
			}
		}
		
		// validate class
		if (!$isValid) {
			return null;
		}
		
		if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\IOptionType')) {
			throw new SystemException("'".$className."' does not implement 'wcf\system\option\IOptionType'");
		}
		
		return $className;
	}
	/**
	 * Loads categories.
	 */
	protected function loadCategories() {
		// validate list class name
		if (empty($this->listClassName) || !ClassUtil::isInstanceOf($this->listClassName, 'wcf\data\DatabaseObjectList')) {
			throw new SystemException("Given class '".$this->listClassName."' is empty or invalid");
		}
		
		// read categories
		$categoryList = new $this->listClassName();
		$categoryList->readObjects();
		
		foreach ($categoryList as $category) {
			// validate options and permissions
			if (!$this->validate($category)) {
				continue;
			}
			
			// save level 1 categories
			if ($category->parentCategoryName == '') {
				$this->topCategories[] = $category->categoryName;
			}
			
			$this->categories[$category->categoryName] = $category;
		}
		
		// create level 2 categories
		$topCategories = array();
		foreach ($this->categories as $category) {
			if ($category->parentCategoryName && in_array($category->parentCategoryName, $this->topCategories)) {
				$topCategories[] = $category->categoryName;
			}
		}
		
		$this->topCategories = array_merge($this->topCategories, $topCategories);
	}
예제 #22
0
 /**
  * Returns items for clipboard editor.
  * 
  * @param	string		$page
  * @param	array		$containerData
  * @return	array<array>
  */
 public function getEditorItems($page, $containerData)
 {
     // ignore unknown pages
     if (!isset($this->pageCache[$page])) {
         return null;
     }
     // get objects
     $this->loadMarkedItems();
     if (!count($this->markedItems)) {
         return null;
     }
     // fetch action ids
     $this->loadActionCache();
     $actionIDs = array();
     foreach ($this->pageCache[$page] as $actionID) {
         if (isset($this->actionCache[$actionID])) {
             $actionIDs[] = $actionID;
         }
     }
     $actionIDs = array_unique($actionIDs);
     // load actions
     $actions = array();
     foreach ($actionIDs as $actionID) {
         $actionClassName = $this->actionCache[$actionID]->actionClassName;
         $actionName = $this->actionCache[$actionID]->actionName;
         if (!isset($actions[$actionClassName])) {
             // validate class
             if (!ClassUtil::isInstanceOf($actionClassName, 'wcf\\system\\clipboard\\action\\IClipboardAction')) {
                 throw new SystemException("class '" . $actionClassName . "' does not implement the interface 'wcf\\system\\clipboard\\action\\IClipboardAction'.");
             }
             $actions[$actionClassName] = array('actions' => array(), 'object' => new $actionClassName());
         }
         $actions[$actionClassName]['actions'][] = $actionName;
     }
     // execute actions
     $editorData = array();
     foreach ($actions as $actionData) {
         // get accepted objects
         $typeName = $actionData['object']->getTypeName();
         if (!isset($this->markedItems[$typeName])) {
             continue;
         }
         $editorData[$typeName] = array('label' => $actionData['object']->getEditorLabel($this->markedItems[$typeName]), 'items' => array());
         $typeData = array();
         if (isset($containerData[$typeName])) {
             $typeData = $containerData[$typeName];
         }
         foreach ($actionData['actions'] as $action) {
             $data = $actionData['object']->execute($this->markedItems[$typeName], $action, $typeData);
             if ($data === null) {
                 continue;
             }
             $editorData[$typeName]['items'][$action] = $data;
         }
     }
     return $editorData;
 }
	/**
	 * Resets cache of database object.
	 */
	protected function resetCache() {
		if (ClassUtil::isInstanceOf($this->className, 'wcf\data\IEditableCachedObject')) {
			call_user_func(array($this->className, 'resetCache'));
		}
	}
예제 #24
0
 /**
  * Creates a new message and returns the parsed template.
  * 
  * @param	\wcf\data\IMessageQuickReplyAction	$object
  * @param	array<array>				$parameters
  * @param	string					$containerActionClassName
  * @param	string					$sortOrder
  * @param	string					$templateName
  * @param	string					$application
  * @return	array
  */
 public function createMessage(IMessageQuickReplyAction $object, array &$parameters, $containerActionClassName, $sortOrder, $templateName, $application = 'wcf')
 {
     $additionalFields = array();
     EventHandler::getInstance()->fireAction($this, 'createMessage', $additionalFields);
     $tableIndexName = call_user_func(array($this->container, 'getDatabaseTableIndexName'));
     $parameters['data'][$tableIndexName] = $parameters['objectID'];
     $parameters['data']['time'] = TIME_NOW;
     $parameters['data']['userID'] = WCF::getUser()->userID ?: null;
     $parameters['data']['username'] = WCF::getUser()->username;
     // pre-parse message text
     if ($parameters['data']['preParse']) {
         $parameters['data']['message'] = PreParser::getInstance()->parse($parameters['data']['message'], $this->allowedBBodes);
     }
     unset($parameters['data']['preParse']);
     $parameters['data'] = array_merge($additionalFields, $parameters['data']);
     // attachment support
     if (MODULE_ATTACHMENT && !empty($parameters['tmpHash']) && $object instanceof IAttachmentMessageQuickReplyAction) {
         $parameters['attachmentHandler'] = $object->getAttachmentHandler($this->container);
     }
     $message = $object->create();
     $eventParameters = array('message' => $message);
     EventHandler::getInstance()->fireAction($this, 'createdMessage', $eventParameters);
     if ($message instanceof IMessage && !$message->isVisible()) {
         return array('isVisible' => false);
     }
     // resolve the page no
     list($pageNo, $count) = $object->getPageNo($this->container);
     // we're still on current page
     if ($pageNo == $parameters['pageNo']) {
         // check for additional messages
         $messageList = $object->getMessageList($this->container, $parameters['lastPostTime']);
         // calculate start index
         $startIndex = $count - (count($messageList) - 1);
         WCF::getTPL()->assign(array('attachmentList' => $messageList->getAttachmentList(), 'container' => $this->container, 'objects' => $messageList, 'startIndex' => $startIndex, 'sortOrder' => $sortOrder));
         // assign 'to top' link
         if (isset($parameters['anchor'])) {
             WCF::getTPL()->assign('anchor', $parameters['anchor']);
         }
         // update visit time (messages shouldn't occur as new upon next visit)
         if (ClassUtil::isInstanceOf($containerActionClassName, 'wcf\\data\\IVisitableObjectAction')) {
             $containerAction = new $containerActionClassName(array($this->container instanceof DatabaseObjectDecorator ? $this->container->getDecoratedObject() : $this->container), 'markAsRead');
             $containerAction->executeAction();
         }
         return array('lastPostTime' => $message->time, 'template' => WCF::getTPL()->fetch($templateName, $application));
     } else {
         // redirect
         return array('url' => $object->getRedirectUrl($this->container, $message));
     }
 }
예제 #25
0
 /**
  * Executes a cronjob.
  * 
  * @param	wcf\data\cronjob\CronjobEditor		$cronjobEditor
  * @param	wcf\data\cronjob\log\CronjobLogEditor	$logEditor
  */
 protected function executeCronjob(CronjobEditor $cronjobEditor, CronjobLogEditor $logEditor)
 {
     $className = $cronjobEditor->className;
     if (!class_exists($className)) {
         throw new SystemException("unable to find class '" . $className . "'");
     }
     // verify class signature
     if (!ClassUtil::isInstanceOf($className, 'wcf\\system\\cronjob\\ICronjob')) {
         throw new SystemException("class '" . $className . "' does not implement the interface 'wcf\\system\\cronjob\\ICronjob'");
     }
     // execute cronjob
     $cronjob = new $className();
     $cronjob->execute($cronjobEditor->getDecoratedObject());
     $this->logResult($logEditor);
 }
예제 #26
0
 /**
  * Initializes DatabaseObjectList instance.
  */
 protected function initObjectList()
 {
     if (empty($this->objectListClassName)) {
         throw new SystemException('DatabaseObjectList class name not specified.');
     }
     if (!ClassUtil::isInstanceOf($this->objectListClassName, 'wcf\\data\\DatabaseObjectList')) {
         throw new SystemException("'" . $this->objectListClassName . "' does not extend 'wcf\\data\\DatabaseObjectList'");
     }
     $this->objectList = new $this->objectListClassName();
 }
예제 #27
0
	/**
	 * Creates a new DatabaseObjectList object.
	 */
	public function __construct() {
		// set class name
		if (empty($this->className)) {
			$className = get_called_class();
			
			if (StringUtil::substring($className, -4) == 'List') {
				$this->className = StringUtil::substring($className, 0, -4);
			}
		}
		
		if (!empty($this->decoratorClassName)) {
			// validate decorator class name
			if (!ClassUtil::isInstanceOf($this->decoratorClassName, 'wcf\data\DatabaseObjectDecorator')) {
				throw new SystemException("'".$this->decoratorClassName."' should extend 'wcf\data\DatabaseObjectDecorator'");
			}
			
			$objectClassName = $this->objectClassName ?: $this->className;
			$baseClassName = call_user_func(array($this->decoratorClassName, 'getBaseClass'));
			if ($objectClassName != $baseClassName && !ClassUtil::isInstanceOf($baseClassName, $objectClassName)) {
				throw new SystemException("'".$this->decoratorClassName."' can't decorate objects of class '".$objectClassName."'");
			}
		}
		
		$this->conditionBuilder = new PreparedStatementConditionBuilder();
	}
 /**
  * @see	wcf\data\IDatabaseObjectAction::executeAction()
  */
 public function executeAction()
 {
     // execute action
     if (method_exists($this, $this->getActionName())) {
         $this->returnValues = call_user_func_array(array($this, $this->getActionName()), $this->getParameters());
     }
     // reset cache
     if (ClassUtil::isInstanceOf($this->className, 'wcf\\data\\IEditableCachedObject')) {
         call_user_func(array($this->className, 'resetCache'));
     }
     // fire event action
     EventHandler::getInstance()->fireAction($this, 'finalizeAction');
     return $this->getReturnValues();
 }
예제 #29
0
 /**
  * Returns the handler object for given object type. Returns false if object type (id)
  * is not found, or null if no handler is assigned.
  * 
  * @param	integer		$objectTypeID
  * @param	string		$objectType
  * @return	mixed
  */
 protected function getHandler($objectTypeID, $objectType = '')
 {
     if ($objectTypeID !== null) {
         foreach ($this->cache as $objectTypeObj) {
             if ($objectTypeObj->objectTypeID == $objectTypeID) {
                 $objectType = $objectTypeObj->objectType;
                 break;
             }
         }
     }
     if (!isset($this->cache[$objectType])) {
         throw new SystemException("Object type '" . $objectType . "' (id " . $objectTypeID . ") is not valid for object type definition 'com.woltlab.wcf.poll'");
     }
     if ($this->cache[$objectType]->className === null) {
         throw new SystemException("Object type '" . $objectType . "' does not provide a processor class name");
     }
     // validates against object type's class
     $className = $this->cache[$objectType]->className;
     if (!ClassUtil::isInstanceOf($className, 'wcf\\system\\poll\\IPollHandler')) {
         throw new SystemException("'" . $className . "' does not implement 'wcf\\system\\poll\\IPollHandler'");
     } else {
         if (!ClassUtil::isInstanceOf($className, 'wcf\\system\\SingletonFactory')) {
             throw new SystemException("'" . $className . "' does not extend 'wcf\\system\\SingletonFactory'");
         }
     }
     $object = call_user_func(array($className, 'getInstance'));
     return $object;
 }
예제 #30
0
 /**
  * Returns dynamically loaded core objects.
  * 
  * @param	string		$name
  * @param	array		$arguments
  */
 public static final function __callStatic($name, array $arguments)
 {
     $className = preg_replace('~^get~', '', $name);
     if (isset(self::$coreObject[$className])) {
         return self::$coreObject[$className];
     }
     $objectName = self::getCoreObject($className);
     if ($objectName === null) {
         throw new SystemException("Core object '" . $className . "' is unknown.");
     }
     if (class_exists($objectName)) {
         if (!ClassUtil::isInstanceOf($objectName, 'wcf\\system\\SingletonFactory')) {
             throw new SystemException("class '" . $objectName . "' does not implement the interface 'SingletonFactory'");
         }
         self::$coreObject[$className] = call_user_func(array($objectName, 'getInstance'));
         return self::$coreObject[$className];
     }
 }