ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilObjectActivationGUI Class Reference

Class ilObjectActivationGUI. More...

+ Collaboration diagram for ilObjectActivationGUI:

Public Member Functions

 __construct ($a_ref_id, $a_item_id)
 ilObjectActivationGUI constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 getItemId ()
 
 getTimingMode ()
 
 getParentId ()
 Get parent ref_id. More...
 
 getActivation ()
 Get item object. More...
 
 cancel ()
 cancel action handler More...
 
 edit (ilPropertyFormGUI $form=null)
 edit timings More...
 
 update ()
 update More...
 

Protected Member Functions

 initFormEdit ()
 init form edit More...
 
 __setTabs ()
 
 initTimingMode ()
 Init type of timing mode. More...
 
 initItem ()
 Init item. More...
 

Protected Attributes

 $error
 
 $tabs_gui
 
 $access
 
 $tree
 
 $user
 
 $help
 
 $parent_ref_id
 
 $item_id
 
 $tpl
 
 $ctrl
 
 $lng
 
 $timing_mode = null
 
 $activation = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjectActivationGUI::__construct (   $a_ref_id,
  $a_item_id 
)

ilObjectActivationGUI constructor.

Parameters
$a_ref_id
$a_item_id

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

84 {
85 global $DIC;
86
87 $this->tpl = $DIC->ui()->mainTemplate();
88 $this->ctrl = $DIC->ctrl();
89 $this->lng = $DIC->language();
90 $this->lng->loadLanguageModule('crs');
91
92 $this->error = $DIC['ilErr'];
93 $this->tabs_gui = $DIC->tabs();
94 $this->access = $DIC->access();
95 $this->tree = $DIC->repositoryTree();
96 $this->user = $DIC->user();
97 $this->help = $DIC["ilHelp"];
98
99
100 $this->parent_ref_id = $a_ref_id;
101 $this->item_id = $a_item_id;
102
103 $this->ctrl->saveParameter($this, 'item_id');
104 }
user()
Definition: user.php:4
error($a_errmsg)
set error message @access public
help()
Definition: help.php:2
$DIC
Definition: xapitoken.php:46

References $DIC, error(), help(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ __setTabs()

ilObjectActivationGUI::__setTabs ( )
protected
Returns
bool

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

332 {
334 $ilHelp = $this->help;
335
336 $this->tabs_gui->clearTargets();
337
338 $ilHelp->setScreenIdComponent("obj");
339
340 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->parent_ref_id);
341 $back_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "");
342 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
343 $this->tabs_gui->setBackTarget($this->lng->txt('btn_back'), $back_link);
344
345 $this->tabs_gui->addTarget(
346 "timings",
347 $this->ctrl->getLinkTarget($this, 'edit'),
348 "edit",
349 get_class($this)
350 );
351
352 $this->ctrl->setParameterByClass('ilconditionhandlergui', 'item_id', $this->item_id);
353 $this->tabs_gui->addTarget(
354 "preconditions",
355 $this->ctrl->getLinkTargetByClass('ilConditionHandlerGUI', 'listConditions'),
356 "",
357 "ilConditionHandlerGUI"
358 );
359 return true;
360 }
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18

References $_GET, $ctrl, $help, and $ilCtrl.

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ cancel()

ilObjectActivationGUI::cancel ( )

cancel action handler

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

186 {
187 $this->ctrl->setParameterByClass('ilrepositorygui', 'ref_id', $this->parent_ref_id);
188 $this->ctrl->redirectByClass('ilrepositorygui');
189 }

◆ edit()

ilObjectActivationGUI::edit ( ilPropertyFormGUI  $form = null)

edit timings

@access public

Returns

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

