00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 define ("IL_COL_LEFT", "left");
00025 define ("IL_COL_RIGHT", "right");
00026 define ("IL_COL_CENTER", "center");
00027
00028 define ("IL_SCREEN_SIDE", "");
00029 define ("IL_SCREEN_CENTER", "center");
00030 define ("IL_SCREEN_FULL", "full");
00031
00041 class ilColumnGUI
00042 {
00043 protected $side = IL_COL_RIGHT;
00044 protected $type;
00045 protected $enableedit = false;
00046 protected $repositorymode = false;
00047 protected $repositoryitems = array();
00048
00049
00050 protected $rep_block_types = array("feed");
00051
00052
00053
00054
00055
00056
00057 static protected $locations = array(
00058 "ilNewsForContextBlockGUI" => "Services/News/",
00059 "ilPDNotesBlockGUI" => "Services/Notes/",
00060 "ilPDMailBlockGUI" => "Services/Mail/",
00061 "ilUsersOnlineBlockGUI" => "Services/PersonalDesktop/",
00062 "ilPDSysMessageBlockGUI" => "Services/Mail/",
00063 "ilPDSelectedItemsBlockGUI" => "Services/PersonalDesktop/",
00064 "ilBookmarkBlockGUI" => "Services/PersonalDesktop/",
00065 "ilPDNewsBlockGUI" => "Services/News/",
00066 "ilExternalFeedBlockGUI" => "Services/Block/",
00067 "ilPDExternalFeedBlockGUI" => "Services/Feeds/",
00068 "ilHtmlBlockGUI" => "Services/Block/",
00069 "ilPDFeedbackBlockGUI" => "Services/Feedback/");
00070
00071 static protected $block_types = array(
00072 "ilPDMailBlockGUI" => "pdmail",
00073 "ilPDNotesBlockGUI" => "pdnotes",
00074 "ilUsersOnlineBlockGUI" => "pdusers",
00075 "ilPDNewsBlockGUI" => "pdnews",
00076 "ilBookmarkBlockGUI" => "pdbookm",
00077 "ilNewsForContextBlockGUI" => "news",
00078 "ilExternalFeedBlockGUI" => "feed",
00079 "ilPDExternalFeedBlockGUI" => "pdfeed",
00080 "ilPDFeedbackBlockGUI" => "pdfeedb",
00081 "ilPDSysMessageBlockGUI" => "pdsysmess",
00082 "ilPDSelectedItemsBlockGUI" => "pditems",
00083 "ilHtmlBlockGUI" => "html"
00084 );
00085
00086
00087 protected $default_blocks = array(
00088 "cat" => array("ilNewsForContextBlockGUI" => IL_COL_RIGHT),
00089 "crs" => array("ilNewsForContextBlockGUI" => IL_COL_RIGHT),
00090 "grp" => array("ilNewsForContextBlockGUI" => IL_COL_RIGHT),
00091 "frm" => array("ilNewsForContextBlockGUI" => IL_COL_RIGHT),
00092 "root" => array(),
00093 "info" => array(
00094 "ilNewsForContextBlockGUI" => IL_COL_RIGHT),
00095 "pd" => array(
00096 "ilPDSysMessageBlockGUI" => IL_COL_LEFT,
00097 "ilPDFeedbackBlockGUI" => IL_COL_LEFT,
00098 "ilPDNewsBlockGUI" => IL_COL_LEFT,
00099 "ilPDSelectedItemsBlockGUI" => IL_COL_CENTER,
00100 "ilPDMailBlockGUI" => IL_COL_RIGHT,
00101 "ilPDNotesBlockGUI" => IL_COL_RIGHT,
00102 "ilUsersOnlineBlockGUI" => IL_COL_RIGHT,
00103 "ilBookmarkBlockGUI" => IL_COL_RIGHT)
00104 );
00105
00106
00107
00108 protected $custom_blocks = array(
00109 "cat" => array(),
00110 "crs" => array(),
00111 "grp" => array(),
00112 "frm" => array(),
00113 "root" => array(),
00114 "info" => array(),
00115 "pd" => array("ilPDExternalFeedBlockGUI")
00116 );
00117
00118
00119 protected $check_global_activation =
00120 array("news" => true,
00121 "pdnews" => true,
00122 "pdfeed" => true,
00123 "pdusers" => true,
00124 "pdbookm" => true,
00125 "pdnotes" => true);
00126
00127 protected $check_nr_limit =
00128 array("pdfeed" => true);
00129
00135 function ilColumnGUI($a_col_type = "", $a_side = "", $use_std_context = false)
00136 {
00137 global $ilUser, $tpl, $ilCtrl;
00138
00139 $this->setColType($a_col_type);
00140
00141
00142
00143
00144
00145 if ($_SESSION["col_".$this->getColType()."_".movement] == "on")
00146 {
00147 $this->setMovementMode(true);
00148 }
00149
00150 $this->setSide($a_side);
00151 }
00152
00158 static function getCmdSide()
00159 {
00160 return $_GET["col_side"];
00161 }
00162
00168 function setColType($a_coltype)
00169 {
00170 $this->coltype = $a_coltype;
00171 }
00172
00178 function getColType()
00179 {
00180 return $this->coltype;
00181 }
00182
00188 function setSide($a_side)
00189 {
00190 $this->side = $a_side;
00191 }
00192
00198 function getSide()
00199 {
00200 return $this->side;
00201 }
00202
00208 function setEnableEdit($a_enableedit)
00209 {
00210 $this->enableedit = $a_enableedit;
00211 }
00212
00218 function getEnableEdit()
00219 {
00220 return $this->enableedit;
00221 }
00222
00228 function setRepositoryMode($a_repositorymode)
00229 {
00230 $this->repositorymode = $a_repositorymode;
00231 }
00232
00238 function getRepositoryMode()
00239 {
00240 return $this->repositorymode;
00241 }
00242
00248 function setAdminCommands($a_admincommands)
00249 {
00250 $this->admincommands = $a_admincommands;
00251 }
00252
00258 function getAdminCommands()
00259 {
00260 return $this->admincommands;
00261 }
00262
00268 function setMovementMode($a_movementmode)
00269 {
00270 $this->movementmode = $a_movementmode;
00271 }
00272
00278 function getMovementMode()
00279 {
00280 return $this->movementmode;
00281 }
00282
00288 function setEnableMovement($a_enablemovement)
00289 {
00290 $this->enablemovement = $a_enablemovement;
00291 }
00292
00298 function getEnableMovement()
00299 {
00300 return $this->enablemovement;
00301 }
00302
00306 static function getScreenMode()
00307 {
00308 global $ilCtrl;
00309
00310 if ($ilCtrl->getCmdClass() == "ilcolumngui")
00311 {
00312 switch ($ilCtrl->getCmd())
00313 {
00314 case "addBlock":
00315 return IL_SCREEN_CENTER;
00316 }
00317 }
00318
00319 $cur_block_type = ($_GET["block_type"])
00320 ? $_GET["block_type"]
00321 : $_POST["block_type"];
00322
00323 if ($class = array_search($cur_block_type, self::$block_types))
00324 {
00325 include_once("./".self::$locations[$class]."classes/".
00326 "class.".$class.".php");
00327 return call_user_func(array($class, 'getScreenMode'));
00328 }
00329
00330 return IL_SCREEN_SIDE;
00331 }
00332
00340 function setBlockProperty($a_block_type, $a_property, $a_value)
00341 {
00342 $this->block_property[$a_block_type][$a_property] = $a_value;
00343 }
00344
00345 function getBlockProperties($a_block_type)
00346 {
00347 return $this->block_property[$a_block_type];
00348 }
00349
00350 function setAllBlockProperties($a_block_properties)
00351 {
00352 $this->block_property = $a_block_properties;
00353 }
00354
00360 function setRepositoryItems($a_repositoryitems)
00361 {
00362 $this->repositoryitems = $a_repositoryitems;
00363 }
00364
00370 function getRepositoryItems()
00371 {
00372 return $this->repositoryitems;
00373 }
00374
00378 function &executeCommand()
00379 {
00380 global $ilCtrl;
00381
00382 $ilCtrl->setParameter($this, "col_side" ,$this->getSide());
00383
00384
00385 $next_class = $ilCtrl->getNextClass();
00386 $cmd = $ilCtrl->getCmd("getHTML");
00387
00388 $cur_block_type = ($_GET["block_type"])
00389 ? $_GET["block_type"]
00390 : $_POST["block_type"];
00391
00392 if ($next_class != "")
00393 {
00394
00395 if ($gui_class = array_search($cur_block_type, self::$block_types))
00396 {
00397 include_once("./".self::$locations[$gui_class]."classes/".
00398 "class.".$gui_class.".php");
00399 $ilCtrl->setParameter($this, "block_type", $cur_block_type);
00400 $block_gui = new $gui_class();
00401 $block_gui->setProperties($this->block_property[$cur_block_type]);
00402 $block_gui->setRepositoryMode($this->getRepositoryMode());
00403 $block_gui->setEnableEdit($this->getEnableEdit());
00404 $block_gui->setAdminCommands($this->getAdminCommands());
00405 $block_gui->setConfigMode($this->getMovementMode());
00406
00407 if (in_array($gui_class, $this->custom_blocks[$this->getColType()]) ||
00408 in_array($cur_block_type, $this->rep_block_types))
00409 {
00410 $block_class = substr($gui_class, 0, strlen($gui_class)-3);
00411 include_once("./".self::$locations[$gui_class]."classes/".
00412 "class.".$block_class.".php");
00413 $app_block = new $block_class($_GET["block_id"]);
00414 $block_gui->setBlock($app_block);
00415 }
00416 $html = $ilCtrl->forwardCommand($block_gui);
00417 $ilCtrl->setParameter($this, "block_type", "");
00418
00419 return $html;
00420 }
00421 }
00422 else
00423 {
00424 return $this->$cmd();
00425 }
00426 }
00427
00431 function getHTML()
00432 {
00433 global $ilCtrl;
00434
00435 $ilCtrl->setParameter($this, "col_side" ,$this->getSide());
00436
00437 $this->tpl = new ilTemplate("tpl.column.html", true, true, "Services/Block");
00438
00439 $this->determineBlocks();
00440 $this->showBlocks();
00441
00442 if ($this->getEnableEdit() || !$this->getRepositoryMode())
00443 {
00444 $this->addHiddenBlockSelector();
00445 }
00446
00447 return $this->tpl->get();
00448 }
00449
00453 function showBlocks()
00454 {
00455 global $ilCtrl, $lng;
00456
00457 $blocks = array();
00458
00459 $i = 1;
00460 $sum_moveable = count($this->blocks[$this->getSide()]);
00461
00462 foreach($this->blocks[$this->getSide()] as $block)
00463 {
00464 $gui_class = $block["class"];
00465 $block_class = substr($block["class"], 0, strlen($block["class"])-3);
00466
00467
00468 include_once("./".self::$locations[$gui_class]."classes/".
00469 "class.".$gui_class.".php");
00470 $block_gui = new $gui_class();
00471 $block_gui->setProperties($this->block_property[$block["type"]]);
00472 $block_gui->setRepositoryMode($this->getRepositoryMode());
00473 $block_gui->setEnableEdit($this->getEnableEdit());
00474 $block_gui->setAdminCommands($this->getAdminCommands());
00475 $block_gui->setConfigMode($this->getMovementMode());
00476 $this->setPossibleMoves($block_gui, $i, $sum_moveable);
00477
00478
00479 if ($block["custom"])
00480 {
00481 include_once("./".self::$locations[$gui_class]."classes/".
00482 "class.".$block_class.".php");
00483 $app_block = new $block_class($block["id"]);
00484 $block_gui->setBlock($app_block);
00485 $block_gui->setRefId($block["ref_id"]);
00486 }
00487
00488 $ilCtrl->setParameter($this, "block_type", $block_gui->getBlockType());
00489 $this->tpl->setCurrentBlock("col_block");
00490 $html = $ilCtrl->getHTML($block_gui);
00491
00492
00493 if ($html == "" && $this->getRepositoryMode() &&
00494 $this->getMovementMode())
00495 {
00496 include_once("./Services/Block/classes/class.ilDummyBlockGUI.php");
00497 $bl = new ilDummyBlockGUI();
00498 $bl->setBlockId($block["id"]);
00499 $bl->setBlockType($block["type"]);
00500 $bl->setTitle($lng->txt("invisible_block"));
00501 $this->setPossibleMoves($bl, $i, $sum_moveable);
00502 $bl->setConfigMode($this->getMovementMode());
00503 $html = $bl->getHTML();
00504 }
00505
00506 $this->tpl->setVariable("BLOCK", $html);
00507 $this->tpl->parseCurrentBlock();
00508 $ilCtrl->setParameter($this, "block_type", "");
00509
00510
00511 if ($block["type"] != "pdsysmess" && $block["type"] != "pdfeedb" &&
00512 $block["type"] != "news")
00513 {
00514 $i++;
00515 }
00516 else
00517 {
00518 $sum_moveable--;
00519 }
00520 }
00521 }
00522
00523 function setPossibleMoves($a_block_gui, $i, $sum_moveable)
00524 {
00525 if ($this->getSide() == IL_COL_LEFT)
00526 {
00527 $a_block_gui->setAllowMove("right");
00528 }
00529 else if ($this->getSide() == IL_COL_RIGHT && !$this->getRepositoryMode())
00530 {
00531 $a_block_gui->setAllowMove("left");
00532 }
00533 if ($i > 1)
00534 {
00535 $a_block_gui->setAllowMove("up");
00536 }
00537 if ($i < $sum_moveable)
00538 {
00539 $a_block_gui->setAllowMove("down");
00540 }
00541 }
00542
00546 function addHiddenBlockSelector()
00547 {
00548 global $lng, $ilUser, $ilCtrl, $ilSetting;
00549
00550
00551 include_once("Services/Block/classes/class.ilBlockSetting.php");
00552 $hidden_blocks = array();
00553 $blocks = array("pdmail" => $lng->txt("mail"),
00554 "pdnotes" => $lng->txt("notes"),
00555 "pdusers" => $lng->txt("users_online"),
00556 "pdnews" => $lng->txt("news_internal_news"),
00557 "pdbookm" => $lng->txt("my_bms"),
00558 "news" => $lng->txt("news_internal_news"),
00559 "feed" => $lng->txt("feed"),
00560 "pdfeed" => $lng->txt("feed"),
00561 "html" => $lng->txt("html_block"),
00562 );
00563
00564
00565 foreach($this->blocks[$this->getSide()] as $block)
00566 {
00567 include_once("./".self::$locations[$block["class"]]."classes/".
00568 "class.".$block["class"].".php");
00569
00570 if ($block["custom"] == false)
00571 {
00572 if ($ilCtrl->getContextObjType() == "user")
00573 {
00574 if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId()) == 0)
00575 {
00576 $hidden_blocks[$block["type"]] = $blocks[$block["type"]];
00577 }
00578 }
00579 else if ($ilCtrl->getContextObjType() != "")
00580 {
00581 if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId(),
00582 $ilCtrl->getContextObjId()) == 0)
00583 {
00584 $hidden_blocks[$block["type"]."_".$ilCtrl->getContextObjId()] = $blocks[$block["type"]];
00585 }
00586 }
00587 }
00588 else
00589 {
00590 if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId(),
00591 $block["id"]) == 0)
00592 {
00593 include_once("./Services/Block/classes/class.ilCustomBlock.php");
00594 $cblock = new ilCustomBlock($block["id"]);
00595 $hidden_blocks[$block["type"]."_".$block["id"]] =
00596 $cblock->getTitle();
00597 }
00598 }
00599 }
00600 if (count($hidden_blocks) > 0)
00601 {
00602 $this->tpl->setCurrentBlock("hidden_block_selector");
00603 $this->tpl->setVariable("HB_ACTION", $ilCtrl->getFormAction($this));
00604 $this->tpl->setVariable("BLOCK_SEL", ilUtil::formSelect("", "block", $hidden_blocks,
00605 false, true, 0, "ilEditSelect"));
00606 $this->tpl->setVariable("TXT_ACTIVATE", $lng->txt("show"));
00607 $this->tpl->parseCurrentBlock();
00608 }
00609
00610
00611 if (!$this->getRepositoryMode() || $this->getEnableEdit())
00612 {
00613 $add_blocks = array();
00614 if ($this->getSide() == IL_COL_RIGHT)
00615 {
00616 if (is_array($this->custom_blocks[$this->getColType()]))
00617 {
00618 foreach($this->custom_blocks[$this->getColType()] as $block_class)
00619 {
00620 include_once("./".self::$locations[$block_class]."classes/".
00621 "class.".$block_class.".php");
00622 $block_type = call_user_func(array($block_class, 'getBlockType'));
00623
00624
00625 if ($this->isGloballyActivated($block_type))
00626 {
00627
00628 if (!$this->exceededLimit($block_type))
00629 {
00630 $add_blocks[$block_type] = $blocks[$block_type];
00631 }
00632 }
00633 }
00634 }
00635 }
00636 if (count($add_blocks) > 0)
00637 {
00638 $this->tpl->setCurrentBlock("add_block_selector");
00639 $this->tpl->setVariable("AB_ACTION", $ilCtrl->getFormAction($this));
00640 $this->tpl->setVariable("ADD_BLOCK_SEL", ilUtil::formSelect("", "block_type", $add_blocks,
00641 false, true, 0, "ilEditSelect"));
00642 $this->tpl->setVariable("TXT_ADD", $lng->txt("create"));
00643 $this->tpl->parseCurrentBlock();
00644 }
00645 }
00646
00647 if ($this->getSide() == IL_COL_RIGHT && $this->getEnableMovement())
00648 {
00649 $this->tpl->setCurrentBlock("toggle_movement");
00650 $this->tpl->setVariable("HREF_TOGGLE_MOVEMENT",
00651 $ilCtrl->getLinkTarget($this, "toggleMovement"));
00652 if ($_SESSION["col_".$this->getColType()."_".movement] == "on")
00653 {
00654 $this->tpl->setVariable("TXT_TOGGLE_MOVEMENT",
00655 $lng->txt("stop_moving_blocks"));
00656 }
00657 else
00658 {
00659 $this->tpl->setVariable("TXT_TOGGLE_MOVEMENT",
00660 $lng->txt("move_blocks"));
00661 }
00662 $this->tpl->parseCurrentBlock();
00663 }
00664
00665
00666
00667 }
00668
00669 function toggleMovement()
00670 {
00671 global $ilCtrl;
00672
00673 if ($_SESSION["col_".$this->getColType()."_".movement] == "on")
00674 {
00675 $_SESSION["col_".$this->getColType()."_".movement] = "off";
00676 }
00677 else
00678 {
00679 $_SESSION["col_".$this->getColType()."_".movement] = "on";
00680 }
00681 $ilCtrl->returnToParent($this);
00682 }
00683
00687 function updateBlock()
00688 {
00689 global $ilCtrl, $ilBench;
00690
00691 $this->determineBlocks();
00692 $i = 1;
00693 $sum_moveable = count($this->blocks[$this->getSide()]);
00694
00695 foreach ($this->blocks[$this->getSide()] as $block)
00696 {
00697
00698 include_once("./".self::$locations[$block["class"]]."classes/".
00699 "class.".$block["class"].".php");
00700
00701
00702
00703 if (!$block["custom"] && $ilCtrl->getContextObjType() != "" && $ilCtrl->getContextObjType() != "user")
00704 {
00705 $block["id"] = $ilCtrl->getContextObjId();
00706 }
00707
00708
00709 if ($_GET["block_id"] == "block_".$block["type"]."_".$block["id"])
00710 {
00711 $gui_class = $block["class"];
00712 $block_class = substr($block["class"], 0, strlen($block["class"])-3);
00713
00714 $block_gui = new $gui_class();
00715 $block_gui->setProperties($this->block_property[$block["type"]]);
00716 $block_gui->setRepositoryMode($this->getRepositoryMode());
00717 $block_gui->setEnableEdit($this->getEnableEdit());
00718 $block_gui->setAdminCommands($this->getAdminCommands());
00719 $block_gui->setConfigMode($this->getMovementMode());
00720
00721 if ($this->getSide() == IL_COL_LEFT)
00722 {
00723 $block_gui->setAllowMove("right");
00724 }
00725 else if ($this->getSide() == IL_COL_RIGHT &&
00726 !$this->getRepositoryMode())
00727 {
00728 $block_gui->setAllowMove("left");
00729 }
00730 if ($i > 1)
00731 {
00732 $block_gui->setAllowMove("up");
00733 }
00734 if ($i < $sum_moveable)
00735 {
00736 $block_gui->setAllowMove("down");
00737 }
00738
00739
00740 if ($block["custom"])
00741 {
00742 include_once("./".self::$locations[$gui_class]."classes/".
00743 "class.".$block_class.".php");
00744 $app_block = new $block_class($block["id"]);
00745 $block_gui->setBlock($app_block);
00746 $block_gui->setRefId($block["ref_id"]);
00747 }
00748
00749 $ilCtrl->setParameter($this, "block_type", $block["type"]);
00750 echo $ilCtrl->getHTML($block_gui);
00751 $ilBench->save();
00752 exit;
00753 }
00754
00755
00756 if ($block["type"] != "pdsysmess" && $block["type"] != "pdfeedb"
00757 && $block["type"] != "news")
00758 {
00759 $i++;
00760 }
00761 else
00762 {
00763 $sum_moveable--;
00764 }
00765 }
00766 echo "Error: ilColumnGUI::updateBlock: Block '".
00767 $_GET["block_id"]."' unknown.";
00768 exit;
00769 }
00770
00774 function activateBlock()
00775 {
00776 global $ilUser, $ilCtrl;
00777
00778 if ($_POST["block"] != "")
00779 {
00780 $block = explode("_", $_POST["block"]);
00781 include_once("Services/Block/classes/class.ilBlockSetting.php");
00782 ilBlockSetting::_writeDetailLevel($block[0], 2, $ilUser->getId(), $block[1]);
00783 }
00784
00785 $ilCtrl->returnToParent($this);
00786 }
00787
00791 function addBlock()
00792 {
00793 global $ilCtrl;
00794
00795 $class = array_search($_POST["block_type"], self::$block_types);
00796
00797 $ilCtrl->setCmdClass($class);
00798 $ilCtrl->setCmd("create");
00799 include_once("./".self::$locations[$class]."classes/class.".$class.".php");
00800 $block_gui = new $class();
00801 $block_gui->setProperties($this->block_property[$_POST["block_type"]]);
00802 $block_gui->setRepositoryMode($this->getRepositoryMode());
00803 $block_gui->setEnableEdit($this->getEnableEdit());
00804 $block_gui->setAdminCommands($this->getAdminCommands());
00805 $block_gui->setConfigMode($this->getMovementMode());
00806
00807 $ilCtrl->setParameter($this, "block_type", $_POST["block_type"]);
00808 $html = $ilCtrl->forwardCommand($block_gui);
00809 $ilCtrl->setParameter($this, "block_type", "");
00810 return $html;
00811 }
00812
00816 function determineBlocks()
00817 {
00818 global $ilUser, $ilCtrl, $ilSetting;
00819
00820 include_once("./Services/Block/classes/class.ilBlockSetting.php");
00821 $this->blocks[IL_COL_LEFT] = array();
00822 $this->blocks[IL_COL_RIGHT] = array();
00823 $this->blocks[IL_COL_CENTER] = array();
00824
00825 $user_id = ($this->getColType() == "pd")
00826 ? $ilUser->getId()
00827 : 0;
00828
00829 $def_nr = 1000;
00830 if (is_array($this->default_blocks[$this->getColType()]))
00831 {
00832 foreach($this->default_blocks[$this->getColType()] as $class => $def_side)
00833 {
00834 $type = self::$block_types[$class];
00835
00836 if ($this->isGloballyActivated($type))
00837 {
00838 $nr = ilBlockSetting::_lookupNr($type, $user_id);
00839 if ($nr === false)
00840 {
00841 $nr = $def_nr++;
00842 }
00843
00844
00845
00846 if ($type == "news")
00847 {
00848 $nr = -15;
00849 }
00850 if ($type == "pdsysmess")
00851 {
00852 $nr = -15;
00853 }
00854 if ($type == "pdfeedb")
00855 {
00856 $nr = -10;
00857 }
00858 $side = ilBlockSetting::_lookupSide($type, $user_id);
00859 if ($side === false)
00860 {
00861 $side = $def_side;
00862 }
00863
00864 $this->blocks[$side][] = array(
00865 "nr" => $nr,
00866 "class" => $class,
00867 "type" => $type,
00868 "id" => 0,
00869 "custom" => false);
00870 }
00871 }
00872 }
00873
00874 if (!$this->getRepositoryMode())
00875 {
00876 include_once("./Services/Block/classes/class.ilCustomBlock.php");
00877 $costum_block = new ilCustomBlock();
00878 $costum_block->setContextObjId($ilCtrl->getContextObjId());
00879 $costum_block->setContextObjType($ilCtrl->getContextObjType());
00880 $c_blocks = $costum_block->queryBlocksForContext();
00881
00882 foreach($c_blocks as $c_block)
00883 {
00884 $type = $c_block["type"];
00885
00886 if ($this->isGloballyActivated($type))
00887 {
00888 $class = array_search($type, self::$block_types);
00889 $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]);
00890 if ($nr === false)
00891 {
00892 $nr = $def_nr++;
00893 }
00894 $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
00895 if ($side === false)
00896 {
00897 $side = IL_COL_RIGHT;
00898 }
00899
00900 $this->blocks[$side][] = array(
00901 "nr" => $nr,
00902 "class" => $class,
00903 "type" => $type,
00904 "id" => $c_block["id"],
00905 "custom" => true);
00906 }
00907 }
00908 }
00909 else
00910 {
00911 include_once("./Services/Block/classes/class.ilCustomBlock.php");
00912 $rep_items = $this->getRepositoryItems();
00913
00914 foreach($this->rep_block_types as $block_type)
00915 {
00916 if ($this->isGloballyActivated($block_type))
00917 {
00918 if (!is_array($rep_items[$block_type]))
00919 {
00920 continue;
00921 }
00922 foreach($rep_items[$block_type] as $item)
00923 {
00924 $costum_block = new ilCustomBlock();
00925 $costum_block->setContextObjId($item["obj_id"]);
00926 $costum_block->setContextObjType($block_type);
00927 $c_blocks = $costum_block->queryBlocksForContext();
00928 $c_block = $c_blocks[0];
00929
00930 $type = $block_type;
00931 $class = array_search($type, self::$block_types);
00932 $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]);
00933 if ($nr === false)
00934 {
00935 $nr = $def_nr++;
00936 }
00937 $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
00938 if ($side === false)
00939 {
00940 $side = IL_COL_RIGHT;
00941 }
00942
00943 $this->blocks[$side][] = array(
00944 "nr" => $nr,
00945 "class" => $class,
00946 "type" => $type,
00947 "id" => $c_block["id"],
00948 "custom" => true,
00949 "ref_id" => $item["ref_id"]);
00950 }
00951 }
00952 }
00953 }
00954
00955
00956 $this->blocks[IL_COL_LEFT] =
00957 ilUtil::sortArray($this->blocks[IL_COL_LEFT], "nr", "asc", true);
00958 $this->blocks[IL_COL_RIGHT] =
00959 ilUtil::sortArray($this->blocks[IL_COL_RIGHT], "nr", "asc", true);
00960 $this->blocks[IL_COL_CENTER] =
00961 ilUtil::sortArray($this->blocks[IL_COL_CENTER], "nr", "asc", true);
00962
00963 }
00964
00965 function moveBlock()
00966 {
00967 global $ilUser, $ilCtrl;
00968
00969 $this->determineBlocks();
00970
00971 if (in_array($this->getColType(), array("pd", "crs", "cat", "grp")))
00972 {
00973 $bid = explode("_", $_GET["block_id"]);
00974 $i = 2;
00975 foreach($this->blocks[$this->getCmdSide()] as $block)
00976 {
00977
00978 if ($this->getRepositoryMode() || ilBlockSetting::_lookupDetailLevel($block["type"],
00979 $ilUser->getId(), $block["id"]) != 0)
00980 {
00981 $user_id = ($this->getRepositoryMode())
00982 ? 0
00983 : $ilUser->getId();
00984
00985 ilBlockSetting::_writeNumber($block["type"], $i, $user_id, $block["id"]);
00986
00987 if ($block["type"] == $bid[0] && $block["id"] == $bid[1])
00988 {
00989 if ($_GET["move_dir"] == "up")
00990 {
00991 ilBlockSetting::_writeNumber($block["type"], $i-3, $user_id, $block["id"]);
00992 }
00993 if ($_GET["move_dir"] == "down")
00994 {
00995 ilBlockSetting::_writeNumber($block["type"], $i+3, $user_id, $block["id"]);
00996 }
00997 if ($_GET["move_dir"] == "left")
00998 {
00999 ilBlockSetting::_writeNumber($block["type"], 200, $user_id, $block["id"]);
01000 ilBlockSetting::_writeSide($block["type"], IL_COL_LEFT, $user_id, $block["id"]);
01001 }
01002 if ($_GET["move_dir"] == "right")
01003 {
01004 ilBlockSetting::_writeNumber($block["type"], 200, $user_id, $block["id"]);
01005 ilBlockSetting::_writeSide($block["type"], IL_COL_RIGHT, $user_id, $block["id"]);
01006 }
01007 }
01008 else
01009 {
01010 ilBlockSetting::_writeNumber($block["type"], $i, $user_id, $block["id"]);
01011 }
01012 $i+=2;
01013 }
01014 }
01015 }
01016 $ilCtrl->returnToParent($this);
01017 }
01018
01022 protected function isGloballyActivated($a_type)
01023 {
01024 global $ilSetting;
01025 if ($this->check_global_activation[$a_type])
01026 {
01027 if ($a_type == 'pdbookm')
01028 {
01029 if (!$ilSetting->get("disable_bookmarks"))
01030 {
01031 return true;
01032 }
01033 return false;
01034 }
01035 else if ($a_type == 'pdnotes')
01036 {
01037 if (!$ilSetting->get("disable_notes"))
01038 {
01039 return true;
01040 }
01041 return false;
01042 }
01043 else if ($ilSetting->get("block_activated_".$a_type))
01044 {
01045 return true;
01046 }
01047 return false;
01048 }
01049 return true;
01050 }
01051
01055 protected function exceededLimit($a_type)
01056 {
01057 global $ilSetting, $ilCtrl;
01058
01059 if ($this->check_nr_limit[$a_type])
01060 {
01061 if (!$this->getRepositoryMode())
01062 {
01063 include_once("./Services/Block/classes/class.ilCustomBlock.php");
01064 $costum_block = new ilCustomBlock();
01065 $costum_block->setContextObjId($ilCtrl->getContextObjId());
01066 $costum_block->setContextObjType($ilCtrl->getContextObjType());
01067 $costum_block->setType($a_type);
01068 $res = $costum_block->queryCntBlockForContext();
01069 $cnt = (int) $res[0]["cnt"];
01070 }
01071 else
01072 {
01073 return false;
01074 }
01075
01076
01077 if ($ilSetting->get("block_limit_".$a_type) > $cnt)
01078 {
01079 return false;
01080 }
01081 else
01082 {
01083 return true;
01084 }
01085 }
01086 return false;
01087 }
01088
01089 }