ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilColumnGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4define ("IL_COL_LEFT", "left");
5define ("IL_COL_RIGHT", "right");
6define ("IL_COL_CENTER", "center");
7
8define ("IL_SCREEN_SIDE", "");
9define ("IL_SCREEN_CENTER", "center");
10define ("IL_SCREEN_FULL", "full");
11
23{
24 protected $side = IL_COL_RIGHT;
25 protected $type;
26 protected $enableedit = false;
27 protected $repositorymode = false;
28 protected $repositoryitems = array();
29
30 // all blocks that are repository objects
31 protected $rep_block_types = array("feed","poll");
32 protected $block_property = array();
33 protected $admincommands = null;
34 protected $movementmode = null;
35 protected $enablemovement = false;
36
40 protected $action_menu;
41
42 //
43 // This two arrays may be replaced by some
44 // xml or other magic in the future...
45 //
46
47 static protected $locations = array(
48 "ilNewsForContextBlockGUI" => "Services/News/",
49 "ilCalendarBlockGUI" => "Services/Calendar/",
50 "ilPDCalendarBlockGUI" => "Services/Calendar/",
51 "ilPDNotesBlockGUI" => "Services/Notes/",
52 "ilPDMailBlockGUI" => "Services/Mail/",
53 "ilUsersOnlineBlockGUI" => "Services/PersonalDesktop/",
54 "ilPDSysMessageBlockGUI" => "Services/Mail/",
55 "ilPDSelectedItemsBlockGUI" => "Services/PersonalDesktop/",
56 "ilBookmarkBlockGUI" => "Services/Bookmarks/",
57 "ilPDNewsBlockGUI" => "Services/News/",
58 "ilExternalFeedBlockGUI" => "Services/Block/",
59 "ilPDExternalFeedBlockGUI" => "Services/Feeds/",
60 'ilPDTaggingBlockGUI' => 'Services/Tagging/',
61 'ilChatroomBlockGUI' => 'Modules/Chatroom/',
62 'ilPollBlockGUI' => 'Modules/Poll/',
63 'ilClassificationBlockGUI' => 'Services/Classification/',
64 'ilPDPortfolioBlockGUI' => 'Modules/Portfolio/',
65 "ilPDStudyProgrammeSimpleListGUI" => "Modules/StudyProgramme/",
66 "ilPDStudyProgrammeExpandableListGUI" => "Modules/StudyProgramme/",
67 "ilForumPostingDraftsBlockGUI" => "Modules/Forum/"
68 );
69
70 static protected $block_types = array(
71 "ilPDMailBlockGUI" => "pdmail",
72 "ilPDNotesBlockGUI" => "pdnotes",
73 "ilUsersOnlineBlockGUI" => "pdusers",
74 "ilPDNewsBlockGUI" => "pdnews",
75 "ilBookmarkBlockGUI" => "pdbookm",
76 "ilNewsForContextBlockGUI" => "news",
77 "ilCalendarBlockGUI" => "cal",
78 "ilPDCalendarBlockGUI" => "pdcal",
79 "ilExternalFeedBlockGUI" => "feed",
80 "ilPDExternalFeedBlockGUI" => "pdfeed",
81 "ilPDSysMessageBlockGUI" => "pdsysmess",
82 "ilPDSelectedItemsBlockGUI" => "pditems",
83 'ilPDTaggingBlockGUI' => 'pdtag',
84 'ilChatroomBlockGUI' => 'chatviewer',
85 'ilPollBlockGUI' => 'poll',
86 'ilClassificationBlockGUI' => 'clsfct',
87 'ilPDPortfolioBlockGUI' => 'pdportf',
88 "ilPDStudyProgrammeSimpleListGUI" => "prgsimplelist",
89 "ilPDStudyProgrammeExpandableListGUI" => "prgexpandablelist",
90 "ilForumPostingDraftsBlockGUI" => "pdfrmpostdraft"
91 );
92
93
94 protected $default_blocks = array(
95 "cat" => array(
96 "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
97 "ilClassificationBlockGUI" => IL_COL_RIGHT
98 ),
99 "crs" => array(
100 "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
101 "ilCalendarBlockGUI" => IL_COL_RIGHT,
102 "ilClassificationBlockGUI" => IL_COL_RIGHT
103 ),
104 "grp" => array(
105 "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
106 "ilCalendarBlockGUI" => IL_COL_RIGHT,
107 "ilClassificationBlockGUI" => IL_COL_RIGHT
108 ),
109 "frm" => array("ilNewsForContextBlockGUI" => IL_COL_RIGHT),
110 "root" => array(),
111 "info" => array(
112 "ilNewsForContextBlockGUI" => IL_COL_RIGHT),
113 "pd" => array(
114 "ilPDCalendarBlockGUI" => IL_COL_RIGHT,
115 "ilPDPortfolioBlockGUI" => IL_COL_RIGHT,
116 "ilPDSysMessageBlockGUI" => IL_COL_LEFT,
117 "ilPDNewsBlockGUI" => IL_COL_LEFT,
118 "ilPDStudyProgrammeSimpleListGUI" => IL_COL_CENTER,
119 "ilPDStudyProgrammeExpandableListGUI" => IL_COL_CENTER,
120 "ilPDSelectedItemsBlockGUI" => IL_COL_CENTER,
121 "ilPDMailBlockGUI" => IL_COL_RIGHT,
122 "ilPDNotesBlockGUI" => IL_COL_RIGHT,
123 //"ilUsersOnlineBlockGUI" => IL_COL_RIGHT,
124 "ilBookmarkBlockGUI" => IL_COL_RIGHT,
125 "ilPDTaggingBlockGUI" => IL_COL_RIGHT,
126 "ilChatroomBlockGUI" => IL_COL_RIGHT,
127 "ilForumPostingDraftsBlockGUI" => IL_COL_RIGHT
128 )
129 );
130
131 // these are only for pd blocks
132 // other blocks are rep objects now
133 protected $custom_blocks = array(
134 "cat" => array(),
135 "crs" => array(),
136 "grp" => array(),
137 "frm" => array(),
138 "root" => array(),
139 "info" => array(),
140 "fold" => array(),
141 "pd" => array("ilPDExternalFeedBlockGUI")
142 );
143
144 // check global activation for these block types
145 // @todo: add calendar
147 array("news" => true,
148 "cal" => true,
149 "pdcal" => true,
150 "pdnews" => true,
151 "pdfeed" => true,
152 "pdusers" => true,
153 "pdbookm" => true,
154 "pdtag" => true,
155 "pdsysmess" => true,
156 "pdnotes" => true,
157 "chatviewer" => true,
158 "pdfrmpostdraft" => true,
159 "tagcld" => true,
160 "pdportf" => true,
161 "clsfct" => true);
162
163 protected $check_nr_limit =
164 array("pdfeed" => true);
165
171 public function __construct($a_col_type = "", $a_side = "", $use_std_context = false)
172 {
173 $this->setColType($a_col_type);
174 $this->setSide($a_side);
175 }
176
187 public static function addCustomBlockLocation($className, $path)
188 {
189 self::$locations[$className] = $path;
190 }
191
202 public static function addCustomBlockType($className, $identifier)
203 {
204 self::$block_types[$className] = $identifier;
205 }
206
212 static function getCmdSide()
213 {
214 return $_GET["col_side"];
215 }
216
222 function setColType($a_coltype)
223 {
224 $this->coltype = $a_coltype;
225 }
226
232 function getColType()
233 {
234 return $this->coltype;
235 }
236
242 function setSide($a_side)
243 {
244 $this->side = $a_side;
245 }
246
252 function getSide()
253 {
254 return $this->side;
255 }
256
262 function setEnableEdit($a_enableedit)
263 {
264 $this->enableedit = $a_enableedit;
265 }
266
272 function getEnableEdit()
273 {
274 return $this->enableedit;
275 }
276
282 function setRepositoryMode($a_repositorymode)
283 {
284 $this->repositorymode = $a_repositorymode;
285 }
286
293 {
295 }
296
302 function setAdminCommands($a_admincommands)
303 {
304 $this->admincommands = $a_admincommands;
305 }
306
313 {
315 }
316
322 function setMovementMode($a_movementmode)
323 {
324 $this->movementmode = $a_movementmode;
325 }
326
333 {
334 return $this->movementmode;
335 }
336
342 function setEnableMovement($a_enablemovement)
343 {
344 $this->enablemovement = $a_enablemovement;
345 }
346
353 {
355 }
356
360 static function getScreenMode()
361 {
362 global $ilCtrl;
363
364 if ($ilCtrl->getCmdClass() == "ilcolumngui")
365 {
366 switch ($ilCtrl->getCmd())
367 {
368 case "addBlock":
369 return IL_SCREEN_CENTER;
370 }
371 }
372
373 $cur_block_type = "";
374 if (isset($_GET["block_type"]) && $_GET["block_type"])
375 {
376 $cur_block_type = $_GET["block_type"];
377 }
378 else if (isset($_POST["block_type"]))
379 {
380 $cur_block_type = $_POST["block_type"];
381 }
382
383 if ($class = array_search($cur_block_type, self::$block_types))
384 {
385 include_once("./".self::$locations[$class]."classes/".
386 "class.".$class.".php");
387 return call_user_func(array($class, 'getScreenMode'));
388 }
389
390 return IL_SCREEN_SIDE;
391 }
392
400 function setBlockProperty($a_block_type, $a_property, $a_value)
401 {
402 $this->block_property[$a_block_type][$a_property] = $a_value;
403 }
404
405 function getBlockProperties($a_block_type)
406 {
407 return $this->block_property[$a_block_type];
408 }
409
410 function setAllBlockProperties($a_block_properties)
411 {
412 $this->block_property = $a_block_properties;
413 }
414
420 function setRepositoryItems($a_repositoryitems)
421 {
422 $this->repositoryitems = $a_repositoryitems;
423 }
424
431 {
433 }
434
438 function executeCommand()
439 {
440 global $ilCtrl;
441
442 $ilCtrl->setParameter($this, "col_side" ,$this->getSide());
443 //$ilCtrl->saveParameter($this, "col_side");
444
445 $next_class = $ilCtrl->getNextClass();
446 $cmd = $ilCtrl->getCmd("getHTML");
447
448 $cur_block_type = ($_GET["block_type"])
449 ? $_GET["block_type"]
450 : $_POST["block_type"];
451
452 if ($next_class != "")
453 {
454 // forward to block
455 if ($gui_class = array_search($cur_block_type, self::$block_types))
456 {
457 include_once("./".self::$locations[$gui_class]."classes/".
458 "class.".$gui_class.".php");
459 $ilCtrl->setParameter($this, "block_type", $cur_block_type);
460 $block_gui = new $gui_class();
461 $block_gui->setProperties($this->block_property[$cur_block_type]);
462 $block_gui->setRepositoryMode($this->getRepositoryMode());
463 $block_gui->setEnableEdit($this->getEnableEdit());
464 $block_gui->setAdminCommands($this->getAdminCommands());
465
466 if (in_array($gui_class, $this->custom_blocks[$this->getColType()]) ||
467 in_array($cur_block_type, $this->rep_block_types))
468 {
469 $block_class = substr($gui_class, 0, strlen($gui_class)-3);
470 include_once("./".self::$locations[$gui_class]."classes/".
471 "class.".$block_class.".php");
472 $app_block = new $block_class($_GET["block_id"]);
473 $block_gui->setBlock($app_block);
474 }
475 $html = $ilCtrl->forwardCommand($block_gui);
476 $ilCtrl->setParameter($this, "block_type", "");
477
478 return $html;
479 }
480 }
481 else
482 {
483 return $this->$cmd();
484 }
485 }
486
490 function getHTML()
491 {
492 global $ilCtrl, $ilBench;
493
494 $ilBench->start("Column", "getHTML");
495
496 $ilCtrl->setParameter($this, "col_side" ,$this->getSide());
497
498 $this->tpl = new ilTemplate("tpl.column.html", true, true, "Services/Block");
499
500 $ilBench->start("Column", "determineBlocks");
501 $this->determineBlocks();
502 $ilBench->stop("Column", "determineBlocks");
503
504 $ilBench->start("Column", "showBlocks");
505 $this->showBlocks();
506 $ilBench->stop("Column", "showBlocks");
507
508 if ($this->getEnableEdit() || !$this->getRepositoryMode())
509 {
510 $this->addHiddenBlockSelector();
511 }
512
513 $ilBench->stop("Column", "getHTML");
514
515 return $this->tpl->get();
516 }
517
521 function showBlocks()
522 {
523 global $ilCtrl, $lng, $ilUser, $ilBench;
524
525 $i = 1;
526 $sum_moveable = count($this->blocks[$this->getSide()]);
527
528 foreach($this->blocks[$this->getSide()] as $block)
529 {
530 if ($ilCtrl->getContextObjType() != "user" ||
532 $ilUser->getId(), $block["id"]) > 0)
533 {
534 $gui_class = $block["class"];
535 $block_class = substr($block["class"], 0, strlen($block["class"])-3);
536
537 // get block gui class
538 include_once("./".self::$locations[$gui_class]."classes/".
539 "class.".$gui_class.".php");
540 $ilBench->start("Column", "instantiate-".$block["type"]);
541 $block_gui = new $gui_class();
542 $ilBench->stop("Column", "instantiate-".$block["type"]);
543 if (isset($this->block_property[$block["type"]]))
544 {
545 $block_gui->setProperties($this->block_property[$block["type"]]);
546 }
547 $block_gui->setRepositoryMode($this->getRepositoryMode());
548 $block_gui->setEnableEdit($this->getEnableEdit());
549 $block_gui->setAdminCommands($this->getAdminCommands());
550
551 // get block for custom blocks
552 if ($block["custom"])
553 {
554 $path = "./".self::$locations[$gui_class]."classes/".
555 "class.".$block_class.".php";
556 if(file_exists($path))
557 {
558 include_once($path);
559 $app_block = new $block_class($block["id"]);
560 }
561 else
562 {
563 // we only need generic block
564 $app_block = new ilCustomBlock($block["id"]);
565 }
566 $block_gui->setBlock($app_block);
567 if (isset($block["ref_id"]))
568 {
569 $block_gui->setRefId($block["ref_id"]);
570 }
571 }
572
573 $ilCtrl->setParameter($this, "block_type", $block_gui->getBlockType());
574 $this->tpl->setCurrentBlock("col_block");
575
576 $ilBench->start("Column", "showBlocks-".$block_gui->getBlockType());
577 $html = $ilCtrl->getHTML($block_gui);
578 $ilBench->stop("Column", "showBlocks-".$block_gui->getBlockType());
579
580 // dummy block, if non visible, but movement is ongoing
581 if ($html == "" && $this->getRepositoryMode() &&
582 $this->getMovementMode())
583 {
584 include_once("./Services/Block/classes/class.ilDummyBlockGUI.php");
585 $bl = new ilDummyBlockGUI();
586 $bl->setBlockId($block["id"]);
587 $bl->setBlockType($block["type"]);
588 $bl->setTitle($lng->txt("invisible_block"));
589 $bl->setConfigMode($this->getMovementMode());
590 $html = $bl->getHTML();
591 }
592
593 // don't render a block if it's empty
594 if ($html != "")
595 {
596 $this->tpl->setVariable("BLOCK", $html);
597 $this->tpl->parseCurrentBlock();
598 $ilCtrl->setParameter($this, "block_type", "");
599 }
600
601 // count (moveable) blocks
602 if ($block["type"] != "pdsysmess" && $block["type"] != "pdfeedb" &&
603 $block["type"] != "news")
604 {
605 $i++;
606 }
607 else
608 {
609 $sum_moveable--;
610 }
611 }
612 }
613 }
614
618 function addHiddenBlockSelector()
619 {
626 global $lng, $ilUser, $ilCtrl, $tpl;
627
628 // show selector for hidden blocks
629 include_once("Services/Block/classes/class.ilBlockSetting.php");
630 $hidden_blocks = array();
631
632 foreach($this->blocks[$this->getSide()] as $block)
633 {
634 include_once("./".self::$locations[$block["class"]]."classes/".
635 "class.".$block["class"].".php");
636
637 if ($block["custom"] == false)
638 {
639 if ($ilCtrl->getContextObjType() == "user") // personal desktop
640 {
641 if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId()) == 0)
642 {
643 $hidden_blocks[$block["type"]] = $lng->txt('block_show_'.$block["type"]);
644 }
645 }
646 else if ($ilCtrl->getContextObjType() != "")
647 {
648 if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId(),
649 $ilCtrl->getContextObjId()) == 0)
650 {
651 $hidden_blocks[$block["type"]."_".$ilCtrl->getContextObjId()] = $lng->txt('block_show_'.$block["type"]);
652 }
653 }
654 }
655 else
656 {
657 if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId(),
658 $block["id"]) == 0)
659 {
660 include_once("./Services/Block/classes/class.ilCustomBlock.php");
661 $cblock = new ilCustomBlock($block["id"]);
662 $hidden_blocks[$block["type"]."_".$block["id"]] = sprintf($lng->txt('block_show_x'), $cblock->getTitle());
663 }
664 }
665 }
666 if(count($hidden_blocks) > 0)
667 {
668 foreach($hidden_blocks as $id => $title)
669 {
670 $ilCtrl->setParameter($this, 'block', $id);
671 $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'activateBlock'));
672 $ilCtrl->setParameter($this, 'block', '');
673 }
674 }
675
676 // create block selection list
677 if (!$this->getRepositoryMode() || $this->getEnableEdit())
678 {
679 $add_blocks = array();
680 if ($this->getSide() == IL_COL_RIGHT)
681 {
682 if (is_array($this->custom_blocks[$this->getColType()]))
683 {
684 foreach($this->custom_blocks[$this->getColType()] as $block_class)
685 {
686 include_once("./".self::$locations[$block_class]."classes/".
687 "class.".$block_class.".php");
688 $block_type = call_user_func(array($block_class, 'getBlockType'));
689
690 // check if block type is globally (de-)activated
691 if ($this->isGloballyActivated($block_type))
692 {
693 // check if number of blocks is limited
694 if (!$this->exceededLimit($block_type))
695 {
696 $add_blocks[$block_type] = $lng->txt('block_create_'.$block_type);
697 }
698 }
699 }
700 }
701 }
702 if(count($add_blocks) > 0)
703 {
704 foreach($add_blocks as $id => $title)
705 {
706 $ilCtrl->setParameter($this, 'block_type', $id);
707 $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'addBlock'));
708 $ilCtrl->setParameter($this, 'block_type', '');
709 }
710 }
711 }
712
713 $this->addBlockSorting();
714 }
715
719 protected function addBlockSorting()
720 {
721 if($this->getSide() == IL_COL_CENTER && $this->getEnableMovement())
722 {
728 global $ilBrowser, $tpl, $ilCtrl;
729
730 include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
733
734 if($ilBrowser->isMobile() || $ilBrowser->isIpad())
735 {
736 $tpl->addJavaScript('./Services/jQuery/js/jquery.ui.touch-punch.min.js');
737 }
738 $tpl->addJavaScript('./Services/Block/js/block_sorting.js');
739
740 // set the col_side parameter to pass the ctrl structure flow
741 $ilCtrl->setParameter($this, 'col_side', IL_COL_CENTER);
742
743 $this->tpl->setVariable('BLOCK_SORTING_STORAGE_URL', $ilCtrl->getLinkTarget($this, 'saveBlockSortingAsynch', '', true, false));
744 $this->tpl->setVariable('BLOCK_COLUMNS', json_encode(array('il_left_col', 'il_right_col')));
745 $this->tpl->setVariable('BLOCK_COLUMNS_SELECTOR', '#il_left_col,#il_right_col');
746 $this->tpl->setVariable('BLOCK_COLUMNS_PARAMETERS', json_encode(array(IL_COL_LEFT, IL_COL_RIGHT)));
747
748 // restore col_side parameter
749 $ilCtrl->setParameter($this, 'col_side', $this->getSide());
750 }
751 }
752
756 function updateBlock()
757 {
758 global $ilCtrl, $ilBench;
759
760 $this->determineBlocks();
761 $i = 1;
762 $sum_moveable = count($this->blocks[$this->getSide()]);
763
764 foreach ($this->blocks[$this->getSide()] as $block)
765 {
766
767 include_once("./".self::$locations[$block["class"]]."classes/".
768 "class.".$block["class"].".php");
769
770 // set block id to context obj id,
771 // if block is not a custom block and context is not personal desktop
772 if (!$block["custom"] && $ilCtrl->getContextObjType() != "" && $ilCtrl->getContextObjType() != "user")
773 {
774 $block["id"] = $ilCtrl->getContextObjId();
775 }
776
777 //if (is_int(strpos($_GET["block_id"], "block_".$block["type"]."_".$block["id"])))
778
779 if ($_GET["block_id"] == "block_".$block["type"]."_".$block["id"])
780 {
781 $gui_class = $block["class"];
782 $block_class = substr($block["class"], 0, strlen($block["class"])-3);
783
784 $block_gui = new $gui_class();
785 $block_gui->setProperties($this->block_property[$block["type"]]);
786 $block_gui->setRepositoryMode($this->getRepositoryMode());
787 $block_gui->setEnableEdit($this->getEnableEdit());
788 $block_gui->setAdminCommands($this->getAdminCommands());
789
790 // get block for custom blocks
791 if ($block["custom"])
792 {
793 include_once("./".self::$locations[$gui_class]."classes/".
794 "class.".$block_class.".php");
795 $app_block = new $block_class($block["id"]);
796 $block_gui->setBlock($app_block);
797 $block_gui->setRefId($block["ref_id"]);
798 }
799
800 $ilCtrl->setParameter($this, "block_type", $block["type"]);
801 echo $ilCtrl->getHTML($block_gui);
802 $ilBench->save();
803 exit;
804 }
805
806 // count (moveable) blocks
807 if ($block["type"] != "pdsysmess" && $block["type"] != "pdfeedb"
808 && $block["type"] != "news")
809 {
810 $i++;
811 }
812 else
813 {
814 $sum_moveable--;
815 }
816 }
817 echo "Error: ilColumnGUI::updateBlock: Block '".
818 $_GET["block_id"]."' unknown.";
819 exit;
820 }
821
825 function activateBlock()
826 {
827 global $ilUser, $ilCtrl;
828
829 if ($_GET["block"] != "")
830 {
831 $block = explode("_", $_GET["block"]);
832 include_once("Services/Block/classes/class.ilBlockSetting.php");
833 ilBlockSetting::_writeDetailLevel($block[0], 2, $ilUser->getId(), $block[1]);
834 }
835
836 $ilCtrl->returnToParent($this);
837 }
838
842 function addBlock()
843
844 {
845 global $ilCtrl;
846
847 $class = array_search($_GET["block_type"], self::$block_types);
848
849 $ilCtrl->setCmdClass($class);
850 $ilCtrl->setCmd("create");
851 include_once("./".self::$locations[$class]."classes/class.".$class.".php");
852 $block_gui = new $class();
853 $block_gui->setProperties($this->block_property[$_GET["block_type"]]);
854 $block_gui->setRepositoryMode($this->getRepositoryMode());
855 $block_gui->setEnableEdit($this->getEnableEdit());
856 $block_gui->setAdminCommands($this->getAdminCommands());
857
858 $ilCtrl->setParameter($this, "block_type", $_GET["block_type"]);
859 $html = $ilCtrl->forwardCommand($block_gui);
860 $ilCtrl->setParameter($this, "block_type", "");
861 return $html;
862 }
863
868 {
869 global $ilUser, $ilCtrl, $ilSetting;
870
871 include_once("./Services/Block/classes/class.ilBlockSetting.php");
872 $this->blocks[IL_COL_LEFT] = array();
873 $this->blocks[IL_COL_RIGHT] = array();
874 $this->blocks[IL_COL_CENTER] = array();
875
876 $user_id = ($this->getColType() == "pd")
877 ? $ilUser->getId()
878 : 0;
879
880 $def_nr = 1000;
881 if (is_array($this->default_blocks[$this->getColType()]))
882 {
883 foreach($this->default_blocks[$this->getColType()] as $class => $def_side)
884 {
885 $type = self::$block_types[$class];
886
887 if ($this->isGloballyActivated($type))
888 {
889 $nr = ilBlockSetting::_lookupNr($type, $user_id);
890 if ($nr === false)
891 {
892 $nr = $def_nr++;
893 }
894
895
896 // extra handling for system messages, feedback block and news
897 if ($type == "news") // always show news first
898 {
899 $nr = -15;
900 }
901 if ($type == "cal")
902 {
903 $nr = -8;
904 }
905 if ($type == "pdsysmess") // always show sys mess first
906 {
907// $nr = -15;
908 }
909 if ($type == "pdfeedb") // always show feedback request second
910 {
911 $nr = -10;
912 }
913 if ($type == "clsfct") // mkunkel wants to have this on top
914 {
915 $nr = -16;
916 }
918 if ($side === false)
919 {
920 $side = $def_side;
921 }
922
923 $this->blocks[$side][] = array(
924 "nr" => $nr,
925 "class" => $class,
926 "type" => $type,
927 "id" => 0,
928 "custom" => false);
929 }
930 }
931 }
932
933 if (!$this->getRepositoryMode())
934 {
935 include_once("./Services/Block/classes/class.ilCustomBlock.php");
936 $custom_block = new ilCustomBlock();
937 $custom_block->setContextObjId($ilCtrl->getContextObjId());
938 $custom_block->setContextObjType($ilCtrl->getContextObjType());
939 $c_blocks = $custom_block->queryBlocksForContext();
940
941 foreach($c_blocks as $c_block)
942 {
943 $type = $c_block["type"];
944
945 if ($this->isGloballyActivated($type))
946 {
947 $class = array_search($type, self::$block_types);
948 $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]);
949 if ($nr === false)
950 {
951 $nr = $def_nr++;
952 }
953 $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
954 if ($side === false)
955 {
957 }
958
959 $this->blocks[$side][] = array(
960 "nr" => $nr,
961 "class" => $class,
962 "type" => $type,
963 "id" => $c_block["id"],
964 "custom" => true);
965 }
966 }
967 }
968 else // get all subitems
969 {
970 include_once("./Services/Block/classes/class.ilCustomBlock.php");
971 $rep_items = $this->getRepositoryItems();
972
973 foreach($this->rep_block_types as $block_type)
974 {
975 if ($this->isGloballyActivated($block_type))
976 {
977 if (!is_array($rep_items[$block_type]))
978 {
979 continue;
980 }
981 foreach($rep_items[$block_type] as $item)
982 {
983 $costum_block = new ilCustomBlock();
984 $costum_block->setContextObjId($item["obj_id"]);
985 $costum_block->setContextObjType($block_type);
986 $c_blocks = $costum_block->queryBlocksForContext();
987 $c_block = $c_blocks[0];
988
989 $type = $block_type;
990 $class = array_search($type, self::$block_types);
991 $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]);
992 if ($nr === false)
993 {
994 $nr = $def_nr++;
995 }
996 $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
997 if ($side === false)
998 {
1000 }
1001
1002 $this->blocks[$side][] = array(
1003 "nr" => $nr,
1004 "class" => $class,
1005 "type" => $type,
1006 "id" => $c_block["id"],
1007 "custom" => true,
1008 "ref_id" => $item["ref_id"]);
1009 }
1010 }
1011 }
1012
1013 // repository object custom blocks
1014 include_once("./Services/Block/classes/class.ilCustomBlock.php");
1015 $custom_block = new ilCustomBlock();
1016 $custom_block->setContextObjId($ilCtrl->getContextObjId());
1017 $custom_block->setContextObjType($ilCtrl->getContextObjType());
1018 $c_blocks = $custom_block->queryBlocksForContext(false); // get all sub-object types
1019
1020 foreach($c_blocks as $c_block)
1021 {
1022 $type = $c_block["type"];
1023 $class = array_search($type, self::$block_types);
1024
1025 if($class)
1026 {
1027 $nr = $def_nr++;
1029
1030 $this->blocks[$side][] = array(
1031 "nr" => $nr,
1032 "class" => $class,
1033 "type" => $type,
1034 "id" => $c_block["id"],
1035 "custom" => true);
1036 }
1037 }
1038 }
1039
1040
1041 $this->blocks[IL_COL_LEFT] =
1042 ilUtil::sortArray($this->blocks[IL_COL_LEFT], "nr", "asc", true);
1043 $this->blocks[IL_COL_RIGHT] =
1044 ilUtil::sortArray($this->blocks[IL_COL_RIGHT], "nr", "asc", true);
1045 $this->blocks[IL_COL_CENTER] =
1046 ilUtil::sortArray($this->blocks[IL_COL_CENTER], "nr", "asc", true);
1047
1048 }
1049
1053 protected function isGloballyActivated($a_type)
1054 {
1055 global $ilSetting, $ilCtrl;
1056
1057 if (isset($this->check_global_activation[$a_type]) && $this->check_global_activation[$a_type])
1058 {
1059 if ($a_type == 'pdbookm')
1060 {
1061 if (!$ilSetting->get("disable_bookmarks"))
1062 {
1063 return true;
1064 }
1065 return false;
1066 }
1067 else if ($a_type == 'pdnotes')
1068 {
1069 if (!$ilSetting->get("disable_notes"))
1070 {
1071 return true;
1072 }
1073 return false;
1074 }
1075 else if ($a_type == 'pdportf')
1076 {
1077 if ($ilSetting->get("user_portfolios"))
1078 {
1079 $prfa_set = new ilSetting("prfa");
1080 if ($prfa_set->get("pd_block", false))
1081 {
1082 return true;
1083 }
1084 }
1085 return false;
1086 }
1087 elseif($a_type == 'news')
1088 {
1089 include_once 'Services/Container/classes/class.ilContainer.php';
1090 return
1091 $ilSetting->get('block_activated_news') &&
1093 $GLOBALS['ilCtrl']->getContextObjId(),
1094 'cont_show_news',
1095 true
1096 );
1097 }
1098 else if($a_type == 'pdsysmess')
1099 {
1100 require_once 'Services/Mail/classes/class.ilObjMail.php';
1101 return ((int)$ilSetting->get('pd_sys_msg_mode')) == ilObjMail::PD_SYS_MSG_OWN_BLOCK;
1102 }
1103 else if ($ilSetting->get("block_activated_".$a_type))
1104 {
1105 return true;
1106 }
1107 elseif($a_type == 'cal')
1108 {
1109 include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
1110 return ilCalendarSettings::lookupCalendarActivated($GLOBALS['ilCtrl']->getContextObjId());
1111
1112 }
1113 elseif($a_type == 'pdcal')
1114 {
1115 include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
1116 return ilCalendarSettings::_getInstance()->isEnabled();
1117 }
1118 elseif($a_type == "tagcld")
1119 {
1120 $tags_active = new ilSetting("tags");
1121 return (bool)$tags_active->get("enable", false);
1122 }
1123 elseif($a_type == "clsfct")
1124 {
1125 if ($ilCtrl->getContextObjType() == "cat") // taxonomy presentation in classification block
1126 {
1127 return true;
1128 }
1129 $tags_active = new ilSetting("tags"); // tags presentation in classification block
1130 return (bool)$tags_active->get("enable", false);
1131 }
1132 return false;
1133 }
1134 return true;
1135 }
1136
1140 protected function exceededLimit($a_type)
1141 {
1142 global $ilSetting, $ilCtrl;
1143
1144 if ($this->check_nr_limit[$a_type])
1145 {
1146 if (!$this->getRepositoryMode())
1147 {
1148 include_once("./Services/Block/classes/class.ilCustomBlock.php");
1149 $costum_block = new ilCustomBlock();
1150 $costum_block->setContextObjId($ilCtrl->getContextObjId());
1151 $costum_block->setContextObjType($ilCtrl->getContextObjType());
1152 $costum_block->setType($a_type);
1153 $res = $costum_block->queryCntBlockForContext();
1154 $cnt = (int) $res[0]["cnt"];
1155 }
1156 else
1157 {
1158 return false; // not implemented for repository yet
1159 }
1160
1161
1162 if ($ilSetting->get("block_limit_".$a_type) > $cnt)
1163 {
1164 return false;
1165 }
1166 else
1167 {
1168 return true;
1169 }
1170 }
1171 return false;
1172 }
1173
1177 public function saveBlockSortingAsynch()
1178 {
1182 global $ilUser;
1183
1184 $response = new stdClass();
1185 $response->success = false;
1186
1187 if(!isset($_POST[IL_COL_LEFT]['sequence']) && !isset($_POST[IL_COL_RIGHT]['sequence']))
1188 {
1189 echo json_encode($response);
1190 return;
1191 };
1192
1193 if(in_array($this->getColType(), array('pd')))
1194 {
1195 $response->success = true;
1196
1197 foreach(array(IL_COL_LEFT => (array)$_POST[IL_COL_LEFT]['sequence'], IL_COL_RIGHT => (array)$_POST[IL_COL_RIGHT]['sequence']) as $side => $blocks)
1198 {
1199 $i = 2;
1200 foreach($blocks as $block)
1201 {
1202 $bid = explode('_', $block);
1203 ilBlockSetting::_writeNumber($bid[1], $i, $ilUser->getId(), $bid[2]);
1204 ilBlockSetting::_writeSide($bid[1], $side, $ilUser->getId(), $bid[2]);
1205
1206 $i +=2;
1207 }
1208 }
1209 }
1210
1211 echo json_encode($response);
1212 exit();
1213 }
1214
1220 {
1221 $this->action_menu = $action_menu;
1222 return $this;
1223 }
1224
1228 public function getActionMenu()
1229 {
1230 return $this->action_menu;
1231 }
1232}
sprintf('%.4f', $callTime)
global $tpl
Definition: ilias.php:8
$path
Definition: aliased.php:25
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_SCREEN_SIDE
const IL_SCREEN_CENTER
const IL_COL_RIGHT
const IL_COL_CENTER
const IL_COL_LEFT
static _lookupNr($a_type, $a_user=0, $a_block_id=0)
Lookup number.
static _writeDetailLevel($a_type, $a_value, $a_user=0, $a_block_id=0)
Write detail level to database.
static _lookupSide($a_type, $a_user=0, $a_block_id=0)
Lookup side.
static _writeNumber($a_type, $a_value, $a_user=0, $a_block_id=0)
Write number to database.
static _writeSide($a_type, $a_value, $a_user=0, $a_block_id=0)
Write side to database.
static _lookupDetailLevel($a_type, $a_user=0, $a_block_id=0)
Lookup detail level.
static _getInstance()
get singleton instance
static lookupCalendarActivated($a_obj_id)
Column user interface class.
updateBlock()
Update Block (asynchronous)
getRepositoryMode()
Get RepositoryMode.
getBlockProperties($a_block_type)
isGloballyActivated($a_type)
Check whether a block type is globally activated.
getColType()
Get Column Type.
showBlocks()
Show blocks.
getEnableEdit()
Get EnableEdit.
setMovementMode($a_movementmode)
Set Movement Mode.
addBlock()
Add a block.
getEnableMovement()
Get Enable Movement.
getHTML()
Get HTML for column.
getRepositoryItems()
Get Repository Items.
setBlockProperty($a_block_type, $a_property, $a_value)
This function is supposed to be used for block type specific properties, that should be passed to ilB...
static addCustomBlockLocation($className, $path)
Adds location information of the custom block gui.
static getScreenMode()
Get Screen Mode for current command.
exceededLimit($a_type)
Check whether limit is not exceeded.
determineBlocks()
Determine which blocks to show.
static addCustomBlockType($className, $identifier)
Adds the block type of the custom block gui.
setEnableMovement($a_enablemovement)
Set Enable Movement.
executeCommand()
execute command
setRepositoryMode($a_repositorymode)
Set RepositoryMode.
setRepositoryItems($a_repositoryitems)
Set Repository Items.
setColType($a_coltype)
Set Column Type.
activateBlock()
Activate hidden block.
getMovementMode()
Get Movement Mode.
getSide()
Get Side IL_COL_LEFT | IL_COL_RIGHT.
setEnableEdit($a_enableedit)
Set EnableEdit.
__construct($a_col_type="", $a_side="", $use_std_context=false)
Constructor.
setActionMenu($action_menu)
setSide($a_side)
Set Side IL_COL_LEFT | IL_COL_RIGHT.
getAdminCommands()
Get Administration Commmands.
static getCmdSide()
Get Column Side of Current Command.
setAdminCommands($a_admincommands)
Set Administration Commmands.
setAllBlockProperties($a_block_properties)
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=NULL)
Lookup a container setting.
This is the super class of all custom blocks.
BlockGUI class for dummy block.
const PD_SYS_MSG_OWN_BLOCK
ILIAS Setting Class.
special template class to simplify handling of ITX/PEAR
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static initjQueryUI()
Init jQuery UI (see included_components.txt for included components)
static initjQuery($a_tpl=null)
Init jQuery.
$html
Definition: example_001.php:87
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilBench
Definition: ilias.php:18
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
global $ilSetting
Definition: privfeed.php:17
$cmd
Definition: sahs_server.php:35
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:93