ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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->lng = $DIC->language();
40 $this->settings = $DIC->settings();
41 $this->ctrl = $DIC->ctrl();
42 $this->access = $DIC->access();
43 $this->type = "prfa";
44 $this->ui = $DIC->ui();
45 $this->request = $DIC->http()->request();
46 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
47
48 $this->declaration_authorship = new ilPortfolioDeclarationOfAuthorship();
49
50 $this->lng->loadLanguageModule("prtf");
51 }
52
59 public function executeCommand()
60 {
61 $next_class = $this->ctrl->getNextClass($this);
62 $cmd = $this->ctrl->getCmd();
63
64 $this->prepareOutput();
65
66 switch ($next_class) {
67 case 'ilpermissiongui':
68 $this->tabs_gui->activateTab('perm_settings');
69 $perm_gui = new ilPermissionGUI($this);
70 $this->ctrl->forwardCommand($perm_gui);
71 break;
72
73 default:
74 if (!$cmd || $cmd == 'view') {
75 $cmd = "editSettings";
76 }
77
78 $this->$cmd();
79 break;
80 }
81 return true;
82 }
83
90 public function getAdminTabs()
91 {
93 $tabs = $this->tabs_gui;
94
95
96 if ($this->checkPermissionBool("visible,read")) {
97 $tabs->addTab(
98 "settings",
99 $lng->txt("settings"),
100 $this->ctrl->getLinkTarget($this, "editSettings")
101 );
102 $tabs->addTab(
103 "authorship",
104 $lng->txt("prtf_decl_authorship"),
105 $this->ctrl->getLinkTarget($this, "editDeclarationOfAuthorship")
106 );
107 }
108
109 if ($this->checkPermissionBool('edit_permission')) {
110 $tabs->addTab(
111 "perm_settings",
112 $lng->txt("perm_settings"),
113 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
114 );
115 }
116 }
117
118
122 public function editSettings($a_form = null)
123 {
126
127 $this->tabs_gui->activateTab('settings');
128
129 /*
130 if ($ilSetting->get('user_portfolios'))
131 {
132 ilUtil::sendInfo($lng->txt("prtf_admin_toggle_info"));
133 }
134 else
135 {
136 ilUtil::sendInfo($lng->txt("prtf_admin_inactive_info"));
137 }
138 */
139
140 if (!$a_form) {
141 $a_form = $this->initFormSettings();
142 }
143 $this->tpl->setContent($a_form->getHTML());
144 return true;
145 }
146
150 public function saveSettings()
151 {
154
155 $this->checkPermission("write");
156
157 $form = $this->initFormSettings();
158 if ($form->checkInput()) {
159 $ilSetting->set('user_portfolios', (int) $form->getInput("prtf"));
160
161 $banner = (bool) $form->getInput("banner");
162
163 $prfa_set = new ilSetting("prfa");
164 $prfa_set->set("banner", $banner);
165 $prfa_set->set("banner_width", (int) $form->getInput("width"));
166 $prfa_set->set("banner_height", (int) $form->getInput("height"));
167 $prfa_set->set("mask", (bool) $form->getInput("mask"));
168 $prfa_set->set("mycrs", (bool) $form->getInput("mycrs"));
169
170 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
171 $ilCtrl->redirect($this, "editSettings");
172 }
173
174 $form->setValuesByPost();
175 $this->editSettings($form);
176 }
177
181 public function cancel()
182 {
184
185 $ilCtrl->redirect($this, "view");
186 }
187
193 protected function initFormSettings()
194 {
197 $ilAccess = $this->access;
198
199 $form = new ilPropertyFormGUI();
200 $form->setFormAction($this->ctrl->getFormAction($this));
201 $form->setTitle($this->lng->txt('prtf_settings'));
202
203 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
204 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
205 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
206 }
207
208 // Enable 'Portfolios'
209 $lng->loadLanguageModule('pd');
210 $lng->loadLanguageModule('user');
211 $prtf_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_prtf'), 'prtf');
212 $prtf_prop->setValue('1');
213 $prtf_prop->setInfo($lng->txt('user_portfolios_desc'));
214 $prtf_prop->setChecked(($ilSetting->get('user_portfolios') ? '1' : '0'));
215 $form->addItem($prtf_prop);
216
217 $prfa_set = new ilSetting("prfa");
218
219 $banner = new ilCheckboxInputGUI($lng->txt("prtf_preview_banner"), "banner");
220 $banner->setInfo($lng->txt("prtf_preview_banner_info"));
221 $form->addItem($banner);
222
223 $width = new ilNumberInputGUI($lng->txt("prtf_preview_banner_width"), "width");
224 $width->setRequired(true);
225 $width->setSize(4);
226 $banner->addSubItem($width);
227
228 $height = new ilNumberInputGUI($lng->txt("prtf_preview_banner_height"), "height");
229 $height->setRequired(true);
230 $height->setSize(4);
231 $banner->addSubItem($height);
232
233 $banner->setChecked($prfa_set->get("banner", false));
234 if ($prfa_set->get("banner")) {
235 $width->setValue($prfa_set->get("banner_width"));
236 $height->setValue($prfa_set->get("banner_height"));
237 } else {
238 $width->setValue(1370);
239 $height->setValue(100);
240 }
241
242 /*
243 $mask = new ilCheckboxInputGUI($lng->txt("prtf_allow_html"), "mask");
244 $mask->setInfo($lng->txt("prtf_allow_html_info"));
245 $mask->setChecked($prfa_set->get("mask", false));
246 $form->addItem($mask);*/
247
249 $ne = new ilNonEditableValueGUI($lng->txt("prtf_allow_html"), "", true);
250 $this->ctrl->setParameter($gui, "ref_id", $gui->object->getRefId());
251 $link = $this->ctrl->getLinkTarget($gui);
252 $ne->setValue("<a href='$link'> >> " . $this->lng->txt("settings") . "</a>");
253 $form->addItem($ne);
254
255 $mycourses = new ilCheckboxInputGUI($lng->txt("prtf_allow_my_courses"), "mycrs");
256 $mycourses->setInfo($lng->txt("prtf_allow_my_courses_info"));
257 $mycourses->setChecked($prfa_set->get("mycrs", true));
258 $form->addItem($mycourses);
259
260 return $form;
261 }
262
263 public function addToExternalSettingsForm($a_form_id)
264 {
266
267 switch ($a_form_id) {
269
270 $fields = array('pd_enable_prtf' => array($ilSetting->get('user_portfolios'), ilAdministrationSettingsFormHandler::VALUE_BOOL));
271
272 return array(array("editSettings", $fields));
273 }
274 }
275
276 //
277 // Declaration of authorship
278 //
279
283 protected function editDeclarationOfAuthorship()
284 {
285 $main_tpl = $this->tpl;
286 $renderer = $ui = $this->ui->renderer();
287 $form = $this->initAuthorshipForm();
288
289 $this->tabs_gui->activateTab("authorship");
290
291 $main_tpl->setContent($renderer->render($form));
292 }
293
298 public function initAuthorshipForm()
299 {
300 $ui = $this->ui;
301 $f = $ui->factory();
304
305 $lng->loadLanguageModule("meta");
306
307 foreach ($lng->getInstalledLanguages() as $l) {
308 $txt = $lng->txt("meta_l_" . $l);
309 if ($lng->getDefaultLanguage() == $l) {
310 $txt .= " (" . $lng->txt("default") . ")";
311 }
312 $fields["decl_" . $l] = $f->input()->field()->textarea($txt)
313 ->withRequired(false)
314 ->withValue((string) $this->declaration_authorship->getForLanguage($l));
315 }
316
317 // section
318 $section1 = $f->input()->field()->section($fields, $lng->txt("prtf_decl_authorship"), "");
319
320 $form_action = $ctrl->getLinkTarget($this, "saveAuthorship");
321 return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
322 }
323
327 public function saveAuthorship()
328 {
330 $form = $this->initAuthorshipForm();
333
334 if ($this->checkPermissionBool("write")) {
335 if ($request->getMethod() == "POST") {
336 $form = $form->withRequest($request);
337 $data = $form->getData();
338 if (is_array($data["sec"])) {
339 foreach ($lng->getInstalledLanguages() as $l) {
340 $this->declaration_authorship->setForLanguage($l, $data["sec"]["decl_" . $l]);
341 }
342
343 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
344 }
345 }
346 } else {
347 ilUtil::sendFailure($lng->txt("msg_no_perm_write"), true);
348 }
349 $ctrl->redirect($this, "editDeclarationOfAuthorship");
350 }
351}
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.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
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 $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17
settings()
Definition: settings.php:2
ui()
Definition: ui.php:5
$DIC
Definition: xapitoken.php:46