ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilPDSelectedItemsBlockGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("Services/Block/classes/class.ilBlockGUI.php");
6 include_once './Services/PersonalDesktop/interfaces/interface.ilDesktopItemHandling.php';
7 
18 {
22 
23  static $block_type = "pditems";
24 
25  private $view = self::VIEW_SELECTED_ITEMS;
26  private $allowed_views = array();
27 
31  public function __construct()
32  {
33  global $ilCtrl, $lng, $ilUser;
34 
35  parent::ilBlockGUI();
36 
37  $lng->loadLanguageModule('pd');
38  $lng->loadLanguageModule('cntr'); // #14158
39 
40  $this->setEnableNumInfo(false);
41  $this->setLimit(99999);
42 // $this->setColSpan(2);
43  $this->setAvailableDetailLevels(3, 1);
44 // $this->setBigMode(true);
45  $this->lng = $lng;
46  $this->allow_moving = false;
47 
48  $this->determineViewSettings();
49  }
50 
54  public function fillDetailRow()
55  {
59  global $ilCtrl;
60 
61  $ilCtrl->setParameterByClass('ilpersonaldesktopgui', 'view', $this->view);
62  parent::fillDetailRow();
63  $ilCtrl->setParameterByClass('ilpersonaldesktopgui', 'view', '');
64  }
65 
69  public function addToDeskObject()
70  {
71  global $ilCtrl, $lng;
72 
73  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
75  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
76  $ilCtrl->setParameterByClass('ilpersonaldesktopgui', 'view', $this->view);
77  $ilCtrl->redirectByClass('ilpersonaldesktopgui', 'show');
78  }
79 
83  public function removeFromDeskObject()
84  {
85  global $ilCtrl, $lng;
86 
87  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
89  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
90  $ilCtrl->setParameterByClass('ilpersonaldesktopgui', 'view', $this->view);
91  $ilCtrl->redirectByClass('ilpersonaldesktopgui', 'show');
92  }
93 
97  public function changeView()
98  {
102  global $ilCtrl;
103 
104  if(in_array((int)$_GET['view'], $this->allowed_views))
105  {
106  $view = (int)$_GET['view'];
107  }
108  else
109  {
110  reset($this->allowed_views);
111  $view = (int)current($this->allowed_views);
112  }
113 
114  $ilCtrl->setParameterByClass('ilpersonaldesktopgui', 'view', $view);
115  $ilCtrl->redirectByClass('ilpersonaldesktopgui', 'show');
116  }
117 
121  protected function determineViewSettings()
122  {
127  global $ilSetting, $ilCtrl;
128 
129  $this->allowed_views = array(self::VIEW_MY_STUDYPROGRAMME);
130 
131  // determine view
132  if($ilSetting->get('disable_my_offers') == 1 &&
133  $ilSetting->get('disable_my_memberships') == 1)
134  {
135  // if both views are disabled set default view (should not occur but we should prevent it)
136  $ilSetting->set('personal_items_default_view', self::VIEW_SELECTED_ITEMS);
137  $this->allowed_views[] = self::VIEW_SELECTED_ITEMS;
138  }
139  // both views are enabled, get default view
140  else if($ilSetting->get('disable_my_offers') == 0 &&
141  $ilSetting->get('disable_my_memberships') == 0)
142  {
143  $this->allowed_views[] = self::VIEW_SELECTED_ITEMS;
144  $this->allowed_views[] = self::VIEW_MY_MEMBERSHIPS;
145  }
146  else if($ilSetting->get('disable_my_offers') == 0 &&
147  $ilSetting->get('disable_my_memberships') == 1)
148  {
149  $this->allowed_views[] = self::VIEW_SELECTED_ITEMS;
150  }
151  else
152  {
153  $this->allowed_views[] = self::VIEW_MY_MEMBERSHIPS;
154  }
155 
156  $this->view = (int)$_GET['view'];
157  if(!in_array((int)$this->view, $this->allowed_views))
158  {
159  $_GET['view'] = $this->view = (int)$ilSetting->get('personal_items_default_view');
160  }
161 
162  $ilCtrl->saveParameter($this, 'view');
163  }
164 
170  static function getBlockType()
171  {
172  return self::$block_type;
173  }
174 
175  public static function getScreenMode()
176  {
177  $cmd = $_GET["cmd"];
178  if($cmd == "post")
179  {
180  $cmd = $_POST["cmd"];
181  $cmd = array_shift(array_keys($cmd));
182  }
183 
184  switch($cmd)
185  {
186  case "confirmRemove":
187  case "manage":
188  return IL_SCREEN_FULL;
189 
190  default:
191  return IL_SCREEN_SIDE;
192  }
193  }
194 
200  static function isRepositoryObject()
201  {
202  return false;
203  }
204 
205 
206  function getHTML()
207  {
208  global $ilCtrl, $ilSetting, $tpl, $lng, $ilHelp, $ilDB;
209 
210  $ilDB->useSlave(true);
211 
212  // workaround to show details row
213  $this->setData(array("dummy"));
214 
215  include_once "Services/Object/classes/class.ilObjectListGUI.php";
216  ilObjectListGUI::prepareJSLinks("",
217  $ilCtrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
218  $ilCtrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false));
219 
220  switch((int)$this->view)
221  {
222  case self::VIEW_MY_MEMBERSHIPS:
223  $ilHelp->setDefaultScreenId(ilHelpGUI::ID_PART_SCREEN, "crs_grp");
224  if ($ilSetting->get('disable_my_offers') == 0)
225  {
226  $tpl->setTitle($lng->txt("my_courses_groups"));
227  }
228  $this->setTitle($this->lng->txt('pd_my_memberships'));
229  $this->setContent($this->getMembershipItemsBlockHTML());
230  break;
231 
232  case self::VIEW_SELECTED_ITEMS:
233  default:
234  $ilHelp->setDefaultScreenId(ilHelpGUI::ID_PART_SCREEN, "sel_items");
235  if(!in_array(self::VIEW_MY_MEMBERSHIPS, $this->allowed_views))
236  {
237  $this->setTitle($this->lng->txt('selected_items'));
238  }
239  else
240  {
241  $this->setTitle($this->lng->txt('pd_my_offers'));
242  }
243 
244  $this->setContent($this->getSelectedItemsBlockHTML());
245  break;
246  }
247 
248  if ($this->getContent() == "")
249  {
250  $this->setEnableDetailRow(false);
251  }
252  $ilCtrl->clearParametersByClass("ilpersonaldesktopgui");
253  $ilCtrl->clearParameters($this);
254 
255  $ilDB->useSlave(false);
256 
257  return parent::getHTML();
258  }
259 
260  // Overwritten from ilBlockGUI as there seems to be no other possibility to
261  // not show Commands in the HEADER(!!!!) of a block in the VIEW_MY_STUDYPROGRAMME
262  // case... Sigh.
263  function getFooterLinks()
264  {
265  if((int)$this->view == self::VIEW_MY_STUDYPROGRAMME) {
266  return array();
267  }
268  return parent::getFooterLinks();
269  }
270 
274  function &executeCommand()
275  {
276  global $ilCtrl;
277 
278  $next_class = $ilCtrl->getNextClass();
279  $cmd = $ilCtrl->getCmd("getHTML");
280 
281  switch($next_class)
282  {
283  case "ilcommonactiondispatchergui":
284  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
286  $ilCtrl->forwardCommand($gui);
287  break;
288 
289  default:
290  if(method_exists($this, $cmd))
291  {
292  return $this->$cmd();
293  }
294  else
295  {
296  $cmd .= 'Object';
297  return $this->$cmd();
298  }
299  }
300  }
301 
302  function getContent()
303  {
304  return $this->content;
305  }
306 
307  function setContent($a_content)
308  {
309  $this->content = $a_content;
310  }
311 
315  function fillDataSection()
316  {
317  global $ilUser;
318 
319  if ($this->getContent() != "")
320  {
321  $this->tpl->setVariable("BLOCK_ROW", $this->getContent());
322  }
323  else
324  {
325  $this->setDataSection($this->getIntroduction());
326  }
327  }
328 
329 
333  function fillFooter()
334  {
335  global $ilCtrl, $lng, $ilUser;
336 
337  $this->setFooterLinks();
338  $this->fillFooterLinks();
339  $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
340  if ($this->tpl->blockExists("block_footer"))
341  {
342  $this->tpl->setCurrentBlock("block_footer");
343  $this->tpl->parseCurrentBlock();
344  }
345  }
346 
350  function setFooterLinks()
351  {
352  global $ilUser, $ilCtrl, $lng;
353 
354  if ($this->getContent() == "")
355  {
356  $this->setEnableNumInfo(false);
357  return "";
358  }
359 
360  if ($this->manage)
361  {
362  return;
363  }
364 
365  // by type
366 // if ($ilUser->getPref("pd_order_items") == 'location')
367 // {
368  $this->addFooterLink( $lng->txt("by_type"),
369  $ilCtrl->getLinkTarget($this, "orderPDItemsByType"),
370  $ilCtrl->getLinkTarget($this, "orderPDItemsByType", "", true),
371  "block_".$this->getBlockType()."_".$this->block_id,
372  false, false, ($ilUser->getPref("pd_order_items") != 'location')
373  );
374 // }
375 // else
376 // {
377 // $this->addFooterLink($lng->txt("by_type"));
378 // }
379 
380 // // by location
381 // if ($ilUser->getPref("pd_order_items") == 'location')
382 // {
383 // $this->addFooterLink($lng->txt("by_location"));
384 // }
385 // else
386 // {
387  $this->addFooterLink( $lng->txt("by_location"),
388  $ilCtrl->getLinkTarget($this, "orderPDItemsByLocation"),
389  $ilCtrl->getLinkTarget($this, "orderPDItemsByLocation", "", true),
390  "block_".$this->getBlockType()."_".$this->block_id,
391  false, false, ($ilUser->getPref("pd_order_items") == 'location')
392  );
393 // }
394 
395  $this->addFooterLink(($this->view == self::VIEW_SELECTED_ITEMS) ?
396  $lng->txt("pd_remove_multiple") :
397  $lng->txt("pd_unsubscribe_multiple_memberships"),
398  $ilCtrl->getLinkTarget($this, "manage"),
399  null,
400  "block_".$this->getBlockType()."_".$this->block_id
401  );
402  }
403 
410  protected function getObjectsByMembership($types = array())
411  {
412  global $tree, $ilUser, $ilObjDataCache;
413 
414  include_once 'Services/Membership/classes/class.ilParticipants.php';
415  $items = array();
416 
417  if(is_array($types) && count($types))
418  {
419  foreach($types as $type)
420  {
421  switch($type)
422  {
423  case 'grp':
424  $items = array_merge(ilParticipants::_getMembershipByType($ilUser->getId(), 'grp'), $items);
425  break;
426  case 'crs':
427  $items = array_merge(ilParticipants::_getMembershipByType($ilUser->getId(), 'crs'), $items);
428  break;
429  default:
430  break;
431  }
432  }
433  }
434  else
435  {
436  $crs_mbs = ilParticipants::_getMembershipByType($ilUser->getId(), 'crs');
437  $grp_mbs = ilParticipants::_getMembershipByType($ilUser->getId(), 'grp');
438  $items = array_merge($crs_mbs, $grp_mbs);
439  }
440 
441  $references = array();
442  foreach($items as $key => $obj_id)
443  {
444  $item_references = ilObject::_getAllReferences($obj_id);
445  foreach($item_references as $ref_id)
446  {
447  if($tree->isInTree($ref_id))
448  {
449  $title = $ilObjDataCache->lookupTitle($obj_id);
450  $type = $ilObjDataCache->lookupType($obj_id);
451 
452  $parent_ref_id = $tree->getParentId($ref_id);
453  $par_left = $tree->getLeftValue($parent_ref_id);
454  $par_left = sprintf("%010d", $par_left);
455 
456  $references[$par_left . $title . $ref_id] = array(
457  'ref_id' => $ref_id,
458  'obj_id' => $obj_id,
459  'type' => $type,
460  'title' => $title,
461  'description' => $ilObjDataCache->lookupDescription($obj_id),
462  'parent_ref' => $parent_ref_id
463  );
464  }
465  }
466  }
467  ksort($references);
468  return is_array($references) ? $references : array();
469  }
470 
478  {
479  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache, $rbacreview;
480 
481  $output = false;
482  $items = $this->getObjectsByMembership();
483  $item_html = array();
484  if(count($items) > 0)
485  {
486  include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
488  foreach($items as $item)
489  {
490  $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
491  }
492  $preloader->preload();
493  unset($preloader);
494 
495  reset($items);
496  foreach($items as $item)
497  {
498  //echo "1";
499  // get list gui class for each object type
500  if ($cur_obj_type != $item["type"])
501  {
502  $item_list_gui =& $this->getItemListGUI($item["type"]);
503  if(!$item_list_gui)
504  {
505  continue;
506  }
507 
508  // notes, comment currently do not work properly
509  $item_list_gui->enableNotes(false);
510  $item_list_gui->enableComments(false);
511  $item_list_gui->enableTags(false);
512 
513  $item_list_gui->enableIcon(true);
514  $item_list_gui->enableDelete(false);
515  $item_list_gui->enableCut(false);
516  $item_list_gui->enableCopy(false);
517  $item_list_gui->enablePayment(false);
518  $item_list_gui->enableLink(false);
519  $item_list_gui->enableInfoScreen(true);
520  if ($ilSetting->get('disable_my_offers') == 1)
521  {
522  $item_list_gui->enableSubscribe(false);
523  }
524  else
525  {
526  $item_list_gui->enableSubscribe(true);
527  }
528  $item_list_gui->setContainerObject($this);
529  if ($this->getCurrentDetailLevel() < 3 || $this->manage)
530  {
531  //echo "3";
532  $item_list_gui->enableDescription(false);
533  $item_list_gui->enableProperties(false);
534  $item_list_gui->enablePreconditions(false);
535  }
536  if ($this->getCurrentDetailLevel() < 2 || $this->manage)
537  {
538  $item_list_gui->enableCommands(true, true);
539  }
540  }
541  // render item row
542  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
543 
544  if (is_object($item_list_gui))
545  {
546  ilObjectActivation::addListGUIActivationProperty($item_list_gui, $item);
547 
548  // #15232
549  if($this->manage)
550  {
551  if(!$rbacsystem->checkAccess("leave", $item["ref_id"]))
552  {
553  $item_list_gui->enableCheckbox(false);
554  }
555  else
556  {
557  $item_list_gui->enableCheckbox(true);
558  }
559  }
560 
561  $html = $item_list_gui->getListItemHTML($item["ref_id"],
562  $item["obj_id"], $item["title"], $item["description"]);
563  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
564  if ($html != "")
565  {
566  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
567  $item_html[] = array(
568  "html" => $html,
569  "item_ref_id" => $item["ref_id"],
570  "item_obj_id" => $item["obj_id"],
571  "parent_ref" => $item["parent_ref"],
572  "type" => $item["type"],
573  'item_icon_image_type' => $item_list_gui->getIconImageType()
574  );
575  // END WebDAV: Use $item_list_gui to determine icon image type
576  }
577  }
578  }
579 
580  // output block for resource type
581  if (count($item_html) > 0)
582  {
583  $cur_parent_ref = 0;
584 
585  // content row
586  foreach($item_html as $item)
587  {
588  // add a parent header row for each new parent
589  if ($cur_parent_ref != $item["parent_ref"])
590  {
591  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
592  {
593  $this->addParentRow($tpl, $item["parent_ref"], false);
594  }
595  else
596  {
597  $this->addParentRow($tpl, $item["parent_ref"]);
598  }
599  $this->resetRowType();
600  $cur_parent_ref = $item["parent_ref"];
601  }
602 
603  // BEGIN WebDAV: Use $item_list_gui to determine icon image type.
604  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
605  $item['item_icon_image_type'],
606  "th_".$cur_parent_ref);
607  // END WebDAV: Use $item_list_gui to determine icon image type.
608  $output = true;
609  }
610  }
611  }
612 
613  return $output;
614  }
615 
623  {
624  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache;
625 
626  $output = false;
627 
628  $objtype_groups = $objDefinition->getGroupedRepositoryObjectTypes(
629  array("cat", "crs", "grp", "fold"));
630 
631  $types = array();
632  foreach($objtype_groups as $grp => $grpdata)
633  {
634  $types[] = array(
635  "grp" => $grp,
636  "title" => $this->lng->txt("objs_".$grp),
637  "types" => $grpdata["objs"]);
638  }
639 
640  include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
641 
642  foreach ($types as $t)
643  {
644  $type = $t["types"];
645  $title = $t["title"];
646  $grp = $t["grp"];
647 
648  $items = $this->getObjectsByMembership($type);
649 
650  if (count($items) > 0)
651  {
653  foreach($items as $item)
654  {
655  $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
656  }
657  $preloader->preload();
658  unset($preloader);
659 
660  reset($items);
661 
662 
663  $item_html = array();
664 
665  if ($this->getCurrentDetailLevel() == 3)
666  {
667  $rel_header = "th_".$grp;
668  }
669 
670  $tstCount = 0;
671  $unsetCount = 0;
672  $progressCount = 0;
673  $unsetFlag = 0;
674  $progressFlag = 0;
675  $completedFlag = 0;
676  if (strcmp($a_type, "tst") == 0) {
677  $items = $this->multiarray_sort($items, "used_tries; title");
678  foreach ($items as $tst_item) {
679  if (!isset($tst_item["used_tries"])) {
680  $unsetCount++;
681  }
682  elseif ($tst_item["used_tries"] == 0) {
683  $progressCount++;
684  }
685  }
686  }
687 
688  foreach($items as $item)
689  {
690  // get list gui class for each object type
691  if ($cur_obj_type != $item["type"])
692  {
693  $class = $objDefinition->getClassName($item["type"]);
694  $location = $objDefinition->getLocation($item["type"]);
695  $full_class = "ilObj".$class."ListGUI";
696  include_once($location."/class.".$full_class.".php");
697  $item_list_gui = new $full_class();
698 
699  // notes, comment currently do not work properly
700  $item_list_gui->enableNotes(false);
701  $item_list_gui->enableComments(false);
702  $item_list_gui->enableTags(false);
703 
704  $item_list_gui->enableIcon(true);
705  $item_list_gui->enableDelete(false);
706  $item_list_gui->enableCut(false);
707  $item_list_gui->enableCopy(false);
708  $item_list_gui->enablePayment(false);
709  $item_list_gui->enableLink(false);
710  $item_list_gui->enableInfoScreen(true);
711  if ($ilSetting->get('disable_my_offers') == 1)
712  {
713  $item_list_gui->enableSubscribe(false);
714  }
715  else
716  {
717  $item_list_gui->enableSubscribe(true);
718  }
719 
720  $item_list_gui->setContainerObject($this);
721  if ($this->manage)
722  {
723  $item_list_gui->enableCheckbox(true);
724  }
725  if ($this->getCurrentDetailLevel() < 3 || $this->manage)
726  {
727  $item_list_gui->enableDescription(false);
728  $item_list_gui->enableProperties(false);
729  $item_list_gui->enablePreconditions(false);
730  $item_list_gui->enableNoticeProperties(false);
731  }
732  if ($this->getCurrentDetailLevel() < 2 || $this->manage)
733  {
734  $item_list_gui->enableCommands(true, true);
735  }
736  }
737  // render item row
738  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
739 
740  ilObjectActivation::addListGUIActivationProperty($item_list_gui, $item);
741 
742  // #15232
743  if($this->manage)
744  {
745  if(!$rbacsystem->checkAccess("leave", $item["ref_id"]))
746  {
747  $item_list_gui->enableCheckbox(false);
748  }
749  else
750  {
751  $item_list_gui->enableCheckbox(true);
752  }
753  }
754 
755  $html = $item_list_gui->getListItemHTML($item["ref_id"],
756  $item["obj_id"], $item["title"], $item["description"]);
757  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
758  if ($html != "")
759  {
760  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
761  $item_html[] = array(
762  "html" => $html,
763  "item_ref_id" => $item["ref_id"],
764  "item_obj_id" => $item["obj_id"],
765  'item_icon_image_type' => (method_exists($item_list_gui, 'getIconImageType')) ?
766  $item_list_gui->getIconImageType() :
767  $item['type']
768  );
769  // END WebDAV: Use $item_list_gui to determine icon image type
770  }
771  }
772 
773  // output block for resource type
774  if (count($item_html) > 0)
775  {
776  // add a header for each resource type
777  if ($this->getCurrentDetailLevel() == 3)
778  {
779  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
780  {
781  $this->addHeaderRow($tpl, $grp, false);
782  }
783  else
784  {
785  $this->addHeaderRow($tpl, $grp);
786  }
787  $this->resetRowType();
788  }
789 
790  // content row
791  foreach($item_html as $item)
792  {
793  if ($this->getCurrentDetailLevel() < 3 ||
794  $ilSetting->get("icon_position_in_lists") == "item_rows")
795  {
796  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
797  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
798  $item['item_icon_image_type'],
799  $rel_header);
800  // END WebDAV: Use $item_list_gui to determine icon image type
801  }
802  else
803  {
804  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], "", $rel_header);
805  }
806  $output = true;
807  }
808  }
809  }
810  }
811 
812  return $output;
813  }
814 
821  public function getMembershipItemsBlockHTML()
822  {
823  global $ilUser;
824 
825  $tpl = $this->newBlockTemplate();
826 
827  switch($ilUser->getPref('pd_order_items'))
828  {
829  case 'location':
831  break;
832 
833  default:
835  break;
836  }
837 
838  return $tpl->get();
839  }
840 
845  {
846  global $ilUser, $rbacsystem, $objDefinition, $ilBench;
847 
848  $tpl =& $this->newBlockTemplate();
849 
850  switch ($ilUser->getPref("pd_order_items"))
851  {
852  case "location":
854  break;
855 
856  default:
857  $ok = $this->getSelectedItemsPerType($tpl);
858  break;
859  }
860 
861  if($this->manage)
862  {
863  // #11355 - see ContainerContentGUI::renderSelectAllBlock()
864  $tpl->setCurrentBlock("select_all_row");
865  $tpl->setVariable("CHECKBOXNAME", "ilToolbarSelectAll");
866  $tpl->setVariable("SEL_ALL_PARENT", "ilToolbar");
867  $tpl->setVariable("SEL_ALL_CB_NAME", "id");
868  $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
869  $tpl->parseCurrentBlock();
870  }
871 
872  return $tpl->get();
873  }
874 
879  {
880  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache, $tree, $ilCtrl;
881 
882  $items = $ilUser->getDesktopItems();
883  if (count($items) > 0)
884  {
885  include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
887  foreach($items as $item)
888  {
889  $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
890  }
891  $preloader->preload();
892  unset($preloader);
893 
894  reset($items);
895  }
896 
897  $output = false;
898 
899  $objtype_groups = $objDefinition->getGroupedRepositoryObjectTypes(
900  array("cat", "crs", "grp", "fold"));
901 
902  $types = array();
903  foreach($objtype_groups as $grp => $grpdata)
904  {
905  $types[] = array(
906  "grp" => $grp,
907  "title" => $this->lng->txt("objs_".$grp),
908  "types" => $grpdata["objs"]);
909  }
910 
911  foreach ($types as $t)
912  {
913 
914  $type = $t["types"];
915  $title = $t["title"];
916  $grp = $t["grp"];
917 
918  $items = $ilUser->getDesktopItems($type);
919  $item_html = array();
920 
921  if ($this->getCurrentDetailLevel() == 3)
922  {
923  $rel_header = "th_".$grp;
924  }
925 
926  if (count($items) > 0)
927  {
928  $tstCount = 0;
929  $unsetCount = 0;
930  $progressCount = 0;
931  $unsetFlag = 0;
932  $progressFlag = 0;
933  $completedFlag = 0;
934  if (strcmp($a_type, "tst") == 0) {
935  $items = $this->multiarray_sort($items, "used_tries; title");
936  foreach ($items as $tst_item) {
937  if (!isset($tst_item["used_tries"])) {
938  $unsetCount++;
939  }
940  elseif ($tst_item["used_tries"] == 0) {
941  $progressCount++;
942  }
943  }
944  }
945 
946  foreach($items as $item)
947  {
948  // get list gui class for each object type
949  if ($cur_obj_type != $item["type"])
950  {
951  $class = $objDefinition->getClassName($item["type"]);
952  $location = $objDefinition->getLocation($item["type"]);
953  $full_class = "ilObj".$class."ListGUI";
954  include_once($location."/class.".$full_class.".php");
955  $item_list_gui = new $full_class();
956 
957  // notes, comment currently do not work properly
958  $item_list_gui->enableNotes(false);
959  $item_list_gui->enableComments(false);
960  $item_list_gui->enableTags(false);
961 
962  $item_list_gui->enableIcon(true);
963  $item_list_gui->enableDelete(false);
964  $item_list_gui->enableCut(false);
965  $item_list_gui->enableCopy(false);
966  $item_list_gui->enablePayment(false);
967  $item_list_gui->enableLink(false);
968  $item_list_gui->enableInfoScreen(true);
969  $item_list_gui->setContainerObject($this);
970 
971  if ($this->manage)
972  {
973  $item_list_gui->enableCheckbox(true);
974  }
975 
976  if ($this->getCurrentDetailLevel() < 3 || $this->manage)
977  {
978  $item_list_gui->enableDescription(false);
979  $item_list_gui->enableProperties(false);
980  $item_list_gui->enablePreconditions(false);
981  $item_list_gui->enableNoticeProperties(false);
982  }
983  if ($this->getCurrentDetailLevel() < 2 || $this->manage)
984  {
985  $item_list_gui->enableCommands(true, true);
986  }
987  }
988  // render item row
989  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
990 
991  include_once './Services/Object/classes/class.ilObjectActivation.php';
992  ilObjectActivation::addListGUIActivationProperty($item_list_gui, $item);
993 
994  $html = $item_list_gui->getListItemHTML($item["ref_id"],
995  $item["obj_id"], $item["title"], $item["description"]);
996  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
997  if ($html != "")
998  {
999  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
1000  $item_html[] = array(
1001  "html" => $html,
1002  "item_ref_id" => $item["ref_id"],
1003  "item_obj_id" => $item["obj_id"],
1004  'item_icon_image_type' => (method_exists($item_list_gui, 'getIconImageType')) ?
1005  $item_list_gui->getIconImageType() :
1006  $item['type']
1007  );
1008  // END WebDAV: Use $item_list_gui to determine icon image type
1009  }
1010  }
1011 
1012  // output block for resource type
1013  if (count($item_html) > 0)
1014  {
1015  // add a header for each resource type
1016  if ($this->getCurrentDetailLevel() == 3)
1017  {
1018  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
1019  {
1020  $this->addHeaderRow($tpl, $grp, false);
1021  }
1022  else
1023  {
1024  $this->addHeaderRow($tpl, $grp);
1025  }
1026  $this->resetRowType();
1027  }
1028 
1029  // content row
1030  foreach($item_html as $item)
1031  {
1032  if ($this->getCurrentDetailLevel() < 3 ||
1033  $ilSetting->get("icon_position_in_lists") == "item_rows")
1034  {
1035  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
1036  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
1037  $item['item_icon_image_type'],
1038  $rel_header);
1039  // END WebDAV: Use $item_list_gui to determine icon image type
1040  }
1041  else
1042  {
1043  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], "", $rel_header);
1044  }
1045  $output = true;
1046  }
1047  }
1048  }
1049  }
1050 
1051  return $output;
1052  }
1053 
1058  {
1059  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache, $tree;
1060 
1061  $output = false;
1062 
1063  $items = $ilUser->getDesktopItems();
1064  $item_html = array();
1065  $cur_obj_type = "";
1066 
1067  if (count($items) > 0)
1068  {
1069  include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
1071  foreach($items as $item)
1072  {
1073  $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
1074  }
1075  $preloader->preload();
1076  unset($preloader);
1077 
1078  reset($items);
1079  foreach($items as $item)
1080  {
1081  //echo "1";
1082  // get list gui class for each object type
1083  if ($cur_obj_type != $item["type"])
1084  {
1085  $item_list_gui =& $this->getItemListGUI($item["type"]);
1086  if(!$item_list_gui)
1087  {
1088  continue;
1089  }
1090 
1091  // notes, comment currently do not work properly
1092  $item_list_gui->enableNotes(false);
1093  $item_list_gui->enableComments(false);
1094  $item_list_gui->enableTags(false);
1095 
1096  $item_list_gui->enableIcon(true);
1097  $item_list_gui->enableDelete(false);
1098  $item_list_gui->enableCut(false);
1099  $item_list_gui->enableCopy(false);
1100  $item_list_gui->enablePayment(false);
1101  $item_list_gui->enableLink(false);
1102  $item_list_gui->enableInfoScreen(true);
1103  if ($this->getCurrentDetailLevel() < 3 || $this->manage)
1104  {
1105  //echo "3";
1106  $item_list_gui->enableDescription(false);
1107  $item_list_gui->enableProperties(false);
1108  $item_list_gui->enablePreconditions(false);
1109  }
1110  if ($this->getCurrentDetailLevel() < 2 || $this->manage)
1111  {
1112  $item_list_gui->enableCommands(true, true);
1113  }
1114  }
1115  // render item row
1116  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
1117 
1118  ilObjectActivation::addListGUIActivationProperty($item_list_gui, $item);
1119 
1120  $item_list_gui->setContainerObject($this);
1121  $html = $item_list_gui->getListItemHTML($item["ref_id"],
1122  $item["obj_id"], $item["title"], $item["description"]);
1123  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
1124  if ($html != "")
1125  {
1126  $item_html[] = array(
1127  "html" => $html,
1128  "item_ref_id" => $item["ref_id"],
1129  "item_obj_id" => $item["obj_id"],
1130  "parent_ref" => $item["parent_ref"],
1131  "type" => $item["type"],
1132  'item_icon_image_type' => $item_list_gui->getIconImageType()
1133  );
1134  }
1135  }
1136 
1137  // output block for resource type
1138  if (count($item_html) > 0)
1139  {
1140  $cur_parent_ref = 0;
1141 
1142  // content row
1143  foreach($item_html as $item)
1144  {
1145  // add a parent header row for each new parent
1146  if ($cur_parent_ref != $item["parent_ref"])
1147  {
1148  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
1149  {
1150  $this->addParentRow($tpl, $item["parent_ref"], false);
1151  }
1152  else
1153  {
1154  $this->addParentRow($tpl, $item["parent_ref"]);
1155  }
1156  $this->resetRowType();
1157  $cur_parent_ref = $item["parent_ref"];
1158  }
1159 
1160  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
1161  $item['item_icon_image_type'],
1162  "th_".$cur_parent_ref);
1163  $output = true;
1164  }
1165  }
1166  }
1167 
1168  return $output;
1169  }
1170 
1171  function resetRowType()
1172  {
1173  $this->cur_row_type = "";
1174  }
1175 
1182  function &newBlockTemplate()
1183  {
1184  $tpl = new ilTemplate("tpl.pd_list_block.html", true, true, "Services/PersonalDesktop");
1185  $this->cur_row_type = "";
1186  return $tpl;
1187  }
1188 
1192  function &getItemListGUI($a_type)
1193  {
1194  global $objDefinition;
1195  //echo "<br>+$a_type+";
1196  if (!isset($this->item_list_guis[$a_type]))
1197  {
1198  $class = $objDefinition->getClassName($a_type);
1199  // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
1200  if(!$class)
1201  {
1202  return NULL;
1203  }
1204  // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
1205  $location = $objDefinition->getLocation($a_type);
1206  if(!$location)
1207  {
1208  return NULL;
1209  }
1210 
1211  $full_class = "ilObj".$class."ListGUI";
1212  //echo "<br>-".$location."/class.".$full_class.".php"."-";
1213  include_once($location."/class.".$full_class.".php");
1214  $item_list_gui = new $full_class();
1215  $this->item_list_guis[$a_type] =& $item_list_gui;
1216  }
1217  else
1218  {
1219  $item_list_gui =& $this->item_list_guis[$a_type];
1220  }
1221 
1222  if ($this->manage)
1223  {
1224  $item_list_gui->enableCheckbox(true);
1225  }
1226 
1227 
1228  return $item_list_gui;
1229  }
1230 
1238  function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
1239  {
1240  global $objDefinition;
1241 
1242  $icon = ilUtil::getImagePath("icon_".$a_type.".svg");
1243  if (!$objDefinition->isPlugin($a_type))
1244  {
1245  $title = $this->lng->txt("objs_".$a_type);
1246  }
1247  else
1248  {
1249  include_once("./Services/Component/classes/class.ilPlugin.php");
1250  $title =
1251  ilPlugin::lookupTxt("rep_robj", $a_type, "objs_".$a_type);
1252 
1253  }
1254  $header_id = "th_".$a_type;
1255 
1256  if ($a_show_image)
1257  {
1258  $a_tpl->setCurrentBlock("container_header_row_image");
1259  $a_tpl->setVariable("HEADER_IMG", $icon);
1260  $a_tpl->setVariable("HEADER_ALT", $title);
1261  }
1262  else
1263  {
1264  $a_tpl->setCurrentBlock("container_header_row");
1265  }
1266 
1267  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1268  $a_tpl->setVariable("BLOCK_HEADER_ID", $header_id);
1269  $a_tpl->parseCurrentBlock();
1270  $a_tpl->touchBlock("container_row");
1271  }
1272 
1280  function addParentRow(&$a_tpl, $a_ref_id, $a_show_image = true)
1281  {
1282  global $tree, $ilSetting;
1283 
1284  $par_id = ilObject::_lookupObjId($a_ref_id);
1285  $type = ilObject::_lookupType($par_id);
1286  if (!in_array($type, array("lm", "dbk", "sahs", "htlm")))
1287  {
1288  $icon = ilUtil::getImagePath("icon_".$type.".svg");
1289  }
1290  else
1291  {
1292  $icon = ilUtil::getImagePath("icon_lm.svg");
1293  }
1294 
1295  // custom icon
1296  if ($ilSetting->get("custom_icons") &&
1297  in_array($type, array("cat","grp","crs", "root")))
1298  {
1299  require_once("./Services/Container/classes/class.ilContainer.php");
1300  if (($path = ilContainer::_lookupIconPath($par_id, "small")) != "")
1301  {
1302  $icon = $path;
1303  }
1304  }
1305 
1306  if ($tree->getRootId() != $par_id)
1307  {
1308  $title = ilObject::_lookupTitle($par_id);
1309  }
1310  else
1311  {
1312  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
1313  $title = $nd["title"];
1314  if ($title == "ILIAS")
1315  {
1316  $title = $this->lng->txt("repository");
1317  }
1318  }
1319 
1320 /*
1321  $item_list_gui =& $this->getItemListGUI($type);
1322 
1323  $item_list_gui->enableIcon(false);
1324  $item_list_gui->enableDelete(false);
1325  $item_list_gui->enableCut(false);
1326  $item_list_gui->enablePayment(false);
1327  $item_list_gui->enableLink(false);
1328  $item_list_gui->enableDescription(false);
1329  $item_list_gui->enableProperties(false);
1330  $item_list_gui->enablePreconditions(false);
1331  $item_list_gui->enablePath(true);
1332  $item_list_gui->enableCommands(false);
1333  $html = $item_list_gui->getListItemHTML($a_ref_id,
1334  $par_id, $title, "");
1335 
1336  if ($a_show_image)
1337  {
1338  $a_tpl->setCurrentBlock("container_header_row_image");
1339  $a_tpl->setVariable("HEADER_IMG", $icon);
1340  $a_tpl->setVariable("HEADER_ALT", $title);
1341  }
1342 */
1343 // else
1344 // {
1345  $a_tpl->setCurrentBlock("container_header_row");
1346 // }
1347 
1348  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1349 /* $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $html);
1350  $a_tpl->setVariable("BLOCK_HEADER_ID", "th_".$a_ref_id);*/
1351  $a_tpl->parseCurrentBlock();
1352  $a_tpl->touchBlock("container_row");
1353  }
1354 
1362  function addStandardRow(&$a_tpl, $a_html, $a_item_ref_id = "", $a_item_obj_id = "",
1363  $a_image_type = "", $a_related_header = "")
1364  {
1365  global $ilSetting;
1366 
1367  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1368  ? "row_type_2"
1369  : "row_type_1";
1370  $a_tpl->touchBlock($this->cur_row_type);
1371 
1372  if ($a_image_type != "")
1373  {
1374  if (!is_array($a_image_type) && !in_array($a_image_type, array("lm", "dbk", "htlm", "sahs")))
1375  {
1376  $icon = ilUtil::getImagePath("icon_".$a_image_type.".svg");
1377  $title = $this->lng->txt("obj_".$a_image_type);
1378  }
1379  else
1380  {
1381  $icon = ilUtil::getImagePath("icon_lm.svg");
1382  $title = $this->lng->txt("learning_resource");
1383  }
1384 
1385  // custom icon
1386  if ($ilSetting->get("custom_icons") &&
1387  in_array($a_image_type, array("cat","grp","crs")))
1388  {
1389  require_once("./Services/Container/classes/class.ilContainer.php");
1390  if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "")
1391  {
1392  $icon = $path;
1393  }
1394  }
1395 
1396  $a_tpl->setCurrentBlock("block_row_image");
1397  $a_tpl->setVariable("ROW_IMG", $icon);
1398  $a_tpl->setVariable("ROW_ALT", $title);
1399  $a_tpl->parseCurrentBlock();
1400  }
1401  else
1402  {
1403  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1404  }
1405  $a_tpl->setCurrentBlock("container_standard_row");
1406  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
1407  $rel_headers = ($a_related_header != "")
1408  ? "th_selected_items ".$a_related_header
1409  : "th_selected_items";
1410  $a_tpl->setVariable("BLOCK_ROW_HEADERS", $rel_headers);
1411  $a_tpl->parseCurrentBlock();
1412  $a_tpl->touchBlock("container_row");
1413  }
1414 
1418  function getIntroduction()
1419  {
1420  global $ilUser, $lng, $ilCtrl, $tree;
1421 
1422  switch((int)$this->view)
1423  {
1424  case self::VIEW_MY_MEMBERSHIPS:
1425  $tpl = new ilTemplate('tpl.pd_my_memberships_intro.html', true, true, 'Services/PersonalDesktop');
1426  $tpl->setVariable('IMG_PD_LARGE', ilObject::_getIcon("", "big", "pd"));
1427  $tpl->setVariable('TXT_WELCOME', $lng->txt('pd_my_memberships_intro'));
1428  $tpl->setVariable('TXT_INTRO_1', $lng->txt('pd_my_memberships_intro2'));
1429  break;
1430 
1431  case self::VIEW_SELECTED_ITEMS:
1432  default:
1433  // get repository link
1434  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
1435  $title = $nd["title"];
1436  if ($title == "ILIAS")
1437  {
1438  $title = $lng->txt("repository");
1439  }
1440 
1441  $tpl = new ilTemplate("tpl.pd_intro.html", true, true, "Services/PersonalDesktop");
1442  $tpl->setVariable('IMG_PD_LARGE', ilObject::_getIcon("", "big", "pd"));
1443  $tpl->setVariable("TXT_WELCOME", $lng->txt("pdesk_intro"));
1444  $tpl->setVariable("TXT_INTRO_1", sprintf($lng->txt("pdesk_intro2"), $lng->txt("to_desktop")));
1445  include_once("./Services/Link/classes/class.ilLink.php");
1446  $tpl->setVariable("TXT_INTRO_2", sprintf($lng->txt("pdesk_intro3"),
1447  '<a href="'.ilLink::_getStaticLink(1,'root',true).'">'.$title.'</a>'));
1448  $tpl->setVariable("TXT_INTRO_3", $lng->txt("pdesk_intro4"));
1449  break;
1450  }
1451 
1452  return $tpl->get();
1453  }
1454 
1459  {
1460  global $ilUser, $ilCtrl;
1461 
1462  $ilUser->writePref("pd_order_items", "location");
1463 
1464  if ($ilCtrl->isAsynch())
1465  {
1466  echo $this->getHTML();
1467  exit;
1468  }
1469  else
1470  {
1471  $ilCtrl->setParameterByClass('ilpersonaldesktopgui', 'view', $this->view);
1472  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
1473  }
1474  }
1475 
1480  {
1481  global $ilUser, $ilCtrl;
1482 
1483  $ilUser->writePref("pd_order_items", "type");
1484 
1485  if ($ilCtrl->isAsynch())
1486  {
1487  echo $this->getHTML();
1488  exit;
1489  }
1490  else
1491  {
1492  $ilCtrl->setParameterByClass('ilpersonaldesktopgui', 'view', $this->view);
1493  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
1494  }
1495  }
1496 
1497  function manageObject()
1498  {
1499  global $ilUser, $objDefinition, $ilCtrl, $lng;
1500 
1501  $objects = array();
1502 
1503  $this->manage = true;
1504  $this->setAvailableDetailLevels(1, 1);
1505 
1506  $top_tb = new ilToolbarGUI();
1507  $top_tb->setFormAction($ilCtrl->getFormAction($this));
1508  $top_tb->setLeadingImage(ilUtil::getImagePath("arrow_upright.svg"), $lng->txt("actions"));
1509 
1510  $button = ilSubmitButton::getInstance();
1511  if($this->view == self::VIEW_SELECTED_ITEMS)
1512  {
1513  $button->setCaption("remove");
1514  }
1515  else
1516  {
1517  $button->setCaption("pd_unsubscribe_memberships");
1518  }
1519  $button->setCommand("confirmRemove");
1520  $top_tb->addStickyItem($button);
1521 
1522  $button2 = ilSubmitButton::getInstance();
1523  $button2->setCaption("cancel");
1524  $button2->setCommand("getHTML");
1525  $top_tb->addStickyItem($button2);
1526 
1527  $top_tb->setCloseFormTag(false);
1528 
1529  $bot_tb = new ilToolbarGUI();
1530  $bot_tb->setLeadingImage(ilUtil::getImagePath("arrow_downright.svg"), $lng->txt("actions"));
1531  $bot_tb->addStickyItem($button);
1532  $bot_tb->addStickyItem($button2);
1533  $bot_tb->setOpenFormTag(false);
1534 
1535  return $top_tb->getHTML().$this->getHTML().$bot_tb->getHTML();
1536  }
1537 
1538  public function confirmRemoveObject()
1539  {
1540  global $ilCtrl;
1541 
1542  $ilCtrl->setParameter($this, 'view', $this->view);
1543  if(!sizeof($_POST["id"]))
1544  {
1545  ilUtil::sendFailure($this->lng->txt("select_one"), true);
1546  $ilCtrl->redirect($this, "manage");
1547  }
1548 
1549  if($this->view == self::VIEW_SELECTED_ITEMS)
1550  {
1551  $question = $this->lng->txt("pd_info_delete_sure_remove");
1552  $cmd = "confirmedRemove";
1553  }
1554  else
1555  {
1556  $question = $this->lng->txt("pd_info_delete_sure_unsubscribe");
1557  $cmd = "confirmedUnsubscribe";
1558  }
1559 
1560  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1561  $cgui = new ilConfirmationGUI();
1562  $cgui->setHeaderText($question);
1563 
1564  $cgui->setFormAction($ilCtrl->getFormAction($this));
1565  $cgui->setCancel($this->lng->txt("cancel"), "manage");
1566  $cgui->setConfirm($this->lng->txt("confirm"), $cmd);
1567 
1568  foreach ($_POST["id"] as $ref_id)
1569  {
1570  $obj_id = ilObject::_lookupObjectId($ref_id);
1571  $title = ilObject::_lookupTitle($obj_id);
1572  $type = ilObject::_lookupType($obj_id);
1573 
1574  $cgui->addItem("ref_id[]", $ref_id, $title,
1575  ilObject::_getIcon($obj_id, "small", $type),
1576  $this->lng->txt("icon")." ".$this->lng->txt("obj_".$type));
1577  }
1578 
1579  return $cgui->getHTML();
1580  }
1581 
1582  public function confirmedRemove()
1583  {
1584  global $ilCtrl, $ilUser;
1585 
1586  if(!sizeof($_POST["ref_id"]))
1587  {
1588  $ilCtrl->redirect($this, "manage");
1589  }
1590 
1591  foreach($_POST["ref_id"] as $ref_id)
1592  {
1593  $type = ilObject::_lookupType($ref_id, true);
1594  ilObjUser::_dropDesktopItem($ilUser->getId(), $ref_id, $type);
1595  }
1596 
1597  // #12909
1598  ilUtil::sendSuccess($this->lng->txt("pd_remove_multi_confirm"), true);
1599  $ilCtrl->setParameterByClass('ilpersonaldesktopgui', 'view', $this->view);
1600  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
1601  }
1602 
1603  public function confirmedUnsubscribe()
1604  {
1605  global $ilCtrl, $ilAccess, $ilUser;
1606 
1607  if(!sizeof($_POST["ref_id"]))
1608  {
1609  $ilCtrl->redirect($this, "manage");
1610  }
1611 
1612  foreach($_POST["ref_id"] as $ref_id)
1613  {
1614  if($ilAccess->checkAccess("leave", "", $ref_id))
1615  {
1616  switch(ilObject::_lookupType($ref_id, true))
1617  {
1618  case "crs":
1619  // see ilObjCourseGUI:performUnsubscribeObject()
1620  include_once "Modules/Course/classes/class.ilCourseParticipants.php";
1621  $members = new ilCourseParticipants(ilObject::_lookupObjId($ref_id));
1622  $members->delete($ilUser->getId());
1623 
1624  $members->sendUnsubscribeNotificationToAdmins($ilUser->getId());
1625  $members->sendNotification(
1626  $members->NOTIFY_UNSUBSCRIBE,
1627  $ilUser->getId()
1628  );
1629  break;
1630 
1631  case "grp":
1632  // see ilObjGroupGUI:performUnsubscribeObject()
1633  include_once "Modules/Group/classes/class.ilGroupParticipants.php";
1634  $members = new ilGroupParticipants(ilObject::_lookupObjId($ref_id));
1635  $members->delete($ilUser->getId());
1636 
1637  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1638  $members->sendNotification(
1640  $ilUser->getId()
1641  );
1642  $members->sendNotification(
1644  $ilUser->getId()
1645  );
1646  break;
1647 
1648  default:
1649  // do nothing
1650  continue;
1651  }
1652 
1653  include_once './Modules/Forum/classes/class.ilForumNotification.php';
1654  ilForumNotification::checkForumsExistsDelete($ref_id, $ilUser->getId());
1655  }
1656  }
1657 
1658 
1659  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1660  $ilCtrl->setParameterByClass('ilpersonaldesktopgui', 'view', $this->view);
1661  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
1662  }
1663 }
1664 
1665 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
getSelectedItemsBlockHTML()
get selected item block
exit
Definition: login.php:54
$_POST['username']
Definition: cron.php:12
addFooterLink($a_text, $a_href="", $a_onclick="", $a_block_id="", $a_top=false, $a_omit_separator=false, $a_checked=false)
Add a footer text/link.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
$_GET["client_id"]
$location
Definition: buildRTE.php:44
getMembershipItemsPerType($tpl)
Generates the block html string by type ordering.
getObjectsByMembership($types=array())
Gets all objects the current user is member of.
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
$cmd
Definition: sahs_server.php:35
getSelectedItemsPerType(&$tpl)
get selected items per type
fillFooterLinks($a_top=false, $a_numinfo="")
Fill footer links.
static _lookupTitle($a_id)
lookup object title
addParentRow(&$a_tpl, $a_ref_id, $a_show_image=true)
adds a header row to a block template
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
static addToDesktop()
Add desktop item public.
addStandardRow(&$a_tpl, $a_html, $a_item_ref_id="", $a_item_obj_id="", $a_image_type="", $a_related_header="")
adds a standard row to a block template
static _getAllReferences($a_id)
get all reference ids of object
_lookupIconPath($a_id, $a_size="big")
lookup icon path
global $tpl
Definition: ilias.php:8
static _lookupObjectId($a_ref_id)
lookup object id
orderPDItemsByLocation()
order desktop items by location
global $ilCtrl
Definition: ilias.php:18
fillDetailRow()
Fill Detail Setting Row.
Preloader for object list GUIs.
static lookupTxt($a_mod_prefix, $a_pl_id, $a_lang_var)
Lookup language text.
const IL_SCREEN_FULL
$nd
Definition: error.php:11
setTitle($a_title)
Set Title.
getSelectedItemsPerLocation(&$tpl)
get selected items per type
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
setData($a_data)
Set Data.
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
setAvailableDetailLevels($a_max, $a_min=0)
Set Available Detail Levels.
orderPDItemsByType()
order desktop items by Type
static _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
drop an item from user&#39;s personal desktop
addHeaderRow(&$a_tpl, $a_type, $a_show_image=true)
adds a header row to a block template
static addListGUIActivationProperty(ilObjectListGUI $a_list_gui, array &$a_item)
Get timing details for list gui.
static _lookupType($a_id, $a_reference=false)
lookup object type
& newBlockTemplate()
returns a new list block template
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static checkForumsExistsDelete($ref_id, $user_id=0)
static removeFromDesktop()
Remove item from personal desktop public.
setLimit($a_limit)
Set Limit.
global $ilUser
Definition: imgupload.php:15
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
$ref_id
Definition: sahs_server.php:39
global $ilSetting
Definition: privfeed.php:40
BlockGUI class for Selected Items on Personal Desktop.
getMembershipItemsBlockHTML()
Gateway method to distinguish between sorting type.
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
global $ilBench
Definition: ilias.php:18
global $ilDB
getColSpan()
Get Columns Span.
& getItemListGUI($a_type)
get item list gui class for type
getMembershipItemsPerLocation($tpl)
Generates the block html string by location ordering.
This class represents a block method of a block.
const IL_SCREEN_SIDE
setEnableDetailRow($a_enabledetailrow)
Set EnableDetailRow.
const ID_PART_SCREEN
$html
Definition: example_001.php:87
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
getCurrentDetailLevel()
Get Current Detail Level.
Confirmation screen class.