ILIAS  release_8 Revision v8.24
class.ilObjectOwnershipManagementTableGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
29{
31 protected ilTree $tree;
33 protected \ILIAS\UI\Factory $factory;
34 protected \ILIAS\UI\Renderer $renderer;
35
36 protected int $user_id;
37
38 public function __construct(?object $parent_obj, string $parent_cmd, int $user_id, array $data = null)
39 {
40 global $DIC;
41
42 $this->ctrl = $DIC->ctrl();
43 $this->lng = $DIC->language();
44 $this->access = $DIC->access();
45 $this->tree = $DIC->repositoryTree();
46 $this->obj_definition = $DIC["objDefinition"];
47 $this->renderer = $DIC->ui()->renderer();
48 $this->factory = $DIC->ui()->factory();
49
50 $this->user_id = $user_id;
51 $this->setId('objownmgmt'); // #16373
52
53 parent::__construct($parent_obj, $parent_cmd);
54
55 $this->addColumn($this->lng->txt("title"), "title");
56 $this->addColumn($this->lng->txt("path"), "path");
57 $this->addColumn($this->lng->txt("action"));
58
59 $this->setFormAction($this->ctrl->getFormAction($parent_obj, $parent_cmd));
60 $this->setRowTemplate("tpl.obj_ownership_row.html", "Services/Object");
62
63 $this->setDefaultOrderField("title");
64 $this->setDefaultOrderDirection("asc");
65
66 $this->initItems($data);
67 }
68
69 protected function initItems(?array $data): void
70 {
71 $process_arr = [];
72 $is_admin = false;
73 $a_type = "";
74 if (!is_null($data) && sizeof($data)) {
75 if (!$this->user_id) {
76 $is_admin = $this->access->checkAccess("visible", "", SYSTEM_FOLDER_ID);
77 }
78
79 foreach ($data as $id => $item) {
80 // workspace objects won't have references
82 if ($refs) {
83 foreach ($refs as $ref_id) {
84 // objects in trash are hidden
85 if (!$this->tree->isDeleted($ref_id)) {
86 if ($this->user_id) {
87 $readable = $this->access->checkAccessOfUser(
88 $this->user_id,
89 "read",
90 "",
91 $ref_id,
92 $a_type
93 );
94 } else {
95 $readable = $is_admin;
96 }
97
98 $process_arr[$ref_id] = [
99 "obj_id" => $id,
100 "ref_id" => $ref_id,
101 "type" => ilObject::_lookupType($id),
102 "title" => $item,
103 "path" => $this->buildPath($ref_id),
104 "readable" => $readable
105 ];
106 }
107 }
108 }
109 }
110 }
111
112 $this->setData($process_arr);
113 }
114
115 protected function fillRow(array $set): void
116 {
117 $icon = $this->factory->symbol()->icon()->standard($set["type"], $set["title"], Standard::MEDIUM);
118 $this->tpl->setVariable("ICON", $this->renderer->render($icon));
119
120 $this->tpl->setVariable("TITLE", strip_tags($set["title"], ilObjectGUI::ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION));
121 $this->tpl->setVariable("PATH", $set["path"]);
122
123 if ($set["readable"] && !$this->isParentReadOnly()) {
124 $this->tpl->setCurrentBlock("actions");
125 $this->tpl->setVariable("ACTIONS", $this->buildActions($set["ref_id"], $set["type"]));
126 $this->tpl->parseCurrentBlock();
127 }
128 }
129
130 protected function buildActions(int $ref_id, string $type): string
131 {
132 $agui = new ilAdvancedSelectionListGUI();
133 $agui->setId($this->id . "-" . $ref_id);
134 $agui->setListTitle($this->lng->txt("actions"));
135
136 $this->ctrl->setParameter($this->parent_obj, "ownid", $ref_id);
137
138 $agui->addItem(
139 $this->lng->txt("show"),
140 "",
141 ilLink::_getLink($ref_id, $type),
142 "",
143 "",
144 "_blank"
145 );
146
147 $agui->addItem(
148 $this->lng->txt("move"),
149 "",
150 $this->ctrl->getLinkTarget($this->parent_obj, "move")
151 );
152
153 $agui->addItem(
154 $this->lng->txt("change_owner"),
155 "",
156 $this->ctrl->getLinkTarget($this->parent_obj, "changeOwner")
157 );
158
159 if (!in_array($type, array("crsr", "catr", "grpr")) && $this->obj_definition->allowExport($type)) {
160 $agui->addItem(
161 $this->lng->txt("export"),
162 "",
163 $this->ctrl->getLinkTarget($this->parent_obj, "export")
164 );
165 }
166
167 $agui->addItem(
168 $this->lng->txt("delete"),
169 "",
170 $this->ctrl->getLinkTarget($this->parent_obj, "delete")
171 );
172
173 $this->ctrl->setParameter($this->parent_obj, "ownid", "");
174
175 return $agui->getHTML();
176 }
177
178 protected function buildPath(int $ref_id): string
179 {
180 $path = "...";
181 $counter = 0;
182 $path_full = $this->tree->getPathFull($ref_id);
183 foreach ($path_full as $data) {
184 if (++$counter < (count($path_full) - 2)) {
185 continue;
186 }
187 if ($ref_id != $data['ref_id']) {
188 $path .= " &raquo; " . $data['title'];
189 }
190 }
191
192 return $path;
193 }
194
195 protected function isParentReadOnly(): bool
196 {
197 if (!method_exists($this->parent_obj, 'isReadOnly')) {
198 return false;
199 }
200 return $this->parent_obj->isReadOnly();
201 }
202}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parses the objects.xml it handles the xml-description of all ilias objects
const ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
__construct(?object $parent_obj, string $parent_cmd, int $user_id, array $data=null)
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
setDisableFilterHiding(bool $a_val=true)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const SYSTEM_FOLDER_ID
Definition: constants.php:35
global $DIC
Definition: feed.php:28
This describes the specific behavior of an ILIAS standard icon.
Definition: Standard.php:27
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
$path
Definition: ltiservices.php:32
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type