ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilRepUtilGUI Class Reference

Repository GUI Utilities. More...

+ Collaboration diagram for ilRepUtilGUI:

Public Member Functions

 __construct ($a_parent_gui, $a_parent_cmd="")
 Constructor. More...
 
 showDeleteConfirmation ($a_ids, $a_supress_message=false)
 Show delete confirmation table. More...
 
 handleMultiReferences ($a_obj_id, $a_ref_id, $a_form_name)
 Build subitem list for multiple references. More...
 
 showTrashTable ($a_ref_id)
 Get trashed objects for a container. More...
 
 restoreObjects ($a_cur_ref_id, $a_ref_ids)
 Restore objects from trash. More...
 
 deleteObjects ($a_cur_ref_id, $a_ref_ids)
 Delete objects. More...
 
 removeObjectsFromSystem ($a_ref_ids, $a_from_recovery_folder=false)
 Remove objects from system. More...
 
 confirmRemoveFromSystemObject ($a_ids)
 Confirmation for trash. More...
 

Protected Member Functions

 buildPath ($ref_ids)
 Build path with deep-link. More...
 

Detailed Description

Repository GUI Utilities.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 11 of file class.ilRepUtilGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilRepUtilGUI::__construct (   $a_parent_gui,
  $a_parent_cmd = "" 
)

Constructor.

Parameters
objectparent gui object
stringcurrent parent command (like in table2gui)

Definition at line 20 of file class.ilRepUtilGUI.php.

21 {
22 $this->parent_gui = $a_parent_gui;
23 $this->parent_cmd = $a_parent_cmd;
24 }

Member Function Documentation

◆ buildPath()

ilRepUtilGUI::buildPath (   $ref_ids)
protected

Build path with deep-link.

Parameters
array$ref_ids
Returns
array

Definition at line 333 of file class.ilRepUtilGUI.php.

334 {
335 global $tree;
336
337 include_once 'Services/Link/classes/class.ilLink.php';
338
339 if(!count($ref_ids))
340 {
341 return false;
342 }
343
344 $result = array();
345 foreach($ref_ids as $ref_id)
346 {
347 $path = "";
348 $path_full = $tree->getPathFull($ref_id);
349 foreach($path_full as $idx => $data)
350 {
351 if($idx)
352 {
353 $path .= " » ";
354 }
355 if($ref_id != $data['ref_id'])
356 {
357 $path .= $data['title'];
358 }
359 else
360 {
361 $path .= ('<a target="_top" href="'.
362 ilLink::_getLink($data['ref_id'],$data['type']).'">'.
363 $data['title'].'</a>');
364 }
365
366 }
367
368 $result[] = $path;
369 }
370 return $result;
371 }
$result
$data
$ref_id
Definition: sahs_server.php:39
$path
Definition: index.php:22

References $data, $path, $ref_id, $result, and ilLink\_getLink().

Referenced by handleMultiReferences().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmRemoveFromSystemObject()

ilRepUtilGUI::confirmRemoveFromSystemObject (   $a_ids)

Confirmation for trash.

Parameters
array$a_idsref_ids

Definition at line 378 of file class.ilRepUtilGUI.php.

379 {
380 global $ilCtrl, $lng, $objDefinition, $tpl;
381 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
382
383 if(!is_array($a_ids))
384 {
385 $a_ids = array($a_ids);
386 }
387
388 $cgui = new ilConfirmationGUI();
389 $cgui->setFormAction($ilCtrl->getFormAction($this->parent_gui));
390 $cgui->setCancel($lng->txt("cancel"), "trash");
391 $cgui->setConfirm($lng->txt("confirm"), "removeFromSystem");
392 $cgui->setFormName("trash_confirmation");
393 $cgui->setHeaderText($lng->txt("info_delete_sure"));
394
395 foreach($a_ids as $id)
396 {
397 $obj_id = ilObject::_lookupObjId($id);
398 $type = ilObject::_lookupType($obj_id);
399 $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'),$obj_id);
400 $alt = ($objDefinition->isPlugin($type))
401 ? $lng->txt("icon")." ".ilPlugin::lookupTxt("rep_robj", $type, "obj_".$type)
402 : $lng->txt("icon")." ".$lng->txt("obj_".$type);
403
404 $cgui->addItem("trash_id[]", $id, $title,
405 ilObject::_getIcon($obj_id, "small", $type),
406 $alt);
407 }
408
409 $tpl->setContent($cgui->getHTML());
410 }
global $tpl
Definition: ilias.php:8
Confirmation screen class.
static getClassByType($a_obj_type)
Get class by type.
static _lookupObjId($a_id)
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 lookupTxt($a_mod_prefix, $a_pl_id, $a_lang_var)
Lookup language text.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40

