ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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{
27 protected $ctrl;
28
32 protected $lng;
33
37 protected $user;
38
42 protected $tpl;
43
47 protected $browser;
48
52 protected $settings;
53
54 protected $side = IL_COL_RIGHT;
55 protected $type;
56 protected $enableedit = false;
57 protected $repositorymode = false;
58 protected $repositoryitems = array();
59
60 // all blocks that are repository objects
61 protected $rep_block_types = array("feed","poll");
62 protected $block_property = array();
63 protected $admincommands = null;
64 protected $movementmode = null;
65 protected $enablemovement = false;
66
70 protected $action_menu;
71
72 //
73 // This two arrays may be replaced by some
74 // xml or other magic in the future...
75 //
76
77 protected static $locations = array(
78 "ilNewsForContextBlockGUI" => "Services/News/",
79 "ilCalendarBlockGUI" => "Services/Calendar/",
80 "ilPDCalendarBlockGUI" => "Services/Calendar/",
81 "ilPDNotesBlockGUI" => "Services/Notes/",
82 "ilPDMailBlockGUI" => "Services/Mail/",
83 "ilUsersOnlineBlockGUI" => "Services/PersonalDesktop/",
84 "ilPDSysMessageBlockGUI" => "Services/Mail/",
85 "ilPDSelectedItemsBlockGUI" => "Services/PersonalDesktop/ItemsBlock/",
86 "ilBookmarkBlockGUI" => "Services/Bookmarks/",
87 "ilPDNewsBlockGUI" => "Services/News/",
88 "ilExternalFeedBlockGUI" => "Services/Block/",
89 "ilPDExternalFeedBlockGUI" => "Services/Feeds/",
90 'ilPDTaggingBlockGUI' => 'Services/Tagging/',
91 'ilChatroomBlockGUI' => 'Modules/Chatroom/',
92 'ilPollBlockGUI' => 'Modules/Poll/',
93 'ilClassificationBlockGUI' => 'Services/Classification/',
94 'ilPDPortfolioBlockGUI' => 'Modules/Portfolio/',
95 "ilPDStudyProgrammeSimpleListGUI" => "Modules/StudyProgramme/",
96 "ilPDStudyProgrammeExpandableListGUI" => "Modules/StudyProgramme/",
97 "ilForumPostingDraftsBlockGUI" => "Modules/Forum/"
98 );
99
100 protected static $block_types = array(
101 "ilPDMailBlockGUI" => "pdmail",
102 "ilPDNotesBlockGUI" => "pdnotes",
103 "ilUsersOnlineBlockGUI" => "pdusers",
104 "ilPDNewsBlockGUI" => "pdnews",
105 "ilBookmarkBlockGUI" => "pdbookm",
106 "ilNewsForContextBlockGUI" => "news",
107 "ilCalendarBlockGUI" => "cal",
108 "ilPDCalendarBlockGUI" => "pdcal",
109 "ilExternalFeedBlockGUI" => "feed",
110 "ilPDExternalFeedBlockGUI" => "pdfeed",
111 "ilPDSysMessageBlockGUI" => "pdsysmess",
112 "ilPDSelectedItemsBlockGUI" => "pditems",
113 'ilPDTaggingBlockGUI' => 'pdtag',
114 'ilChatroomBlockGUI' => 'chatviewer',
115 'ilPollBlockGUI' => 'poll',
116 'ilClassificationBlockGUI' => 'clsfct',
117 'ilPDPortfolioBlockGUI' => 'pdportf',
118 "ilPDStudyProgrammeSimpleListGUI" => "prgsimplelist",
119 "ilPDStudyProgrammeExpandableListGUI" => "prgexpandablelist",
120 "ilForumPostingDraftsBlockGUI" => "pdfrmpostdraft"
121 );
122
123
124 protected $default_blocks = array(
125 "cat" => array(
126 "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
127 "ilClassificationBlockGUI" => IL_COL_RIGHT
128 ),
129 "crs" => array(
130 "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
131 "ilCalendarBlockGUI" => IL_COL_RIGHT,
132 "ilClassificationBlockGUI" => IL_COL_RIGHT
133 ),
134 "grp" => array(
135 "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
136 "ilCalendarBlockGUI" => IL_COL_RIGHT,
137 "ilClassificationBlockGUI" => IL_COL_RIGHT
138 ),
139 "frm" => array("ilNewsForContextBlockGUI" => IL_COL_RIGHT),
140 "root" => array(),
141 "info" => array(
142 "ilNewsForContextBlockGUI" => IL_COL_RIGHT),
143 "pd" => array(
144 "ilPDCalendarBlockGUI" => IL_COL_RIGHT,
145 "ilPDPortfolioBlockGUI" => IL_COL_RIGHT,
146 "ilPDSysMessageBlockGUI" => IL_COL_LEFT,
147 "ilPDNewsBlockGUI" => IL_COL_LEFT,
148 "ilPDStudyProgrammeSimpleListGUI" => IL_COL_CENTER,
149 "ilPDStudyProgrammeExpandableListGUI" => IL_COL_CENTER,
150 "ilPDSelectedItemsBlockGUI" => IL_COL_CENTER,
151 "ilPDMailBlockGUI" => IL_COL_RIGHT,
152 "ilPDNotesBlockGUI" => IL_COL_RIGHT,
153 //"ilUsersOnlineBlockGUI" => IL_COL_RIGHT,
154 "ilBookmarkBlockGUI" => IL_COL_RIGHT,
155 "ilPDTaggingBlockGUI" => IL_COL_RIGHT,
156 "ilChatroomBlockGUI" => IL_COL_RIGHT,
157 "ilForumPostingDraftsBlockGUI" => IL_COL_RIGHT
158 )
159 );
160
161 // these are only for pd blocks
162 // other blocks are rep objects now
163 protected $custom_blocks = array(
164 "cat" => array(),
165 "crs" => array(),
166 "grp" => array(),
167 "frm" => array(),
168 "root" => array(),
169 "info" => array(),
170 "fold" => array(),
171 "pd" => array("ilPDExternalFeedBlockGUI")
172 );
173
174 // check global activation for these block types
175 // @todo: add calendar
177 array("news" => true,
178 "cal" => true,
179 "pdcal" => true,
180 "pdnews" => true,
181 "pdfeed" => true,
182 "pdusers" => true,
183 "pdbookm" => true,
184 "pdtag" => true,
185 "pdsysmess" => true,
186 "pdnotes" => true,
187 "chatviewer" => true,
188 "pdfrmpostdraft" => true,
189 "tagcld" => true,
190 "pdportf" => true,
191 "clsfct" => true);
192
193 protected $check_nr_limit =
194 array("pdfeed" => true);
195
201 public function __construct($a_col_type = "", $a_side = "", $use_std_context = false)
202 {
203 global $DIC;
204
205 $this->ctrl = $DIC->ctrl();
206 $this->lng = $DIC->language();
207 $this->user = $DIC->user();
208 $this->tpl = $DIC["tpl"];
209 $this->browser = $DIC["ilBrowser"];
210 $this->settings = $DIC->settings();
211 $this->setColType($a_col_type);
212 $this->setSide($a_side);
213 }
214
225 public static function addCustomBlockLocation($className, $path)
226 {
227 self::$locations[$className] = $path;
228 }
229
240 public static function addCustomBlockType($className, $identifier)
241 {
242 self::$block_types[$className] = $identifier;
243 }
244
250 public static function getCmdSide()
251 {
252 return $_GET["col_side"];
253 }
254
260 public function setColType($a_coltype)
261 {
262 $this->coltype = $a_coltype;
263 }
264
270 public function getColType()
271 {
272 return $this->coltype;
273 }
274
280 public function setSide($a_side)
281 {
282 $this->side = $a_side;
283 }
284
290 public function getSide()
291 {
292 return $this->side;
293 }
294
300 public function setEnableEdit($a_enableedit)
301 {
302 $this->enableedit = $a_enableedit;
303 }
304
310 public function getEnableEdit()
311 {
312 return $this->enableedit;
313 }
314
320 public function setRepositoryMode($a_repositorymode)
321 {
322 $this->repositorymode = $a_repositorymode;
323 }
324
330 public function getRepositoryMode()
331 {
333 }
334
340 public function setAdminCommands($a_admincommands)
341 {
342 $this->admincommands = $a_admincommands;
343 }
344
350 public function getAdminCommands()
351 {
353 }
354
360 public function setMovementMode($a_movementmode)
361 {
362 $this->movementmode = $a_movementmode;
363 }
364
370 public function getMovementMode()
371 {
372 return $this->movementmode;
373 }
374
380 public function setEnableMovement($a_enablemovement)
381 {
382 $this->enablemovement = $a_enablemovement;
383 }
384
390 public function getEnableMovement()
391 {
393 }
394
398 public static function getScreenMode()
399 {
400 global $DIC;
401
402 $ilCtrl = $DIC->ctrl();
403
404 if ($ilCtrl->getCmdClass() == "ilcolumngui") {
405 switch ($ilCtrl->getCmd()) {
406 case "addBlock":
407 return IL_SCREEN_CENTER;
408 }
409 }
410
411 $cur_block_type = "";
412 if (isset($_GET["block_type"]) && $_GET["block_type"]) {
413 $cur_block_type = $_GET["block_type"];
414 } elseif (isset($_POST["block_type"])) {
415 $cur_block_type = $_POST["block_type"];
416 }
417
418 if ($class = array_search($cur_block_type, self::$block_types)) {
419 include_once("./" . self::$locations[$class] . "classes/" .
420 "class." . $class . ".php");
421 return call_user_func(array($class, 'getScreenMode'));
422 }
423
424 return IL_SCREEN_SIDE;
425 }
426
434 public function setBlockProperty($a_block_type, $a_property, $a_value)
435 {
436 $this->block_property[$a_block_type][$a_property] = $a_value;
437 }
438
439 public function getBlockProperties($a_block_type)
440 {
441 return $this->block_property[$a_block_type];
442 }
443
444 public function setAllBlockProperties($a_block_properties)
445 {
446 $this->block_property = $a_block_properties;
447 }
448
454 public function setRepositoryItems($a_repositoryitems)
455 {
456 $this->repositoryitems = $a_repositoryitems;
457 }
458
464 public function getRepositoryItems()
465 {
467 }
468
472 public function executeCommand()
473 {
475
476 $ilCtrl->setParameter($this, "col_side", $this->getSide());
477 //$ilCtrl->saveParameter($this, "col_side");
478
479 $next_class = $ilCtrl->getNextClass();
480 $cmd = $ilCtrl->getCmd("getHTML");
481
482 $cur_block_type = ($_GET["block_type"])
483 ? $_GET["block_type"]
484 : $_POST["block_type"];
485
486 if ($next_class != "") {
487 // forward to block
488 if ($gui_class = array_search($cur_block_type, self::$block_types)) {
489 include_once("./" . self::$locations[$gui_class] . "classes/" .
490 "class." . $gui_class . ".php");
491 $ilCtrl->setParameter($this, "block_type", $cur_block_type);
492 $block_gui = new $gui_class();
493 $block_gui->setProperties($this->block_property[$cur_block_type]);
494 $block_gui->setRepositoryMode($this->getRepositoryMode());
495 $block_gui->setEnableEdit($this->getEnableEdit());
496 $block_gui->setAdminCommands($this->getAdminCommands());
497
498 if (in_array($gui_class, $this->custom_blocks[$this->getColType()]) ||
499 in_array($cur_block_type, $this->rep_block_types)) {
500 $block_class = substr($gui_class, 0, strlen($gui_class)-3);
501 include_once("./" . self::$locations[$gui_class] . "classes/" .
502 "class." . $block_class . ".php");
503 $app_block = new $block_class($_GET["block_id"]);
504 $block_gui->setBlock($app_block);
505 }
506 $html = $ilCtrl->forwardCommand($block_gui);
507 $ilCtrl->setParameter($this, "block_type", "");
508
509 return $html;
510 }
511 } else {
512 return $this->$cmd();
513 }
514 }
515
519 public function getHTML()
520 {
522
523 $ilCtrl->setParameter($this, "col_side", $this->getSide());
524
525 $this->tpl = new ilTemplate("tpl.column.html", true, true, "Services/Block");
526
527 $this->determineBlocks();
528 $this->showBlocks();
529
530 if ($this->getEnableEdit() || !$this->getRepositoryMode()) {
531 $this->addHiddenBlockSelector();
532 }
533
534 return $this->tpl->get();
535 }
536
540 public function showBlocks()
541 {
545
546 $i = 1;
547 $sum_moveable = count($this->blocks[$this->getSide()]);
548
549 foreach ($this->blocks[$this->getSide()] as $block) {
550 if ($ilCtrl->getContextObjType() != "user" ||
552 $block["type"],
553 $ilUser->getId(),
554 $block["id"]
555 ) > 0) {
556 $gui_class = $block["class"];
557 $block_class = substr($block["class"], 0, strlen($block["class"])-3);
558
559 // get block gui class
560 include_once("./" . self::$locations[$gui_class] . "classes/" .
561 "class." . $gui_class . ".php");
562 $block_gui = new $gui_class();
563 if (isset($this->block_property[$block["type"]])) {
564 $block_gui->setProperties($this->block_property[$block["type"]]);
565 }
566 $block_gui->setRepositoryMode($this->getRepositoryMode());
567 $block_gui->setEnableEdit($this->getEnableEdit());
568 $block_gui->setAdminCommands($this->getAdminCommands());
569
570 // get block for custom blocks
571 if ($block["custom"]) {
572 $path = "./" . self::$locations[$gui_class] . "classes/" .
573 "class." . $block_class . ".php";
574 if (file_exists($path)) {
575 include_once($path);
576 $app_block = new $block_class($block["id"]);
577 } else {
578 // we only need generic block
579 $app_block = new ilCustomBlock($block["id"]);
580 }
581 $block_gui->setBlock($app_block);
582 if (isset($block["ref_id"])) {
583 $block_gui->setRefId($block["ref_id"]);
584 }
585 }
586
587 $ilCtrl->setParameter($this, "block_type", $block_gui->getBlockType());
588 $this->tpl->setCurrentBlock("col_block");
589
590 $html = $ilCtrl->getHTML($block_gui);
591
592 // dummy block, if non visible, but movement is ongoing
593 if ($html == "" && $this->getRepositoryMode() &&
594 $this->getMovementMode()) {
595 include_once("./Services/Block/classes/class.ilDummyBlockGUI.php");
596 $bl = new ilDummyBlockGUI();
597 $bl->setBlockId($block["id"]);
598 $bl->setBlockType($block["type"]);
599 $bl->setTitle($lng->txt("invisible_block"));
600 $bl->setConfigMode($this->getMovementMode());
601 $html = $bl->getHTML();
602 }
603
604 // don't render a block if it's empty
605 if ($html != "") {
606 $this->tpl->setVariable("BLOCK", $html);
607 $this->tpl->parseCurrentBlock();
608 $ilCtrl->setParameter($this, "block_type", "");
609 }
610
611 // count (moveable) blocks
612 if ($block["type"] != "pdsysmess" && $block["type"] != "pdfeedb" &&
613 $block["type"] != "news") {
614 $i++;
615 } else {
616 $sum_moveable--;
617 }
618 }
619 }
620 }
621
625 public function addHiddenBlockSelector()
626 {
636
637 // show selector for hidden blocks
638 include_once("Services/Block/classes/class.ilBlockSetting.php");
639 $hidden_blocks = array();
640
641 foreach ($this->blocks[$this->getSide()] as $block) {
642 include_once("./" . self::$locations[$block["class"]] . "classes/" .
643 "class." . $block["class"] . ".php");
644
645 if ($block["custom"] == false) {
646 if ($ilCtrl->getContextObjType() == "user") { // personal desktop
647 if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId()) == 0) {
648 $hidden_blocks[$block["type"]] = $lng->txt('block_show_' . $block["type"]);
649 }
650 } elseif ($ilCtrl->getContextObjType() != "") {
652 $block["type"],
653 $ilUser->getId(),
654 $ilCtrl->getContextObjId()
655 ) == 0) {
656 $hidden_blocks[$block["type"] . "_" . $ilCtrl->getContextObjId()] = $lng->txt('block_show_' . $block["type"]);
657 }
658 }
659 } else {
661 $block["type"],
662 $ilUser->getId(),
663 $block["id"]
664 ) == 0) {
665 include_once("./Services/Block/classes/class.ilCustomBlock.php");
666 $cblock = new ilCustomBlock($block["id"]);
667 $hidden_blocks[$block["type"] . "_" . $block["id"]] = sprintf($lng->txt('block_show_x'), $cblock->getTitle());
668 }
669 }
670 }
671 if (count($hidden_blocks) > 0) {
672 foreach ($hidden_blocks as $id => $title) {
673 $ilCtrl->setParameter($this, 'block', $id);
674 $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'activateBlock'));
675 $ilCtrl->setParameter($this, 'block', '');
676 }
677 }
678
679 // create block selection list
680 if (!$this->getRepositoryMode() || $this->getEnableEdit()) {
681 $add_blocks = array();
682 if ($this->getSide() == IL_COL_RIGHT) {
683 if (is_array($this->custom_blocks[$this->getColType()])) {
684 foreach ($this->custom_blocks[$this->getColType()] as $block_class) {
685 include_once("./" . self::$locations[$block_class] . "classes/" .
686 "class." . $block_class . ".php");
687 $block_type = call_user_func(array($block_class, 'getBlockType'));
688
689 // check if block type is globally (de-)activated
690 if ($this->isGloballyActivated($block_type)) {
691 // check if number of blocks is limited
692 if (!$this->exceededLimit($block_type)) {
693 $add_blocks[$block_type] = $lng->txt('block_create_' . $block_type);
694 }
695 }
696 }
697 }
698 }
699 if (count($add_blocks) > 0) {
700 foreach ($add_blocks as $id => $title) {
701 $ilCtrl->setParameter($this, 'block_type', $id);
702 $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'addBlock'));
703 $ilCtrl->setParameter($this, 'block_type', '');
704 }
705 }
706 }
707
708 $this->addBlockSorting();
709 }
710
714 protected function addBlockSorting()
715 {
716 global $DIC;
717
718 if ($this->getSide() == IL_COL_CENTER && $this->getEnableMovement()) {
719 $ilBrowser = $this->browser;
720 $main_tpl = $DIC["tpl"];
722
723 include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
726
727 if ($ilBrowser->isMobile() || $ilBrowser->isIpad()) {
728 $main_tpl->addJavaScript('./libs/bower/bower_components/jqueryui-touch-punch/jquery.ui.touch-punch.min.js');
729 }
730 $main_tpl->addJavaScript('./Services/Block/js/block_sorting.js');
731
732 // set the col_side parameter to pass the ctrl structure flow
733 $ilCtrl->setParameter($this, 'col_side', IL_COL_CENTER);
734
735 $this->tpl->setVariable('BLOCK_SORTING_STORAGE_URL', $ilCtrl->getLinkTarget($this, 'saveBlockSortingAsynch', '', true, false));
736 $this->tpl->setVariable('BLOCK_COLUMNS', json_encode(array('il_left_col', 'il_right_col')));
737 $this->tpl->setVariable('BLOCK_COLUMNS_SELECTOR', '#il_left_col,#il_right_col');
738 $this->tpl->setVariable('BLOCK_COLUMNS_PARAMETERS', json_encode(array(IL_COL_LEFT, IL_COL_RIGHT)));
739
740 // restore col_side parameter
741 $ilCtrl->setParameter($this, 'col_side', $this->getSide());
742 }
743 }
744
748 public function updateBlock()
749 {
751
752 $this->determineBlocks();
753 $i = 1;
754 $sum_moveable = count($this->blocks[$this->getSide()]);
755
756 foreach ($this->blocks[$this->getSide()] as $block) {
757 include_once("./" . self::$locations[$block["class"]] . "classes/" .
758 "class." . $block["class"] . ".php");
759
760 // set block id to context obj id,
761 // if block is not a custom block and context is not personal desktop
762 if (!$block["custom"] && $ilCtrl->getContextObjType() != "" && $ilCtrl->getContextObjType() != "user") {
763 $block["id"] = $ilCtrl->getContextObjId();
764 }
765
766 //if (is_int(strpos($_GET["block_id"], "block_".$block["type"]."_".$block["id"])))
767
768 if ($_GET["block_id"] == "block_" . $block["type"] . "_" . $block["id"]) {
769 $gui_class = $block["class"];
770 $block_class = substr($block["class"], 0, strlen($block["class"])-3);
771
772 $block_gui = new $gui_class();
773 $block_gui->setProperties($this->block_property[$block["type"]]);
774 $block_gui->setRepositoryMode($this->getRepositoryMode());
775 $block_gui->setEnableEdit($this->getEnableEdit());
776 $block_gui->setAdminCommands($this->getAdminCommands());
777
778 // get block for custom blocks
779 if ($block["custom"]) {
780 include_once("./" . self::$locations[$gui_class] . "classes/" .
781 "class." . $block_class . ".php");
782 $app_block = new $block_class($block["id"]);
783 $block_gui->setBlock($app_block);
784 $block_gui->setRefId($block["ref_id"]);
785 }
786
787 $ilCtrl->setParameter($this, "block_type", $block["type"]);
788 echo $ilCtrl->getHTML($block_gui);
789 exit;
790 }
791
792 // count (moveable) blocks
793 if ($block["type"] != "pdsysmess" && $block["type"] != "pdfeedb"
794 && $block["type"] != "news") {
795 $i++;
796 } else {
797 $sum_moveable--;
798 }
799 }
800 echo "Error: ilColumnGUI::updateBlock: Block '" .
801 $_GET["block_id"] . "' unknown.";
802 exit;
803 }
804
808 public function activateBlock()
809 {
812
813 if ($_GET["block"] != "") {
814 $block = explode("_", $_GET["block"]);
815 include_once("Services/Block/classes/class.ilBlockSetting.php");
816 ilBlockSetting::_writeDetailLevel($block[0], 2, $ilUser->getId(), $block[1]);
817 }
818
819 $ilCtrl->returnToParent($this);
820 }
821
825 public function addBlock()
826 {
828
829 $class = array_search($_GET["block_type"], self::$block_types);
830
831 $ilCtrl->setCmdClass($class);
832 $ilCtrl->setCmd("create");
833 include_once("./" . self::$locations[$class] . "classes/class." . $class . ".php");
834 $block_gui = new $class();
835 $block_gui->setProperties($this->block_property[$_GET["block_type"]]);
836 $block_gui->setRepositoryMode($this->getRepositoryMode());
837 $block_gui->setEnableEdit($this->getEnableEdit());
838 $block_gui->setAdminCommands($this->getAdminCommands());
839
840 $ilCtrl->setParameter($this, "block_type", $_GET["block_type"]);
841 $html = $ilCtrl->forwardCommand($block_gui);
842 $ilCtrl->setParameter($this, "block_type", "");
843 return $html;
844 }
845
849 public function determineBlocks()
850 {
854
855 include_once("./Services/Block/classes/class.ilBlockSetting.php");
856 $this->blocks[IL_COL_LEFT] = array();
857 $this->blocks[IL_COL_RIGHT] = array();
858 $this->blocks[IL_COL_CENTER] = array();
859
860 $user_id = ($this->getColType() == "pd")
861 ? $ilUser->getId()
862 : 0;
863
864 $def_nr = 1000;
865 if (is_array($this->default_blocks[$this->getColType()])) {
866 foreach ($this->default_blocks[$this->getColType()] as $class => $def_side) {
867 $type = self::$block_types[$class];
868
869 if ($this->isGloballyActivated($type)) {
870 $nr = ilBlockSetting::_lookupNr($type, $user_id);
871 if ($nr === false) {
872 $nr = $def_nr++;
873 }
874
875
876 // extra handling for system messages, feedback block and news
877 if ($type == "news") { // always show news first
878 $nr = -15;
879 }
880 if ($type == "cal") {
881 $nr = -8;
882 }
883 if ($type == "pdsysmess") { // always show sys mess first
884// $nr = -15;
885 }
886 if ($type == "pdfeedb") { // always show feedback request second
887 $nr = -10;
888 }
889 if ($type == "clsfct") { // mkunkel wants to have this on top
890 $nr = -16;
891 }
893 if ($side === false) {
894 $side = $def_side;
895 }
896
897 $this->blocks[$side][] = array(
898 "nr" => $nr,
899 "class" => $class,
900 "type" => $type,
901 "id" => 0,
902 "custom" => false);
903 }
904 }
905 }
906
907 if (!$this->getRepositoryMode()) {
908 include_once("./Services/Block/classes/class.ilCustomBlock.php");
909 $custom_block = new ilCustomBlock();
910 $custom_block->setContextObjId($ilCtrl->getContextObjId());
911 $custom_block->setContextObjType($ilCtrl->getContextObjType());
912 $c_blocks = $custom_block->queryBlocksForContext();
913
914 foreach ($c_blocks as $c_block) {
915 $type = $c_block["type"];
916
917 if ($this->isGloballyActivated($type)) {
918 $class = array_search($type, self::$block_types);
919 $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]);
920 if ($nr === false) {
921 $nr = $def_nr++;
922 }
923 $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
924 if ($side === false) {
926 }
927
928 $this->blocks[$side][] = array(
929 "nr" => $nr,
930 "class" => $class,
931 "type" => $type,
932 "id" => $c_block["id"],
933 "custom" => true);
934 }
935 }
936 } else { // get all subitems
937 include_once("./Services/Block/classes/class.ilCustomBlock.php");
938 $rep_items = $this->getRepositoryItems();
939
940 foreach ($this->rep_block_types as $block_type) {
941 if ($this->isGloballyActivated($block_type)) {
942 if (!is_array($rep_items[$block_type])) {
943 continue;
944 }
945 foreach ($rep_items[$block_type] as $item) {
946 $costum_block = new ilCustomBlock();
947 $costum_block->setContextObjId($item["obj_id"]);
948 $costum_block->setContextObjType($block_type);
949 $c_blocks = $costum_block->queryBlocksForContext();
950 $c_block = $c_blocks[0];
951
952 $type = $block_type;
953 $class = array_search($type, self::$block_types);
954 $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]);
955 if ($nr === false) {
956 $nr = $def_nr++;
957 }
958 $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
959 if ($side === false) {
961 }
962
963 $this->blocks[$side][] = array(
964 "nr" => $nr,
965 "class" => $class,
966 "type" => $type,
967 "id" => $c_block["id"],
968 "custom" => true,
969 "ref_id" => $item["ref_id"]);
970 }
971 }
972 }
973
974 // repository object custom blocks
975 include_once("./Services/Block/classes/class.ilCustomBlock.php");
976 $custom_block = new ilCustomBlock();
977 $custom_block->setContextObjId($ilCtrl->getContextObjId());
978 $custom_block->setContextObjType($ilCtrl->getContextObjType());
979 $c_blocks = $custom_block->queryBlocksForContext(false); // get all sub-object types
980
981 foreach ($c_blocks as $c_block) {
982 $type = $c_block["type"];
983 $class = array_search($type, self::$block_types);
984
985 if ($class) {
986 $nr = $def_nr++;
988
989 $this->blocks[$side][] = array(
990 "nr" => $nr,
991 "class" => $class,
992 "type" => $type,
993 "id" => $c_block["id"],
994 "custom" => true);
995 }
996 }
997 }
998
999
1000 $this->blocks[IL_COL_LEFT] =
1001 ilUtil::sortArray($this->blocks[IL_COL_LEFT], "nr", "asc", true);
1002 $this->blocks[IL_COL_RIGHT] =
1003 ilUtil::sortArray($this->blocks[IL_COL_RIGHT], "nr", "asc", true);
1004 $this->blocks[IL_COL_CENTER] =
1005 ilUtil::sortArray($this->blocks[IL_COL_CENTER], "nr", "asc", true);
1006 }
1007
1011 protected function isGloballyActivated($a_type)
1012 {
1015
1016 if (isset($this->check_global_activation[$a_type]) && $this->check_global_activation[$a_type]) {
1017 if ($a_type == 'pdbookm') {
1018 if (!$ilSetting->get("disable_bookmarks")) {
1019 return true;
1020 }
1021 return false;
1022 } elseif ($a_type == 'pdnotes') {
1023 if (!$ilSetting->get("disable_notes")) {
1024 return true;
1025 }
1026 return false;
1027 } elseif ($a_type == 'pdportf') {
1028 if ($ilSetting->get("user_portfolios")) {
1029 $prfa_set = new ilSetting("prfa");
1030 if ($prfa_set->get("pd_block", false)) {
1031 return true;
1032 }
1033 }
1034 return false;
1035 } elseif ($a_type == 'news') {
1036 include_once 'Services/Container/classes/class.ilContainer.php';
1037 return
1038 $ilSetting->get('block_activated_news') &&
1040 $GLOBALS['ilCtrl']->getContextObjId(),
1041 'cont_show_news',
1042 true
1043 );
1044 } elseif ($a_type == 'pdsysmess') {
1045 require_once 'Services/Mail/classes/class.ilObjMail.php';
1046 return ((int) $ilSetting->get('pd_sys_msg_mode')) == ilObjMail::PD_SYS_MSG_OWN_BLOCK;
1047 } elseif ($ilSetting->get("block_activated_" . $a_type)) {
1048 return true;
1049 } elseif ($a_type == 'cal') {
1050 include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
1051 return ilCalendarSettings::lookupCalendarActivated($GLOBALS['ilCtrl']->getContextObjId());
1052 } elseif ($a_type == 'pdcal') {
1053 include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
1054 return ilCalendarSettings::_getInstance()->isEnabled();
1055 } elseif ($a_type == "tagcld") {
1056 $tags_active = new ilSetting("tags");
1057 return (bool) $tags_active->get("enable", false);
1058 } elseif ($a_type == "clsfct") {
1059 if ($ilCtrl->getContextObjType() == "cat") { // taxonomy presentation in classification block
1060 return true;
1061 }
1062 $tags_active = new ilSetting("tags"); // tags presentation in classification block
1063 return (bool) $tags_active->get("enable", false);
1064 }
1065 return false;
1066 }
1067 return true;
1068 }
1069
1073 protected function exceededLimit($a_type)
1074 {
1077
1078 if ($this->check_nr_limit[$a_type]) {
1079 if (!$this->getRepositoryMode()) {
1080 include_once("./Services/Block/classes/class.ilCustomBlock.php");
1081 $costum_block = new ilCustomBlock();
1082 $costum_block->setContextObjId($ilCtrl->getContextObjId());
1083 $costum_block->setContextObjType($ilCtrl->getContextObjType());
1084 $costum_block->setType($a_type);
1085 $res = $costum_block->queryCntBlockForContext();
1086 $cnt = (int) $res[0]["cnt"];
1087 } else {
1088 return false; // not implemented for repository yet
1089 }
1090
1091
1092 if ($ilSetting->get("block_limit_" . $a_type) > $cnt) {
1093 return false;
1094 } else {
1095 return true;
1096 }
1097 }
1098 return false;
1099 }
1100
1104 public function saveBlockSortingAsynch()
1105 {
1110
1111 $response = new stdClass();
1112 $response->success = false;
1113
1114 if (!isset($_POST[IL_COL_LEFT]['sequence']) && !isset($_POST[IL_COL_RIGHT]['sequence'])) {
1115 echo json_encode($response);
1116 return;
1117 };
1118
1119 if (in_array($this->getColType(), array('pd'))) {
1120 $response->success = true;
1121
1122 foreach (array(IL_COL_LEFT => (array) $_POST[IL_COL_LEFT]['sequence'], IL_COL_RIGHT => (array) $_POST[IL_COL_RIGHT]['sequence']) as $side => $blocks) {
1123 $i = 2;
1124 foreach ($blocks as $block) {
1125 $bid = explode('_', $block);
1126 ilBlockSetting::_writeNumber($bid[1], $i, $ilUser->getId(), $bid[2]);
1127 ilBlockSetting::_writeSide($bid[1], $side, $ilUser->getId(), $bid[2]);
1128
1129 $i +=2;
1130 }
1131 }
1132 }
1133
1134 echo json_encode($response);
1135 exit();
1136 }
1137
1143 {
1144 $this->action_menu = $action_menu;
1145 return $this;
1146 }
1147
1151 public function getActionMenu()
1152 {
1153 return $this->action_menu;
1154 }
1155}
sprintf('%.4f', $callTime)
user()
Definition: user.php:4
$_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($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components....
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
$i
Definition: disco.tpl.php:19
$html
Definition: example_001.php:87
if(!array_key_exists('StateId', $_REQUEST)) $id
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:17
$response
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92