ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjectActivationGUI Class Reference

Class ilObjectActivationGUI. More...

+ Collaboration diagram for ilObjectActivationGUI:

Public Member Functions

 __construct ($a_ref_id, $a_item_id)
 Constructor public. More...
 
 executeCommand ()
 
 getItemId ()
 
 cancel ()
 
 edit ()
 edit timings More...
 
 update ()
 update More...
 
 __setTabs ()
 

Protected Member Functions

 initFormEdit ()
 init form edit More...
 
 getValues ()
 get values More...
 

Protected Attributes

 $error
 
 $tabs
 
 $access
 
 $tree
 
 $user
 
 $help
 
 $parent_ref_id
 
 $item_id
 
 $tpl
 
 $ctrl
 
 $lng
 

Detailed Description

Class ilObjectActivationGUI.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id
class.ilCourseItemAdministrationGUI.php 33406 2012-02-28 16:26:59Z akill

ilObjectActivationGUI: ilConditionHandlerGUI

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

Constructor & Destructor Documentation

◆ __construct()

ilObjectActivationGUI::__construct (   $a_ref_id,
  $a_item_id 
)

Constructor public.

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

References $DIC, $ilCtrl, $ilErr, $lng, $tpl, and user().

55  {
56  global $DIC;
57 
58  $this->tpl = $DIC["tpl"];
59  $this->ctrl = $DIC->ctrl();
60  $this->lng = $DIC->language();
61  $this->error = $DIC["ilErr"];
62  $this->tabs = $DIC->tabs();
63  $this->access = $DIC->access();
64  $this->tree = $DIC->repositoryTree();
65  $this->user = $DIC->user();
66  $this->help = $DIC["ilHelp"];
67  $tpl = $DIC["tpl"];
68  $ilCtrl = $DIC->ctrl();
69  $lng = $DIC->language();
70  $ilErr = $DIC["ilErr"];
71  $ilTabs = $DIC->tabs();
72 
73  $this->tpl =&$tpl;
74  $this->ctrl =&$ilCtrl;
75  $this->lng =&$lng;
76  $this->lng->loadLanguageModule('crs');
77  $this->err =&$ilErr;
78  $this->tabs_gui =&$ilTabs;
79 
80  $this->parent_ref_id = $a_ref_id;
81  $this->item_id = $a_item_id;
82  $this->ctrl->saveParameter($this, 'item_id');
83  }
global $ilErr
Definition: raiseError.php:16
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:

Member Function Documentation

◆ __setTabs()

ilObjectActivationGUI::__setTabs ( )

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

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

Referenced by executeCommand().

355  {
357  $ilHelp = $this->help;
358 
359  $this->tabs_gui->clearTargets();
360 
361  $ilHelp->setScreenIdComponent("obj");
362 
363  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->parent_ref_id);
364  $back_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "");
365  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
366  $this->tabs_gui->setBackTarget($this->lng->txt('btn_back'), $back_link);
367 
368  $this->tabs_gui->addTarget(
369  "timings",
370  $this->ctrl->getLinkTarget($this, 'edit'),
371  "edit",
372  get_class($this)
373  );
374 
375  $this->ctrl->setParameterByClass('ilconditionhandlergui', 'item_id', $this->item_id);
376  $this->tabs_gui->addTarget(
377  "preconditions",
378  $this->ctrl->getLinkTargetByClass('ilConditionHandlerGUI', 'listConditions'),
379  "",
380  "ilConditionHandlerGUI"
381  );
382  return true;
383  }
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
+ Here is the caller graph for this function:

◆ cancel()

ilObjectActivationGUI::cancel ( )

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

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

◆ edit()

ilObjectActivationGUI::edit ( )

edit timings

public

Returns

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

References $access, $error, $ilErr, $tpl, getItemId(), getValues(), and initFormEdit().

