ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjTermsOfServiceGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
14 protected $dic;
15
17 protected $rbacsystem;
18
20 protected $error;
21
25 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
26 {
27 global $DIC;
28
29 $this->dic = $DIC;
30 $this->lng = $DIC['lng'];
31 $this->rbacsystem = $DIC['rbacsystem'];
32 $this->error = $DIC['ilErr'];
33
34 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
35
36 $this->lng->loadLanguageModule('tos');
37 $this->lng->loadLanguageModule('meta');
38 }
39
43 public function getType()
44 {
45 return 'tos';
46 }
47
51 public function executeCommand()
52 {
53 $this->prepareOutput();
54
55 $nextClass = $this->ctrl->getNextClass($this);
56 $cmd = $this->ctrl->getCmd();
57
58 $tableDataProviderFactory = new \ilTermsOfServiceTableDataProviderFactory();
59 $tableDataProviderFactory->setDatabaseAdapter($this->dic->database());
60
61 switch (strtolower($nextClass)) {
62 case 'iltermsofservicedocumentgui':
63 $documentGui = new \ilTermsOfServiceDocumentGUI(
64 $this->object,
65 $this->dic['tos.criteria.type.factory'],
66 $this->dic->ui()->mainTemplate(),
67 $this->dic->user(),
68 $this->dic->ctrl(),
69 $this->dic->language(),
70 $this->dic->rbac()->system(),
71 $this->dic['ilErr'],
72 $this->dic->logger()->tos(),
73 $this->dic->toolbar(),
74 $this->dic->http(),
75 $this->dic->ui()->factory(),
76 $this->dic->ui()->renderer(),
77 $this->dic->filesystem(),
78 $this->dic->upload(),
79 $tableDataProviderFactory,
81 );
82 $this->ctrl->forwardCommand($documentGui);
83 break;
84
85 case 'iltermsofserviceacceptancehistorygui':
86 $documentGui = new \ilTermsOfServiceAcceptanceHistoryGUI(
87 $this->object,
88 $this->dic['tos.criteria.type.factory'],
89 $this->dic->ui()->mainTemplate(),
90 $this->dic->ctrl(),
91 $this->dic->language(),
92 $this->dic->rbac()->system(),
93 $this->dic['ilErr'],
94 $this->dic->http()->request(),
95 $this->dic->ui()->factory(),
96 $this->dic->ui()->renderer(),
97 $tableDataProviderFactory
98 );
99 $this->ctrl->forwardCommand($documentGui);
100 break;
101
102 case 'ilpermissiongui':
103 $perm_gui = new \ilPermissionGUI($this);
104 $this->ctrl->forwardCommand($perm_gui);
105 break;
106
107 default:
108 if ($cmd == '' || $cmd == 'view' || !method_exists($this, $cmd)) {
109 $cmd = 'settings';
110 }
111 $this->$cmd();
112 break;
113 }
114 }
115
119 public function getAdminTabs()
120 {
121 if ($this->rbacsystem->checkAccess('read', $this->object->getRefId())) {
122 $this->tabs_gui->addTarget(
123 'settings',
124 $this->ctrl->getLinkTarget($this, 'settings'),
125 '',
126 [strtolower(get_class($this))]
127 );
128 }
129
130 if ($this->rbacsystem->checkAccess('read', $this->object->getRefId())) {
131 $this->tabs_gui->addTarget(
132 'tos_agreement_documents_tab_label',
133 $this->ctrl->getLinkTargetByClass('ilTermsOfServiceDocumentGUI'),
134 '',
135 ['iltermsofservicedocumentgui']
136 );
137 }
138
139 if ($this->rbacsystem->checkAccess('read', $this->object->getRefId()) &&
140 $this->rbacsystem->checkAccess('read', USER_FOLDER_ID)
141 ) {
142 $this->tabs_gui->addTarget(
143 'tos_acceptance_history',
144 $this->ctrl->getLinkTargetByClass('ilTermsOfServiceAcceptanceHistoryGUI'),
145 '',
146 ['iltermsofserviceacceptancehistorygui']
147 );
148 }
149
150 if ($this->rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
151 $this->tabs_gui->addTarget(
152 'perm_settings',
153 $this->ctrl->getLinkTargetByClass([get_class($this), 'ilpermissiongui'], 'perm'),
154 '',
155 ['ilpermissiongui', 'ilobjectpermissionstatusgui']
156 );
157 }
158 }
159
164 {
165 $form = new \ilTermsOfServiceSettingsFormGUI(
166 $this->object,
167 $this->ctrl->getFormAction($this, 'saveSettings'),
168 'saveSettings',
169 $this->rbacsystem->checkAccess('write', $this->object->getRefId())
170 );
171
172 return $form;
173 }
174
178 protected function saveSettings()
179 {
180 if (!$this->rbacsystem->checkAccess('write', $this->object->getRefId())) {
181 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
182 }
183
184 $form = $this->getSettingsForm();
185 if ($form->saveObject()) {
186 \ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
187 $this->ctrl->redirect($this, 'settings');
188 } else {
189 if ($form->hasTranslatedError()) {
190 \ilUtil::sendFailure($form->getTranslatedError());
191 }
192 }
193
194 $this->tpl->setContent($form->getHTML());
195 }
196
200 protected function showMissingDocuments()
201 {
202 if (!$this->object->getStatus()) {
203 return;
204 }
205
206 if (0 === \ilTermsOfServiceDocument::where([])->count()) {
207 \ilUtil::sendInfo($this->lng->txt('tos_no_documents_exist'));
208 }
209 }
210
214 protected function settings()
215 {
216 if (!$this->rbacsystem->checkAccess('read', $this->object->getRefId())) {
217 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
218 }
219
220 $this->showMissingDocuments();
221
222 $form = $this->getSettingsForm();
223 $this->tpl->setContent($form->getHTML());
224 }
225}
static where($where, $operator=null)
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
const USER_FOLDER_ID
Class ilObjUserFolder.
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
Constructor.
getType()
Functions that must be overwritten.
getAdminTabs()
administration tabs show only permissions and trash folder
New implementation of ilObjectGUI.
prepareOutput($a_show_subobjects=true)
prepare output
Class ilTermsOfServiceSettingsFormGUI.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7