ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
12{
13
17 protected $ctrl;
21 protected $lng;
25 protected $tpl;
29 protected $tabs;
33 protected $toolbar;
34
35
41 public function __construct(ilObjDataCollectionGUI $a_parent_obj)
42 {
43 global $DIC;
44 $ilCtrl = $DIC['ilCtrl'];
45 $lng = $DIC['lng'];
46 $tpl = $DIC['tpl'];
47 $ilTabs = $DIC['ilTabs'];
48 $ilToolbar = $DIC['ilToolbar'];
49
50 $this->parent_obj = $a_parent_obj;
51 $this->obj_id = $a_parent_obj->obj_id;
52 $this->ctrl = $ilCtrl;
53 $this->lng = $lng;
54 $this->tpl = $tpl;
55 $this->tabs = $ilTabs;
56 $this->toolbar = $ilToolbar;
57
58 if (!$this->checkAccess()) {
59 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
60 $this->ctrl->redirectByClass('ildclrecordlistgui', 'listRecords');
61 }
62 }
63
64
68 public function executeCommand()
69 {
70 global $DIC;
71 $cmd = $this->ctrl->getCmd('listTables');
72
73 $next_class = $this->ctrl->getNextClass($this);
74
75 /*
76 * see https://www.ilias.de/mantis/view.php?id=22775
77 */
78 $tableHelper = new ilDclTableHelper((int) $this->obj_id, (int) $_GET['ref_id'], $DIC->rbac()->review(), $DIC->user(), $DIC->database());
79 // send a warning if there are roles with rbac read access on the data collection but without read access on any standard view
80 $role_titles = $tableHelper->getRoleTitlesWithoutReadRightOnAnyStandardView();
81
82 if (count($role_titles) > 0) {
83 ilUtil::sendInfo($DIC->language()->txt('dcl_rbac_roles_without_read_access_on_any_standard_view') . " " . implode(", ", $role_titles));
84 }
85
86 switch ($next_class) {
87 case 'ildcltableeditgui':
88 $this->tabs->clearTargets();
89 if ($cmd != 'create') {
90 $this->setTabs('settings');
91 } else {
92 $this->tabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'listTables'));
93 }
94 $ilDclTableEditGUI = new ilDclTableEditGUI($this);
95 $this->ctrl->forwardCommand($ilDclTableEditGUI);
96 break;
97
98 case 'ildclfieldlistgui':
99 $this->tabs->clearTargets();
100 $this->setTabs('fields');
101 $ilDclFieldListGUI = new ilDclFieldListGUI($this);
102 $this->ctrl->forwardCommand($ilDclFieldListGUI);
103 break;
104
105 case "ildclfieldeditgui":
106 $this->tabs->clearTargets();
107 $this->setTabs("fields");
108 $ilDclFieldEditGUI = new ilDclFieldEditGUI($this);
109 $this->ctrl->forwardCommand($ilDclFieldEditGUI);
110 break;
111
112 case 'ildcltableviewgui':
113 $this->tabs->clearTargets();
114 $this->setTabs('tableviews');
115 $ilDclTableViewGUI = new ilDclTableViewGUI($this);
116 $this->ctrl->forwardCommand($ilDclTableViewGUI);
117 break;
118
119 default:
120 switch ($cmd) {
121 default:
122 $this->$cmd();
123 break;
124 }
125 }
126 }
127
128
129 public function listTables()
130 {
131 $add_new = ilLinkButton::getInstance();
132 $add_new->setPrimary(true);
133 $add_new->setCaption("dcl_add_new_table");
134 $add_new->setUrl($this->ctrl->getLinkTargetByClass('ilDclTableEditGUI', 'create'));
135 $this->toolbar->addStickyItem($add_new);
136
137 $table_gui = new ilDclTableListTableGUI($this);
138 $this->tpl->setContent($table_gui->getHTML());
139 }
140
141
142 protected function setTabs($active)
143 {
144 $this->tabs->setBackTarget($this->lng->txt('dcl_tables'), $this->ctrl->getLinkTarget($this, 'listTables'));
145 $this->tabs->addTab('settings', $this->lng->txt('settings'), $this->ctrl->getLinkTargetByClass('ilDclTableEditGUI', 'edit'));
146 $this->tabs->addTab('fields', $this->lng->txt('dcl_list_fields'), $this->ctrl->getLinkTargetByClass('ilDclFieldListGUI', 'listFields'));
147 $this->tabs->addTab('tableviews', $this->lng->txt('dcl_tableviews'), $this->ctrl->getLinkTargetByClass('ilDclTableViewGUI'));
148 $this->tabs->setTabActive($active);
149 }
150
151
155 protected function save()
156 {
157 $comments = $_POST['comments'];
158 $visible = $_POST['visible'];
159 $orders = $_POST['order'];
160 asort($orders);
161 $order = 10;
162 foreach (array_keys($orders) as $table_id) {
163 $table = ilDclCache::getTableCache($table_id);
164 $table->setOrder($order);
165 $table->setPublicCommentsEnabled(isset($comments[$table_id]));
166 $table->setIsVisible(isset($visible[$table_id]));
167 $table->doUpdate();
168 $order += 10;
169 }
170 $this->ctrl->redirect($this);
171 }
172
173
177 public function confirmDeleteTables()
178 {
179 //at least one table must exist
180 $tables = isset($_POST['dcl_table_ids']) ? $_POST['dcl_table_ids'] : array();
181 $this->checkTablesLeft(count($tables));
182
183 $this->tabs->clearSubTabs();
184 $conf = new ilConfirmationGUI();
185 $conf->setFormAction($this->ctrl->getFormAction($this));
186 $conf->setHeaderText($this->lng->txt('dcl_tables_confirm_delete'));
187
188 foreach ($tables as $table_id) {
189 $conf->addItem('dcl_table_ids[]', $table_id, ilDclCache::getTableCache($table_id)->getTitle());
190 }
191 $conf->setConfirm($this->lng->txt('delete'), 'deleteTables');
192 $conf->setCancel($this->lng->txt('cancel'), 'listTables');
193 $this->tpl->setContent($conf->getHTML());
194 }
195
196
200 protected function deleteTables()
201 {
202 $tables = isset($_POST['dcl_table_ids']) ? $_POST['dcl_table_ids'] : array();
203 foreach ($tables as $table_id) {
204 ilDclCache::getTableCache($table_id)->doDelete();
205 }
206 ilUtil::sendSuccess($this->lng->txt('dcl_msg_tables_deleted'), true);
207 $this->ctrl->redirect($this, 'listTables');
208 }
209
210
216 public function checkTablesLeft($delete_count)
217 {
218 if ($delete_count >= count($this->getDataCollectionObject()->getTables())) {
219 ilUtil::sendFailure($this->lng->txt('dcl_msg_tables_delete_all'), true);
220 $this->ctrl->redirect($this, 'listTables');
221 }
222 }
223
224
228 protected function checkAccess()
229 {
230 $ref_id = $this->getDataCollectionObject()->getRefId();
231
233 }
234
235
239 public function getDataCollectionObject()
240 {
241 return $this->parent_obj->getDataCollectionObject();
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 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
$DIC
Definition: xapitoken.php:46