ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 
4 define ("IL_COL_LEFT", "left");
5 define ("IL_COL_RIGHT", "right");
6 define ("IL_COL_CENTER", "center");
7 
8 define ("IL_SCREEN_SIDE", "");
9 define ("IL_SCREEN_CENTER", "center");
10 define ("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  );
68 
69  static protected $block_types = array(
70  "ilPDMailBlockGUI" => "pdmail",
71  "ilPDNotesBlockGUI" => "pdnotes",
72  "ilUsersOnlineBlockGUI" => "pdusers",
73  "ilPDNewsBlockGUI" => "pdnews",
74  "ilBookmarkBlockGUI" => "pdbookm",
75  "ilNewsForContextBlockGUI" => "news",
76  "ilCalendarBlockGUI" => "cal",
77  "ilPDCalendarBlockGUI" => "pdcal",
78  "ilExternalFeedBlockGUI" => "feed",
79  "ilPDExternalFeedBlockGUI" => "pdfeed",
80  "ilPDSysMessageBlockGUI" => "pdsysmess",
81  "ilPDSelectedItemsBlockGUI" => "pditems",
82  'ilPDTaggingBlockGUI' => 'pdtag',
83  'ilChatroomBlockGUI' => 'chatviewer',
84  'ilPollBlockGUI' => 'poll',
85  'ilClassificationBlockGUI' => 'clsfct',
86  'ilPDPortfolioBlockGUI' => 'pdportf',
87  "ilPDStudyProgrammeSimpleListGUI" => "prgsimplelist",
88  "ilPDStudyProgrammeExpandableListGUI" => "prgexpandablelist"
89  );
90 
91 
92  protected $default_blocks = array(
93  "cat" => array(
94  "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
95  "ilClassificationBlockGUI" => IL_COL_RIGHT
96  ),
97  "crs" => array(
98  "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
99  "ilCalendarBlockGUI" => IL_COL_RIGHT,
100  "ilClassificationBlockGUI" => IL_COL_RIGHT
101  ),
102  "grp" => array(
103  "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
104  "ilCalendarBlockGUI" => IL_COL_RIGHT,
105  "ilClassificationBlockGUI" => IL_COL_RIGHT
106  ),
107  "frm" => array("ilNewsForContextBlockGUI" => IL_COL_RIGHT),
108  "root" => array(),
109  "info" => array(
110  "ilNewsForContextBlockGUI" => IL_COL_RIGHT),
111  "pd" => array(
112  "ilPDCalendarBlockGUI" => IL_COL_RIGHT,
113  "ilPDPortfolioBlockGUI" => IL_COL_RIGHT,
114  "ilPDSysMessageBlockGUI" => IL_COL_LEFT,
115  "ilPDNewsBlockGUI" => IL_COL_LEFT,
116  "ilPDStudyProgrammeSimpleListGUI" => IL_COL_CENTER,
117  "ilPDStudyProgrammeExpandableListGUI" => IL_COL_CENTER,
118  "ilPDSelectedItemsBlockGUI" => IL_COL_CENTER,
119  "ilPDMailBlockGUI" => IL_COL_RIGHT,
120  "ilPDNotesBlockGUI" => IL_COL_RIGHT,
121  //"ilUsersOnlineBlockGUI" => IL_COL_RIGHT,
122  "ilBookmarkBlockGUI" => IL_COL_RIGHT,
123  "ilPDTaggingBlockGUI" => IL_COL_RIGHT,
124  "ilChatroomBlockGUI" => IL_COL_RIGHT
125  )
126  );
127 
128  // these are only for pd blocks
129  // other blocks are rep objects now
130  protected $custom_blocks = array(
131  "cat" => array(),
132  "crs" => array(),
133  "grp" => array(),
134  "frm" => array(),
135  "root" => array(),
136  "info" => array(),
137  "fold" => array(),
138  "pd" => array("ilPDExternalFeedBlockGUI")
139  );
140 
141  // check global activation for these block types
142  // @todo: add calendar
144  array("news" => true,
145  "cal" => true,
146  "pdcal" => true,
147  "pdnews" => true,
148  "pdfeed" => true,
149  "pdusers" => true,
150  "pdbookm" => true,
151  "pdtag" => true,
152  "pdnotes" => true,
153  "chatviewer" => true,
154  "tagcld" => true,
155  "pdportf" => true);
156 
157  protected $check_nr_limit =
158  array("pdfeed" => true);
159 
165  public function __construct($a_col_type = "", $a_side = "", $use_std_context = false)
166  {
167  $this->setColType($a_col_type);
168  $this->setSide($a_side);
169  }
170 
181  public static function addCustomBlockLocation($className, $path)
182  {
183  self::$locations[$className] = $path;
184  }
185 
196  public static function addCustomBlockType($className, $identifier)
197  {
198  self::$block_types[$className] = $identifier;
199  }
200 
206  static function getCmdSide()
207  {
208  return $_GET["col_side"];
209  }
210 
216  function setColType($a_coltype)
217  {
218  $this->coltype = $a_coltype;
219  }
220 
226  function getColType()
227  {
228  return $this->coltype;
229  }
230 
236  function setSide($a_side)
237  {
238  $this->side = $a_side;
239  }
240 
246  function getSide()
247  {
248  return $this->side;
249  }
250 
256  function setEnableEdit($a_enableedit)
257  {
258  $this->enableedit = $a_enableedit;
259  }
260 
266  function getEnableEdit()
267  {
268  return $this->enableedit;
269  }
270 
276  function setRepositoryMode($a_repositorymode)
277  {
278  $this->repositorymode = $a_repositorymode;
279  }
280 
286  function getRepositoryMode()
287  {
288  return $this->repositorymode;
289  }
290 
296  function setAdminCommands($a_admincommands)
297  {
298  $this->admincommands = $a_admincommands;
299  }
300 
306  function getAdminCommands()
307  {
308  return $this->admincommands;
309  }
310 
316  function setMovementMode($a_movementmode)
317  {
318  $this->movementmode = $a_movementmode;
319  }
320 
326  function getMovementMode()
327  {
328  return $this->movementmode;
329  }
330 
336  function setEnableMovement($a_enablemovement)
337  {
338  $this->enablemovement = $a_enablemovement;
339  }
340 
346  function getEnableMovement()
347  {
348  return $this->enablemovement;
349  }
350 
354  static function getScreenMode()
355  {
356  global $ilCtrl;
357 
358  if ($ilCtrl->getCmdClass() == "ilcolumngui")
359  {
360  switch ($ilCtrl->getCmd())
361  {
362  case "addBlock":
363  return IL_SCREEN_CENTER;
364  }
365  }
366 
367  $cur_block_type = "";
368  if (isset($_GET["block_type"]) && $_GET["block_type"])
369  {
370  $cur_block_type = $_GET["block_type"];
371  }
372  else if (isset($_POST["block_type"]))
373  {
374  $cur_block_type = $_POST["block_type"];
375  }
376 
377  if ($class = array_search($cur_block_type, self::$block_types))
378  {
379  include_once("./".self::$locations[$class]."classes/".
380  "class.".$class.".php");
381  return call_user_func(array($class, 'getScreenMode'));
382  }
383 
384  return IL_SCREEN_SIDE;
385  }
386 
394  function setBlockProperty($a_block_type, $a_property, $a_value)
395  {
396  $this->block_property[$a_block_type][$a_property] = $a_value;
397  }
398 
399  function getBlockProperties($a_block_type)
400  {
401  return $this->block_property[$a_block_type];
402  }
403 
404  function setAllBlockProperties($a_block_properties)
405  {
406  $this->block_property = $a_block_properties;
407  }
408 
414  function setRepositoryItems($a_repositoryitems)
415  {
416  $this->repositoryitems = $a_repositoryitems;
417  }
418 
425  {
426  return $this->repositoryitems;
427  }
428 
432  function &executeCommand()
433  {
434  global $ilCtrl;
435 
436  $ilCtrl->setParameter($this, "col_side" ,$this->getSide());
437  //$ilCtrl->saveParameter($this, "col_side");
438 
439  $next_class = $ilCtrl->getNextClass();
440  $cmd = $ilCtrl->getCmd("getHTML");
441 
442  $cur_block_type = ($_GET["block_type"])
443  ? $_GET["block_type"]
444  : $_POST["block_type"];
445 
446  if ($next_class != "")
447  {
448  // forward to block
449  if ($gui_class = array_search($cur_block_type, self::$block_types))
450  {
451  include_once("./".self::$locations[$gui_class]."classes/".
452  "class.".$gui_class.".php");
453  $ilCtrl->setParameter($this, "block_type", $cur_block_type);
454  $block_gui = new $gui_class();
455  $block_gui->setProperties($this->block_property[$cur_block_type]);
456  $block_gui->setRepositoryMode($this->getRepositoryMode());
457  $block_gui->setEnableEdit($this->getEnableEdit());
458  $block_gui->setAdminCommands($this->getAdminCommands());
459 
460  if (in_array($gui_class, $this->custom_blocks[$this->getColType()]) ||
461  in_array($cur_block_type, $this->rep_block_types))
462  {
463  $block_class = substr($gui_class, 0, strlen($gui_class)-3);
464  include_once("./".self::$locations[$gui_class]."classes/".
465  "class.".$block_class.".php");
466  $app_block = new $block_class($_GET["block_id"]);
467  $block_gui->setBlock($app_block);
468  }
469  $html = $ilCtrl->forwardCommand($block_gui);
470  $ilCtrl->setParameter($this, "block_type", "");
471 
472  return $html;
473  }
474  }
475  else
476  {
477  return $this->$cmd();
478  }
479  }
480 
484  function getHTML()
485  {
486  global $ilCtrl, $ilBench;
487 
488  $ilBench->start("Column", "getHTML");
489 
490  $ilCtrl->setParameter($this, "col_side" ,$this->getSide());
491 
492  $this->tpl = new ilTemplate("tpl.column.html", true, true, "Services/Block");
493 
494  $ilBench->start("Column", "determineBlocks");
495  $this->determineBlocks();
496  $ilBench->stop("Column", "determineBlocks");
497 
498  $ilBench->start("Column", "showBlocks");
499  $this->showBlocks();
500  $ilBench->stop("Column", "showBlocks");
501 
502  if ($this->getEnableEdit() || !$this->getRepositoryMode())
503  {
504  $this->addHiddenBlockSelector();
505  }
506 
507  $ilBench->stop("Column", "getHTML");
508 
509  return $this->tpl->get();
510  }
511 
515  function showBlocks()
516  {
517  global $ilCtrl, $lng, $ilUser, $ilBench;
518 
519  $i = 1;
520  $sum_moveable = count($this->blocks[$this->getSide()]);
521 
522  foreach($this->blocks[$this->getSide()] as $block)
523  {
524  if ($ilCtrl->getContextObjType() != "user" ||
525  ilBlockSetting::_lookupDetailLevel($block["type"],
526  $ilUser->getId(), $block["id"]) > 0)
527  {
528  $gui_class = $block["class"];
529  $block_class = substr($block["class"], 0, strlen($block["class"])-3);
530 
531  // get block gui class
532  include_once("./".self::$locations[$gui_class]."classes/".
533  "class.".$gui_class.".php");
534  $ilBench->start("Column", "instantiate-".$block["type"]);
535  $block_gui = new $gui_class();
536  $ilBench->stop("Column", "instantiate-".$block["type"]);
537  if (isset($this->block_property[$block["type"]]))
538  {
539  $block_gui->setProperties($this->block_property[$block["type"]]);
540  }
541  $block_gui->setRepositoryMode($this->getRepositoryMode());
542  $block_gui->setEnableEdit($this->getEnableEdit());
543  $block_gui->setAdminCommands($this->getAdminCommands());
544 
545  // get block for custom blocks
546  if ($block["custom"])
547  {
548  $path = "./".self::$locations[$gui_class]."classes/".
549  "class.".$block_class.".php";
550  if(file_exists($path))
551  {
552  include_once($path);
553  $app_block = new $block_class($block["id"]);
554  }
555  else
556  {
557  // we only need generic block
558  $app_block = new ilCustomBlock($block["id"]);
559  }
560  $block_gui->setBlock($app_block);
561  if (isset($block["ref_id"]))
562  {
563  $block_gui->setRefId($block["ref_id"]);
564  }
565  }
566 
567  $ilCtrl->setParameter($this, "block_type", $block_gui->getBlockType());
568  $this->tpl->setCurrentBlock("col_block");
569 
570  $ilBench->start("Column", "showBlocks-".$block_gui->getBlockType());
571  $html = $ilCtrl->getHTML($block_gui);
572  $ilBench->stop("Column", "showBlocks-".$block_gui->getBlockType());
573 
574  // dummy block, if non visible, but movement is ongoing
575  if ($html == "" && $this->getRepositoryMode() &&
576  $this->getMovementMode())
577  {
578  include_once("./Services/Block/classes/class.ilDummyBlockGUI.php");
579  $bl = new ilDummyBlockGUI();
580  $bl->setBlockId($block["id"]);
581  $bl->setBlockType($block["type"]);
582  $bl->setTitle($lng->txt("invisible_block"));
583  $bl->setConfigMode($this->getMovementMode());
584  $html = $bl->getHTML();
585  }
586 
587  // don't render a block if it's empty
588  if ($html != "")
589  {
590  $this->tpl->setVariable("BLOCK", $html);
591  $this->tpl->parseCurrentBlock();
592  $ilCtrl->setParameter($this, "block_type", "");
593  }
594 
595  // count (moveable) blocks
596  if ($block["type"] != "pdsysmess" && $block["type"] != "pdfeedb" &&
597  $block["type"] != "news")
598  {
599  $i++;
600  }
601  else
602  {
603  $sum_moveable--;
604  }
605  }
606  }
607  }
608 
612  function addHiddenBlockSelector()
613  {
620  global $lng, $ilUser, $ilCtrl, $tpl;
621 
622  // show selector for hidden blocks
623  include_once("Services/Block/classes/class.ilBlockSetting.php");
624  $hidden_blocks = array();
625 
626  foreach($this->blocks[$this->getSide()] as $block)
627  {
628  include_once("./".self::$locations[$block["class"]]."classes/".
629  "class.".$block["class"].".php");
630 
631  if ($block["custom"] == false)
632  {
633  if ($ilCtrl->getContextObjType() == "user") // personal desktop
634  {
635  if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId()) == 0)
636  {
637  $hidden_blocks[$block["type"]] = $lng->txt('block_show_'.$block["type"]);
638  }
639  }
640  else if ($ilCtrl->getContextObjType() != "")
641  {
642  if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId(),
643  $ilCtrl->getContextObjId()) == 0)
644  {
645  $hidden_blocks[$block["type"]."_".$ilCtrl->getContextObjId()] = $lng->txt('block_show_'.$block["type"]);
646  }
647  }
648  }
649  else
650  {
651  if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId(),
652  $block["id"]) == 0)
653  {
654  include_once("./Services/Block/classes/class.ilCustomBlock.php");
655  $cblock = new ilCustomBlock($block["id"]);
656  $hidden_blocks[$block["type"]."_".$block["id"]] = sprintf($lng->txt('block_show_x'), $cblock->getTitle());
657  }
658  }
659  }
660  if(count($hidden_blocks) > 0)
661  {
662  foreach($hidden_blocks as $id => $title)
663  {
664  $ilCtrl->setParameter($this, 'block', $id);
665  $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'activateBlock'));
666  $ilCtrl->setParameter($this, 'block', '');
667  }
668  }
669 
670  // create block selection list
671  if (!$this->getRepositoryMode() || $this->getEnableEdit())
672  {
673  $add_blocks = array();
674  if ($this->getSide() == IL_COL_RIGHT)
675  {
676  if (is_array($this->custom_blocks[$this->getColType()]))
677  {
678  foreach($this->custom_blocks[$this->getColType()] as $block_class)
679  {
680  include_once("./".self::$locations[$block_class]."classes/".
681  "class.".$block_class.".php");
682  $block_type = call_user_func(array($block_class, 'getBlockType'));
683 
684  // check if block type is globally (de-)activated
685  if ($this->isGloballyActivated($block_type))
686  {
687  // check if number of blocks is limited
688  if (!$this->exceededLimit($block_type))
689  {
690  $add_blocks[$block_type] = $lng->txt('block_create_'.$block_type);
691  }
692  }
693  }
694  }
695  }
696  if(count($add_blocks) > 0)
697  {
698  foreach($add_blocks as $id => $title)
699  {
700  $ilCtrl->setParameter($this, 'block_type', $id);
701  $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'addBlock'));
702  $ilCtrl->setParameter($this, 'block_type', '');
703  }
704  }
705  }
706 
707  $this->addBlockSorting();
708  }
709 
713  protected function addBlockSorting()
714  {
715  if($this->getSide() == IL_COL_CENTER && $this->getEnableMovement())
716  {
722  global $ilBrowser, $tpl, $ilCtrl;
723 
724  include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
727 
728  if($ilBrowser->isMobile() || $ilBrowser->isIpad())
729  {
730  $tpl->addJavaScript('./Services/jQuery/js/jquery.ui.touch-punch.min.js');
731  }
732  $tpl->addJavaScript('./Services/Block/js/block_sorting.js');
733 
734  // set the col_side parameter to pass the ctrl structure flow
735  $ilCtrl->setParameter($this, 'col_side', IL_COL_CENTER);
736 
737  $this->tpl->setVariable('BLOCK_SORTING_STORAGE_URL', $ilCtrl->getLinkTarget($this, 'saveBlockSortingAsynch', '', true, false));
738  $this->tpl->setVariable('BLOCK_COLUMNS', json_encode(array('il_left_col', 'il_right_col')));
739  $this->tpl->setVariable('BLOCK_COLUMNS_SELECTOR', '#il_left_col,#il_right_col');
740  $this->tpl->setVariable('BLOCK_COLUMNS_PARAMETERS', json_encode(array(IL_COL_LEFT, IL_COL_RIGHT)));
741 
742  // restore col_side parameter
743  $ilCtrl->setParameter($this, 'col_side', $this->getSide());
744  }
745  }
746 
750  function updateBlock()
751  {
752  global $ilCtrl, $ilBench;
753 
754  $this->determineBlocks();
755  $i = 1;
756  $sum_moveable = count($this->blocks[$this->getSide()]);
757 
758  foreach ($this->blocks[$this->getSide()] as $block)
759  {
760 
761  include_once("./".self::$locations[$block["class"]]."classes/".
762  "class.".$block["class"].".php");
763 
764  // set block id to context obj id,
765  // if block is not a custom block and context is not personal desktop
766  if (!$block["custom"] && $ilCtrl->getContextObjType() != "" && $ilCtrl->getContextObjType() != "user")
767  {
768  $block["id"] = $ilCtrl->getContextObjId();
769  }
770 
771  //if (is_int(strpos($_GET["block_id"], "block_".$block["type"]."_".$block["id"])))
772 
773  if ($_GET["block_id"] == "block_".$block["type"]."_".$block["id"])
774  {
775  $gui_class = $block["class"];
776  $block_class = substr($block["class"], 0, strlen($block["class"])-3);
777 
778  $block_gui = new $gui_class();
779  $block_gui->setProperties($this->block_property[$block["type"]]);
780  $block_gui->setRepositoryMode($this->getRepositoryMode());
781  $block_gui->setEnableEdit($this->getEnableEdit());
782  $block_gui->setAdminCommands($this->getAdminCommands());
783 
784  // get block for custom blocks
785  if ($block["custom"])
786  {
787  include_once("./".self::$locations[$gui_class]."classes/".
788  "class.".$block_class.".php");
789  $app_block = new $block_class($block["id"]);
790  $block_gui->setBlock($app_block);
791  $block_gui->setRefId($block["ref_id"]);
792  }
793 
794  $ilCtrl->setParameter($this, "block_type", $block["type"]);
795  echo $ilCtrl->getHTML($block_gui);
796  $ilBench->save();
797  exit;
798  }
799 
800  // count (moveable) blocks
801  if ($block["type"] != "pdsysmess" && $block["type"] != "pdfeedb"
802  && $block["type"] != "news")
803  {
804  $i++;
805  }
806  else
807  {
808  $sum_moveable--;
809  }
810  }
811  echo "Error: ilColumnGUI::updateBlock: Block '".
812  $_GET["block_id"]."' unknown.";
813  exit;
814  }
815 
819  function activateBlock()
820  {
821  global $ilUser, $ilCtrl;
822 
823  if ($_GET["block"] != "")
824  {
825  $block = explode("_", $_GET["block"]);
826  include_once("Services/Block/classes/class.ilBlockSetting.php");
827  ilBlockSetting::_writeDetailLevel($block[0], 2, $ilUser->getId(), $block[1]);
828  }
829 
830  $ilCtrl->returnToParent($this);
831  }
832 
836  function addBlock()
837 
838  {
839  global $ilCtrl;
840 
841  $class = array_search($_GET["block_type"], self::$block_types);
842 
843  $ilCtrl->setCmdClass($class);
844  $ilCtrl->setCmd("create");
845  include_once("./".self::$locations[$class]."classes/class.".$class.".php");
846  $block_gui = new $class();
847  $block_gui->setProperties($this->block_property[$_GET["block_type"]]);
848  $block_gui->setRepositoryMode($this->getRepositoryMode());
849  $block_gui->setEnableEdit($this->getEnableEdit());
850  $block_gui->setAdminCommands($this->getAdminCommands());
851 
852  $ilCtrl->setParameter($this, "block_type", $_GET["block_type"]);
853  $html = $ilCtrl->forwardCommand($block_gui);
854  $ilCtrl->setParameter($this, "block_type", "");
855  return $html;
856  }
857 
861  function determineBlocks()
862  {
863  global $ilUser, $ilCtrl, $ilSetting;
864 
865  include_once("./Services/Block/classes/class.ilBlockSetting.php");
866  $this->blocks[IL_COL_LEFT] = array();
867  $this->blocks[IL_COL_RIGHT] = array();
868  $this->blocks[IL_COL_CENTER] = array();
869 
870  $user_id = ($this->getColType() == "pd")
871  ? $ilUser->getId()
872  : 0;
873 
874  $def_nr = 1000;
875  if (is_array($this->default_blocks[$this->getColType()]))
876  {
877  foreach($this->default_blocks[$this->getColType()] as $class => $def_side)
878  {
879  $type = self::$block_types[$class];
880 
881  if ($this->isGloballyActivated($type))
882  {
883  $nr = ilBlockSetting::_lookupNr($type, $user_id);
884  if ($nr === false)
885  {
886  $nr = $def_nr++;
887  }
888 
889 
890  // extra handling for system messages, feedback block and news
891  if ($type == "news") // always show news first
892  {
893  $nr = -15;
894  }
895  if ($type == "cal")
896  {
897  $nr = -8;
898  }
899  if ($type == "pdsysmess") // always show sys mess first
900  {
901 // $nr = -15;
902  }
903  if ($type == "pdfeedb") // always show feedback request second
904  {
905  $nr = -10;
906  }
907  if ($type == "clsfct") // mkunkel wants to have this on top
908  {
909  $nr = -16;
910  }
912  if ($side === false)
913  {
914  $side = $def_side;
915  }
916 
917  $this->blocks[$side][] = array(
918  "nr" => $nr,
919  "class" => $class,
920  "type" => $type,
921  "id" => 0,
922  "custom" => false);
923  }
924  }
925  }
926 
927  if (!$this->getRepositoryMode())
928  {
929  include_once("./Services/Block/classes/class.ilCustomBlock.php");
930  $custom_block = new ilCustomBlock();
931  $custom_block->setContextObjId($ilCtrl->getContextObjId());
932  $custom_block->setContextObjType($ilCtrl->getContextObjType());
933  $c_blocks = $custom_block->queryBlocksForContext();
934 
935  foreach($c_blocks as $c_block)
936  {
937  $type = $c_block["type"];
938 
939  if ($this->isGloballyActivated($type))
940  {
941  $class = array_search($type, self::$block_types);
942  $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]);
943  if ($nr === false)
944  {
945  $nr = $def_nr++;
946  }
947  $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
948  if ($side === false)
949  {
951  }
952 
953  $this->blocks[$side][] = array(
954  "nr" => $nr,
955  "class" => $class,
956  "type" => $type,
957  "id" => $c_block["id"],
958  "custom" => true);
959  }
960  }
961  }
962  else // get all subitems
963  {
964  include_once("./Services/Block/classes/class.ilCustomBlock.php");
965  $rep_items = $this->getRepositoryItems();
966 
967  foreach($this->rep_block_types as $block_type)
968  {
969  if ($this->isGloballyActivated($block_type))
970  {
971  if (!is_array($rep_items[$block_type]))
972  {
973  continue;
974  }
975  foreach($rep_items[$block_type] as $item)
976  {
977  $costum_block = new ilCustomBlock();
978  $costum_block->setContextObjId($item["obj_id"]);
979  $costum_block->setContextObjType($block_type);
980  $c_blocks = $costum_block->queryBlocksForContext();
981  $c_block = $c_blocks[0];
982 
983  $type = $block_type;
984  $class = array_search($type, self::$block_types);
985  $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]);
986  if ($nr === false)
987  {
988  $nr = $def_nr++;
989  }
990  $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
991  if ($side === false)
992  {
994  }
995 
996  $this->blocks[$side][] = array(
997  "nr" => $nr,
998  "class" => $class,
999  "type" => $type,
1000  "id" => $c_block["id"],
1001  "custom" => true,
1002  "ref_id" => $item["ref_id"]);
1003  }
1004  }
1005  }
1006 
1007  // repository object custom blocks
1008  include_once("./Services/Block/classes/class.ilCustomBlock.php");
1009  $custom_block = new ilCustomBlock();
1010  $custom_block->setContextObjId($ilCtrl->getContextObjId());
1011  $custom_block->setContextObjType($ilCtrl->getContextObjType());
1012  $c_blocks = $custom_block->queryBlocksForContext(false); // get all sub-object types
1013 
1014  foreach($c_blocks as $c_block)
1015  {
1016  $type = $c_block["type"];
1017  $class = array_search($type, self::$block_types);
1018 
1019  if($class)
1020  {
1021  $nr = $def_nr++;
1022  $side = IL_COL_RIGHT;
1023 
1024  $this->blocks[$side][] = array(
1025  "nr" => $nr,
1026  "class" => $class,
1027  "type" => $type,
1028  "id" => $c_block["id"],
1029  "custom" => true);
1030  }
1031  }
1032  }
1033 
1034 
1035  $this->blocks[IL_COL_LEFT] =
1036  ilUtil::sortArray($this->blocks[IL_COL_LEFT], "nr", "asc", true);
1037  $this->blocks[IL_COL_RIGHT] =
1038  ilUtil::sortArray($this->blocks[IL_COL_RIGHT], "nr", "asc", true);
1039  $this->blocks[IL_COL_CENTER] =
1040  ilUtil::sortArray($this->blocks[IL_COL_CENTER], "nr", "asc", true);
1041 
1042  }
1043 
1047  protected function isGloballyActivated($a_type)
1048  {
1049 
1050  global $ilSetting;
1051  if (isset($this->check_global_activation[$a_type]) && $this->check_global_activation[$a_type])
1052  {
1053  if ($a_type == 'pdbookm')
1054  {
1055  if (!$ilSetting->get("disable_bookmarks"))
1056  {
1057  return true;
1058  }
1059  return false;
1060  }
1061  else if ($a_type == 'pdnotes')
1062  {
1063  if (!$ilSetting->get("disable_notes"))
1064  {
1065  return true;
1066  }
1067  return false;
1068  }
1069  else if ($a_type == 'pdportf')
1070  {
1071  if ($ilSetting->get("user_portfolios"))
1072  {
1073  $prfa_set = new ilSetting("prfa");
1074  if ($prfa_set->get("pd_block", false))
1075  {
1076  return true;
1077  }
1078  }
1079  return false;
1080  }
1081  elseif($a_type == 'news')
1082  {
1083  include_once 'Services/Container/classes/class.ilContainer.php';
1084  return
1085  $ilSetting->get('block_activated_news') &&
1087  $GLOBALS['ilCtrl']->getContextObjId(),
1088  'cont_show_news',
1089  true
1090  );
1091  }
1092  else if ($ilSetting->get("block_activated_".$a_type))
1093  {
1094  return true;
1095  }
1096  elseif($a_type == 'cal')
1097  {
1098  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
1099  return ilCalendarSettings::lookupCalendarActivated($GLOBALS['ilCtrl']->getContextObjId());
1100 
1101  }
1102  elseif($a_type == 'pdcal')
1103  {
1104  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
1105  return ilCalendarSettings::_getInstance()->isEnabled();
1106  }
1107  elseif($a_type == "tagcld")
1108  {
1109  $tags_active = new ilSetting("tags");
1110  return (bool)$tags_active->get("enable", false);
1111  }
1112  return false;
1113  }
1114  return true;
1115  }
1116 
1120  protected function exceededLimit($a_type)
1121  {
1122  global $ilSetting, $ilCtrl;
1123 
1124  if ($this->check_nr_limit[$a_type])
1125  {
1126  if (!$this->getRepositoryMode())
1127  {
1128  include_once("./Services/Block/classes/class.ilCustomBlock.php");
1129  $costum_block = new ilCustomBlock();
1130  $costum_block->setContextObjId($ilCtrl->getContextObjId());
1131  $costum_block->setContextObjType($ilCtrl->getContextObjType());
1132  $costum_block->setType($a_type);
1133  $res = $costum_block->queryCntBlockForContext();
1134  $cnt = (int) $res[0]["cnt"];
1135  }
1136  else
1137  {
1138  return false; // not implemented for repository yet
1139  }
1140 
1141 
1142  if ($ilSetting->get("block_limit_".$a_type) > $cnt)
1143  {
1144  return false;
1145  }
1146  else
1147  {
1148  return true;
1149  }
1150  }
1151  return false;
1152  }
1153 
1157  public function saveBlockSortingAsynch()
1158  {
1162  global $ilUser;
1163 
1164  $response = new stdClass();
1165  $response->success = false;
1166 
1167  if(!isset($_POST[IL_COL_LEFT]['sequence']) && !isset($_POST[IL_COL_RIGHT]['sequence']))
1168  {
1169  echo json_encode($response);
1170  return;
1171  };
1172 
1173  if(in_array($this->getColType(), array('pd')))
1174  {
1175  $response->success = true;
1176 
1177  foreach(array(IL_COL_LEFT => (array)$_POST[IL_COL_LEFT]['sequence'], IL_COL_RIGHT => (array)$_POST[IL_COL_RIGHT]['sequence']) as $side => $blocks)
1178  {
1179  $i = 2;
1180  foreach($blocks as $block)
1181  {
1182  $bid = explode('_', $block);
1183  ilBlockSetting::_writeNumber($bid[1], $i, $ilUser->getId(), $bid[2]);
1184  ilBlockSetting::_writeSide($bid[1], $side, $ilUser->getId(), $bid[2]);
1185 
1186  $i +=2;
1187  }
1188  }
1189  }
1190 
1191  echo json_encode($response);
1192  exit();
1193  }
1194 
1199  public function setActionMenu($action_menu)
1200  {
1201  $this->action_menu = $action_menu;
1202  return $this;
1203  }
1204 
1208  public function getActionMenu()
1209  {
1210  return $this->action_menu;
1211  }
1212 }
__construct($a_col_type="", $a_side="", $use_std_context=false)
Constructor.
exceededLimit($a_type)
Check whether limit is not exceeded.
static initjQueryUI()
Init jQuery UI (see included_components.txt for included components)
ILIAS Setting Class.
static _getInstance()
get singleton instance
static addCustomBlockType($className, $identifier)
Adds the block type of the custom block gui.
static getCmdSide()
Get Column Side of Current Command.
exit
Definition: login.php:54
& executeCommand()
execute command
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...
getAdminCommands()
Get Administration Commmands.
$_POST['username']
Definition: cron.php:12
static _writeDetailLevel($a_type, $a_value, $a_user=0, $a_block_id=0)
Write detail level to database.
$_GET["client_id"]
setMovementMode($a_movementmode)
Set Movement Mode.
static _writeSide($a_type, $a_value, $a_user=0, $a_block_id=0)
Write side to database.
BlockGUI class for dummy block.
activateBlock()
Activate hidden block.
setAllBlockProperties($a_block_properties)
static lookupCalendarActivated($a_obj_id)
$cmd
Definition: sahs_server.php:35
static _lookupDetailLevel($a_type, $a_user=0, $a_block_id=0)
Lookup detail level.
const IL_COL_CENTER
setEnableEdit($a_enableedit)
Set EnableEdit.
getHTML()
Get HTML for column.
const IL_COL_RIGHT
getBlockProperties($a_block_type)
setColType($a_coltype)
Set Column Type.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
addBlock()
Add a block.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
setRepositoryItems($a_repositoryitems)
Set Repository Items.
setActionMenu($action_menu)
getRepositoryItems()
Get Repository Items.
Column user interface class.
setRepositoryMode($a_repositorymode)
Set RepositoryMode.
special template class to simplify handling of ITX/PEAR
getSide()
Get Side IL_COL_LEFT | IL_COL_RIGHT.
getEnableEdit()
Get EnableEdit.
getMovementMode()
Get Movement Mode.
const IL_SCREEN_CENTER
getEnableMovement()
Get Enable Movement.
static _lookupSide($a_type, $a_user=0, $a_block_id=0)
Lookup side.
This is the super class of all custom blocks.
static _lookupNr($a_type, $a_user=0, $a_block_id=0)
Lookup number.
static getScreenMode()
Get Screen Mode for current command.
global $ilUser
Definition: imgupload.php:15
showBlocks()
Show blocks.
global $ilSetting
Definition: privfeed.php:40
updateBlock()
Update Block (asynchronous)
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
_lookupContainerSetting($a_id, $a_keyword, $a_default_value=NULL)
Lookup a container setting.
global $ilBench
Definition: ilias.php:18
static initjQuery($a_tpl=null)
Init jQuery.
static addCustomBlockLocation($className, $path)
Adds location information of the custom block gui.
static _writeNumber($a_type, $a_value, $a_user=0, $a_block_id=0)
Write number to database.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
setAdminCommands($a_admincommands)
Set Administration Commmands.
const IL_SCREEN_SIDE
getRepositoryMode()
Get RepositoryMode.
isGloballyActivated($a_type)
Check whether a block type is globally activated.
$html
Definition: example_001.php:87
setSide($a_side)
Set Side IL_COL_LEFT | IL_COL_RIGHT.
getColType()
Get Column Type.
setEnableMovement($a_enablemovement)
Set Enable Movement.
determineBlocks()
Determine which blocks to show.
const IL_COL_LEFT