/** * @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\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(); }