142  {
144  $ilAccess = $this->access;
145  $tpl = $this->tpl;
146 
147  // #19997 - see ilObjectListGUI::insertTimingsCommand()
148  if (!$ilAccess->checkAccess('write', '', $this->parent_ref_id) &&
149  !$ilAccess->checkAccess('write', '', $this->getItemId())) {
150  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
151  }
152 
153  $this->initFormEdit();
154  $this->getValues();
155 
156  $tpl->setContent($this->form->getHTML());
157  }
global $ilErr
Definition: raiseError.php:16
+ Here is the call graph for this function:

◆ executeCommand()

ilObjectActivationGUI::executeCommand ( )

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

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

86  {
87  $tpl = $this->tpl;
88 
89  $this->__setTabs();
90 
91  $cmd = $this->ctrl->getCmd();
92 
93  // Check if item id is given and valid
94  if (!$this->item_id) {
95  ilUtil::sendFailure($this->lng->txt("crs_no_item_id_given"), true);
96  $this->ctrl->returnToParent($this);
97  }
98 
99  $tpl->getStandardTemplate();
100 
101  switch ($this->ctrl->getNextClass($this)) {
102  case 'ilconditionhandlergui':
103  // preconditions for single course items
104  include_once './Services/AccessControl/classes/class.ilConditionHandlerGUI.php';
105  $this->ctrl->saveParameter($this, 'item_id', $_GET['item_id']);
106  $new_gui = new ilConditionHandlerGUI($this, (int) $_GET['item_id']);
107  $this->ctrl->forwardCommand($new_gui);
108  $this->tabs_gui->setTabActive('preconditions');
109  break;
110 
111  default:
112  $this->tabs_gui->setTabActive('timings');
113  if (!$cmd) {
114  $cmd = 'edit';
115  }
116  $this->$cmd();
117  $this->tabs_gui->setTabActive('timings');
118  break;
119  }
120 
121  $tpl->show();
122  }
class ilConditionHandlerGUI
$_GET["client_id"]
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ getItemId()

ilObjectActivationGUI::getItemId ( )

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

References $item_id.

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

125  {
126  return $this->item_id;
127  }
+ Here is the caller graph for this function:

◆ getValues()

ilObjectActivationGUI::getValues ( )
protected

get values

protected

Returns

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

References $data, $ilUser, $user, array, ilObjectActivation\getItem(), getItemId(), IL_CAL_UNIX, and ilObjectActivation\TIMINGS_DEACTIVATED.

Referenced by edit().

247  {
249 
250  include_once "Services/Object/classes/class.ilObjectActivation.php";
251  $item_data = ilObjectActivation::getItem($this->getItemId());
252 
253  $data = array();
254 
255  if (!$item_data) {
257  } else {
258  $data['timing_type'] = $item_data['timing_type'];
259  $data['visible'] = $item_data['visible'];
260  $data['changeable'] = $item_data['changeable'];
261 
262  $map = array(
263  'timing_start' => 'timing_start'
264  ,'timing_end' => 'timing_end'
265  ,'sug_start' => 'suggestion_start'
266  ,'sug_end' => 'suggestion_end'
267  ,'early_start' => 'earliest_start'
268  ,'late_end' => 'latest_end'
269  );
270  foreach ($map as $data_key => $item_key) {
271  $data[$data_key] = null;
272 
273  // #14531
274  if ($item_data[$item_key]) {
275  $data[$data_key] = new ilDateTime($item_data[$item_key], IL_CAL_UNIX);
276  }
277  }
278  }
279 
280  $this->form->setValuesByArray($data);
281  }
static getItem($a_ref_id)
Get item data.
const IL_CAL_UNIX
Date and time handling
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFormEdit()

ilObjectActivationGUI::initFormEdit ( )
protected

init form edit

protected

Returns

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

References $end, $title, $tree, ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilSubEnabledFormPropertyGUI\addSubItem(), ilRadioOption\addSubItem(), getItemId(), ilRadioOption\setInfo(), ilFormPropertyGUI\setInfo(), ilFormPropertyGUI\setRequired(), ilObjectActivation\TIMINGS_ACTIVATION, ilObjectActivation\TIMINGS_DEACTIVATED, and ilObjectActivation\TIMINGS_PRESETTING.

