/** * @see wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ public function rebuild(array $parameters) { // get object types $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.versionableObject'); $data = array( 'versions' => array(), 'versionIDs' => array() ); foreach ($objectTypes as $objectTypeID => $objectType) { $processorObject = $objectType->getProcessor(); $sql = "SELECT * FROM ".$processorObject::getDatabaseVersionTableName(); $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array()); while ($row = $statement->fetchArray()) { $object = new $objectType->className(null, $row); $data['versions'][$objectTypeID][$object->{$processorObject::getDatabaseIndexName()}] = $object; $data['versionIDs'][$objectTypeID][$object->{$processorObject::getDatabaseIndexName()}][] = $object->{$processorObject::getDatabaseVersionTableIndexName()}; } } return $data; }
/** * @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ protected function rebuild(array $parameters) { $data = array('boxes' => array(), 'pages' => array()); // load boxes $boxList = new DashboardBoxList(); $boxList->readObjects(); foreach ($boxList as $box) { $data['boxes'][$box->boxID] = $box; } // load settings $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.user.dashboardContainer'); $objectTypeIDs = array(); foreach ($objectTypes as $objectType) { $objectTypeIDs[] = $objectType->objectTypeID; } $conditions = new PreparedStatementConditionBuilder(); $conditions->add("objectTypeID IN (?)", array($objectTypeIDs)); $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_dashboard_option\n\t\t\t" . $conditions . "\n\t\t\tORDER BY\tshowOrder ASC"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($conditions->getParameters()); while ($row = $statement->fetchArray()) { if (!isset($data['pages'][$row['objectTypeID']])) { $data['pages'][$row['objectTypeID']] = array(); } $data['pages'][$row['objectTypeID']][] = $row['boxID']; } return $data; }
/** * @see \wcf\system\worker\IWorker::execute() */ public function execute() { EventHandler::getInstance()->fireAction($this, 'execute'); if (!$this->loopCount) { // delete existing stat $sql = "DELETE FROM\twcf" . WCF_N . "_stat_daily"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(); } // prepare insert statement $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_stat_daily\n\t\t\t\t\t\t(objectTypeID, date, counter, total)\n\t\t\tVALUES\t\t\t(?, ?, ?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); $this->getStartDate(); $d = DateUtil::getDateTimeByTimestamp($this->startDate); $d->setTimezone(new \DateTimeZone(TIMEZONE)); $d->setTime(0, 0); if ($this->loopCount) { $d->add(new \DateInterval('P' . $this->loopCount * $this->limit . 'D')); } for ($i = 0; $i < $this->limit; $i++) { if ($d->getTimestamp() > TIME_NOW) { break; } // get object types foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.statDailyHandler') as $objectType) { $data = $objectType->getProcessor()->getData($d->getTimestamp()); $statement->execute(array($objectType->objectTypeID, $d->format('Y-m-d'), $data['counter'], $data['total'])); } $d->add(new \DateInterval('P1D')); } }
/** * Creates a new GroupedAttachmentList object. * * @param string $objectType */ public function __construct($objectType) { parent::__construct(); $this->objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', $objectType); $this->getConditionBuilder()->add('attachment.objectTypeID = ?', array($this->objectType->objectTypeID)); $this->getConditionBuilder()->add('(SELECT embeddedObjectID FROM wcf' . WCF_N . '_message_embedded_object WHERE messageObjectTypeID = ? AND messageID = attachment.objectID AND embeddedObjectTypeID = ? AND embeddedObjectID = attachment.attachmentID) IS NULL', array(ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.message', $objectType), ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.message.embeddedObject', 'com.woltlab.wcf.attachment'))); }
/** * Returns the liked object. * * @return \wcf\data\like\object\ILikeObject */ public function getLikedObject() { if ($this->likedObject === null) { $this->likedObject = ObjectTypeCache::getInstance()->getObjectType($this->objectTypeID)->getProcessor()->getObjectByID($this->objectID); } return $this->likedObject; }
/** * @see \wcf\system\worker\IWorker::execute() */ public function execute() { $this->objectList->getConditionBuilder()->add('conversation_message.messageID BETWEEN ? AND ?', array($this->limit * $this->loopCount + 1, $this->limit * $this->loopCount + $this->limit)); parent::execute(); if (!$this->loopCount) { // reset search index SearchIndexManager::getInstance()->reset('com.woltlab.wcf.conversation.message'); } // prepare statements $attachmentObjectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', 'com.woltlab.wcf.conversation.message'); $sql = "SELECT\t\tCOUNT(*) AS attachments\n\t\t\tFROM\t\twcf" . WCF_N . "_attachment\n\t\t\tWHERE\t\tobjectTypeID = ?\n\t\t\t\t\tAND objectID = ?"; $attachmentStatement = WCF::getDB()->prepareStatement($sql); foreach ($this->objectList as $message) { SearchIndexManager::getInstance()->add('com.woltlab.wcf.conversation.message', $message->messageID, $message->message, $message->subject ?: '', $message->time, $message->userID, $message->username); $editor = new ConversationMessageEditor($message); $data = array(); // count attachments $attachmentStatement->execute(array($attachmentObjectType->objectTypeID, $message->messageID)); $row = $attachmentStatement->fetchSingleRow(); $data['attachments'] = $row['attachments']; // update embedded objects $data['hasEmbeddedObjects'] = MessageEmbeddedObjectManager::getInstance()->registerObjects('com.woltlab.wcf.conversation.message', $message->messageID, $message->message) ? 1 : 0; $editor->update($data); } }
/** * @see \wcf\system\SingletonFactory::init() */ protected function init() { // load locations foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.user.online.location') as $objectType) { $this->locations[$objectType->controller] = $objectType; } }
/** * @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; }
/** * @see \wcf\system\SingletonFactory::init() */ protected function init() { $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.captcha'); foreach ($objectTypes as $objectType) { $this->objectTypes[$objectType->objectTypeID] = $objectType; } }
/** * @see \wcf\form\IForm::save() */ public function save() { AbstractForm::save(); $this->label = 'wcf.acp.label.label' . $this->labelObj->labelID; if (I18nHandler::getInstance()->isPlainValue('label')) { I18nHandler::getInstance()->remove($this->label); $this->label = I18nHandler::getInstance()->getValue('label'); } else { I18nHandler::getInstance()->save('label', $this->label, 'wcf.acp.label', 1); } // update label $this->objectAction = new LabelAction(array($this->labelID), 'update', array('data' => array_merge($this->additionalFields, array('label' => $this->label, 'cssClassName' => $this->cssClassName == 'custom' ? $this->customCssClassName : $this->cssClassName, 'groupID' => $this->groupID)))); $this->objectAction->executeAction(); $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.label.objectType'); foreach ($objectTypes as $objectType) { $objectType->getProcessor()->save(); } $this->saved(); // reset values if non-custom value was choosen if ($this->cssClassName != 'custom') { $this->customCssClassName = ''; } // show success WCF::getTPL()->assign(array('success' => true)); }
/** * Fetches the information of the latest edit. * * @see \wcf\data\DatabaseObjectDecorator::__construct() */ public function __construct(DatabaseObject $object) { parent::__construct($object); $objectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.modifiableContent', 'de.incendium.cms.news.entry'); $sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_modification_log\n\t\t\tWHERE\t\tobjectTypeID = ?\n\t\t\t\tAND\tobjectID = ?\n\t\t\t\tAND\taction = ?\n\t\t\tORDER BY time DESC"; $statement = WCF::getDB()->prepareStatement($sql, 1); $statement->execute(array($objectTypeID, $this->getDecoratedObject()->entryID, 'edit')); $row = $statement->fetchArray(); if ($row) { $this->userID = $row['userID']; $this->username = $row['username']; $this->time = $row['time']; $additionalData = @unserialize($row['additionalData']); if (isset($additionalData['reason'])) { $this->reason = $additionalData['reason']; } else { $this->reason = ''; } } else { $this->userID = $this->getDecoratedObject()->getUserID(); $this->username = $this->getDecoratedObject()->getUsername(); $this->time = $this->getDecoratedObject()->getTime(); $this->reason = ''; } }
/** * @see \wcf\page\IPage::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_REQUEST['id'])) { $this->objectTypeID = intval($_REQUEST['id']); } // load object type $objectTypeDefinition = ObjectTypeCache::getInstance()->getDefinitionByName('com.woltlab.wcf.user.dashboardContainer'); $this->objectType = ObjectTypeCache::getInstance()->getObjectType($this->objectTypeID); if ($this->objectType === null || $this->objectType->definitionID != $objectTypeDefinition->definitionID) { throw new IllegalLinkException(); } // load available boxes $allowedBoxTypes = array(); if ($this->objectType->allowcontent) { $allowedBoxTypes[] = 'content'; } if ($this->objectType->allowsidebar) { $allowedBoxTypes[] = 'sidebar'; } if (empty($allowedBoxTypes)) { // this should not happen unless you go full retard throw new IllegalLinkException(); } $boxList = new DashboardBoxList(); $boxList->getConditionBuilder()->add("dashboard_box.boxType IN (?)", array($allowedBoxTypes)); $boxList->readObjects(); $this->boxes = $boxList->getObjects(); }
/** * @see \wcf\data\like\object\ILikeObject::getObjectType() */ public function getObjectType() { if ($this->objectType === null) { $this->objectType = ObjectTypeCache::getInstance()->getObjectType($this->getDecoratedObject()->objectTypeID); } return $this->objectType; }
/** * @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ public function rebuild(array $parameters) { if (!isset($parameters['definitionID'])) { throw new SystemException("Missing 'definitionID' parameter"); } $definition = ObjectTypeCache::getInstance()->getDefinition($parameters['definitionID']); if ($definition === null) { throw new SystemException("Unknown object type definition with id '" . $parameters['definitionID'] . "'"); } $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes($definition->definitionName); if (empty($objectTypes)) { return array(); } $objectTypeIDs = array(); foreach ($objectTypes as $objectType) { $objectTypeIDs[] = $objectType->objectTypeID; } $conditionList = new ConditionList(); $conditionList->getConditionBuilder()->add('condition_table.objectTypeID IN (?)', array($objectTypeIDs)); $conditionList->readObjects(); $groupedConditions = array(); foreach ($conditionList as $condition) { if (!isset($groupedConditions[$condition->objectID])) { $groupedConditions[$condition->objectID] = array(); } $groupedConditions[$condition->objectID][$condition->conditionID] = $condition; } return $groupedConditions; }
/** * @see \wcf\system\SingletonFactory::init() */ protected function init() { $this->objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.user.activityPointEvent'); foreach ($this->objectTypes as $objectType) { $this->objectTypeNames[$objectType->objectTypeID] = $objectType->objectType; } }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); // get object types $this->objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.rebuildData'); // sort object types uasort($this->objectTypes, function ($a, $b) { $niceValueA = $a->nicevalue ?: 0; $niceValueB = $b->nicevalue ?: 0; if ($niceValueA < $niceValueB) { return -1; } else { if ($niceValueA > $niceValueB) { return 1; } } return 0; }); $sql = "SHOW VARIABLES LIKE 'innodb_flush_log_at_trx_commit'"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(); $row = $statement->fetchArray(); if ($row && $row['Value'] == 1) { $this->showInnoDBWarning = true; } }
/** * @see \wcf\data\AbstractDatabaseObjectAction::delete() */ public function delete() { $count = parent::delete(); foreach (ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.label.objectType') as $objectType) { $objectType->getProcessor()->save(); } return $count; }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); $this->objectTypeList = ObjectTypeCache::getInstance()->getObjectTypes('de.codequake.cms.content.type'); // read pages $pageNodeTree = new PageNodeTree(); $this->pageList = $pageNodeTree->getIterator(); }
/** * @see wcf\system\SingletonFactory::init() */ protected function init() { $this->cache = array('objectTypes' => array(), 'objectTypeIDs' => array()); $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.collapsibleContent'); foreach ($objectTypes as $objectType) { $this->cache['objectTypes'][$objectType->objectTypeID] = $objectType; $this->cache['objectTypeIDs'][$objectType->objectType] = $objectType->objectTypeID; } }
/** * @see \wcf\system\SingletonFactory::init() */ protected function init() { // load object types $cache = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.user.recentActivityEvent'); foreach ($cache as $objectType) { $this->objectTypes['names'][$objectType->objectType] = $objectType->objectTypeID; $this->objectTypes['objects'][$objectType->objectTypeID] = $objectType; } }
/** * Gets the container object of this attachment. * * @return \wcf\data\IUserContent */ public function getContainerObject() { if (!$this->containerObjectLoaded) { $this->containerObjectLoaded = true; $objectType = ObjectTypeCache::getInstance()->getObjectType($this->objectTypeID); $this->containerObject = $objectType->getProcessor()->getObject($this->objectID); } return $this->containerObject; }
/** * @see \wcf\system\SingletonFactory::init() */ protected function init() { // get available object types $this->availableObjectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.searchableObjectType'); // get processors foreach ($this->availableObjectTypes as &$objectType) { $objectType = $objectType->getProcessor(); } }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); $pageNodeTree = new PageNodeTree(); $this->pageList = $pageNodeTree->getIterator(); $this->contentListBody = new DrainedPositionContentNodeTree(null, $this->pageID, null, 'body', 1); $this->contentListSidebar = new DrainedPositionContentNodeTree(null, $this->pageID, null, 'sidebar', 1); $this->objectTypeList = ObjectTypeCache::getInstance()->getObjectTypes('de.codequake.cms.content.type'); }
/** * Returns the location of the ad. * * @return string */ public function getLocation() { $objectType = ObjectTypeCache::getInstance()->getObjectType($this->objectTypeID); $location = WCF::getLanguage()->get('wcf.acp.ad.location.' . $objectType->objectType); if ($objectType->categoryname != 'com.woltlab.wcf.global') { $location = WCF::getLanguage()->get('wcf.acp.ad.location.category.' . $objectType->categoryname) . ': ' . $location; } return $location; }
/** * Returns the corresponding IHistorySavingObject * * @return \wcf\system\edit\IHistorySavingObject */ public function getObject() { if ($this->object === null) { $objectType = ObjectTypeCache::getInstance()->getObjectType($this->objectTypeID); $processor = $objectType->getProcessor(); $this->object = $processor->getObjectByID($this->objectID); } return $this->object; }
/** * @see \wcf\page\IPage::readParameters() */ public function readParameters() { parent::readParameters(); // get tag id if (isset($_REQUEST['id'])) { $this->tagID = intval($_REQUEST['id']); } $this->tag = new Tag($this->tagID); if (!$this->tag->tagID) { throw new IllegalLinkException(); } // filter taggable object types by options and permissions $this->availableObjectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.tagging.taggableObject'); foreach ($this->availableObjectTypes as $key => $objectType) { if ($objectType->options) { $hasEnabledOption = false; $options = explode(',', strtoupper($objectType->options)); foreach ($options as $option) { if (defined($option) && constant($option)) { $hasEnabledOption = true; break; } } if (!$hasEnabledOption) { unset($this->availableObjectTypes[$key]); } } if ($objectType->permissions) { $hasPermission = false; $permissions = explode(',', $objectType->permissions); foreach ($permissions as $permission) { if (WCF::getSession()->getPermission($permission)) { $hasPermission = true; break; } } if (!$hasPermission) { unset($this->availableObjectTypes[$key]); } } } if (empty($this->availableObjectTypes)) { throw new IllegalLinkException(); } // get object type if (isset($_REQUEST['objectType'])) { $objectType = StringUtil::trim($_REQUEST['objectType']); if (!isset($this->availableObjectTypes[$objectType])) { throw new IllegalLinkException(); } $this->objectType = $this->availableObjectTypes[$objectType]; } else { // use first object type $this->objectType = reset($this->availableObjectTypes); } }
/** * @see \wcf\system\SingletonFactory::init() */ protected function init() { $this->cache = array('objectTypes' => array(), 'objectTypeNames' => array()); $cache = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.label.object'); foreach ($cache as $objectType) { $this->cache['objectTypes'][$objectType->objectTypeID] = $objectType; $this->cache['objectTypeNames'][$objectType->objectType] = $objectType->objectTypeID; } $this->labelGroups = LabelCacheBuilder::getInstance()->getData(); }
/** * @see \wcf\system\SingletonFactory::init() */ protected function init() { $this->cache = array('objectTypes' => array(), 'objectTypeNames' => array()); $cache = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.clipboardItem'); foreach ($cache as $objectType) { $this->cache['objectTypes'][$objectType->objectTypeID] = $objectType; $this->cache['objectTypeNames'][$objectType->objectType] = $objectType->objectTypeID; } $this->pageCache = ClipboardPageCacheBuilder::getInstance()->getData(); }
/** * @see \wcf\page\IPage::assignVariables() */ public function assignVariables() { parent::assignVariables(); $commentableContents = \wcf\data\object\type\ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.comment.commentableContent'); $commentObjectTypeIDs = array(); foreach ($commentableContents as $objectType) { $commentObjectTypeIDs[$objectType->objectTypeID] = $objectType->objectType; } \wcf\system\WCF::getTPL()->assign(array('commentObjectTypeIDs' => $commentObjectTypeIDs)); }
/** * @see \wcf\page\IPage::readData() */ public function readData() { $this->objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.user.activityPointEvent'); if (empty($_POST)) { foreach ($this->objectTypes as $objectType) { $this->points[$objectType->objectTypeID] = $objectType->points; } } parent::readData(); }