ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilDclTableListGUI.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/Table/class.ilDclTableListTableGUI.php');
5require_once ('./Services/Utilities/classes/class.ilConfirmationGUI.php');
14
18 protected $ctrl;
19
23 protected $lng;
24
28 protected $tpl;
29
33 protected $tabs;
34
38 protected $toolbar;
39
45 public function __construct(ilObjDataCollectionGUI $a_parent_obj) {
46 global $DIC;
47 $ilCtrl = $DIC['ilCtrl'];
48 $lng = $DIC['lng'];
49 $tpl = $DIC['tpl'];
50 $ilTabs = $DIC['ilTabs'];
51 $ilToolbar = $DIC['ilToolbar'];
52
53
54 $this->parent_obj = $a_parent_obj;
55 $this->obj_id = $a_parent_obj->obj_id;
56 $this->ctrl = $ilCtrl;
57 $this->lng = $lng;
58 $this->tpl = $tpl;
59 $this->tabs = $ilTabs;
60 $this->toolbar = $ilToolbar;
61
62 if ( ! $this->checkAccess()) {
63 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
64 $this->ctrl->redirectByClass('ildclrecordlistgui', 'listRecords');
65 }
66 }
67
71 public function executeCommand()
72 {
73 global $DIC;
74 $cmd = $this->ctrl->getCmd('listTables');
75
76 $next_class = $this->ctrl->getNextClass($this);
77
78 /*
79 * see https://www.ilias.de/mantis/view.php?id=22775
80 */
81 require_once('./Modules/DataCollection/classes/Table/class.ilDclTableHelper.php');
82 $tableHelper = new ilDclTableHelper((int)$this->obj_id, (int)$_GET['ref_id'], $DIC->rbac()->review(), $DIC->user(), $DIC->database());
83 // send a warning if there are roles with rbac read access on the data collection but without read access on any standard view
84 $role_titles = $tableHelper->getRoleTitlesWithoutReadRightOnAnyStandardView();
85
86 if (count($role_titles) > 0) {
87 ilUtil::sendInfo($DIC->language()->txt('dcl_rbac_roles_without_read_access_on_any_standard_view') . " " . implode(", ", $role_titles));
88 }
89
90 switch ($next_class) {
91 case 'ildcltableeditgui':
92 $this->tabs->clearTargets();
93 if ($cmd != 'create') {
94 $this->setTabs('settings');
95 } else {
96 $this->tabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'listTables'));
97 }
98 require_once 'Modules/DataCollection/classes/Table/class.ilDclTableEditGUI.php';
99 $ilDclTableEditGUI = new ilDclTableEditGUI($this);
100 $this->ctrl->forwardCommand($ilDclTableEditGUI);
101 break;
102
103 case 'ildclfieldlistgui' :
104 $this->tabs->clearTargets();
105 $this->setTabs('fields');
106 require_once 'Modules/DataCollection/classes/Fields/class.ilDclFieldListGUI.php';
107 $ilDclFieldListGUI = new ilDclFieldListGUI($this);
108 $this->ctrl->forwardCommand($ilDclFieldListGUI);
109 break;
110
111 case "ildclfieldeditgui":
112 $this->tabs->clearTargets();
113 $this->setTabs("fields");
114 require_once "Modules/DataCollection/classes/Fields/class.ilDclFieldEditGUI.php";
115 $ilDclFieldEditGUI = new ilDclFieldEditGUI($this);
116 $this->ctrl->forwardCommand($ilDclFieldEditGUI);
117 break;
118
119 case 'ildcltableviewgui' :
120 $this->tabs->clearTargets();
121 $this->setTabs('tableviews');
122 require_once 'Modules/DataCollection/classes/TableView/class.ilDclTableViewGUI.php';
123 $ilDclTableViewGUI = new ilDclTableViewGUI($this);
124 $this->ctrl->forwardCommand($ilDclTableViewGUI);
125 break;
126
127 default:
128 switch($cmd) {
129 default:
130 $this->$cmd();
131 break;
132 }
133 }
134 }
135
136 public function listTables() {
137 $add_new = ilLinkButton::getInstance();
138 $add_new->setPrimary(true);
139 $add_new->setCaption("dcl_add_new_table");
140 $add_new->setUrl($this->ctrl->getLinkTargetByClass('ilDclTableEditGUI', 'create'));
141 $this->toolbar->addStickyItem($add_new);
142
143 $table_gui = new ilDclTableListTableGUI($this);
144 $this->tpl->setContent($table_gui->getHTML());
145 }
146
147 protected function setTabs($active) {
148 $this->tabs->setBackTarget($this->lng->txt('dcl_tables'), $this->ctrl->getLinkTarget($this, 'listTables'));
149 $this->tabs->addTab('settings', $this->lng->txt('settings'), $this->ctrl->getLinkTargetByClass('ilDclTableEditGUI', 'edit'));
150 $this->tabs->addTab('fields', $this->lng->txt('dcl_list_fields'), $this->ctrl->getLinkTargetByClass('ilDclFieldListGUI', 'listFields'));
151 $this->tabs->addTab('tableviews', $this->lng->txt('dcl_tableviews'), $this->ctrl->getLinkTargetByClass('ilDclTableViewGUI'));
152 $this->tabs->setTabActive($active);
153 }
154
158 protected function save() {
159 $comments = $_POST['comments'];
160 $visible = $_POST['visible'];
161 $orders = $_POST['order'];
162 asort($orders);
163 $order = 10;
164 foreach(array_keys($orders) as $table_id)
165 {
166 $table = ilDclCache::getTableCache($table_id);
167 $table->setOrder($order);
168 $table->setPublicCommentsEnabled(isset($comments[$table_id]));
169 $table->setIsVisible(isset($visible[$table_id]));
170 $table->doUpdate();
171 $order += 10;
172 }
173 $this->ctrl->redirect($this);
174 }
175
179 public function confirmDeleteTables()
180 {
181 //at least one table must exist
182 $tables = isset($_POST['dcl_table_ids']) ? $_POST['dcl_table_ids'] : array();
183 $this->checkTablesLeft(count($tables));
184
185 $this->tabs->clearSubTabs();
186 $conf = new ilConfirmationGUI();
187 $conf->setFormAction($this->ctrl->getFormAction($this));
188 $conf->setHeaderText($this->lng->txt('dcl_tables_confirm_delete'));
189
190 foreach ($tables as $table_id) {
191 $conf->addItem('dcl_table_ids[]', $table_id, ilDclCache::getTableCache($table_id)->getTitle());
192 }
193 $conf->setConfirm($this->lng->txt('delete'), 'deleteTables');
194 $conf->setCancel($this->lng->txt('cancel'), 'listTables');
195 $this->tpl->setContent($conf->getHTML());
196 }
197
201 protected function deleteTables()
202 {
203 $tables = isset($_POST['dcl_table_ids']) ? $_POST['dcl_table_ids'] : array();
204 foreach ($tables as $table_id) {
205 ilDclCache::getTableCache($table_id)->doDelete();
206 }
207 ilUtil::sendSuccess($this->lng->txt('dcl_msg_tables_deleted'), true);
208 $this->ctrl->redirect($this, 'listTables');
209 }
210
216 public function checkTablesLeft($delete_count)
217 {
218 if ($delete_count >= count($this->getDataCollectionObject()->getTables()))
219 {
220 ilUtil::sendFailure($this->lng->txt('dcl_msg_tables_delete_all'), true);
221 $this->ctrl->redirect($this, 'listTables');
222 }
223 }
224
228 protected function checkAccess()
229 {
230 $ref_id = $this->getDataCollectionObject()->getRefId();
232 }
233
234
238 public function getDataCollectionObject() {
239 return $this->parent_obj->getDataCollectionObject();
240 }
241
242
243}
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Confirmation screen class.
static getTableCache($table_id=0)
Class ilDclFieldEditGUI.
Class ilDclBaseFieldModel.
Class ilDclTableHelper.
Class ilDclTableListGUI.
executeCommand()
execute command
__construct(ilObjDataCollectionGUI $a_parent_obj)
ilDclTableListGUI constructor.
confirmDeleteTables()
Confirm deletion of multiple fields.
checkTablesLeft($delete_count)
redirects if there are no tableviews left after deletion of {$delete_count} tableviews
Class ilDclTableListTableGUI.
Class ilDclTableViewGUI.
static getInstance()
Factory.
Class ilObjDataCollectionGUI.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
$ref_id
Definition: sahs_server.php:39
global $DIC