ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjDataCollectionGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
30{
31 const GET_DCL_GTR = "dcl_gtr";
32 const GET_REF_ID = "ref_id";
33 const GET_VIEW_ID = "tableview_id";
34
35
43 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
44 {
45 global $DIC;
46
47 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
48
49 $DIC->language()->loadLanguageModule("dcl");
50
51 if (isset($_GET['table_id'])) {
52 $this->table_id = $_GET['table_id'];
53 } elseif (isset($_GET['tableview_id'])) {
54 $this->table_id = ilDclTableView::find($_GET['tableview_id'])->getTableId();
55 } elseif ($a_id > 0) {
56 $this->table_id = $this->object->getFirstVisibleTableId();
57 }
61 if (!$DIC->ctrl()->isAsynch()) {
64 $DIC->ui()->mainTemplate()->addJavaScript('Modules/DataCollection/js/ilDataCollection.js');
65 $DIC->ui()->mainTemplate()->addJavaScript("Modules/DataCollection/js/datacollection.js");
66 $this->tpl->addOnLoadCode("ilDataCollection.setEditUrl('" . $DIC->ctrl()->getLinkTargetByClass(array(
67 'ilrepositorygui',
68 'ilobjdatacollectiongui',
69 'ildclrecordeditgui'
70 ), 'edit', '', true) . "');");
71 $this->tpl->addOnLoadCode("ilDataCollection.setCreateUrl('" . $DIC->ctrl()->getLinkTargetByClass(array(
72 'ilrepositorygui',
73 'ilobjdatacollectiongui',
74 'ildclrecordeditgui'
75 ), 'create', '', true) . "');");
76 $this->tpl->addOnLoadCode("ilDataCollection.setSaveUrl('" . $DIC->ctrl()->getLinkTargetByClass(array(
77 'ilrepositorygui',
78 'ilobjdatacollectiongui',
79 'ildclrecordeditgui'
80 ), 'save', '', true) . "');");
81 $this->tpl->addOnLoadCode("ilDataCollection.setDataUrl('" . $DIC->ctrl()->getLinkTargetByClass(array(
82 'ilrepositorygui',
83 'ilobjdatacollectiongui',
84 'ildclrecordeditgui'
85 ), 'getRecordData', '', true) . "');");
86 }
87 $DIC->ctrl()->saveParameter($this, "table_id");
88 }
89
90
94 public function getStandardCmd()
95 {
96 return "render";
97 }
98
99
103 public function getType()
104 {
105 return "dcl";
106 }
107
108
113 public function executeCommand()
114 {
115 global $DIC;
116
117 $ilNavigationHistory = $DIC['ilNavigationHistory'];
118 $ilHelp = $DIC['ilHelp'];
119 $ilHelp->setScreenIdComponent('bibl');
120
121 // Navigation History
122 $link = $DIC->ctrl()->getLinkTarget($this, "render");
123
124 if ($this->object != null) {
125 $ilNavigationHistory->addItem($this->object->getRefId(), $link, "dcl");
126 }
127
128 // Direct-Link Resource, redirect to viewgui
129 if ($_GET[self::GET_DCL_GTR]) {
130 $DIC->ctrl()->setParameterByClass(ilDclDetailedViewGUI::class, 'tableview_id', $_GET[self::GET_VIEW_ID]);
131 $DIC->ctrl()->setParameterByClass(ilDclDetailedViewGUI::class, 'record_id', $_GET[self::GET_DCL_GTR]);
132 $DIC->ctrl()->redirectByClass(ilDclDetailedViewGUI::class, 'renderRecord');
133 }
134
135
136 $next_class = $DIC->ctrl()->getNextClass($this);
137
138 if (!$this->getCreationMode() and $next_class != "ilinfoscreengui" and !$this->checkPermissionBool("read")) {
139 $DIC->ui()->mainTemplate()->getStandardTemplate();
140 $DIC->ui()->mainTemplate()->setContent("Permission Denied.");
141
142 return;
143 }
144
145 switch ($next_class) {
146 case "ilinfoscreengui":
147 $this->prepareOutput();
148 $DIC->tabs()->activateTab("id_info");
149 $this->infoScreenForward();
150 break;
151
152 case "ilcommonactiondispatchergui":
154 $gui->enableCommentsSettings(false);
155 $this->ctrl->forwardCommand($gui);
156 break;
157
158 case "ilpermissiongui":
159 $this->prepareOutput();
160 $DIC->tabs()->activateTab("id_permissions");
161 $perm_gui = new ilPermissionGUI($this);
162 $this->ctrl->forwardCommand($perm_gui);
163 break;
164
165 case "ilobjectcopygui":
166 $cp = new ilObjectCopyGUI($this);
167 $cp->setType("dcl");
168 $DIC->ui()->mainTemplate()->getStandardTemplate();
169 $this->ctrl->forwardCommand($cp);
170 break;
171
172 case "ildcltablelistgui":
173 $this->prepareOutput();
174 $DIC->tabs()->setTabActive("id_tables");
175 $tablelist_gui = new ilDclTableListGUI($this);
176 $this->ctrl->forwardCommand($tablelist_gui);
177 break;
178
179 case "ildclrecordlistgui":
180 $this->addHeaderAction(false);
181 $this->prepareOutput();
182 $DIC->tabs()->activateTab("id_records");
183 $this->ctrl->setParameterByClass(ilDclRecordListGUI::class, 'tableview_id', $_REQUEST['tableview_id']);
184 $recordlist_gui = new ilDclRecordListGUI($this, $this->table_id);
185 $this->ctrl->forwardCommand($recordlist_gui);
186 break;
187
188 case "ildclrecordeditgui":
189 $this->prepareOutput();
190 $DIC->tabs()->activateTab("id_records");
191 $recordedit_gui = new ilDclRecordEditGUI($this);
192 $this->ctrl->forwardCommand($recordedit_gui);
193 break;
194
195 case "ilobjfilegui":
196 $this->prepareOutput();
197 $DIC->tabs()->setTabActive("id_records");
198 $file_gui = new ilObjFile($this);
199 $this->ctrl->forwardCommand($file_gui);
200 break;
201
202 case "ilratinggui":
203 $rgui = new ilRatingGUI();
204 $rgui->setObject($_GET['record_id'], "dcl_record", $_GET["field_id"], "dcl_field");
205 $rgui->executeCommand();
206 $DIC->ctrl()->redirectByClass("ilDclRecordListGUI", "listRecords");
207 break;
208
209 case "ildcldetailedviewgui":
210 $this->prepareOutput();
211 $recordview_gui = new ilDclDetailedViewGUI($this);
212 $this->ctrl->forwardCommand($recordview_gui);
213 $DIC->tabs()->clearTargets();
214 $DIC->tabs()->setBackTarget($this->lng->txt("back"), $DIC->ctrl()->getLinkTargetByClass(ilDclRecordListGUI::class, ilDclRecordListGUI::CMD_LIST_RECORDS));
215 break;
216
217 case 'ilnotegui':
218 $this->prepareOutput();
219 $recordviewGui = new ilDclDetailedViewGUI($this);
220 $this->ctrl->forwardCommand($recordviewGui);
221 $DIC->tabs()->clearTargets();
222 $DIC->tabs()->setBackTarget($this->lng->txt("back"), $DIC->ctrl()->getLinkTarget($this, ""));
223 break;
224 case "ildclexportgui":
225 $this->prepareOutput();
226 $DIC->tabs()->setTabActive("export");
227 $exp_gui = new ilDclExportGUI($this);
228 $exporter = new ilDclContentExporter($this->object->getRefId());
229 $exp_gui->addFormat("xlsx", $this->lng->txt('dlc_xls_async_export'), $exporter, 'exportAsync');
230 $exp_gui->addFormat("xml");
231
232 $this->ctrl->forwardCommand($exp_gui);
233 break;
234
235 case strtolower(ilDclPropertyFormGUI::class):
236 $recordedit_gui = new ilDclRecordEditGUI($this);
237 $recordedit_gui->getRecord();
238 $recordedit_gui->initForm();
239 $form = $recordedit_gui->getForm();
240 $this->ctrl->forwardCommand($form);
241 break;
242
243 default:
244 return parent::executeCommand();
245 }
246
247 return true;
248 }
249
250
256 public function infoScreen()
257 {
258 $this->ctrl->setCmd("showSummary");
259 $this->ctrl->setCmdClass("ilinfoscreengui");
260 $this->infoScreenForward();
261 }
262
263
267 public function render()
268 {
269 global $DIC;
270 $ilCtrl = $DIC['ilCtrl'];
271 $this->ctrl->setParameterByClass('ilDclRecordListGUI', 'tableview_id', $_GET['tableview_id']);
272 $ilCtrl->redirectByClass("ildclrecordlistgui", "show");
273 }
274
275
279 public function infoScreenForward()
280 {
281 global $DIC;
282 $ilTabs = $DIC['ilTabs'];
283 $ilErr = $DIC['ilErr'];
284
285 $ilTabs->activateTab("id_info");
286
287 if (!$this->checkPermissionBool("visible") && !$this->checkPermissionBool("read")) {
288 $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
289 }
290
291 $info = new ilInfoScreenGUI($this);
292 $info->enablePrivateNotes();
293 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
294
295 $this->ctrl->forwardCommand($info);
296 }
297
298
299 public function addLocatorItems()
300 {
301 global $DIC;
302 $ilLocator = $DIC['ilLocator'];
303
304 if (is_object($this->object)) {
305 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
306 }
307 }
308
309
313 public static function _goto($a_target)
314 {
315 $id = explode("_", $a_target);
316
317 $_GET["baseClass"] = "ilRepositoryGUI";
318 $_GET[self::GET_REF_ID] = $id[0]; // ref_id
319 $_GET[self::GET_VIEW_ID] = $id[1]; // view_id
320 $_GET[self::GET_DCL_GTR] = $id[2]; // record_id
321 $_GET["cmd"] = "listRecords";
322 require_once('./ilias.php');
323 exit;
324 }
325
326
332 protected function initCreationForms($a_new_type)
333 {
334 $forms = parent::initCreationForms($a_new_type);
335
336 return $forms;
337 }
338
339
343 protected function afterSave(ilObject $a_new_object)
344 {
345 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
346 $this->ctrl->redirectByClass("ilDclTableListGUI", "listTables");
347 }
348
349
356 public function setTabs()
357 {
358 global $DIC;
359 $ilAccess = $DIC['ilAccess'];
360 $ilTabs = $DIC['ilTabs'];
361 $lng = $DIC['lng'];
362 $ilHelp = $DIC['ilHelp'];
363
364 $ilHelp->setScreenIdComponent("dcl");
365
366 // list records
367 if ($ilAccess->checkAccess('read', "", $this->object->getRefId())) {
368 $ilTabs->addTab("id_records", $lng->txt("content"), $this->ctrl->getLinkTargetByClass("ildclrecordlistgui", "show"));
369 }
370
371 // info screen
372 if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()) || $ilAccess->checkAccess('read', "", $this->object->getRefId())) {
373 $ilTabs->addTab("id_info", $lng->txt("info_short"), $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
374 }
375
376 // settings
377 if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
378 $ilTabs->addTab("id_settings", $lng->txt("settings"), $this->ctrl->getLinkTarget($this, "editObject"));
379 }
380
381 // list tables
382 if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
383 $ilTabs->addTab("id_tables", $lng->txt("dcl_tables"), $this->ctrl->getLinkTargetByClass("ildcltablelistgui", "listTables"));
384 }
385
386 // export
387 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
388 $ilTabs->addTab("export", $lng->txt("export"), $this->ctrl->getLinkTargetByClass("ildclexportgui", ""));
389 }
390
391 // edit permissions
392 if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
393 $ilTabs->addTab("id_permissions", $lng->txt("perm_settings"), $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"));
394 }
395 }
396
400 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
401 {
402 global $DIC;
403 $ilTabs = $DIC['ilTabs'];
404
405 $ilTabs->activateTab("id_settings");
406
407 // is_online
408 $cb = new ilCheckboxInputGUI($this->lng->txt("online"), "is_online");
409 $cb->setInfo($this->lng->txt("dcl_online_info"));
410 $a_form->addItem($cb);
411
412 // Notification
413 $cb = new ilCheckboxInputGUI($this->lng->txt("dcl_activate_notification"), "notification");
414 $cb->setInfo($this->lng->txt("dcl_notification_info"));
415 $a_form->addItem($cb);
416
417 //table order
418 $order_options = array();
419 foreach ($this->getDataCollectionObject()->getTables() as $table) {
420 $order_options[$table->getId()] = $table->getTitle();
421 }
422 }
423
424
428 public function listRecords()
429 {
430 global $DIC;
431 $ilCtrl = $DIC['ilCtrl'];
432 $ilCtrl->setParameterByClass("ildclrecordlistgui", "tableview_id", $_GET["tableview_id"]);
433 $ilCtrl->redirectByClass("ildclrecordlistgui", "show");
434 }
435
436
440 public function getDataCollectionObject()
441 {
442 $obj = new ilObjDataCollection($this->ref_id, true);
443
444 return $obj;
445 }
446
447
453 public function getEditFormCustomValues(array &$a_values)
454 {
455 $a_values["is_online"] = $this->object->getOnline();
456 $a_values["rating"] = $this->object->getRating();
457 $a_values["public_notes"] = $this->object->getPublicNotes();
458 $a_values["approval"] = $this->object->getApproval();
459 $a_values["notification"] = $this->object->getNotification();
460
461 return $a_values;
462 }
463
464
468 public function updateCustom(ilPropertyFormGUI $a_form)
469 {
470 $this->object->setOnline($a_form->getInput("is_online"));
471 $this->object->setRating($a_form->getInput("rating"));
472 $this->object->setPublicNotes($a_form->getInput("public_notes"));
473 $this->object->setApproval($a_form->getInput("approval"));
474 $this->object->setNotification($a_form->getInput("notification"));
475
476 $this->emptyInfo();
477 }
478
479
480 private function emptyInfo()
481 {
482 global $DIC;
483 $lng = $DIC['lng'];
484 $this->table = ilDclCache::getTableCache($this->object->getFirstVisibleTableId());
485 $tables = $this->object->getTables();
486 if (count($tables) == 1 and count($this->table->getRecordFields()) == 0 and count($this->table->getRecords()) == 0
487 and $this->object->getOnline()
488 ) {
489 ilUtil::sendInfo($lng->txt("dcl_no_content_warning"), true);
490 }
491 }
492
493
494
495 public function toggleNotification()
496 {
497 global $DIC;
498 $ilCtrl = $DIC['ilCtrl'];
499 $ilUser = $DIC['ilUser'];
500
501 switch ($_GET["ntf"]) {
502 case 1:
504 break;
505 case 2:
507 break;
508 }
509 $ilCtrl->redirectByClass("ildclrecordlistgui", "show");
510 }
511
512
518 public function addHeaderAction($a_redraw = false)
519 {
520 global $DIC;
521 $ilUser = $DIC['ilUser'];
522 $ilAccess = $DIC['ilAccess'];
523 $tpl = $DIC['tpl'];
524 $lng = $DIC['lng'];
525 $ilCtrl = $DIC['ilCtrl'];
526
527 $dispatcher = new ilCommonActionDispatcherGUI(ilCommonActionDispatcherGUI::TYPE_REPOSITORY, $ilAccess, "dcl", $this->ref_id, $this->obj_id);
528
529 ilObjectListGUI::prepareJSLinks($this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true), $ilCtrl->getLinkTargetByClass(array(
530 "ilcommonactiondispatchergui",
531 "ilnotegui"
532 ), "", "", true, false), $ilCtrl->getLinkTargetByClass(array( "ilcommonactiondispatchergui", "iltagginggui" ), "", "", true, false));
533
534 $lg = $dispatcher->initHeaderAction();
535 //$lg->enableNotes(true);
536 //$lg->enableComments(ilObjWiki::_lookupPublicNotes($this->getPageObject()->getParentId()), false);
537
538 // notification
539 if ($ilUser->getId() != ANONYMOUS_USER_ID and $this->object->getNotification() == 1) {
541 //Command Activate Notification
542 $ilCtrl->setParameter($this, "ntf", 1);
543 $lg->addCustomCommand($ilCtrl->getLinkTarget($this, "toggleNotification"), "dcl_notification_deactivate_dcl");
544
545 $lg->addHeaderIcon("not_icon", ilUtil::getImagePath("notification_on.svg"), $lng->txt("dcl_notification_activated"));
546 } else {
547 //Command Deactivate Notification
548 $ilCtrl->setParameter($this, "ntf", 2);
549 $lg->addCustomCommand($ilCtrl->getLinkTarget($this, "toggleNotification"), "dcl_notification_activate_dcl");
550
551 $lg->addHeaderIcon("not_icon", ilUtil::getImagePath("notification_off.svg"), $lng->txt("dcl_notification_deactivated"));
552 }
553 $ilCtrl->setParameter($this, "ntf", "");
554 }
555
556 if (!$a_redraw) {
557 $tpl->setHeaderActionMenu($lg->getHeaderAction());
558 } else {
559 return $lg->getHeaderAction();
560 }
561
562 $tpl->setHeaderActionMenu($lg->getHeaderAction());
563 }
564}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
Class ilCommonActionDispatcherGUI.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static getTableCache($table_id=0)
Hook-Class for exporting data-collections (used in SOAP-Class) This Class avoids duplicated code by r...
Export User Interface Class.
Class ilDclRecordEditGUI.
Class ilDclTableListGUI.
Class ilInfoScreenGUI.
static setNotification($type, $user_id, $id, $status=true)
Set notification status for object and user.
static hasNotification($type, $user_id, $id)
Check notification status for object and user.
Class ilObjDataCollectionGUI.
render()
show Content; redirect to ilDclRecordListGUI::listRecords
infoScreenForward()
show information screen
addLocatorItems()
Functions to be overwritten.
setTabs()
setTabs create tabs (repository/workspace switch)
initEditCustomForm(ilPropertyFormGUI $a_form)
updateCustom(ilPropertyFormGUI $a_form)
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
Class ilObjDataCollection.
Class ilObjFile.
New implementation of ilObjectGUI.
prepareOutput($a_show_subobjects=true)
prepare output
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
getCreationMode()
get creation mode
GUI class for the workflow of copying objects.
addHeaderAction()
Add header action menu.
Class ilObject Basic functions for all objects.
static initJavascript()
Init javascript.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
Class ilRatingGUI.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static initConnection(ilTemplate $a_main_tpl=null)
Init YUI Connection module.
$lg
Definition: example_018.php:62
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
$info
Definition: index.php:5
if(empty($password)) $table
Definition: pwgen.php:24
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18