ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilWorkspaceShareTableGUI.php
Go to the documentation of this file.
1<?php
2
20
27{
29 protected ilObjUser $user;
31 protected ?int $parent_node_id = null;
32 protected array $filter;
33 protected array $crs_ids;
34 protected array $grp_ids;
35 protected bool $portfolio_mode = false;
37 protected \ILIAS\UI\Factory $ui_factory;
38 protected \ILIAS\UI\Renderer $renderer;
39
40 public function __construct(
41 object $a_parent_obj,
42 string $a_parent_cmd,
44 ?int $a_parent_node_id = null,
45 bool $a_load_data = false
46 ) {
47 global $DIC;
48 $main_tpl = $DIC->ui()->mainTemplate();
49
50 $this->ui_factory = $DIC->ui()->factory();
51 $this->renderer = $DIC->ui()->renderer();
52
53 $this->ctrl = $DIC->ctrl();
54 $this->lng = $DIC->language();
55 $this->settings = $DIC->settings();
56 $this->user = $DIC->user();
57 $ilCtrl = $DIC->ctrl();
58 $lng = $DIC->language();
59 $this->handler = $a_handler;
60 $this->std_request = new StandardGUIRequest(
61 $DIC->http(),
62 $DIC->refinery()
63 );
64
65 $this->parent_node_id = 0;
66
67 if (stristr(get_class($a_parent_obj), "portfolio")) {
68 $this->parent_node_id = (int) $a_parent_node_id;
69 $this->portfolio_mode = true;
70 }
71
72 parent::__construct($a_parent_obj, $a_parent_cmd);
73
74 $this->setId("il_tbl_wspsh" . (int) $this->portfolio_mode);
75
76 $this->setTitle($lng->txt("wsp_shared_resources"));
77
78 $this->addColumn($this->lng->txt("lastname"), "lastname");
79 $this->addColumn($this->lng->txt("firstname"), "firstname");
80 $this->addColumn($this->lng->txt("login"), "login");
81
82 if (!$this->portfolio_mode) {
83 $this->addColumn($this->lng->txt("wsp_shared_object_type"), "obj_type");
84 }
85
86 $this->addColumn($this->lng->txt("wsp_shared_date"), "acl_date");
87 $this->addColumn($this->lng->txt("wsp_shared_title"), "title");
88 $this->addColumn($this->lng->txt("wsp_shared_type"));
89
90 //if (!$this->portfolio_mode) {
91 $this->addColumn($this->lng->txt("action"));
92 //}
93
94 $this->setDefaultOrderField("acl_date");
95 $this->setDefaultOrderDirection("desc");
96
97 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
98 $this->setRowTemplate("tpl.shared_row.html", "components/ILIAS/PersonalWorkspace");
99
100 $this->setDisableFilterHiding(true);
101 $this->setResetCommand("resetsharefilter", $this->lng->txt("wsp_shared_filter_reset_button"));
102 $this->setFilterCommand("applysharefilter", $this->lng->txt("wsp_shared_filter_button"));
103
104 $this->initFilter();
105
106 // reset will remove all filters
107 if ($this->portfolio_mode &&
108 !$this->filter["obj_type"]) {
109 $this->filter["obj_type"] = "prtf";
110 }
111
112 // see #38253
113 if ((isset($this->filter["user"]) && $this->filter["user"] !== "") ||
114 (isset($this->filter["title"]) && $this->filter["title"] !== "") ||
115 (isset($this->filter["acl_type"]) && $this->filter["acl_type"] !== "") ||
116 (isset($this->filter["acl_date"]) && $this->filter["acl_date"] !== "")) {
117 $a_load_data = true;
118 }
119
120 // incoming request: check for validity
121 if ($a_load_data) {
122 /*
123 if(($this->filter["user"] && strlen($this->filter["user"]) > 3) ||
124 ($this->filter["title"] && strlen($this->filter["title"]) > 3) ||
125 $this->filter["acl_date"] ||
126 $this->filter["obj_type"] ||
127 $this->filter["acl_type"] ||
128 $this->filter["crsgrp"])
129 {
130 */
131
132 // #16630
133 $this->importData();
134 return;
135 } else {
136 //$main_tpl->setOnScreenMessage('info', $lng->txt("wsp_shared_mandatory_filter_info"));
137 }
138
139 // initial state: show filters only
140 $this->disable("header");
141 $this->disable("content");
142 }
143
144 public function initFilter(): void
145 {
148 $ilUser = $this->user;
149
150 $this->crs_ids = ilParticipants::_getMembershipByType($ilUser->getId(), ["crs"]);
151 $this->grp_ids = ilParticipants::_getMembershipByType($ilUser->getId(), ["grp"]);
152
153 $lng->loadLanguageModule("search");
154
155 $item = $this->addFilterItemByMetaType("user", self::FILTER_TEXT, false, $lng->txt("wsp_shared_user_filter"));
156 $this->filter["user"] = $item->getValue();
157
158 // incoming back link (shared)
159 $form_sess = ilSession::get("form_" . $this->getId());
160 if ($this->std_request->getShareId() &&
161 !is_array($form_sess) && // #17747
162 !$this->filter["user"]) {
163 $this->filter["user"] = ilObjUser::_lookupName($this->std_request->getShareId());
164 $this->filter["user"] = $this->filter["user"]["login"];
165 $item->setValue($this->filter["user"]);
166 }
167
168 $item = $this->addFilterItemByMetaType("title", self::FILTER_TEXT, false, $lng->txt("wsp_shared_title"));
169 $this->filter["title"] = $item->getValue();
170
171 $item = $this->addFilterItemByMetaType("acl_date", self::FILTER_DATE, false, $lng->txt("wsp_shared_date_filter"));
172 $this->filter["acl_date"] = $item->getDate();
173
174 if (!$this->portfolio_mode) {
175 // see ilPersonalWorkspaceGUI::renderToolbar
176 $options = array("" => $lng->txt("search_any"));
177 $settings_map = array("blog" => "blogs",
178 "file" => "files");
179 // see ilObjWorkspaceFolderTableGUI
180 foreach (array("file", "blog") as $type) {
181 if (isset($settings_map[$type]) && $ilSetting->get("disable_wsp_" . $settings_map[$type])) {
182 continue;
183 }
184 $options[$type] = $lng->txt("wsp_type_" . $type);
185 }
186 } else {
187 $options = array("prtf" => $lng->txt("obj_prtf"));
188 }
189 if (count($options) > 0) {
190 asort($options);
191 $item = $this->addFilterItemByMetaType("obj_type", self::FILTER_SELECT, false, $lng->txt("wsp_shared_object_type"));
192 $item->setOptions($options);
193 $this->filter["obj_type"] = $item->getValue();
194 }
195
196 // see ilWorkspaceAccessGUI::share
197 $options = array();
198 $options["user"] = $lng->txt("wsp_set_permission_single_user");
199
200 if (sizeof($this->grp_ids)) {
201 $options["group"] = $lng->txt("wsp_set_permission_group");
202 }
203
204 if (sizeof($this->crs_ids)) {
205 $options["course"] = $lng->txt("wsp_set_permission_course");
206 }
207
208 if (!$this->handler->hasRegisteredPermission($this->parent_node_id)) {
209 $options["registered"] = $lng->txt("wsp_set_permission_registered");
210 }
211
212 if ($ilSetting->get("enable_global_profiles")) {
213 if (!$this->handler->hasGlobalPasswordPermission($this->parent_node_id)) {
214 $options["password"] = $this->lng->txt("wsp_set_permission_all_password");
215 }
216
217 if (!$this->handler->hasGlobalPermission($this->parent_node_id)) {
218 $options["all"] = $this->lng->txt("wsp_set_permission_all");
219 }
220 }
221
222 if (count($options) > 0) {
223 $item = $this->addFilterItemByMetaType("acl_type", self::FILTER_SELECT, false, $lng->txt("wsp_shared_type"));
224 $item->setOptions(array("" => $lng->txt("search_any")) + $options);
225 $this->filter["acl_type"] = $item->getValue();
226 }
227
228 if (sizeof($this->crs_ids) || sizeof($this->grp_ids)) {
229 $options = array();
230 foreach ($this->crs_ids as $crs_id) {
231 $options[$crs_id] = $lng->txt("obj_crs") . " " . ilObject::_lookupTitle($crs_id);
232 }
233 foreach ($this->grp_ids as $grp_id) {
234 $options[$grp_id] = $lng->txt("obj_grp") . " " . ilObject::_lookupTitle($grp_id);
235 }
236 asort($options);
237 $item = $this->addFilterItemByMetaType("crsgrp", self::FILTER_SELECT, false, $lng->txt("wsp_shared_member_filter"));
238 $item->setOptions(array("" => $lng->txt("search_any")) + $options);
239 $this->filter["crsgrp"] = $item->getValue();
240 }
241 }
242
243 protected function importData(): void
244 {
246
247 $data = array();
248
249 $user_data = array();
250
251 $objects = $this->handler->findSharedObjects($this->filter, $this->crs_ids, $this->grp_ids);
252 if ($objects) {
253 foreach ($objects as $wsp_id => $item) {
254 if (!isset($user_data[$item["owner"]])) {
255 $user_data[$item["owner"]] = ilObjUser::_lookupName($item["owner"]);
256 }
257
258 // #18535 - deleted user?
259 if (!$user_data[$item["owner"]]["login"]) {
260 continue;
261 }
262 $data[] = array(
263 "wsp_id" => $wsp_id,
264 "obj_id" => $item["obj_id"],
265 "type" => $item["type"] ?? "",
266 "obj_type" => $lng->txt("wsp_type_" . ($item["type"] ?? "")),
267 "title" => $item["title"],
268 "owner_id" => $item["owner"],
269 "lastname" => $user_data[$item["owner"]]["lastname"],
270 "firstname" => $user_data[$item["owner"]]["firstname"],
271 "login" => $user_data[$item["owner"]]["login"],
272 "acl_type" => $item["acl_type"],
273 "acl_date" => $item["acl_date"]
274 );
275 }
276 }
277
278 $this->setData($data);
279 }
280
284 protected function fillRow(array $a_set): void
285 {
286 $ilCtrl = $this->ctrl;
288 $this->tpl->setVariable("LASTNAME", $a_set["lastname"]);
289 $this->tpl->setVariable("FIRSTNAME", $a_set["firstname"]);
290 $this->tpl->setVariable("LOGIN", $a_set["login"]);
291
292 $this->tpl->setVariable("TITLE", $a_set["title"]);
293
294 if (!$this->portfolio_mode) {
295 $icon = $this->ui_factory->symbol()->icon()->standard($a_set["type"], "");
296 $this->tpl->setVariable("ICON", $this->renderer->render($icon));
297 $this->tpl->setVariable("TYPE", $a_set["obj_type"]);
298 $url = $this->handler->getGotoLink($a_set["wsp_id"], $a_set["obj_id"]);
299 } else {
300 $url = ilLink::_getStaticLink($a_set["obj_id"], "prtf", true);
301 }
302 $this->tpl->setVariable("URL_TITLE", $url);
303
304 $this->tpl->setVariable(
305 "ACL_DATE",
307 );
308
309 asort($a_set["acl_type"]);
310 foreach ($a_set["acl_type"] as $obj_id) {
311 // see ilWorkspaceAccessTableGUI
312 switch ($obj_id) {
314 $title = $icon_alt = $this->lng->txt("wsp_set_permission_registered");
315 $type = "registered";
316 break;
317
319 $title = $icon_alt = $this->lng->txt("wsp_set_permission_all_password");
320 $type = "all_password";
321 break;
322
324 $title = $icon_alt = $this->lng->txt("wsp_set_permission_all");
325 $type = "all_password";
326 break;
327
328 default:
329 $type = ilObject::_lookupType($obj_id);
330 if ($type != "usr") {
332 } else {
333 $title = ilUserUtil::getNamePresentation($obj_id, false, true);
334 }
335 break;
336 }
337
338 $this->tpl->setCurrentBlock("acl_type_bl");
339 $this->tpl->setVariable("ACL_TYPE", $title);
340 $this->tpl->parseCurrentBlock();
341 }
342
343 if (!$this->portfolio_mode) {
344 // files may be copied to own workspace
345 if ($a_set["type"] == "file") {
346 $ilCtrl->setParameter(
347 $this->parent_obj,
348 "wsp_id",
349 $this->parent_node_id
350 );
351 $ilCtrl->setParameter(
352 $this->parent_obj,
353 "item_ref_id",
354 $a_set["wsp_id"]
355 );
356 $url = $ilCtrl->getLinkTarget($this->parent_obj, "copyshared");
357
358 $this->tpl->setCurrentBlock("action_bl");
359 $this->tpl->setVariable("URL_ACTION", $url);
360 $this->tpl->setVariable("ACTION", $lng->txt("copy"));
361 $this->tpl->parseCurrentBlock();
362 } else {
363 $this->tpl->touchBlock("action_col_bl");
364 }
365 } else {
366 $ilCtrl->setParameter($this->parent_obj, "owner_id", $a_set["owner_id"]);
367 $ilCtrl->setParameter($this->parent_obj, "prt_id", $a_set["obj_id"]);
368 $b = $this->ui_factory->button()->shy(
369 $this->lng->txt("wsp_send_mail"),
370 $ilCtrl->getLinkTarget($this->parent_obj, "redirectSendMailToSharer")
371 );
372 $dd = $this->ui_factory->dropdown()->standard([$b]);
373 $this->tpl->setCurrentBlock("action_bl");
374 $this->tpl->setVariable("ACTION_DD", $this->renderer->render($dd));
375 $this->tpl->parseCurrentBlock();
376 }
377 }
378}
renderer()
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
User class.
static _lookupName(int $a_user_id)
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
static _getMembershipByType(int $a_usr_id, array $a_type, bool $a_only_member_role=false)
get membership by type Get course or group membership
Access handler for portfolio NOTE: This file needs to stay in the classes directory,...
static get(string $a_var)
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFilterCommand(string $a_val, string $a_caption="")
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
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)
ilGlobalTemplateInterface $main_tpl
setDisableFilterHiding(bool $a_val=true)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setResetCommand(string $a_val, string $a_caption="")
setData(array $a_data)
Set table data.
ilLanguage $lng
disable(string $a_module_name)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Workspace share handler table GUI class.
ilWorkspaceAccessHandler ilPortfolioAccessHandler $handler
__construct(object $a_parent_obj, string $a_parent_cmd, ilWorkspaceAccessHandler|ilPortfolioAccessHandler $a_handler, ?int $a_parent_node_id=null, bool $a_load_data=false)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, array $class_path, string $cmd, bool $activated=true, bool $expanded=true)
global $ilSetting
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68