ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 require_once("./Services/Rating/classes/class.ilRatingGUI.php");
6 require_once('./Services/Object/classes/class.ilObject2GUI.php');
7 require_once('./Services/Export/classes/class.ilExportGUI.php');
8 require_once('./Services/YUI/classes/class.ilYuiUtil.php');
9 require_once('./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php');
10 require_once('./Modules/DataCollection/classes/class.ilDclExportGUI.php');
11 
36 
37  /*
38  * __construct
39  */
40  const GET_DCL_GTR = "dcl_gtr";
41  const GET_REF_ID = "ref_id";
42  const GET_VIEW_ID = "tableview_id";
43 
44 
45  public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0) {
46  global $DIC;
47  $lng = $DIC['lng'];
48  $ilCtrl = $DIC['ilCtrl'];
49  $tpl = $DIC['tpl'];
50 
51  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
52 
53  $lng->loadLanguageModule("dcl");
54 
55  if (isset($_GET['table_id'])) {
56  $this->table_id = $_GET['table_id'];
57  } elseif (isset($_GET['tableview_id'])) {
58  $this->table_id = ilDclTableView::find($_GET['tableview_id'])->getTableId();
59  } elseif ($a_id > 0) {
60  $this->table_id = $this->object->getFirstVisibleTableId();
61  }
65  if (!$ilCtrl->isAsynch()) {
68  $tpl->addJavaScript('Modules/DataCollection/js/ilDataCollection.js');
69  $tpl->addJavaScript("Modules/DataCollection/js/datacollection.js");
70  $this->tpl->addOnLoadCode("ilDataCollection.setEditUrl('" . $ilCtrl->getLinkTargetByClass(array(
71  'ilrepositorygui',
72  'ilobjdatacollectiongui',
73  'ildclrecordeditgui'
74  ), 'edit', '', true) . "');");
75  $this->tpl->addOnLoadCode("ilDataCollection.setCreateUrl('" . $ilCtrl->getLinkTargetByClass(array(
76  'ilrepositorygui',
77  'ilobjdatacollectiongui',
78  'ildclrecordeditgui'
79  ), 'create', '', true) . "');");
80  $this->tpl->addOnLoadCode("ilDataCollection.setSaveUrl('" . $ilCtrl->getLinkTargetByClass(array(
81  'ilrepositorygui',
82  'ilobjdatacollectiongui',
83  'ildclrecordeditgui'
84  ), 'save', '', true) . "');");
85  $this->tpl->addOnLoadCode("ilDataCollection.setDataUrl('" . $ilCtrl->getLinkTargetByClass(array(
86  'ilrepositorygui',
87  'ilobjdatacollectiongui',
88  'ildclrecordeditgui'
89  ), 'getRecordData', '', true) . "');");
90  }
91  $ilCtrl->saveParameter($this, "table_id");
92  }
93 
94 
98  public function getStandardCmd() {
99  return "render";
100  }
101 
102 
106  public function getType() {
107  return "dcl";
108  }
109 
110 
115  public function executeCommand() {
116  global $DIC;
117  $ilCtrl = $DIC['ilCtrl'];
118  $ilTabs = $DIC['ilTabs'];
119  $ilNavigationHistory = $DIC['ilNavigationHistory'];
120  $tpl = $DIC['tpl'];
124  // Navigation History
125  $link = $ilCtrl->getLinkTarget($this, "render");
126 
127  if ($this->object != NULL) {
128  $ilNavigationHistory->addItem($this->object->getRefId(), $link, "dcl");
129  }
130 
131  // Direct-Link Resource, redirect to viewgui
132  if ($_GET[self::GET_DCL_GTR]) {
133  $ilCtrl->setParameterByClass('ilDclDetailedViewGUI', 'tableview_id', $_GET[self::GET_VIEW_ID]);
134  $ilCtrl->setParameterByClass('ilDclDetailedViewGUI', 'record_id', $_GET[self::GET_DCL_GTR]);
135  $ilCtrl->redirectByClass('ilDclDetailedViewGUI', 'renderRecord');
136  }
137 
138 
139  $next_class = $ilCtrl->getNextClass($this);
140 
141  if (!$this->getCreationMode() AND $next_class != "ilinfoscreengui" AND !$this->checkPermissionBool("read")) {
142  $tpl->getStandardTemplate();
143  $tpl->setContent("Permission Denied.");
144 
145  return;
146  }
147 
148  switch ($next_class) {
149  case "ilinfoscreengui":
150  $this->prepareOutput();
151  $ilTabs->activateTab("id_info");
152  $this->infoScreenForward();
153  break;
154 
155  case "ilcommonactiondispatchergui":
156  require_once('./Services/Object/classes/class.ilCommonActionDispatcherGUI.php');
158  $gui->enableCommentsSettings(false);
159  $this->ctrl->forwardCommand($gui);
160  break;
161 
162  case "ilpermissiongui":
163  $this->prepareOutput();
164  $ilTabs->activateTab("id_permissions");
165  require_once('./Services/AccessControl/classes/class.ilPermissionGUI.php');
166  $perm_gui = new ilPermissionGUI($this);
167  $this->ctrl->forwardCommand($perm_gui);
168  break;
169 
170  case "ilobjectcopygui":
171  require_once('./Services/Object/classes/class.ilObjectCopyGUI.php');
172  $cp = new ilObjectCopyGUI($this);
173  $cp->setType("dcl");
174  $tpl->getStandardTemplate();
175  $this->ctrl->forwardCommand($cp);
176  break;
177 
178  case "ildcltablelistgui":
179  $this->prepareOutput();
180  $ilTabs->setTabActive("id_tables");
181  require_once('./Modules/DataCollection/classes/Table/class.ilDclTableListGUI.php');
182  $tablelist_gui = new ilDclTableListGUI($this);
183  $this->ctrl->forwardCommand($tablelist_gui);
184  break;
185 
186  case "ildclrecordlistgui":
187  $this->addHeaderAction(false);
188  $this->prepareOutput();
189  $ilTabs->activateTab("id_records");
190  $this->ctrl->setParameterByClass('ilDclRecordListGUI', 'tableview_id', $_REQUEST['tableview_id']);
191  require_once('./Modules/DataCollection/classes/Content/class.ilDclRecordListGUI.php');
192  $recordlist_gui = new ilDclRecordListGUI($this, $this->table_id);
193  $this->ctrl->forwardCommand($recordlist_gui);
194  break;
195 
196  case "ildclrecordeditgui":
197  $this->prepareOutput();
198  $ilTabs->activateTab("id_records");
199  require_once('./Modules/DataCollection/classes/Content/class.ilDclRecordEditGUI.php');
200  $recordedit_gui = new ilDclRecordEditGUI($this);
201  $this->ctrl->forwardCommand($recordedit_gui);
202  break;
203 
204  case "ildclrecordlistviewdefinitiongui":
205  $this->prepareOutput();
206  $this->addListFieldsTabs("list_viewdefinition");
207  $ilTabs->setTabActive("id_fields");
208  require_once('./Modules/DataCollection/classes/Content/class.ilDclRecordListViewdefinitionGUI.php');
209  $recordlist_gui = new ilDclRecordListViewdefinitionGUI($this, $this->table_id);
210  $this->ctrl->forwardCommand($recordlist_gui);
211  break;
212 
213  case "ilobjfilegui":
214  $this->prepareOutput();
215  $ilTabs->setTabActive("id_records");
216  require_once('./Modules/File/classes/class.ilObjFile.php');
217  $file_gui = new ilObjFile($this);
218  $this->ctrl->forwardCommand($file_gui);
219  break;
220 
221  case "ilratinggui":
222  $rgui = new ilRatingGUI();
223  $rgui->setObject($_GET['record_id'], "dcl_record", $_GET["field_id"], "dcl_field");
224  $rgui->executeCommand();
225  $ilCtrl->redirectByClass("ilDclRecordListGUI", "listRecords");
226  break;
227 
228  case "ildcldetailedviewgui":
229  $this->prepareOutput();
230  require_once('./Modules/DataCollection/classes/DetailedView/class.ilDclDetailedViewGUI.php');
231  $recordview_gui = new ilDclDetailedViewGUI($this);
232  $this->ctrl->forwardCommand($recordview_gui);
233  $ilTabs->clearTargets();
234  $ilTabs->setBackTarget($this->lng->txt("back"), $ilCtrl->getLinkTargetByClass(ilDclRecordListGUI::class, ilDclRecordListGUI::CMD_LIST_RECORDS));
235  break;
236 
237  case 'ilnotegui':
238  $this->prepareOutput();
239  require_once('./Modules/DataCollection/classes/DetailedView/class.ilDclDetailedViewGUI.php'); //Forward the command to recordViewGUI
240  $recordviewGui = new ilDclDetailedViewGUI($this);
241  $this->ctrl->forwardCommand($recordviewGui);
242  $ilTabs->clearTargets();
243  $ilTabs->setBackTarget($this->lng->txt("back"), $ilCtrl->getLinkTargetByClass("ilObjDataCollectionGUI", ""));
244  break;
245  case "ildclexportgui":
246  $this->prepareOutput();
247  $ilTabs->setTabActive("export");
248 // $this->setLocator();
249  $exp_gui = new ilDclExportGUI($this);
250  $exp_gui->addFormat("xml");
251 
252  require_once 'Modules/DataCollection/classes/Content/class.ilDclContentExporter.php';
253  $exporter = new ilDclContentExporter($this->object->getRefId());
254  $exp_gui->addFormat("xlsx", $this->lng->txt('dlc_xls_async_export'), $exporter, 'exportAsync');
255 
256  $this->ctrl->forwardCommand($exp_gui);
257  break;
258 
259  case strtolower(ilDclPropertyFormGUI::class):
260  require_once './Modules/DataCollection/classes/Content/class.ilDclRecordEditGUI.php';
261  $recordedit_gui = new ilDclRecordEditGUI($this);
262  $recordedit_gui->getRecord();
263  $recordedit_gui->initForm();
264  $form = $recordedit_gui->getForm();
265  $this->ctrl->forwardCommand($form);
266  break;
267 
268  default:
269  return parent::executeCommand();
270  }
271 
272  return true;
273  }
274 
275 
281  public function infoScreen() {
282  $this->ctrl->setCmd("showSummary");
283  $this->ctrl->setCmdClass("ilinfoscreengui");
284  $this->infoScreenForward();
285  }
286 
287 
291  public function render() {
292  global $DIC;
293  $ilCtrl = $DIC['ilCtrl'];
294  $this->ctrl->setParameterByClass('ilDclRecordListGUI', 'tableview_id', $_GET['tableview_id']);
295  $ilCtrl->redirectByClass("ildclrecordlistgui", "show");
296  }
297 
298 
302  public function infoScreenForward() {
303  global $DIC;
304  $ilTabs = $DIC['ilTabs'];
305  $ilErr = $DIC['ilErr'];
306 
307  $ilTabs->activateTab("id_info");
308 
309  if (!$this->checkPermissionBool("visible") && !$this->checkPermissionBool("read")) {
310  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
311  }
312 
313  require_once('./Services/InfoScreen/classes/class.ilInfoScreenGUI.php');
314  $info = new ilInfoScreenGUI($this);
315  $info->enablePrivateNotes();
316  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
317 
318  $this->ctrl->forwardCommand($info);
319  }
320 
321 
322  public function addLocatorItems() {
323  global $DIC;
324  $ilLocator = $DIC['ilLocator'];
325 
326  if (is_object($this->object)) {
327  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
328  }
329  }
330 
331 
335  public static function _goto($a_target) {
336  $id = explode("_", $a_target);
337 
338  $_GET["baseClass"] = "ilRepositoryGUI";
339  $_GET[self::GET_REF_ID] = $id[0];
340  $_GET[self::GET_VIEW_ID] = $id[1];
341  $_GET[self::GET_DCL_GTR] = $id[2]; //recordID
342  $_GET["cmd"] = "listRecords";
343  require_once('./ilias.php');
344  exit;
345  }
346 
347 
353  protected function initCreationForms($a_new_type) {
354  $forms = parent::initCreationForms($a_new_type);
355 
356  return $forms;
357  }
358 
359 
363  protected function afterSave(ilObject $a_new_object) {
364  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
365  $this->ctrl->redirectByClass("ilDclTableListGUI", "listTables");
366  }
367 
368 
375  public function setTabs() {
376  global $DIC;
377  $ilAccess = $DIC['ilAccess'];
378  $ilTabs = $DIC['ilTabs'];
379  $lng = $DIC['lng'];
380  $ilHelp = $DIC['ilHelp'];
381 
382  $ilHelp->setScreenIdComponent("dcl");
383 
384  // list records
385  if ($ilAccess->checkAccess('read', "", $this->object->getRefId())) {
386  $ilTabs->addTab("id_records", $lng->txt("content"), $this->ctrl->getLinkTargetByClass("ildclrecordlistgui", "show"));
387  }
388 
389  // info screen
390  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()) || $ilAccess->checkAccess('read', "", $this->object->getRefId())) {
391  $ilTabs->addTab("id_info", $lng->txt("info_short"), $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
392  }
393 
394  // settings
395  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
396  $ilTabs->addTab("id_settings", $lng->txt("settings"), $this->ctrl->getLinkTarget($this, "editObject"));
397  }
398 
399  // list tables
400  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
401  $ilTabs->addTab("id_tables", $lng->txt("dcl_tables"), $this->ctrl->getLinkTargetByClass("ildcltablelistgui", "listTables"));
402  }
403 
404  // export
405  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
406  $ilTabs->addTab("export", $lng->txt("export"), $this->ctrl->getLinkTargetByClass("ildclexportgui", ""));
407  }
408 
409  // edit permissions
410  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
411  $ilTabs->addTab("id_permissions", $lng->txt("perm_settings"), $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"));
412  }
413  }
414 
418  protected function initEditCustomForm(ilPropertyFormGUI $a_form) {
419  global $DIC;
420  $ilTabs = $DIC['ilTabs'];
421 
422  $ilTabs->activateTab("id_settings");
423 
424  // is_online
425  $cb = new ilCheckboxInputGUI($this->lng->txt("online"), "is_online");
426  $cb->setInfo($this->lng->txt("dcl_online_info"));
427  $a_form->addItem($cb);
428 
429  // Notification
430  $cb = new ilCheckboxInputGUI($this->lng->txt("dcl_activate_notification"), "notification");
431  $cb->setInfo($this->lng->txt("dcl_notification_info"));
432  $a_form->addItem($cb);
433 
434  //table order
435  $order_options = array();
436  foreach($this->getDataCollectionObject()->getTables() as $table) {
437  $order_options[$table->getId()] = $table->getTitle();
438  }
439  }
440 
441 
445  public function listRecords() {
446  global $DIC;
447  $ilCtrl = $DIC['ilCtrl'];
448  $ilCtrl->setParameterByClass("ildclrecordlistgui", "tableview_id", $_GET["tableview_id"]);
449  $ilCtrl->redirectByClass("ildclrecordlistgui", "show");
450  }
451 
452 
456  public function getDataCollectionObject() {
457  $obj = new ilObjDataCollection($this->ref_id, true);
458 
459  return $obj;
460  }
461 
462 
468  public function getEditFormCustomValues(array &$a_values) {
469  $a_values["is_online"] = $this->object->getOnline();
470  $a_values["rating"] = $this->object->getRating();
471  $a_values["public_notes"] = $this->object->getPublicNotes();
472  $a_values["approval"] = $this->object->getApproval();
473  $a_values["notification"] = $this->object->getNotification();
474 
475  return $a_values;
476  }
477 
478 
482  public function updateCustom(ilPropertyFormGUI $a_form) {
483  $this->object->setOnline($a_form->getInput("is_online"));
484  $this->object->setRating($a_form->getInput("rating"));
485  $this->object->setPublicNotes($a_form->getInput("public_notes"));
486  $this->object->setApproval($a_form->getInput("approval"));
487  $this->object->setNotification($a_form->getInput("notification"));
488 
489  $this->emptyInfo();
490  }
491 
492 
493  private function emptyInfo() {
494  global $DIC;
495  $lng = $DIC['lng'];
496  $this->table = ilDclCache::getTableCache($this->object->getFirstVisibleTableId());
497  $tables = $this->object->getTables();
498  if (count($tables) == 1 AND count($this->table->getRecordFields()) == 0 AND count($this->table->getRecords()) == 0
499  AND $this->object->getOnline()
500  ) {
501  ilUtil::sendInfo($lng->txt("dcl_no_content_warning"), true);
502  }
503  }
504 
505 
506 
507  public function toggleNotification() {
508  global $DIC;
509  $ilCtrl = $DIC['ilCtrl'];
510  $ilUser = $DIC['ilUser'];
511 
512  require_once('./Services/Notification/classes/class.ilNotification.php');
513  switch ($_GET["ntf"]) {
514  case 1:
516  break;
517  case 2:
519  break;
520  }
521  $ilCtrl->redirectByClass("ildclrecordlistgui", "show");
522  }
523 
524 
530  public function addHeaderAction($a_redraw = false) {
531  global $DIC;
532  $ilUser = $DIC['ilUser'];
533  $ilAccess = $DIC['ilAccess'];
534  $tpl = $DIC['tpl'];
535  $lng = $DIC['lng'];
536  $ilCtrl = $DIC['ilCtrl'];
537 
538  require_once('./Services/Object/classes/class.ilCommonActionDispatcherGUI.php');
539  $dispatcher = new ilCommonActionDispatcherGUI(ilCommonActionDispatcherGUI::TYPE_REPOSITORY, $ilAccess, "dcl", $this->ref_id, $this->obj_id);
540 
541  require_once('./Services/Object/classes/class.ilObjectListGUI.php');
542  ilObjectListGUI::prepareJSLinks($this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true), $ilCtrl->getLinkTargetByClass(array(
543  "ilcommonactiondispatchergui",
544  "ilnotegui"
545  ), "", "", true, false), $ilCtrl->getLinkTargetByClass(array( "ilcommonactiondispatchergui", "iltagginggui" ), "", "", true, false));
546 
547  $lg = $dispatcher->initHeaderAction();
548  //$lg->enableNotes(true);
549  //$lg->enableComments(ilObjWiki::_lookupPublicNotes($this->getPageObject()->getParentId()), false);
550 
551  // notification
552  if ($ilUser->getId() != ANONYMOUS_USER_ID AND $this->object->getNotification() == 1) {
553  require_once('./Services/Notification/classes/class.ilNotification.php');
555  //Command Activate Notification
556  $ilCtrl->setParameter($this, "ntf", 1);
557  $lg->addCustomCommand($ilCtrl->getLinkTarget($this, "toggleNotification"), "dcl_notification_deactivate_dcl");
558 
559  $lg->addHeaderIcon("not_icon", ilUtil::getImagePath("notification_on.svg"), $lng->txt("dcl_notification_activated"));
560  } else {
561  //Command Deactivate Notification
562  $ilCtrl->setParameter($this, "ntf", 2);
563  $lg->addCustomCommand($ilCtrl->getLinkTarget($this, "toggleNotification"), "dcl_notification_activate_dcl");
564 
565  $lg->addHeaderIcon("not_icon", ilUtil::getImagePath("notification_off.svg"), $lng->txt("dcl_notification_deactivated"));
566  }
567  $ilCtrl->setParameter($this, "ntf", "");
568  }
569 
570  if (!$a_redraw) {
571  $tpl->setHeaderActionMenu($lg->getHeaderAction());
572  } else {
573  return $lg->getHeaderAction();
574  }
575 
576  $tpl->setHeaderActionMenu($lg->getHeaderAction());
577  }
578 }
579 
580 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilErr
Definition: raiseError.php:16
$lg
Definition: example_018.php:62
static hasNotification($type, $user_id, $id)
Check notification status for object and user.
Class ilInfoScreenGUI.
executeCommand()
execute command
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.
$_GET["client_id"]
Class ilDclRecordEditGUI.
Class ilObject Basic functions for all objects.
static initConnection()
Init YUI Connection module.
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.
$info
Definition: example_052.php:80
setTabs()
setTabs create tabs (repository/workspace switch)
Class ilRatingGUI.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Class ilObjFile.
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
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
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.
global $DIC
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.