References $ilCtrl, $lng, $tpl, ilObject\_getIcon(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilObjectFactory\getClassByType(), and ilPlugin\lookupTxt().

+ Here is the call graph for this function:

◆ deleteObjects()

ilRepUtilGUI::deleteObjects (   $a_cur_ref_id,
  $a_ref_ids 
)

Delete objects.

Definition at line 265 of file class.ilRepUtilGUI.php.

266 {
267 global $ilSetting, $lng;
268
269 if (!is_array($a_ref_ids) || count($a_ref_ids) == 0)
270 {
271 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
272 return false;
273 }
274 else
275 {
276 include_once("./Services/Repository/classes/class.ilRepUtil.php");
277 try
278 {
279 ilRepUtil::deleteObjects($a_cur_ref_id, $a_ref_ids);
280 if ($ilSetting->get('enable_trash'))
281 {
282 ilUtil::sendSuccess($lng->txt("info_deleted"),true);
283 }
284 else
285 {
286 ilUtil::sendSuccess($lng->txt("msg_removed"),true);
287 }
288 }
289 catch (Exception $e)
290 {
291 ilUtil::sendFailure($e->getMessage(), true);
292 return false;
293 }
294 }
295 }
static deleteObjects($a_cur_ref_id, $a_ids)
Delete objects.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilSetting
Definition: privfeed.php:40

References $ilSetting, $lng, ilRepUtil\deleteObjects(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ handleMultiReferences()

ilRepUtilGUI::handleMultiReferences (   $a_obj_id,
  $a_ref_id,
  $a_form_name 
)

Build subitem list for multiple references.

Parameters
int$a_obj_id
int$a_ref_id
string$a_form_name
Returns
string

Definition at line 103 of file class.ilRepUtilGUI.php.

104 {
105 global $lng, $ilAccess, $tree;
106
107 // process
108
109 $all_refs = ilObject::_getAllReferences($a_obj_id);
110 if(sizeof($all_refs) > 1)
111 {
112 $lng->loadLanguageModule("rep");
113
114 $may_delete_any = 0;
115 $counter = 0;
116 $items = array();
117 foreach($all_refs as $mref_id)
118 {
119 // not the already selected reference, no refs from trash
120 if($mref_id != $a_ref_id && !$tree->isDeleted($mref_id))
121 {
122 if($ilAccess->checkAccess("read", "", $mref_id))
123 {
124 $may_delete = false;
125 if($ilAccess->checkAccess("delete", "", $mref_id))
126 {
127 $may_delete = true;
128 $may_delete_any++;
129 }
130
131 $items[] = array("id" => $mref_id,
132 "path" => array_shift($this->buildPath(array($mref_id))),
133 "delete" => $may_delete);
134 }
135 else
136 {
137 $counter++;
138 }
139 }
140 }
141
142
143 // render
144
145 $tpl = new ilTemplate("tpl.rep_multi_ref.html", true, true, "Services/Repository");
146
147 $tpl->setVariable("TXT_INTRO", $lng->txt("rep_multiple_reference_deletion_intro"));
148
149 if($may_delete_any)
150 {
151 $tpl->setVariable("TXT_INSTRUCTION", $lng->txt("rep_multiple_reference_deletion_instruction"));
152 }
153
154 if($items)
155 {
156 $var_name = "mref_id[]";
157
158 foreach($items as $item)
159 {
160 if($item["delete"])
161 {
162 $tpl->setCurrentBlock("cbox");
163 $tpl->setVariable("ITEM_NAME", $var_name);
164 $tpl->setVariable("ITEM_VALUE", $item["id"]);
165 $tpl->parseCurrentBlock();
166 }
167 else
168 {
169 $tpl->setCurrentBlock("item_info");
170 $tpl->setVariable("TXT_ITEM_INFO", $lng->txt("rep_no_permission_to_delete"));
171 $tpl->parseCurrentBlock();
172 }
173
174 $tpl->setCurrentBlock("item");
175 $tpl->setVariable("ITEM_TITLE", $item["path"]);
176 $tpl->parseCurrentBlock();
177 }
178
179 if($may_delete_any > 1)
180 {
181 $tpl->setCurrentBlock("cbox");
182 $tpl->setVariable("ITEM_NAME", "sall_".$a_ref_id);
183 $tpl->setVariable("ITEM_VALUE", "");
184 $tpl->setVariable("ITEM_ADD", " onclick=\"il.Util.setChecked('".
185 $a_form_name."', '".$var_name."', document.".$a_form_name.
186 ".sall_".$a_ref_id.".checked)\"");
187 $tpl->parseCurrentBlock();
188
189 $tpl->setCurrentBlock("item");
190 $tpl->setVariable("ITEM_TITLE", $lng->txt("select_all"));
191 $tpl->parseCurrentBlock();
192 }
193 }
194
195 if($counter)
196 {
197 $tpl->setCurrentBlock("add_info");
198 $tpl->setVariable("TXT_ADDITIONAL_INFO",
199 sprintf($lng->txt("rep_object_references_cannot_be_read"), $counter));
200 $tpl->parseCurrentBlock();
201 }
202
203 return $tpl->get();
204 }
205 }
static _getAllReferences($a_id)
get all reference ids of object
buildPath($ref_ids)
Build path with deep-link.
special template class to simplify handling of ITX/PEAR

References $lng, $tpl, ilObject\_getAllReferences(), and buildPath().

Referenced by showDeleteConfirmation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeObjectsFromSystem()

ilRepUtilGUI::removeObjectsFromSystem (   $a_ref_ids,
  $a_from_recovery_folder = false 
)

Remove objects from system.

Definition at line 300 of file class.ilRepUtilGUI.php.

301 {
302 global $lng;
303
304 if (!is_array($a_ref_ids) || count($a_ref_ids) == 0)
305 {
306 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
307 return false;
308 }
309 else
310 {
311 include_once("./Services/Repository/classes/class.ilRepUtil.php");
312 try
313 {
314 ilRepUtil::removeObjectsFromSystem($a_ref_ids, $a_from_recovery_folder);
315 ilUtil::sendSuccess($lng->txt("msg_removed"),true);
316 }
317 catch (Exception $e)
318 {
319 ilUtil::sendFailure($e->getMessage(), true);
320 return false;
321 }
322 }
323
324 return true;
325 }
removeObjectsFromSystem($a_ref_ids, $a_from_recovery_folder=false)
remove objects from trash bin and all entries therefore every object needs a specific deleteObject() ...

References $lng, ilRepUtil\removeObjectsFromSystem(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ restoreObjects()

ilRepUtilGUI::restoreObjects (   $a_cur_ref_id,
  $a_ref_ids 
)

Restore objects from trash.

Parameters
integercurrent ref id
arrayarray of ref ids to be restored

Definition at line 236 of file class.ilRepUtilGUI.php.

237 {
238 global $lng;
239
240 if (!is_array($a_ref_ids) || count($a_ref_ids) == 0)
241 {
242 ilUtil::sendFailure($lng->txt("no_checkbox"),true);
243 return false;
244 }
245 else
246 {
247 try
248 {
249 include_once("./Services/Repository/classes/class.ilRepUtil.php");
250 ilRepUtil::restoreObjects($a_cur_ref_id, $a_ref_ids);
251 ilUtil::sendSuccess($lng->txt("msg_undeleted"),true);
252 }
253 catch (Exception $e)
254 {
255 ilUtil::sendFailure($e->getMessage(),true);
256 return false;
257 }
258 }
259 return true;
260 }
restoreObjects($a_cur_ref_id, $a_ref_ids)
Move objects from trash back to repository.

References $lng, ilRepUtil\restoreObjects(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ showDeleteConfirmation()

ilRepUtilGUI::showDeleteConfirmation (   $a_ids,
  $a_supress_message = false 
)

Show delete confirmation table.

Definition at line 30 of file class.ilRepUtilGUI.php.

31 {
32 global $lng, $ilSetting, $ilCtrl, $tpl, $objDefinition;
33
34 if (!is_array($a_ids) || count($a_ids) == 0)
35 {
36 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
37 return false;
38 }
39
40 // Remove duplicate entries
41 $a_ids = array_unique((array) $a_ids);
42
43 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
44 $cgui = new ilConfirmationGUI();
45
46 if(!$a_supress_message)
47 {
48 $msg = $lng->txt("info_delete_sure");
49
50 if (!$ilSetting->get('enable_trash'))
51 {
52 $msg .= "<br/>".$lng->txt("info_delete_warning_no_trash");
53 }
54
55 $cgui->setHeaderText($msg);
56 }
57 $cgui->setFormAction($ilCtrl->getFormAction($this->parent_gui));
58 $cgui->setCancel($lng->txt("cancel"), "cancelDelete");
59 $cgui->setConfirm($lng->txt("confirm"), "confirmedDelete");
60
61 $form_name = "cgui_".md5(uniqid());
62 $cgui->setFormName($form_name);
63
64 $deps = array();
65 foreach ($a_ids as $ref_id)
66 {
68 $type = ilObject::_lookupType($obj_id);
69 $title = call_user_func(array(ilObjectFactory::getClassByType($type),'_lookupTitle'),$obj_id);
70 $alt = ($objDefinition->isPlugin($type))
71 ? $lng->txt("icon")." ".ilPlugin::lookupTxt("rep_robj", $type, "obj_".$type)
72 : $lng->txt("icon")." ".$lng->txt("obj_".$type);
73
74 $title .= $this->handleMultiReferences($obj_id, $ref_id, $form_name);
75
76 $cgui->addItem("id[]", $ref_id, $title,
77 ilObject::_getIcon($obj_id, "small", $type),
78 $alt);
79
80 ilObject::collectDeletionDependencies($deps, $ref_id, $obj_id, $type);
81 }
82 $deps_html = "";
83
84 if (is_array($deps) && count($deps) > 0)
85 {
86 include_once("./Services/Repository/classes/class.ilRepDependenciesTableGUI.php");
88 $deps_html = "<br/><br/>".$tab->getHTML();
89 }
90
91 $tpl->setContent($cgui->getHTML().$deps_html);
92 return true;
93 }
static collectDeletionDependencies(&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
Collect deletion dependencies.
handleMultiReferences($a_obj_id, $a_ref_id, $a_form_name)
Build subitem list for multiple references.

References $ilCtrl, $ilSetting, $lng, $ref_id, $tab, $tpl, ilObject\_getIcon(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilObject\collectDeletionDependencies(), ilObjectFactory\getClassByType(), handleMultiReferences(), ilPlugin\lookupTxt(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ showTrashTable()

ilRepUtilGUI::showTrashTable (   $a_ref_id)

Get trashed objects for a container.

Parameters
intergerref id of container

Definition at line 212 of file class.ilRepUtilGUI.php.

213 {
214 global $tpl, $tree, $lng;
215
216 $objects = $tree->getSavedNodeData($a_ref_id);
217
218 if (count($objects) == 0)
219 {
220 ilUtil::sendInfo($lng->txt("msg_trash_empty"));
221 return;
222 }
223 include_once("./Services/Repository/classes/class.ilTrashTableGUI.php");
224 $ttab = new ilTrashTableGUI($this->parent_gui, "trash");
225 $ttab->setData($objects);
226
227 $tpl->setContent($ttab->getHTML());
228 }
TableGUI class for.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $lng, $tpl, and ilUtil\sendInfo().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: