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(),
121 'description' => $this->table->getDescription(),
123 if(!$this->table->getLimitStart())
124 $values[
'limit_start'] = NULL;
125 if(!$this->table->getLimitEnd())
126 $values[
'limit_end'] = NULL;
127 $this->form->setValuesByArray($values);
141 'edit_by_owner' => 1,
142 'export_enabled' => 0,
144 'limit_start' => NULL,
147 $this->form->setValuesByArray($values);
157 $ilCtrl->redirectByClass(
"ilDataCollectionFieldListGUI",
"listFields");
169 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
174 $this->form->addItem($item);
176 $this->form->addItem($item);
181 $item->setRteTagSet(
'mini');
182 $this->form->addItem($item);
185 $section->setTitle($lng->txt(
'dcl_permissions_form'));
189 $item->setHtml($lng->txt(
'dcl_table_info'));
190 $item->setTitle($lng->txt(
'dcl_table_info_title'));
191 $this->form->addItem($item);
195 $this->form->addItem($item);
198 $this->form->addItem($item);
201 $this->form->addItem($item);
204 $this->form->addItem($item);
207 $this->form->addItem($item);
211 $sitem1->setShowTime(
true);
215 $item->addSubItem($sitem1);
216 $item->addSubItem($sitem2);
217 $this->form->addItem($item);
218 if($a_mode ==
"edit")
220 $this->form->addCommandButton(
'update', $lng->txt(
'dcl_table_'.$a_mode));
224 $this->form->addCommandButton(
'save', $lng->txt(
'dcl_table_'.$a_mode));
227 $this->form->addCommandButton(
'cancel', $lng->txt(
'cancel'));
228 $this->form->setFormAction($ilCtrl->getFormAction($this, $a_mode));
229 if($a_mode ==
"edit")
231 $this->form->setTitle($lng->txt(
'dcl_edit_table'));
235 $this->form->setTitle($lng->txt(
'dcl_new_table'));
245 public function save($a_mode =
"create")
255 $ilTabs->activateTab(
"id_fields");
261 if($a_mode !=
"update")
265 elseif($this->table_id)
271 $ilCtrl->redirectByClass(
"ildatacollectionfieldeditgui",
"listFields");
275 $this->table->setTitle($this->form->getInput(
"title"));
276 $this->table->setObjId($this->obj_id);
277 $this->table->setIsVisible($this->form->getInput(
"is_visible"));
278 $this->table->setAddPerm($this->form->getInput(
"add_perm"));
279 $this->table->setEditPerm($this->form->getInput(
"edit_perm"));
280 $this->table->setDeletePerm($this->form->getInput(
"delete_perm"));
281 $this->table->setEditByOwner($this->form->getInput(
"edit_by_owner"));
282 $this->table->setExportEnabled($this->form->getInput(
"export_enabled"));
283 $this->table->setDescription($this->form->getInput(
'description'));
284 $this->table->setLimited($this->form->getInput(
"limited"));
285 $limit_start = $this->form->getInput(
"limit_start");
286 $limit_end = $this->form->getInput(
"limit_end");
287 $this->table->setLimitStart($limit_start[
"date"].
" ".$limit_start[
"time"]);
288 $this->table->setLimitEnd($limit_end[
"date"].
" ".$limit_end[
"time"]);
290 if(!$this->table->hasPermissionToAddTable($this->parent_object->ref_id))
295 if($a_mode ==
"update")
297 $this->table->doUpdate();
299 $ilCtrl->redirectByClass(
"ildatacollectiontableeditgui",
"edit");
306 $this->table->doCreate();
308 $ilCtrl->setParameterByClass(
"ildatacollectionfieldlistgui",
"table_id", $this->table->getId());
309 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
315 $this->form->setValuesByPost();
316 $tpl->setContent($this->form->getHTML());
327 $return = $this->form->checkInput();
330 if ($a_mode ==
'create') {
331 if ($title = $this->form->getInput(
'title')) {
333 $inputObj = $this->form->getItemByPostVar(
'title');
334 $inputObj->setAlert($lng->txt(
"dcl_table_title_unique"));
351 $tpl->setContent(
"Access denied.");
361 include_once
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
363 $conf->setFormAction($ilCtrl->getFormAction($this));
364 $conf->setHeaderText($lng->txt(
'dcl_confirm_delete_table'));
366 $conf->addItem(
'table', (
int) $this->table->getId(), $this->table->getTitle());
368 $conf->setConfirm($lng->txt(
'delete'),
'delete');
369 $conf->setCancel($lng->txt(
'cancel'),
'cancelDelete');
371 $tpl->setContent($conf->getHTML());
381 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
387 public function delete()
390 $mainTableId = $this->table->getCollectionObject()->getMainTableId();
391 if($mainTableId == $this->table->getId()){
395 $ilCtrl->setParameterByClass(
"ildatacollectionfieldlistgui",
"table_id", $mainTableId);
398 $this->table->doDelete();
399 $ilCtrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
407 $ref_id = $this->parent_object->getDataCollectionObject()->getRefId();