Referenced by edit(), and update().

166  {
167  $tree = $this->tree;
168 
169  include_once "Services/Object/classes/class.ilObjectActivation.php";
170 
171  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
172  $this->form = new ilPropertyFormGUI();
173  $this->form->setFormAction($this->ctrl->getFormAction($this));
174 
176  $this->form->setTitle($title . ': ' . $this->lng->txt('crs_edit_timings'));
177 
178  $timings = new ilRadioGroupInputGUI($this->lng->txt('timings'), 'timing_type');
179 
180  // opt deactivated
181  $dea = new ilRadioOption($this->lng->txt('crs_timings_disabled'), ilObjectActivation::TIMINGS_DEACTIVATED);
182  $dea->setInfo($this->lng->txt('crs_timings_disabled_info'));
183  $timings->addOption($dea);
184 
185  // Visiblity
186  $vis = new ilRadioOption($this->lng->txt('crs_timings_availability_enabled'), ilObjectActivation::TIMINGS_ACTIVATION);
187  #$vis->setInfo($this->lng->txt('crs_timings_visibility'));
188 
189  $start = new ilDateTimeInputGUI($this->lng->txt('crs_timings_start'), 'timing_start');
190  $start->setRequired(true);
191  $start->setShowTime(true);
192  $vis->addSubItem($start);
193 
194  $end = new ilDateTimeInputGUI($this->lng->txt('crs_timings_end'), 'timing_end');
195  $end->setRequired(true);
196  $end->setShowTime(true);
197  $vis->addSubItem($end);
198 
199  $isv = new ilCheckboxInputGUI($this->lng->txt('crs_timings_visibility_short'), 'visible');
200  $isv->setInfo($this->lng->txt('crs_timings_visibility'));
201  $isv->setValue(1);
202  $vis->addSubItem($isv);
203 
204  $timings->addOption($vis);
205 
206  // Timings
207  $tim = new ilRadioOption($this->lng->txt('crs_timings_presetting'), ilObjectActivation::TIMINGS_PRESETTING);
208  $tim->setInfo($this->lng->txt('crs_item_presetting_info'));
209 
210  $start = new ilDateTimeInputGUI($this->lng->txt('crs_timings_sug_begin'), 'sug_start');
211  $start->setRequired(true);
212  $tim->addSubItem($start);
213 
214  $end = new ilDateTimeInputGUI($this->lng->txt('crs_timings_sug_end'), 'sug_end');
215  $end->setRequired(true);
216  $tim->addSubItem($end);
217 
218  if ($tree->checkForParentType($this->parent_ref_id, 'crs')) {
219  $cha = new ilCheckboxInputGUI($this->lng->txt('crs_timings_changeable'), 'changeable');
220  $tim->addSubItem($cha);
221 
222  $start = new ilDateTimeInputGUI($this->lng->txt('crs_timings_early_begin'), 'early_start');
223  $start->setRequired(true);
224  $tim->addSubItem($start);
225 
226  $late = new ilDateTimeInputGUI($this->lng->txt('crs_timings_short_limit_start_end'), 'late_end');
227  $late->setRequired(true);
228  $tim->addSubItem($late);
229  }
230 
231 
232  $timings->addOption($tim);
233 
234  $this->form->addItem($timings);
235 
236  $this->form->addCommandButton('update', $this->lng->txt('save'));
237  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
238  }
This class represents an option in a radio group.
This class represents a property form user interface.
$end
Definition: saml1-acs.php:18
This class represents a checkbox property in a property form.
static _lookupTitle($a_id)
lookup object title
setInfo($a_info)
Set Info.
This class represents a date/time property in a property form.
setInfo($a_info)
Set Information Text.
This class represents a property in a property form.
addSubItem($a_item)
Add Subitem.
static _lookupObjId($a_id)
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilObjectActivationGUI::update ( )

