ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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

 $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 24 of file class.ilObjectActivationGUI.php.

References $ilCtrl, $ilErr, $lng, and $tpl.

25  {
26  global $tpl,$ilCtrl,$lng,$ilErr,$ilTabs;
27 
28  $this->tpl =& $tpl;
29  $this->ctrl =& $ilCtrl;
30  $this->lng =& $lng;
31  $this->lng->loadLanguageModule('crs');
32  $this->err =& $ilErr;
33  $this->tabs_gui =& $ilTabs;
34 
35  $this->parent_ref_id = $a_ref_id;
36  $this->item_id = $a_item_id;
37  $this->ctrl->saveParameter($this,'item_id');
38 
39  }
global $ilErr
Definition: raiseError.php:16
global $ilCtrl
Definition: ilias.php:18

Member Function Documentation

◆ __setTabs()

ilObjectActivationGUI::__setTabs ( )

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

References $_GET, and $ilCtrl.

Referenced by executeCommand().

325  {
326  global $ilCtrl, $ilHelp;
327 
328  $this->tabs_gui->clearTargets();
329 
330  $ilHelp->setScreenIdComponent("obj");
331 
332  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->parent_ref_id);
333  $back_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "");
334  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
335  $this->tabs_gui->setBackTarget($this->lng->txt('btn_back'), $back_link);
336 
337  $this->tabs_gui->addTarget("timings",
338  $this->ctrl->getLinkTarget($this,'edit'),
339  "edit", get_class($this));
340 
341  $this->ctrl->setParameterByClass('ilconditionhandlergui','item_id',$this->item_id);
342  $this->tabs_gui->addTarget("preconditions",
343  $this->ctrl->getLinkTargetByClass('ilConditionHandlerGUI','listConditions'),
344  "", "ilConditionHandlerGUI");
345  return true;
346  }
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
+ Here is the caller graph for this function:

◆ cancel()

ilObjectActivationGUI::cancel ( )

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

89  {
90  $this->ctrl->setParameterByClass('ilrepositorygui', 'ref_id', $this->parent_ref_id);
91  $this->ctrl->redirectByClass('ilrepositorygui');
92  }

◆ edit()

ilObjectActivationGUI::edit ( )

edit timings

public

Returns

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

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

101  {
102  global $ilErr,$ilAccess,$tpl;
103 
104  // #19997 - see ilObjectListGUI::insertTimingsCommand()
105  if(!$ilAccess->checkAccess('write','',$this->parent_ref_id) &&
106  !$ilAccess->checkAccess('write','',$this->getItemId()))
107  {
108  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
109  }
110 
111  $this->initFormEdit();
112  $this->getValues();
113 
114  $tpl->setContent($this->form->getHTML());
115  }
global $ilErr
Definition: raiseError.php:16
+ Here is the call graph for this function:

◆ executeCommand()

ilObjectActivationGUI::executeCommand ( )

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

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

42  {
43  global $tpl;
44 
45  $this->__setTabs();
46 
47  $cmd = $this->ctrl->getCmd();
48 
49  // Check if item id is given and valid
50  if(!$this->item_id)
51  {
52  ilUtil::sendFailure($this->lng->txt("crs_no_item_id_given"),true);
53  $this->ctrl->returnToParent($this);
54  }
55 
56  $tpl->getStandardTemplate();
57 
58  switch($this->ctrl->getNextClass($this))
59  {
60  case 'ilconditionhandlergui':
61  // preconditions for single course items
62  include_once './Services/AccessControl/classes/class.ilConditionHandlerGUI.php';
63  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
64  $new_gui = new ilConditionHandlerGUI($this,(int) $_GET['item_id']);
65  $this->ctrl->forwardCommand($new_gui);
66  $this->tabs_gui->setTabActive('preconditions');
67  break;
68 
69  default:
70  $this->tabs_gui->setTabActive('timings');
71  if(!$cmd)
72  {
73  $cmd = 'edit';
74  }
75  $this->$cmd();
76  $this->tabs_gui->setTabActive('timings');
77  break;
78  }
79 
80  $tpl->show();
81  }
class ilConditionHandlerGUI
$_GET["client_id"]
$cmd
Definition: sahs_server.php:35
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 83 of file class.ilObjectActivationGUI.php.

