ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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";
33 
34 
42  public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
43  {
44  global $DIC;
45 
46  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
47 
48  $DIC->language()->loadLanguageModule("dcl");
49 
50  if (isset($_GET['table_id'])) {
51  $this->table_id = $_GET['table_id'];
52  } elseif (isset($_GET['tableview_id'])) {
53  $this->table_id = ilDclTableView::find($_GET['tableview_id'])->getTableId();
54  } elseif ($a_id > 0) {
55  $this->table_id = $this->object->getFirstVisibleTableId();
56  }
60  if (!$DIC->ctrl()->isAsynch()) {
63  $DIC->ui()->mainTemplate()->addJavaScript('Modules/DataCollection/js/ilDataCollection.js');
64  $DIC->ui()->mainTemplate()->addJavaScript("Modules/DataCollection/js/datacollection.js");
65  $this->tpl->addOnLoadCode(
66  "ilDataCollection.setEditUrl('" . $DIC->ctrl()->getLinkTargetByClass(
67  array(
68  'ilrepositorygui',
69  'ilobjdatacollectiongui',
70  'ildclrecordeditgui',
71  ),
72  'edit',
73  '',
74  true
75  ) . "');"
76  );
77  $this->tpl->addOnLoadCode(
78  "ilDataCollection.setCreateUrl('" . $DIC->ctrl()->getLinkTargetByClass(
79  array(
80  'ilrepositorygui',
81  'ilobjdatacollectiongui',
82  'ildclrecordeditgui',
83  ),
84  'create',
85  '',
86  true
87  ) . "');"
88  );
89  $this->tpl->addOnLoadCode(
90  "ilDataCollection.setSaveUrl('" . $DIC->ctrl()->getLinkTargetByClass(
91  array(
92  'ilrepositorygui',
93  'ilobjdatacollectiongui',
94  'ildclrecordeditgui',
95  ),
96  'save',
97  '',
98  true
99  ) . "');"
100  );
101  $this->tpl->addOnLoadCode(
102  "ilDataCollection.setDataUrl('" . $DIC->ctrl()->getLinkTargetByClass(
103  array(
104  'ilrepositorygui',
105  'ilobjdatacollectiongui',
106  'ildclrecordeditgui',
107  ),
108  'getRecordData',
109  '',
110  true
111  ) . "');"
112  );
113  }
114  $DIC->ctrl()->saveParameter($this, "table_id");
115  }
116 
117 
121  public function getStandardCmd()
122  {
123  return "render";
124  }
125 
126 
130  public function getType()
131  {
132  return "dcl";
133  }
134 
135 
140  public function executeCommand()
141  {
142  global $DIC;
143 
144  $ilNavigationHistory = $DIC['ilNavigationHistory'];
145  $ilHelp = $DIC['ilHelp'];
146  $ilHelp->setScreenIdComponent('bibl');
147 
148  // Navigation History
149  $link = $DIC->ctrl()->getLinkTarget($this, "render");
150 
151  if ($this->object != null) {
152  $ilNavigationHistory->addItem($this->object->getRefId(), $link, "dcl");
153  }
154 
155  // Direct-Link Resource, redirect to viewgui
156  if ($_GET[self::GET_DCL_GTR]) {
157  $DIC->ctrl()->setParameterByClass(ilDclDetailedViewGUI::class, 'tableview_id', $_GET[self::GET_VIEW_ID]);
158  $DIC->ctrl()->setParameterByClass(ilDclDetailedViewGUI::class, 'record_id', $_GET[self::GET_DCL_GTR]);
159  $DIC->ctrl()->redirectByClass(ilDclDetailedViewGUI::class, 'renderRecord');
160  }
161 
162  $next_class = $DIC->ctrl()->getNextClass($this);
163  $cmd = $DIC->ctrl()->getCmd();
164 
165  if (!$this->getCreationMode() and $next_class != "ilinfoscreengui" and $cmd != 'infoScreen' and !$this->checkPermissionBool("read")) {
166  $DIC->ui()->mainTemplate()->getStandardTemplate();
167  $DIC->ui()->mainTemplate()->setContent("Permission Denied.");
168 
169  return;
170  }
171 
172  switch ($next_class) {
173  case "ilinfoscreengui":
174  $this->prepareOutput();
175  $DIC->tabs()->activateTab("id_info");
176  $this->infoScreenForward();
177  break;
178 
179  case "ilcommonactiondispatchergui":
181  $gui->enableCommentsSettings(false);
182  $this->ctrl->forwardCommand($gui);
183  break;
184 
185  case "ilpermissiongui":
186  $this->prepareOutput();
187  $DIC->tabs()->activateTab("id_permissions");
188  $perm_gui = new ilPermissionGUI($this);
189  $this->ctrl->forwardCommand($perm_gui);
190  break;
191 
192  case "ilobjectcopygui":
193  $cp = new ilObjectCopyGUI($this);
194  $cp->setType("dcl");
195  $DIC->ui()->mainTemplate()->getStandardTemplate();
196  $this->ctrl->forwardCommand($cp);
197  break;
198 
199  case "ildcltablelistgui":
200  $this->prepareOutput();
201  $DIC->tabs()->setTabActive("id_tables");
202  $tablelist_gui = new ilDclTableListGUI($this);
203  $this->ctrl->forwardCommand($tablelist_gui);
204  break;
205 
206  case "ildclrecordlistgui":
207  $this->addHeaderAction(false);
208  $this->prepareOutput();
209  $DIC->tabs()->activateTab("id_records");
210  $this->ctrl->setParameterByClass(ilDclRecordListGUI::class, 'tableview_id', $_REQUEST['tableview_id']);
211  $recordlist_gui = new ilDclRecordListGUI($this, $this->table_id);
212  $this->ctrl->forwardCommand($recordlist_gui);
213  break;
214 
215  case "ildclrecordeditgui":
216  $this->prepareOutput();
217  $DIC->tabs()->activateTab("id_records");
218  $recordedit_gui = new ilDclRecordEditGUI($this);
219  $this->ctrl->forwardCommand($recordedit_gui);
220  break;
221 
222  case "ilobjfilegui":
223  $this->prepareOutput();
224  $DIC->tabs()->setTabActive("id_records");
225  $file_gui = new ilObjFile($this);
226  $this->ctrl->forwardCommand($file_gui);
227  break;
228 
229  case "ilratinggui":
230  $rgui = new ilRatingGUI();
231  $rgui->setObject($_GET['record_id'], "dcl_record", $_GET["field_id"], "dcl_field");
232  $rgui->executeCommand();
233  $DIC->ctrl()->redirectByClass("ilDclRecordListGUI", "listRecords");
234  break;
235 
236  case "ildcldetailedviewgui":
237  $this->prepareOutput();
238  $recordview_gui = new ilDclDetailedViewGUI($this);
239  $this->ctrl->forwardCommand($recordview_gui);
240  $DIC->tabs()->clearTargets();
241  $DIC->tabs()->setBackTarget($this->lng->txt("back"), $DIC->ctrl()->getLinkTargetByClass(ilDclRecordListGUI::class, ilDclRecordListGUI::CMD_LIST_RECORDS));
242  break;
243 
244  case 'ilnotegui':
245  $this->prepareOutput();
246  $recordviewGui = new ilDclDetailedViewGUI($this);
247  $this->ctrl->forwardCommand($recordviewGui);
248  $DIC->tabs()->clearTargets();
249  $DIC->tabs()->setBackTarget($this->lng->txt("back"), $DIC->ctrl()->getLinkTarget($this, ""));
250  break;
251  case "ildclexportgui":
252  $this->prepareOutput();
253  $DIC->tabs()->setTabActive("export");
254  $exp_gui = new ilDclExportGUI($this);
255  $exporter = new ilDclContentExporter($this->object->getRefId());
256  $exp_gui->addFormat("xlsx", $this->lng->txt('dlc_xls_async_export'), $exporter, 'exportAsync');
257  $exp_gui->addFormat("xml");
258 
259  $this->ctrl->forwardCommand($exp_gui);
260  break;
261 
262  case strtolower(ilDclPropertyFormGUI::class):
263  $recordedit_gui = new ilDclRecordEditGUI($this);
264  $recordedit_gui->getRecord();
265  $recordedit_gui->initForm();
266  $form = $recordedit_gui->getForm();
267  $this->ctrl->forwardCommand($form);
268  break;
269 
270  default:
271  return parent::executeCommand();
272  }
273 
274  return true;
275  }
276 
277 
283  public function infoScreen()
284  {
285  $this->ctrl->setCmd("showSummary");
286  $this->ctrl->setCmdClass("ilinfoscreengui");
287  $this->infoScreenForward();
288  }
289 
290 
294  public function render()
295  {
296  global $DIC;
297  $ilCtrl = $DIC['ilCtrl'];
298  $this->ctrl->setParameterByClass('ilDclRecordListGUI', 'tableview_id', $_GET['tableview_id']);
299  $ilCtrl->redirectByClass("ildclrecordlistgui", "show");
300  }
301 
302 
306  public function infoScreenForward()
307  {
308  global $DIC;
309  $ilTabs = $DIC['ilTabs'];
310  $ilErr = $DIC['ilErr'];
311 
312  $ilTabs->activateTab("id_info");
313 
314  if (!$this->checkPermissionBool("visible") && !$this->checkPermissionBool("read")) {
315  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
316  }
317 
318  $info = new ilInfoScreenGUI($this);
319  $info->enablePrivateNotes();
320  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
321 
322  $this->ctrl->forwardCommand($info);
323  }
324 
325 
326  public function addLocatorItems()
327  {
328  global $DIC;
329  $ilLocator = $DIC['ilLocator'];
330 
331  if (is_object($this->object)) {
332  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
333  }
334  }
335 
336 
340  public static function _goto($a_target)
341  {
342  $id = explode("_", $a_target);
343 
344  $_GET["baseClass"] = "ilRepositoryGUI";
345  $_GET[self::GET_REF_ID] = $id[0]; // ref_id
346  $_GET[self::GET_VIEW_ID] = $id[1]; // view_id
347  $_GET[self::GET_DCL_GTR] = $id[2]; // record_id
348  $_GET["cmd"] = "listRecords";
349  require_once('./ilias.php');
350  exit;
351  }
352 
353 
359  protected function initCreationForms($a_new_type)
360  {
361  $forms = parent::initCreationForms($a_new_type);
362 
363  return $forms;
364  }
365 
366 
370  protected function afterSave(ilObject $a_new_object)
371  {
372  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
373  $this->ctrl->redirectByClass("ilDclTableListGUI", "listTables");
374  }
375 
376 
383  public function setTabs()
384  {
385  global $DIC;
386  $ilAccess = $DIC['ilAccess'];
387  $ilTabs = $DIC['ilTabs'];
388  $lng = $DIC['lng'];
389  $ilHelp = $DIC['ilHelp'];
390 
391  $ilHelp->setScreenIdComponent("dcl");
392 
393  // list records
394  if ($ilAccess->checkAccess('read', "", $this->object->getRefId())) {
395  $ilTabs->addTab("id_records", $lng->txt("content"), $this->ctrl->getLinkTargetByClass("ildclrecordlistgui", "show"));
396  }
397 
398  // info screen
399  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()) || $ilAccess->checkAccess('read', "", $this->object->getRefId())) {
400  $ilTabs->addTab("id_info", $lng->txt("info_short"), $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
401  }
402 
403  // settings
404  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
405  $ilTabs->addTab("id_settings", $lng->txt("settings"), $this->ctrl->getLinkTarget($this, "editObject"));
406  }
407 
408  // list tables
409  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
410  $ilTabs->addTab("id_tables", $lng->txt("dcl_tables"), $this->ctrl->getLinkTargetByClass("ildcltablelistgui", "listTables"));
411  }
412 
413  // export
414  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
415  $ilTabs->addTab("export", $lng->txt("export"), $this->ctrl->getLinkTargetByClass("ildclexportgui", ""));
416  }
417 
418  // edit permissions
419  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
420  $ilTabs->addTab("id_permissions", $lng->txt("perm_settings"), $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"));
421  }
422  }
423 
424 
428  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
429  {
430  global $DIC;
431  $ilTabs = $DIC['ilTabs'];
432 
433  $ilTabs->activateTab("id_settings");
434 
435  // is_online
436  $cb = new ilCheckboxInputGUI($this->lng->txt("online"), "is_online");
437  $cb->setInfo($this->lng->txt("dcl_online_info"));
438  $a_form->addItem($cb);
439 
440  // Notification
441  $cb = new ilCheckboxInputGUI($this->lng->txt("dcl_activate_notification"), "notification");
442  $cb->setInfo($this->lng->txt("dcl_notification_info"));
443  $a_form->addItem($cb);
444 
445  //table order
446  $order_options = array();
447  foreach ($this->getDataCollectionObject()->getTables() as $table) {
448  $order_options[$table->getId()] = $table->getTitle();
449  }
450  }
451 
452 
456  public function listRecords()
457  {
458  global $DIC;
459  $ilCtrl = $DIC['ilCtrl'];
460  $ilCtrl->setParameterByClass("ildclrecordlistgui", "tableview_id", $_GET["tableview_id"]);
461  $ilCtrl->redirectByClass("ildclrecordlistgui", "show");
462  }
463 
464 
468  public function getDataCollectionObject()
469  {
470  $obj = new ilObjDataCollection($this->ref_id, true);
471 
472  return $obj;
473  }
474 
475 
481  public function getEditFormCustomValues(array &$a_values)
482  {
483  $a_values["is_online"] = $this->object->getOnline();
484  $a_values["rating"] = $this->object->getRating();
485  $a_values["public_notes"] = $this->object->getPublicNotes();
486  $a_values["approval"] = $this->object->getApproval();
487  $a_values["notification"] = $this->object->getNotification();
488 
489  return $a_values;
490  }
491 
492 
496  public function updateCustom(ilPropertyFormGUI $a_form)
497  {
498  $this->object->setOnline($a_form->getInput("is_online"));
499  $this->object->setRating($a_form->getInput("rating"));
500  $this->object->setPublicNotes($a_form->getInput("public_notes"));
501  $this->object->setApproval($a_form->getInput("approval"));
502  $this->object->setNotification($a_form->getInput("notification"));
503 
504  $this->emptyInfo();
505  }
506 
507 
508  private function emptyInfo()
509  {
510  global $DIC;
511  $lng = $DIC['lng'];
512  $this->table = ilDclCache::getTableCache($this->object->getFirstVisibleTableId());
513  $tables = $this->object->getTables();
514  if (count($tables) == 1 and count($this->table->getRecordFields()) == 0 and count($this->table->getRecords()) == 0
515  and $this->object->getOnline()
516  ) {
517  ilUtil::sendInfo($lng->txt("dcl_no_content_warning"), true);
518  }
519  }
520 
521 
522  public function toggleNotification()
523  {
524  global $DIC;
525  $ilCtrl = $DIC['ilCtrl'];
526  $ilUser = $DIC['ilUser'];
527 
528  switch ($_GET["ntf"]) {
529  case 1:
531  break;
532  case 2:
534  break;
535  }
536  $ilCtrl->redirectByClass("ildclrecordlistgui", "show");
537  }
538 
539 
545  public function addHeaderAction($a_redraw = false)
546  {
547  global $DIC;
548  $ilUser = $DIC['ilUser'];
549  $ilAccess = $DIC['ilAccess'];
550  $tpl = $DIC['tpl'];
551  $lng = $DIC['lng'];
552  $ilCtrl = $DIC['ilCtrl'];
553 
554  $dispatcher = new ilCommonActionDispatcherGUI(ilCommonActionDispatcherGUI::TYPE_REPOSITORY, $ilAccess, "dcl", $this->ref_id, $this->obj_id);
555 
556  ilObjectListGUI::prepareJSLinks(
557  $this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
558  $ilCtrl->getLinkTargetByClass(
559  array(
560  "ilcommonactiondispatchergui",
561  "ilnotegui",
562  ),
563  "",
564  "",
565  true,
566  false
567  ),
568  $ilCtrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false)
569  );
570 
571  $lg = $dispatcher->initHeaderAction();
572  //$lg->enableNotes(true);
573  //$lg->enableComments(ilObjWiki::_lookupPublicNotes($this->getPageObject()->getParentId()), false);
574 
575  // notification
576  if ($ilUser->getId() != ANONYMOUS_USER_ID and $this->object->getNotification() == 1) {
578  //Command Activate Notification
579  $ilCtrl->setParameter($this, "ntf", 1);
580  $lg->addCustomCommand($ilCtrl->getLinkTarget($this, "toggleNotification"), "dcl_notification_deactivate_dcl");
581 
582  $lg->addHeaderIcon("not_icon", ilUtil::getImagePath("notification_on.svg"), $lng->txt("dcl_notification_activated"));
583  } else {
584  //Command Deactivate Notification
585  $ilCtrl->setParameter($this, "ntf", 2);
586  $lg->addCustomCommand($ilCtrl->getLinkTarget($this, "toggleNotification"), "dcl_notification_activate_dcl");
587 
588  $lg->addHeaderIcon("not_icon", ilUtil::getImagePath("notification_off.svg"), $lng->txt("dcl_notification_deactivated"));
589  }
590  $ilCtrl->setParameter($this, "ntf", "");
591  }
592 
593  if (!$a_redraw) {
594  $tpl->setHeaderActionMenu($lg->getHeaderAction());
595  } else {
596  return $lg->getHeaderAction();
597  }
598 
599  $tpl->setHeaderActionMenu($lg->getHeaderAction());
600  }
601 }
$lg
Definition: example_018.php:62
static hasNotification($type, $user_id, $id)
Check notification status for object and user.
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.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static initConnection(ilTemplate $a_main_tpl=null)
Init YUI Connection module.
Class ilDclRecordEditGUI.
if(!array_key_exists('StateId', $_REQUEST)) $id
This class represents a checkbox property in a property form.
Class ilDclTableListGUI.
addItem($a_item)
Add Item (Property, SectionHeader).
static getTableCache($table_id=0)
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.
if(isset($_POST['submit'])) $form
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
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
exit
Definition: backend.php:16
updateCustom(ilPropertyFormGUI $a_form)
initEditCustomForm(ilPropertyFormGUI $a_form)
__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.
if(empty($password)) $table
Definition: pwgen.php:24
$info
Definition: index.php:5
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.