ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjBibliographicAdminLibrariesGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13{
14
18 protected $dic;
22 protected $parent_gui;
26 protected $ctrl;
30 protected $lng;
34 protected $rbacsystem;
38 protected $error;
39
40
46 public function __construct($parent_gui)
47 {
48 global $DIC;
49 $this->dic = $DIC;
50 $lng = $this->dic->language();
51 $ilCtrl = $this->dic->ctrl();
52 $this->lng = $lng;
53 $this->ctrl = $ilCtrl;
54 $this->parent_gui = $parent_gui;
55 $this->rbacsystem = $this->dic->rbac()->system();
56 }
57
58
65 public function executeCommand()
66 {
67 $cmd = $this->ctrl->getCmd();
68 if (!$this->rbacsystem->checkAccess("visible,read", $_GET['ref_id'])) {
69 $this->error->raiseError($this->lng->txt("no_permission"), $this->error->WARNING);
70 }
71 switch ($cmd) {
72 case 'view':
73 $this->view();
74 break;
75 case 'add':
76 $this->checkPermission('write');
77 $this->add();
78 break;
79 case 'edit':
80 $this->checkPermission('write');
81 $this->edit();
82 break;
83 case 'delete':
84 $this->checkPermission('write');
85 $this->delete();
86 break;
87 case 'create':
88 $this->checkPermission('write');
89 $this->create();
90 break;
91 case 'update':
92 $this->checkPermission('write');
93 $this->update();
94 break;
95 case 'cancel':
96 $this->cancel();
97 break;
98 }
99 }
100
101
107 public function view()
108 {
109 global $DIC;
110 if ($this->checkPermissionBool('write')) {
111 $ilToolbar = $DIC['ilToolbar'];
116 $b->setCaption('add');
117 $b->setUrl($this->ctrl->getLinkTarget($this, 'add'));
118 $b->setPrimary(true);
119 $ilToolbar->addButtonInstance($b);
120 }
121
122 $a_table = $this->initTable();
123 $this->parent_gui->tpl->setContent($a_table->getHTML());
124
125 return true;
126 }
127
128
135 protected function initTable()
136 {
137 $table = new ilObjBibliographicAdminTableGUI($this, 'library', $this->checkPermissionBool('write'));
138 $settings = ilBibliographicSetting::getAll();
139 $result = array();
140 foreach ($settings as $set) {
141 $result[] = array(
142 "id" => $set->getId(),
143 "name" => $set->getName(),
144 "url" => $set->getUrl(),
145 "img" => $set->getImg(),
146 );
147 }
148 $table->setData($result);
149
150 return $table;
151 }
152
153
157 public function add()
158 {
160 $this->parent_gui->tpl->setContent($form->getHTML());
161 $this->parent_gui->getTabsGui()->setTabActive('settings');
162 }
163
164
168 public function delete()
169 {
170 $ilBibliographicSetting = new ilBibliographicSetting($_REQUEST["lib_id"]);
171 $ilBibliographicSetting->delete();
172 $this->ctrl->redirect($this, 'view');
173 }
174
175
179 public function cancel()
180 {
181 $this->ctrl->redirect($this, 'view');
182 }
183
184
188 public function update()
189 {
190 $form = new ilObjBibliographicAdminLibrariesFormGUI($this, new ilBibliographicSetting($_REQUEST["lib_id"]));
191 $form->setValuesByPost();
192 if ($form->saveObject()) {
193 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
194 $this->ctrl->redirect($this, 'view');
195 }
196 $this->parent_gui->tpl->setContent($form->getHTML());
197 }
198
199
203 public function create()
204 {
206 $form->setValuesByPost();
207 if ($form->saveObject()) {
208 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
209 $this->ctrl->redirect($this, 'view');
210 }
211 $this->parent_gui->tpl->setContent($form->getHTML());
212 }
213
214
218 public function edit()
219 {
220 $this->ctrl->saveParameter($this, 'lib_id');
221 $form = new ilObjBibliographicAdminLibrariesFormGUI($this, new ilBibliographicSetting($_REQUEST["lib_id"]));
222 $this->parent_gui->tpl->setContent($form->getHTML());
223 }
224
225
226 //
227 // Helper
228 //
229 protected function checkPermission($a_perm)
230 {
231 if (!$this->checkPermissionBool($a_perm)) {
232 throw new ilObjectException($this->lng->txt("permission_denied"));
233 }
234 }
235
236
242 protected function checkPermissionBool($a_perm)
243 {
244 global $DIC;
245
246 return (bool) $DIC->access()->checkAccess($a_perm, '', $DIC->http()->request()->getQueryParams()['ref_id']);
247 }
248}
$result
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
Class ilBibliographicSetting.
static getInstance()
Factory.
Bibliographic ilObjBibliographicAdminTableGUI.
Base exception class for object service.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
if(empty($password)) $table
Definition: pwgen.php:24
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7