ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
5require_once("./Modules/Portfolio/classes/class.ilPCConsultationHours.php");
6require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
7
19{
23 protected $user;
24
29 public function __construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id = "")
30 {
31 global $DIC;
32
33 $this->tpl = $DIC["tpl"];
34 $this->ctrl = $DIC->ctrl();
35 $this->user = $DIC->user();
36 $this->lng = $DIC->language();
37 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
38 }
39
43 public function executeCommand()
44 {
45 // get next class that processes or forwards current command
46 $next_class = $this->ctrl->getNextClass($this);
47
48 // get current command
49 $cmd = $this->ctrl->getCmd();
50
51 switch ($next_class) {
52 default:
53 $ret =&$this->$cmd();
54 break;
55 }
56
57 return $ret;
58 }
59
65 public function insert(ilPropertyFormGUI $a_form = null)
66 {
68
70
71 if (!$a_form) {
72 $a_form = $this->initForm(true);
73 }
74 $tpl->setContent($a_form->getHTML());
75 }
76
82 public function edit(ilPropertyFormGUI $a_form = null)
83 {
85
87
88 if (!$a_form) {
89 $a_form = $this->initForm();
90 }
91 $tpl->setContent($a_form->getHTML());
92 }
93
100 protected function initForm($a_insert = false)
101 {
105
106 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
107 $form = new ilPropertyFormGUI();
108 $form->setFormAction($ilCtrl->getFormAction($this));
109 if ($a_insert) {
110 $form->setTitle($this->lng->txt("cont_insert_consultation_hours"));
111 } else {
112 $form->setTitle($this->lng->txt("cont_update_consultation_hours"));
113 }
114
115 $mode = new ilRadioGroupInputGUI($this->lng->txt("cont_cach_mode"), "mode");
116 $mode->setRequired(true);
117 $form->addItem($mode);
118
119 $opt_auto = new ilRadioOption($this->lng->txt("cont_cach_mode_automatic"), "auto");
120 $opt_auto->setInfo($this->lng->txt("cont_cach_mode_automatic_info"));
121 $mode->addOption($opt_auto);
122
123 $opt_manual = new ilRadioOption($this->lng->txt("cont_cach_mode_manual"), "manual");
124 $opt_manual->setInfo($this->lng->txt("cont_cach_mode_manual_info"));
125 $mode->addOption($opt_manual);
126
127 if (!$this->getPageConfig()->getEnablePCType("PlaceHolder")) {
128 include_once "Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php";
130 if (sizeof($grp_ids)) {
131 $this->lng->loadLanguageModule("dateplaner");
132 $groups = new ilCheckboxGroupInputGUI($this->lng->txt("cal_ch_app_grp"), "grp");
133 $groups->setRequired(true);
134 $opt_manual->addSubItem($groups);
135
136 foreach ($grp_ids as $grp_obj) {
137 $groups->addOption(new ilCheckboxOption($grp_obj->getTitle(), $grp_obj->getGroupId()));
138 }
139 } else {
140 $opt_manual->setDisabled(true);
141 }
142 } else {
143 $opt_manual->setDisabled(true);
144 }
145
146 if ($a_insert) {
147 $mode->setValue("auto");
148
149 $form->addCommandButton("create_consultation_hours", $this->lng->txt("select"));
150 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
151 } else {
152 // set values
153 $grp_ids = $this->content_obj->getGroupIds();
154 if (sizeof($grp_ids)) {
155 $mode->setValue("manual");
156 $groups->setValue($grp_ids);
157 } else {
158 $mode->setValue("auto");
159 }
160
161 $form->addCommandButton("update", $this->lng->txt("select"));
162 $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
163 }
164
165 return $form;
166 }
167
171 public function create()
172 {
173 $form = $this->initForm(true);
174 if ($form->checkInput()) {
175 $grp_ids = null;
176 $mode = $form->getInput("mode");
177 if ($mode == "manual") {
178 $grp_ids = $form->getInput("grp");
179 }
180
181 $this->content_obj = new ilPCConsultationHours($this->getPage());
182 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
183 $this->content_obj->setData($mode, (array) $grp_ids);
184 $this->updated = $this->pg_obj->update();
185 if ($this->updated === true) {
186 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
187 }
188 }
189
190 $form->setValuesByPost();
191 return $this->insert($form);
192 }
193
197 public function update()
198 {
199 $form = $this->initForm();
200 if ($form->checkInput()) {
201 $grp_ids = array();
202 $mode = $form->getInput("mode");
203 if ($mode == "manual") {
204 $grp_ids = $form->getInput("grp");
205 }
206
207 $this->content_obj->setData($mode, $grp_ids);
208 $this->updated = $this->pg_obj->update();
209 if ($this->updated === true) {
210 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
211 }
212 }
213
214 $this->pg_obj->addHierIDs();
215 $form->setValuesByPost();
216 return $this->edit($form);
217 }
218}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
This class represents a property in a property form.
This class represents an option in a checkbox group.
static getGroupsOfUser($a_user_id)
Get a all groups of an user.
Class ilPCConsultationHoursGUI.
create()
Create new consultation hours.
insert(ilPropertyFormGUI $a_form=null)
Insert consultation hours form.
edit(ilPropertyFormGUI $a_form=null)
Edit consultation hours form.
update()
Update consultation hours.
initForm($a_insert=false)
Init consultation hours form.
__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
Class ilPCConsultationHours.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getPageConfig()
Get Page Config.
displayValidationError()
display validation errors
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18