ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjLearningSequenceAdminGUI.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
4
11{
12 const CMD_VIEW = 'view';
13 const CMD_EDIT = 'edit';
14 const CMD_SAVE = 'save';
15 const F_POLL_INTERVAL = 'polling';
16
20 protected $settings_db;
21
22 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
23 {
24 $this->type = 'lsos';
25
26 global $DIC;
27 $this->ctrl = $DIC['ilCtrl'];
28 $this->rbacsystem = $DIC['rbacsystem'];
29 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
30
31 $this->settings_db = new ilLSGlobalSettingsDB($DIC['ilSetting']);
32 $this->ui_factory = $DIC['ui.factory'];
33 $this->ui_renderer = $DIC['ui.renderer'];
34 $this->refinery = $DIC['refinery'];
35 $this->request = $DIC->http()->request();
36 }
37
38 public function getAdminTabs()
39 {
40 $this->tabs_gui->addTarget('settings', $this->ctrl->getLinkTargetByClass(self::class, self::CMD_EDIT));
41 if ($this->rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
42 $this->tabs_gui->addTarget('perm_settings', $this->ctrl->getLinkTargetByClass('ilpermissiongui', 'perm'), array(), 'ilpermissiongui');
43 }
44 }
45
46 public function executeCommand()
47 {
48 $this->checkPermission('read');
49 $next_class = $this->ctrl->getNextClass($this);
50 $cmd = $this->ctrl->getCmd();
51 $this->prepareOutput();
52
53 switch ($next_class) {
54 case 'ilpermissiongui':
55 $this->tabs_gui->setTabActive('perm_settings');
56 $perm_gui = new ilPermissionGUI($this);
57 $this->ctrl->forwardCommand($perm_gui);
58 break;
59
60 default:
61 switch ($cmd) {
62 case self::CMD_VIEW:
63 case self::CMD_EDIT:
64 $this->edit();
65 break;
66 case self::CMD_SAVE:
67 $this->save();
68 break;
69 default:
70 throw new Exception(__METHOD__ . " :: Unknown command " . $cmd);
71 }
72 }
73 }
74
75 protected function getForm(array $values = []) : Input\Container\Form\Form
76 {
77 $target = $this->ctrl->getLinkTargetByClass(self::class, self::CMD_SAVE);
78 $poll_interval = $this->ui_factory->input()->field()->numeric(
79 $this->lng->txt("lso_admin_interval_label"),
80 $this->lng->txt("lso_admin_interval_byline")
81 )
82 ->withAdditionalTransformation(
83 $this->refinery->int()->isGreaterThan(0)
84 )
85 ->withAdditionalTransformation(
86 $this->refinery->custom()->transformation(
87 function ($v) {
88 return (float) $v;
89 }
90 )
91 );
92
93 if (isset($values[self::F_POLL_INTERVAL])) {
94 $poll_interval = $poll_interval->withValue($values[self::F_POLL_INTERVAL]);
95 }
96
97 $section = $this->ui_factory->input()->field()->section(
98 [self::F_POLL_INTERVAL => $poll_interval],
99 $this->lng->txt("lso_admin_form_title"),
100 $this->lng->txt("lso_admin_form_byline")
101 );
102 $form = $this->ui_factory->input()->container()->form()
103 ->standard($target, [$section])
104 ->withAdditionalTransformation(
105 $this->refinery->custom()->transformation(
106 function ($data) {
107 return array_shift($data);
108 }
109 )
110 );
111
112 return $form;
113 }
114
115 protected function show(Input\Container\Form\Form $form) : void
116 {
117 $this->tpl->setContent(
118 $this->ui_renderer->render($form)
119 );
120 }
121
122 protected function edit() : void
123 {
124 $values = [
125 self::F_POLL_INTERVAL => $this->settings_db->getSettings()->getPollingIntervalSeconds()
126 ];
127 $form = $this->getForm($values);
128 $this->show($form);
129 }
130
131 protected function save() : void
132 {
133 $form = $this->getForm()->withRequest($this->request);
134 $data = $form->getData();
135 if ($data) {
136 $settings = $this->settings_db->getSettings()
137 ->withPollingIntervalSeconds($data[self::F_POLL_INTERVAL]);
138 $this->settings_db->storeSettings($settings);
139 }
140 $this->show($form);
141 }
142}
$section
Definition: Utf8Test.php:83
An exception for terminatinating execution or to throw for unit testing.
Repository for LSGlobalSettings over ILIAS global settings.
LearningSequence Administration Settings.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
getAdminTabs()
administration tabs show only permissions and trash folder
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
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46