ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
class.ilPCConsultationHoursGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once("./Modules/Portfolio/classes/class.ilPCConsultationHours.php");
6 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
7 
19 {
24  function ilPCConsultationHoursGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id = "")
25  {
26  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
27  }
28 
32  function &executeCommand()
33  {
34  // get next class that processes or forwards current command
35  $next_class = $this->ctrl->getNextClass($this);
36 
37  // get current command
38  $cmd = $this->ctrl->getCmd();
39 
40  switch($next_class)
41  {
42  default:
43  $ret =& $this->$cmd();
44  break;
45  }
46 
47  return $ret;
48  }
49 
55  function insert(ilPropertyFormGUI $a_form = null)
56  {
57  global $tpl;
58 
59  $this->displayValidationError();
60 
61  if(!$a_form)
62  {
63  $a_form = $this->initForm(true);
64  }
65  $tpl->setContent($a_form->getHTML());
66  }
67 
73  function edit(ilPropertyFormGUI $a_form = null)
74  {
75  global $tpl;
76 
77  $this->displayValidationError();
78 
79  if(!$a_form)
80  {
81  $a_form = $this->initForm();
82  }
83  $tpl->setContent($a_form->getHTML());
84  }
85 
92  protected function initForm($a_insert = false)
93  {
94  global $ilCtrl, $ilUser, $lng;
95 
96  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
97  $form = new ilPropertyFormGUI();
98  $form->setFormAction($ilCtrl->getFormAction($this));
99  if ($a_insert)
100  {
101  $form->setTitle($this->lng->txt("cont_insert_consultation_hours"));
102  }
103  else
104  {
105  $form->setTitle($this->lng->txt("cont_update_consultation_hours"));
106  }
107 
108  $mode = new ilRadioGroupInputGUI($this->lng->txt("cont_cach_mode"), "mode");
109  $mode->setRequired(true);
110  $form->addItem($mode);
111 
112  $opt_auto = new ilRadioOption($this->lng->txt("cont_cach_mode_automatic"), "auto");
113  $opt_auto->setInfo($this->lng->txt("cont_cach_mode_automatic_info"));
114  $mode->addOption($opt_auto);
115 
116  $opt_manual = new ilRadioOption($this->lng->txt("cont_cach_mode_manual"), "manual");
117  $opt_manual->setInfo($this->lng->txt("cont_cach_mode_manual_info"));
118  $mode->addOption($opt_manual);
119 
120  if(!$this->getPageConfig()->getEnablePCType("PlaceHolder"))
121  {
122  include_once "Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php";
123  $grp_ids = ilConsultationHourGroups::getGroupsOfUser($ilUser->getId());
124  if(sizeof($grp_ids))
125  {
126  $this->lng->loadLanguageModule("dateplaner");
127  $groups = new ilCheckboxGroupInputGUI($this->lng->txt("cal_ch_app_grp"), "grp");
128  $groups->setRequired(true);
129  $opt_manual->addSubItem($groups);
130 
131  foreach($grp_ids as $grp_obj)
132  {
133  $groups->addOption(new ilCheckboxOption($grp_obj->getTitle(), $grp_obj->getGroupId()));
134  }
135  }
136  else
137  {
138  $opt_manual->setDisabled(true);
139  }
140  }
141  else
142  {
143  $opt_manual->setDisabled(true);
144  }
145 
146  if ($a_insert)
147  {
148  $mode->setValue("auto");
149 
150  $form->addCommandButton("create_consultation_hours", $this->lng->txt("select"));
151  $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
152  }
153  else
154  {
155  // set values
156  $grp_ids = $this->content_obj->getGroupIds();
157  if(sizeof($grp_ids))
158  {
159  $mode->setValue("manual");
160  $groups->setValue($grp_ids);
161  }
162  else
163  {
164  $mode->setValue("auto");
165  }
166 
167  $form->addCommandButton("update", $this->lng->txt("select"));
168  $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
169  }
170 
171  return $form;
172  }
173 
177  function create()
178  {
179  $form = $this->initForm(true);
180  if($form->checkInput())
181  {
182  $grp_ids = null;
183  $mode = $form->getInput("mode");
184  if($mode == "manual")
185  {
186  $grp_ids = $form->getInput("grp");
187  }
188 
189  $this->content_obj = new ilPCConsultationHours($this->getPage());
190  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
191  $this->content_obj->setData($mode, (array)$grp_ids);
192  $this->updated = $this->pg_obj->update();
193  if ($this->updated === true)
194  {
195  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
196  }
197  }
198 
199  $form->setValuesByPost();
200  return $this->insert($form);
201  }
202 
206  function update()
207  {
208  $form = $this->initForm();
209  if($form->checkInput())
210  {
211  $grp_ids = array();
212  $mode = $form->getInput("mode");
213  if($mode == "manual")
214  {
215  $grp_ids = $form->getInput("grp");
216  }
217 
218  $this->content_obj->setData($mode, $grp_ids);
219  $this->updated = $this->pg_obj->update();
220  if ($this->updated === true)
221  {
222  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
223  }
224  }
225 
226  $this->pg_obj->addHierIDs();
227  $form->setValuesByPost();
228  return $this->edit($form);
229  }
230 }
231 
232 ?>
This class represents an option in a radio group.
This class represents an option in a checkbox group.
insert(ilPropertyFormGUI $a_form=null)
Insert consultation hours form.
This class represents a property form user interface.
$cmd
Definition: sahs_server.php:35
Class ilPCConsultationHours.
getPageConfig()
Get Page Config.
setInfo($a_info)
Set Info.
initForm($a_insert=false)
Init consultation hours form.
update()
Update consultation hours.
global $ilCtrl
Definition: ilias.php:18
static getGroupsOfUser($a_user_id)
Get a all groups of an user.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
This class represents a property in a property form.
displayValidationError()
display validation errors
This class represents a property in a property form.
Class ilPCConsultationHoursGUI.
edit(ilPropertyFormGUI $a_form=null)
Edit consultation hours form.
global $ilUser
Definition: imgupload.php:15
ilPCConsultationHoursGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id="")
Constructor public.
create()
Create new consultation hours.
setRequired($a_required)
Set Required.