ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjectOwnershipManagementTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once ('./Services/Table/classes/class.ilTable2GUI.php');
5 
16 {
17  protected $user_id; // [int]
18 
19  public function __construct($a_parent_obj, $a_parent_cmd, $a_user_id, array $a_data = null)
20  {
21  global $ilCtrl, $lng;
22 
23  $this->user_id = (int)$a_user_id;
24  $this->setId('objownmgmt'); // #16373
25 
26  parent::__construct($a_parent_obj,$a_parent_cmd);
27 
28  $this->addColumn($lng->txt("title"), "title");
29  $this->addColumn($lng->txt("path"), "path");
30  $this->addColumn($lng->txt("action"), "");
31 
32  // $this->setTitle($this->lng->txt(''));
33  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
34  $this->setRowTemplate("tpl.obj_ownership_row.html", "Services/Object");
35  $this->setDisableFilterHiding(true);
36 
37  $this->setDefaultOrderField("title");
38  $this->setDefaultOrderDirection("asc");
39 
40  if($a_data)
41  {
42  $this->initItems($a_data);
43  }
44  }
45 
46  protected function initItems($a_data)
47  {
48  global $ilAccess, $lng, $tree;
49 
50  $data = array();
51 
52  if(!$this->user_id)
53  {
54  $is_admin = $ilAccess->checkAccess("visible", "", SYSTEM_FOLDER_ID);
55  }
56 
57  foreach($a_data as $id => $item)
58  {
59  // workspace objects won't have references
60  $refs = ilObject::_getAllReferences($id);
61  if($refs)
62  {
63  foreach($refs as $idx => $ref_id)
64  {
65  // objects in trash are hidden
66  if(!$tree->isDeleted($ref_id))
67  {
68  if($this->user_id)
69  {
70  $readable = $ilAccess->checkAccessOfUser($this->user_id, "read", "", $ref_id, $a_type);
71  }
72  else
73  {
74  $readable = $is_admin;
75  }
76 
77  $data[$ref_id] = array("obj_id" => $id,
78  "ref_id" => $ref_id,
79  "type" => ilObject::_lookupType($id),
80  "title" => $item,
81  "path" => $this->buildPath($ref_id),
82  "readable" => $readable);
83  }
84  }
85  }
86  }
87 
88  $this->setData($data);
89  }
90 
91  public function fillRow($row)
92  {
93  global $lng, $objDefinition;
94 
95  // #11050
96  if(!$objDefinition->isPlugin($row["type"]))
97  {
98  $txt_type = $lng->txt("obj_".$row["type"]);
99  }
100  else
101  {
102  include_once("./Services/Component/classes/class.ilPlugin.php");
103  $txt_type = ilPlugin::lookupTxt("rep_robj", $row["type"], "obj_".$row["type"]);
104  }
105 
106  $this->tpl->setVariable("TITLE", $row["title"]);
107  $this->tpl->setVariable("ALT_ICON", $txt_type);
108  $this->tpl->setVariable("SRC_ICON", ilObject::_getIcon("", "tiny", $row["type"]));
109  $this->tpl->setVariable("PATH", $row["path"]);
110 
111  if($row["readable"])
112  {
113  $this->tpl->setCurrentBlock("actions");
114  $this->tpl->setVariable("ACTIONS", $this->buildActions($row["ref_id"], $row["type"]));
115  $this->tpl->parseCurrentBlock();
116  }
117  }
118 
119  protected function buildActions($a_ref_id, $a_type)
120  {
121  global $lng, $ilCtrl, $objDefinition;
122 
123  include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
124  $agui = new ilAdvancedSelectionListGUI();
125  $agui->setId($this->id."-".$a_ref_id);
126  $agui->setListTitle($lng->txt("actions"));
127 
128  $ilCtrl->setParameter($this->parent_obj, "ownid", $a_ref_id);
129 
130  include_once "Services/Link/classes/class.ilLink.php";
131  $agui->addItem($lng->txt("show"), "",
132  ilLink::_getLink($a_ref_id, $a_type),
133  "", "", "_blank");
134 
135  $agui->addItem($lng->txt("move"), "",
136  $ilCtrl->getLinkTarget($this->parent_obj, "move"),
137  "", "", "");
138 
139  $agui->addItem($lng->txt("change_owner"), "",
140  $ilCtrl->getLinkTarget($this->parent_obj, "changeOwner"),
141  "", "", "");
142 
143  if(!in_array($a_type, array("crsr", "catr")) && $objDefinition->allowExport($a_type))
144  {
145  $agui->addItem($lng->txt("export"), "",
146  $ilCtrl->getLinkTarget($this->parent_obj, "export"),
147  "", "", "");
148  }
149 
150  $agui->addItem($lng->txt("delete"), "",
151  $ilCtrl->getLinkTarget($this->parent_obj, "delete"),
152  "", "", "");
153 
154  $ilCtrl->setParameter($this->parent_obj, "ownid", "");
155 
156  return $agui->getHTML();
157  }
158 
159  protected function buildPath($a_ref_id)
160  {
161  global $tree;
162 
163  $path = "...";
164  $counter = 0;
165  $path_full = $tree->getPathFull($a_ref_id);
166  foreach($path_full as $data)
167  {
168  if(++$counter < (count($path_full)-2))
169  {
170  continue;
171  }
172  if($a_ref_id != $data['ref_id'])
173  {
174  $path .= " &raquo; ".$data['title'];
175  }
176  }
177 
178  return $path;
179  }
180 }
181 
182 ?>