References $item_id.

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

+ Here is the caller graph for this function:

◆ getValues()

ilObjectActivationGUI::getValues ( )
protected

get values

protected

Returns

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

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

Referenced by edit().

206  {
207  global $ilUser;
208 
209  include_once "Services/Object/classes/class.ilObjectActivation.php";
210  $item_data = ilObjectActivation::getItem($this->getItemId());
211 
212  $data = array();
213 
214  if(!$item_data)
215  {
217  }
218  else
219  {
220  $data['timing_type'] = $item_data['timing_type'];
221  $data['visible'] = $item_data['visible'];
222  $data['changeable'] = $item_data['changeable'];
223 
224  $map = array(
225  'timing_start' => 'timing_start'
226  ,'timing_end' => 'timing_end'
227  ,'sug_start' => 'suggestion_start'
228  ,'sug_end' => 'suggestion_end'
229  ,'early_start' => 'earliest_start'
230  ,'late_end' => 'latest_end'
231  );
232  foreach($map as $data_key => $item_key)
233  {
234  $data[$data_key] = null;
235 
236  // #14531
237  if($item_data[$item_key])
238  {
239  $data[$data_key] = new ilDateTime($item_data[$item_key], IL_CAL_UNIX);
240  }
241  }
242  }
243 
244  $this->form->setValuesByArray($data);
245  }
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 123 of file class.ilObjectActivationGUI.php.

References $start, $title, 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().

124  {
125  global $tree;
126 
127  include_once "Services/Object/classes/class.ilObjectActivation.php";
128 
129  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
130  $this->form = new ilPropertyFormGUI();
131  $this->form->setFormAction($this->ctrl->getFormAction($this));
132 
134  $this->form->setTitle($title.': '.$this->lng->txt('crs_edit_timings'));
135 
136  $timings = new ilRadioGroupInputGUI($this->lng->txt('timings'),'timing_type');
137 
138  // opt deactivated
139  $dea = new ilRadioOption($this->lng->txt('crs_timings_disabled'),ilObjectActivation::TIMINGS_DEACTIVATED);
140  $dea->setInfo($this->lng->txt('crs_timings_disabled_info'));
141  $timings->addOption($dea);
142 
143  // Visiblity
144  $vis = new ilRadioOption($this->lng->txt('crs_timings_availability_enabled'),ilObjectActivation::TIMINGS_ACTIVATION);
145  #$vis->setInfo($this->lng->txt('crs_timings_visibility'));
146 
147  $start = new ilDateTimeInputGUI($this->lng->txt('crs_timings_start'),'timing_start');
148  $start->setRequired(true);
149  $start->setShowTime(true);
150  $vis->addSubItem($start);
151 
152  $end = new ilDateTimeInputGUI($this->lng->txt('crs_timings_end'),'timing_end');
153  $end->setRequired(true);
154  $end->setShowTime(true);
155  $vis->addSubItem($end);
156 
157  $isv = new ilCheckboxInputGUI($this->lng->txt('crs_timings_visibility_short'),'visible');
158  $isv->setInfo($this->lng->txt('crs_timings_visibility'));
159  $isv->setValue(1);
160  $vis->addSubItem($isv);
161 
162  $timings->addOption($vis);
163 
164  // Timings
165  $tim = new ilRadioOption($this->lng->txt('crs_timings_presetting'),ilObjectActivation::TIMINGS_PRESETTING);
166  $tim->setInfo($this->lng->txt('crs_item_presetting_info'));
167 
168  $start = new ilDateTimeInputGUI($this->lng->txt('crs_timings_sug_begin'),'sug_start');
169  $start->setRequired(true);
170  $tim->addSubItem($start);
171 
172  $end = new ilDateTimeInputGUI($this->lng->txt('crs_timings_sug_end'),'sug_end');
173  $end->setRequired(true);
174  $tim->addSubItem($end);
175 
176  if ($tree->checkForParentType($this->parent_ref_id,'crs'))
177  {
178  $cha = new ilCheckboxInputGUI($this->lng->txt('crs_timings_changeable'),'changeable');
179  $tim->addSubItem($cha);
180 
181  $start = new ilDateTimeInputGUI($this->lng->txt('crs_timings_early_begin'),'early_start');
182  $start->setRequired(true);
183  $tim->addSubItem($start);
184 
185  $late = new ilDateTimeInputGUI($this->lng->txt('crs_timings_short_limit_start_end'),'late_end');
186  $late->setRequired(true);
187  $tim->addSubItem($late);
188  }
189 
190 
191  $timings->addOption($tim);
192 
193  $this->form->addItem($timings);
194 
195  $this->form->addCommandButton('update',$this->lng->txt('save'));
196  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
197  }
This class represents an option in a radio group.
This class represents a property form user interface.
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 253 of file class.ilObjectActivationGUI.php.

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

