ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilWorkspaceShareTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 2010 Leifos, GPL, see docs/LICENSE */
3
4include_once("./Services/Table/classes/class.ilTable2GUI.php");
5
15{
16 protected $handler; // [ilWorkspaceAccessHandler]
17 protected $parent_node_id; // [int]
18 protected $filter; // [array]
19 protected $crs_ids; // [array]
20 protected $grp_ids; // [array]
21 protected $portfolio_mode = false; // [bool]
22
32 function __construct($a_parent_obj, $a_parent_cmd, $a_handler, $a_parent_node_id = null, $a_load_data = false)
33 {
34 global $ilCtrl, $lng;
35
36 $this->handler = $a_handler;
37
38 if(stristr(get_class($a_parent_obj), "portfolio"))
39 {
40 $this->parent_node_id = $a_parent_node_id;
41 $this->portfolio_mode = true;
42 }
43
44 parent::__construct($a_parent_obj, $a_parent_cmd);
45
46 $this->setId("il_tbl_wspsh");
47
48 $this->setTitle($lng->txt("wsp_shared_resources"));
49
50 $this->addColumn($this->lng->txt("lastname"), "lastname");
51 $this->addColumn($this->lng->txt("firstname"), "firstname");
52 $this->addColumn($this->lng->txt("login"), "login");
53
54 if(!$this->portfolio_mode)
55 {
56 $this->addColumn($this->lng->txt("wsp_shared_object_type"), "obj_type");
57 }
58
59 $this->addColumn($this->lng->txt("wsp_shared_date"), "acl_date");
60 $this->addColumn($this->lng->txt("wsp_shared_title"), "title");
61 $this->addColumn($this->lng->txt("wsp_shared_type"));
62
63 if(!$this->portfolio_mode)
64 {
65 $this->addColumn($this->lng->txt("action"));
66 }
67
68 $this->setDefaultOrderField("acl_date");
69 $this->setDefaultOrderDirection("desc");
70
71 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
72 $this->setRowTemplate("tpl.shared_row.html", "Services/PersonalWorkspace");
73
74 $this->setDisableFilterHiding(true);
75 $this->setResetCommand("resetsharefilter", $this->lng->txt("wsp_shared_filter_reset_button"));
76 $this->setFilterCommand("applysharefilter", $this->lng->txt("wsp_shared_filter_button"));
77
78 $this->initFilter();
79
80 // reset will remove all filters
81 if($this->portfolio_mode &&
82 !$this->filter["obj_type"])
83 {
84 $this->filter["obj_type"] = "prtf";
85 }
86
87 if($a_load_data)
88 {
89 /*
90 if(($this->filter["user"] && strlen($this->filter["user"]) > 3) ||
91 ($this->filter["title"] && strlen($this->filter["title"]) > 3) ||
92 $this->filter["acl_date"] ||
93 $this->filter["obj_type"] ||
94 $this->filter["acl_type"] ||
95 $this->filter["crsgrp"])
96 {
97 */
98
99 // #16630
100 $this->importData();
101 include_once "Services/User/classes/class.ilUserUtil.php";
102 return;
103 }
104 else
105 {
106 ilUtil::sendInfo($lng->txt("wsp_shared_mandatory_filter_info"));
107 }
108
109 // initial state: show filters only
110 $this->disable("header");
111 $this->disable("content");
112 }
113
114 public function initFilter()
115 {
116 global $lng, $ilSetting, $ilUser;
117
118 include_once "Services/Membership/classes/class.ilParticipants.php";
119 $this->crs_ids = ilParticipants::_getMembershipByType($ilUser->getId(), "crs");
120 $this->grp_ids = ilParticipants::_getMembershipByType($ilUser->getId(), "grp");
121
122 $lng->loadLanguageModule("search");
123
124 $item = $this->addFilterItemByMetaType("user", self::FILTER_TEXT, false, $lng->txt("wsp_shared_user_filter"));
125 $this->filter["user"] = $item->getValue();
126
127 // incoming back link (shared)
128 if((int)$_REQUEST["shr_id"] &&
129 !is_array($_SESSION["form_".$this->getId()]) && // #17747
130 !$this->filter["user"])
131 {
132 $this->filter["user"] = ilObjUser::_lookupName((int)$_REQUEST["shr_id"]);
133 $this->filter["user"] = $this->filter["user"]["login"];
134 $item->setValue($this->filter["user"]);
135 }
136
137 $item = $this->addFilterItemByMetaType("title", self::FILTER_TEXT, false, $lng->txt("wsp_shared_title"));
138 $this->filter["title"] = $item->getValue();
139
140 $item = $this->addFilterItemByMetaType("acl_date", self::FILTER_DATE, false, $lng->txt("wsp_shared_date_filter"));
141 $this->filter["acl_date"] = $item->getDate();
142
143 if(!$this->portfolio_mode)
144 {
145 // see ilPersonalWorkspaceGUI::renderToolbar
146 $options = array(""=>$lng->txt("search_any"));
147 $settings_map = array("blog" => "blogs",
148 "file" => "files");
149 // see ilObjWorkspaceFolderTableGUI
150 foreach(array("file", "blog") as $type)
151 {
152 if(isset($settings_map[$type]) && $ilSetting->get("disable_wsp_".$settings_map[$type]))
153 {
154 continue;
155 }
156 $options[$type] = $lng->txt("wsp_type_".$type);
157 }
158 }
159 else
160 {
161 $options = array("prtf"=>$lng->txt("obj_prtf"));
162 }
163 if(sizeof($options))
164 {
165 asort($options);
166 $item = $this->addFilterItemByMetaType("obj_type", self::FILTER_SELECT, false, $lng->txt("wsp_shared_object_type"));
167 $item->setOptions($options);
168 $this->filter["obj_type"] = $item->getValue();
169 }
170
171 // see ilWorkspaceAccessGUI::share
172 $options = array();
173 $options["user"] = $lng->txt("wsp_set_permission_single_user");
174
175 if(sizeof($this->grp_ids))
176 {
177 $options["group"] = $lng->txt("wsp_set_permission_group");
178 }
179
180 if(sizeof($this->crs_ids))
181 {
182 $options["course"] = $lng->txt("wsp_set_permission_course");
183 }
184
185 if(!$this->handler->hasRegisteredPermission($this->parent_node_id))
186 {
187 $options["registered"] = $lng->txt("wsp_set_permission_registered");
188 }
189
190 if($ilSetting->get("enable_global_profiles"))
191 {
192 if(!$this->handler->hasGlobalPasswordPermission($this->parent_node_id))
193 {
194 $options["password"] = $this->lng->txt("wsp_set_permission_all_password");
195 }
196
197 if(!$this->handler->hasGlobalPermission($this->parent_node_id))
198 {
199 $options["all"] = $this->lng->txt("wsp_set_permission_all");
200 }
201 }
202
203 if(sizeof($options))
204 {
205 // asort($options);
206 $item = $this->addFilterItemByMetaType("acl_type", self::FILTER_SELECT, false, $lng->txt("wsp_shared_type"));
207 $item->setOptions(array(""=>$lng->txt("search_any"))+$options);
208 $this->filter["acl_type"] = $item->getValue();
209 }
210
211 if(sizeof($this->crs_ids) || sizeof($this->grp_ids))
212 {
213 $options = array();
214 foreach($this->crs_ids as $crs_id)
215 {
216 $options[$crs_id] = $lng->txt("obj_crs")." ".ilObject::_lookupTitle($crs_id);
217 }
218 foreach($this->grp_ids as $grp_id)
219 {
220 $options[$grp_id] = $lng->txt("obj_grp")." ".ilObject::_lookupTitle($grp_id);
221 }
222 asort($options);
223 $item = $this->addFilterItemByMetaType("crsgrp", self::FILTER_SELECT, false, $lng->txt("wsp_shared_member_filter"));
224 $item->setOptions(array(""=>$lng->txt("search_any"))+$options);
225 $this->filter["crsgrp"] = $item->getValue();
226 }
227 }
228
229 protected function importData()
230 {
231 global $lng;
232
233 $data = array();
234
235 $user_data = array();
236
237 $objects = $this->handler->findSharedObjects($this->filter, $this->crs_ids, $this->grp_ids);
238 if($objects)
239 {
240 foreach($objects as $wsp_id => $item)
241 {
242 if(!isset($user_data[$item["owner"]]))
243 {
244 $user_data[$item["owner"]] = ilObjUser::_lookupName($item["owner"]);
245 }
246
247 // #18535 - deleted user?
248 if(!$user_data[$item["owner"]]["login"])
249 {
250 continue;
251 }
252
253 $data[] = array(
254 "wsp_id" => $wsp_id,
255 "obj_id" => $item["obj_id"],
256 "type" => $item["type"],
257 "obj_type" => $lng->txt("wsp_type_".$item["type"]),
258 "title" => $item["title"],
259 "owner_id" => $item["owner"],
260 "lastname" => $user_data[$item["owner"]]["lastname"],
261 "firstname" => $user_data[$item["owner"]]["firstname"],
262 "login" => $user_data[$item["owner"]]["login"],
263 "acl_type" => $item["acl_type"],
264 "acl_date" => $item["acl_date"]
265 );
266 }
267 }
268
269 $this->setData($data);
270
271 include_once('./Services/Link/classes/class.ilLink.php');
272 }
273
279 protected function fillRow($node)
280 {
281 global $ilCtrl, $lng;
282
283 $this->tpl->setVariable("LASTNAME", $node["lastname"]);
284 $this->tpl->setVariable("FIRSTNAME", $node["firstname"]);
285 $this->tpl->setVariable("LOGIN", $node["login"]);
286
287 $this->tpl->setVariable("TITLE", $node["title"]);
288
289 if(!$this->portfolio_mode)
290 {
291 $this->tpl->setVariable("TYPE", $node["obj_type"]);
292 $this->tpl->setVariable("ICON_ALT", $node["obj_type"]);
293 $this->tpl->setVariable("ICON", ilObject::_getIcon("", "tiny", $node["type"]));
294
295 $url = $this->handler->getGotoLink($node["wsp_id"], $node["obj_id"]);
296 }
297 else
298 {
299 $url = ilLink::_getStaticLink($node["obj_id"], "prtf", true);
300 }
301 $this->tpl->setVariable("URL_TITLE", $url);
302
303 $this->tpl->setVariable("ACL_DATE",
304 ilDatePresentation::formatDate(new ilDateTime($node["acl_date"], IL_CAL_UNIX)));
305
306 asort($node["acl_type"]);
307 foreach($node["acl_type"] as $obj_id)
308 {
309 // see ilWorkspaceAccessTableGUI
310 switch($obj_id)
311 {
313 $title = $icon_alt = $this->lng->txt("wsp_set_permission_registered");
314 $type = "registered";
315 $icon = "";
316 break;
317
319 $title = $icon_alt = $this->lng->txt("wsp_set_permission_all_password");
320 $type = "all_password";
321 $icon = "";
322 break;
323
325 $title = $icon_alt = $this->lng->txt("wsp_set_permission_all");
326 $type = "all_password";
327 $icon = "";
328 break;
329
330 default:
331 $type = ilObject::_lookupType($obj_id);
332 $icon = ilUtil::getTypeIconPath($type, null, "tiny");
333 $icon_alt = $this->lng->txt("obj_".$type);
334
335 if($type != "usr")
336 {
337 $title = ilObject::_lookupTitle($obj_id);
338 }
339 else
340 {
341 $title = ilUserUtil::getNamePresentation($obj_id, true, true);
342 }
343 break;
344 }
345
346 if($icon)
347 {
348 $this->tpl->setCurrentBlock("acl_type_icon_bl");
349 $this->tpl->setVariable("ACL_ICON", $icon);
350 $this->tpl->setVariable("ACL_ICON_ALT", $icon_alt);
351 $this->tpl->parseCurrentBlock();
352 }
353
354 $this->tpl->setCurrentBlock("acl_type_bl");
355 $this->tpl->setVariable("ACL_TYPE", $title);
356 $this->tpl->parseCurrentBlock();
357 }
358
359 if(!$this->portfolio_mode)
360 {
361 // files may be copied to own workspace
362 if($node["type"] == "file")
363 {
364 $ilCtrl->setParameter($this->parent_obj, "wsp_id",
365 $this->parent_node_id);
366 $ilCtrl->setParameter($this->parent_obj, "item_ref_id",
367 $node["wsp_id"]);
368 $url = $ilCtrl->getLinkTarget($this->parent_obj, "copyshared");
369
370 $this->tpl->setCurrentBlock("action_bl");
371 $this->tpl->setVariable("URL_ACTION", $url);
372 $this->tpl->setVariable("ACTION", $lng->txt("copy"));
373 $this->tpl->parseCurrentBlock();
374 }
375 }
376 }
377}
378
379?>
const IL_CAL_UNIX
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
static _lookupName($a_user_id)
lookup user name
static _lookupTitle($a_id)
lookup object title
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
getId()
Get element id.
setData($a_data)
set table data @access public
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
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.
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=NULL)
Add filter by standard type.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
disable($a_module_name)
diesables particular modules of table
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true)
Default behaviour is:
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...
Workspace share handler table GUI class.
__construct($a_parent_obj, $a_parent_cmd, $a_handler, $a_parent_node_id=null, $a_load_data=false)
Constructor.
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15