ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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  $this->initItems($a_data);
41  }
42 
43  protected function initItems($a_data)
44  {
45  global $ilAccess, $tree;
46 
47  $data = array();
48 
49  if(sizeof($a_data))
50  {
51  if(!$this->user_id)
52  {
53  $is_admin = $ilAccess->checkAccess("visible", "", SYSTEM_FOLDER_ID);
54  }
55 
56  foreach($a_data as $id => $item)
57  {
58  // workspace objects won't have references
59  $refs = ilObject::_getAllReferences($id);
60  if($refs)
61  {
62  foreach($refs as $idx => $ref_id)
63  {
64  // objects in trash are hidden
65  if(!$tree->isDeleted($ref_id))
66  {
67  if($this->user_id)
68  {
69  $readable = $ilAccess->checkAccessOfUser($this->user_id, "read", "", $ref_id, $a_type);
70  }
71  else
72  {
73  $readable = $is_admin;
74  }
75 
76  $data[$ref_id] = array("obj_id" => $id,
77  "ref_id" => $ref_id,
78  "type" => ilObject::_lookupType($id),
79  "title" => $item,
80  "path" => $this->buildPath($ref_id),
81  "readable" => $readable);
82  }
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 ?>
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
__construct($a_parent_obj, $a_parent_cmd, $a_user_id, array $a_data=null)
setId($a_val)
Set id.
static _getAllReferences($a_id)
get all reference ids of object
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
static lookupTxt($a_mod_prefix, $a_pl_id, $a_lang_var)
Lookup language text.
Class ilTable2GUI.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static _lookupType($a_id, $a_reference=false)
lookup object type
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
$ref_id
Definition: sahs_server.php:39
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.