254  {
255  global $ilErr,$ilAccess,$tpl,$ilUser;
256 
257  // #19997 - see ilObjectListGUI::insertTimingsCommand()
258  if(!$ilAccess->checkAccess('write','',$this->parent_ref_id) &&
259  !$ilAccess->checkAccess('write','',$this->getItemId()))
260  {
261  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
262  }
263 
264  $this->initFormEdit();
265  if($this->form->checkInput())
266  {
267  include_once "Services/Object/classes/class.ilObjectActivation.php";
268  $activation = new ilObjectActivation();
269 
270  $activation->setTimingType($this->form->getInput('timing_type'));
271 
272  $date = $this->form->getItemByPostVar('timing_start')->getDate();
273  $activation->setTimingStart($date ? $date->get(IL_CAL_UNIX) : null);
274 
275  $date = $this->form->getItemByPostVar('timing_end')->getDate();
276  $activation->setTimingEnd($date ? $date->get(IL_CAL_UNIX) : null);
277 
278  $date = $this->form->getItemByPostVar('sug_start')->getDate();
279  $activation->setSuggestionStart($date ? $date->get(IL_CAL_UNIX) : null);
280 
281  $date = $this->form->getItemByPostVar('sug_end')->getDate();
282  $activation->setSuggestionEnd($date ? $date->get(IL_CAL_UNIX) : null);
283 
284  $date = null;
285  $item = $this->form->getItemByPostVar('early_start');
286  if($item)
287  {
288  $date = $item->getDate();
289  }
290  $activation->setEarliestStart($date ? $date->get(IL_CAL_UNIX) : null);
291 
292  $date = null;
293  $item = $this->form->getItemByPostVar('late_end');
294  if($item)
295  {
296  $date = $item->getDate();
297  }
298  $activation->setLatestEnd($date ? $date->get(IL_CAL_UNIX) : null);
299 
300  $activation->toggleVisible((bool) $this->form->getInput('visible'));
301  $activation->toggleChangeable((bool) $this->form->getInput('changeable'));
302 
303  if(!$activation->validateActivation())
304  {
305  ilUtil::sendFailure($ilErr->getMessage());
306  $this->form->setValuesByPost();
307  $tpl->setContent($this->form->getHTML());
308  return false;
309  }
310  else
311  {
312  $activation->update($this->getItemId());
313  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
314  $this->ctrl->redirect($this, "edit");
315  }
316  }
317  else
318  {
319  $this->form->setValuesByPost();
320  $tpl->setContent($this->form->getHTML());
321  }
322  }
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

◆ $ctrl

ilObjectActivationGUI::$ctrl
protected

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

◆ $item_id

ilObjectActivationGUI::$item_id
protected

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

Referenced by getItemId().

◆ $lng

ilObjectActivationGUI::$lng
protected

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

Referenced by __construct().

◆ $parent_ref_id

ilObjectActivationGUI::$parent_ref_id
protected

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

◆ $tpl

ilObjectActivationGUI::$tpl
protected

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

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


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