ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 require_once 'Modules/DataCollection/classes/Table/class.ilDclTableEditGUI.php';
95 $ilDclTableEditGUI = new ilDclTableEditGUI($this);
96 $this->ctrl->forwardCommand($ilDclTableEditGUI);
97 break;
98
99 case 'ildclfieldlistgui':
100 $this->tabs->clearTargets();
101 $this->setTabs('fields');
102 require_once 'Modules/DataCollection/classes/Fields/class.ilDclFieldListGUI.php';
103 $ilDclFieldListGUI = new ilDclFieldListGUI($this);
104 $this->ctrl->forwardCommand($ilDclFieldListGUI);
105 break;
106
107 case "ildclfieldeditgui":
108 $this->tabs->clearTargets();
109 $this->setTabs("fields");
110 require_once "Modules/DataCollection/classes/Fields/class.ilDclFieldEditGUI.php";
111 $ilDclFieldEditGUI = new ilDclFieldEditGUI($this);
112 $this->ctrl->forwardCommand($ilDclFieldEditGUI);
113 break;
114
115 case 'ildcltableviewgui':
116 $this->tabs->clearTargets();
117 $this->setTabs('tableviews');
118 require_once 'Modules/DataCollection/classes/TableView/class.ilDclTableViewGUI.php';
119 $ilDclTableViewGUI = new ilDclTableViewGUI($this);
120 $this->ctrl->forwardCommand($ilDclTableViewGUI);
121 break;
122
123 default:
124 switch ($cmd) {
125 default:
126 $this->$cmd();
127 break;
128 }
129 }
130 }
131
132
133 public function listTables()
134 {
135 $add_new = ilLinkButton::getInstance();
136 $add_new->setPrimary(true);
137 $add_new->setCaption("dcl_add_new_table");
138 $add_new->setUrl($this->ctrl->getLinkTargetByClass('ilDclTableEditGUI', 'create'));
139 $this->toolbar->addStickyItem($add_new);
140
141 $table_gui = new ilDclTableListTableGUI($this);
142 $this->tpl->setContent($table_gui->getHTML());
143 }
144
145
146 protected function setTabs($active)
147 {
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
155
159 protected function save()
160 {
161 $comments = $_POST['comments'];
162 $visible = $_POST['visible'];
163 $orders = $_POST['order'];
164 asort($orders);
165 $order = 10;
166 foreach (array_keys($orders) as $table_id) {
168 $table->setOrder($order);
169 $table->setPublicCommentsEnabled(isset($comments[$table_id]));
170 $table->setIsVisible(isset($visible[$table_id]));
171 $table->doUpdate();
172 $order += 10;
173 }
174 $this->ctrl->redirect($this);
175 }
176
177
181 public function confirmDeleteTables()
182 {
183 //at least one table must exist
184 $tables = isset($_POST['dcl_table_ids']) ? $_POST['dcl_table_ids'] : array();
185 $this->checkTablesLeft(count($tables));
186
187 $this->tabs->clearSubTabs();
188 $conf = new ilConfirmationGUI();
189 $conf->setFormAction($this->ctrl->getFormAction($this));
190 $conf->setHeaderText($this->lng->txt('dcl_tables_confirm_delete'));
191
192 foreach ($tables as $table_id) {
193 $conf->addItem('dcl_table_ids[]', $table_id, ilDclCache::getTableCache($table_id)->getTitle());
194 }
195 $conf->setConfirm($this->lng->txt('delete'), 'deleteTables');
196 $conf->setCancel($this->lng->txt('cancel'), 'listTables');
197 $this->tpl->setContent($conf->getHTML());
198 }
199
200
204 protected function deleteTables()
205 {
206 $tables = isset($_POST['dcl_table_ids']) ? $_POST['dcl_table_ids'] : array();
207 foreach ($tables as $table_id) {
208 ilDclCache::getTableCache($table_id)->doDelete();
209 }
210 ilUtil::sendSuccess($this->lng->txt('dcl_msg_tables_deleted'), true);
211 $this->ctrl->redirect($this, 'listTables');
212 }
213
214
220 public function checkTablesLeft($delete_count)
221 {
222 if ($delete_count >= count($this->getDataCollectionObject()->getTables())) {
223 ilUtil::sendFailure($this->lng->txt('dcl_msg_tables_delete_all'), true);
224 $this->ctrl->redirect($this, 'listTables');
225 }
226 }
227
228
232 protected function checkAccess()
233 {
234 $ref_id = $this->getDataCollectionObject()->getRefId();
235
237 }
238
239
243 public function getDataCollectionObject()
244 {
245 return $this->parent_obj->getDataCollectionObject();
246 }
247}
$_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
if(empty($password)) $table
Definition: pwgen.php:24
global $DIC
Definition: saml.php:7