ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilDclFieldListGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
18 {
19 
23  protected $ctrl;
24 
25 
29  protected $lng;
30 
34  protected $toolbar;
35 
39  protected $tpl;
40 
44  protected $tabs;
45 
52  public function __construct(ilDclTableListGUI $a_parent_obj)
53  {
54  global $DIC;
55  $ilCtrl = $DIC['ilCtrl'];
56  $lng = $DIC['lng'];
57  $ilToolbar = $DIC['ilToolbar'];
58  $tpl = $DIC['tpl'];
59  $ilTabs = $DIC['ilTabs'];
60  $locator = $DIC['ilLocator'];
61 
62  $table_id = $_GET['table_id'];
63 
64  $this->table_id = $table_id;
65  $this->parent_obj = $a_parent_obj;
66  $this->obj_id = $a_parent_obj->obj_id;
67  $this->ctrl = $ilCtrl;
68  $this->lng = $lng;
69  $this->tpl = $tpl;
70  $this->tabs = $ilTabs;
71  $this->toolbar = $ilToolbar;
72 
73  $this->ctrl->saveParameter('ilDclTableEditGUI', 'table_id');
74  $locator->addItem(ilDclCache::getTableCache($this->table_id)->getTitle(), $this->ctrl->getLinkTargetByClass('ilDclTableEditGUI', 'edit'));
75  $this->tpl->setLocator();
76 
77  if (!$this->checkAccess()) {
78  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
79  $this->ctrl->redirectByClass('ildclrecordlistgui', 'listRecords');
80  }
81  }
82 
83 
87  public function executeCommand()
88  {
89  $cmd = $this->ctrl->getCmd('listFields');
90  switch ($cmd) {
91  default:
92  $this->$cmd();
93  break;
94  }
95  }
96 
100  public function deleteFields()
101  {
102  $field_ids = isset($_POST['dcl_field_ids']) ? $_POST['dcl_field_ids'] : array();
103  $table = ilDclCache::getTableCache($this->table_id);
104  foreach ($field_ids as $field_id) {
105  $table->deleteField($field_id);
106  }
107  ilUtil::sendSuccess($this->lng->txt('dcl_msg_fields_deleted'), true);
108  $this->ctrl->redirect($this, 'listFields');
109  }
110 
114  public function confirmDeleteFields()
115  {
116  $this->tabs->clearSubTabs();
117  $conf = new ilConfirmationGUI();
118  $conf->setFormAction($this->ctrl->getFormAction($this));
119  $conf->setHeaderText($this->lng->txt('dcl_confirm_delete_fields'));
120  $field_ids = isset($_POST['dcl_field_ids']) ? $_POST['dcl_field_ids'] : array();
121  foreach ($field_ids as $field_id) {
123  $field = ilDclCache::getFieldCache($field_id);
124  $conf->addItem('dcl_field_ids[]', $field_id, $field->getTitle());
125  }
126  $conf->setConfirm($this->lng->txt('delete'), 'deleteFields');
127  $conf->setCancel($this->lng->txt('cancel'), 'listFields');
128  $this->tpl->setContent($conf->getHTML());
129  }
130 
131  /*
132  * save
133  */
134  public function save()
135  {
136  $table = ilDclCache::getTableCache($_GET['table_id']);
137  $fields = $table->getFields();
138  $order = $_POST['order'];
139  asort($order);
140  $val = 10;
141  foreach (array_keys($order) as $field_id) {
142  $order[$field_id] = $val;
143  $val += 10;
144  }
145 
146 
147  foreach ($fields as $field) {
148  $field->setLocked($_POST['locked'][$field->getId()] == "on");
149  $field->setExportable($_POST['exportable'][$field->getId()] == "on");
150  $field->setOrder($order[$field->getId()]);
151  $field->doUpdate();
152  }
153 
154  $table->reloadFields();
155  ilUtil::sendSuccess($this->lng->txt("dcl_table_settings_saved"));
156  $this->listFields();
157  }
158 
162  public function listFields()
163  {
164  //add button
165  $add_new = ilLinkButton::getInstance();
166  $add_new->setPrimary(true);
167  $add_new->setCaption("dcl_add_new_field");
168  $add_new->setUrl($this->ctrl->getLinkTargetByClass('ildclfieldeditgui', 'create'));
169  $this->toolbar->addStickyItem($add_new);
170 
171  $this->toolbar->addSeparator();
172 
173  // Show tableswitcher
174  $tables = $this->parent_obj->getDataCollectionObject()->getTables();
175 
176  foreach ($tables as $table) {
177  $options[$table->getId()] = $table->getTitle();
178  }
179  include_once './Services/Form/classes/class.ilSelectInputGUI.php';
180  $table_selection = new ilSelectInputGUI('', 'table_id');
181  $table_selection->setOptions($options);
182  $table_selection->setValue($this->table_id);
183 
184  $this->toolbar->setFormAction($this->ctrl->getFormActionByClass("ilDclFieldListGUI", "doTableSwitch"));
185  $this->toolbar->addText($this->lng->txt("dcl_select"));
186  $this->toolbar->addInputItem($table_selection);
187  $this->toolbar->addFormButton($this->lng->txt('change'), 'doTableSwitch');
188 
189  //table gui
190  $list = new ilDclFieldListTableGUI($this, $this->ctrl->getCmd(), $this->table_id);
191  $this->tpl->setContent($list->getHTML());
192  }
193 
194  /*
195  * doTableSwitch
196  */
197  public function doTableSwitch()
198  {
199  $this->ctrl->setParameterByClass("ilObjDataCollectionGUI", "table_id", $_POST['table_id']);
200  $this->ctrl->redirectByClass("ilDclFieldListGUI", "listFields");
201  }
202 
206  protected function checkAccess()
207  {
208  $ref_id = $this->getDataCollectionObject()->getRefId();
209  return ilObjDataCollectionAccess::hasAccessToEditTable($ref_id, $this->table_id);
210  }
211 
212 
216  public function getDataCollectionObject()
217  {
218  return $this->parent_obj->getDataCollectionObject();
219  }
220 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
This class represents a selection list property in a property form.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static getFieldCache($field_id=0)
static hasAccessToEditTable($ref_id, $table_id)
Class ilDclTableListGUI.
static getTableCache($table_id=0)
global $ilCtrl
Definition: ilias.php:18
deleteFields()
Delete multiple fields.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
executeCommand()
execute command
Class ilDclFieldListTableGUI.
if(empty($password)) $table
Definition: pwgen.php:24
__construct(ilDclTableListGUI $a_parent_obj)
Constructor.
$_POST["username"]
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
Confirmation screen class.