ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 = 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  "ilPDSysMessageBlockGUI" => "Services/Mail/",
84  "ilPDSelectedItemsBlockGUI" => "Services/PersonalDesktop/ItemsBlock/",
85  "ilBookmarkBlockGUI" => "Services/Bookmarks/",
86  "ilPDNewsBlockGUI" => "Services/News/",
87  "ilExternalFeedBlockGUI" => "Services/Block/",
88  "ilPDExternalFeedBlockGUI" => "Services/Feeds/",
89  'ilPDTaggingBlockGUI' => 'Services/Tagging/',
90  'ilChatroomBlockGUI' => 'Modules/Chatroom/',
91  'ilPollBlockGUI' => 'Modules/Poll/',
92  'ilClassificationBlockGUI' => 'Services/Classification/',
93  'ilPDPortfolioBlockGUI' => 'Modules/Portfolio/',
94  "ilPDStudyProgrammeSimpleListGUI" => "Modules/StudyProgramme/",
95  "ilPDStudyProgrammeExpandableListGUI" => "Modules/StudyProgramme/",
96  "ilForumPostingDraftsBlockGUI" => "Modules/Forum/"
97  );
98 
99  protected static $block_types = array(
100  "ilPDMailBlockGUI" => "pdmail",
101  "ilPDNotesBlockGUI" => "pdnotes",
102  "ilPDNewsBlockGUI" => "pdnews",
103  "ilBookmarkBlockGUI" => "pdbookm",
104  "ilNewsForContextBlockGUI" => "news",
105  "ilCalendarBlockGUI" => "cal",
106  "ilPDCalendarBlockGUI" => "pdcal",
107  "ilExternalFeedBlockGUI" => "feed",
108  "ilPDExternalFeedBlockGUI" => "pdfeed",
109  "ilPDSysMessageBlockGUI" => "pdsysmess",
110  "ilPDSelectedItemsBlockGUI" => "pditems",
111  'ilPDTaggingBlockGUI' => 'pdtag',
112  'ilChatroomBlockGUI' => 'chatviewer',
113  'ilPollBlockGUI' => 'poll',
114  'ilClassificationBlockGUI' => 'clsfct',
115  'ilPDPortfolioBlockGUI' => 'pdportf',
116  "ilPDStudyProgrammeSimpleListGUI" => "prgsimplelist",
117  "ilPDStudyProgrammeExpandableListGUI" => "prgexpandablelist",
118  "ilForumPostingDraftsBlockGUI" => "pdfrmpostdraft"
119  );
120 
121 
122  protected $default_blocks = array(
123  "cat" => array(
124  "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
125  "ilClassificationBlockGUI" => IL_COL_RIGHT
126  ),
127  "crs" => array(
128  "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
129  "ilCalendarBlockGUI" => IL_COL_RIGHT,
130  "ilClassificationBlockGUI" => IL_COL_RIGHT
131  ),
132  "grp" => array(
133  "ilNewsForContextBlockGUI" => IL_COL_RIGHT,
134  "ilCalendarBlockGUI" => IL_COL_RIGHT,
135  "ilClassificationBlockGUI" => IL_COL_RIGHT
136  ),
137  "frm" => array("ilNewsForContextBlockGUI" => IL_COL_RIGHT),
138  "root" => array(),
139  "info" => array(
140  "ilNewsForContextBlockGUI" => IL_COL_RIGHT),
141  "pd" => array(
142  "ilPDCalendarBlockGUI" => IL_COL_RIGHT,
143  "ilPDPortfolioBlockGUI" => IL_COL_RIGHT,
144  "ilPDSysMessageBlockGUI" => IL_COL_LEFT,
145  "ilPDNewsBlockGUI" => IL_COL_LEFT,
146  "ilPDStudyProgrammeSimpleListGUI" => IL_COL_CENTER,
147  "ilPDStudyProgrammeExpandableListGUI" => IL_COL_CENTER,
148  "ilPDSelectedItemsBlockGUI" => IL_COL_CENTER,
149  "ilPDMailBlockGUI" => IL_COL_RIGHT,
150  "ilPDNotesBlockGUI" => IL_COL_RIGHT,
151  "ilBookmarkBlockGUI" => IL_COL_RIGHT,
152  "ilPDTaggingBlockGUI" => IL_COL_RIGHT,
153  "ilChatroomBlockGUI" => IL_COL_RIGHT,
154  "ilForumPostingDraftsBlockGUI" => IL_COL_RIGHT
155  )
156  );
157 
158  // these are only for pd blocks
159  // other blocks are rep objects now
160  protected $custom_blocks = array(
161  "cat" => array(),
162  "crs" => array(),
163  "grp" => array(),
164  "frm" => array(),
165  "root" => array(),
166  "info" => array(),
167  "fold" => array(),
168  "pd" => array("ilPDExternalFeedBlockGUI")
169  );
170 
171  // check global activation for these block types
172  // @todo: add calendar
174  array("news" => true,
175  "cal" => true,
176  "pdcal" => true,
177  "pdnews" => true,
178  "pdfeed" => true,
179  "pdbookm" => true,
180  "pdtag" => true,
181  "pdsysmess" => true,
182  "pdnotes" => true,
183  "chatviewer" => true,
184  "pdfrmpostdraft" => true,
185  "tagcld" => true,
186  "pdportf" => true,
187  "clsfct" => true);
188 
189  protected $check_nr_limit =
190  array("pdfeed" => true);
191 
197  public function __construct($a_col_type = "", $a_side = "", $use_std_context = false)
198  {
199  global $DIC;
200 
201  $this->ctrl = $DIC->ctrl();
202  $this->lng = $DIC->language();
203  $this->user = $DIC->user();
204  $this->tpl = $DIC["tpl"];
205  $this->browser = $DIC["ilBrowser"];
206  $this->settings = $DIC->settings();
207  $this->setColType($a_col_type);
208  $this->setSide($a_side);
209  }
210 
221  public static function addCustomBlockLocation($className, $path)
222  {
223  self::$locations[$className] = $path;
224  }
225 
236  public static function addCustomBlockType($className, $identifier)
237  {
238  self::$block_types[$className] = $identifier;
239  }
240 
246  public static function getCmdSide()
247  {
248  return $_GET["col_side"];
249  }
250 
256  public function setColType($a_coltype)
257  {
258  $this->coltype = $a_coltype;
259  }
260 
266  public function getColType()
267  {
268  return $this->coltype;
269  }
270 
276  public function setSide($a_side)
277  {
278  $this->side = $a_side;
279  }
280 
286  public function getSide()
287  {
288  return $this->side;
289  }
290 
296  public function setEnableEdit($a_enableedit)
297  {
298  $this->enableedit = $a_enableedit;
299  }
300 
306  public function getEnableEdit()
307  {
308  return $this->enableedit;
309  }
310 
316  public function setRepositoryMode($a_repositorymode)
317  {
318  $this->repositorymode = $a_repositorymode;
319  }
320 
326  public function getRepositoryMode()
327  {
328  return $this->repositorymode;
329  }
330 
336  public function setAdminCommands($a_admincommands)
337  {
338  $this->admincommands = $a_admincommands;
339  }
340 
346  public function getAdminCommands()
347  {
348  return $this->admincommands;
349  }
350 
356  public function setMovementMode($a_movementmode)
357  {
358  $this->movementmode = $a_movementmode;
359  }
360 
366  public function getMovementMode()
367  {
368  return $this->movementmode;
369  }
370 
376  public function setEnableMovement($a_enablemovement)
377  {
378  $this->enablemovement = $a_enablemovement;
379  }
380 
386  public function getEnableMovement()
387  {
388  return $this->enablemovement;
389  }
390 
394  public static function getScreenMode()
395  {
396  global $DIC;
397 
398  $ilCtrl = $DIC->ctrl();
399 
400  if ($ilCtrl->getCmdClass() == "ilcolumngui") {
401  switch ($ilCtrl->getCmd()) {
402  case "addBlock":
403  return IL_SCREEN_CENTER;
404  }
405  }
406 
407  $cur_block_type = "";
408  if (isset($_GET["block_type"]) && $_GET["block_type"]) {
409  $cur_block_type = $_GET["block_type"];
410  } elseif (isset($_POST["block_type"])) {
411  $cur_block_type = $_POST["block_type"];
412  }
413 
414  if ($class = array_search($cur_block_type, self::$block_types)) {
415  include_once("./" . self::$locations[$class] . "classes/" .
416  "class." . $class . ".php");
417  return call_user_func(array($class, 'getScreenMode'));
418  }
419 
420  return IL_SCREEN_SIDE;
421  }
422 
430  public function setBlockProperty($a_block_type, $a_property, $a_value)
431  {
432  $this->block_property[$a_block_type][$a_property] = $a_value;
433  }
434 
435  public function getBlockProperties($a_block_type)
436  {
437  return $this->block_property[$a_block_type];
438  }
439 
440  public function setAllBlockProperties($a_block_properties)
441  {
442  $this->block_property = $a_block_properties;
443  }
444 
450  public function setRepositoryItems($a_repositoryitems)
451  {
452  $this->repositoryitems = $a_repositoryitems;
453  }
454 
460  public function getRepositoryItems()
461  {
462  return $this->repositoryitems;
463  }
464 
468  public function executeCommand()
469  {
471 
472  $ilCtrl->setParameter($this, "col_side", $this->getSide());
473  //$ilCtrl->saveParameter($this, "col_side");
474 
475  $next_class = $ilCtrl->getNextClass();
476  $cmd = $ilCtrl->getCmd("getHTML");
477 
478  $cur_block_type = ($_GET["block_type"])
479  ? $_GET["block_type"]
480  : $_POST["block_type"];
481 
482  if ($next_class != "") {
483  // forward to block
484  if ($gui_class = array_search($cur_block_type, self::$block_types)) {
485  include_once("./" . self::$locations[$gui_class] . "classes/" .
486  "class." . $gui_class . ".php");
487  $ilCtrl->setParameter($this, "block_type", $cur_block_type);
488  $block_gui = new $gui_class();
489  $block_gui->setProperties($this->block_property[$cur_block_type]);
490  $block_gui->setRepositoryMode($this->getRepositoryMode());
491  $block_gui->setEnableEdit($this->getEnableEdit());
492  $block_gui->setAdminCommands($this->getAdminCommands());
493 
494  if (in_array($gui_class, $this->custom_blocks[$this->getColType()]) ||
495  in_array($cur_block_type, $this->rep_block_types)) {
496  $block_class = substr($gui_class, 0, strlen($gui_class) - 3);
497  include_once("./" . self::$locations[$gui_class] . "classes/" .
498  "class." . $block_class . ".php");
499  $app_block = new $block_class($_GET["block_id"]);
500  $block_gui->setBlock($app_block);
501  }
502  $html = $ilCtrl->forwardCommand($block_gui);
503  $ilCtrl->setParameter($this, "block_type", "");
504 
505  return $html;
506  }
507  } else {
508  return $this->$cmd();
509  }
510  }
511 
515  public function getHTML()
516  {
518 
519  $ilCtrl->setParameter($this, "col_side", $this->getSide());
520 
521  $this->tpl = new ilTemplate("tpl.column.html", true, true, "Services/Block");
522 
523  $this->determineBlocks();
524  $this->showBlocks();
525 
526  if ($this->getEnableEdit() || !$this->getRepositoryMode()) {
527  $this->addHiddenBlockSelector();
528  }
529 
530  return $this->tpl->get();
531  }
532 
536  public function showBlocks()
537  {
539  $lng = $this->lng;
541 
542  $i = 1;
543  $sum_moveable = count($this->blocks[$this->getSide()]);
544 
545  foreach ($this->blocks[$this->getSide()] as $block) {
546  if ($ilCtrl->getContextObjType() != "user" ||
548  $block["type"],
549  $ilUser->getId(),
550  $block["id"]
551  ) > 0) {
552  $gui_class = $block["class"];
553  $block_class = substr($block["class"], 0, strlen($block["class"]) - 3);
554 
555  // get block gui class
556  include_once("./" . self::$locations[$gui_class] . "classes/" .
557  "class." . $gui_class . ".php");
558  $block_gui = new $gui_class();
559  if (isset($this->block_property[$block["type"]])) {
560  $block_gui->setProperties($this->block_property[$block["type"]]);
561  }
562  $block_gui->setRepositoryMode($this->getRepositoryMode());
563  $block_gui->setEnableEdit($this->getEnableEdit());
564  $block_gui->setAdminCommands($this->getAdminCommands());
565 
566  // get block for custom blocks
567  if ($block["custom"]) {
568  $path = "./" . self::$locations[$gui_class] . "classes/" .
569  "class." . $block_class . ".php";
570  if (file_exists($path)) {
571  include_once($path);
572  $app_block = new $block_class($block["id"]);
573  } else {
574  // we only need generic block
575  $app_block = new ilCustomBlock($block["id"]);
576  }
577  $block_gui->setBlock($app_block);
578  if (isset($block["ref_id"])) {
579  $block_gui->setRefId($block["ref_id"]);
580  }
581  }
582 
583  $ilCtrl->setParameter($this, "block_type", $block_gui->getBlockType());
584  $this->tpl->setCurrentBlock("col_block");
585 
586  $html = $ilCtrl->getHTML($block_gui);
587 
588  // dummy block, if non visible, but movement is ongoing
589  if ($html == "" && $this->getRepositoryMode() &&
590  $this->getMovementMode()) {
591  include_once("./Services/Block/classes/class.ilDummyBlockGUI.php");
592  $bl = new ilDummyBlockGUI();
593  $bl->setBlockId($block["id"]);
594  $bl->setBlockType($block["type"]);
595  $bl->setTitle($lng->txt("invisible_block"));
596  $bl->setConfigMode($this->getMovementMode());
597  $html = $bl->getHTML();
598  }
599 
600  // don't render a block if it's empty
601  if ($html != "") {
602  $this->tpl->setVariable("BLOCK", $html);
603  $this->tpl->parseCurrentBlock();
604  $ilCtrl->setParameter($this, "block_type", "");
605  }
606 
607  // count (moveable) blocks
608  if ($block["type"] != "pdsysmess" && $block["type"] != "pdfeedb" &&
609  $block["type"] != "news") {
610  $i++;
611  } else {
612  $sum_moveable--;
613  }
614  }
615  }
616  }
617 
621  public function addHiddenBlockSelector()
622  {
629  $lng = $this->lng;
632 
633  // show selector for hidden blocks
634  include_once("Services/Block/classes/class.ilBlockSetting.php");
635  $hidden_blocks = array();
636 
637  foreach ($this->blocks[$this->getSide()] as $block) {
638  include_once("./" . self::$locations[$block["class"]] . "classes/" .
639  "class." . $block["class"] . ".php");
640 
641  if ($block["custom"] == false) {
642  if ($ilCtrl->getContextObjType() == "user") { // personal desktop
643  if (ilBlockSetting::_lookupDetailLevel($block["type"], $ilUser->getId()) == 0) {
644  $hidden_blocks[$block["type"]] = $lng->txt('block_show_' . $block["type"]);
645  }
646  } elseif ($ilCtrl->getContextObjType() != "") {
648  $block["type"],
649  $ilUser->getId(),
650  $ilCtrl->getContextObjId()
651  ) == 0) {
652  $hidden_blocks[$block["type"] . "_" . $ilCtrl->getContextObjId()] = $lng->txt('block_show_' . $block["type"]);
653  }
654  }
655  } else {
657  $block["type"],
658  $ilUser->getId(),
659  $block["id"]
660  ) == 0) {
661  include_once("./Services/Block/classes/class.ilCustomBlock.php");
662  $cblock = new ilCustomBlock($block["id"]);
663  $hidden_blocks[$block["type"] . "_" . $block["id"]] = sprintf($lng->txt('block_show_x'), $cblock->getTitle());
664  }
665  }
666  }
667  if (count($hidden_blocks) > 0) {
668  foreach ($hidden_blocks as $id => $title) {
669  $ilCtrl->setParameter($this, 'block', $id);
670  $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'activateBlock'));
671  $ilCtrl->setParameter($this, 'block', '');
672  }
673  }
674 
675  // create block selection list
676  if (!$this->getRepositoryMode() || $this->getEnableEdit()) {
677  $add_blocks = array();
678  if ($this->getSide() == IL_COL_RIGHT) {
679  if (is_array($this->custom_blocks[$this->getColType()])) {
680  foreach ($this->custom_blocks[$this->getColType()] as $block_class) {
681  include_once("./" . self::$locations[$block_class] . "classes/" .
682  "class." . $block_class . ".php");
683  $block_gui = new $block_class();
684  $block_type = $block_gui->getBlockType();
685 
686  // check if block type is globally (de-)activated
687  if ($this->isGloballyActivated($block_type)) {
688  // check if number of blocks is limited
689  if (!$this->exceededLimit($block_type)) {
690  $add_blocks[$block_type] = $lng->txt('block_create_' . $block_type);
691  }
692  }
693  }
694  }
695  }
696  if (count($add_blocks) > 0) {
697  foreach ($add_blocks as $id => $title) {
698  $ilCtrl->setParameter($this, 'block_type', $id);
699  $this->action_menu->addItem($title, '', $ilCtrl->getLinkTarget($this, 'addBlock'));
700  $ilCtrl->setParameter($this, 'block_type', '');
701  }
702  }
703  }
704 
705  $this->addBlockSorting();
706  }
707 
711  protected function addBlockSorting()
712  {
713  global $DIC;
714 
715  if ($this->getSide() == IL_COL_CENTER && $this->getEnableMovement()) {
716  $ilBrowser = $this->browser;
717  $main_tpl = $DIC["tpl"];
719 
720  include_once 'Services/jQuery/classes/class.iljQueryUtil.php';
723 
724  if ($ilBrowser->isMobile() || $ilBrowser->isIpad()) {
725  $main_tpl->addJavaScript('./libs/bower/bower_components/jqueryui-touch-punch/jquery.ui.touch-punch.min.js');
726  }
727  $main_tpl->addJavaScript('./Services/Block/js/block_sorting.js');
728 
729  // set the col_side parameter to pass the ctrl structure flow
730  $ilCtrl->setParameter($this, 'col_side', IL_COL_CENTER);
731 
732  $this->tpl->setVariable('BLOCK_SORTING_STORAGE_URL', $ilCtrl->getLinkTarget($this, 'saveBlockSortingAsynch', '', true, false));
733  $this->tpl->setVariable('BLOCK_COLUMNS', json_encode(array('il_left_col', 'il_right_col')));
734  $this->tpl->setVariable('BLOCK_COLUMNS_SELECTOR', '#il_left_col,#il_right_col');
735  $this->tpl->setVariable('BLOCK_COLUMNS_PARAMETERS', json_encode(array(IL_COL_LEFT, IL_COL_RIGHT)));
736 
737  // restore col_side parameter
738  $ilCtrl->setParameter($this, 'col_side', $this->getSide());
739  }
740  }
741 
745  public function updateBlock()
746  {
748 
749  $this->determineBlocks();
750  $i = 1;
751  $sum_moveable = count($this->blocks[$this->getSide()]);
752 
753  foreach ($this->blocks[$this->getSide()] as $block) {
754  include_once("./" . self::$locations[$block["class"]] . "classes/" .
755  "class." . $block["class"] . ".php");
756 
757  // set block id to context obj id,
758  // if block is not a custom block and context is not personal desktop
759  if (!$block["custom"] && $ilCtrl->getContextObjType() != "" && $ilCtrl->getContextObjType() != "user") {
760  $block["id"] = $ilCtrl->getContextObjId();
761  }
762 
763  //if (is_int(strpos($_GET["block_id"], "block_".$block["type"]."_".$block["id"])))
764 
765  if ($_GET["block_id"] == "block_" . $block["type"] . "_" . $block["id"]) {
766  $gui_class = $block["class"];
767  $block_class = substr($block["class"], 0, strlen($block["class"]) - 3);
768 
769  $block_gui = new $gui_class();
770  $block_gui->setProperties($this->block_property[$block["type"]]);
771  $block_gui->setRepositoryMode($this->getRepositoryMode());
772  $block_gui->setEnableEdit($this->getEnableEdit());
773  $block_gui->setAdminCommands($this->getAdminCommands());
774 
775  // get block for custom blocks
776  if ($block["custom"]) {
777  include_once("./" . self::$locations[$gui_class] . "classes/" .
778  "class." . $block_class . ".php");
779  $app_block = new $block_class($block["id"]);
780  $block_gui->setBlock($app_block);
781  $block_gui->setRefId($block["ref_id"]);
782  }
783 
784  $ilCtrl->setParameter($this, "block_type", $block["type"]);
785  echo $ilCtrl->getHTML($block_gui);
786  exit;
787  }
788 
789  // count (moveable) blocks
790  if ($block["type"] != "pdsysmess" && $block["type"] != "pdfeedb"
791  && $block["type"] != "news") {
792  $i++;
793  } else {
794  $sum_moveable--;
795  }
796  }
797  echo "Error: ilColumnGUI::updateBlock: Block '" .
798  $_GET["block_id"] . "' unknown.";
799  exit;
800  }
801 
805  public function activateBlock()
806  {
809 
810  if ($_GET["block"] != "") {
811  $block = explode("_", $_GET["block"]);
812  include_once("Services/Block/classes/class.ilBlockSetting.php");
813  ilBlockSetting::_writeDetailLevel($block[0], 2, $ilUser->getId(), $block[1]);
814  }
815 
816  $ilCtrl->returnToParent($this);
817  }
818 
822  public function addBlock()
823  {
825 
826  $class = array_search($_GET["block_type"], self::$block_types);
827 
828  $ilCtrl->setCmdClass($class);
829  $ilCtrl->setCmd("create");
830  include_once("./" . self::$locations[$class] . "classes/class." . $class . ".php");
831  $block_gui = new $class();
832  $block_gui->setProperties($this->block_property[$_GET["block_type"]]);
833  $block_gui->setRepositoryMode($this->getRepositoryMode());
834  $block_gui->setEnableEdit($this->getEnableEdit());
835  $block_gui->setAdminCommands($this->getAdminCommands());
836 
837  $ilCtrl->setParameter($this, "block_type", $_GET["block_type"]);
838  $html = $ilCtrl->forwardCommand($block_gui);
839  $ilCtrl->setParameter($this, "block_type", "");
840  return $html;
841  }
842 
846  public function determineBlocks()
847  {
851 
852  include_once("./Services/Block/classes/class.ilBlockSetting.php");
853  $this->blocks[IL_COL_LEFT] = array();
854  $this->blocks[IL_COL_RIGHT] = array();
855  $this->blocks[IL_COL_CENTER] = array();
856 
857  $user_id = ($this->getColType() == "pd")
858  ? $ilUser->getId()
859  : 0;
860 
861  $def_nr = 1000;
862  if (is_array($this->default_blocks[$this->getColType()])) {
863  foreach ($this->default_blocks[$this->getColType()] as $class => $def_side) {
864  $type = self::$block_types[$class];
865 
866  if ($this->isGloballyActivated($type)) {
867  $nr = ilBlockSetting::_lookupNr($type, $user_id);
868  if ($nr === false) {
869  $nr = $def_nr++;
870  }
871 
872 
873  // extra handling for system messages, feedback block and news
874  if ($type == "news") { // always show news first
875  $nr = -15;
876  }
877  if ($type == "cal") {
878  $nr = -8;
879  }
880  if ($type == "pdsysmess") { // always show sys mess first
881 // $nr = -15;
882  }
883  if ($type == "pdfeedb") { // always show feedback request second
884  $nr = -10;
885  }
886  if ($type == "clsfct") { // mkunkel wants to have this on top
887  $nr = -16;
888  }
890  if ($side === false) {
891  $side = $def_side;
892  }
893 
894  $this->blocks[$side][] = array(
895  "nr" => $nr,
896  "class" => $class,
897  "type" => $type,
898  "id" => 0,
899  "custom" => false);
900  }
901  }
902  }
903 
904  if (!$this->getRepositoryMode()) {
905  include_once("./Services/Block/classes/class.ilCustomBlock.php");
906  $custom_block = new ilCustomBlock();
907  $custom_block->setContextObjId($ilCtrl->getContextObjId());
908  $custom_block->setContextObjType($ilCtrl->getContextObjType());
909  $c_blocks = $custom_block->queryBlocksForContext();
910 
911  foreach ($c_blocks as $c_block) {
912  $type = $c_block["type"];
913 
914  if ($this->isGloballyActivated($type)) {
915  $class = array_search($type, self::$block_types);
916  $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]);
917  if ($nr === false) {
918  $nr = $def_nr++;
919  }
920  $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
921  if ($side === false) {
923  }
924 
925  $this->blocks[$side][] = array(
926  "nr" => $nr,
927  "class" => $class,
928  "type" => $type,
929  "id" => $c_block["id"],
930  "custom" => true);
931  }
932  }
933  } else { // get all subitems
934  include_once("./Services/Block/classes/class.ilCustomBlock.php");
935  $rep_items = $this->getRepositoryItems();
936 
937  foreach ($this->rep_block_types as $block_type) {
938  if ($this->isGloballyActivated($block_type)) {
939  if (!is_array($rep_items[$block_type])) {
940  continue;
941  }
942  foreach ($rep_items[$block_type] as $item) {
943  $costum_block = new ilCustomBlock();
944  $costum_block->setContextObjId($item["obj_id"]);
945  $costum_block->setContextObjType($block_type);
946  $c_blocks = $costum_block->queryBlocksForContext();
947  $c_block = $c_blocks[0];
948 
949  $type = $block_type;
950  $class = array_search($type, self::$block_types);
951  $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]);
952  if ($nr === false) {
953  $nr = $def_nr++;
954  }
955  $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
956  if ($side === false) {
958  }
959 
960  $this->blocks[$side][] = array(
961  "nr" => $nr,
962  "class" => $class,
963  "type" => $type,
964  "id" => $c_block["id"],
965  "custom" => true,
966  "ref_id" => $item["ref_id"]);
967  }
968  }
969  }
970 
971  // repository object custom blocks
972  include_once("./Services/Block/classes/class.ilCustomBlock.php");
973  $custom_block = new ilCustomBlock();
974  $custom_block->setContextObjId($ilCtrl->getContextObjId());
975  $custom_block->setContextObjType($ilCtrl->getContextObjType());
976  $c_blocks = $custom_block->queryBlocksForContext(false); // get all sub-object types
977 
978  foreach ($c_blocks as $c_block) {
979  $type = $c_block["type"];
980  $class = array_search($type, self::$block_types);
981 
982  if ($class) {
983  $nr = $def_nr++;
985 
986  $this->blocks[$side][] = array(
987  "nr" => $nr,
988  "class" => $class,
989  "type" => $type,
990  "id" => $c_block["id"],
991  "custom" => true);
992  }
993  }
994  }
995 
996 
997  $this->blocks[IL_COL_LEFT] =
998  ilUtil::sortArray($this->blocks[IL_COL_LEFT], "nr", "asc", true);
999  $this->blocks[IL_COL_RIGHT] =
1000  ilUtil::sortArray($this->blocks[IL_COL_RIGHT], "nr", "asc", true);
1001  $this->blocks[IL_COL_CENTER] =
1002  ilUtil::sortArray($this->blocks[IL_COL_CENTER], "nr", "asc", true);
1003  }
1004 
1008  protected function isGloballyActivated($a_type)
1009  {
1011  $ilCtrl = $this->ctrl;
1012 
1013  if (isset($this->check_global_activation[$a_type]) && $this->check_global_activation[$a_type]) {
1014  if ($a_type == 'pdbookm') {
1015  if (!$ilSetting->get("disable_bookmarks")) {
1016  return true;
1017  }
1018  return false;
1019  } elseif ($a_type == 'pdnotes') {
1020  if (!$ilSetting->get("disable_notes")) {
1021  return true;
1022  }
1023  return false;
1024  } elseif ($a_type == 'pdportf') {
1025  if ($ilSetting->get("user_portfolios")) {
1026  $prfa_set = new ilSetting("prfa");
1027  if ($prfa_set->get("pd_block", false)) {
1028  return true;
1029  }
1030  }
1031  return false;
1032  } elseif ($a_type == 'news') {
1033  include_once 'Services/Container/classes/class.ilContainer.php';
1034  return
1035  $ilSetting->get('block_activated_news') &&
1037  $GLOBALS['ilCtrl']->getContextObjId(),
1038  'cont_show_news',
1039  true
1040  );
1041  } elseif ($a_type == 'pdsysmess') {
1042  require_once 'Services/Mail/classes/class.ilObjMail.php';
1043  return ((int) $ilSetting->get('pd_sys_msg_mode')) == ilObjMail::PD_SYS_MSG_OWN_BLOCK;
1044  } elseif ($ilSetting->get("block_activated_" . $a_type)) {
1045  return true;
1046  } elseif ($a_type == 'cal') {
1047  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
1048  return ilCalendarSettings::lookupCalendarActivated($GLOBALS['ilCtrl']->getContextObjId());
1049  } elseif ($a_type == 'pdcal') {
1050  include_once('./Services/Calendar/classes/class.ilCalendarSettings.php');
1051  return ilCalendarSettings::_getInstance()->isEnabled();
1052  } elseif ($a_type == "tagcld") {
1053  $tags_active = new ilSetting("tags");
1054  return (bool) $tags_active->get("enable", false);
1055  } elseif ($a_type == "clsfct") {
1056  if ($ilCtrl->getContextObjType() == "cat") { // taxonomy presentation in classification block
1057  return true;
1058  }
1059  $tags_active = new ilSetting("tags"); // tags presentation in classification block
1060  return (bool) $tags_active->get("enable", false);
1061  }
1062  return false;
1063  }
1064  return true;
1065  }
1066 
1070  protected function exceededLimit($a_type)
1071  {
1073  $ilCtrl = $this->ctrl;
1074 
1075  if ($this->check_nr_limit[$a_type]) {
1076  if (!$this->getRepositoryMode()) {
1077  include_once("./Services/Block/classes/class.ilCustomBlock.php");
1078  $costum_block = new ilCustomBlock();
1079  $costum_block->setContextObjId($ilCtrl->getContextObjId());
1080  $costum_block->setContextObjType($ilCtrl->getContextObjType());
1081  $costum_block->setType($a_type);
1082  $res = $costum_block->queryCntBlockForContext();
1083  $cnt = (int) $res[0]["cnt"];
1084  } else {
1085  return false; // not implemented for repository yet
1086  }
1087 
1088 
1089  if ($ilSetting->get("block_limit_" . $a_type) > $cnt) {
1090  return false;
1091  } else {
1092  return true;
1093  }
1094  }
1095  return false;
1096  }
1097 
1101  public function saveBlockSortingAsynch()
1102  {
1106  $ilUser = $this->user;
1107 
1108  $response = new stdClass();
1109  $response->success = false;
1110 
1111  if (!isset($_POST[IL_COL_LEFT]['sequence']) && !isset($_POST[IL_COL_RIGHT]['sequence'])) {
1112  echo json_encode($response);
1113  return;
1114  };
1115 
1116  if (in_array($this->getColType(), array('pd'))) {
1117  $response->success = true;
1118 
1119  foreach (array(IL_COL_LEFT => (array) $_POST[IL_COL_LEFT]['sequence'], IL_COL_RIGHT => (array) $_POST[IL_COL_RIGHT]['sequence']) as $side => $blocks) {
1120  $i = 2;
1121  foreach ($blocks as $block) {
1122  $bid = explode('_', $block);
1123  ilBlockSetting::_writeNumber($bid[1], $i, $ilUser->getId(), $bid[2]);
1124  ilBlockSetting::_writeSide($bid[1], $side, $ilUser->getId(), $bid[2]);
1125 
1126  $i += 2;
1127  }
1128  }
1129  }
1130 
1131  echo json_encode($response);
1132  exit();
1133  }
1134 
1139  public function setActionMenu($action_menu)
1140  {
1141  $this->action_menu = $action_menu;
1142  return $this;
1143  }
1144 
1148  public function getActionMenu()
1149  {
1150  return $this->action_menu;
1151  }
1152 }
__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
$path
Definition: aliased.php:25
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.
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.
global $DIC
Definition: saml.php:7
$_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)
static _lookupDetailLevel($a_type, $a_user=0, $a_block_id=0)
Lookup detail level.
if(!array_key_exists('StateId', $_REQUEST)) $id
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
const PD_SYS_MSG_OWN_BLOCK
$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.
special template class to simplify handling of ITX/PEAR
getSide()
Get Side IL_COL_LEFT | IL_COL_RIGHT.
getEnableEdit()
Get EnableEdit.
$ilUser
Definition: imgupload.php:18
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 initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
exit
Definition: backend.php:16
static getScreenMode()
Get Screen Mode for current command.
showBlocks()
Show blocks.
global $ilSetting
Definition: privfeed.php:17
updateBlock()
Update Block (asynchronous)
$i
Definition: disco.tpl.php:19
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
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"]
$html
Definition: example_001.php:87
setSide($a_side)
Set Side IL_COL_LEFT | IL_COL_RIGHT.
getColType()
Get Column Type.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
setEnableMovement($a_enablemovement)
Set Enable Movement.
determineBlocks()
Determine which blocks to show.
const IL_COL_LEFT