ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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  "ilPDTasksBlockGUI" => "Services/Tasks/",
80  "ilPDMailBlockGUI" => "Services/Mail/",
81  "ilPDSelectedItemsBlockGUI" => "Services/Dashboard/ItemsBlock/",
82  "ilPDNewsBlockGUI" => "Services/News/",
83  "ilExternalFeedBlockGUI" => "Modules/ExternalFeed/",
84  "ilPDExternalFeedBlockGUI" => "Services/Feeds/",
85  'ilPollBlockGUI' => 'Modules/Poll/',
86  'ilClassificationBlockGUI' => 'Services/Classification/',
87  "ilPDStudyProgrammeSimpleListGUI" => "Modules/StudyProgramme/",
88  "ilPDStudyProgrammeExpandableListGUI" => "Modules/StudyProgramme/",
89  );
90 
91  protected static $block_types = array(
92  "ilPDMailBlockGUI" => "pdmail",
93  "ilPDTasksBlockGUI" => "pdtasks",
94  "ilPDNewsBlockGUI" => "pdnews",
95  "ilNewsForContextBlockGUI" => "news",
96  "ilCalendarBlockGUI" => "cal",
97  "ilPDCalendarBlockGUI" => "pdcal",
98  "ilExternalFeedBlockGUI" => "feed",
99  "ilPDExternalFeedBlockGUI" => "pdfeed",
100  "ilPDSelectedItemsBlockGUI" => "pditems",
101  'ilPollBlockGUI' => 'poll',
102  'ilClassificationBlockGUI' => 'clsfct',
103  "ilPDStudyProgrammeSimpleListGUI" => "prgsimplelist",
104  "ilPDStudyProgrammeExpandableListGUI" => "prgexpandablelist",
105  );
106 
107 
108  protected $default_blocks = array(
109  "cat" => array(
110  "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
111  "ilClassificationBlockGUI" => IL_COL_RIGHT
112  ),
113  "crs" => array(
114  "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
115  "ilCalendarBlockGUI" => IL_COL_RIGHT,
116  "ilClassificationBlockGUI" => IL_COL_RIGHT
117  ),
118  "grp" => array(
119  "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
120  "ilCalendarBlockGUI" => IL_COL_RIGHT,
121  "ilClassificationBlockGUI" => IL_COL_RIGHT
122  ),
123  "frm" => array("ilNewsForContextBlockGUI" => IL_COL_RIGHT),
124  "root" => array(),
125  "info" => array(
126  "ilNewsForContextBlockGUI" => IL_COL_RIGHT),
127  "pd" => array(
128  "ilPDTasksBlockGUI" => IL_COL_RIGHT,
129  "ilPDCalendarBlockGUI" => IL_COL_RIGHT,
130  "ilPDNewsBlockGUI" => IL_COL_RIGHT,
131  "ilPDStudyProgrammeSimpleListGUI" => IL_COL_CENTER,
132  "ilPDStudyProgrammeExpandableListGUI" => IL_COL_CENTER,
133  "ilPDSelectedItemsBlockGUI" => IL_COL_CENTER,
134  "ilPDMailBlockGUI" => IL_COL_RIGHT
135  )
136  );
137 
138  // these are only for pd blocks
139  // other blocks are rep objects now
140  protected $custom_blocks = array(
141  "cat" => array(),
142  "crs" => array(),
143  "grp" => array(),
144  "frm" => array(),
145  "root" => array(),
146  "info" => array(),
147  "fold" => array(),
148  "pd" => array()
149  );
150  /*
151  "pd" => array("ilPDExternalFeedBlockGUI")
152  );*/
153 
154  // check global activation for these block types
155  // @todo: add calendar
157  array("news" => true,
158  "cal" => true,
159  "pdcal" => true,
160  "pdnews" => true,
161  "pdtag" => true,
162  "pdmail" => true,
163  "pdtasks" => true,
164  "tagcld" => true,
165  "clsfct" => true);
166 
167  protected $check_nr_limit =
168  array("pdfeed" => true);
169 
175  public function __construct($a_col_type = "", $a_side = "", $use_std_context = false)
176  {
177  global $DIC;
178 
179  $this->ctrl = $DIC->ctrl();
180  $this->lng = $DIC->language();
181  $this->user = $DIC->user();
182  $this->tpl = $DIC["tpl"];
183  $this->browser = $DIC["ilBrowser"];
184  $this->settings = $DIC->settings();
185  $this->setColType($a_col_type);
186  $this->setSide($a_side);
187 
188  $this->dash_side_panel_settings = new ilDashboardSidePanelSettingsRepository();
189  }
190 
201  public static function addCustomBlockLocation($className, $path)
202  {
203  self::$locations[$className] = $path;
204  }
205 
216  public static function addCustomBlockType($className, $identifier)
217  {
218  self::$block_types[$className] = $identifier;
219  }
220 
226  public static function getCmdSide()
227  {
228  return $_GET["col_side"];
229  }
230 
236  public function setColType($a_coltype)
237  {
238  $this->coltype = $a_coltype;
239  }
240 
246  public function getColType()
247  {
248  return $this->coltype;
249  }
250 
256  public function setSide($a_side)
257  {
258  $this->side = $a_side;
259  }
260 
266  public function getSide()
267  {
268  return $this->side;
269  }
270 
276  public function setEnableEdit($a_enableedit)
277  {
278  $this->enableedit = $a_enableedit;
279  }
280 
286  public function getEnableEdit()
287  {
288  return $this->enableedit;
289  }
290 
296  public function setRepositoryMode($a_repositorymode)
297  {
298  $this->repositorymode = $a_repositorymode;
299  }
300 
306  public function getRepositoryMode()
307  {
308  return $this->repositorymode;
309  }
310 
316  public function setAdminCommands($a_admincommands)
317  {
318  $this->admincommands = $a_admincommands;
319  }
320 
326  public function getAdminCommands()
327  {
328  return $this->admincommands;
329  }
330 
334  public static function getScreenMode()
335  {
336  global $DIC;
337 
338  $ilCtrl = $DIC->ctrl();
339 
340  if ($ilCtrl->getCmdClass() == "ilcolumngui") {
341  switch ($ilCtrl->getCmd()) {
342  case "addBlock":
343  return IL_SCREEN_CENTER;
344  }
345  }
346 
347  $cur_block_type = "";
348  if (isset($_GET["block_type"]) && $_GET["block_type"]) {
349  $cur_block_type = $_GET["block_type"];
350  } elseif (isset($_POST["block_type"])) {
351  $cur_block_type = $_POST["block_type"];
352  }
353 
354  if ($class = array_search($cur_block_type, self::$block_types)) {
355  include_once("./" . self::$locations[$class] . "classes/" .
356  "class." . $class . ".php");
357  return call_user_func(array($class, 'getScreenMode'));
358  }
359 
360  return IL_SCREEN_SIDE;
361  }
362 
370  public function setBlockProperty($a_block_type, $a_property, $a_value)
371  {
372  $this->block_property[$a_block_type][$a_property] = $a_value;
373  }
374 
375  public function getBlockProperties($a_block_type)
376  {
377  return $this->block_property[$a_block_type];
378  }
379 
380  public function setAllBlockProperties($a_block_properties)
381  {
382  $this->block_property = $a_block_properties;
383  }
384 
390  public function setRepositoryItems($a_repositoryitems)
391  {
392  $this->repositoryitems = $a_repositoryitems;
393  }
394 
400  public function getRepositoryItems()
401  {
402  return $this->repositoryitems;
403  }
404 
408  public function executeCommand()
409  {
411 
412  $ilCtrl->setParameter($this, "col_side", $this->getSide());
413  //$ilCtrl->saveParameter($this, "col_side");
414 
415  $next_class = $ilCtrl->getNextClass();
416  $cmd = $ilCtrl->getCmd("getHTML");
417 
418  $cur_block_type = ($_GET["block_type"])
419  ? $_GET["block_type"]
420  : $_POST["block_type"];
421 
422  if ($next_class != "") {
423  // forward to block
424  if ($gui_class = array_search($cur_block_type, self::$block_types)) {
425  include_once("./" . self::$locations[$gui_class] . "classes/" .
426  "class." . $gui_class . ".php");
427  $ilCtrl->setParameter($this, "block_type", $cur_block_type);
428  $block_gui = new $gui_class();
429  $block_gui->setProperties($this->block_property[$cur_block_type]);
430  $block_gui->setRepositoryMode($this->getRepositoryMode());
431  $block_gui->setEnableEdit($this->getEnableEdit());
432  $block_gui->setAdminCommands($this->getAdminCommands());
433 
434  if (in_array($gui_class, $this->custom_blocks[$this->getColType()]) ||
435  in_array($cur_block_type, $this->rep_block_types)) {
436  $block_class = substr($gui_class, 0, strlen($gui_class) - 3);
437  include_once("./" . self::$locations[$gui_class] . "classes/" .
438  "class." . $block_class . ".php");
439  $app_block = new $block_class($_GET["block_id"]);
440  $block_gui->setBlock($app_block);
441  }
442  $html = $ilCtrl->forwardCommand($block_gui);
443  $ilCtrl->setParameter($this, "block_type", "");
444 
445  return $html;
446  }
447  } else {
448  return $this->$cmd();
449  }
450  }
451 
455  public function getHTML()
456  {
458 
459  $ilCtrl->setParameter($this, "col_side", $this->getSide());
460 
461  $this->tpl = new ilTemplate("tpl.column.html", true, true, "Services/Block");
462  $this->determineBlocks();
463  $this->showBlocks();
464 
465  if ($this->getEnableEdit() || !$this->getRepositoryMode()) {
466  $this->addHiddenBlockSelector();
467  }
468 
469  return $this->tpl->get();
470  }
471 
475  public function showBlocks()
476  {
478  $lng = $this->lng;
480 
481  $i = 1;
482  $sum_moveable = count($this->blocks[$this->getSide()]);
483 
484  foreach ($this->blocks[$this->getSide()] as $block) {
485  if ($ilCtrl->getContextObjType() != "user" ||
487  $block["type"],
488  $ilUser->getId(),
489  $block["id"]
490  ) > 0) {
491  $gui_class = $block["class"];
492  $block_class = substr($block["class"], 0, strlen($block["class"]) - 3);
493 
494  // get block gui class
495  include_once("./" . self::$locations[$gui_class] . "classes/" .
496  "class." . $gui_class . ".php");
497  $block_gui = new $gui_class();
498  if (isset($this->block_property[$block["type"]])) {
499  $block_gui->setProperties($this->block_property[$block["type"]]);
500  }
501  $block_gui->setRepositoryMode($this->getRepositoryMode());
502  $block_gui->setEnableEdit($this->getEnableEdit());
503  $block_gui->setAdminCommands($this->getAdminCommands());
504 
505  // get block for custom blocks
506  if ($block["custom"]) {
507  $path = "./" . self::$locations[$gui_class] . "classes/" .
508  "class." . $block_class . ".php";
509  if (file_exists($path)) {
510  include_once($path);
511  $app_block = new $block_class($block["id"]);
512  } else {
513  // we only need generic block
514  $app_block = new ilCustomBlock($block["id"]);
515  }
516  $block_gui->setBlock($app_block);
517  if (isset($block["ref_id"])) {
518  $block_gui->setRefId($block["ref_id"]);
519  }
520  }
521 
522  $ilCtrl->setParameter($this, "block_type", $block_gui->getBlockType());
523  $this->tpl->setCurrentBlock("col_block");
524 
525  $html = $ilCtrl->getHTML($block_gui);
526 
527  // don't render a block if it's empty
528  if ($html != "") {
529  $this->tpl->setVariable("BLOCK", $html);
530  $this->tpl->parseCurrentBlock();
531  $ilCtrl->setParameter($this, "block_type", "");
532  }
533 
534  // count (moveable) blocks
535  if ($block["type"] != "pdfeedb" &&
536  $block["type"] != "news") {
537  $i++;
538  } else {
539  $sum_moveable--;
540  }
541  }
542  }
543  }
544 
548  public function addHiddenBlockSelector()
549  {
556  $lng = $this->lng;
559 
560  // show selector for hidden blocks
561  include_once("Services/Block/classes/class.ilBlockSetting.php");
562  $hidden_blocks = array();
563 
564  foreach ($this->blocks[$this->getSide()] as $block) {
565  include_once("./" . self::$locations[$block["class"]] . "classes/" .
566  "class." . $block["class"] . ".php");
567 
568  if ($block["custom"] == false) {
569  if ($ilCtrl->getContextObjType() == "user") { // personal desktop
570  if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId()) == 0) {
571  $hidden_blocks[$block["type"]] = $lng->txt('block_show_' . $block["type"]);
572  }
573  } elseif ($ilCtrl->getContextObjType() != "") {
575  $block["type"],
576  $ilUser->getId(),
577  $ilCtrl->getContextObjId()
578  ) == 0) {
579  $hidden_blocks[$block["type"] . "_" . $ilCtrl->getContextObjId()] = $lng->txt('block_show_' . $block["type"]);
580  }
581  }
582  } else {
584  $block["type"],
585  $ilUser->getId(),
586  $block["id"]
587  ) == 0) {
588  include_once("./Services/Block/classes/class.ilCustomBlock.php");
589  $cblock = new ilCustomBlock($block["id"]);
590  $hidden_blocks[$block["type"] . "_" . $block["id"]] = sprintf($lng->txt('block_show_x'), $cblock->getTitle());
591  }
592  }
593  }
594  if (count($hidden_blocks) > 0) {
595  foreach ($hidden_blocks as $id => $title) {
596  $ilCtrl->setParameter($this, 'block', $id);
597  $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'activateBlock'));
598  $ilCtrl->setParameter($this, 'block', '');
599  }
600  }
601 
602  // create block selection list
603  if (!$this->getRepositoryMode() || $this->getEnableEdit()) {
604  $add_blocks = array();
605  if ($this->getSide() == IL_COL_RIGHT) {
606  if (is_array($this->custom_blocks[$this->getColType()])) {
607  foreach ($this->custom_blocks[$this->getColType()] as $block_class) {
608  include_once("./" . self::$locations[$block_class] . "classes/" .
609  "class." . $block_class . ".php");
610  $block_gui = new $block_class();
611  $block_type = $block_gui->getBlockType();
612 
613  // check if block type is globally (de-)activated
614  if ($this->isGloballyActivated($block_type)) {
615  // check if number of blocks is limited
616  if (!$this->exceededLimit($block_type)) {
617  $add_blocks[$block_type] = $lng->txt('block_create_' . $block_type);
618  }
619  }
620  }
621  }
622  }
623  if (count($add_blocks) > 0) {
624  foreach ($add_blocks as $id => $title) {
625  $ilCtrl->setParameter($this, 'block_type', $id);
626  $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'addBlock'));
627  $ilCtrl->setParameter($this, 'block_type', '');
628  }
629  }
630  }
631  }
632 
633 
637  public function updateBlock()
638  {
640 
641  $this->determineBlocks();
642  $i = 1;
643  $sum_moveable = count($this->blocks[$this->getSide()]);
644 
645  foreach ($this->blocks[$this->getSide()] as $block) {
646  include_once("./" . self::$locations[$block["class"]] . "classes/" .
647  "class." . $block["class"] . ".php");
648 
649  // set block id to context obj id,
650  // if block is not a custom block and context is not personal desktop
651  if (!$block["custom"] && $ilCtrl->getContextObjType() != "" && $ilCtrl->getContextObjType() != "user") {
652  $block["id"] = $ilCtrl->getContextObjId();
653  }
654 
655  //if (is_int(strpos($_GET["block_id"], "block_".$block["type"]."_".$block["id"])))
656 
657  if ($_GET["block_id"] == "block_" . $block["type"] . "_" . $block["id"]) {
658  $gui_class = $block["class"];
659  $block_class = substr($block["class"], 0, strlen($block["class"]) - 3);
660 
661  $block_gui = new $gui_class();
662  $block_gui->setProperties($this->block_property[$block["type"]]);
663  $block_gui->setRepositoryMode($this->getRepositoryMode());
664  $block_gui->setEnableEdit($this->getEnableEdit());
665  $block_gui->setAdminCommands($this->getAdminCommands());
666 
667  // get block for custom blocks
668  if ($block["custom"]) {
669  include_once("./" . self::$locations[$gui_class] . "classes/" .
670  "class." . $block_class . ".php");
671  $app_block = new $block_class($block["id"]);
672  $block_gui->setBlock($app_block);
673  $block_gui->setRefId($block["ref_id"]);
674  }
675 
676  $ilCtrl->setParameter($this, "block_type", $block["type"]);
677  echo $ilCtrl->getHTML($block_gui);
678  exit;
679  }
680 
681  // count (moveable) blocks
682  if ($block["type"] != "pdfeedb"
683  && $block["type"] != "news") {
684  $i++;
685  } else {
686  $sum_moveable--;
687  }
688  }
689  echo "Error: ilColumnGUI::updateBlock: Block '" .
690  $_GET["block_id"] . "' unknown.";
691  exit;
692  }
693 
697  public function activateBlock()
698  {
701 
702  if ($_GET["block"] != "") {
703  $block = explode("_", $_GET["block"]);
704  include_once("Services/Block/classes/class.ilBlockSetting.php");
705  ilBlockSetting::_writeDetailLevel($block[0], 2, $ilUser->getId(), $block[1]);
706  }
707 
708  $ilCtrl->returnToParent($this);
709  }
710 
714  public function addBlock()
715  {
717 
718  $class = array_search($_GET["block_type"], self::$block_types);
719 
720  $ilCtrl->setCmdClass($class);
721  $ilCtrl->setCmd("create");
722  include_once("./" . self::$locations[$class] . "classes/class." . $class . ".php");
723  $block_gui = new $class();
724  $block_gui->setProperties($this->block_property[$_GET["block_type"]]);
725  $block_gui->setRepositoryMode($this->getRepositoryMode());
726  $block_gui->setEnableEdit($this->getEnableEdit());
727  $block_gui->setAdminCommands($this->getAdminCommands());
728 
729  $ilCtrl->setParameter($this, "block_type", $_GET["block_type"]);
730  $html = $ilCtrl->forwardCommand($block_gui);
731  $ilCtrl->setParameter($this, "block_type", "");
732  return $html;
733  }
734 
738  public function determineBlocks()
739  {
743 
744  include_once("./Services/Block/classes/class.ilBlockSetting.php");
745  $this->blocks[IL_COL_LEFT] = array();
746  $this->blocks[IL_COL_RIGHT] = array();
747  $this->blocks[IL_COL_CENTER] = array();
748 
749  $user_id = ($this->getColType() == "pd")
750  ? $ilUser->getId()
751  : 0;
752 
753  $def_nr = 1000;
754  if (is_array($this->default_blocks[$this->getColType()])) {
755  foreach ($this->default_blocks[$this->getColType()] as $class => $def_side) {
756  $type = self::$block_types[$class];
757 
758  if ($this->isGloballyActivated($type)) {
759  $nr = $def_nr++;
760 
761  // extra handling for system messages, feedback block and news
762  if ($type == "news") { // always show news first
763  $nr = -15;
764  }
765  if ($type == "cal") {
766  $nr = -8;
767  }
768  if ($type == "pdfeedb") { // always show feedback request second
769  $nr = -10;
770  }
771  if ($type == "clsfct") { // mkunkel wants to have this on top
772  $nr = -16;
773  }
775  if ($side === false) {
776  $side = $def_side;
777  }
778  if ($side == IL_COL_LEFT) {
780  }
781 
782  $this->blocks[$side][] = array(
783  "nr" => $nr,
784  "class" => $class,
785  "type" => $type,
786  "id" => 0,
787  "custom" => false);
788  }
789  }
790  }
791 
792  if (!$this->getRepositoryMode()) {
793  include_once("./Services/Block/classes/class.ilCustomBlock.php");
794  $custom_block = new ilCustomBlock();
795  $custom_block->setContextObjId($ilCtrl->getContextObjId());
796  $custom_block->setContextObjType($ilCtrl->getContextObjType());
797  $c_blocks = $custom_block->queryBlocksForContext();
798 
799  foreach ($c_blocks as $c_block) {
800  $type = $c_block["type"];
801 
802  if ($this->isGloballyActivated($type)) {
803  $class = array_search($type, self::$block_types);
804  $nr = $def_nr++;
805  $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
806  if ($side === false) {
808  }
809 
810  $this->blocks[$side][] = array(
811  "nr" => $nr,
812  "class" => $class,
813  "type" => $type,
814  "id" => $c_block["id"],
815  "custom" => true);
816  }
817  }
818  } else { // get all subitems
819  include_once("./Services/Block/classes/class.ilCustomBlock.php");
820  $rep_items = $this->getRepositoryItems();
821 
822  foreach ($this->rep_block_types as $block_type) {
823  if ($this->isGloballyActivated($block_type)) {
824  if (!is_array($rep_items[$block_type])) {
825  continue;
826  }
827  foreach ($rep_items[$block_type] as $item) {
828  $costum_block = new ilCustomBlock();
829  $costum_block->setContextObjId($item["obj_id"]);
830  $costum_block->setContextObjType($block_type);
831  $c_blocks = $costum_block->queryBlocksForContext();
832  $c_block = $c_blocks[0];
833 
834  $type = $block_type;
835  $class = array_search($type, self::$block_types);
836  $nr = $def_nr++;
837  $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
838  if ($side === false) {
840  }
841 
842  $this->blocks[$side][] = array(
843  "nr" => $nr,
844  "class" => $class,
845  "type" => $type,
846  "id" => $c_block["id"],
847  "custom" => true,
848  "ref_id" => $item["ref_id"]);
849  }
850  }
851  }
852 
853  // repository object custom blocks
854  include_once("./Services/Block/classes/class.ilCustomBlock.php");
855  $custom_block = new ilCustomBlock();
856  $custom_block->setContextObjId($ilCtrl->getContextObjId());
857  $custom_block->setContextObjType($ilCtrl->getContextObjType());
858  $c_blocks = $custom_block->queryBlocksForContext(false); // get all sub-object types
859 
860  foreach ($c_blocks as $c_block) {
861  $type = $c_block["type"];
862  $class = array_search($type, self::$block_types);
863 
864  if ($class) {
865  $nr = $def_nr++;
867 
868  $this->blocks[$side][] = array(
869  "nr" => $nr,
870  "class" => $class,
871  "type" => $type,
872  "id" => $c_block["id"],
873  "custom" => true);
874  }
875  }
876  }
877 
878 
879  $this->blocks[IL_COL_LEFT] =
880  ilUtil::sortArray($this->blocks[IL_COL_LEFT], "nr", "asc", true);
881  $this->blocks[IL_COL_RIGHT] =
882  ilUtil::sortArray($this->blocks[IL_COL_RIGHT], "nr", "asc", true);
883  $this->blocks[IL_COL_CENTER] =
884  ilUtil::sortArray($this->blocks[IL_COL_CENTER], "nr", "asc", true);
885  }
886 
890  protected function isGloballyActivated($a_type)
891  {
894 
895  if ($a_type == 'pdfeed') {
896  return false;
897  }
898 
899  if (isset($this->check_global_activation[$a_type]) && $this->check_global_activation[$a_type]) {
900  if ($a_type == 'pdnews') {
901  return ($this->dash_side_panel_settings->isEnabled($this->dash_side_panel_settings::NEWS) &&
902  $ilSetting->get('block_activated_news'));
903  } elseif ($a_type == 'pdmail') {
904  return $this->dash_side_panel_settings->isEnabled($this->dash_side_panel_settings::MAIL);
905  } elseif ($a_type == 'pdtasks') {
906  return $this->dash_side_panel_settings->isEnabled($this->dash_side_panel_settings::TASKS);
907  } elseif ($a_type == 'news') {
908  include_once 'Services/Container/classes/class.ilContainer.php';
909  return
910  $ilSetting->get('block_activated_news') &&
911 
912  (!in_array($ilCtrl->getContextObjType(), ["grp", "crs"]) ||
914  $GLOBALS['ilCtrl']->getContextObjId(),
916  true
917  )) &&
919  $GLOBALS['ilCtrl']->getContextObjId(),
920  'cont_show_news',
921  true
922  );
923  } elseif ($ilSetting->get("block_activated_" . $a_type)) {
924  return true;
925  } elseif ($a_type == 'cal') {
926  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
927  return ilCalendarSettings::lookupCalendarActivated($GLOBALS['ilCtrl']->getContextObjId());
928  } elseif ($a_type == 'pdcal') {
929  if (!$this->dash_side_panel_settings->isEnabled($this->dash_side_panel_settings::CALENDAR)) {
930  return false;
931  }
932  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
933  return ilCalendarSettings::_getInstance()->isEnabled();
934  } elseif ($a_type == "tagcld") {
935  $tags_active = new ilSetting("tags");
936  return (bool) $tags_active->get("enable", false);
937  } elseif ($a_type == "clsfct") {
938  if ($ilCtrl->getContextObjType() == "cat") { // taxonomy presentation in classification block
939  return true;
940  }
941  $tags_active = new ilSetting("tags"); // tags presentation in classification block
942  return (bool) $tags_active->get("enable", false);
943  }
944  return false;
945  }
946  return true;
947  }
948 
952  protected function exceededLimit($a_type)
953  {
956 
957  if ($this->check_nr_limit[$a_type]) {
958  if (!$this->getRepositoryMode()) {
959  include_once("./Services/Block/classes/class.ilCustomBlock.php");
960  $costum_block = new ilCustomBlock();
961  $costum_block->setContextObjId($ilCtrl->getContextObjId());
962  $costum_block->setContextObjType($ilCtrl->getContextObjType());
963  $costum_block->setType($a_type);
964  $res = $costum_block->queryCntBlockForContext();
965  $cnt = (int) $res[0]["cnt"];
966  } else {
967  return false; // not implemented for repository yet
968  }
969 
970 
971  if ($ilSetting->get("block_limit_" . $a_type) > $cnt) {
972  return false;
973  } else {
974  return true;
975  }
976  }
977  return false;
978  }
979 
983  public function saveBlockSortingAsynch()
984  {
989 
990  $response = new stdClass();
991  $response->success = false;
992 
993  if (!isset($_POST[IL_COL_LEFT]['sequence']) && !isset($_POST[IL_COL_RIGHT]['sequence'])) {
994  echo json_encode($response);
995  return;
996  };
997 
998  if (in_array($this->getColType(), array('pd'))) {
999  $response->success = true;
1000 
1001  foreach (array(IL_COL_LEFT => (array) $_POST[IL_COL_LEFT]['sequence'], IL_COL_RIGHT => (array) $_POST[IL_COL_RIGHT]['sequence']) as $side => $blocks) {
1002  $i = 2;
1003  foreach ($blocks as $block) {
1004  $bid = explode('_', $block);
1005  ilBlockSetting::_writeNumber($bid[1], $i, $ilUser->getId(), $bid[2]);
1006  ilBlockSetting::_writeSide($bid[1], $side, $ilUser->getId(), $bid[2]);
1007 
1008  $i += 2;
1009  }
1010  }
1011  }
1012 
1013  echo json_encode($response);
1014  exit();
1015  }
1016 
1021  public function setActionMenu($action_menu)
1022  {
1023  $this->action_menu = $action_menu;
1024  return $this;
1025  }
1026 
1030  public function getActionMenu()
1031  {
1032  return $this->action_menu;
1033  }
1034 }
__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 lookupCalendarActivated($a_obj_id)
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.
global $ilCtrl
Definition: ilias.php:18
$a_type
Definition: workflow.php:92
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.
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.
$ilUser
Definition: imgupload.php:18
const IL_SCREEN_CENTER
static _lookupSide($a_type, $a_user=0, $a_block_id=0)
Lookup side.
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)
$DIC
Definition: xapitoken.php:46
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.
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