/** * Determine which blocks to show. */ function determineBlocks() { global $ilUser, $ilCtrl, $ilSetting; include_once "./Services/Block/classes/class.ilBlockSetting.php"; $this->blocks[IL_COL_LEFT] = array(); $this->blocks[IL_COL_RIGHT] = array(); $this->blocks[IL_COL_CENTER] = array(); $user_id = $this->getColType() == "pd" ? $ilUser->getId() : 0; $def_nr = 1000; if (is_array($this->default_blocks[$this->getColType()])) { foreach ($this->default_blocks[$this->getColType()] as $class => $def_side) { $type = self::$block_types[$class]; if ($this->isGloballyActivated($type)) { $nr = ilBlockSetting::_lookupNr($type, $user_id); if ($nr === false) { $nr = $def_nr++; } // extra handling for system messages, feedback block and news if ($type == "news") { $nr = -15; } if ($type == "cal") { $nr = -8; } if ($type == "pdsysmess") { // $nr = -15; } if ($type == "pdfeedb") { $nr = -10; } $side = ilBlockSetting::_lookupSide($type, $user_id); if ($side === false) { $side = $def_side; } $this->blocks[$side][] = array("nr" => $nr, "class" => $class, "type" => $type, "id" => 0, "custom" => false); } } } if (!$this->getRepositoryMode()) { include_once "./Services/Block/classes/class.ilCustomBlock.php"; $costum_block = new ilCustomBlock(); $costum_block->setContextObjId($ilCtrl->getContextObjId()); $costum_block->setContextObjType($ilCtrl->getContextObjType()); $c_blocks = $costum_block->queryBlocksForContext(); foreach ($c_blocks as $c_block) { $type = $c_block["type"]; if ($this->isGloballyActivated($type)) { $class = array_search($type, self::$block_types); $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]); if ($nr === false) { $nr = $def_nr++; } $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]); if ($side === false) { $side = IL_COL_RIGHT; } $this->blocks[$side][] = array("nr" => $nr, "class" => $class, "type" => $type, "id" => $c_block["id"], "custom" => true); } } } else { include_once "./Services/Block/classes/class.ilCustomBlock.php"; $rep_items = $this->getRepositoryItems(); foreach ($this->rep_block_types as $block_type) { if ($this->isGloballyActivated($block_type)) { if (!is_array($rep_items[$block_type])) { continue; } foreach ($rep_items[$block_type] as $item) { $costum_block = new ilCustomBlock(); $costum_block->setContextObjId($item["obj_id"]); $costum_block->setContextObjType($block_type); $c_blocks = $costum_block->queryBlocksForContext(); $c_block = $c_blocks[0]; $type = $block_type; $class = array_search($type, self::$block_types); $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]); if ($nr === false) { $nr = $def_nr++; } $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]); if ($side === false) { $side = IL_COL_RIGHT; } $this->blocks[$side][] = array("nr" => $nr, "class" => $class, "type" => $type, "id" => $c_block["id"], "custom" => true, "ref_id" => $item["ref_id"]); } } } } $this->blocks[IL_COL_LEFT] = ilUtil::sortArray($this->blocks[IL_COL_LEFT], "nr", "asc", true); $this->blocks[IL_COL_RIGHT] = ilUtil::sortArray($this->blocks[IL_COL_RIGHT], "nr", "asc", true); $this->blocks[IL_COL_CENTER] = ilUtil::sortArray($this->blocks[IL_COL_CENTER], "nr", "asc", true); }