5 require_once(
"./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
53 $this->parent_object = $a_parent_obj;
54 $this->obj_id = $a_parent_obj->obj_id;
55 $this->table_id =
$_GET[
'table_id'];
59 $this->ctrl->redirectByClass(
'ildatacollectionrecordlistgui',
'listRecords');
68 $cmd = $this->ctrl->getCmd();
69 $this->tpl->getStandardTemplate();
73 $this->
save(
"update");
90 $this->tpl->setContent($this->form->getHTML());
98 if (! $this->table_id) {
99 $this->ctrl->redirectByClass(
"ildatacollectionfieldeditgui",
"listFields");
107 $this->tpl->setContent($this->form->getHTML());
116 'title' => $this->table->getTitle(),
117 'add_perm' => $this->table->getAddPerm(),
118 'edit_perm' => $this->table->getEditPerm(),
119 'delete_perm' => $this->table->getDeletePerm(),
120 'edit_by_owner' => $this->table->getEditByOwner(),
121 'export_enabled' => $this->table->getExportEnabled(),
122 'limited' => $this->table->getLimited(),
123 'limit_start' => array(
"date" => substr($this->table->getLimitStart(), 0, 10),
"time" => substr($this->table->getLimitStart(), - 8) ),
124 'limit_end' => array(
"date" => substr($this->table->getLimitEnd(), 0, 10),
"time" => substr($this->table->getLimitEnd(), - 8) ),
125 'is_visible' => $this->table->getIsVisible(),
126 'default_sort_field' => $this->table->getDefaultSortField(),
127 'default_sort_field_order' => $this->table->getDefaultSortFieldOrder(),
128 'description' => $this->table->getDescription(),
129 'public_comments' => $this->table->getPublicCommentsEnabled(),
130 'view_own_records_perm' => $this->table->getViewOwnRecordsPerm(),
132 if (! $this->table->getLimitStart()) {
133 $values[
'limit_start'] = NULL;
135 if (! $this->table->getLimitEnd()) {
136 $values[
'limit_end'] = NULL;
138 $this->form->setValuesByArray($values);
152 'edit_by_owner' => 1,
153 'export_enabled' => 0,
155 'limit_start' => NULL,
158 $this->form->setValuesByArray($values);
166 $this->ctrl->redirectByClass(
"ilDataCollectionFieldListGUI",
"listFields");
176 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
181 $this->form->addItem($item);
183 $this->form->addItem($item);
186 if ($a_mode !=
'create') {
187 $item =
new ilSelectInputGUI($this->lng->txt(
'dcl_default_sort_field'),
'default_sort_field');
188 $fields = $this->table->getVisibleFields();
189 $options = array( 0 => $this->lng->txt(
'dcl_please_select') );
190 foreach ($fields as $field) {
191 $options[$field->getId()] = $field->getTitle();
194 $this->form->addItem($item);
196 $item =
new ilSelectInputGUI($this->lng->txt(
'dcl_default_sort_field_order'),
'default_sort_field_order');
197 $options = array(
'asc' => $this->lng->txt(
'dcl_asc'),
'desc' => $this->lng->txt(
'dcl_desc') );
198 $item->setOptions($options);
199 $this->form->addItem($item);
205 $item->setRteTagSet(
'mini');
206 $this->form->addItem($item);
208 $item =
new ilCheckboxInputGUI($this->lng->txt(
'dcl_public_comments'),
'public_comments');
209 $this->form->addItem($item);
212 $section->setTitle($this->lng->txt(
'dcl_permissions_form'));
216 $item->setHtml($this->lng->txt(
'dcl_table_info'));
217 $item->setTitle($this->lng->txt(
'dcl_table_info_title'));
218 $this->form->addItem($item);
222 $this->form->addItem($item);
225 $this->form->addItem($item);
228 $this->form->addItem($item);
229 $item =
new ilCheckboxInputGUI($this->lng->txt(
'dcl_edit_by_owner'),
'edit_by_owner');
231 $this->form->addItem($item);
233 $item =
new ilCheckboxInputGUI($this->lng->txt(
'dcl_view_own_records_perm'),
'view_own_records_perm');
235 $this->form->addItem($item);
237 $item =
new ilCheckboxInputGUI($this->lng->txt(
'dcl_export_enabled'),
'export_enabled');
238 $this->form->addItem($item);
242 $sitem1->setShowTime(
true);
246 $item->addSubItem($sitem1);
247 $item->addSubItem($sitem2);
248 $this->form->addItem($item);
250 if ($a_mode ==
"edit") {
251 $this->form->addCommandButton(
'update', $this->lng->txt(
'dcl_table_' . $a_mode));
253 $this->form->addCommandButton(
'save', $this->lng->txt(
'dcl_table_' . $a_mode));
256 $this->form->addCommandButton(
'cancel', $this->lng->txt(
'cancel'));
257 $this->form->setFormAction($this->ctrl->getFormAction($this, $a_mode));
258 if ($a_mode ==
"edit") {
259 $this->form->setTitle($this->lng->txt(
'dcl_edit_table'));
261 $this->form->setTitle($this->lng->txt(
'dcl_new_table'));
271 public function save($a_mode =
"create") {
280 $ilTabs->activateTab(
"id_fields");
285 if ($a_mode !=
"update") {
287 } elseif ($this->table_id) {
290 $this->ctrl->redirectByClass(
"ildatacollectionfieldeditgui",
"listFields");
293 $this->table->setTitle($this->form->getInput(
"title"));
294 $this->table->setObjId($this->obj_id);
295 $this->table->setIsVisible($this->form->getInput(
"is_visible"));
296 $this->table->setAddPerm($this->form->getInput(
"add_perm"));
297 $this->table->setEditPerm($this->form->getInput(
"edit_perm"));
298 $this->table->setDeletePerm($this->form->getInput(
"delete_perm"));
299 $this->table->setEditByOwner($this->form->getInput(
"edit_by_owner"));
300 $this->table->setViewOwnRecordsPerm($this->form->getInput(
'view_own_records_perm'));
301 $this->table->setExportEnabled($this->form->getInput(
"export_enabled"));
302 $this->table->setDefaultSortField($this->form->getInput(
"default_sort_field"));
303 $this->table->setDefaultSortFieldOrder($this->form->getInput(
"default_sort_field_order"));
304 $this->table->setPublicCommentsEnabled($this->form->getInput(
'public_comments'));
305 $this->table->setLimited($this->form->getInput(
"limited"));
306 $this->table->setDescription($this->form->getInput(
'description'));
307 $limit_start = $this->form->getInput(
"limit_start");
308 $limit_end = $this->form->getInput(
"limit_end");
309 $this->table->setLimitStart($limit_start[
"date"] .
" " . $limit_start[
"time"]);
310 $this->table->setLimitEnd($limit_end[
"date"] .
" " . $limit_end[
"time"]);
312 if (! $this->table->hasPermissionToAddTable($this->parent_object->ref_id)) {
317 if ($a_mode ==
"update") {
318 $this->table->doUpdate();
320 $this->ctrl->redirectByClass(
"ildatacollectiontableeditgui",
"edit");
322 $this->table->doCreate();
324 $this->ctrl->setParameterByClass(
"ildatacollectionfieldlistgui",
"table_id", $this->table->getId());
325 $this->ctrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
328 $this->form->setValuesByPost();
329 $this->tpl->setContent($this->form->getHTML());
342 $return = $this->form->checkInput();
345 if ($a_mode ==
'create') {
346 if ($title = $this->form->getInput(
'title')) {
348 $inputObj = $this->form->getItemByPostVar(
'title');
349 $inputObj->setAlert($this->lng->txt(
"dcl_table_title_unique"));
367 $this->tpl->setContent(
"Access denied.");
375 include_once
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
377 $conf->setFormAction($this->ctrl->getFormAction($this));
378 $conf->setHeaderText($this->lng->txt(
'dcl_confirm_delete_table'));
380 $conf->addItem(
'table', (
int)$this->table->getId(), $this->table->getTitle());
382 $conf->setConfirm($this->lng->txt(
'delete'),
'delete');
383 $conf->setCancel($this->lng->txt(
'cancel'),
'cancelDelete');
385 $this->tpl->setContent($conf->getHTML());
393 $this->ctrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
400 public function delete() {
401 $mainTableId = $this->table->getCollectionObject()->getMainTableId();
402 if ($mainTableId == $this->table->getId()) {
405 $this->ctrl->setParameterByClass(
"ildatacollectionfieldlistgui",
"table_id", $mainTableId);
408 $this->table->doDelete();
409 $this->ctrl->redirectByClass(
"ildatacollectionfieldlistgui",
"listFields");
417 $ref_id = $this->parent_object->getDataCollectionObject()->getRefId();