ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjPortfolioAdministrationGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
14{
18 protected $ui;
19
23 protected $request;
24
29
35 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
36 {
37 global $DIC;
38
39 $this->rbacsystem = $DIC->rbac()->system();
40 $this->lng = $DIC->language();
41 $this->settings = $DIC->settings();
42 $this->ctrl = $DIC->ctrl();
43 $this->access = $DIC->access();
44 $this->type = "prfa";
45 $this->ui = $DIC->ui();
46 $this->request = $DIC->http()->request();
47 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
48
49 $this->declaration_authorship = new ilPortfolioDeclarationOfAuthorship();
50
51 $this->lng->loadLanguageModule("prtf");
52 }
53
60 public function executeCommand()
61 {
62 $next_class = $this->ctrl->getNextClass($this);
63 $cmd = $this->ctrl->getCmd();
64
65 $this->prepareOutput();
66
67 switch ($next_class) {
68 case 'ilpermissiongui':
69 $this->tabs_gui->activateTab('perm_settings');
70 $perm_gui = new ilPermissionGUI($this);
71 $this->ctrl->forwardCommand($perm_gui);
72 break;
73
74 default:
75 if (!$cmd || $cmd == 'view') {
76 $cmd = "editSettings";
77 }
78
79 $this->$cmd();
80 break;
81 }
82 return true;
83 }
84
91 public function getAdminTabs()
92 {
94 $tabs = $this->tabs_gui;
95
96
97 if ($this->hasReadPermission()) {
98 $tabs->addTab(
99 "settings",
100 $lng->txt("settings"),
101 $this->ctrl->getLinkTarget($this, "editSettings")
102 );
103 $tabs->addTab(
104 "authorship",
105 $lng->txt("prtf_decl_authorship"),
106 $this->ctrl->getLinkTarget($this, "editDeclarationOfAuthorship")
107 );
108 }
109
110 if ($this->checkPermissionBool('edit_permission')) {
111 $tabs->addTab(
112 "perm_settings",
113 $lng->txt("perm_settings"),
114 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
115 );
116 }
117 }
118
119
123 public function editSettings($a_form = null)
124 {
127
128 $this->tabs_gui->activateTab('settings');
129
130 /*
131 if ($ilSetting->get('user_portfolios'))
132 {
133 ilUtil::sendInfo($lng->txt("prtf_admin_toggle_info"));
134 }
135 else
136 {
137 ilUtil::sendInfo($lng->txt("prtf_admin_inactive_info"));
138 }
139 */
140
141 if (!$a_form) {
142 $a_form = $this->initFormSettings();
143 }
144 $this->tpl->setContent($a_form->getHTML());
145 return true;
146 }
147
151 public function saveSettings()
152 {
153 $ilCtrl = $this->ctrl;
155
156 if ($this->hasWritePermission()) {
157
158 $form = $this->initFormSettings();
159 if ($form->checkInput()) {
160 $ilSetting->set('user_portfolios', (int) $form->getInput("prtf"));
161
162 $banner = (bool) $form->getInput("banner");
163
164 $prfa_set = new ilSetting("prfa");
165 $prfa_set->set("banner", $banner);
166 $prfa_set->set("banner_width", (int) $form->getInput("width"));
167 $prfa_set->set("banner_height", (int) $form->getInput("height"));
168 $prfa_set->set("mask", (bool) $form->getInput("mask"));
169 $prfa_set->set("mycrs", (bool) $form->getInput("mycrs"));
170
171 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
172 $ilCtrl->redirect($this, "editSettings");
173 }
174 }
175
176 $form->setValuesByPost();
177 $this->editSettings($form);
178 }
179
183 public function cancel()
184 {
185 $ilCtrl = $this->ctrl;
186
187 $ilCtrl->redirect($this, "view");
188 }
189
194 protected function hasWritePermission()
195 {
196 return $this->rbacsystem->checkAccess("write", $this->object->getRefId());
197 }
198
203 protected function hasReadPermission()
204 {
205 return $this->rbacsystem->checkAccess("read", $this->object->getRefId());
206 }
207
213 protected function initFormSettings()
214 {
217
218 $form = new ilPropertyFormGUI();
219 $form->setFormAction($this->ctrl->getFormAction($this));
220 $form->setTitle($this->lng->txt('prtf_settings'));
221
222 if ($this->hasWritePermission()) {
223 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
224 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
225 }
226
227 // Enable 'Portfolios'
228 $lng->loadLanguageModule('pd');
229 $lng->loadLanguageModule('user');
230 $prtf_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_prtf'), 'prtf');
231 $prtf_prop->setValue('1');
232 $prtf_prop->setInfo($lng->txt('user_portfolios_desc'));
233 $prtf_prop->setChecked(($ilSetting->get('user_portfolios') ? '1' : '0'));
234 $form->addItem($prtf_prop);
235
236 $prfa_set = new ilSetting("prfa");
237
238 $banner = new ilCheckboxInputGUI($lng->txt("prtf_preview_banner"), "banner");
239 $banner->setInfo($lng->txt("prtf_preview_banner_info"));
240 $form->addItem($banner);
241
242 $width = new ilNumberInputGUI($lng->txt("prtf_preview_banner_width"), "width");
243 $width->setRequired(true);
244 $width->setSize(4);
245 $banner->addSubItem($width);
246
247 $height = new ilNumberInputGUI($lng->txt("prtf_preview_banner_height"), "height");
248 $height->setRequired(true);
249 $height->setSize(4);
250 $banner->addSubItem($height);
251
252 $banner->setChecked($prfa_set->get("banner", false));
253 if ($prfa_set->get("banner")) {
254 $width->setValue($prfa_set->get("banner_width"));
255 $height->setValue($prfa_set->get("banner_height"));
256 } else {
257 $width->setValue(1370);
258 $height->setValue(100);
259 }
260
261 /*
262 $mask = new ilCheckboxInputGUI($lng->txt("prtf_allow_html"), "mask");
263 $mask->setInfo($lng->txt("prtf_allow_html_info"));
264 $mask->setChecked($prfa_set->get("mask", false));
265 $form->addItem($mask);*/
267 $ne = new ilNonEditableValueGUI($lng->txt("prtf_allow_html"), "", true);
268 $this->ctrl->setParameter($gui, "ref_id", $gui->object->getRefId());
269 $link = $this->ctrl->getLinkTarget($gui);
270 $ne->setValue("<a href='$link'> >> " . $this->lng->txt("settings") . "</a>");
271 $form->addItem($ne);
272
273 $mycourses = new ilCheckboxInputGUI($lng->txt("prtf_allow_my_courses"), "mycrs");
274 $mycourses->setInfo($lng->txt("prtf_allow_my_courses_info"));
275 $mycourses->setChecked($prfa_set->get("mycrs", true));
276 $form->addItem($mycourses);
277
278 return $form;
279 }
280
281 public function addToExternalSettingsForm($a_form_id)
282 {
284
285 switch ($a_form_id) {
287
288 $fields = array('pd_enable_prtf' => array($ilSetting->get('user_portfolios'), ilAdministrationSettingsFormHandler::VALUE_BOOL));
289
290 return array(array("editSettings", $fields));
291 }
292 }
293
294 //
295 // Declaration of authorship
296 //
297
301 protected function editDeclarationOfAuthorship()
302 {
303 $main_tpl = $this->tpl;
304 $renderer = $ui = $this->ui->renderer();
305 $form = $this->initAuthorshipForm();
306
307 $this->tabs_gui->activateTab("authorship");
308
309 $main_tpl->setContent($renderer->render($form));
310 }
311
316 public function initAuthorshipForm()
317 {
318 $ui = $this->ui;
319 $f = $ui->factory();
322
323 $lng->loadLanguageModule("meta");
324
325 foreach ($lng->getInstalledLanguages() as $l) {
326 $txt = $lng->txt("meta_l_" . $l);
327 if ($lng->getDefaultLanguage() == $l) {
328 $txt .= " (" . $lng->txt("default") . ")";
329 }
330 $fields["decl_" . $l] = $f->input()->field()->textarea($txt)
331 ->withRequired(false)
332 ->withValue((string) $this->declaration_authorship->getForLanguage($l));
333 }
334
335 // section
336 $section1 = $f->input()->field()->section($fields, $lng->txt("prtf_decl_authorship"), "");
337
338 $form_action = $ctrl->getLinkTarget($this, "saveAuthorship");
339 return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
340 }
341
345 public function saveAuthorship()
346 {
348 $form = $this->initAuthorshipForm();
351
352 if ($this->hasWritePermission()) {
353 if ($request->getMethod() == "POST") {
354 $form = $form->withRequest($request);
355 $data = $form->getData();
356 if (is_array($data["sec"])) {
357 foreach ($lng->getInstalledLanguages() as $l) {
358 $this->declaration_authorship->setForLanguage($l, $data["sec"]["decl_" . $l]);
359 }
360
361 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
362 }
363 }
364 } else {
365 ilUtil::sendFailure($lng->txt("msg_no_perm_write"), true);
366 }
367 $ctrl->redirect($this, "editDeclarationOfAuthorship");
368 }
369}
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
This class represents a non editable value in a property form.
This class represents a number property in a property form.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Contructor.
editDeclarationOfAuthorship()
Edit declaration of authorship.
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
ILIAS Setting Class.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$txt
Definition: error.php:13
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17
settings()
Definition: settings.php:2
ui()
Definition: ui.php:5