ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 
29 {
30  const GET_DCL_GTR = "dcl_gtr";
31  const GET_REF_ID = "ref_id";
32  const GET_VIEW_ID = "tableview_id";
36  public $object;
37 
38 
46  public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
47  {
48  global $DIC;
49 
50  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
51 
52  $this->lng->loadLanguageModule("dcl");
53  $this->lng->loadLanguageModule('content');
54  $this->lng->loadLanguageModule('obj');
55  $this->lng->loadLanguageModule('cntr');
56 
57  if (isset($_GET['table_id'])) {
58  $this->table_id = $_GET['table_id'];
59  } elseif (isset($_GET['tableview_id'])) {
60  $this->table_id = ilDclTableView::find($_GET['tableview_id'])->getTableId();
61  } elseif ($a_id > 0) {
62  $this->table_id = $this->object->getFirstVisibleTableId();
63  }
67  if (!$DIC->ctrl()->isAsynch()) {
70  $DIC->ui()->mainTemplate()->addJavaScript('Modules/DataCollection/js/ilDataCollection.js');
71  // # see https://mantis.ilias.de/view.php?id=26463
72  $DIC->ui()->mainTemplate()->addJavaScript("./Services/UIComponent/Modal/js/Modal.js");
73  $DIC->ui()->mainTemplate()->addJavaScript("Modules/DataCollection/js/datacollection.js");
74  $this->tpl->addOnLoadCode(
75  "ilDataCollection.setEditUrl('" . $DIC->ctrl()->getLinkTargetByClass(
76  array(
77  'ilrepositorygui',
78  'ilobjdatacollectiongui',
79  'ildclrecordeditgui',
80  ),
81  'edit',
82  '',
83  true
84  ) . "');"
85  );
86  $this->tpl->addOnLoadCode(
87  "ilDataCollection.setCreateUrl('" . $DIC->ctrl()->getLinkTargetByClass(
88  array(
89  'ilrepositorygui',
90  'ilobjdatacollectiongui',
91  'ildclrecordeditgui',
92  ),
93  'create',
94  '',
95  true
96  ) . "');"
97  );
98  $this->tpl->addOnLoadCode(
99  "ilDataCollection.setSaveUrl('" . $DIC->ctrl()->getLinkTargetByClass(
100  array(
101  'ilrepositorygui',
102  'ilobjdatacollectiongui',
103  'ildclrecordeditgui',
104  ),
105  'save',
106  '',
107  true
108  ) . "');"
109  );
110  $this->tpl->addOnLoadCode(
111  "ilDataCollection.setDataUrl('" . $DIC->ctrl()->getLinkTargetByClass(
112  array(
113  'ilrepositorygui',
114  'ilobjdatacollectiongui',
115  'ildclrecordeditgui',
116  ),
117  'getRecordData',
118  '',
119  true
120  ) . "');"
121  );
122  }
123  $DIC->ctrl()->saveParameter($this, "table_id");
124  }
125 
126 
130  public function getStandardCmd()
131  {
132  return "render";
133  }
134 
135 
139  public function getType()
140  {
141  return "dcl";
142  }
143 
144 
149  public function executeCommand()
150  {
151  global $DIC;
152 
153  $ilNavigationHistory = $DIC['ilNavigationHistory'];
154  $ilHelp = $DIC['ilHelp'];
155  $ilHelp->setScreenIdComponent('bibl');
156 
157  // Navigation History
158  $link = $DIC->ctrl()->getLinkTarget($this, "render");
159 
160  if ($this->object != null) {
161  $ilNavigationHistory->addItem($this->object->getRefId(), $link, "dcl");
162  }
163 
164  // Direct-Link Resource, redirect to viewgui
165  if ($_GET[self::GET_DCL_GTR]) {
166  $DIC->ctrl()->setParameterByClass(ilDclDetailedViewGUI::class, 'tableview_id', $_GET[self::GET_VIEW_ID]);
167  $DIC->ctrl()->setParameterByClass(ilDclDetailedViewGUI::class, 'record_id', $_GET[self::GET_DCL_GTR]);
168  $DIC->ctrl()->redirectByClass(ilDclDetailedViewGUI::class, 'renderRecord');
169  }
170 
171  $next_class = $DIC->ctrl()->getNextClass($this);
172  $cmd = $this->ctrl->getCmd();
173 
174  if (!$this->getCreationMode() and $next_class != "ilinfoscreengui" and $cmd != 'infoScreen' and !$this->checkPermissionBool("read")) {
175  $DIC->ui()->mainTemplate()->loadStandardTemplate();
176  $DIC->ui()->mainTemplate()->setContent("Permission Denied.");
177 
178  return;
179  }
180 
181  switch ($next_class) {
182  case "ilinfoscreengui":
183  $this->prepareOutput();
184  $DIC->tabs()->activateTab("id_info");
185  $this->infoScreenForward();
186  break;
187 
188  case "ilcommonactiondispatchergui":
190  $gui->enableCommentsSettings(false);
191  $this->ctrl->forwardCommand($gui);
192  break;
193 
194  case "ilpermissiongui":
195  $this->prepareOutput();
196  $DIC->tabs()->activateTab("id_permissions");
197  $perm_gui = new ilPermissionGUI($this);
198  $this->ctrl->forwardCommand($perm_gui);
199  break;
200 
201  case "ilobjectcopygui":
202  $cp = new ilObjectCopyGUI($this);
203  $cp->setType("dcl");
204  $DIC->ui()->mainTemplate()->loadStandardTemplate();
205  $this->ctrl->forwardCommand($cp);
206  break;
207 
208  case "ildcltablelistgui":
209  $this->prepareOutput();
210  $DIC->tabs()->setTabActive("id_tables");
211  $tablelist_gui = new ilDclTableListGUI($this);
212  $this->ctrl->forwardCommand($tablelist_gui);
213  break;
214 
215  case "ildclrecordlistgui":
216  $this->addHeaderAction(false);
217  $this->prepareOutput();
218  $DIC->tabs()->activateTab("id_records");
219  $this->ctrl->setParameterByClass(ilDclRecordListGUI::class, 'tableview_id', $_REQUEST['tableview_id']);
220  $recordlist_gui = new ilDclRecordListGUI($this, $this->table_id);
221  $this->ctrl->forwardCommand($recordlist_gui);
222  break;
223 
224  case "ildclrecordeditgui":
225  $this->prepareOutput();
226  $DIC->tabs()->activateTab("id_records");
227  $recordedit_gui = new ilDclRecordEditGUI($this);
228  $this->ctrl->forwardCommand($recordedit_gui);
229  break;
230 
231  case "ilobjfilegui":
232  $this->prepareOutput();
233  $DIC->tabs()->setTabActive("id_records");
234  $file_gui = new ilObjFile($this);
235  $this->ctrl->forwardCommand($file_gui);
236  break;
237 
238  case "ilratinggui":
239  $rgui = new ilRatingGUI();
240  $rgui->setObject($_GET['record_id'], "dcl_record", $_GET["field_id"], "dcl_field");
241  $rgui->executeCommand();
242  $DIC->ctrl()->redirectByClass("ilDclRecordListGUI", "listRecords");
243  break;
244 
245  case "ildcldetailedviewgui":
246  $this->prepareOutput();
247  $recordview_gui = new ilDclDetailedViewGUI($this);
248  $this->ctrl->forwardCommand($recordview_gui);
249  $DIC->tabs()->clearTargets();
250  $DIC->tabs()->setBackTarget($this->lng->txt("back"), $DIC->ctrl()->getLinkTargetByClass(ilDclRecordListGUI::class, ilDclRecordListGUI::CMD_LIST_RECORDS));
251  break;
252 
253  case 'ilnotegui':
254  $this->prepareOutput();
255  $recordviewGui = new ilDclDetailedViewGUI($this);
256  $this->ctrl->forwardCommand($recordviewGui);
257  $DIC->tabs()->clearTargets();
258  $DIC->tabs()->setBackTarget($this->lng->txt("back"), $DIC->ctrl()->getLinkTarget($this, ""));
259  break;
260  case "ildclexportgui":
261  $this->prepareOutput();
262  $DIC->tabs()->setTabActive("export");
263  $exp_gui = new ilDclExportGUI($this);
264  $exporter = new ilDclContentExporter($this->object->getRefId());
265  $exp_gui->addFormat("xlsx", $this->lng->txt('dlc_xls_async_export'), $exporter, 'exportAsync');
266  $exp_gui->addFormat("xml");
267 
268  $this->ctrl->forwardCommand($exp_gui);
269  break;
270 
271  case strtolower(ilDclPropertyFormGUI::class):
272  $recordedit_gui = new ilDclRecordEditGUI($this);
273  $recordedit_gui->getRecord();
274  $recordedit_gui->initForm();
275  $form = $recordedit_gui->getForm();
276  $this->ctrl->forwardCommand($form);
277  break;
278 
279  default:
280  switch ($cmd) {
281  case 'edit': // this is necessary because ilObjectGUI only calls its own editObject (why??)
282  $this->prepareOutput();
283  $this->editObject();
284  break;
285  default:
286  return parent::executeCommand();
287  }
288  }
289 
290  return true;
291  }
292 
293 
299  public function infoScreen()
300  {
301  $this->ctrl->setCmd("showSummary");
302  $this->ctrl->setCmdClass("ilinfoscreengui");
303  $this->infoScreenForward();
304  }
305 
306 
310  public function render()
311  {
312  global $DIC;
313  $ilCtrl = $DIC['ilCtrl'];
314  $this->ctrl->setParameterByClass('ilDclRecordListGUI', 'tableview_id', $_GET['tableview_id']);
315  $ilCtrl->redirectByClass("ildclrecordlistgui", "show");
316  }
317 
318 
322  public function infoScreenForward()
323  {
324  global $DIC;
325  $ilTabs = $DIC['ilTabs'];
326  $ilErr = $DIC['ilErr'];
327 
328  $ilTabs->activateTab("id_info");
329 
330  if (!$this->checkPermissionBool("visible") && !$this->checkPermissionBool("read")) {
331  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
332  }
333 
334  $info = new ilInfoScreenGUI($this);
335  $info->enablePrivateNotes();
336  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
337 
338  $this->ctrl->forwardCommand($info);
339  }
340 
341 
342  public function addLocatorItems()
343  {
344  global $DIC;
345  $ilLocator = $DIC['ilLocator'];
346 
347  if (is_object($this->object)) {
348  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
349  }
350  }
351 
352 
356  public static function _goto($a_target)
357  {
358  global $DIC;
359 
360  $ilAccess = $DIC->access();
361  $lng = $DIC->language();
362 
363  $id = explode("_", $a_target);
364 
365  if ($ilAccess->checkAccess('read', "", $a_target)) {
366  $_GET["baseClass"] = "ilRepositoryGUI";
367  $_GET[self::GET_REF_ID] = $id[0]; // ref_id
368  $_GET[self::GET_VIEW_ID] = $id[1]; // view_id
369  $_GET[self::GET_DCL_GTR] = $id[2]; // record_id
370  $_GET["cmd"] = "listRecords";
371  require_once('./ilias.php');
372  exit;
373  }
374 
375  if ($ilAccess->checkAccess('visible', "", $a_target)) {
376  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
377  }
378 
380  sprintf(
381  $lng->txt("msg_no_perm_read_item"),
383  ),
384  true
385  );
387  }
388 
389 
395  protected function initCreationForms($a_new_type)
396  {
397  $forms = parent::initCreationForms($a_new_type);
398 
399  return $forms;
400  }
401 
402 
406  protected function afterSave(ilObject $a_new_object)
407  {
408  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
409  $this->ctrl->redirectByClass("ilDclTableListGUI", "listTables");
410  }
411 
412 
419  public function setTabs()
420  {
421  global $DIC;
422  $ilAccess = $DIC['ilAccess'];
423  $ilTabs = $DIC['ilTabs'];
424  $lng = $DIC['lng'];
425  $ilHelp = $DIC['ilHelp'];
426 
427  $ilHelp->setScreenIdComponent("dcl");
428 
429  // list records
430  if ($ilAccess->checkAccess('read', "", $this->object->getRefId())) {
431  $ilTabs->addTab("id_records", $lng->txt("content"), $this->ctrl->getLinkTargetByClass("ildclrecordlistgui", "show"));
432  }
433 
434  // info screen
435  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()) || $ilAccess->checkAccess('read', "", $this->object->getRefId())) {
436  $ilTabs->addTab("id_info", $lng->txt("info_short"), $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
437  }
438 
439  // settings
440  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
441  $ilTabs->addTab("id_settings", $lng->txt("settings"), $this->ctrl->getLinkTarget($this, "editObject"));
442  }
443 
444  // list tables
445  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
446  $ilTabs->addTab("id_tables", $lng->txt("dcl_tables"), $this->ctrl->getLinkTargetByClass("ildcltablelistgui", "listTables"));
447  }
448 
449  // export
450  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
451  $ilTabs->addTab("export", $lng->txt("export"), $this->ctrl->getLinkTargetByClass("ildclexportgui", ""));
452  }
453 
454  // edit permissions
455  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
456  $ilTabs->addTab("id_permissions", $lng->txt("perm_settings"), $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"));
457  }
458  }
459 
460 
466  public function editObject()
467  {
468  $tpl = $this->tpl;
469  $ilTabs = $this->tabs_gui;
471 
472  if (!$this->checkPermissionBool("write")) {
473  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
474  }
475 
476  $ilTabs->activateTab("settings");
477 
478  $form = $this->initEditForm();
479  $values = $this->getEditFormValues();
480  if ($values) {
481  $form->setValuesByArray($values, true);
482  }
483 
484  $this->addExternalEditFormCustom($form);
485 
486  $tpl->setContent($form->getHTML());
487  }
488 
489 
495  protected function initEditForm()
496  {
497  $this->tabs_gui->activateTab("id_settings");
498  $this->lng->loadLanguageModule($this->object->getType());
499 
500  $form = new ilPropertyFormGUI();
501  $form->setFormAction($this->ctrl->getFormAction($this, "update"));
502  $form->setTitle($this->lng->txt($this->object->getType() . "_edit"));
503 
504  // title
505  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
506  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
507  $ti->setMaxLength(ilObject::TITLE_LENGTH);
508  $ti->setRequired(true);
509  $form->addItem($ti);
510 
511  // description
512  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
513  $ta->setCols(40);
514  $ta->setRows(2);
515  $form->addItem($ta);
516 
517  // is_online
518  $cb = new ilCheckboxInputGUI($this->lng->txt("online"), "is_online");
519  $cb->setInfo($this->lng->txt("dcl_online_info"));
520  $form->addItem($cb);
521 
522  // Notification
523  $cb = new ilCheckboxInputGUI($this->lng->txt("dcl_activate_notification"), "notification");
524  $cb->setInfo($this->lng->txt("dcl_notification_info"));
525  $form->addItem($cb);
526 
527  //table order
528  $order_options = array();
529  foreach ($this->getDataCollectionObject()->getTables() as $table) {
530  $order_options[$table->getId()] = $table->getTitle();
531  }
532 
533  // tile img upload
534  $section_appearance = new ilFormSectionHeaderGUI();
535  $section_appearance->setTitle($this->lng->txt('cont_presentation'));
536  $form->addItem($section_appearance);
537  $form = $this->object_service->commonSettings()->legacyForm($form, $this->object)->addTileImage();
538 
539  $form->addCommandButton("update", $this->lng->txt("save"));
540 
541  return $form;
542  }
543 
544 
548  public function listRecords()
549  {
550  global $DIC;
551  $ilCtrl = $DIC['ilCtrl'];
552  $ilCtrl->setParameterByClass("ildclrecordlistgui", "tableview_id", $_GET["tableview_id"]);
553  $ilCtrl->redirectByClass("ildclrecordlistgui", "show");
554  }
555 
556 
560  public function getDataCollectionObject()
561  {
562  $obj = new ilObjDataCollection($this->ref_id, true);
563 
564  return $obj;
565  }
566 
567 
573  public function getEditFormCustomValues(array &$a_values)
574  {
575  $a_values["is_online"] = $this->object->getOnline();
576  $a_values["rating"] = $this->object->getRating();
577  $a_values["public_notes"] = $this->object->getPublicNotes();
578  $a_values["approval"] = $this->object->getApproval();
579  $a_values["notification"] = $this->object->getNotification();
580 
581  return $a_values;
582  }
583 
584 
588  public function updateCustom(ilPropertyFormGUI $a_form)
589  {
590  $this->object->setOnline($a_form->getInput("is_online"));
591  $this->object->setRating($a_form->getInput("rating"));
592  $this->object->setPublicNotes($a_form->getInput("public_notes"));
593  $this->object->setApproval($a_form->getInput("approval"));
594  $this->object->setNotification($a_form->getInput("notification"));
595 
596  $this->object_service->commonSettings()->legacyForm($a_form, $this->object)->saveTileImage();
597 
598  $this->emptyInfo();
599  }
600 
601 
602  private function emptyInfo()
603  {
604  global $DIC;
605  $lng = $DIC['lng'];
606  $this->table = ilDclCache::getTableCache($this->object->getFirstVisibleTableId());
607  $tables = $this->object->getTables();
608  if (count($tables) == 1 and count($this->table->getRecordFields()) == 0 and count($this->table->getRecords()) == 0
609  and $this->object->getOnline()
610  ) {
611  ilUtil::sendInfo($lng->txt("dcl_no_content_warning"), true);
612  }
613  }
614 
615 
616  public function toggleNotification()
617  {
618  global $DIC;
619  $ilCtrl = $DIC['ilCtrl'];
620  $ilUser = $DIC['ilUser'];
621 
622  switch ($_GET["ntf"]) {
623  case 1:
625  break;
626  case 2:
628  break;
629  }
630  $ilCtrl->redirectByClass("ildclrecordlistgui", "show");
631  }
632 
633 
639  public function addHeaderAction($a_redraw = false)
640  {
641  global $DIC;
642  $ilUser = $DIC['ilUser'];
643  $ilAccess = $DIC['ilAccess'];
644  $tpl = $DIC['tpl'];
645  $lng = $DIC['lng'];
646  $ilCtrl = $DIC['ilCtrl'];
647 
648  $dispatcher = new ilCommonActionDispatcherGUI(ilCommonActionDispatcherGUI::TYPE_REPOSITORY, $ilAccess, "dcl", $this->ref_id, $this->obj_id);
649 
650  ilObjectListGUI::prepareJSLinks(
651  $this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
652  $ilCtrl->getLinkTargetByClass(
653  array(
654  "ilcommonactiondispatchergui",
655  "ilnotegui",
656  ),
657  "",
658  "",
659  true,
660  false
661  ),
662  $ilCtrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false)
663  );
664 
665  $lg = $dispatcher->initHeaderAction();
666  //$lg->enableNotes(true);
667  //$lg->enableComments(ilObjWiki::_lookupPublicNotes($this->getPageObject()->getParentId()), false);
668 
669  // notification
670  if ($ilUser->getId() != ANONYMOUS_USER_ID and $this->object->getNotification() == 1) {
672  //Command Activate Notification
673  $ilCtrl->setParameter($this, "ntf", 1);
674  $lg->addCustomCommand($ilCtrl->getLinkTarget($this, "toggleNotification"), "dcl_notification_deactivate_dcl");
675 
676  $lg->addHeaderIcon("not_icon", ilUtil::getImagePath("notification_on.svg"), $lng->txt("dcl_notification_activated"));
677  } else {
678  //Command Deactivate Notification
679  $ilCtrl->setParameter($this, "ntf", 2);
680  $lg->addCustomCommand($ilCtrl->getLinkTarget($this, "toggleNotification"), "dcl_notification_activate_dcl");
681 
682  $lg->addHeaderIcon("not_icon", ilUtil::getImagePath("notification_off.svg"), $lng->txt("dcl_notification_deactivated"));
683  }
684  $ilCtrl->setParameter($this, "ntf", "");
685  }
686 
687  if (!$a_redraw) {
688  $tpl->setHeaderActionMenu($lg->getHeaderAction());
689  } else {
690  return $lg->getHeaderAction();
691  }
692 
693  $tpl->setHeaderActionMenu($lg->getHeaderAction());
694  }
695 }
static hasNotification($type, $user_id, $id)
Check notification status for object and user.
exit
Definition: login.php:29
Class ilInfoScreenGUI.
This class represents a property form user interface.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
New implementation of ilObjectGUI.
GUI class for the workflow of copying objects.
const TITLE_LENGTH
max length of object title
$_GET["client_id"]
This class represents a section header in a property form.
Class ilDclRecordEditGUI.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
static initConnection(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
This class represents a checkbox property in a property form.
static _lookupTitle($a_id)
lookup object title
Class ilDclTableListGUI.
static getTableCache($table_id=0)
initEditForm()
Init object edit form.
addExternalEditFormCustom(ilPropertyFormGUI $a_form)
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Class ilObjDataCollectionGUI.
setTabs()
setTabs create tabs (repository/workspace switch)
Class ilRatingGUI.
static _gotoRepositoryNode($a_ref_id, $a_cmd="frameset")
Goto repository root.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _lookupObjId($a_id)
static setNotification($type, $user_id, $id, $status=true)
Set notification status for object and user.
$ilUser
Definition: imgupload.php:18
Export User Interface Class.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
render()
show Content; redirect to ilDclRecordListGUI::listRecords
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
getEditFormValues()
Get values for edit form.
updateCustom(ilPropertyFormGUI $a_form)
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
$DIC
Definition: xapitoken.php:46
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
prepareOutput($a_show_subobjects=true)
Hook-Class for exporting data-collections (used in SOAP-Class) This Class avoids duplicated code by r...
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
addHeaderAction()
Add header action menu.
Class ilObjDataCollection.
Class ilCommonActionDispatcherGUI.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
infoScreenForward()
show information screen
static initJavascript()
Init javascript.