ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 {
19  const VIEW_MY_OFFERS = 0;
21 
22  static $block_type = "pditems";
23 
25  private $allowed_views = array();
26 
31  {
32  global $ilCtrl, $lng, $ilUser;
33 
35 
36  $lng->loadLanguageModule('pd');
37  $lng->loadLanguageModule('cntr'); // #14369
38 
39  //$this->setImage(ilUtil::getImagePath("icon_bm_s.png"));
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 addToDeskObject()
55  {
56  global $ilCtrl, $lng;
57 
58  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
60  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
61  $ilCtrl->redirectByClass('ilpersonaldesktopgui', 'show');
62  }
63 
67  public function removeFromDeskObject()
68  {
69  global $ilCtrl, $lng;
70 
71  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
73  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
74  $ilCtrl->redirectByClass('ilpersonaldesktopgui', 'show');
75  }
76 
77 
83  public function changeView()
84  {
85  global $ilUser, $ilCtrl;
86 
87  if(in_array((int)$_GET['view'], $this->allowed_views))
88  {
89  $ilUser->writePref('pd_view', (int)$_GET['view']);
90  }
91  else
92  {
93  @reset($this->allowed_views);
94  $view = (int)@current($this->allowed_views);
95  $ilUser->writePref('pd_view', $view);
96  }
97 
98  $ilCtrl->redirectByClass('ilpersonaldesktopgui', 'show');
99  }
100 
106  protected function determineViewSettings()
107  {
108  global $ilSetting, $ilUser;
109 
110  $this->allowed_views = array();
111 
112  // determine view
113  if($ilSetting->get('disable_my_offers') == 1 &&
114  $ilSetting->get('disable_my_memberships') == 1)
115  {
116  // if both views are disabled set default view (should not occur but we should prevent it)
117  $ilSetting->set('personal_items_default_view', self::VIEW_MY_OFFERS);
118  $this->allowed_views[] = self::VIEW_MY_OFFERS;
119  }
120  // both views are enabled, get default view
121  else if($ilSetting->get('disable_my_offers') == 0 &&
122  $ilSetting->get('disable_my_memberships') == 0)
123  {
124  $this->allowed_views[] = self::VIEW_MY_OFFERS;
125  $this->allowed_views[] = self::VIEW_MY_MEMBERSHIPS;
126  }
127  else if($ilSetting->get('disable_my_offers') == 0 &&
128  $ilSetting->get('disable_my_memberships') == 1)
129  {
130  $this->allowed_views[] = self::VIEW_MY_OFFERS;
131  }
132  else
133  {
134  $this->allowed_views[] = self::VIEW_MY_MEMBERSHIPS;
135  }
136 
137  $this->view = $ilUser->getPref('pd_view');
138  if($this->view === false || !in_array((int)$this->view, $this->allowed_views))
139  {
140  $ilUser->writePref('pd_view', (int)$ilSetting->get('personal_items_default_view'));
141  $this->view = (int)$ilSetting->get('personal_items_default_view');
142  }
143  }
144 
150  static function getBlockType()
151  {
152  return self::$block_type;
153  }
154 
155  public static function getScreenMode()
156  {
157  $cmd = $_GET["cmd"];
158  if($cmd == "post")
159  {
160  $cmd = $_POST["cmd"];
161  $cmd = array_shift(array_keys($cmd));
162  }
163 
164  switch($cmd)
165  {
166  case "confirmRemove":
167  case "manage":
168  return IL_SCREEN_FULL;
169 
170  default:
171  return IL_SCREEN_SIDE;
172  }
173  }
174 
180  static function isRepositoryObject()
181  {
182  return false;
183  }
184 
185 
186  function getHTML()
187  {
188  global $ilCtrl, $ilSetting, $tpl, $lng, $ilHelp, $ilDB;
189 
190  $ilDB->useSlave(true);
191 
192  // both views are activated (show buttons)
193  if($ilSetting->get('disable_my_offers') == 0 &&
194  $ilSetting->get('disable_my_memberships') == 0)
195  {
196 /* $ilCtrl->setParameter($this, 'block_type', $this->getBlockType());
197  $ilCtrl->setParameter($this, 'view', self::VIEW_MY_OFFERS);
198  $this->addHeaderLink($ilCtrl->getLinkTarget($this, 'changeView'), $this->lng->txt('pd_my_offers'),
199  ($this->view == self::VIEW_MY_OFFERS ? false : true)
200  );
201  $ilCtrl->setParameter($this, 'view', self::VIEW_MY_MEMBERSHIPS);
202  $this->addHeaderLink($ilCtrl->getLinkTarget($this, 'changeView'), $this->lng->txt('pd_my_memberships'),
203  ($this->view == self::VIEW_MY_MEMBERSHIPS ? false : true)
204  );
205  $ilCtrl->clearParameters($this);*/
206  }
207 
208  // workaround to show details row
209  $this->setData(array("dummy"));
210 
211  include_once "Services/Object/classes/class.ilObjectListGUI.php";
212  ilObjectListGUI::prepareJSLinks("",
213  $ilCtrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
214  $ilCtrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false));
215 
216  switch((int)$this->view)
217  {
218  case self::VIEW_MY_MEMBERSHIPS:
219  $ilHelp->setDefaultScreenId(ilHelpGUI::ID_PART_SCREEN, "crs_grp");
220  if ($ilSetting->get('disable_my_offers') == 0)
221  {
222  $tpl->setTitle($lng->txt("my_courses_groups"));
223  }
224  $this->setTitle($this->lng->txt('pd_my_memberships'));
225  $this->setContent($this->getMembershipItemsBlockHTML());
226  break;
227 
228  case self::VIEW_MY_OFFERS:
229  default:
230  $ilHelp->setDefaultScreenId(ilHelpGUI::ID_PART_SCREEN, "sel_items");
231  if(!in_array(self::VIEW_MY_MEMBERSHIPS, $this->allowed_views))
232  {
233  $this->setTitle($this->lng->txt('selected_items'));
234  }
235  else
236  {
237  $this->setTitle($this->lng->txt('pd_my_offers'));
238  }
239 
240  $this->setContent($this->getSelectedItemsBlockHTML());
241  break;
242  }
243 
244  if ($this->getContent() == "")
245  {
246  $this->setEnableDetailRow(false);
247  }
248  $ilCtrl->clearParametersByClass("ilpersonaldesktopgui");
249  $ilCtrl->clearParameters($this);
250 
251  $ilDB->useSlave(false);
252 
253  return parent::getHTML();
254  }
255 
259  function &executeCommand()
260  {
261  global $ilCtrl;
262 
263  $next_class = $ilCtrl->getNextClass();
264  $cmd = $ilCtrl->getCmd("getHTML");
265 
266  switch($next_class)
267  {
268  case "ilcommonactiondispatchergui":
269  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
271  $ilCtrl->forwardCommand($gui);
272  break;
273 
274  default:
275  if(method_exists($this, $cmd))
276  {
277  return $this->$cmd();
278  }
279  else
280  {
281  $cmd .= 'Object';
282  return $this->$cmd();
283  }
284  }
285  }
286 
287  function getContent()
288  {
289  return $this->content;
290  }
291 
292  function setContent($a_content)
293  {
294  $this->content = $a_content;
295  }
296 
300  function fillDataSection()
301  {
302  global $ilUser;
303 
304  if ($this->getContent() != "")
305  {
306  $this->tpl->setVariable("BLOCK_ROW", $this->getContent());
307  }
308  else
309  {
310  $this->setDataSection($this->getIntroduction());
311  }
312  }
313 
314 
318  function fillFooter()
319  {
320  global $ilCtrl, $lng, $ilUser;
321 
322  $this->setFooterLinks();
323  $this->fillFooterLinks();
324  $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
325  if ($this->tpl->blockExists("block_footer"))
326  {
327  $this->tpl->setCurrentBlock("block_footer");
328  $this->tpl->parseCurrentBlock();
329  }
330  }
331 
335  function setFooterLinks()
336  {
337  global $ilUser, $ilCtrl, $lng;
338 
339  if ($this->getContent() == "")
340  {
341  $this->setEnableNumInfo(false);
342  return "";
343  }
344 
345  if ($this->manage)
346  {
347  return;
348  }
349 
350  // by type
351 // if ($ilUser->getPref("pd_order_items") == 'location')
352 // {
353  $this->addFooterLink( $lng->txt("by_type"),
354  $ilCtrl->getLinkTarget($this, "orderPDItemsByType"),
355  $ilCtrl->getLinkTarget($this, "orderPDItemsByType", "", true),
356  "block_".$this->getBlockType()."_".$this->block_id,
357  false, false, ($ilUser->getPref("pd_order_items") != 'location')
358  );
359 // }
360 // else
361 // {
362 // $this->addFooterLink($lng->txt("by_type"));
363 // }
364 
365 // // by location
366 // if ($ilUser->getPref("pd_order_items") == 'location')
367 // {
368 // $this->addFooterLink($lng->txt("by_location"));
369 // }
370 // else
371 // {
372  $this->addFooterLink( $lng->txt("by_location"),
373  $ilCtrl->getLinkTarget($this, "orderPDItemsByLocation"),
374  $ilCtrl->getLinkTarget($this, "orderPDItemsByLocation", "", true),
375  "block_".$this->getBlockType()."_".$this->block_id,
376  false, false, ($ilUser->getPref("pd_order_items") == 'location')
377  );
378 // }
379 
380  $this->addFooterLink(($this->view == self::VIEW_MY_OFFERS) ?
381  $lng->txt("pd_remove_multiple") :
382  $lng->txt("pd_unsubscribe_multiple_memberships"),
383  $ilCtrl->getLinkTarget($this, "manage"),
384  null,
385  "block_".$this->getBlockType()."_".$this->block_id
386  );
387  }
388 
395  protected function getObjectsByMembership($types = array())
396  {
397  global $tree, $ilUser, $ilObjDataCache;
398 
399  include_once 'Services/Membership/classes/class.ilParticipants.php';
400  $items = array();
401 
402  if(is_array($types) && count($types))
403  {
404  foreach($types as $type)
405  {
406  switch($type)
407  {
408  case 'grp':
409  $items = array_merge(ilParticipants::_getMembershipByType($ilUser->getId(), 'grp'), $items);
410  break;
411  case 'crs':
412  $items = array_merge(ilParticipants::_getMembershipByType($ilUser->getId(), 'crs'), $items);
413  break;
414  default:
415  break;
416  }
417  }
418  }
419  else
420  {
421  $crs_mbs = ilParticipants::_getMembershipByType($ilUser->getId(), 'crs');
422  $grp_mbs = ilParticipants::_getMembershipByType($ilUser->getId(), 'grp');
423  $items = array_merge($crs_mbs, $grp_mbs);
424  }
425 
426  $references = array();
427  foreach($items as $key => $obj_id)
428  {
429  $item_references = ilObject::_getAllReferences($obj_id);
430  foreach($item_references as $ref_id)
431  {
432  if($tree->isInTree($ref_id))
433  {
434  $title = $ilObjDataCache->lookupTitle($obj_id);
435  $type = $ilObjDataCache->lookupType($obj_id);
436 
437  $parent_ref_id = $tree->getParentId($ref_id);
438  $par_left = $tree->getLeftValue($parent_ref_id);
439  $par_left = sprintf("%010d", $par_left);
440 
441  $references[$par_left . $title . $ref_id] = array(
442  'ref_id' => $ref_id,
443  'obj_id' => $obj_id,
444  'type' => $type,
445  'title' => $title,
446  'description' => $ilObjDataCache->lookupDescription($obj_id),
447  'parent_ref' => $parent_ref_id
448  );
449  }
450  }
451  }
452  ksort($references);
453  return is_array($references) ? $references : array();
454  }
455 
463  {
464  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache, $rbacreview;
465 
466  $output = false;
467  $items = $this->getObjectsByMembership();
468  $item_html = array();
469  if(count($items) > 0)
470  {
471  include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
473  foreach($items as $item)
474  {
475  $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
476  }
477  $preloader->preload();
478  unset($preloader);
479 
480  reset($items);
481  foreach($items as $item)
482  {
483  //echo "1";
484  // get list gui class for each object type
485  if ($cur_obj_type != $item["type"])
486  {
487  $item_list_gui =& $this->getItemListGUI($item["type"]);
488  if(!$item_list_gui)
489  {
490  continue;
491  }
492 
493  // notes, comment currently do not work properly
494  $item_list_gui->enableNotes(false);
495  $item_list_gui->enableComments(false);
496  $item_list_gui->enableTags(false);
497 
498  $item_list_gui->enableIcon(true);
499  $item_list_gui->enableDelete(false);
500  $item_list_gui->enableCut(false);
501  $item_list_gui->enableCopy(false);
502  $item_list_gui->enablePayment(false);
503  $item_list_gui->enableLink(false);
504  $item_list_gui->enableInfoScreen(true);
505  if ($ilSetting->get('disable_my_offers') == 1)
506  {
507  $item_list_gui->enableSubscribe(false);
508  }
509  else
510  {
511  $item_list_gui->enableSubscribe(true);
512  }
513  $item_list_gui->setContainerObject($this);
514  if ($this->getCurrentDetailLevel() < 3 || $this->manage)
515  {
516  //echo "3";
517  $item_list_gui->enableDescription(false);
518  $item_list_gui->enableProperties(false);
519  $item_list_gui->enablePreconditions(false);
520  }
521  if ($this->getCurrentDetailLevel() < 2 || $this->manage)
522  {
523  $item_list_gui->enableCommands(true, true);
524  }
525  }
526  // render item row
527  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
528 
529  if (is_object($item_list_gui))
530  {
531  ilObjectActivation::addListGUIActivationProperty($item_list_gui, $item);
532 
533  // #15232
534  if($this->manage)
535  {
536  if(!$rbacsystem->checkAccess("leave", $item["ref_id"]))
537  {
538  $item_list_gui->enableCheckbox(false);
539  }
540  else
541  {
542  $item_list_gui->enableCheckbox(true);
543  }
544  }
545 
546  $html = $item_list_gui->getListItemHTML($item["ref_id"],
547  $item["obj_id"], $item["title"], $item["description"]);
548  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
549  if ($html != "")
550  {
551  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
552  $item_html[] = array(
553  "html" => $html,
554  "item_ref_id" => $item["ref_id"],
555  "item_obj_id" => $item["obj_id"],
556  "parent_ref" => $item["parent_ref"],
557  "type" => $item["type"],
558  'item_icon_image_type' => $item_list_gui->getIconImageType()
559  );
560  // END WebDAV: Use $item_list_gui to determine icon image type
561  }
562  }
563  }
564 
565  // output block for resource type
566  if (count($item_html) > 0)
567  {
568  $cur_parent_ref = 0;
569 
570  // content row
571  foreach($item_html as $item)
572  {
573  // add a parent header row for each new parent
574  if ($cur_parent_ref != $item["parent_ref"])
575  {
576  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
577  {
578  $this->addParentRow($tpl, $item["parent_ref"], false);
579  }
580  else
581  {
582  $this->addParentRow($tpl, $item["parent_ref"]);
583  }
584  $this->resetRowType();
585  $cur_parent_ref = $item["parent_ref"];
586  }
587 
588  // BEGIN WebDAV: Use $item_list_gui to determine icon image type.
589  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
590  $item['item_icon_image_type'],
591  "th_".$cur_parent_ref);
592  // END WebDAV: Use $item_list_gui to determine icon image type.
593  $output = true;
594  }
595  }
596  }
597 
598  return $output;
599  }
600 
608  {
609  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache;
610 
611  $output = false;
612 
613  $objtype_groups = $objDefinition->getGroupedRepositoryObjectTypes(
614  array("cat", "crs", "grp", "fold"));
615 
616  $types = array();
617  foreach($objtype_groups as $grp => $grpdata)
618  {
619  $types[] = array(
620  "grp" => $grp,
621  "title" => $this->lng->txt("objs_".$grp),
622  "types" => $grpdata["objs"]);
623  }
624 
625  include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
626 
627  foreach ($types as $t)
628  {
629  $type = $t["types"];
630  $title = $t["title"];
631  $grp = $t["grp"];
632 
633  $items = $this->getObjectsByMembership($type);
634 
635  if (count($items) > 0)
636  {
638  foreach($items as $item)
639  {
640  $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
641  }
642  $preloader->preload();
643  unset($preloader);
644 
645  reset($items);
646 
647 
648  $item_html = array();
649 
650  if ($this->getCurrentDetailLevel() == 3)
651  {
652  $rel_header = "th_".$grp;
653  }
654 
655  $tstCount = 0;
656  $unsetCount = 0;
657  $progressCount = 0;
658  $unsetFlag = 0;
659  $progressFlag = 0;
660  $completedFlag = 0;
661  if (strcmp($a_type, "tst") == 0) {
662  $items = $this->multiarray_sort($items, "used_tries; title");
663  foreach ($items as $tst_item) {
664  if (!isset($tst_item["used_tries"])) {
665  $unsetCount++;
666  }
667  elseif ($tst_item["used_tries"] == 0) {
668  $progressCount++;
669  }
670  }
671  }
672 
673  foreach($items as $item)
674  {
675  // get list gui class for each object type
676  if ($cur_obj_type != $item["type"])
677  {
678  $class = $objDefinition->getClassName($item["type"]);
679  $location = $objDefinition->getLocation($item["type"]);
680  $full_class = "ilObj".$class."ListGUI";
681  include_once($location."/class.".$full_class.".php");
682  $item_list_gui = new $full_class();
683 
684  // notes, comment currently do not work properly
685  $item_list_gui->enableNotes(false);
686  $item_list_gui->enableComments(false);
687  $item_list_gui->enableTags(false);
688 
689  $item_list_gui->enableIcon(true);
690  $item_list_gui->enableDelete(false);
691  $item_list_gui->enableCut(false);
692  $item_list_gui->enableCopy(false);
693  $item_list_gui->enablePayment(false);
694  $item_list_gui->enableLink(false);
695  $item_list_gui->enableInfoScreen(true);
696  if ($ilSetting->get('disable_my_offers') == 1)
697  {
698  $item_list_gui->enableSubscribe(false);
699  }
700  else
701  {
702  $item_list_gui->enableSubscribe(true);
703  }
704 
705  $item_list_gui->setContainerObject($this);
706  if ($this->manage)
707  {
708  $item_list_gui->enableCheckbox(true);
709  }
710  if ($this->getCurrentDetailLevel() < 3 || $this->manage)
711  {
712  $item_list_gui->enableDescription(false);
713  $item_list_gui->enableProperties(false);
714  $item_list_gui->enablePreconditions(false);
715  $item_list_gui->enableNoticeProperties(false);
716  }
717  if ($this->getCurrentDetailLevel() < 2 || $this->manage)
718  {
719  $item_list_gui->enableCommands(true, true);
720  }
721  }
722  // render item row
723  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
724 
725  ilObjectActivation::addListGUIActivationProperty($item_list_gui, $item);
726 
727  // #15232
728  if($this->manage)
729  {
730  if(!$rbacsystem->checkAccess("leave", $item["ref_id"]))
731  {
732  $item_list_gui->enableCheckbox(false);
733  }
734  else
735  {
736  $item_list_gui->enableCheckbox(true);
737  }
738  }
739 
740  $html = $item_list_gui->getListItemHTML($item["ref_id"],
741  $item["obj_id"], $item["title"], $item["description"]);
742  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
743  if ($html != "")
744  {
745  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
746  $item_html[] = array(
747  "html" => $html,
748  "item_ref_id" => $item["ref_id"],
749  "item_obj_id" => $item["obj_id"],
750  'item_icon_image_type' => (method_exists($item_list_gui, 'getIconImageType')) ?
751  $item_list_gui->getIconImageType() :
752  $item['type']
753  );
754  // END WebDAV: Use $item_list_gui to determine icon image type
755  }
756  }
757 
758  // output block for resource type
759  if (count($item_html) > 0)
760  {
761  // add a header for each resource type
762  if ($this->getCurrentDetailLevel() == 3)
763  {
764  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
765  {
766  $this->addHeaderRow($tpl, $grp, false);
767  }
768  else
769  {
770  $this->addHeaderRow($tpl, $grp);
771  }
772  $this->resetRowType();
773  }
774 
775  // content row
776  foreach($item_html as $item)
777  {
778  if ($this->getCurrentDetailLevel() < 3 ||
779  $ilSetting->get("icon_position_in_lists") == "item_rows")
780  {
781  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
782  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
783  $item['item_icon_image_type'],
784  $rel_header);
785  // END WebDAV: Use $item_list_gui to determine icon image type
786  }
787  else
788  {
789  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], "", $rel_header);
790  }
791  $output = true;
792  }
793  }
794  }
795  }
796 
797  return $output;
798  }
799 
806  public function getMembershipItemsBlockHTML()
807  {
808  global $ilUser;
809 
810  $tpl = $this->newBlockTemplate();
811 
812  switch($ilUser->getPref('pd_order_items'))
813  {
814  case 'location':
816  break;
817 
818  default:
820  break;
821  }
822 
823  return $tpl->get();
824  }
825 
830  {
831  global $ilUser, $rbacsystem, $objDefinition, $ilBench;
832 
833  $tpl =& $this->newBlockTemplate();
834 
835  switch ($ilUser->getPref("pd_order_items"))
836  {
837  case "location":
839  break;
840 
841  default:
842  $ok = $this->getSelectedItemsPerType($tpl);
843  break;
844  }
845 
846  if($this->manage)
847  {
848  // #11355 - see ContainerContentGUI::renderSelectAllBlock()
849  $tpl->setCurrentBlock("select_all_row");
850  $tpl->setVariable("CHECKBOXNAME", "ilToolbarSelectAll");
851  $tpl->setVariable("SEL_ALL_PARENT", "ilToolbar");
852  $tpl->setVariable("SEL_ALL_CB_NAME", "id");
853  $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
854  $tpl->parseCurrentBlock();
855  }
856 
857  return $tpl->get();
858  }
859 
864  {
865  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache, $tree, $ilCtrl;
866 
867  $items = $ilUser->getDesktopItems();
868  if (count($items) > 0)
869  {
870  include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
872  foreach($items as $item)
873  {
874  $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
875  }
876  $preloader->preload();
877  unset($preloader);
878 
879  reset($items);
880  }
881 
882  $output = false;
883 
884  $objtype_groups = $objDefinition->getGroupedRepositoryObjectTypes(
885  array("cat", "crs", "grp", "fold"));
886 
887  $types = array();
888  foreach($objtype_groups as $grp => $grpdata)
889  {
890  $types[] = array(
891  "grp" => $grp,
892  "title" => $this->lng->txt("objs_".$grp),
893  "types" => $grpdata["objs"]);
894  }
895 
896  foreach ($types as $t)
897  {
898 
899  $type = $t["types"];
900  $title = $t["title"];
901  $grp = $t["grp"];
902 
903  $items = $ilUser->getDesktopItems($type);
904  $item_html = array();
905 
906  if ($this->getCurrentDetailLevel() == 3)
907  {
908  $rel_header = "th_".$grp;
909  }
910 
911  if (count($items) > 0)
912  {
913  $tstCount = 0;
914  $unsetCount = 0;
915  $progressCount = 0;
916  $unsetFlag = 0;
917  $progressFlag = 0;
918  $completedFlag = 0;
919  if (strcmp($a_type, "tst") == 0) {
920  $items = $this->multiarray_sort($items, "used_tries; title");
921  foreach ($items as $tst_item) {
922  if (!isset($tst_item["used_tries"])) {
923  $unsetCount++;
924  }
925  elseif ($tst_item["used_tries"] == 0) {
926  $progressCount++;
927  }
928  }
929  }
930 
931  foreach($items as $item)
932  {
933  // get list gui class for each object type
934  if ($cur_obj_type != $item["type"])
935  {
936  $class = $objDefinition->getClassName($item["type"]);
937  $location = $objDefinition->getLocation($item["type"]);
938  $full_class = "ilObj".$class."ListGUI";
939  include_once($location."/class.".$full_class.".php");
940  $item_list_gui = new $full_class();
941 
942  // notes, comment currently do not work properly
943  $item_list_gui->enableNotes(false);
944  $item_list_gui->enableComments(false);
945  $item_list_gui->enableTags(false);
946 
947  $item_list_gui->enableIcon(true);
948  $item_list_gui->enableDelete(false);
949  $item_list_gui->enableCut(false);
950  $item_list_gui->enableCopy(false);
951  $item_list_gui->enablePayment(false);
952  $item_list_gui->enableLink(false);
953  $item_list_gui->enableInfoScreen(true);
954  $item_list_gui->setContainerObject($this);
955 
956  if ($this->manage)
957  {
958  $item_list_gui->enableCheckbox(true);
959  }
960 
961  if ($this->getCurrentDetailLevel() < 3 || $this->manage)
962  {
963  $item_list_gui->enableDescription(false);
964  $item_list_gui->enableProperties(false);
965  $item_list_gui->enablePreconditions(false);
966  $item_list_gui->enableNoticeProperties(false);
967  }
968  if ($this->getCurrentDetailLevel() < 2 || $this->manage)
969  {
970  $item_list_gui->enableCommands(true, true);
971  }
972  }
973  // render item row
974  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
975 
976  ilObjectActivation::addListGUIActivationProperty($item_list_gui, $item);
977 
978  $html = $item_list_gui->getListItemHTML($item["ref_id"],
979  $item["obj_id"], $item["title"], $item["description"]);
980  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
981  if ($html != "")
982  {
983  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
984  $item_html[] = array(
985  "html" => $html,
986  "item_ref_id" => $item["ref_id"],
987  "item_obj_id" => $item["obj_id"],
988  'item_icon_image_type' => (method_exists($item_list_gui, 'getIconImageType')) ?
989  $item_list_gui->getIconImageType() :
990  $item['type']
991  );
992  // END WebDAV: Use $item_list_gui to determine icon image type
993  }
994  }
995 
996  // output block for resource type
997  if (count($item_html) > 0)
998  {
999  // add a header for each resource type
1000  if ($this->getCurrentDetailLevel() == 3)
1001  {
1002  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
1003  {
1004  $this->addHeaderRow($tpl, $grp, false);
1005  }
1006  else
1007  {
1008  $this->addHeaderRow($tpl, $grp);
1009  }
1010  $this->resetRowType();
1011  }
1012 
1013  // content row
1014  foreach($item_html as $item)
1015  {
1016  if ($this->getCurrentDetailLevel() < 3 ||
1017  $ilSetting->get("icon_position_in_lists") == "item_rows")
1018  {
1019  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
1020  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
1021  $item['item_icon_image_type'],
1022  $rel_header);
1023  // END WebDAV: Use $item_list_gui to determine icon image type
1024  }
1025  else
1026  {
1027  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], "", $rel_header);
1028  }
1029  $output = true;
1030  }
1031  }
1032  }
1033  }
1034 
1035  return $output;
1036  }
1037 
1042  {
1043  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache, $tree;
1044 
1045  $output = false;
1046 
1047  $items = $ilUser->getDesktopItems();
1048  $item_html = array();
1049  $cur_obj_type = "";
1050 
1051  if (count($items) > 0)
1052  {
1053  include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
1055  foreach($items as $item)
1056  {
1057  $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
1058  }
1059  $preloader->preload();
1060  unset($preloader);
1061 
1062  reset($items);
1063  foreach($items as $item)
1064  {
1065  //echo "1";
1066  // get list gui class for each object type
1067  if ($cur_obj_type != $item["type"])
1068  {
1069  $item_list_gui =& $this->getItemListGUI($item["type"]);
1070  if(!$item_list_gui)
1071  {
1072  continue;
1073  }
1074 
1075  // notes, comment currently do not work properly
1076  $item_list_gui->enableNotes(false);
1077  $item_list_gui->enableComments(false);
1078  $item_list_gui->enableTags(false);
1079 
1080  $item_list_gui->enableIcon(true);
1081  $item_list_gui->enableDelete(false);
1082  $item_list_gui->enableCut(false);
1083  $item_list_gui->enableCopy(false);
1084  $item_list_gui->enablePayment(false);
1085  $item_list_gui->enableLink(false);
1086  $item_list_gui->enableInfoScreen(true);
1087  if ($this->getCurrentDetailLevel() < 3 || $this->manage)
1088  {
1089  //echo "3";
1090  $item_list_gui->enableDescription(false);
1091  $item_list_gui->enableProperties(false);
1092  $item_list_gui->enablePreconditions(false);
1093  }
1094  if ($this->getCurrentDetailLevel() < 2 || $this->manage)
1095  {
1096  $item_list_gui->enableCommands(true, true);
1097  }
1098  }
1099  // render item row
1100  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
1101 
1102  ilObjectActivation::addListGUIActivationProperty($item_list_gui, $item);
1103 
1104  $item_list_gui->setContainerObject($this);
1105  $html = $item_list_gui->getListItemHTML($item["ref_id"],
1106  $item["obj_id"], $item["title"], $item["description"]);
1107  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
1108  if ($html != "")
1109  {
1110  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
1111  $item_html[] = array(
1112  "html" => $html,
1113  "item_ref_id" => $item["ref_id"],
1114  "item_obj_id" => $item["obj_id"],
1115  "parent_ref" => $item["parent_ref"],
1116  "type" => $item["type"],
1117  'item_icon_image_type' => $item_list_gui->getIconImageType()
1118  );
1119  // END WebDAV: Use $item_list_gui to determine icon image type
1120  }
1121  }
1122 
1123  // output block for resource type
1124  if (count($item_html) > 0)
1125  {
1126  $cur_parent_ref = 0;
1127 
1128  // content row
1129  foreach($item_html as $item)
1130  {
1131  // add a parent header row for each new parent
1132  if ($cur_parent_ref != $item["parent_ref"])
1133  {
1134  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
1135  {
1136  $this->addParentRow($tpl, $item["parent_ref"], false);
1137  }
1138  else
1139  {
1140  $this->addParentRow($tpl, $item["parent_ref"]);
1141  }
1142  $this->resetRowType();
1143  $cur_parent_ref = $item["parent_ref"];
1144  }
1145 
1146  // BEGIN WebDAV: Use $item_list_gui to determine icon image type.
1147  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
1148  $item['item_icon_image_type'],
1149  "th_".$cur_parent_ref);
1150  // END WebDAV: Use $item_list_gui to determine icon image type.
1151  $output = true;
1152  }
1153  }
1154  }
1155 
1156  return $output;
1157  }
1158 
1159  function resetRowType()
1160  {
1161  $this->cur_row_type = "";
1162  }
1163 
1170  function &newBlockTemplate()
1171  {
1172  $tpl = new ilTemplate("tpl.pd_list_block.html", true, true, "Services/PersonalDesktop");
1173  $this->cur_row_type = "";
1174  return $tpl;
1175  }
1176 
1180  function &getItemListGUI($a_type)
1181  {
1182  global $objDefinition;
1183  //echo "<br>+$a_type+";
1184  if (!isset($this->item_list_guis[$a_type]))
1185  {
1186  $class = $objDefinition->getClassName($a_type);
1187  // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
1188  if(!$class)
1189  {
1190  return NULL;
1191  }
1192  // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
1193  $location = $objDefinition->getLocation($a_type);
1194  if(!$location)
1195  {
1196  return NULL;
1197  }
1198 
1199  $full_class = "ilObj".$class."ListGUI";
1200  //echo "<br>-".$location."/class.".$full_class.".php"."-";
1201  include_once($location."/class.".$full_class.".php");
1202  $item_list_gui = new $full_class();
1203  $this->item_list_guis[$a_type] =& $item_list_gui;
1204  }
1205  else
1206  {
1207  $item_list_gui =& $this->item_list_guis[$a_type];
1208  }
1209 
1210  if ($this->manage)
1211  {
1212  $item_list_gui->enableCheckbox(true);
1213  }
1214 
1215 
1216  return $item_list_gui;
1217  }
1218 
1226  function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
1227  {
1228  global $objDefinition;
1229 
1230  $icon = ilUtil::getImagePath("icon_".$a_type.".png");
1231  if (!$objDefinition->isPlugin($a_type))
1232  {
1233  $title = $this->lng->txt("objs_".$a_type);
1234  }
1235  else
1236  {
1237  include_once("./Services/Component/classes/class.ilPlugin.php");
1238  $title =
1239  ilPlugin::lookupTxt("rep_robj", $a_type, "objs_".$a_type);
1240 
1241  }
1242  $header_id = "th_".$a_type;
1243 
1244  if ($a_show_image)
1245  {
1246  $a_tpl->setCurrentBlock("container_header_row_image");
1247  $a_tpl->setVariable("HEADER_IMG", $icon);
1248  $a_tpl->setVariable("HEADER_ALT", $title);
1249  }
1250  else
1251  {
1252  $a_tpl->setCurrentBlock("container_header_row");
1253  }
1254 
1255  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1256  $a_tpl->setVariable("BLOCK_HEADER_ID", $header_id);
1257  $a_tpl->parseCurrentBlock();
1258  $a_tpl->touchBlock("container_row");
1259  }
1260 
1268  function addParentRow(&$a_tpl, $a_ref_id, $a_show_image = true)
1269  {
1270  global $tree, $ilSetting;
1271 
1272  $par_id = ilObject::_lookupObjId($a_ref_id);
1273  $type = ilObject::_lookupType($par_id);
1274  if (!in_array($type, array("lm", "dbk", "sahs", "htlm")))
1275  {
1276  $icon = ilUtil::getImagePath("icon_".$type.".png");
1277  }
1278  else
1279  {
1280  $icon = ilUtil::getImagePath("icon_lm.png");
1281  }
1282 
1283  // custom icon
1284  if ($ilSetting->get("custom_icons") &&
1285  in_array($type, array("cat","grp","crs", "root")))
1286  {
1287  require_once("./Services/Container/classes/class.ilContainer.php");
1288  if (($path = ilContainer::_lookupIconPath($par_id, "small")) != "")
1289  {
1290  $icon = $path;
1291  }
1292  }
1293 
1294  if ($tree->getRootId() != $par_id)
1295  {
1296  $title = ilObject::_lookupTitle($par_id);
1297  }
1298  else
1299  {
1300  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
1301  $title = $nd["title"];
1302  if ($title == "ILIAS")
1303  {
1304  $title = $this->lng->txt("repository");
1305  }
1306  }
1307 
1308 /*
1309  $item_list_gui =& $this->getItemListGUI($type);
1310 
1311  $item_list_gui->enableIcon(false);
1312  $item_list_gui->enableDelete(false);
1313  $item_list_gui->enableCut(false);
1314  $item_list_gui->enablePayment(false);
1315  $item_list_gui->enableLink(false);
1316  $item_list_gui->enableDescription(false);
1317  $item_list_gui->enableProperties(false);
1318  $item_list_gui->enablePreconditions(false);
1319  $item_list_gui->enablePath(true);
1320  $item_list_gui->enableCommands(false);
1321  $html = $item_list_gui->getListItemHTML($a_ref_id,
1322  $par_id, $title, "");
1323 
1324  if ($a_show_image)
1325  {
1326  $a_tpl->setCurrentBlock("container_header_row_image");
1327  $a_tpl->setVariable("HEADER_IMG", $icon);
1328  $a_tpl->setVariable("HEADER_ALT", $title);
1329  }
1330 */
1331 // else
1332 // {
1333  $a_tpl->setCurrentBlock("container_header_row");
1334 // }
1335 
1336  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1337 /* $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $html);
1338  $a_tpl->setVariable("BLOCK_HEADER_ID", "th_".$a_ref_id);*/
1339  $a_tpl->parseCurrentBlock();
1340  $a_tpl->touchBlock("container_row");
1341  }
1342 
1350  function addStandardRow(&$a_tpl, $a_html, $a_item_ref_id = "", $a_item_obj_id = "",
1351  $a_image_type = "", $a_related_header = "")
1352  {
1353  global $ilSetting;
1354 
1355  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1356  ? "row_type_2"
1357  : "row_type_1";
1358  $a_tpl->touchBlock($this->cur_row_type);
1359 
1360  if ($a_image_type != "")
1361  {
1362  if (!is_array($a_image_type) && !in_array($a_image_type, array("lm", "dbk", "htlm", "sahs")))
1363  {
1364  $icon = ilUtil::getImagePath("icon_".$a_image_type.".png");
1365  $title = $this->lng->txt("obj_".$a_image_type);
1366  }
1367  else
1368  {
1369  $icon = ilUtil::getImagePath("icon_lm.png");
1370  $title = $this->lng->txt("learning_resource");
1371  }
1372 
1373  // custom icon
1374  if ($ilSetting->get("custom_icons") &&
1375  in_array($a_image_type, array("cat","grp","crs")))
1376  {
1377  require_once("./Services/Container/classes/class.ilContainer.php");
1378  if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "")
1379  {
1380  $icon = $path;
1381  }
1382  }
1383 
1384  $a_tpl->setCurrentBlock("block_row_image");
1385  $a_tpl->setVariable("ROW_IMG", $icon);
1386  $a_tpl->setVariable("ROW_ALT", $title);
1387  $a_tpl->parseCurrentBlock();
1388  }
1389  else
1390  {
1391  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1392  }
1393  $a_tpl->setCurrentBlock("container_standard_row");
1394  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
1395  $rel_headers = ($a_related_header != "")
1396  ? "th_selected_items ".$a_related_header
1397  : "th_selected_items";
1398  $a_tpl->setVariable("BLOCK_ROW_HEADERS", $rel_headers);
1399  $a_tpl->parseCurrentBlock();
1400  $a_tpl->touchBlock("container_row");
1401  }
1402 
1406  function getIntroduction()
1407  {
1408  global $ilUser, $lng, $ilCtrl, $tree;
1409 
1410  switch((int)$this->view)
1411  {
1412  case self::VIEW_MY_MEMBERSHIPS:
1413  $tpl = new ilTemplate('tpl.pd_my_memberships_intro.html', true, true, 'Services/PersonalDesktop');
1414  $tpl->setVariable('IMG_PD_LARGE', ilUtil::getImagePath('icon_pd_xxl.png'));
1415  $tpl->setVariable('TXT_WELCOME', $lng->txt('pd_my_memberships_intro'));
1416  $tpl->setVariable('TXT_INTRO_1', $lng->txt('pd_my_memberships_intro2'));
1417  break;
1418 
1419  case self::VIEW_MY_OFFERS:
1420  default:
1421  // get repository link
1422  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
1423  $title = $nd["title"];
1424  if ($title == "ILIAS")
1425  {
1426  $title = $lng->txt("repository");
1427  }
1428 
1429  $tpl = new ilTemplate("tpl.pd_intro.html", true, true, "Services/PersonalDesktop");
1430  $tpl->setVariable("IMG_PD_LARGE", ilUtil::getImagePath("icon_pd_xxl.png"));
1431  $tpl->setVariable("TXT_WELCOME", $lng->txt("pdesk_intro"));
1432  $tpl->setVariable("TXT_INTRO_1", sprintf($lng->txt("pdesk_intro2"), $lng->txt("to_desktop")));
1433  include_once("./Services/Link/classes/class.ilLink.php");
1434  $tpl->setVariable("TXT_INTRO_2", sprintf($lng->txt("pdesk_intro3"),
1435  '<a href="'.ilLink::_getStaticLink(1,'root',true).'">'.$title.'</a>'));
1436  $tpl->setVariable("TXT_INTRO_3", $lng->txt("pdesk_intro4"));
1437  break;
1438  }
1439 
1440  return $tpl->get();
1441  }
1442 
1447  {
1448  global $ilUser, $ilCtrl;
1449 
1450  $ilUser->writePref("pd_order_items", "location");
1451 
1452  if ($ilCtrl->isAsynch())
1453  {
1454  echo $this->getHTML();
1455  exit;
1456  }
1457  else
1458  {
1459  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
1460  }
1461  }
1462 
1467  {
1468  global $ilUser, $ilCtrl;
1469 
1470  $ilUser->writePref("pd_order_items", "type");
1471 
1472  if ($ilCtrl->isAsynch())
1473  {
1474  echo $this->getHTML();
1475  exit;
1476  }
1477  else
1478  {
1479  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
1480  }
1481  }
1482 
1483  function manageObject()
1484  {
1485  global $ilUser, $objDefinition, $ilCtrl, $lng;
1486 
1487  $objects = array();
1488 
1489  $this->manage = true;
1490  $this->setAvailableDetailLevels(1, 1);
1491 
1492  $top_tb = new ilToolbarGUI();
1493  $top_tb->setFormAction($ilCtrl->getFormAction($this));
1494  $top_tb->setLeadingImage(ilUtil::getImagePath("arrow_upright.png"), $lng->txt("actions"));
1495  if ($this->view == self::VIEW_MY_OFFERS)
1496  {
1497  $top_tb->addFormButton($lng->txt("remove"), "confirmRemove");
1498  }
1499  else
1500  {
1501  $top_tb->addFormButton($lng->txt("pd_unsubscribe_memberships"), "confirmRemove");
1502  }
1503  $top_tb->addSeparator();
1504  $top_tb->addFormButton($lng->txt("cancel"), "getHTML");
1505  $top_tb->setCloseFormTag(false);
1506 
1507  $bot_tb = new ilToolbarGUI();
1508  $bot_tb->setLeadingImage(ilUtil::getImagePath("arrow_downright.png"), $lng->txt("actions"));
1509  if ($this->view == self::VIEW_MY_OFFERS)
1510  {
1511  $bot_tb->addFormButton($lng->txt("remove"), "confirmRemove");
1512  }
1513  else
1514  {
1515  $bot_tb->addFormButton($lng->txt("pd_unsubscribe_memberships"), "confirmRemove");
1516  }
1517  $bot_tb->addSeparator();
1518  $bot_tb->addFormButton($lng->txt("cancel"), "getHTML");
1519  $bot_tb->setOpenFormTag(false);
1520 
1521  return $top_tb->getHTML().$this->getHTML().$bot_tb->getHTML();
1522 /*
1523  if($this->view == self::VIEW_MY_OFFERS)
1524  {
1525  return $top_tb->getHTML().$this->getHTML().$bot_tb->getHTML();
1526 
1527  foreach($ilUser->getDesktopItems() as $item)
1528  {
1529  $objects[] = $item;
1530  }
1531  }
1532  else
1533  {
1534  $objtype_groups = $objDefinition->getGroupedRepositoryObjectTypes(
1535  array("cat", "crs", "grp", "fold"));
1536 
1537  foreach($objtype_groups as $grpdata)
1538  {
1539  foreach($this->getObjectsByMembership($grpdata["objs"]) as $item)
1540  {
1541  $objects[] = $item;
1542  }
1543  }
1544  }
1545 
1546  include_once "Services/PersonalDesktop/classes/class.ilPDSelectedItemsTableGUI.php";
1547  $tbl = new ilPDSelectedItemsTableGUI($this, "manage", $objects, $this->view, ($ilUser->getPref("pd_order_items") == 'location'));
1548  return $tbl->getHTML();
1549 */
1550  }
1551 
1552  public function confirmRemoveObject()
1553  {
1554  global $ilCtrl;
1555 
1556  if(!sizeof($_POST["id"]))
1557  {
1558  ilUtil::sendFailure($this->lng->txt("select_one"), true);
1559  $ilCtrl->redirect($this, "manage");
1560  }
1561 
1562  if($this->view == self::VIEW_MY_OFFERS)
1563  {
1564  $question = $this->lng->txt("pd_info_delete_sure_remove");
1565  $cmd = "confirmedRemove";
1566  }
1567  else
1568  {
1569  $question = $this->lng->txt("pd_info_delete_sure_unsubscribe");
1570  $cmd = "confirmedUnsubscribe";
1571  }
1572 
1573  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1574  $cgui = new ilConfirmationGUI();
1575  $cgui->setHeaderText($question);
1576 
1577  $cgui->setFormAction($ilCtrl->getFormAction($this));
1578  $cgui->setCancel($this->lng->txt("cancel"), "manage");
1579  $cgui->setConfirm($this->lng->txt("confirm"), $cmd);
1580 
1581  foreach ($_POST["id"] as $ref_id)
1582  {
1583  $obj_id = ilObject::_lookupObjectId($ref_id);
1584  $title = ilObject::_lookupTitle($obj_id);
1585  $type = ilObject::_lookupType($obj_id);
1586 
1587  $cgui->addItem("ref_id[]", $ref_id, $title,
1588  ilObject::_getIcon($obj_id, "small", $type),
1589  $this->lng->txt("icon")." ".$this->lng->txt("obj_".$type));
1590  }
1591 
1592  return $cgui->getHTML();
1593  }
1594 
1595  public function confirmedRemove()
1596  {
1597  global $ilCtrl, $ilUser;
1598 
1599  if(!sizeof($_POST["ref_id"]))
1600  {
1601  $ilCtrl->redirect($this, "manage");
1602  }
1603 
1604  foreach($_POST["ref_id"] as $ref_id)
1605  {
1606  $type = ilObject::_lookupType($ref_id, true);
1607  ilObjUser::_dropDesktopItem($ilUser->getId(), $ref_id, $type);
1608  }
1609 
1610  ilUtil::sendSuccess($this->lng->txt("pd_remove_multi_confirm"), true);
1611  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
1612  }
1613 
1614  public function confirmedUnsubscribe()
1615  {
1616  global $ilCtrl, $ilAccess, $ilUser;
1617 
1618  if(!sizeof($_POST["ref_id"]))
1619  {
1620  $ilCtrl->redirect($this, "manage");
1621  }
1622 
1623  foreach($_POST["ref_id"] as $ref_id)
1624  {
1625  if($ilAccess->checkAccess("leave", "", $ref_id))
1626  {
1627  switch(ilObject::_lookupType($ref_id, true))
1628  {
1629  case "crs":
1630  // see ilObjCourseGUI:performUnsubscribeObject()
1631  include_once "Modules/Course/classes/class.ilCourseParticipants.php";
1632  $members = new ilCourseParticipants(ilObject::_lookupObjId($ref_id));
1633  $members->delete($ilUser->getId());
1634 
1635  $members->sendUnsubscribeNotificationToAdmins($ilUser->getId());
1636  $members->sendNotification(
1637  $members->NOTIFY_UNSUBSCRIBE,
1638  $ilUser->getId()
1639  );
1640  break;
1641 
1642  case "grp":
1643  // see ilObjGroupGUI:performUnsubscribeObject()
1644  include_once "Modules/Group/classes/class.ilGroupParticipants.php";
1645  $members = new ilGroupParticipants(ilObject::_lookupObjId($ref_id));
1646  $members->delete($ilUser->getId());
1647 
1648  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1649  $members->sendNotification(
1651  $ilUser->getId()
1652  );
1653  $members->sendNotification(
1655  $ilUser->getId()
1656  );
1657  break;
1658 
1659  default:
1660  // do nothing
1661  continue;
1662  }
1663 
1664  include_once './Modules/Forum/classes/class.ilForumNotification.php';
1665  ilForumNotification::checkForumsExistsDelete($ref_id, $ilUser->getId());
1666  }
1667  }
1668 
1669 
1670  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1671  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
1672  }
1673 }
1674 
1675 ?>