198 {
200 $ilAccess = $this->access;
202
203 // #19997 - see ilObjectListGUI::insertTimingsCommand()
204 if (
205 !$ilAccess->checkAccess('write', '', $this->parent_ref_id) &&
206 !$ilAccess->checkAccess('write', '', $this->getItemId())) {
207 $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
208 }
209
210 if (!$form instanceof ilPropertyFormGUI) {
211 // show edit warning if timings are on
212 if ($GLOBALS['tree']->checkForParentType($this->getParentId(), 'crs')) {
213 if ($this->getActivation()->getTimingType() == ilObjectActivation::TIMINGS_PRESETTING) {
214 ilUtil::sendInfo($this->lng->txt('crs_timings_warning_timing_exists'));
215 }
216 }
217
218 $form = $this->initFormEdit();
219 }
220 $tpl->setContent($form->getHTML());
221 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
This class represents a property form user interface.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$ilErr
Definition: raiseError.php:18

References $access, $error, $GLOBALS, $ilErr, $tpl, getActivation(), getParentId(), initFormEdit(), ilUtil\sendInfo(), 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 ( )

Execute command.

Exceptions
ilCtrlException

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

111 {
113
114 $this->__setTabs();
115
116 $cmd = $this->ctrl->getCmd();
117
118 // Check if item id is given and valid
119 if (!$this->item_id) {
120 ilUtil::sendFailure($this->lng->txt("crs_no_item_id_given"), true);
121 $this->ctrl->returnToParent($this);
122 }
123
124 $tpl->loadStandardTemplate();
125
126 switch ($this->ctrl->getNextClass($this)) {
127 case 'ilconditionhandlergui':
128 // preconditions for single course items
129 $this->ctrl->saveParameter($this, 'item_id', $_GET['item_id']);
130 $new_gui = new ilConditionHandlerGUI($this, (int) $_GET['item_id']);
131 $this->ctrl->forwardCommand($new_gui);
132 $this->tabs_gui->setTabActive('preconditions');
133 break;
134
135 default:
136 $this->initTimingMode();
137 $this->initItem();
138 $this->tabs_gui->setTabActive('timings');
139 if (!$cmd) {
140 $cmd = 'edit';
141 }
142 $this->$cmd();
143 $this->tabs_gui->setTabActive('timings');
144 break;
145 }
146
147 $tpl->printToStdout();
148 }
class ilConditionHandlerGUI
initTimingMode()
Init type of timing mode.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References $_GET, $tpl, __setTabs(), initItem(), initTimingMode(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ getActivation()

ilObjectActivationGUI::getActivation ( )

Get item object.

Returns
ilObjectActivation

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

References $activation.

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

+ Here is the caller graph for this function:

◆ getItemId()

ilObjectActivationGUI::getItemId ( )
Returns
int

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

References $item_id.

Referenced by initFormEdit(), and update().

+ Here is the caller graph for this function:

◆ getParentId()

ilObjectActivationGUI::getParentId ( )

Get parent ref_id.

Returns
int

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

References $parent_ref_id.

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

+ Here is the caller graph for this function:

◆ getTimingMode()

ilObjectActivationGUI::getTimingMode ( )

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

References $timing_mode.

◆ initFormEdit()

ilObjectActivationGUI::initFormEdit ( )
protected

init form edit

@access protected

Returns

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

230 {
232
233 $form = new ilPropertyFormGUI();
234 $form->setFormAction($this->ctrl->getFormAction($this));
235
237 $form->setTitle($title . ': ' . $this->lng->txt('crs_edit_timings'));
238
239
240 $availability = new ilCheckboxInputGUI($this->lng->txt('crs_timings_availability_enabled'), 'availability');
241 $availability->setValue(1);
242 $availability->setChecked($this->getActivation()->getTimingType() == ilObjectActivation::TIMINGS_ACTIVATION);
243
244 $start = new ilDateTimeInputGUI($this->lng->txt('crs_timings_start'), 'timing_start');
245 $start->setDate(new ilDateTime($this->getActivation()->getTimingStart(), IL_CAL_UNIX));
246 $start->setShowTime(true);
247 $availability->addSubItem($start);
248
249 $end = new ilDateTimeInputGUI($this->lng->txt('crs_timings_end'), 'timing_end');
250 $end->setDate(new ilDateTime($this->getActivation()->getTimingEnd(), IL_CAL_UNIX));
251 $end->setShowTime(true);
252 $availability->addSubItem($end);
253
254 $isv = new ilCheckboxInputGUI($this->lng->txt('crs_timings_visibility_short'), 'visible');
255 $isv->setInfo($this->lng->txt('crs_timings_visibility'));
256 $isv->setValue(1);
257 $isv->setChecked((bool) $this->getActivation()->enabledVisible());
258 $availability->addSubItem($isv);
259
260
261 $form->addItem($availability);
262
263 $form->addCommandButton('update', $this->lng->txt('save'));
264 $form->addCommandButton('cancel', $this->lng->txt('cancel'));
265
266 return $form;
267 }
const IL_CAL_UNIX
This class represents a checkbox property in a property form.
This class represents a date/time property in a property form.
@classDescription Date and time handling
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title

References $tree, ilObject\_lookupObjId(), ilObject\_lookupTitle(), getActivation(), getItemId(), IL_CAL_UNIX, 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

Init item.

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

385 {
386 $this->activation = new ilObjectActivation();
387 $this->getActivation()->read($this->item_id, $this->getParentId());
388 }
Class ilObjectActivation.

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

Init type of timing mode.

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

366 {
367 // Check for parent course and if available read timing mode (abs | rel)
368 $crs_ref_id = $GLOBALS['tree']->checkForParentType(
369 $this->parent_ref_id,
370 'crs'
371 );
372 $crs_obj_id = ilObject::_lookupObjId($crs_ref_id);
373
374 if ($crs_obj_id) {
375 $this->timing_mode = ilObjCourse::lookupTimingMode($crs_obj_id);
376 } else {
378 }
379 }
static lookupTimingMode($a_obj_id)

References $GLOBALS, 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 ( )

update

@access public

Returns

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

276 {
278 $ilAccess = $this->access;
281
282 // #19997 - see ilObjectListGUI::insertTimingsCommand()
283 if (
284 !$ilAccess->checkAccess('write', '', $this->parent_ref_id) &&
285 !$ilAccess->checkAccess('write', '', $this->getItemId())) {
286 $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
287 }
288
289 $form = $this->initFormEdit();
290 if ($form->checkInput()) {
291 $valid = true;
293 $activation->read($this->getItemId());
294
295 if ($form->getInput('availability')) {
297
298 $timing_start = $form->getItemByPostVar('timing_start')->getDate();
299 $timing_end = $form->getItemByPostVar('timing_end')->getDate();
300
301 if ($timing_start && $timing_end && ilDateTime::_after($timing_start, $timing_end)) {
302 $form->getItemByPostVar('timing_start')->setAlert($this->lng->txt('crs_timing_err_start_end'));
303 $form->getItemByPostVar('timing_end')->setAlert($this->lng->txt('crs_timing_err_start_end'));
304 $valid = false;
305 }
306
307 $this->getActivation()->setTimingStart($timing_start ? $timing_start->get(IL_CAL_UNIX) : null);
308 $this->getActivation()->setTimingEnd($timing_end ? $timing_end->get(IL_CAL_UNIX) : null);
309
310 $this->getActivation()->toggleVisible((bool) $form->getInput('visible'));
311 } elseif ($this->getActivation()->getTimingType() != ilObjectActivation::TIMINGS_PRESETTING) {
313 }
314
315 if ($valid) {
316 $this->getActivation()->update($this->getItemId(), $this->getParentId());
317 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
318 $this->ctrl->redirect($this, "edit");
319 } else {
320 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
321 }
322 }
323
324 $form->setValuesByPost();
325 $this->edit($form);
326 }
static _after(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
edit(ilPropertyFormGUI $form=null)
edit timings
$valid
$ilUser
Definition: imgupload.php:18

References $access, $activation, $error, $ilErr, $ilUser, $tpl, $user, $valid, ilDateTime\_after(), edit(), getActivation(), getItemId(), getParentId(), IL_CAL_UNIX, initFormEdit(), ilUtil\sendFailure(), ilObjectActivation\TIMINGS_ACTIVATION, ilObjectActivation\TIMINGS_DEACTIVATED, and ilObjectActivation\TIMINGS_PRESETTING.

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilObjectActivationGUI::$access
protected

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

Referenced by edit(), and update().

◆ $activation

ilObjectActivationGUI::$activation = null
protected

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

Referenced by getActivation(), and update().

◆ $ctrl

ilObjectActivationGUI::$ctrl
protected

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

Referenced by __setTabs().

◆ $error

ilObjectActivationGUI::$error
protected

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

Referenced by edit(), and update().

◆ $help

ilObjectActivationGUI::$help
protected

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

Referenced by __setTabs().

◆ $item_id

ilObjectActivationGUI::$item_id
protected

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

Referenced by getItemId().

◆ $lng

ilObjectActivationGUI::$lng
protected

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

◆ $parent_ref_id

ilObjectActivationGUI::$parent_ref_id
protected

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

Referenced by getParentId().

◆ $tabs_gui

ilObjectActivationGUI::$tabs_gui
protected

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

◆ $timing_mode

ilObjectActivationGUI::$timing_mode = null
protected

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

Referenced by getTimingMode().

◆ $tpl

ilObjectActivationGUI::$tpl
protected

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

Referenced by edit(), executeCommand(), and update().

◆ $tree

ilObjectActivationGUI::$tree
protected

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

Referenced by initFormEdit().

◆ $user

ilObjectActivationGUI::$user
protected

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

Referenced by update().


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