ILIAS  release_8 Revision v8.24
ilObjectActivationGUI Class Reference

Class ilObjectActivationGUI. More...

+ Collaboration diagram for ilObjectActivationGUI:

Public Member Functions

 __construct (int $ref_id, int $item_id)
 
 executeCommand ()
 
 getItemId ()
 
 getTimingMode ()
 
 getParentId ()
 
 getActivation ()
 
 cancel ()
 
 edit (ilPropertyFormGUI $form=null)
 
 update ()
 

Protected Member Functions

 initFormEdit ()
 
 __setTabs ()
 
 initTimingMode ()
 
 initItem ()
 

Protected Attributes

ilGlobalTemplateInterface $tpl
 
ilCtrl $ctrl
 
ilLanguage $lng
 
ilErrorHandling $error
 
ilTabsGUI $tabs_gui
 
ilAccessHandler $access
 
ilTree $tree
 
ilObjUser $user
 
ilHelpGUI $help
 
ILIAS HTTP Wrapper RequestWrapper $request_wrapper
 
ILIAS Refinery Factory $refinery
 
int $parent_ref_id
 
int $item_id
 
int $timing_mode = null
 
ilObjectActivation $activation = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjectActivationGUI::__construct ( int  $ref_id,
int  $item_id 
)

Definition at line 48 of file class.ilObjectActivationGUI.php.

49 {
50 global $DIC;
51
52 $this->tpl = $DIC->ui()->mainTemplate();
53 $this->ctrl = $DIC->ctrl();
54 $this->lng = $DIC->language();
55 $this->lng->loadLanguageModule('crs');
56 $this->error = $DIC['ilErr'];
57 $this->tabs_gui = $DIC->tabs();
58 $this->access = $DIC->access();
59 $this->tree = $DIC->repositoryTree();
60 $this->user = $DIC->user();
61 $this->help = $DIC["ilHelp"];
62 $this->request_wrapper = $DIC->http()->wrapper()->query();
63 $this->refinery = $DIC->refinery();
64
65 $this->parent_ref_id = $ref_id;
66 $this->item_id = $item_id;
67
68 $this->ctrl->saveParameter($this, 'item_id');
69 }
error(string $a_errmsg)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67

References $DIC, $item_id, $ref_id, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), error(), ILIAS\Repository\help(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ __setTabs()

ilObjectActivationGUI::__setTabs ( )
protected

Definition at line 248 of file class.ilObjectActivationGUI.php.

248 : bool
249 {
250 $this->tabs_gui->clearTargets();
251
252 $this->help->setScreenIdComponent("obj");
253
254 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->parent_ref_id);
255 $back_link = $this->ctrl->getLinkTargetByClass("ilrepositorygui", "");
256 $ref_id = $this->request_wrapper->retrieve("ref_id", $this->refinery->kindlyTo()->string());
257 $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
258 $this->tabs_gui->setBackTarget($this->lng->txt('btn_back'), $back_link);
259
260 $this->tabs_gui->addTarget(
261 "timings",
262 $this->ctrl->getLinkTarget($this, 'edit'),
263 "edit",
264 get_class($this)
265 );
266
267 $this->ctrl->setParameterByClass('ilconditionhandlergui', 'item_id', $this->item_id);
268 $this->tabs_gui->addTarget(
269 "preconditions",
270 $this->ctrl->getLinkTargetByClass('ilConditionHandlerGUI', 'listConditions'),
271 "",
272 "ilConditionHandlerGUI"
273 );
274 return true;
275 }