update

public

Returns

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

References $access, $error, $ilErr, $ilUser, $tpl, $user, getItemId(), IL_CAL_UNIX, initFormEdit(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

290  {
292  $ilAccess = $this->access;
293  $tpl = $this->tpl;
295 
296  // #19997 - see ilObjectListGUI::insertTimingsCommand()
297  if (!$ilAccess->checkAccess('write', '', $this->parent_ref_id) &&
298  !$ilAccess->checkAccess('write', '', $this->getItemId())) {
299  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE);
300  }
301 
302  $this->initFormEdit();
303  if ($this->form->checkInput()) {
304  include_once "Services/Object/classes/class.ilObjectActivation.php";
305  $activation = new ilObjectActivation();
306 
307  $activation->setTimingType($this->form->getInput('timing_type'));
308 
309  $date = $this->form->getItemByPostVar('timing_start')->getDate();
310  $activation->setTimingStart($date ? $date->get(IL_CAL_UNIX) : null);
311 
312  $date = $this->form->getItemByPostVar('timing_end')->getDate();
313  $activation->setTimingEnd($date ? $date->get(IL_CAL_UNIX) : null);
314 
315  $date = $this->form->getItemByPostVar('sug_start')->getDate();
316  $activation->setSuggestionStart($date ? $date->get(IL_CAL_UNIX) : null);
317 
318  $date = $this->form->getItemByPostVar('sug_end')->getDate();
319  $activation->setSuggestionEnd($date ? $date->get(IL_CAL_UNIX) : null);
320 
321  $date = null;
322  $item = $this->form->getItemByPostVar('early_start');
323  if ($item) {
324  $date = $item->getDate();
325  }
326  $activation->setEarliestStart($date ? $date->get(IL_CAL_UNIX) : null);
327 
328  $date = null;
329  $item = $this->form->getItemByPostVar('late_end');
330  if ($item) {
331  $date = $item->getDate();
332  }
333  $activation->setLatestEnd($date ? $date->get(IL_CAL_UNIX) : null);
334 
335  $activation->toggleVisible((bool) $this->form->getInput('visible'));
336  $activation->toggleChangeable((bool) $this->form->getInput('changeable'));
337 
338  if (!$activation->validateActivation()) {
339  ilUtil::sendFailure($ilErr->getMessage());
340  $this->form->setValuesByPost();
341  $tpl->setContent($this->form->getHTML());
342  return false;
343  } else {
344  $activation->update($this->getItemId());
345  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
346  $this->ctrl->redirect($this, "edit");
347  }
348  } else {
349  $this->form->setValuesByPost();
350  $tpl->setContent($this->form->getHTML());
351  }
352  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilErr
Definition: raiseError.php:16
const IL_CAL_UNIX
$ilUser
Definition: imgupload.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilObjectActivation.
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilObjectActivationGUI::$access
protected

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

Referenced by edit(), and update().

◆ $ctrl

ilObjectActivationGUI::$ctrl
protected

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

Referenced by __setTabs().

◆ $error

ilObjectActivationGUI::$error
protected

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

Referenced by edit(), and update().

◆ $help

ilObjectActivationGUI::$help
protected

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

Referenced by __setTabs().

◆ $item_id

ilObjectActivationGUI::$item_id
protected

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

Referenced by getItemId().

◆ $lng

ilObjectActivationGUI::$lng
protected

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

Referenced by __construct().

◆ $parent_ref_id

ilObjectActivationGUI::$parent_ref_id
protected

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

◆ $tabs

ilObjectActivationGUI::$tabs
protected

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

◆ $tpl

ilObjectActivationGUI::$tpl
protected

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

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

◆ $tree

ilObjectActivationGUI::$tree
protected

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

Referenced by initFormEdit().

◆ $user

ilObjectActivationGUI::$user
protected

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

Referenced by getValues(), and update().


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