ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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;
18 
22  protected $lng;
23 
27  protected $tpl;
28 
32  protected $tabs;
33 
37  protected $toolbar;
38 
44  public function __construct(ilObjDataCollectionGUI $a_parent_obj)
45  {
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  $tableHelper = new ilDclTableHelper((int) $this->obj_id, (int) $_GET['ref_id'], $DIC->rbac()->review(), $DIC->user(), $DIC->database());
82  // send a warning if there are roles with rbac read access on the data collection but without read access on any standard view
83  $role_titles = $tableHelper->getRoleTitlesWithoutReadRightOnAnyStandardView();
84 
85  if (count($role_titles) > 0) {
86  ilUtil::sendInfo($DIC->language()->txt('dcl_rbac_roles_without_read_access_on_any_standard_view') . " " . implode(", ", $role_titles));
87  }
88 
89  switch ($next_class) {
90  case 'ildcltableeditgui':
91  $this->tabs->clearTargets();
92  if ($cmd != 'create') {
93  $this->setTabs('settings');
94  } else {
95  $this->tabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'listTables'));
96  }
97  require_once 'Modules/DataCollection/classes/Table/class.ilDclTableEditGUI.php';
98  $ilDclTableEditGUI = new ilDclTableEditGUI($this);
99  $this->ctrl->forwardCommand($ilDclTableEditGUI);
100  break;
101 
102  case 'ildclfieldlistgui':
103  $this->tabs->clearTargets();
104  $this->setTabs('fields');
105  require_once 'Modules/DataCollection/classes/Fields/class.ilDclFieldListGUI.php';
106  $ilDclFieldListGUI = new ilDclFieldListGUI($this);
107  $this->ctrl->forwardCommand($ilDclFieldListGUI);
108  break;
109 
110  case "ildclfieldeditgui":
111  $this->tabs->clearTargets();
112  $this->setTabs("fields");
113  require_once "Modules/DataCollection/classes/Fields/class.ilDclFieldEditGUI.php";
114  $ilDclFieldEditGUI = new ilDclFieldEditGUI($this);
115  $this->ctrl->forwardCommand($ilDclFieldEditGUI);
116  break;
117 
118  case 'ildcltableviewgui':
119  $this->tabs->clearTargets();
120  $this->setTabs('tableviews');
121  require_once 'Modules/DataCollection/classes/TableView/class.ilDclTableViewGUI.php';
122  $ilDclTableViewGUI = new ilDclTableViewGUI($this);
123  $this->ctrl->forwardCommand($ilDclTableViewGUI);
124  break;
125 
126  default:
127  switch ($cmd) {
128  default:
129  $this->$cmd();
130  break;
131  }
132  }
133  }
134 
135  public function listTables()
136  {
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  {
149  $this->tabs->setBackTarget($this->lng->txt('dcl_tables'), $this->ctrl->getLinkTarget($this, 'listTables'));
150  $this->tabs->addTab('settings', $this->lng->txt('settings'), $this->ctrl->getLinkTargetByClass('ilDclTableEditGUI', 'edit'));
151  $this->tabs->addTab('fields', $this->lng->txt('dcl_list_fields'), $this->ctrl->getLinkTargetByClass('ilDclFieldListGUI', 'listFields'));
152  $this->tabs->addTab('tableviews', $this->lng->txt('dcl_tableviews'), $this->ctrl->getLinkTargetByClass('ilDclTableViewGUI'));
153  $this->tabs->setTabActive($active);
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) {
167  $table = ilDclCache::getTableCache($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 
180  public function confirmDeleteTables()
181  {
182  //at least one table must exist
183  $tables = isset($_POST['dcl_table_ids']) ? $_POST['dcl_table_ids'] : array();
184  $this->checkTablesLeft(count($tables));
185 
186  $this->tabs->clearSubTabs();
187  $conf = new ilConfirmationGUI();
188  $conf->setFormAction($this->ctrl->getFormAction($this));
189  $conf->setHeaderText($this->lng->txt('dcl_tables_confirm_delete'));
190 
191  foreach ($tables as $table_id) {
192  $conf->addItem('dcl_table_ids[]', $table_id, ilDclCache::getTableCache($table_id)->getTitle());
193  }
194  $conf->setConfirm($this->lng->txt('delete'), 'deleteTables');
195  $conf->setCancel($this->lng->txt('cancel'), 'listTables');
196  $this->tpl->setContent($conf->getHTML());
197  }
198 
202  protected function deleteTables()
203  {
204  $tables = isset($_POST['dcl_table_ids']) ? $_POST['dcl_table_ids'] : array();
205  foreach ($tables as $table_id) {
206  ilDclCache::getTableCache($table_id)->doDelete();
207  }
208  ilUtil::sendSuccess($this->lng->txt('dcl_msg_tables_deleted'), true);
209  $this->ctrl->redirect($this, 'listTables');
210  }
211 
217  public function checkTablesLeft($delete_count)
218  {
219  if ($delete_count >= count($this->getDataCollectionObject()->getTables())) {
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  {
240  return $this->parent_obj->getDataCollectionObject();
241  }
242 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
Class ilDclTableHelper.
Class ilDclTableViewGUI.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
Class ilDclTableListGUI.
static getTableCache($table_id=0)
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Class ilObjDataCollectionGUI.
__construct(ilObjDataCollectionGUI $a_parent_obj)
ilDclTableListGUI constructor.
executeCommand()
execute command
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilDclFieldEditGUI.
Class ilDclTableListTableGUI.
checkTablesLeft($delete_count)
redirects if there are no tableviews left after deletion of {$delete_count} tableviews ...
confirmDeleteTables()
Confirm deletion of multiple fields.
if(empty($password)) $table
Definition: pwgen.php:24
$_POST["username"]
Class ilDclBaseFieldModel.
Confirmation screen class.