ILIAS  Release_4_2_x_branch Revision 61807
 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 
38  //$this->setImage(ilUtil::getImagePath("icon_bm_s.gif"));
39  $this->setEnableNumInfo(false);
40  $this->setLimit(99999);
41 // $this->setColSpan(2);
42  $this->setAvailableDetailLevels(3, 1);
43  $this->setBigMode(true);
44  $this->lng = $lng;
45  $this->allow_moving = false;
46 
47  $this->determineViewSettings();
48  }
49 
53  public function addToDeskObject()
54  {
55  global $ilCtrl;
56 
57  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
59  $ilCtrl->redirectByClass('ilpersonaldesktopgui', 'show');
60  }
61 
65  public function removeFromDeskObject()
66  {
67  global $ilCtrl;
68 
69  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
71  $ilCtrl->redirectByClass('ilpersonaldesktopgui', 'show');
72  }
73 
74 
80  public function changeView()
81  {
82  global $ilUser, $ilCtrl;
83 
84  if(in_array((int)$_GET['view'], $this->allowed_views))
85  {
86  $ilUser->writePref('pd_view', (int)$_GET['view']);
87  }
88  else
89  {
90  @reset($this->allowed_views);
91  $view = (int)@current($this->allowed_views);
92  $ilUser->writePref('pd_view', $view);
93  }
94 
95  $ilCtrl->redirectByClass('ilpersonaldesktopgui', 'show');
96  }
97 
103  protected function determineViewSettings()
104  {
105  global $ilSetting, $ilUser;
106 
107  $this->allowed_views = array();
108 
109  // determine view
110  if($ilSetting->get('disable_my_offers') == 1 &&
111  $ilSetting->get('disable_my_memberships') == 1)
112  {
113  // if both views are disabled set default view (should not occur but we should prevent it)
114  $ilSetting->set('personal_items_default_view', self::VIEW_MY_OFFERS);
115  $this->allowed_views[] = self::VIEW_MY_OFFERS;
116  }
117  // both views are enabled, get default view
118  else if($ilSetting->get('disable_my_offers') == 0 &&
119  $ilSetting->get('disable_my_memberships') == 0)
120  {
121  $this->allowed_views[] = self::VIEW_MY_OFFERS;
122  $this->allowed_views[] = self::VIEW_MY_MEMBERSHIPS;
123  }
124  else if($ilSetting->get('disable_my_offers') == 0 &&
125  $ilSetting->get('disable_my_memberships') == 1)
126  {
127  $this->allowed_views[] = self::VIEW_MY_OFFERS;
128  }
129  else
130  {
131  $this->allowed_views[] = self::VIEW_MY_MEMBERSHIPS;
132  }
133 
134  $this->view = $ilUser->getPref('pd_view');
135  if($this->view === false || !in_array((int)$this->view, $this->allowed_views))
136  {
137  $ilUser->writePref('pd_view', (int)$ilSetting->get('personal_items_default_view'));
138  $this->view = (int)$ilSetting->get('personal_items_default_view');
139  }
140  }
141 
147  static function getBlockType()
148  {
149  return self::$block_type;
150  }
151 
157  static function isRepositoryObject()
158  {
159  return false;
160  }
161 
162 
163  function getHTML()
164  {
165  global $ilCtrl, $ilSetting, $tpl, $lng;
166 
167  // both views are activated (show buttons)
168  if($ilSetting->get('disable_my_offers') == 0 &&
169  $ilSetting->get('disable_my_memberships') == 0)
170  {
171 /* $ilCtrl->setParameter($this, 'block_type', $this->getBlockType());
172  $ilCtrl->setParameter($this, 'view', self::VIEW_MY_OFFERS);
173  $this->addHeaderLink($ilCtrl->getLinkTarget($this, 'changeView'), $this->lng->txt('pd_my_offers'),
174  ($this->view == self::VIEW_MY_OFFERS ? false : true)
175  );
176  $ilCtrl->setParameter($this, 'view', self::VIEW_MY_MEMBERSHIPS);
177  $this->addHeaderLink($ilCtrl->getLinkTarget($this, 'changeView'), $this->lng->txt('pd_my_memberships'),
178  ($this->view == self::VIEW_MY_MEMBERSHIPS ? false : true)
179  );
180  $ilCtrl->clearParameters($this);*/
181  }
182 
183  // workaround to show details row
184  $this->setData(array("dummy"));
185 
186  include_once "Services/Object/classes/class.ilObjectListGUI.php";
187  ilObjectListGUI::prepareJSLinks("",
188  $ilCtrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
189  $ilCtrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false));
190 
191  switch((int)$this->view)
192  {
193  case self::VIEW_MY_MEMBERSHIPS:
194  if ($ilSetting->get('disable_my_offers') == 0)
195  {
196  $tpl->setTitle($lng->txt("my_courses_groups"));
197  }
198  $this->setTitle($this->lng->txt('pd_my_memberships'));
199  $this->setContent($this->getMembershipItemsBlockHTML());
200  break;
201 
202  case self::VIEW_MY_OFFERS:
203  default:
204  if(!in_array(self::VIEW_MY_MEMBERSHIPS, $this->allowed_views))
205  {
206  $this->setTitle($this->lng->txt('selected_items'));
207  }
208  else
209  {
210  $this->setTitle($this->lng->txt('pd_my_offers'));
211  }
212 
213  $this->setContent($this->getSelectedItemsBlockHTML());
214  break;
215  }
216 
217  if ($this->getContent() == "")
218  {
219  $this->setEnableDetailRow(false);
220  }
221  $ilCtrl->clearParametersByClass("ilpersonaldesktopgui");
222  $ilCtrl->clearParameters($this);
223  return parent::getHTML();
224  }
225 
229  function &executeCommand()
230  {
231  global $ilCtrl;
232 
233  $next_class = $ilCtrl->getNextClass();
234  $cmd = $ilCtrl->getCmd("getHTML");
235 
236  switch($next_class)
237  {
238  case "ilcommonactiondispatchergui":
239  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
241  $ilCtrl->forwardCommand($gui);
242  break;
243 
244  default:
245  if(method_exists($this, $cmd))
246  {
247  return $this->$cmd();
248  }
249  else
250  {
251  $cmd .= 'Object';
252  return $this->$cmd();
253  }
254  }
255  }
256 
257  function getContent()
258  {
259  return $this->content;
260  }
261 
262  function setContent($a_content)
263  {
264  $this->content = $a_content;
265  }
266 
270  function fillDataSection()
271  {
272  global $ilUser;
273 
274  if ($this->getContent() != "")
275  {
276  $this->tpl->setVariable("BLOCK_ROW", $this->getContent());
277  }
278  else
279  {
280  $this->setDataSection($this->getIntroduction());
281  }
282  }
283 
284 
288  function fillFooter()
289  {
290  global $ilCtrl, $lng, $ilUser;
291 
292  $this->setFooterLinks();
293  $this->fillFooterLinks();
294  $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
295  if ($this->tpl->blockExists("block_footer"))
296  {
297  $this->tpl->setCurrentBlock("block_footer");
298  $this->tpl->parseCurrentBlock();
299  }
300  }
301 
305  function setFooterLinks()
306  {
307  global $ilUser, $ilCtrl, $lng;
308 
309  if ($this->getContent() == "")
310  {
311  $this->setEnableNumInfo(false);
312  return "";
313  }
314 
315  // by type
316  if ($ilUser->getPref("pd_order_items") == 'location')
317  {
318  $this->addFooterLink( $lng->txt("by_type"),
319  $ilCtrl->getLinkTarget($this,
320  "orderPDItemsByType"),
321  $ilCtrl->getLinkTarget($this,
322  "orderPDItemsByType", "", true),
323  "block_".$this->getBlockType()."_".$this->block_id
324  );
325  }
326  else
327  {
328  $this->addFooterLink($lng->txt("by_type"));
329  }
330 
331  // by location
332  if ($ilUser->getPref("pd_order_items") == 'location')
333  {
334  $this->addFooterLink($lng->txt("by_location"));
335  }
336  else
337  {
338  $this->addFooterLink( $lng->txt("by_location"),
339  $ilCtrl->getLinkTarget($this,
340  "orderPDItemsByLocation"),
341  $ilCtrl->getLinkTarget($this,
342  "orderPDItemsByLocation", "", true),
343  "block_".$this->getBlockType()."_".$this->block_id
344  );
345  }
346  }
347 
354  protected function getObjectsByMembership($types = array())
355  {
356  global $tree, $ilUser, $ilObjDataCache;
357 
358  include_once 'Services/Membership/classes/class.ilParticipants.php';
359  $items = array();
360 
361  if(is_array($types) && count($types))
362  {
363  foreach($types as $type)
364  {
365  switch($type)
366  {
367  case 'grp':
368  $items = array_merge(ilParticipants::_getMembershipByType($ilUser->getId(), 'grp'), $items);
369  break;
370  case 'crs':
371  $items = array_merge(ilParticipants::_getMembershipByType($ilUser->getId(), 'crs'), $items);
372  break;
373  default:
374  break;
375  }
376  }
377  }
378  else
379  {
380  $crs_mbs = ilParticipants::_getMembershipByType($ilUser->getId(), 'crs');
381  $grp_mbs = ilParticipants::_getMembershipByType($ilUser->getId(), 'grp');
382  $items = array_merge($crs_mbs, $grp_mbs);
383  }
384 
385  $references = array();
386  foreach($items as $key => $obj_id)
387  {
388  $item_references = ilObject::_getAllReferences($obj_id);
389  if(is_array($item_references) && count($item_references))
390  {
391  foreach($item_references as $ref_id)
392  {
393  $title = $ilObjDataCache->lookupTitle($obj_id);
394  $type = $ilObjDataCache->lookupType($obj_id);
395 
396  $references[$title.$ref_id] =
397  array('ref_id' => $ref_id,
398  'obj_id' => $obj_id,
399  'type' => $type,
400  'title' => $title,
401  'description' => $ilObjDataCache->lookupDescription($obj_id),
402  'parent_ref' => $tree->getParentId($ref_id));
403  }
404  }
405  }
406  ksort($references);
407  return is_array($references) ? $references : array();
408  }
409 
417  {
418  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache, $rbacreview;
419 
420  $output = false;
421  $items = $this->getObjectsByMembership();
422  $item_html = array();
423  if(count($items) > 0)
424  {
425  // preload object data cache
426  $ref_ids = array();
427  foreach($items as $item)
428  {
429  $ref_ids[] = $item['ref_id'];
430  }
431  reset($items);
432  $ilObjDataCache->preloadReferenceCache($ref_ids);
433 
434  foreach($items as $item)
435  {
436  //echo "1";
437  // get list gui class for each object type
438  if ($cur_obj_type != $item["type"])
439  {
440  $item_list_gui =& $this->getItemListGUI($item["type"]);
441  if(!$item_list_gui)
442  {
443  continue;
444  }
445 
446  $item_list_gui->enableNotes(true);
447  $item_list_gui->enableComments(true);
448  $item_list_gui->enableTags(true);
449 
450  $item_list_gui->enableIcon(true);
451  $item_list_gui->enableDelete(false);
452  $item_list_gui->enableCut(false);
453  $item_list_gui->enableCopy(false);
454  $item_list_gui->enablePayment(false);
455  $item_list_gui->enableLink(false);
456  $item_list_gui->enableInfoScreen(false);
457  $item_list_gui->enableSubscribe(false);
458  if ($this->getCurrentDetailLevel() < 3)
459  {
460  //echo "3";
461  $item_list_gui->enableDescription(false);
462  $item_list_gui->enableProperties(false);
463  $item_list_gui->enablePreconditions(false);
464  }
465  if ($this->getCurrentDetailLevel() < 2)
466  {
467  $item_list_gui->enableCommands(true, true);
468  }
469  }
470  // render item row
471  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
472 
473  if (is_object($item_list_gui))
474  {
475  $html = $item_list_gui->getListItemHTML($item["ref_id"],
476  $item["obj_id"], $item["title"], $item["description"]);
477  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
478  if ($html != "")
479  {
480  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
481  $item_html[] = array(
482  "html" => $html,
483  "item_ref_id" => $item["ref_id"],
484  "item_obj_id" => $item["obj_id"],
485  "parent_ref" => $item["parent_ref"],
486  "type" => $item["type"],
487  'item_icon_image_type' => $item_list_gui->getIconImageType()
488  );
489  // END WebDAV: Use $item_list_gui to determine icon image type
490  }
491  }
492  }
493 
494  // output block for resource type
495  if (count($item_html) > 0)
496  {
497  $cur_parent_ref = 0;
498 
499  // content row
500  foreach($item_html as $item)
501  {
502  // add a parent header row for each new parent
503  if ($cur_parent_ref != $item["parent_ref"])
504  {
505  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
506  {
507  $this->addParentRow($tpl, $item["parent_ref"], false);
508  }
509  else
510  {
511  $this->addParentRow($tpl, $item["parent_ref"]);
512  }
513  $this->resetRowType();
514  $cur_parent_ref = $item["parent_ref"];
515  }
516 
517  // BEGIN WebDAV: Use $item_list_gui to determine icon image type.
518  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
519  $item['item_icon_image_type'],
520  "th_".$cur_parent_ref);
521  // END WebDAV: Use $item_list_gui to determine icon image type.
522  $output = true;
523  }
524  }
525  }
526 
527  return $output;
528  }
529 
537  {
538  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache;
539 
540  $output = false;
541 
542  $objtype_groups = $objDefinition->getGroupedRepositoryObjectTypes(
543  array("cat", "crs", "grp", "fold"));
544 
545  $types = array();
546  foreach($objtype_groups as $grp => $grpdata)
547  {
548  $types[] = array(
549  "grp" => $grp,
550  "title" => $this->lng->txt("objs_".$grp),
551  "types" => $grpdata["objs"]);
552  }
553 
554  foreach ($types as $t)
555  {
556  $type = $t["types"];
557  $title = $t["title"];
558  $grp = $t["grp"];
559 
560  $items = $this->getObjectsByMembership($type);
561 //var_dump($items);
562  // preload object data cache
563  $ref_ids = array();
564  foreach($items as $item)
565  {
566  $ref_ids[] = $item['ref_id'];
567  }
568  reset($items);
569  $ilObjDataCache->preloadReferenceCache($ref_ids);
570  $item_html = array();
571 
572  if ($this->getCurrentDetailLevel() == 3)
573  {
574  $rel_header = "th_".$grp;
575  }
576 
577  if (count($items) > 0)
578  {
579  $tstCount = 0;
580  $unsetCount = 0;
581  $progressCount = 0;
582  $unsetFlag = 0;
583  $progressFlag = 0;
584  $completedFlag = 0;
585  if (strcmp($a_type, "tst") == 0) {
586  $items = $this->multiarray_sort($items, "used_tries; title");
587  foreach ($items as $tst_item) {
588  if (!isset($tst_item["used_tries"])) {
589  $unsetCount++;
590  }
591  elseif ($tst_item["used_tries"] == 0) {
592  $progressCount++;
593  }
594  }
595  }
596 
597  foreach($items as $item)
598  {
599  // get list gui class for each object type
600  if ($cur_obj_type != $item["type"])
601  {
602  $class = $objDefinition->getClassName($item["type"]);
603  $location = $objDefinition->getLocation($item["type"]);
604  $full_class = "ilObj".$class."ListGUI";
605  include_once($location."/class.".$full_class.".php");
606  $item_list_gui = new $full_class();
607 
608  $item_list_gui->enableNotes(true);
609  $item_list_gui->enableComments(true);
610  $item_list_gui->enableTags(true);
611 
612  $item_list_gui->enableIcon(true);
613  $item_list_gui->enableDelete(false);
614  $item_list_gui->enableCut(false);
615  $item_list_gui->enableCopy(false);
616  $item_list_gui->enablePayment(false);
617  $item_list_gui->enableLink(false);
618  $item_list_gui->enableInfoScreen(false);
619  $item_list_gui->enableSubscribe(false);
620  if ($this->getCurrentDetailLevel() < 3)
621  {
622  $item_list_gui->enableDescription(false);
623  $item_list_gui->enableProperties(false);
624  $item_list_gui->enablePreconditions(false);
625  $item_list_gui->enableNoticeProperties(false);
626  }
627  if ($this->getCurrentDetailLevel() < 2)
628  {
629  $item_list_gui->enableCommands(true, true);
630  }
631  }
632  // render item row
633  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
634 
635  $html = $item_list_gui->getListItemHTML($item["ref_id"],
636  $item["obj_id"], $item["title"], $item["description"]);
637  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
638  if ($html != "")
639  {
640  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
641  $item_html[] = array(
642  "html" => $html,
643  "item_ref_id" => $item["ref_id"],
644  "item_obj_id" => $item["obj_id"],
645  'item_icon_image_type' => (method_exists($item_list_gui, 'getIconImageType')) ?
646  $item_list_gui->getIconImageType() :
647  $item['type']
648  );
649  // END WebDAV: Use $item_list_gui to determine icon image type
650  }
651  }
652 
653  // output block for resource type
654  if (count($item_html) > 0)
655  {
656  // add a header for each resource type
657  if ($this->getCurrentDetailLevel() == 3)
658  {
659  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
660  {
661  $this->addHeaderRow($tpl, $grp, false);
662  }
663  else
664  {
665  $this->addHeaderRow($tpl, $grp);
666  }
667  $this->resetRowType();
668  }
669 
670  // content row
671  foreach($item_html as $item)
672  {
673  if ($this->getCurrentDetailLevel() < 3 ||
674  $ilSetting->get("icon_position_in_lists") == "item_rows")
675  {
676  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
677  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
678  $item['item_icon_image_type'],
679  $rel_header);
680  // END WebDAV: Use $item_list_gui to determine icon image type
681  }
682  else
683  {
684  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], "", $rel_header);
685  }
686  $output = true;
687  }
688  }
689  }
690  }
691 
692  return $output;
693  }
694 
701  public function getMembershipItemsBlockHTML()
702  {
703  global $ilUser;
704 
705  $tpl = $this->newBlockTemplate();
706 
707  switch($ilUser->getPref('pd_order_items'))
708  {
709  case 'location':
711  break;
712 
713  default:
715  break;
716  }
717 
718  return $tpl->get();
719  }
720 
725  {
726  global $ilUser, $rbacsystem, $objDefinition, $ilBench;
727 
728  $tpl =& $this->newBlockTemplate();
729 
730  switch ($ilUser->getPref("pd_order_items"))
731  {
732  case "location":
734  break;
735 
736  default:
737  $ok = $this->getSelectedItemsPerType($tpl);
738  break;
739  }
740 
741  return $tpl->get();
742  }
743 
748  {
749  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache, $tree;
750 
751  $items = $ilUser->getDesktopItems();
752  if (count($items) > 0)
753  {
754  // preload object data cache
755  $ref_ids = array();
756  foreach($items as $item)
757  {
758  $ref_ids[] = $item["ref_id"];
759  }
760  $tree->preloadDeleted($ref_ids);
761  $tree->preloadDepthParent($ref_ids);
762  $ilObjDataCache->preloadReferenceCache($ref_ids, true);
763  }
764 
765  $output = false;
766 
767  $objtype_groups = $objDefinition->getGroupedRepositoryObjectTypes(
768  array("cat", "crs", "grp", "fold"));
769 
770  $types = array();
771  foreach($objtype_groups as $grp => $grpdata)
772  {
773  $types[] = array(
774  "grp" => $grp,
775  "title" => $this->lng->txt("objs_".$grp),
776  "types" => $grpdata["objs"]);
777  }
778 
779  foreach ($types as $t)
780  {
781 
782  $type = $t["types"];
783  $title = $t["title"];
784  $grp = $t["grp"];
785 
786  $items = $ilUser->getDesktopItems($type);
787  $item_html = array();
788 
789  if ($this->getCurrentDetailLevel() == 3)
790  {
791  $rel_header = "th_".$grp;
792  }
793 
794  if (count($items) > 0)
795  {
796  $tstCount = 0;
797  $unsetCount = 0;
798  $progressCount = 0;
799  $unsetFlag = 0;
800  $progressFlag = 0;
801  $completedFlag = 0;
802  if (strcmp($a_type, "tst") == 0) {
803  $items = $this->multiarray_sort($items, "used_tries; title");
804  foreach ($items as $tst_item) {
805  if (!isset($tst_item["used_tries"])) {
806  $unsetCount++;
807  }
808  elseif ($tst_item["used_tries"] == 0) {
809  $progressCount++;
810  }
811  }
812  }
813 
814  foreach($items as $item)
815  {
816  // get list gui class for each object type
817  if ($cur_obj_type != $item["type"])
818  {
819  $class = $objDefinition->getClassName($item["type"]);
820  $location = $objDefinition->getLocation($item["type"]);
821  $full_class = "ilObj".$class."ListGUI";
822  include_once($location."/class.".$full_class.".php");
823  $item_list_gui = new $full_class();
824 
825  $item_list_gui->enableNotes(true);
826  $item_list_gui->enableComments(true);
827  $item_list_gui->enableTags(true);
828 
829  $item_list_gui->enableIcon(true);
830  $item_list_gui->enableDelete(false);
831  $item_list_gui->enableCut(false);
832  $item_list_gui->enableCopy(false);
833  $item_list_gui->enablePayment(false);
834  $item_list_gui->enableLink(false);
835  $item_list_gui->enableInfoScreen(false);
836  $item_list_gui->setContainerObject($this);
837  if ($this->getCurrentDetailLevel() < 3)
838  {
839  $item_list_gui->enableDescription(false);
840  $item_list_gui->enableProperties(false);
841  $item_list_gui->enablePreconditions(false);
842  $item_list_gui->enableNoticeProperties(false);
843  }
844  if ($this->getCurrentDetailLevel() < 2)
845  {
846  $item_list_gui->enableCommands(true, true);
847  }
848  }
849  // render item row
850  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
851 
852  $html = $item_list_gui->getListItemHTML($item["ref_id"],
853  $item["obj_id"], $item["title"], $item["description"]);
854  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
855  if ($html != "")
856  {
857  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
858  $item_html[] = array(
859  "html" => $html,
860  "item_ref_id" => $item["ref_id"],
861  "item_obj_id" => $item["obj_id"],
862  'item_icon_image_type' => (method_exists($item_list_gui, 'getIconImageType')) ?
863  $item_list_gui->getIconImageType() :
864  $item['type']
865  );
866  // END WebDAV: Use $item_list_gui to determine icon image type
867  }
868  }
869 
870  // output block for resource type
871  if (count($item_html) > 0)
872  {
873  // add a header for each resource type
874  if ($this->getCurrentDetailLevel() == 3)
875  {
876  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
877  {
878  $this->addHeaderRow($tpl, $grp, false);
879  }
880  else
881  {
882  $this->addHeaderRow($tpl, $grp);
883  }
884  $this->resetRowType();
885  }
886 
887  // content row
888  foreach($item_html as $item)
889  {
890  if ($this->getCurrentDetailLevel() < 3 ||
891  $ilSetting->get("icon_position_in_lists") == "item_rows")
892  {
893  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
894  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
895  $item['item_icon_image_type'],
896  $rel_header);
897  // END WebDAV: Use $item_list_gui to determine icon image type
898  }
899  else
900  {
901  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], "", $rel_header);
902  }
903  $output = true;
904  }
905  }
906  }
907  }
908 
909  return $output;
910  }
911 
916  {
917  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache, $tree;
918 
919  $output = false;
920 
921  $items = $ilUser->getDesktopItems();
922  $item_html = array();
923  $cur_obj_type = "";
924 
925  if (count($items) > 0)
926  {
927  // preload object data cache
928  $ref_ids = array();
929  foreach($items as $item)
930  {
931  $ref_ids[] = $item["ref_id"];
932  }
933  reset($items);
934  $tree->preloadDeleted($ref_ids);
935  $tree->preloadDepthParent($ref_ids);
936  $ilObjDataCache->preloadReferenceCache($ref_ids);
937 
938  foreach($items as $item)
939  {
940  //echo "1";
941  // get list gui class for each object type
942  if ($cur_obj_type != $item["type"])
943  {
944  $item_list_gui =& $this->getItemListGUI($item["type"]);
945  if(!$item_list_gui)
946  {
947  continue;
948  }
949 
950  $item_list_gui->enableNotes(true);
951  $item_list_gui->enableComments(true);
952  $item_list_gui->enableTags(true);
953 
954  $item_list_gui->enableIcon(true);
955  $item_list_gui->enableDelete(false);
956  $item_list_gui->enableCut(false);
957  $item_list_gui->enableCopy(false);
958  $item_list_gui->enablePayment(false);
959  $item_list_gui->enableLink(false);
960  $item_list_gui->enableInfoScreen(false);
961  if ($this->getCurrentDetailLevel() < 3)
962  {
963  //echo "3";
964  $item_list_gui->enableDescription(false);
965  $item_list_gui->enableProperties(false);
966  $item_list_gui->enablePreconditions(false);
967  }
968  if ($this->getCurrentDetailLevel() < 2)
969  {
970  $item_list_gui->enableCommands(true, true);
971  }
972  }
973  // render item row
974  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
975  $item_list_gui->setContainerObject($this);
976  $html = $item_list_gui->getListItemHTML($item["ref_id"],
977  $item["obj_id"], $item["title"], $item["description"]);
978  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
979  if ($html != "")
980  {
981  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
982  $item_html[] = array(
983  "html" => $html,
984  "item_ref_id" => $item["ref_id"],
985  "item_obj_id" => $item["obj_id"],
986  "parent_ref" => $item["parent_ref"],
987  "type" => $item["type"],
988  'item_icon_image_type' => $item_list_gui->getIconImageType()
989  );
990  // END WebDAV: Use $item_list_gui to determine icon image type
991  }
992  }
993 
994  // output block for resource type
995  if (count($item_html) > 0)
996  {
997  $cur_parent_ref = 0;
998 
999  // content row
1000  foreach($item_html as $item)
1001  {
1002  // add a parent header row for each new parent
1003  if ($cur_parent_ref != $item["parent_ref"])
1004  {
1005  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
1006  {
1007  $this->addParentRow($tpl, $item["parent_ref"], false);
1008  }
1009  else
1010  {
1011  $this->addParentRow($tpl, $item["parent_ref"]);
1012  }
1013  $this->resetRowType();
1014  $cur_parent_ref = $item["parent_ref"];
1015  }
1016 
1017  // BEGIN WebDAV: Use $item_list_gui to determine icon image type.
1018  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
1019  $item['item_icon_image_type'],
1020  "th_".$cur_parent_ref);
1021  // END WebDAV: Use $item_list_gui to determine icon image type.
1022  $output = true;
1023  }
1024  }
1025  }
1026 
1027  return $output;
1028  }
1029 
1030  function resetRowType()
1031  {
1032  $this->cur_row_type = "";
1033  }
1034 
1041  function &newBlockTemplate()
1042  {
1043  $tpl = new ilTemplate ("tpl.pd_list_block.html", true, true, "Services/PersonalDesktop");
1044  $this->cur_row_type = "";
1045  return $tpl;
1046  }
1047 
1051  function &getItemListGUI($a_type)
1052  {
1053  global $objDefinition;
1054  //echo "<br>+$a_type+";
1055  if (!isset($this->item_list_guis[$a_type]))
1056  {
1057  $class = $objDefinition->getClassName($a_type);
1058  // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
1059  if(!$class)
1060  {
1061  return NULL;
1062  }
1063  // Fixed problem with deactivated plugins and existing repo. object plugin objects on the user's desktop
1064  $location = $objDefinition->getLocation($a_type);
1065  if(!$location)
1066  {
1067  return NULL;
1068  }
1069 
1070  $full_class = "ilObj".$class."ListGUI";
1071  //echo "<br>-".$location."/class.".$full_class.".php"."-";
1072  include_once($location."/class.".$full_class.".php");
1073  $item_list_gui = new $full_class();
1074  $this->item_list_guis[$a_type] =& $item_list_gui;
1075  }
1076  else
1077  {
1078  $item_list_gui =& $this->item_list_guis[$a_type];
1079  }
1080  return $item_list_gui;
1081  }
1082 
1090  function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
1091  {
1092  global $objDefinition;
1093 
1094  $icon = ilUtil::getImagePath("icon_".$a_type.".gif");
1095  if (!$objDefinition->isPlugin($a_type))
1096  {
1097  $title = $this->lng->txt("objs_".$a_type);
1098  }
1099  else
1100  {
1101  include_once("./Services/Component/classes/class.ilPlugin.php");
1102  $title =
1103  ilPlugin::lookupTxt("rep_robj", $a_type, "objs_".$a_type);
1104 
1105  }
1106  $header_id = "th_".$a_type;
1107 
1108  if ($a_show_image)
1109  {
1110  $a_tpl->setCurrentBlock("container_header_row_image");
1111  $a_tpl->setVariable("HEADER_IMG", $icon);
1112  $a_tpl->setVariable("HEADER_ALT", $title);
1113  }
1114  else
1115  {
1116  $a_tpl->setCurrentBlock("container_header_row");
1117  }
1118 
1119  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1120  $a_tpl->setVariable("BLOCK_HEADER_ID", $header_id);
1121  $a_tpl->parseCurrentBlock();
1122  $a_tpl->touchBlock("container_row");
1123  }
1124 
1132  function addParentRow(&$a_tpl, $a_ref_id, $a_show_image = true)
1133  {
1134  global $tree, $ilSetting;
1135 
1136  $par_id = ilObject::_lookupObjId($a_ref_id);
1137  $type = ilObject::_lookupType($par_id);
1138  if (!in_array($type, array("lm", "dbk", "sahs", "htlm")))
1139  {
1140  $icon = ilUtil::getImagePath("icon_".$type.".gif");
1141  }
1142  else
1143  {
1144  $icon = ilUtil::getImagePath("icon_lm.gif");
1145  }
1146 
1147  // custom icon
1148  if ($ilSetting->get("custom_icons") &&
1149  in_array($type, array("cat","grp","crs", "root")))
1150  {
1151  require_once("./Services/Container/classes/class.ilContainer.php");
1152  if (($path = ilContainer::_lookupIconPath($par_id, "small")) != "")
1153  {
1154  $icon = $path;
1155  }
1156  }
1157 
1158  if ($tree->getRootId() != $par_id)
1159  {
1160  $title = ilObject::_lookupTitle($par_id);
1161  }
1162  else
1163  {
1164  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
1165  $title = $nd["title"];
1166  if ($title == "ILIAS")
1167  {
1168  $title = $this->lng->txt("repository");
1169  }
1170  }
1171 
1172 /*
1173  $item_list_gui =& $this->getItemListGUI($type);
1174 
1175  $item_list_gui->enableIcon(false);
1176  $item_list_gui->enableDelete(false);
1177  $item_list_gui->enableCut(false);
1178  $item_list_gui->enablePayment(false);
1179  $item_list_gui->enableLink(false);
1180  $item_list_gui->enableDescription(false);
1181  $item_list_gui->enableProperties(false);
1182  $item_list_gui->enablePreconditions(false);
1183  $item_list_gui->enablePath(true);
1184  $item_list_gui->enableCommands(false);
1185  $html = $item_list_gui->getListItemHTML($a_ref_id,
1186  $par_id, $title, "");
1187 
1188  if ($a_show_image)
1189  {
1190  $a_tpl->setCurrentBlock("container_header_row_image");
1191  $a_tpl->setVariable("HEADER_IMG", $icon);
1192  $a_tpl->setVariable("HEADER_ALT", $title);
1193  }
1194 */
1195 // else
1196 // {
1197  $a_tpl->setCurrentBlock("container_header_row");
1198 // }
1199 
1200  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1201 /* $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $html);
1202  $a_tpl->setVariable("BLOCK_HEADER_ID", "th_".$a_ref_id);*/
1203  $a_tpl->parseCurrentBlock();
1204  $a_tpl->touchBlock("container_row");
1205  }
1206 
1214  function addStandardRow(&$a_tpl, $a_html, $a_item_ref_id = "", $a_item_obj_id = "",
1215  $a_image_type = "", $a_related_header = "")
1216  {
1217  global $ilSetting;
1218 
1219  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1220  ? "row_type_2"
1221  : "row_type_1";
1222  $a_tpl->touchBlock($this->cur_row_type);
1223 
1224  if ($a_image_type != "")
1225  {
1226  if (!is_array($a_image_type) && !in_array($a_image_type, array("lm", "dbk", "htlm", "sahs")))
1227  {
1228  $icon = ilUtil::getImagePath("icon_".$a_image_type.".gif");
1229  $title = $this->lng->txt("obj_".$a_image_type);
1230  }
1231  else
1232  {
1233  $icon = ilUtil::getImagePath("icon_lm.gif");
1234  $title = $this->lng->txt("learning_resource");
1235  }
1236 
1237  // custom icon
1238  if ($ilSetting->get("custom_icons") &&
1239  in_array($a_image_type, array("cat","grp","crs")))
1240  {
1241  require_once("./Services/Container/classes/class.ilContainer.php");
1242  if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "")
1243  {
1244  $icon = $path;
1245  }
1246  }
1247 
1248  $a_tpl->setCurrentBlock("block_row_image");
1249  $a_tpl->setVariable("ROW_IMG", $icon);
1250  $a_tpl->setVariable("ROW_ALT", $title);
1251  $a_tpl->parseCurrentBlock();
1252  }
1253  else
1254  {
1255  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1256  }
1257  $a_tpl->setCurrentBlock("container_standard_row");
1258  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
1259  $rel_headers = ($a_related_header != "")
1260  ? "th_selected_items ".$a_related_header
1261  : "th_selected_items";
1262  $a_tpl->setVariable("BLOCK_ROW_HEADERS", $rel_headers);
1263  $a_tpl->parseCurrentBlock();
1264  $a_tpl->touchBlock("container_row");
1265  }
1266 
1270  function getIntroduction()
1271  {
1272  global $ilUser, $lng, $ilCtrl, $tree;
1273 
1274  switch((int)$this->view)
1275  {
1276  case self::VIEW_MY_MEMBERSHIPS:
1277  $tpl = new ilTemplate('tpl.pd_my_memberships_intro.html', true, true, 'Services/PersonalDesktop');
1278  $tpl->setVariable('IMG_PD_LARGE', ilUtil::getImagePath('icon_pd_xxl.gif'));
1279  $tpl->setVariable('TXT_WELCOME', $lng->txt('pd_my_memberships_intro'));
1280  $tpl->setVariable('TXT_INTRO_1', $lng->txt('pd_my_memberships_intro2'));
1281  break;
1282 
1283  case self::VIEW_MY_OFFERS:
1284  default:
1285  // get repository link
1286  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
1287  $title = $nd["title"];
1288  if ($title == "ILIAS")
1289  {
1290  $title = $lng->txt("repository");
1291  }
1292 
1293  $tpl = new ilTemplate("tpl.pd_intro.html", true, true, "Services/PersonalDesktop");
1294  $tpl->setVariable("IMG_PD_LARGE", ilUtil::getImagePath("icon_pd_xxl.gif"));
1295  $tpl->setVariable("TXT_WELCOME", $lng->txt("pdesk_intro"));
1296  $tpl->setVariable("TXT_INTRO_1", sprintf($lng->txt("pdesk_intro2"), $lng->txt("to_desktop")));
1297  $tpl->setVariable("TXT_INTRO_2", sprintf($lng->txt("pdesk_intro3"),
1298  '<a href="repository.php?cmd=frameset&getlast=true">'.$title.'</a>'));
1299  $tpl->setVariable("TXT_INTRO_3", $lng->txt("pdesk_intro4"));
1300  break;
1301  }
1302 
1303  return $tpl->get();
1304  }
1305 
1310  {
1311  global $ilUser, $ilCtrl;
1312 
1313  $ilUser->writePref("pd_order_items", "location");
1314 
1315  if ($ilCtrl->isAsynch())
1316  {
1317  echo $this->getHTML();
1318  exit;
1319  }
1320  else
1321  {
1322  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
1323  }
1324  }
1325 
1330  {
1331  global $ilUser, $ilCtrl;
1332 
1333  $ilUser->writePref("pd_order_items", "type");
1334 
1335  if ($ilCtrl->isAsynch())
1336  {
1337  echo $this->getHTML();
1338  exit;
1339  }
1340  else
1341  {
1342  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
1343  }
1344  }
1345 
1346 }
1347 
1348 ?>