ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 {
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 = false;
64 
68  protected $action_menu;
69 
70  //
71  // This two arrays may be replaced by some
72  // xml or other magic in the future...
73  //
74 
75  protected static $locations = array(
76  "ilNewsForContextBlockGUI" => "Services/News/",
77  "ilCalendarBlockGUI" => "Services/Calendar/",
78  "ilPDCalendarBlockGUI" => "Services/Calendar/",
79  "ilConsultationHoursCalendarBlockGUI" => "Services/Calendar/",
80  "ilPDTasksBlockGUI" => "Services/Tasks/",
81  "ilPDMailBlockGUI" => "Services/Mail/",
82  "ilPDSelectedItemsBlockGUI" => "Services/Dashboard/ItemsBlock/",
83  "ilPDNewsBlockGUI" => "Services/News/",
84  "ilExternalFeedBlockGUI" => "Modules/ExternalFeed/",
85  "ilPDExternalFeedBlockGUI" => "Services/Feeds/",
86  'ilPollBlockGUI' => 'Modules/Poll/',
87  'ilClassificationBlockGUI' => 'Services/Classification/',
88  "ilPDStudyProgrammeSimpleListGUI" => "Modules/StudyProgramme/",
89  "ilPDStudyProgrammeExpandableListGUI" => "Modules/StudyProgramme/",
90  );
91 
92  protected static $block_types = array(
93  "ilPDMailBlockGUI" => "pdmail",
94  "ilPDTasksBlockGUI" => "pdtasks",
95  "ilPDNewsBlockGUI" => "pdnews",
96  "ilNewsForContextBlockGUI" => "news",
97  "ilCalendarBlockGUI" => "cal",
98  "ilPDCalendarBlockGUI" => "pdcal",
99  "ilConsultationHoursCalendarBlockGUI" => "chcal",
100  "ilExternalFeedBlockGUI" => "feed",
101  "ilPDExternalFeedBlockGUI" => "pdfeed",
102  "ilPDSelectedItemsBlockGUI" => "pditems",
103  'ilPollBlockGUI' => 'poll',
104  'ilClassificationBlockGUI' => 'clsfct',
105  "ilPDStudyProgrammeSimpleListGUI" => "prgsimplelist",
106  "ilPDStudyProgrammeExpandableListGUI" => "prgexpandablelist",
107  );
108 
109 
110  protected $default_blocks = array(
111  "cat" => array(
112  "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
113  "ilClassificationBlockGUI" => IL_COL_RIGHT
114  ),
115  "crs" => array(
116  "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
117  "ilCalendarBlockGUI" => IL_COL_RIGHT,
118  "ilConsultationHoursCalendarBlockGUI" => IL_COL_RIGHT,
119  "ilClassificationBlockGUI" => IL_COL_RIGHT
120  ),
121  "grp" => array(
122  "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
123  "ilCalendarBlockGUI" => IL_COL_RIGHT,
124  "ilConsultationHoursCalendarBlockGUI" => IL_COL_RIGHT,
125  "ilClassificationBlockGUI" => IL_COL_RIGHT
126  ),
127  "frm" => array("ilNewsForContextBlockGUI" => IL_COL_RIGHT),
128  "root" => array(),
129  "info" => array(
130  "ilNewsForContextBlockGUI" => IL_COL_RIGHT),
131  "pd" => array(
132  "ilPDTasksBlockGUI" => IL_COL_RIGHT,
133  "ilPDCalendarBlockGUI" => IL_COL_RIGHT,
134  "ilPDNewsBlockGUI" => IL_COL_RIGHT,
135  "ilPDStudyProgrammeSimpleListGUI" => IL_COL_CENTER,
136  "ilPDStudyProgrammeExpandableListGUI" => IL_COL_CENTER,
137  "ilPDSelectedItemsBlockGUI" => IL_COL_CENTER,
138  "ilPDMailBlockGUI" => IL_COL_RIGHT
139  )
140  );
141 
142  // these are only for pd blocks
143  // other blocks are rep objects now
144  protected $custom_blocks = array(
145  "cat" => array(),
146  "crs" => array(),
147  "grp" => array(),
148  "frm" => array(),
149  "root" => array(),
150  "info" => array(),
151  "fold" => array(),
152  "pd" => array()
153  );
154  /*
155  "pd" => array("ilPDExternalFeedBlockGUI")
156  );*/
157 
158  // check global activation for these block types
159  // @todo: add calendar
161  array("news" => true,
162  "cal" => true,
163  "pdcal" => true,
164  "chcal" => true,
165  "pdnews" => true,
166  "pdtag" => true,
167  "pdmail" => true,
168  "pdtasks" => true,
169  "tagcld" => true,
170  "clsfct" => true);
171 
172  protected $check_nr_limit =
173  array("pdfeed" => true);
174 
180  public function __construct($a_col_type = "", $a_side = "", $use_std_context = false)
181  {
182  global $DIC;
183 
184  $this->ctrl = $DIC->ctrl();
185  $this->lng = $DIC->language();
186  $this->user = $DIC->user();
187  $this->tpl = $DIC["tpl"];
188  $this->browser = $DIC["ilBrowser"];
189  $this->settings = $DIC->settings();
190  $this->setColType($a_col_type);
191  $this->setSide($a_side);
192 
193  $this->dash_side_panel_settings = new ilDashboardSidePanelSettingsRepository();
194  }
195 
206  public static function addCustomBlockLocation($className, $path)
207  {
208  self::$locations[$className] = $path;
209  }
210 
221  public static function addCustomBlockType($className, $identifier)
222  {
223  self::$block_types[$className] = $identifier;
224  }
225 
231  public static function getCmdSide()
232  {
233  return $_GET["col_side"];
234  }
235 
241  public function setColType($a_coltype)
242  {
243  $this->coltype = $a_coltype;
244  }
245 
251  public function getColType()
252  {
253  return $this->coltype;
254  }
255 
261  public function setSide($a_side)
262  {
263  $this->side = $a_side;
264  }
265 
271  public function getSide()
272  {
273  return $this->side;
274  }
275 
281  public function setEnableEdit($a_enableedit)
282  {
283  $this->enableedit = $a_enableedit;
284  }
285 
291  public function getEnableEdit()
292  {
293  return $this->enableedit;
294  }
295 
301  public function setRepositoryMode($a_repositorymode)
302  {
303  $this->repositorymode = $a_repositorymode;
304  }
305 
311  public function getRepositoryMode()
312  {
313  return $this->repositorymode;
314  }
315 
321  public function setAdminCommands($a_admincommands)
322  {
323  $this->admincommands = $a_admincommands;
324  }
325 
331  public function getAdminCommands()
332  {
333  return $this->admincommands;
334  }
335 
339  public static function getScreenMode()
340  {
341  global $DIC;
342 
343  $ilCtrl = $DIC->ctrl();
344 
345  if ($ilCtrl->getCmdClass() == "ilcolumngui") {
346  switch ($ilCtrl->getCmd()) {
347  case "addBlock":
348  return IL_SCREEN_CENTER;
349  }
350  }
351 
352  $cur_block_type = "";
353  if (isset($_GET["block_type"]) && $_GET["block_type"]) {
354  $cur_block_type = $_GET["block_type"];
355  } elseif (isset($_POST["block_type"])) {
356  $cur_block_type = $_POST["block_type"];
357  }
358 
359  if ($class = array_search($cur_block_type, self::$block_types)) {
360  include_once("./" . self::$locations[$class] . "classes/" .
361  "class." . $class . ".php");
362  return call_user_func(array($class, 'getScreenMode'));
363  }
364 
365  return IL_SCREEN_SIDE;
366  }
367 
375  public function setBlockProperty($a_block_type, $a_property, $a_value)
376  {
377  $this->block_property[$a_block_type][$a_property] = $a_value;
378  }
379 
380  public function getBlockProperties($a_block_type)
381  {
382  return $this->block_property[$a_block_type];
383  }
384 
385  public function setAllBlockProperties($a_block_properties)
386  {
387  $this->block_property = $a_block_properties;
388  }
389 
395  public function setRepositoryItems($a_repositoryitems)
396  {
397  $this->repositoryitems = $a_repositoryitems;
398  }
399 
405  public function getRepositoryItems()
406  {
407  return $this->repositoryitems;
408  }
409 
413  public function executeCommand()
414  {
415  $ilCtrl = $this->ctrl;
416 
417  $ilCtrl->setParameter($this, "col_side", $this->getSide());
418  //$ilCtrl->saveParameter($this, "col_side");
419 
420  $next_class = $ilCtrl->getNextClass();
421  $cmd = $ilCtrl->getCmd("getHTML");
422 
423  $cur_block_type = ($_GET["block_type"])
424  ? $_GET["block_type"]
425  : $_POST["block_type"];
426 
427  if ($next_class != "") {
428  // forward to block
429  if ($gui_class = array_search($cur_block_type, self::$block_types)) {
430  include_once("./" . self::$locations[$gui_class] . "classes/" .
431  "class." . $gui_class . ".php");
432  $ilCtrl->setParameter($this, "block_type", $cur_block_type);
433  $block_gui = new $gui_class();
434  $block_gui->setProperties($this->block_property[$cur_block_type]);
435  $block_gui->setRepositoryMode($this->getRepositoryMode());
436  $block_gui->setEnableEdit($this->getEnableEdit());
437  $block_gui->setAdminCommands($this->getAdminCommands());
438 
439  if (in_array($gui_class, $this->custom_blocks[$this->getColType()]) ||
440  in_array($cur_block_type, $this->rep_block_types)) {
441  $block_class = substr($gui_class, 0, strlen($gui_class) - 3);
442  include_once("./" . self::$locations[$gui_class] . "classes/" .
443  "class." . $block_class . ".php");
444  $app_block = new $block_class($_GET["block_id"]);
445  $block_gui->setBlock($app_block);
446  }
447  $html = $ilCtrl->forwardCommand($block_gui);
448  $ilCtrl->setParameter($this, "block_type", "");
449 
450  return $html;
451  }
452  } else {
453  return $this->$cmd();
454  }
455  }
456 
460  public function getHTML()
461  {
462  $ilCtrl = $this->ctrl;
463 
464  $ilCtrl->setParameter($this, "col_side", $this->getSide());
465 
466  $this->tpl = new ilTemplate("tpl.column.html", true, true, "Services/Block");
467  $this->determineBlocks();
468  $this->showBlocks();
469 
470  if ($this->getEnableEdit() || !$this->getRepositoryMode()) {
471  $this->addHiddenBlockSelector();
472  }
473 
474  return $this->tpl->get();
475  }
476 
480  public function showBlocks()
481  {
482  $ilCtrl = $this->ctrl;
483  $lng = $this->lng;
485 
486  $i = 1;
487  $sum_moveable = count($this->blocks[$this->getSide()]);
488 
489  foreach ($this->blocks[$this->getSide()] as $block) {
490  if ($ilCtrl->getContextObjType() != "user" ||
492  $block["type"],
493  $ilUser->getId(),
494  $block["id"]
495  ) > 0) {
496  $gui_class = $block["class"];
497  $block_class = substr($block["class"], 0, strlen($block["class"]) - 3);
498 
499  // get block gui class
500  include_once("./" . self::$locations[$gui_class] . "classes/" .
501  "class." . $gui_class . ".php");
502  $block_gui = new $gui_class();
503  if (isset($this->block_property[$block["type"]])) {
504  $block_gui->setProperties($this->block_property[$block["type"]]);
505  }
506  $block_gui->setRepositoryMode($this->getRepositoryMode());
507  $block_gui->setEnableEdit($this->getEnableEdit());
508  $block_gui->setAdminCommands($this->getAdminCommands());
509 
510  // get block for custom blocks
511  if ($block["custom"]) {
512  $path = "./" . self::$locations[$gui_class] . "classes/" .
513  "class." . $block_class . ".php";
514  if (file_exists($path)) {
515  include_once($path);
516  $app_block = new $block_class($block["id"]);
517  } else {
518  // we only need generic block
519  $app_block = new ilCustomBlock($block["id"]);
520  }
521  $block_gui->setBlock($app_block);
522  if (isset($block["ref_id"])) {
523  $block_gui->setRefId($block["ref_id"]);
524  }
525  }
526 
527  $ilCtrl->setParameter($this, "block_type", $block_gui->getBlockType());
528  $this->tpl->setCurrentBlock("col_block");
529 
530  $html = $ilCtrl->getHTML($block_gui);
531 
532  // don't render a block if it's empty
533  if ($html != "") {
534  $this->tpl->setVariable("BLOCK", $html);
535  $this->tpl->parseCurrentBlock();
536  $ilCtrl->setParameter($this, "block_type", "");
537  }
538 
539  // count (moveable) blocks
540  if ($block["type"] != "pdfeedb" &&
541  $block["type"] != "news") {
542  $i++;
543  } else {
544  $sum_moveable--;
545  }
546  }
547  }
548  }
549 
553  public function addHiddenBlockSelector()
554  {
561  $lng = $this->lng;
563  $ilCtrl = $this->ctrl;
564 
565  // show selector for hidden blocks
566  include_once("Services/Block/classes/class.ilBlockSetting.php");
567  $hidden_blocks = array();
568 
569  foreach ($this->blocks[$this->getSide()] as $block) {
570  include_once("./" . self::$locations[$block["class"]] . "classes/" .
571  "class." . $block["class"] . ".php");
572 
573  if ($block["custom"] == false) {
574  if ($ilCtrl->getContextObjType() == "user") { // personal desktop
575  if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId()) == 0) {
576  $hidden_blocks[$block["type"]] = $lng->txt('block_show_' . $block["type"]);
577  }
578  } elseif ($ilCtrl->getContextObjType() != "") {
580  $block["type"],
581  $ilUser->getId(),
582  $ilCtrl->getContextObjId()
583  ) == 0) {
584  $hidden_blocks[$block["type"] . "_" . $ilCtrl->getContextObjId()] = $lng->txt('block_show_' . $block["type"]);
585  }
586  }
587  } else {
589  $block["type"],
590  $ilUser->getId(),
591  $block["id"]
592  ) == 0) {
593  include_once("./Services/Block/classes/class.ilCustomBlock.php");
594  $cblock = new ilCustomBlock($block["id"]);
595  $hidden_blocks[$block["type"] . "_" . $block["id"]] = sprintf($lng->txt('block_show_x'), $cblock->getTitle());
596  }
597  }
598  }
599  if (count($hidden_blocks) > 0) {
600  foreach ($hidden_blocks as $id => $title) {
601  $ilCtrl->setParameter($this, 'block', $id);
602  $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'activateBlock'));
603  $ilCtrl->setParameter($this, 'block', '');
604  }
605  }
606 
607  // create block selection list
608  if (!$this->getRepositoryMode() || $this->getEnableEdit()) {
609  $add_blocks = array();
610  if ($this->getSide() == IL_COL_RIGHT) {
611  if (is_array($this->custom_blocks[$this->getColType()])) {
612  foreach ($this->custom_blocks[$this->getColType()] as $block_class) {
613  include_once("./" . self::$locations[$block_class] . "classes/" .
614  "class." . $block_class . ".php");
615  $block_gui = new $block_class();
616  $block_type = $block_gui->getBlockType();
617 
618  // check if block type is globally (de-)activated
619  if ($this->isGloballyActivated($block_type)) {
620  // check if number of blocks is limited
621  if (!$this->exceededLimit($block_type)) {
622  $add_blocks[$block_type] = $lng->txt('block_create_' . $block_type);
623  }
624  }
625  }
626  }
627  }
628  if (count($add_blocks) > 0) {
629  foreach ($add_blocks as $id => $title) {
630  $ilCtrl->setParameter($this, 'block_type', $id);
631  $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'addBlock'));
632  $ilCtrl->setParameter($this, 'block_type', '');
633  }
634  }
635  }
636  }
637 
638 
642  public function updateBlock()
643  {
644  $ilCtrl = $this->ctrl;
645 
646  $this->determineBlocks();
647  $i = 1;
648  $sum_moveable = count($this->blocks[$this->getSide()]);
649 
650  foreach ($this->blocks[$this->getSide()] as $block) {
651  include_once("./" . self::$locations[$block["class"]] . "classes/" .
652  "class." . $block["class"] . ".php");
653 
654  // set block id to context obj id,
655  // if block is not a custom block and context is not personal desktop
656  if (!$block["custom"] && $ilCtrl->getContextObjType() != "" && $ilCtrl->getContextObjType() != "user") {
657  $block["id"] = $ilCtrl->getContextObjId();
658  }
659 
660  //if (is_int(strpos($_GET["block_id"], "block_".$block["type"]."_".$block["id"])))
661 
662  if ($_GET["block_id"] == "block_" . $block["type"] . "_" . $block["id"]) {
663  $gui_class = $block["class"];
664  $block_class = substr($block["class"], 0, strlen($block["class"]) - 3);
665 
666  $block_gui = new $gui_class();
667  $block_gui->setProperties($this->block_property[$block["type"]]);
668  $block_gui->setRepositoryMode($this->getRepositoryMode());
669  $block_gui->setEnableEdit($this->getEnableEdit());
670  $block_gui->setAdminCommands($this->getAdminCommands());
671 
672  // get block for custom blocks
673  if ($block["custom"]) {
674  include_once("./" . self::$locations[$gui_class] . "classes/" .
675  "class." . $block_class . ".php");
676  $app_block = new $block_class($block["id"]);
677  $block_gui->setBlock($app_block);
678  $block_gui->setRefId($block["ref_id"]);
679  }
680 
681  $ilCtrl->setParameter($this, "block_type", $block["type"]);
682  echo $ilCtrl->getHTML($block_gui);
683  exit;
684  }
685 
686  // count (moveable) blocks
687  if ($block["type"] != "pdfeedb"
688  && $block["type"] != "news") {
689  $i++;
690  } else {
691  $sum_moveable--;
692  }
693  }
694  echo "Error: ilColumnGUI::updateBlock: Block '" .
695  $_GET["block_id"] . "' unknown.";
696  exit;
697  }
698 
702  public function activateBlock()
703  {
705  $ilCtrl = $this->ctrl;
706 
707  if ($_GET["block"] != "") {
708  $block = explode("_", $_GET["block"]);
709  include_once("Services/Block/classes/class.ilBlockSetting.php");
710  ilBlockSetting::_writeDetailLevel($block[0], 2, $ilUser->getId(), $block[1]);
711  }
712 
713  $ilCtrl->returnToParent($this);
714  }
715 
719  public function addBlock()
720  {
721  $ilCtrl = $this->ctrl;
722 
723  $class = array_search($_GET["block_type"], self::$block_types);
724 
725  $ilCtrl->setCmdClass($class);
726  $ilCtrl->setCmd("create");
727  include_once("./" . self::$locations[$class] . "classes/class." . $class . ".php");
728  $block_gui = new $class();
729  $block_gui->setProperties($this->block_property[$_GET["block_type"]]);
730  $block_gui->setRepositoryMode($this->getRepositoryMode());
731  $block_gui->setEnableEdit($this->getEnableEdit());
732  $block_gui->setAdminCommands($this->getAdminCommands());
733 
734  $ilCtrl->setParameter($this, "block_type", $_GET["block_type"]);
735  $html = $ilCtrl->forwardCommand($block_gui);
736  $ilCtrl->setParameter($this, "block_type", "");
737  return $html;
738  }
739 
743  public function determineBlocks()
744  {
746  $ilCtrl = $this->ctrl;
748 
749  include_once("./Services/Block/classes/class.ilBlockSetting.php");
750  $this->blocks[IL_COL_LEFT] = array();
751  $this->blocks[IL_COL_RIGHT] = array();
752  $this->blocks[IL_COL_CENTER] = array();
753 
754  $user_id = ($this->getColType() == "pd")
755  ? $ilUser->getId()
756  : 0;
757 
758  $def_nr = 1000;
759  if (is_array($this->default_blocks[$this->getColType()])) {
760  foreach ($this->default_blocks[$this->getColType()] as $class => $def_side) {
761  $type = self::$block_types[$class];
762 
763  if ($this->isGloballyActivated($type)) {
764  $nr = $def_nr++;
765 
766  // extra handling for system messages, feedback block and news
767  if ($type == "news") { // always show news first
768  $nr = -15;
769  }
770  if ($type == "cal") {
771  $nr = -8;
772  }
773  if ($type == "chcal") { // consultation hours always directly below calendar
774  $nr = -7;
775  }
776  if ($type == "pdfeedb") { // always show feedback request second
777  $nr = -10;
778  }
779  if ($type == "clsfct") { // mkunkel wants to have this on top
780  $nr = -16;
781  }
783  if ($side === false) {
784  $side = $def_side;
785  }
786  if ($side == IL_COL_LEFT) {
788  }
789 
790  $this->blocks[$side][] = array(
791  "nr" => $nr,
792  "class" => $class,
793  "type" => $type,
794  "id" => 0,
795  "custom" => false);
796  }
797  }
798  }
799 
800  if (!$this->getRepositoryMode()) {
801  include_once("./Services/Block/classes/class.ilCustomBlock.php");
802  $custom_block = new ilCustomBlock();
803  $custom_block->setContextObjId($ilCtrl->getContextObjId());
804  $custom_block->setContextObjType($ilCtrl->getContextObjType());
805  $c_blocks = $custom_block->queryBlocksForContext();
806 
807  foreach ($c_blocks as $c_block) {
808  $type = $c_block["type"];
809 
810  if ($this->isGloballyActivated($type)) {
811  $class = array_search($type, self::$block_types);
812  $nr = $def_nr++;
813  $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
814  if ($side === false) {
816  }
817 
818  $this->blocks[$side][] = array(
819  "nr" => $nr,
820  "class" => $class,
821  "type" => $type,
822  "id" => $c_block["id"],
823  "custom" => true);
824  }
825  }
826  } else { // get all subitems
827  include_once("./Services/Block/classes/class.ilCustomBlock.php");
828  $rep_items = $this->getRepositoryItems();
829 
830  foreach ($this->rep_block_types as $block_type) {
831  if ($this->isGloballyActivated($block_type)) {
832  if (!is_array($rep_items[$block_type])) {
833  continue;
834  }
835  foreach ($rep_items[$block_type] as $item) {
836  $costum_block = new ilCustomBlock();
837  $costum_block->setContextObjId($item["obj_id"]);
838  $costum_block->setContextObjType($block_type);
839  $c_blocks = $costum_block->queryBlocksForContext();
840  $c_block = $c_blocks[0];
841 
842  $type = $block_type;
843  $class = array_search($type, self::$block_types);
844  $nr = $def_nr++;
845  $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
846  if ($side === false) {
848  }
849 
850  $this->blocks[$side][] = array(
851  "nr" => $nr,
852  "class" => $class,
853  "type" => $type,
854  "id" => $c_block["id"],
855  "custom" => true,
856  "ref_id" => $item["ref_id"]);
857  }
858  }
859  }
860 
861  // repository object custom blocks
862  include_once("./Services/Block/classes/class.ilCustomBlock.php");
863  $custom_block = new ilCustomBlock();
864  $custom_block->setContextObjId($ilCtrl->getContextObjId());
865  $custom_block->setContextObjType($ilCtrl->getContextObjType());
866  $c_blocks = $custom_block->queryBlocksForContext(false); // get all sub-object types
867 
868  foreach ($c_blocks as $c_block) {
869  $type = $c_block["type"];
870  $class = array_search($type, self::$block_types);
871 
872  if ($class) {
873  $nr = $def_nr++;
875 
876  $this->blocks[$side][] = array(
877  "nr" => $nr,
878  "class" => $class,
879  "type" => $type,
880  "id" => $c_block["id"],
881  "custom" => true);
882  }
883  }
884  }
885 
886 
887  $this->blocks[IL_COL_LEFT] =
888  ilUtil::sortArray($this->blocks[IL_COL_LEFT], "nr", "asc", true);
889  $this->blocks[IL_COL_RIGHT] =
890  ilUtil::sortArray($this->blocks[IL_COL_RIGHT], "nr", "asc", true);
891  $this->blocks[IL_COL_CENTER] =
892  ilUtil::sortArray($this->blocks[IL_COL_CENTER], "nr", "asc", true);
893  }
894 
898  protected function isGloballyActivated($a_type)
899  {
901  $ilCtrl = $this->ctrl;
902 
903  if ($a_type == 'pdfeed') {
904  return false;
905  }
906 
907  if (isset($this->check_global_activation[$a_type]) && $this->check_global_activation[$a_type]) {
908  if ($a_type == 'pdnews') {
909  return ($this->dash_side_panel_settings->isEnabled($this->dash_side_panel_settings::NEWS) &&
910  $ilSetting->get('block_activated_news'));
911  } elseif ($a_type == 'pdmail') {
912  return $this->dash_side_panel_settings->isEnabled($this->dash_side_panel_settings::MAIL);
913  } elseif ($a_type == 'pdtasks') {
914  return $this->dash_side_panel_settings->isEnabled($this->dash_side_panel_settings::TASKS);
915  } elseif ($a_type == 'news') {
916  include_once 'Services/Container/classes/class.ilContainer.php';
917  return
918  $ilSetting->get('block_activated_news') &&
919 
920  (!in_array($ilCtrl->getContextObjType(), ["grp", "crs"]) ||
922  $GLOBALS['ilCtrl']->getContextObjId(),
924  true
925  )) &&
927  $GLOBALS['ilCtrl']->getContextObjId(),
928  'cont_show_news',
929  true
930  );
931  } elseif ($ilSetting->get("block_activated_" . $a_type)) {
932  return true;
933  } elseif ($a_type == 'cal' || $a_type == 'chcal') {
934  return ilCalendarSettings::lookupCalendarContentPresentationEnabled($ilCtrl->getContextObjId());
935  } elseif ($a_type == 'pdcal') {
936  if (!$this->dash_side_panel_settings->isEnabled($this->dash_side_panel_settings::CALENDAR)) {
937  return false;
938  }
939  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
940  return ilCalendarSettings::_getInstance()->isEnabled();
941  } elseif ($a_type == "tagcld") {
942  $tags_active = new ilSetting("tags");
943  return (bool) $tags_active->get("enable", false);
944  } elseif ($a_type == "clsfct") {
945  if ($ilCtrl->getContextObjType() == "cat") { // taxonomy presentation in classification block
946  return true;
947  }
948  $tags_active = new ilSetting("tags"); // tags presentation in classification block
949  return (bool) $tags_active->get("enable", false);
950  }
951  return false;
952  }
953  return true;
954  }
955 
959  protected function exceededLimit($a_type)
960  {
962  $ilCtrl = $this->ctrl;
963 
964  if ($this->check_nr_limit[$a_type]) {
965  if (!$this->getRepositoryMode()) {
966  include_once("./Services/Block/classes/class.ilCustomBlock.php");
967  $costum_block = new ilCustomBlock();
968  $costum_block->setContextObjId($ilCtrl->getContextObjId());
969  $costum_block->setContextObjType($ilCtrl->getContextObjType());
970  $costum_block->setType($a_type);
971  $res = $costum_block->queryCntBlockForContext();
972  $cnt = (int) $res[0]["cnt"];
973  } else {
974  return false; // not implemented for repository yet
975  }
976 
977 
978  if ($ilSetting->get("block_limit_" . $a_type) > $cnt) {
979  return false;
980  } else {
981  return true;
982  }
983  }
984  return false;
985  }
986 
990  public function saveBlockSortingAsynch()
991  {
996 
997  $response = new stdClass();
998  $response->success = false;
999 
1000  if (!isset($_POST[IL_COL_LEFT]['sequence']) && !isset($_POST[IL_COL_RIGHT]['sequence'])) {
1001  echo json_encode($response);
1002  return;
1003  };
1004 
1005  if (in_array($this->getColType(), array('pd'))) {
1006  $response->success = true;
1007 
1008  foreach (array(IL_COL_LEFT => (array) $_POST[IL_COL_LEFT]['sequence'], IL_COL_RIGHT => (array) $_POST[IL_COL_RIGHT]['sequence']) as $side => $blocks) {
1009  $i = 2;
1010  foreach ($blocks as $block) {
1011  $bid = explode('_', $block);
1012  ilBlockSetting::_writeNumber($bid[1], $i, $ilUser->getId(), $bid[2]);
1013  ilBlockSetting::_writeSide($bid[1], $side, $ilUser->getId(), $bid[2]);
1014 
1015  $i += 2;
1016  }
1017  }
1018  }
1019 
1020  echo json_encode($response);
1021  exit();
1022  }
1023 
1028  public function setActionMenu($action_menu)
1029  {
1030  $this->action_menu = $action_menu;
1031  return $this;
1032  }
1033 
1037  public function getActionMenu()
1038  {
1039  return $this->action_menu;
1040  }
1041 }
__construct($a_col_type="", $a_side="", $use_std_context=false)
Constructor.
exceededLimit($a_type)
Check whether limit is not exceeded.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
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:29
settings()
Definition: settings.php:2
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.
static _writeDetailLevel($a_type, $a_value, $a_user=0, $a_block_id=0)
Write detail level to database.
$_GET["client_id"]
static _writeSide($a_type, $a_value, $a_user=0, $a_block_id=0)
Write side to database.
activateBlock()
Activate hidden block.
setAllBlockProperties($a_block_properties)
static _lookupDetailLevel($a_type, $a_user=0, $a_block_id=0)
Lookup detail level.
executeCommand()
execute command
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.
user()
Definition: user.php:4
addBlock()
Add a block.
setRepositoryItems($a_repositoryitems)
Set Repository Items.
foreach($_POST as $key=> $value) $res
setActionMenu($action_menu)
getRepositoryItems()
Get Repository Items.
Column user interface class.
setRepositoryMode($a_repositorymode)
Set RepositoryMode.
global $DIC
Definition: goto.php:24
getSide()
Get Side IL_COL_LEFT | IL_COL_RIGHT.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
getEnableEdit()
Get EnableEdit.
const IL_SCREEN_CENTER
static _lookupSide($a_type, $a_user=0, $a_block_id=0)
Lookup side.
static lookupCalendarContentPresentationEnabled(int $obj_id)
This is the super class of all custom blocks.
static getScreenMode()
Get Screen Mode for current command.
showBlocks()
Show blocks.
global $ilSetting
Definition: privfeed.php:17
updateBlock()
Update Block (asynchronous)
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.
$ilUser
Definition: imgupload.php:18
setAdminCommands($a_admincommands)
Set Administration Commmands.
const IL_SCREEN_SIDE
$response
getRepositoryMode()
Get RepositoryMode.
isGloballyActivated($a_type)
Check whether a block type is globally activated.
$_POST["username"]
setSide($a_side)
Set Side IL_COL_LEFT | IL_COL_RIGHT.
getColType()
Get Column Type.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
determineBlocks()
Determine which blocks to show.
const IL_COL_LEFT
$i
Definition: metadata.php:24