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