ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPDSelectedItemsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once('./Services/Table/classes/class.ilTable2GUI.php');
5 
14 {
15  public function __construct($a_parent_obj, $a_parent_cmd, array &$a_data, $a_view, $a_by_location = false)
16  {
17  global $ilCtrl, $tree, $ilUser;
18 
19  $this->setId("pdmng");
20  parent::__construct($a_parent_obj, $a_parent_cmd);
21 
22  $this->addColumn('','', '5%');
23  $this->addColumn($this->lng->txt("type"), 'type_caption', '1%');
24  $this->addColumn($this->lng->txt("title"), 'title', '44%');
25  $this->addColumn($this->lng->txt("container"), 'container', '50%');
26 
27  $this->setDefaultOrderField("title");
28 
29  $this->setRowTemplate("tpl.pd_manage_row.html", "Services/PersonalDesktop");
30 
31  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
32 
34  {
35  $this->setTitle($this->lng->txt("pd_my_offers"));
36  $this->addMultiCommand('confirmRemove', $this->lng->txt('unsubscribe'));
37  }
38  else
39  {
40  $this->setTitle($this->lng->txt("pd_my_memberships"));
41  $this->addMultiCommand('confirmRemove', $this->lng->txt('crs_unsubscribe'));
42  }
43 
44  $this->addCommandButton("getHTML", $this->lng->txt("cancel"));
45 
46  // root node caption
47  $root = $tree->getNodeData(ROOT_FOLDER_ID);
48  $root = $root["title"];
49  if ($root == "ILIAS")
50  {
51  $root = $this->lng->txt("repository");
52  }
53 
54  foreach($a_data as $idx => $item)
55  {
56  if(!$item["parent_ref"])
57  {
58  unset($a_data[$idx]);
59  continue;
60  }
61 
63  {
64  $a_data[$idx]["last_admin"] = false;
65 
66  switch($item["type"])
67  {
68  case "crs":
69  // see ilObjCourseGUI:performUnsubscribeObject()
70  include_once "Modules/Course/classes/class.ilCourseParticipants.php";
71  $members = new ilCourseParticipants($item["obj_id"]);
72  break;
73 
74  case "grp":
75  include_once "Modules/Group/classes/class.ilGroupParticipants.php";
76  $members = new ilGroupParticipants($item["obj_id"]);
77  break;
78 
79  default:
80  // do nothing?
81  continue;
82  }
83 
84  $a_data[$idx]["last_admin"] = $members->isLastAdmin($ilUser->getId());
85  }
86 
87  $a_data[$idx]["type_caption"] = $this->lng->txt("obj_".$item["type"]);
88 
89  // parent
90  if ($tree->getRootId() != $item["parent_ref"])
91  {
92  $a_data[$idx]["container"] = ilObject::_lookupTitle(ilObject::_lookupObjId($item["parent_ref"]));
93  }
94  else
95  {
96  $a_data[$idx]["container"] = $root;
97  }
98 
99  }
100 
101  $this->setData($a_data);
102  }
103 
104  public function fillRow($a_set)
105  {
106  if($a_set["last_admin"])
107  {
108  $this->tpl->setCurrentBlock("warning_bl");
109  $this->tpl->setVariable("TXT_WARNING", $this->lng->txt('pd_min_one_admin'));
110  $this->tpl->parseCurrentBlock();
111 
112  $this->tpl->setVariable("CHK_DISABLED", ' disabled="disabled"');
113  }
114 
115  $this->tpl->setVariable("VAL_REF_ID", $a_set["ref_id"]);
116  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
117  $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["desc"]);
118  $this->tpl->setVariable("URL_ICON", ilUtil::getTypeIconPath($a_set["type"], $a_set["obj_id"]));
119  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("icon")." ".$a_set["type_caption"]);
120  $this->tpl->setVariable("TXT_CONTAINER", $a_set["container"]);
121  }
122 }
123 
124 ?>