ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPCConsultationHoursGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
17 protected $user;
18
23 public function __construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id = "")
24 {
25 global $DIC;
26
27 $this->tpl = $DIC["tpl"];
28 $this->ctrl = $DIC->ctrl();
29 $this->user = $DIC->user();
30 $this->lng = $DIC->language();
31 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
32 }
33
37 public function executeCommand()
38 {
39 // get next class that processes or forwards current command
40 $next_class = $this->ctrl->getNextClass($this);
41
42 // get current command
43 $cmd = $this->ctrl->getCmd();
44
45 switch ($next_class) {
46 default:
47 $ret = &$this->$cmd();
48 break;
49 }
50
51 return $ret;
52 }
53
59 public function insert(ilPropertyFormGUI $a_form = null)
60 {
62
64
65 if (!$a_form) {
66 $a_form = $this->initForm(true);
67 }
68 $tpl->setContent($a_form->getHTML());
69 }
70
76 public function edit(ilPropertyFormGUI $a_form = null)
77 {
79
81
82 if (!$a_form) {
83 $a_form = $this->initForm();
84 }
85 $tpl->setContent($a_form->getHTML());
86 }
87
94 protected function initForm($a_insert = false)
95 {
96 $ilCtrl = $this->ctrl;
99
100 $form = new ilPropertyFormGUI();
101 $form->setFormAction($ilCtrl->getFormAction($this));
102 if ($a_insert) {
103 $form->setTitle($this->lng->txt("cont_insert_consultation_hours"));
104 } else {
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")) {
122 if (sizeof($grp_ids)) {
123 $this->lng->loadLanguageModule("dateplaner");
124 $groups = new ilCheckboxGroupInputGUI($this->lng->txt("cal_ch_app_grp"), "grp");
125 $groups->setRequired(true);
126 $opt_manual->addSubItem($groups);
127
128 foreach ($grp_ids as $grp_obj) {
129 $groups->addOption(new ilCheckboxOption($grp_obj->getTitle(), $grp_obj->getGroupId()));
130 }
131 } else {
132 $opt_manual->setDisabled(true);
133 }
134 } else {
135 $opt_manual->setDisabled(true);
136 }
137
138 if ($a_insert) {
139 $mode->setValue("auto");
140
141 $form->addCommandButton("create_consultation_hours", $this->lng->txt("select"));
142 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
143 } else {
144 // set values
145 $grp_ids = $this->content_obj->getGroupIds();
146 if (sizeof($grp_ids)) {
147 $mode->setValue("manual");
148 $groups->setValue($grp_ids);
149 } else {
150 $mode->setValue("auto");
151 }
152
153 $form->addCommandButton("update", $this->lng->txt("select"));
154 $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
155 }
156
157 return $form;
158 }
159
163 public function create()
164 {
165 $form = $this->initForm(true);
166 if ($form->checkInput()) {
167 $grp_ids = null;
168 $mode = $form->getInput("mode");
169 if ($mode == "manual") {
170 $grp_ids = $form->getInput("grp");
171 }
172
173 $this->content_obj = new ilPCConsultationHours($this->getPage());
174 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
175 $this->content_obj->setData($mode, (array) $grp_ids);
176 $this->updated = $this->pg_obj->update();
177 if ($this->updated === true) {
178 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
179 }
180 }
181
182 $form->setValuesByPost();
183 return $this->insert($form);
184 }
185
189 public function update()
190 {
191 $form = $this->initForm();
192 if ($form->checkInput()) {
193 $grp_ids = array();
194 $mode = $form->getInput("mode");
195 if ($mode == "manual") {
196 $grp_ids = $form->getInput("grp");
197 }
198
199 $this->content_obj->setData($mode, $grp_ids);
200 $this->updated = $this->pg_obj->update();
201 if ($this->updated === true) {
202 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
203 }
204 }
205
206 $this->pg_obj->addHierIDs();
207 $form->setValuesByPost();
208 return $this->edit($form);
209 }
210}
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 $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6