ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilDataCollectionFieldListGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once ("./Modules/DataCollection/classes/class.ilDataCollectionField.php");
5require_once ("./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
6include_once("class.ilDataCollectionDatatype.php");
7require_once "class.ilDataCollectionCache.php";
8require_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
9require_once('./Modules/DataCollection/classes/class.ilDataCollectionFieldListTableGUI.php');
10
11
26{
27
31 protected $ctrl;
32
33
37 protected $lng;
38
42 protected $toolbar;
43
47 protected $tpl;
48
52 protected $tabs;
53
60 public function __construct(ilObjDataCollectionGUI $a_parent_obj, $table_id)
61 {
62 global $ilCtrl, $lng, $ilToolbar, $tpl, $ilTabs;
63
64 $this->main_table_id = $a_parent_obj->object->getMainTableId();
65 $this->table_id = $table_id;
66 $this->parent_obj = $a_parent_obj;
67 $this->obj_id = $a_parent_obj->obj_id;
68 $this->ctrl = $ilCtrl;
69 $this->lng = $lng;
70 $this->tpl = $tpl;
71 $this->tabs = $ilTabs;
72 $this->toolbar = $ilToolbar;
73 if ( ! $this->checkAccess()) {
74 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
75 $this->ctrl->redirectByClass('ildatacollectionrecordlistgui', 'listRecords');
76 }
77 }
78
79
83 public function executeCommand()
84 {
85 $cmd = $this->ctrl->getCmd();
86 switch($cmd) {
87 default:
88 $this->$cmd();
89 break;
90 }
91 }
92
96 public function deleteFields()
97 {
98 $field_ids = isset($_POST['dcl_field_ids']) ? $_POST['dcl_field_ids'] : array();
99 $table = ilDataCollectionCache::getTableCache($this->table_id);
100 foreach ($field_ids as $field_id) {
101 $table->deleteField($field_id);
102 }
103 ilUtil::sendSuccess($this->lng->txt('dcl_msg_fields_deleted'), true);
104 $this->ctrl->redirect($this, 'listFields');
105 }
106
110 public function confirmDeleteFields() {
111 $this->tabs->clearSubTabs();
112 $conf = new ilConfirmationGUI();
113 $conf->setFormAction($this->ctrl->getFormAction($this));
114 $conf->setHeaderText($this->lng->txt('dcl_confirm_delete_fields'));
115 $field_ids = isset($_POST['dcl_field_ids']) ? $_POST['dcl_field_ids'] : array();
116 foreach ($field_ids as $field_id) {
118 $field = ilDataCollectionCache::getFieldCache($field_id);
119 $conf->addItem('dcl_field_ids[]', $field_id, $field->getTitle());
120 }
121 $conf->setConfirm($this->lng->txt('delete'), 'deleteFields');
122 $conf->setCancel($this->lng->txt('cancel'), 'listFields');
123 $this->tpl->setContent($conf->getHTML());
124 }
125
126 /*
127 * save
128 */
129 public function save()
130 {
131 $table = ilDataCollectionCache::getTableCache($_GET['table_id']);
132 $fields = $table->getFields();
133
134 foreach($fields as $field)
135 {
136 $field->setVisible($_POST['visible'][$field->getId()] == "on");
137 $field->setEditable($_POST['editable'][$field->getId()] == "on");
138 $field->setFilterable($_POST['filterable'][$field->getId()] == "on");
139 $field->setLocked($_POST['locked'][$field->getId()] == "on");
140 $field->setExportable($_POST['exportable'][$field->getId()] == "on");
141 $field->setOrder($_POST['order'][$field->getId()]);
142 $field->doUpdate();
143 }
144 $table->buildOrderFields();
145 ilUtil::sendSuccess($this->lng->txt("dcl_table_settings_saved"));
146 $this->listFields();
147 }
148
152 public function listFields()
153 {
154 // Show tables
155 require_once("./Modules/DataCollection/classes/class.ilDataCollectionTable.php");
156 $tables = $this->parent_obj->object->getTables();
157
158 foreach($tables as $table)
159 {
160 $options[$table->getId()] = $table->getTitle();
161 }
162 include_once './Services/Form/classes/class.ilSelectInputGUI.php';
163 $table_selection = new ilSelectInputGUI('', 'table_id');
164 $table_selection->setOptions($options);
165 $table_selection->setValue($this->table_id);
166
167 $this->toolbar->setFormAction($this->ctrl->getFormActionByClass("ilDataCollectionFieldListGUI", "doTableSwitch"));
168 $this->toolbar->addText($this->lng->txt("dcl_table"));
169 $this->toolbar->addInputItem($table_selection);
170 $this->toolbar->addFormButton($this->lng->txt('change'),'doTableSwitch');
171 $this->toolbar->addSeparator();
172 $this->toolbar->addButton($this->lng->txt("dcl_add_new_table"), $this->ctrl->getLinkTargetByClass("ildatacollectiontableeditgui", "create"));
173 $this->toolbar->addSeparator();
174 $this->ctrl->setParameterByClass("ildatacollectiontableeditgui", "table_id", $this->table_id);
175 $this->toolbar->addButton($this->lng->txt("dcl_table_settings"), $this->ctrl->getLinkTargetByClass("ildatacollectiontableeditgui", "edit"));
176 $this->toolbar->addSeparator();
177 $this->toolbar->addButton($this->lng->txt("dcl_delete_table"), $this->ctrl->getLinkTargetByClass("ildatacollectiontableeditgui", "confirmDelete"));
178 $this->toolbar->addSeparator();
179 $this->toolbar->addButton($this->lng->txt("dcl_add_new_field"), $this->ctrl->getLinkTargetByClass("ildatacollectionfieldeditgui", "create"));
180 $list = new ilDataCollectionFieldListTableGUI($this, $this->ctrl->getCmd(), $this->table_id);
181 $this->tpl->setContent($list->getHTML());
182
183 }
184
185 /*
186 * doTableSwitch
187 */
188 public function doTableSwitch()
189 {
190 $this->ctrl->setParameterByClass("ilObjDataCollectionGUI", "table_id", $_POST['table_id']);
191 $this->ctrl->redirectByClass("ilDataCollectionFieldListGUI", "listFields");
192 }
193
197 protected function checkAccess()
198 {
199 $ref_id = $this->parent_obj->getDataCollectionObject()->getRefId();
201 }
202
203}
204
205?>
$_GET["client_id"]
Confirmation screen class.
Class ilDataCollectionFieldListGUI.
__construct(ilObjDataCollectionGUI $a_parent_obj, $table_id)
Constructor.
Class ilObjDataCollectionGUI.
This class represents a selection list property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
$ref_id
Definition: sahs_server.php:39
if(!is_array($argv)) $options