ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjPortfolioAdministrationGUI.php
Go to the documentation of this file.
1<?php
2
27{
28 protected \ILIAS\DI\UIServices $ui;
30
31 public function __construct(
32 $a_data,
33 int $a_id,
34 bool $a_call_by_reference = true,
35 bool $a_prepare_output = true
36 ) {
37 global $DIC;
38
39 $this->rbac_system = $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
54 public function executeCommand(): void
55 {
56 $next_class = $this->ctrl->getNextClass($this);
57 $cmd = $this->ctrl->getCmd();
58
59 $this->prepareOutput();
60
61 switch ($next_class) {
62 case 'ilpermissiongui':
63 $this->tabs_gui->activateTab('perm_settings');
64 $perm_gui = new ilPermissionGUI($this);
65 $this->ctrl->forwardCommand($perm_gui);
66 break;
67
68 case 'ilportfolioroleassignmentgui':
69 $this->tabs_gui->activateTab('role_assignment');
71 $this->ctrl->forwardCommand($gui);
72 break;
73
74 default:
75 if (!$cmd || $cmd === 'view') {
76 $cmd = "editSettings";
77 }
78
79 $this->$cmd();
80 break;
81 }
82 }
83
84 public function getAdminTabs(): void
85 {
87 $tabs = $this->tabs_gui;
88
89
90 if ($this->hasReadPermission()) {
91 $tabs->addTab(
92 "settings",
93 $lng->txt("settings"),
94 $this->ctrl->getLinkTarget($this, "editSettings")
95 );
96 $tabs->addTab(
97 "role_assignment",
98 $lng->txt("prtf_role_assignment"),
99 $this->ctrl->getLinkTargetByClass("ilPortfolioRoleAssignmentGUI", "")
100 );
101 $tabs->addTab(
102 "authorship",
103 $lng->txt("prtf_decl_authorship"),
104 $this->ctrl->getLinkTarget($this, "editDeclarationOfAuthorship")
105 );
106 }
107
108 if ($this->checkPermissionBool('edit_permission')) {
109 $tabs->addTab(
110 "perm_settings",
111 $lng->txt("perm_settings"),
112 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
113 );
114 }
115 }
116
117 public function editSettings($a_form = null): void
118 {
119 $this->tabs_gui->activateTab('settings');
120 if (!$a_form) {
121 $a_form = $this->initFormSettings();
122 }
123 $this->tpl->setContent($a_form->getHTML());
124 }
125
126 public function saveSettings(): void
127 {
128 $ilCtrl = $this->ctrl;
130
131 if ($this->hasWritePermission()) {
132 $form = $this->initFormSettings();
133 if ($form->checkInput()) {
134 $ilSetting->set('user_portfolios', (int) $form->getInput("prtf"));
135
136 $prfa_set = new ilSetting("prfa");
137 $prfa_set->set("mask", (bool) $form->getInput("mask"));
138 $prfa_set->set("mycrs", (bool) $form->getInput("mycrs"));
139
140 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
141 $ilCtrl->redirect($this, "editSettings");
142 }
143 $form->setValuesByPost();
144 $this->editSettings($form);
145 }
146 }
147
148 public function cancel(): void
149 {
150 $ilCtrl = $this->ctrl;
151
152 $ilCtrl->redirect($this, "view");
153 }
154
155 protected function hasWritePermission(): bool
156 {
157 return $this->rbac_system->checkAccess("write", $this->object->getRefId());
158 }
159
160 protected function hasReadPermission(): bool
161 {
162 return $this->rbac_system->checkAccess("read", $this->object->getRefId());
163 }
164
166 {
169
170 $form = new ilPropertyFormGUI();
171 $form->setFormAction($this->ctrl->getFormAction($this));
172 $form->setTitle($this->lng->txt('prtf_settings'));
173
174 if ($this->hasWritePermission()) {
175 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
176 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
177 }
178
179 // Enable 'Portfolios'
181 $lng->loadLanguageModule('user');
182 $prtf_prop = new ilCheckboxInputGUI($lng->txt('pd_enable_prtf'), 'prtf');
183 $prtf_prop->setValue('1');
184 $prtf_prop->setInfo($lng->txt('user_portfolios_desc'));
185 $prtf_prop->setChecked((bool) $ilSetting->get('user_portfolios'));
186 $form->addItem($prtf_prop);
187
188 $prfa_set = new ilSetting("prfa");
189
190 $mycourses = new ilCheckboxInputGUI($lng->txt("prtf_allow_my_courses"), "mycrs");
191 $mycourses->setInfo($lng->txt("prtf_allow_my_courses_info"));
192 $mycourses->setChecked($prfa_set->get("mycrs", true));
193 $form->addItem($mycourses);
194
195 return $form;
196 }
197
198 public function addToExternalSettingsForm(int $a_form_id): array
199 {
201
203 $fields = array('pd_enable_prtf' => array($ilSetting->get('user_portfolios'),
205 )
206 );
207
208 return array(array("editSettings", $fields));
209 }
210 return [];
211 }
212
213 //
214 // Declaration of authorship
215 //
216
217 protected function editDeclarationOfAuthorship(): void
218 {
219 $main_tpl = $this->tpl;
220 $renderer = $ui = $this->ui->renderer();
221 $form = $this->initAuthorshipForm();
222
223 $this->tabs_gui->activateTab("authorship");
224
225 $main_tpl->setContent($renderer->render($form));
226 }
227
228 public function initAuthorshipForm(): \ILIAS\UI\Component\Input\Container\Form\Standard
229 {
230 $ui = $this->ui;
231 $f = $ui->factory();
234
235 $lng->loadLanguageModule("meta");
236 $fields = [];
237
238 foreach ($lng->getInstalledLanguages() as $l) {
239 $txt = $lng->txt("meta_l_" . $l);
240 if ($lng->getDefaultLanguage() == $l) {
241 $txt .= " (" . $lng->txt("default") . ")";
242 }
243 $fields["decl_" . $l] = $f->input()->field()->textarea($txt)
244 ->withRequired(false)
245 ->withValue($this->declaration_authorship->getForLanguage($l));
246 }
247
248 // section
249 $section1 = $f->input()->field()->section($fields, $lng->txt("prtf_decl_authorship"), "");
250
251 $form_action = $ctrl->getLinkTarget($this, "saveAuthorship");
252 return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
253 }
254
255 public function saveAuthorship(): void
256 {
258 $form = $this->initAuthorshipForm();
261
262 if ($this->hasWritePermission()) {
263 if ($request->getMethod() === "POST") {
264 $form = $form->withRequest($request);
265 $data = $form->getData();
266 if (is_array($data["sec"])) {
267 foreach ($lng->getInstalledLanguages() as $l) {
268 $this->declaration_authorship->setForLanguage($l, $data["sec"]["decl_" . $l]);
269 }
270
271 $this->tpl->setOnScreenMessage('info', $lng->txt("msg_obj_modified"), true);
272 }
273 }
274 } else {
275 $this->tpl->setOnScreenMessage('failure', $lng->txt("msg_no_perm_write"), true);
276 }
277 $ctrl->redirect($this, "editDeclarationOfAuthorship");
278 }
279}
$renderer
This class represents a checkbox property in a property form.
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getDefaultLanguage()
Return default language.
getInstalledLanguages()
Get installed languages.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAdminTabs()
administration tabs show only permissions and trash folder
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
Class ilObjectGUI Basic methods of all Output classes.
ilGlobalTemplateInterface $tpl
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
ilSetting $settings
ilTabsGUI $tabs_gui
prepareOutput(bool $show_sub_objects=true)
ServerRequestInterface $request
ilLanguage $lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@ilCtrl_Calls ilPortfolioRoleAssignmentGUI: ilPropertyFormGUI
This class represents a property form user interface.
ILIAS Setting Class.
addTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
Add a Tab.
$txt
Definition: error.php:31
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $ilSetting
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26