ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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/Object/classes/class.ilObject2GUI.php";
6 
29 {
30 
31  /*
32  * __construct
33  */
34  public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
35  {
36  global $lng, $ilCtrl;
37 
38  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
39 
40  $lng->loadLanguageModule("dcl");
41 
42  if(isset($_REQUEST['table_id']))
43  {
44  $this->table_id = $_REQUEST['table_id'];
45  }
46  elseif($a_id > 0)
47  {
48  $this->table_id = $this->object->getMainTableId();
49  }
50 
51  $ilCtrl->saveParameter($this, "table_id");
52  }
53 
54  /*
55  * getStandardCmd
56  */
57  public function getStandardCmd()
58  {
59  return "render";
60  }
61 
62  /*
63  * getType
64  */
65  public function getType()
66  {
67  return "dcl";
68  }
69 
70  /*
71  * executeCommand
72  */
73  public function executeCommand()
74  {
75  global $ilCtrl, $ilTabs, $ilNavigationHistory, $ilUser, $tpl;
76 
77  // Navigation History
78  $link = $ilCtrl->getLinkTarget($this, "render");
79 
80  if($this->object != NULL)
81  {
82  $ilNavigationHistory->addItem($this->object->getRefId(), $link, "dcl");
83  }
84 
85  //Direct-Link Resource
86  if($_GET["dcl_gtr"])
87  {
88  $ilCtrl->setCmdClass("ildatacollectionrecordviewgui");
89  $_GET['record_id'] = $_GET["dcl_gtr"];
90  $ilCtrl->setCmd("renderRecord");
91  }
92 
93 
94  $next_class = $ilCtrl->getNextClass($this);
95  $cmd = $ilCtrl->getCmd();
96 
97 
98  if(!$this->getCreationMode() && $next_class != "ilinfoscreengui" && !$this->checkPermissionBool("read")){
99  $tpl->getStandardTemplate();
100  $tpl->setContent("Permission Denied.");
101  return;
102  }
103 
104 
105  switch($next_class)
106  {
107  case "ilinfoscreengui":
108  $this->prepareOutput();
109  $ilTabs->activateTab("id_info");
110  $this->infoScreenForward();
111  break;
112 
113  case "ilcommonactiondispatchergui":
114  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
116  $this->ctrl->forwardCommand($gui);
117  break;
118 
119  case "ilpermissiongui":
120  $this->prepareOutput();
121  $ilTabs->activateTab("id_permissions");
122  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
123  $perm_gui = new ilPermissionGUI($this);
124  $this->ctrl->forwardCommand($perm_gui);
125  break;
126 
127  case "ilobjectcopygui":
128  include_once "./Services/Object/classes/class.ilObjectCopyGUI.php";
129  $cp = new ilObjectCopyGUI($this);
130  $cp->setType("dcl");
131  $tpl->getStandardTemplate();
132  $this->ctrl->forwardCommand($cp);
133  break;
134 
135  case "ildatacollectionfieldlistgui":
136  $this->prepareOutput();
137  $this->addListFieldsTabs("list_fields");
138  $ilTabs->setTabActive("id_fields");
139  include_once("./Modules/DataCollection/classes/class.ilDataCollectionFieldListGUI.php");
140  $fieldlist_gui = new ilDataCollectionFieldListGUI($this, $this->table_id);
141  $this->ctrl->forwardCommand($fieldlist_gui);
142  break;
143 
144  case "ildatacollectiontableeditgui":
145  $this->prepareOutput();
146  $ilTabs->setTabActive("id_fields");
147  include_once("./Modules/DataCollection/classes/class.ilDataCollectionTableEditGUI.php");
148  $tableedit_gui = new ilDataCollectionTableEditGUI($this);
149  $this->ctrl->forwardCommand($tableedit_gui);
150  break;
151 
152  case "ildatacollectionfieldeditgui":
153  $this->prepareOutput();
154  $ilTabs->activateTab("id_fields");
155  include_once("./Modules/DataCollection/classes/class.ilDataCollectionFieldEditGUI.php");
156  $fieldedit_gui = new ilDataCollectionFieldEditGUI($this,$this->table_id,$_REQUEST["field_id"]);
157  $this->ctrl->forwardCommand($fieldedit_gui);
158  break;
159 
160  case "ildatacollectionrecordlistgui":
161  $this->addHeaderAction(false);
162  $this->prepareOutput();
163  $ilTabs->activateTab("id_records");
164  include_once("./Modules/DataCollection/classes/class.ilDataCollectionRecordListGUI.php");
165  $recordlist_gui = new ilDataCollectionRecordListGUI($this,$this->table_id);
166  $this->ctrl->forwardCommand($recordlist_gui);
167  break;
168 
169  case "ildatacollectionrecordeditgui":
170  $this->prepareOutput();
171  $ilTabs->activateTab("id_records");
172  include_once("./Modules/DataCollection/classes/class.ilDataCollectionRecordEditGUI.php");
173  $recordedit_gui = new ilDataCollectionRecordEditGUI($this);
174  $this->ctrl->forwardCommand($recordedit_gui);
175  break;
176 
177  case "ildatacollectionrecordviewviewdefinitiongui":
178  $this->prepareOutput();
179 
180  // page editor will set its own tabs
181  $ilTabs->clearTargets();
182  $ilTabs->setBackTarget($this->lng->txt("back"),
183  $ilCtrl->getLinkTargetByClass("ildatacollectionfieldlistgui", "listFields"));
184 
185  include_once("./Modules/DataCollection/classes/class.ilDataCollectionRecordViewViewdefinitionGUI.php");
186  $recordedit_gui = new ilDataCollectionRecordViewViewdefinitionGUI($this->table_id);
187 
188  // needed for editor
189  $recordedit_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0, "dcl"));
190 
191  if (!$this->checkPermissionBool("write"))
192  {
193  $recordedit_gui->setEnableEditing(false);
194  }
195 
196  $ret = $this->ctrl->forwardCommand($recordedit_gui);
197  if ($ret != "")
198  {
199  $this->tpl->setContent($ret);
200  }
201 
202  $ilTabs->removeTab('history');
203  $ilTabs->removeTab('clipboard'); // Fixme
204  $ilTabs->removeTab('pg');
205  break;
206 
207  case "ildatacollectionrecordlistviewdefinitiongui":
208  $this->prepareOutput();
209  $this->addListFieldsTabs("list_viewdefinition");
210  $ilTabs->setTabActive("id_fields");
211  include_once("./Modules/DataCollection/classes/class.ilDataCollectionRecordListViewdefinitionGUI.php");
212  $recordlist_gui = new ilDataCollectionRecordListViewdefinitionGUI($this, $this->table_id);
213  $this->ctrl->forwardCommand($recordlist_gui);
214  break;
215 
216  case "ilobjfilegui":
217  $this->prepareOutput();
218  $ilTabs->setTabActive("id_records");
219  include_once("./Modules/File/classes/class.ilObjFile.php");
220  $file_gui = new ilObjFile($this);
221  $this->ctrl->forwardCommand($file_gui);
222  break;
223 
224  case "ildatacollectionrecordviewgui":
225  $this->prepareOutput();
226  include_once("./Modules/DataCollection/classes/class.ilDataCollectionRecordViewGUI.php");
227  $recordview_gui = new ilDataCollectionRecordViewGUI($this);
228  $this->ctrl->forwardCommand($recordview_gui);
229  $ilTabs->clearTargets();
230  $ilTabs->setBackTarget($this->lng->txt("back"), $ilCtrl->getLinkTargetByClass("ilObjDataCollectionGUI", ""));
231  break;
232 
233  case "ilratinggui":
234  $rgui = new ilRatingGUI();
235  $rgui->setObject($_GET['record_id'], "dcl_record", $_GET["field_id"], "dcl_field");
236  $rgui->executeCommand();
237  $ilCtrl->redirectByClass("ilDataCollectionRecordListGUI", "listRecords");
238  break;
239 
240  default:
241  return parent::executeCommand();
242  }
243 
244  return true;
245  }
246 
252  public function infoScreen()
253  {
254  $this->ctrl->setCmd("showSummary");
255  $this->ctrl->setCmdClass("ilinfoscreengui");
256  $this->infoScreenForward();
257  }
258 
262  public function render()
263  {
264  global $ilCtrl;
265 
266  $ilCtrl->redirectByClass("ildatacollectionrecordlistgui","listRecords");
267  }
268 
272  public function infoScreenForward()
273  {
274  global $ilTabs, $ilErr;
275 
276  $ilTabs->activateTab("id_info");
277 
278  if (!$this->checkPermissionBool("visible"))
279  {
280  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
281  }
282 
283  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
284  $info = new ilInfoScreenGUI($this);
285  $info->enablePrivateNotes();
286  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
287 
288  $this->ctrl->forwardCommand($info);
289  }
290 
291  /*
292  * addLocatorItems
293  */
294  public function addLocatorItems()
295  {
296  global $ilLocator;
297 
298  if (is_object($this->object))
299  {
300  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
301  }
302  }
303 
310  public function _goto($a_target)
311  {
312  $id = explode("_", $a_target);
313 
314  $_GET["baseClass"] = "ilRepositoryGUI";
315  $_GET["ref_id"] = $id[0];
316  $_GET["dcl_gtr"] = $id[1]; //recordID
317  $_GET["cmd"] = "listRecords";
318  include("ilias.php");
319  exit;
320  }
321 
322  /*
323  * initCreationForms
324  */
325  protected function initCreationForms($a_new_type)
326  {
327  $forms = parent::initCreationForms($a_new_type);
328 
329  // disabling import
330  unset($forms[self::CFORM_IMPORT]);
331 
332  return $forms;
333  }
334 
335  /*
336  * afterSave
337  */
338  protected function afterSave(ilObject $a_new_object)
339  {
340  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
341  $this->ctrl->redirectByClass("ilDataCollectionFieldListGUI", "listFields");
342  }
343 
350  public function setTabs()
351  {
352  global $ilAccess, $ilTabs, $lng, $ilHelp;
353 
354  $ilHelp->setScreenIdComponent("dcl");
355 
356  // list records
357  if ($ilAccess->checkAccess('read', "", $this->object->getRefId()))
358  {
359  $ilTabs->addTab("id_records",
360  $lng->txt("content"),
361  $this->ctrl->getLinkTargetByClass("ildatacollectionrecordlistgui", "listRecords"));
362  }
363 
364  // info screen
365  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()))
366  {
367  $ilTabs->addTab("id_info",
368  $lng->txt("info_short"),
369  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
370  }
371 
372  // settings
373  if ($ilAccess->checkAccess('write', "", $this->object->getRefId()))
374  {
375  $ilTabs->addTab("id_settings",
376  $lng->txt("settings"),
377  $this->ctrl->getLinkTarget($this, "editObject"));
378  }
379 
380  // list fields
381  if ($ilAccess->checkAccess('write', "", $this->object->getRefId()))
382  {
383  $ilTabs->addTab("id_fields",
384  $lng->txt("dcl_list_fields"),
385  $this->ctrl->getLinkTargetByClass("ildatacollectionfieldlistgui", "listFields"));
386  }
387 
388  // export
389  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
390  {
391  //$ilTabs->addTab("export",
392  //$lng->txt("export"),
393  //$this->ctrl->getLinkTargetByClass("ilexportgui", ""));
394  }
395 
396  // edit permissions
397  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
398  {
399  $ilTabs->addTab("id_permissions",
400  $lng->txt("perm_settings"),
401  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"));
402  }
403  }
404 
405 
411  public function addListFieldsTabs($a_active)
412  {
413  global $ilTabs, $ilCtrl, $lng;
414 
415 
416  $ilTabs->addSubTab("list_fields",
417  $lng->txt("dcl_list_fields"),
418  $ilCtrl->getLinkTargetByClass("ildatacollectionfieldlistgui", "listFields"));
419 
420  $ilCtrl->setParameterByClass("ildatacollectionrecordviewviewdefinitiongui","table_id", $this->table_id);
421  $ilTabs->addSubTab("view_viewdefinition",
422  $lng->txt("dcl_record_view_viewdefinition"),
423  $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewviewdefinitiongui","edit"));
424 
425  $ilTabs->activateSubTab($a_active);
426  }
427 
428 
432  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
433  {
434  global $ilCtrl, $ilErr, $ilTabs;
435 
436  $ilTabs->activateTab("id_settings");
437 
438  // is_online
439  $cb = new ilCheckboxInputGUI($this->lng->txt("online"), "is_online");
440  $a_form->addItem($cb);
441 
442  // edit_type
443 
444  // Rating
445  //$cb = new ilCheckboxInputGUI($this->lng->txt("dcl_activate_rating"), "rating");
446  //$a_form->addItem($cb);
447 
448  // Public Notes
449  //$cb = new ilCheckboxInputGUI($this->lng->txt("public_notes"), "public_notes");
450  //$a_form->addItem($cb);
451 
452  // Approval
453  //$cb = new ilCheckboxInputGUI($this->lng->txt("dcl_activate_approval"), "approval");
454  //$a_form->addItem($cb);
455 
456  // Notification
457  $cb = new ilCheckboxInputGUI($this->lng->txt("dcl_activate_notification"), "notification");
458  $a_form->addItem($cb);
459 
460  }
461 
462  /*
463  * listRecords
464  */
465  public function listRecords()
466  {
467  global $ilCtrl;
468 
469  $ilCtrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords");
470  }
471 
472  /*
473  * getDataCollectionObject
474  */
475  public function getDataCollectionObject()
476  {
477  $obj = new ilObjDataCollection($this->ref_id, true);
478 
479  return $obj;
480  }
481 
485  public function getEditFormCustomValues(array &$a_values)
486  {
487  $a_values["is_online"] = $this->object->getOnline();
488  $a_values["rating"] = $this->object->getRating();
489  $a_values["public_notes"] = $this->object->getPublicNotes();
490  $a_values["approval"] = $this->object->getApproval();
491  $a_values["notification"] = $this->object->getNotification();
492 
493  return $a_values;
494  }
495 
499  public function updateCustom(ilPropertyFormGUI $a_form)
500  {
501  global $ilUser;
502 
503  $this->object->setOnline($a_form->getInput("is_online"));
504  $this->object->setRating($a_form->getInput("rating"));
505  $this->object->setPublicNotes($a_form->getInput("public_notes"));
506  $this->object->setApproval($a_form->getInput("approval"));
507  $this->object->setNotification($a_form->getInput("notification"));
508  $this->emptyInfo();
509  }
510 
511 
512  private function emptyInfo(){
513  global $lng;
514  $this->table = ilDataCollectionCache::getTableCache($this->object->getMainTableId());
515  $tables = $this->object->getTables();
516  if(count($tables) == 1 && count($this->table->getRecordFields()) == 0 && count($this->table->getRecords()) == 0 && $this->object->getOnline()){
517  ilUtil::sendInfo($lng->txt("dcl_no_content_warning"), true);
518  }
519  }
520  /*
521  * toggleNotification
522  */
523  public function toggleNotification()
524  {
525  global $ilCtrl, $ilUser;
526 
527  include_once "./Services/Notification/classes/class.ilNotification.php";
528  switch($_GET["ntf"])
529  {
530  case 1:
532  break;
533  case 2:
535  break;
536  }
537  $ilCtrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords");
538  }
539 
540  /*
541  * addHeaderAction
542  */
543  public function addHeaderAction($a_redraw = false)
544  {
545  global $ilUser, $ilAccess, $tpl, $lng, $ilCtrl;
546 
547  include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
549  $ilAccess, "dcl", $this->ref_id,$this->obj_id);
550 
551  include_once "Services/Object/classes/class.ilObjectListGUI.php";
552  ilObjectListGUI::prepareJSLinks($this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
553  $ilCtrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
554  $ilCtrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false));
555 
556  $lg = $dispatcher->initHeaderAction();
557  //$lg->enableNotes(true);
558  //$lg->enableComments(ilObjWiki::_lookupPublicNotes($this->getPageObject()->getParentId()), false);
559 
560  // notification
561  if ($ilUser->getId() != ANONYMOUS_USER_ID && $this->object->getNotification() == 1)
562  {
563  include_once "./Services/Notification/classes/class.ilNotification.php";
565  {
566  //Command Activate Notification
567  $ilCtrl->setParameter($this, "ntf", 1);
568  $lg->addCustomCommand($ilCtrl->getLinkTarget($this, "toggleNotification"), "dcl_notification_deactivate_dcl");
569 
570  $lg->addHeaderIcon("not_icon",
571  ilUtil::getImagePath("notification_on.png"),
572  $lng->txt("dcl_notification_activated"));
573  }
574  else
575  {
576  //Command Deactivate Notification
577  $ilCtrl->setParameter($this, "ntf", 2);
578  $lg->addCustomCommand($ilCtrl->getLinkTarget($this,"toggleNotification"), "dcl_notification_activate_dcl");
579 
580  $lg->addHeaderIcon("not_icon",
581  ilUtil::getImagePath("notification_off.png"),
582  $lng->txt("dcl_notification_deactivated"));
583  }
584  $ilCtrl->setParameter($this, "ntf", "");
585  }
586 
587  if(!$a_redraw)
588  {
589  $tpl->setHeaderActionMenu($lg->getHeaderAction());
590  }
591  else
592  {
593  return $lg->getHeaderAction();
594  }
595 
596  $tpl->setHeaderActionMenu($lg->getHeaderAction());
597  }
598 }
599 
600 ?>