ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjPortfolioAdministrationGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3include_once("./Services/Object/classes/class.ilObjectGUI.php");
4
17{
21 protected $ui;
22
26 protected $request;
27
32
38 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
39 {
40 global $DIC;
41
42 $this->lng = $DIC->language();
43 $this->settings = $DIC->settings();
44 $this->ctrl = $DIC->ctrl();
45 $this->access = $DIC->access();
46 $this->type = "prfa";
47 $this->ui = $DIC->ui();
48 $this->request = $DIC->http()->request();
49 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
50
51 $this->declaration_authorship = new ilPortfolioDeclarationOfAuthorship();
52
53 $this->lng->loadLanguageModule("prtf");
54 }
55
62 public function executeCommand()
63 {
64 $next_class = $this->ctrl->getNextClass($this);
65 $cmd = $this->ctrl->getCmd();
66
67 $this->prepareOutput();
68
69 switch ($next_class) {
70 case 'ilpermissiongui':
71 $this->tabs_gui->activateTab('perm_settings');
72 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
73 $perm_gui = new ilPermissionGUI($this);
74 $this->ctrl->forwardCommand($perm_gui);
75 break;
76
77 default:
78 if (!$cmd || $cmd == 'view') {
79 $cmd = "editSettings";
80 }
81
82 $this->$cmd();
83 break;
84 }
85 return true;
86 }
87
94 public function getAdminTabs()
95 {
98
99
100 if ($this->checkPermissionBool("visible,read")) {
101 $tabs->addTab(
102 "settings",
103 $lng->txt("settings"),
104 $this->ctrl->getLinkTarget($this, "editSettings")
105 );
106 $tabs->addTab(
107 "authorship",
108 $lng->txt("prtf_decl_authorship"),
109 $this->ctrl->getLinkTarget($this, "editDeclarationOfAuthorship")
110 );
111 }
112
113 if ($this->checkPermissionBool('edit_permission')) {
114 $tabs->addTab(
115 "perm_settings",
116 $lng->txt("perm_settings"),
117 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
118 );
119 }
120 }
121
122
126 public function editSettings($a_form = null)
127 {
130
131 $this->tabs_gui->activateTab('settings');
132
133 /*
134 if ($ilSetting->get('user_portfolios'))
135 {
136 ilUtil::sendInfo($lng->txt("prtf_admin_toggle_info"));
137 }
138 else
139 {
140 ilUtil::sendInfo($lng->txt("prtf_admin_inactive_info"));
141 }
142 */
143
144 if (!$a_form) {
145 $a_form = $this->initFormSettings();
146 }
147 $this->tpl->setContent($a_form->getHTML());
148 return true;
149 }
150
154 public function saveSettings()
155 {
158
159 $this->checkPermission("write");
160
161 $form = $this->initFormSettings();
162 if ($form->checkInput()) {
163 $ilSetting->set('user_portfolios', (int) $form->getInput("prtf"));
164
165 $banner = (bool) $form->getInput("banner");
166
167 $prfa_set = new ilSetting("prfa");
168 $prfa_set->set("pd_block", (bool) $form->getInput("pd_block"));
169 $prfa_set->set("banner", $banner);
170 $prfa_set->set("banner_width", (int) $form->getInput("width"));
171 $prfa_set->set("banner_height", (int) $form->getInput("height"));
172 $prfa_set->set("mask", (bool) $form->getInput("mask"));
173 $prfa_set->set("mycrs", (bool) $form->getInput("mycrs"));
174
175 ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
176 $ilCtrl->redirect($this, "editSettings");
177 }
178
179 $form->setValuesByPost();
180 $this->editSettings($form);
181 }
182
186 public function cancel()
187 {
189
190 $ilCtrl->redirect($this, "view");
191 }
192
198 protected function initFormSettings()
199 {
202 $ilAccess = $this->access;
203
204 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
205 $form = new ilPropertyFormGUI();
206 $form->setFormAction($this->ctrl->getFormAction($this));
207 $form->setTitle($this->lng->txt('prtf_settings'));
208
209 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
210 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
211 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
212 }
213
214 // Enable 'Portfolios'
215 $lng->loadLanguageModule('pd');
216 $lng->loadLanguageModule('user');
217 $prtf_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_prtf'), 'prtf');
218 $prtf_prop->setValue('1');
219 $prtf_prop->setInfo($lng->txt('user_portfolios_desc'));
220 $prtf_prop->setChecked(($ilSetting->get('user_portfolios') ? '1' : '0'));
221 $form->addItem($prtf_prop);
222
223 $prfa_set = new ilSetting("prfa");
224
225 $pdblock = new ilCheckboxInputGUI($lng->txt("prtf_pd_block"), "pd_block");
226 $pdblock->setInfo($lng->txt("prtf_pd_block_info"));
227 $pdblock->setChecked($prfa_set->get("pd_block", false));
228 $form->addItem($pdblock);
229
230 $banner = new ilCheckboxInputGUI($lng->txt("prtf_preview_banner"), "banner");
231 $banner->setInfo($lng->txt("prtf_preview_banner_info"));
232 $form->addItem($banner);
233
234 $width = new ilNumberInputGUI($lng->txt("prtf_preview_banner_width"), "width");
235 $width->setRequired(true);
236 $width->setSize(4);
237 $banner->addSubItem($width);
238
239 $height = new ilNumberInputGUI($lng->txt("prtf_preview_banner_height"), "height");
240 $height->setRequired(true);
241 $height->setSize(4);
242 $banner->addSubItem($height);
243
244 $banner->setChecked($prfa_set->get("banner", false));
245 if ($prfa_set->get("banner")) {
246 $width->setValue($prfa_set->get("banner_width"));
247 $height->setValue($prfa_set->get("banner_height"));
248 } else {
249 $width->setValue(1370);
250 $height->setValue(100);
251 }
252
253 /*
254 $mask = new ilCheckboxInputGUI($lng->txt("prtf_allow_html"), "mask");
255 $mask->setInfo($lng->txt("prtf_allow_html_info"));
256 $mask->setChecked($prfa_set->get("mask", false));
257 $form->addItem($mask);*/
258
260 $ne = new ilNonEditableValueGUI($lng->txt("prtf_allow_html"), "", true);
261 $this->ctrl->setParameter($gui, "ref_id", $gui->object->getRefId());
262 $link = $this->ctrl->getLinkTarget($gui);
263 $ne->setValue("<a href='$link'> >> " . $this->lng->txt("settings") . "</a>");
264 $form->addItem($ne);
265
266 $mycourses = new ilCheckboxInputGUI($lng->txt("prtf_allow_my_courses"), "mycrs");
267 $mycourses->setInfo($lng->txt("prtf_allow_my_courses_info"));
268 $mycourses->setChecked($prfa_set->get("mycrs", true));
269 $form->addItem($mycourses);
270
271 return $form;
272 }
273
274 public function addToExternalSettingsForm($a_form_id)
275 {
277
278 switch ($a_form_id) {
280
281 $fields = array('pd_enable_prtf' => array($ilSetting->get('user_portfolios'), ilAdministrationSettingsFormHandler::VALUE_BOOL));
282
283 return array(array("editSettings", $fields));
284 }
285 }
286
287 //
288 // Declaration of authorship
289 //
290
294 protected function editDeclarationOfAuthorship()
295 {
296 $main_tpl = $this->tpl;
297 $renderer = $ui = $this->ui->renderer();
298 $form = $this->initAuthorshipForm();
299
300 $this->tabs_gui->activateTab("authorship");
301
302 $main_tpl->setContent($renderer->render($form));
303 }
304
309 public function initAuthorshipForm()
310 {
311 $ui = $this->ui;
312 $f = $ui->factory();
315
316 $lng->loadLanguageModule("meta");
317
318 foreach ($lng->getInstalledLanguages() as $l) {
319 $txt = $lng->txt("meta_l_" . $l);
320 if ($lng->getDefaultLanguage() == $l) {
321 $txt .= " (" . $lng->txt("default") . ")";
322 }
323 $fields["decl_" . $l] = $f->input()->field()->textarea($txt)
324 ->withRequired(false)
325 ->withValue((string) $this->declaration_authorship->getForLanguage($l));
326 }
327
328 // section
329 $section1 = $f->input()->field()->section($fields, $lng->txt("prtf_decl_authorship"));
330
331 $form_action = $ctrl->getLinkTarget($this, "saveAuthorship");
332 return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
333 }
334
338 public function saveAuthorship()
339 {
341 $form = $this->initAuthorshipForm();
344
345 if ($this->checkPermissionBool("write")) {
346 if ($request->getMethod() == "POST") {
347 $form = $form->withRequest($request);
348 $data = $form->getData();
349 if (is_array($data["sec"])) {
350 foreach ($lng->getInstalledLanguages() as $l) {
351 $this->declaration_authorship->setForLanguage($l, $data["sec"]["decl_" . $l]);
352 }
353
354 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
355 }
356 }
357 } else {
358 ilUtil::sendFailure($lng->txt("msg_no_perm_write"), true);
359 }
360 $ctrl->redirect($this, "editDeclarationOfAuthorship");
361 }
362}
global $l
Definition: afr.php:30
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.
if(!empty($this->data['faventry'])) $tabs
Definition: disco.tpl.php:124
$txt
Definition: error.php:11
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:17
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2