References $ref_id, ILIAS\Repository\ctrl(), ILIAS\Repository\help(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancel()

ilObjectActivationGUI::cancel ( )

Definition at line 130 of file class.ilObjectActivationGUI.php.

130 : void
131 {
132 $this->ctrl->setParameterByClass('ilrepositorygui', 'ref_id', $this->parent_ref_id);
133 $this->ctrl->redirectByClass('ilrepositorygui');
134 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ edit()

ilObjectActivationGUI::edit ( ilPropertyFormGUI  $form = null)

Definition at line 136 of file class.ilObjectActivationGUI.php.

136 : void
137 {
138 // #19997 - see ilObjectListGUI::insertTimingsCommand()
139 if (
140 !$this->access->checkAccess('write', '', $this->parent_ref_id) &&
141 !$this->access->checkAccess('write', '', $this->getItemId())
142 ) {
143 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
144 }
145
146 if (!$form instanceof ilPropertyFormGUI) {
147 // show edit warning if timings are on
148 if ($this->tree->checkForParentType($this->getParentId(), 'crs')) {
149 if ($this->getActivation()->getTimingType() == ilObjectActivation::TIMINGS_PRESETTING) {
150 $this->tpl->setOnScreenMessage('info', $this->lng->txt('crs_timings_warning_timing_exists'));
151 }
152 }
153
154 $form = $this->initFormEdit();
155 }
156 $this->tpl->setContent($form->getHTML());
157 }
This class represents a property form user interface.

References ILIAS\Repository\access(), error(), getActivation(), initFormEdit(), ILIAS\Repository\lng(), and ilObjectActivation\TIMINGS_PRESETTING.

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilObjectActivationGUI::executeCommand ( )

Definition at line 71 of file class.ilObjectActivationGUI.php.

71 : void
72 {
73 $this->__setTabs();
74
75 $cmd = $this->ctrl->getCmd();
76
77 // Check if item id is given and valid
78 if (!$this->item_id) {
79 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("crs_no_item_id_given"), true);
80 $this->ctrl->returnToParent($this);
81 }
82
83 $this->tpl->loadStandardTemplate();
84
85 switch ($this->ctrl->getNextClass($this)) {
86 case 'ilconditionhandlergui':
87 // preconditions for single course items
88 $this->ctrl->saveParameter($this, 'item_id');
89 $item_id = $this->request_wrapper->retrieve("item_id", $this->refinery->kindlyTo()->int());
90 $new_gui = new ilConditionHandlerGUI($item_id);
91 $this->ctrl->forwardCommand($new_gui);
92 $this->tabs_gui->setTabActive('preconditions');
93 break;
94
95 default:
96 $this->initTimingMode();
97 $this->initItem();
98 $this->tabs_gui->setTabActive('timings');
99 if (!$cmd) {
100 $cmd = 'edit';
101 }
102 $this->$cmd();
103 $this->tabs_gui->setTabActive('timings');
104 break;
105 }
106
107 $this->tpl->printToStdout();
108 }
class ilConditionHandlerGUI

References $item_id, __setTabs(), ILIAS\Repository\ctrl(), initItem(), initTimingMode(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getActivation()

ilObjectActivationGUI::getActivation ( )

Definition at line 125 of file class.ilObjectActivationGUI.php.

126 {
127 return $this->activation;
128 }
Class ilObjectActivation.

References $activation.

Referenced by edit(), initFormEdit(), initItem(), and update().

+ Here is the caller graph for this function:

◆ getItemId()

ilObjectActivationGUI::getItemId ( )

Definition at line 110 of file class.ilObjectActivationGUI.php.

110 : int
111 {
112 return $this->item_id;
113 }

References $item_id.

Referenced by initFormEdit(), and update().

+ Here is the caller graph for this function:

◆ getParentId()

ilObjectActivationGUI::getParentId ( )

Definition at line 120 of file class.ilObjectActivationGUI.php.

120 : int
121 {
123 }

References $parent_ref_id.

Referenced by initItem(), and update().

+ Here is the caller graph for this function:

◆ getTimingMode()

ilObjectActivationGUI::getTimingMode ( )

Definition at line 115 of file class.ilObjectActivationGUI.php.

115 : ?int
116 {
117 return $this->timing_mode;
118 }

References $timing_mode.

◆ initFormEdit()

ilObjectActivationGUI::initFormEdit ( )
protected

Definition at line 159 of file class.ilObjectActivationGUI.php.

160 {
161 $form = new ilPropertyFormGUI();
162 $form->setFormAction($this->ctrl->getFormAction($this));
163
164 $title = htmlspecialchars(
166 ENT_QUOTES | ENT_SUBSTITUTE,
167 'utf-8'
168 );
169 $form->setTitle($title . ': ' . $this->lng->txt('crs_edit_timings'));
170
171 $availability = new ilCheckboxInputGUI($this->lng->txt('crs_timings_availability_enabled'), 'availability');
172 $availability->setValue("1");
173 $availability->setChecked($this->getActivation()->getTimingType() == ilObjectActivation::TIMINGS_ACTIVATION);
174
175 $start = new ilDateTimeInputGUI($this->lng->txt('crs_timings_start'), 'timing_start');
176 $start->setDate(new ilDateTime($this->getActivation()->getTimingStart(), IL_CAL_UNIX));
177 $start->setShowTime(true);
178 $availability->addSubItem($start);
179
180 $end = new ilDateTimeInputGUI($this->lng->txt('crs_timings_end'), 'timing_end');
181 $end->setDate(new ilDateTime($this->getActivation()->getTimingEnd(), IL_CAL_UNIX));
182 $end->setShowTime(true);
183 $availability->addSubItem($end);
184
185 $isv = new ilCheckboxInputGUI($this->lng->txt('crs_timings_visibility_short'), 'visible');
186 $isv->setInfo($this->lng->txt('crs_timings_visibility'));
187 $isv->setValue("1");
188 $isv->setChecked($this->getActivation()->enabledVisible());
189 $availability->addSubItem($isv);
190
191 $form->addItem($availability);
192
193 $form->addCommandButton('update', $this->lng->txt('save'));
194 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
195
196 return $form;
197 }
const IL_CAL_UNIX
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@classDescription Date and time handling
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)

References ilObject\_lookupObjId(), ilObject\_lookupTitle(), ILIAS\Repository\ctrl(), getActivation(), getItemId(), IL_CAL_UNIX, ILIAS\Repository\lng(), and ilObjectActivation\TIMINGS_ACTIVATION.

Referenced by edit(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initItem()

ilObjectActivationGUI::initItem ( )
protected

Definition at line 290 of file class.ilObjectActivationGUI.php.

290 : void
291 {
292 $this->activation = new ilObjectActivation();
293 $this->getActivation()->read($this->item_id, $this->getParentId());
294 }

References getActivation(), and getParentId().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTimingMode()

ilObjectActivationGUI::initTimingMode ( )
protected

Definition at line 277 of file class.ilObjectActivationGUI.php.

277 : void
278 {
279 // Check for parent course and if available read timing mode (abs | rel)
280 $crs_ref_id = $this->tree->checkForParentType($this->parent_ref_id, 'crs');
281 $crs_obj_id = ilObject::_lookupObjId($crs_ref_id);
282
283 if ($crs_obj_id) {
284 $this->timing_mode = ilObjCourse::lookupTimingMode($crs_obj_id);
285 } else {
287 }
288 }
static lookupTimingMode(int $a_obj_id)

References ilObject\_lookupObjId(), ilCourseConstants\IL_CRS_VIEW_TIMING_ABSOLUTE, and ilObjCourse\lookupTimingMode().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilObjectActivationGUI::update ( )

Definition at line 199 of file class.ilObjectActivationGUI.php.

199 : void
200 {
201 // #19997 - see ilObjectListGUI::insertTimingsCommand()
202 if (
203 !$this->access->checkAccess('write', '', $this->parent_ref_id) &&
204 !$this->access->checkAccess('write', '', $this->getItemId())
205 ) {
206 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
207 }
208
209 $form = $this->initFormEdit();
210 if ($form->checkInput()) {
211 $valid = true;
213 $activation->read($this->getItemId());
214
215 if ($form->getInput('availability')) {
217
218 $timing_start = $form->getItemByPostVar('timing_start')->getDate();
219 $timing_end = $form->getItemByPostVar('timing_end')->getDate();
220
221 if ($timing_start && $timing_end && ilDateTime::_after($timing_start, $timing_end)) {
222 $form->getItemByPostVar('timing_start')->setAlert($this->lng->txt('crs_timing_err_start_end'));
223 $form->getItemByPostVar('timing_end')->setAlert($this->lng->txt('crs_timing_err_start_end'));
224 $valid = false;
225 }
226
227 $this->getActivation()->setTimingStart($timing_start ? $timing_start->get(IL_CAL_UNIX) : null);
228 $this->getActivation()->setTimingEnd($timing_end ? $timing_end->get(IL_CAL_UNIX) : null);
229
230 $this->getActivation()->toggleVisible((bool) $form->getInput('visible'));
231 } elseif ($this->getActivation()->getTimingType() != ilObjectActivation::TIMINGS_PRESETTING) {
233 }
234
235 if ($valid) {
236 $this->getActivation()->update($this->getItemId(), $this->getParentId());
237 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
238 $this->ctrl->redirect($this, "edit");
239 } else {
240 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
241 }
242 }
243
244 $form->setValuesByPost();
245 $this->edit($form);
246 }
static _after(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
edit(ilPropertyFormGUI $form=null)
read(int $ref_id, int $parent_id=0)
$valid

References $activation, $valid, ilDateTime\_after(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), edit(), error(), getActivation(), getItemId(), getParentId(), IL_CAL_UNIX, initFormEdit(), ILIAS\Repository\lng(), ilObjectActivation\read(), ilObjectActivation\TIMINGS_ACTIVATION, ilObjectActivation\TIMINGS_DEACTIVATED, and ilObjectActivation\TIMINGS_PRESETTING.

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilObjectActivationGUI::$access
protected

Definition at line 35 of file class.ilObjectActivationGUI.php.

◆ $activation

ilObjectActivation ilObjectActivationGUI::$activation = null
protected

Definition at line 46 of file class.ilObjectActivationGUI.php.

Referenced by getActivation(), and update().

◆ $ctrl

ilCtrl ilObjectActivationGUI::$ctrl
protected

Definition at line 31 of file class.ilObjectActivationGUI.php.

◆ $error

ilErrorHandling ilObjectActivationGUI::$error
protected

Definition at line 33 of file class.ilObjectActivationGUI.php.

◆ $help

ilHelpGUI ilObjectActivationGUI::$help
protected

Definition at line 38 of file class.ilObjectActivationGUI.php.

◆ $item_id

int ilObjectActivationGUI::$item_id
protected

Definition at line 43 of file class.ilObjectActivationGUI.php.

Referenced by __construct(), executeCommand(), and getItemId().

◆ $lng

ilLanguage ilObjectActivationGUI::$lng
protected

Definition at line 32 of file class.ilObjectActivationGUI.php.

◆ $parent_ref_id

int ilObjectActivationGUI::$parent_ref_id
protected

Definition at line 42 of file class.ilObjectActivationGUI.php.

Referenced by getParentId().

◆ $refinery

ILIAS Refinery Factory ilObjectActivationGUI::$refinery
protected

Definition at line 40 of file class.ilObjectActivationGUI.php.

◆ $request_wrapper

ILIAS HTTP Wrapper RequestWrapper ilObjectActivationGUI::$request_wrapper
protected

Definition at line 39 of file class.ilObjectActivationGUI.php.

◆ $tabs_gui

ilTabsGUI ilObjectActivationGUI::$tabs_gui
protected

Definition at line 34 of file class.ilObjectActivationGUI.php.

◆ $timing_mode

int ilObjectActivationGUI::$timing_mode = null
protected

Definition at line 45 of file class.ilObjectActivationGUI.php.

Referenced by getTimingMode().

◆ $tpl

ilGlobalTemplateInterface ilObjectActivationGUI::$tpl
protected

Definition at line 30 of file class.ilObjectActivationGUI.php.

◆ $tree

ilTree ilObjectActivationGUI::$tree
protected

Definition at line 36 of file class.ilObjectActivationGUI.php.

◆ $user

ilObjUser ilObjectActivationGUI::$user
protected

Definition at line 37 of file class.ilObjectActivationGUI.php.


The documentation for this class was generated from the following file: