5 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
38 $this->parent_object = $a_parent_obj;
39 $this->obj_id = $a_parent_obj->obj_id;
40 $this->table_id =
$_GET[
'table_id'];
44 $ilCtrl->redirectByClass(
'ildatacollectionrecordlistgui',
'listRecords');
56 $cmd = $ilCtrl->getCmd();
57 $tpl->getStandardTemplate();
62 $this->
save(
"update");
81 $tpl->setContent($this->form->getHTML());
93 $ilCtrl->redirectByClass(
"ildatacollectionfieldeditgui",
"listFields");
102 $tpl->setContent($this->form->getHTML());
111 'title' => $this->table->getTitle(),
112 'add_perm' => $this->table->getAddPerm(),
113 'edit_perm' => $this->table->getEditPerm(),
114 'delete_perm' => $this->table->getDeletePerm(),
115 'edit_by_owner' => $this->table->getEditByOwner(),
116 'export_enabled' => $this->table->getExportEnabled(),
117 'limited' => $this->table->getLimited(),
118 'limit_start' => array(
"date" => substr($this->table->getLimitStart(),0,10),
"time" => substr($this->table->getLimitStart(),-8)),
119 'limit_end' => array(
"date" => substr($this->table->getLimitEnd(),0,10),
"time" => substr($this->table->getLimitEnd(),-8)),
120 'is_visible' => $this->table->getIsVisible()
122 if(!$this->table->getLimitStart())
123 $values[
'limit_start'] = NULL;
124 if(!$this->table->getLimitEnd())
125 $values[
'limit_end'] = NULL;
126 $this->form->setValuesByArray($values);
140 'edit_by_owner' => 1,
141 'export_enabled' => 0,
143 'limit_start' => NULL,
146 $this->form->setValuesByArray($values);
156 $ilCtrl->redirectByClass(
"ilDataCollectionFieldListGUI",
"listFields");
168 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
173 $this->form->addItem($item);
175 $this->form->addItem($item);
178 $section->setTitle($lng->txt(
'dcl_permissions_form'));
182 $item->setHtml($lng->txt(
'dcl_table_info'));
183 $item->setTitle($lng->txt(
'dcl_table_info_title'));
184 $this->form->addItem($item);
188 $this->form->addItem($item);
191 $this->form->addItem($item);
194 $this->form->addItem($item);
197 $this->form->addItem($item);
200 $this->form->addItem($item);
207 $item->addSubItem($sitem2);
208 $this->form->addItem($item);
209 if($a_mode ==
"edit")
211 $this->form->addCommandButton(
'update', $lng->txt(
'dcl_table_'.$a_mode));
215 $this->form->addCommandButton(
'save', $lng->txt(
'dcl_table_'.$a_mode));
218 $this->form->addCommandButton(
'cancel', $lng->txt(
'cancel'));
219 $this->form->setFormAction($ilCtrl->getFormAction($this, $a_mode));
220 if($a_mode ==
"edit")
222 $this->form->setTitle($lng->txt(
'dcl_edit_table'));
226 $this->form->setTitle($lng->txt(
'dcl_new_table'));
236 public function save($a_mode =
"create")
246 $ilTabs->activateTab(
"id_fields");
252 if($a_mode !=
"update")
256 elseif($this->table_id)
262 $ilCtrl->redirectByClass(
"ildatacollectionfieldeditgui",
"listFields");
266 $this->table->setTitle($this->form->getInput(
"title"));
267 $this->table->setObjId($this->obj_id);
268 $this->table->setIsVisible($this->form->getInput(
"is_visible"));
269 $this->table->setAddPerm($this->form->getInput(
"add_perm"));
270 $this->table->setEditPerm($this->form->getInput(
"edit_perm"));
271 $this->table->setDeletePerm($this->form->getInput(
"delete_perm"));
272 $this->table->setEditByOwner($this->form->getInput(
"edit_by_owner"));
273 $this->table->setExportEnabled($this->form->getInput(
"export_enabled"));
274 $this->table->setLimited($this->form->getInput(
"limited"));
275 $limit_start = $this->form->getInput(
"limit_start");
276 $limit_end = $this->form->getInput(
"limit_end");
277 $this->table->setLimitStart($limit_start[
"date"].
" ".$limit_start[
"time"]);
278 $this->table->setLimitEnd($limit_end[
"date"].
" ".$limit_end[
"time"]);
280 if(!$this->table->hasPermissionToAddTable($this->parent_object->ref_id))
285 if($a_mode ==
"update")
287 $this->table->doUpdate();
289 $ilCtrl->redirectByClass(
"ildatacollectiontableeditgui",
"edit");
296 $this->table->doCreate();
298 $ilCtrl->setParameterByClass(
"ildatacollectionfieldlistgui",
"table_id", $this->table->getId());
299 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
305 $this->form->setValuesByPost();
306 $tpl->setContent($this->form->getHTML());
317 $return = $this->form->checkInput();
320 if ($a_mode ==
'create') {
321 if (
$title = $this->form->getInput(
'title')) {
323 $inputObj = $this->form->getItemByPostVar(
'title');
324 $inputObj->setAlert($lng->txt(
"dcl_table_title_unique"));
341 $tpl->setContent(
"Access denied.");
351 include_once
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
353 $conf->setFormAction($ilCtrl->getFormAction($this));
354 $conf->setHeaderText($lng->txt(
'dcl_confirm_delete_table'));
356 $conf->addItem(
'table', (
int) $this->table->getId(), $this->table->getTitle());
358 $conf->setConfirm($lng->txt(
'delete'),
'delete');
359 $conf->setCancel($lng->txt(
'cancel'),
'cancelDelete');
361 $tpl->setContent($conf->getHTML());
371 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
377 public function delete()
380 $mainTableId = $this->table->getCollectionObject()->getMainTableId();
381 if($mainTableId == $this->table->getId()){
385 $ilCtrl->setParameterByClass(
"ildatacollectionfieldlistgui",
"table_id", $mainTableId);
388 $this->table->doDelete();
389 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
397 $ref_id = $this->parent_object->getDataCollectionObject()->getRefId();