ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
4include_once ('./Services/Table/classes/class.ilTable2GUI.php');
5require_once('./Services/Repository/classes/class.ilObjectPlugin.php');
6
17{
18 protected $user_id; // [int]
19
20 public function __construct($a_parent_obj, $a_parent_cmd, $a_user_id, array $a_data = null)
21 {
22 global $ilCtrl, $lng;
23
24 $this->user_id = (int)$a_user_id;
25 $this->setId('objownmgmt'); // #16373
26
27 parent::__construct($a_parent_obj,$a_parent_cmd);
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 $this->initItems($a_data);
42 }
43
44 protected function initItems($a_data)
45 {
46 global $ilAccess, $tree;
47
48 $data = array();
49
50 if(sizeof($a_data))
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
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 = ilObjectPlugin::lookupTxtById($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", "grpr")) && $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?>
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
__construct($a_parent_obj, $a_parent_cmd, $a_user_id, array $a_data=null)
static lookupTxtById($plugin_id, $lang_var)
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilTable2GUI.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
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.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
$counter
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
$ref_id
Definition: sahs_server.php:39
$a_type
Definition: workflow.php:93