ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjNotesSettingsGUI.php
Go to the documentation of this file.
1<?php
2
20
28{
31 protected ilTabsGUI $tabs;
32 protected \ILIAS\DI\UIServices $ui;
35
36 public function __construct(
37 $a_data,
38 int $a_id,
39 bool $a_call_by_reference = true,
40 bool $a_prepare_output = true
41 ) {
42 global $DIC;
43
44 $this->lng = $DIC->language();
45 $this->rbacsystem = $DIC->rbac()->system();
46 $this->error = $DIC["ilErr"];
47 $this->ctrl = $DIC->ctrl();
48 $this->request = $DIC->http()->request();
49 $this->tabs = $DIC->tabs();
50 $this->ui = $DIC->ui();
51 $this->setting = $DIC->settings();
52 $this->main_tpl = $DIC->ui()->mainTemplate();
53
54 $this->type = 'nots';
55
56 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
57
58 $this->lng->loadLanguageModule("note");
59 }
60
65 public function executeCommand(): void
66 {
70
71 $next_class = $ctrl->getNextClass($this);
72 $cmd = $ctrl->getCmd("editSettings");
73
74 if (!$rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
75 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
76 }
77
78 $this->prepareOutput();
79
80 switch ($next_class) {
81 case 'ilpermissiongui':
82 $tabs->activateTab('perm_settings');
83 $perm_gui = new ilPermissionGUI($this);
84 $ctrl->forwardCommand($perm_gui);
85 break;
86
87 default:
88 if ($cmd === "view") {
89 $cmd = "editSettings";
90 }
91 if (in_array($cmd, ["editSettings", "saveSettings"])) {
92 $this->$cmd();
93 }
94 break;
95 }
96 }
97
98 public function getAdminTabs(): void
99 {
104
105 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
106 $tabs->addTab(
107 "settings",
108 $lng->txt("settings"),
109 $ctrl->getLinkTarget($this, "editSettings")
110 );
111 }
112
113 if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
114 $tabs->addTab(
115 "perm_settings",
116 $lng->txt("perm_settings"),
117 $ctrl->getLinkTargetByClass('ilpermissiongui', "perm")
118 );
119 }
120 }
121
122 public function editSettings(): void
123 {
125 $ui = $this->ui;
127
128 $tabs->activateTab("settings");
129
130 $form = $this->initForm();
131 $main_tpl->setContent($ui->renderer()->render($form));
132 }
133
134 public function initForm(): Standard
135 {
136 $ui = $this->ui;
137 $f = $ui->factory();
141
142 $fields["enable_notes"] = $f->input()->field()->checkbox($lng->txt("note_enable_notes"))
143 ->withValue(!($setting->get("disable_notes")));
144
145 // section
146 $section1 = $f->input()->field()->section($fields, $lng->txt("settings"));
147
148 $form_action = $ctrl->getLinkTarget($this, "saveSettings");
149 return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
150 }
151
152 public function saveSettings(): void
153 {
155 $form = $this->initForm();
158 $setting = $this->setting;
159
160 if ($request->getMethod() === "POST") {
161 $form = $form->withRequest($request);
162 $data = $form->getData();
163 if (is_array($data["sec"])) {
164 $setting->set("disable_notes", $data["sec"]["enable_notes"] ? 0 : 1);
165 $this->main_tpl->setOnScreenMessage('info', $lng->txt("msg_obj_modified"), true);
166 }
167 }
168 $ctrl->redirect($this, "editSettings");
169 }
170}
error(string $a_errmsg)
getLinkTarget(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
getNextClass($a_gui_class=null)
@inheritDoc
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
forwardCommand(object $a_gui_object)
@inheritDoc
getCmd(?string $fallback_command=null)
@inheritDoc
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
Error Handling & global info handling.
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...
getAdminTabs()
administration tabs show only permissions and trash folder
ilGlobalTemplateInterface $main_tpl
__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.
prepareOutput(bool $show_sub_objects=true)
ServerRequestInterface $request
ilLanguage $lng
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
ILIAS Setting Class.
set(string $a_key, string $a_val)
get(string $a_keyword, ?string $a_default_value=null)
get setting
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
Add a Tab.
activateTab(string $a_id)
setContent(string $a_html)
Sets content for standard template.
This describes a standard form.
Definition: Standard.php:29
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26