ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilObjiLincClassroomGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
35include_once "./Services/Object/classes/class.ilObjectGUI.php";
36include_once "./Modules/ILinc/classes/class.ilObjiLincClassroom.php";
37
39{
40 private $form_gui = null;
41
47 function ilObjiLincClassroomGUI($a_icla_id,$a_icrs_id,$a_call_by_reference = false,$a_prepare_output = false)
48 {
50
51 $this->type = "icla";
52 $this->id = $a_icla_id;
53 $this->parent = $a_icrs_id;
54 $this->ilias =& $ilias;
55 $this->objDefinition =& $objDefinition;
56 $this->tpl =& $tpl;
57 $this->html = "";
58 $this->ctrl =& $ilCtrl;
59 $this->lng =& $lng;
60 $this->tree =& $tree;
61 $this->ilErr =& $ilErr;
62
63 //$this->ctrl->saveParameter($this,'parent');
64 $this->lng->loadLanguageModule('ilinc');
65
66 $this->formaction = array();
67 $this->return_location = array();
68 $this->target_frame = array();
69 //$this->tab_target_script = "adm_object.php";
70 $this->actions = "";
71 $this->sub_objects = "";
72
73 //prepare output
74 if (false)
75 {
76 $this->prepareOutput();
77 }
78
79 $this->assignObject();
80 }
81
82 function assignObject()
83 {
84 $this->object = new ilObjiLincClassroom($this->id, $this->parent);
85 }
86
87 public function create()
88 {
89 $this->prepareOutput();
90
91 $this->initSettingsForm('create');
92 $this->getDefaultValues();
93 return $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
94 }
95
96 protected function getDefaultValues()
97 {
98 $data = array(
99 'title' => '',
100 'desc' => '',
101 'instructoruserid' => 0,
102 'alwaysopen' => 1
103 );
104
105 $icrs_obj_id = ilObject::_lookupObjectId( $this->parent );
106 include_once 'Modules/ILinc/classes/class.ilObjiLincCourse.php';
107 $akclassvalues = ilObjiLincCourse::_getAKClassValues( $icrs_obj_id );
108 $data['akclassvalue1'] = $akclassvalues[0];
109 $data['akclassvalue2'] = $akclassvalues[1];
110
111 $this->form_gui->setValuesByArray( $data );
112 }
113
118 public function save()
119 {
120 $this->prepareOutput();
121
122 $this->initSettingsForm('create');
123 if($this->form_gui->checkInput())
124 {
125 $_POST['Fobject']['title'] = $this->form_gui->getInput('title');
126 $_POST['Fobject']['desc'] = $this->form_gui->getInput('desc');
127 $_POST['Fobject']['instructoruserid'] = $this->form_gui->getInput('instructoruserid');
128 $_POST['Fobject']['alwaysopen'] = $this->form_gui->getInput('alwaysopen');
129
130 // Akclassvalues
131 if($this->ilias->getSetting('ilinc_akclassvalues_active'))
132 {
133 $icrs_obj_id = ilObject::_lookupObjectId( $this->parent );
134 include_once 'Modules/ILinc/classes/class.ilObjiLincCourse.php';
135 $akclassvalues = ilObjiLincCourse::_getAKClassValues( $icrs_obj_id );
136
137 $_POST['Fobject']['akclassvalue1'] = $akclassvalues[0];
138 $_POST['Fobject']['akclassvalue2'] = $akclassvalues[1];
139 }
140
141 $ilinc_course_id = ilObjiLincClassroom::_lookupiCourseId( $this->parent );
142
143 $this->object->ilincAPI->addClass($ilinc_course_id, $_POST['Fobject']);
144 $response = $this->object->ilincAPI->sendRequest('addClass');
145 if($response->isError())
146 {
147 $this->ilErr->raiseError($response->getErrorMsg(), $this->ilErr->MESSAGE);
148 }
149
150 // Always send a message
151 ilUtil::sendInfo($response->getResultMsg(), true);
152
153 $this->ctrl->redirectByClass('ilobjilinccoursegui');
154 }
155 else
156 {
157 if($this->ilias->getSetting('ilinc_akclassvalues_active'))
158 {
159 $icrs_obj_id = ilObject::_lookupObjectId( $this->parent );
160 include_once 'Modules/ILinc/classes/class.ilObjiLincCourse.php';
161 $akclassvalues = ilObjiLincCourse::_getAKClassValues( $icrs_obj_id );
162
163 $_POST['akclassvalue1'] = $akclassvalues[0];
164 $_POST['akclassvalue2'] = $akclassvalues[1];
165 }
166
167 $this->form_gui->setValuesByPost();
168 return $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
169 }
170 }
171
172 function joinClassroom()
173 {
174 // join class
175 $url = $this->object->joinClass($this->ilias->account,$_GET['class_id']);
176
177 if (!$url)
178 {
179 $this->ilias->raiseError($this->object->getErrorMsg(),$this->ilias->error_obj->FATAL);
180 }
181
182 ilUtil::redirect(trim($url));
183 }
184
185 public function editClassroom()
186 {
187 $this->initSettingsForm('edit');
188 $this->getObjectValues();
189 return $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
190 }
191
192 protected function getObjectValues()
193 {
194 $data = array(
195 'title' => $this->object->getTitle(),
196 'desc' => $this->object->getDescription(),
197 'alwaysopen' => $this->object->getStatus(),
198 'instructoruserid' => $this->object->getDocentId()
199 );
200
201 $icrs_obj_id = ilObject::_lookupObjectId( $this->parent );
202 include_once 'Modules/ILinc/classes/class.ilObjiLincCourse.php';
203 $akclassvalues = ilObjiLincCourse::_getAKClassValues( $icrs_obj_id );
204 $data['akclassvalue1'] = $akclassvalues[0];
205 $data['akclassvalue2'] = $akclassvalues[1];
206
207 $this->form_gui->setValuesByArray( $data );
208 }
209
210 protected function initSettingsForm($a_mode = 'create')
211 {
212 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
213
214 $this->form_gui = new ilPropertyFormGUI();
215 $this->form_gui->setTableWidth('600');
216 if($a_mode == 'create')
217 {
218 $this->form_gui->setTitle($this->lng->txt('icla_add'));
219 }
220 else
221 {
222 $this->form_gui->setTitle($this->lng->txt('icla_edit'));
223 }
224 $this->form_gui->setTitleIcon(ilUtil::getTypeIconPath('icla', 0));
225
226 // Title
227 $text_input = new ilTextInputGUI($this->lng->txt('title'), 'title');
228 $text_input->setRequired(true);
229 $this->form_gui->addItem($text_input);
230
231 // Description
232 $text_area = new ilTextAreaInputGUI($this->lng->txt('desc'), 'desc');
233 $this->form_gui->addItem($text_area);
234
235 // Docentselection
236 $sel = new ilSelectInputGUI($this->lng->txt(ILINC_MEMBER_DOCENT), 'instructoruserid');
237 $docentlist = $this->object->getDocentList();
238 $docent_options = array();
239 $docent_options[0] = $this->lng->txt('please_choose');
240 foreach((array)$docentlist as $id => $data)
241 {
242 $docent_options[$id] = $data['fullname'];
243 }
244 $sel->setOptions($docent_options);
245 $this->form_gui->addItem($sel);
246
247 // Open
248 $rg = new ilRadioGroupInputGUI($this->lng->txt('access'), 'alwaysopen');
249 $rg->setValue(0);
250 $ro = new ilRadioOption($this->lng->txt('ilinc_classroom_open'), 1);
251 $rg->addOption($ro);
252 $ro = new ilRadioOption($this->lng->txt('ilinc_classroom_closed'), 0);
253 $rg->addOption($ro);
254 $this->form_gui->addItem($rg);
255
256 // Display akclassvalues
257 if($this->ilias->getSetting('ilinc_akclassvalues_active'))
258 {
259 $text_input = new ilTextInputGUI($this->lng->txt('akclassvalue1'), 'akclassvalue1');
260 $text_input->setDisabled(true);
261 $this->form_gui->addItem($text_input);
262
263 $text_input = new ilTextInputGUI($this->lng->txt('akclassvalue2'), 'akclassvalue2');
264 $text_input->setDisabled(true);
265 $this->form_gui->addItem($text_input);
266 }
267
268 // save and cancel commands
269 if($a_mode == 'create')
270 {
271 $this->ctrl->setParameter($this, 'mode', 'create');
272 $this->ctrl->setParameter($this, 'new_type', 'icla');
273
274 $this->form_gui->addCommandButton('save', $this->lng->txt('icla_add'));
275 $this->form_gui->addCommandButton('cancel', $this->lng->txt('cancel'));
276 $this->form_gui->setFormAction($this->ctrl->getFormAction($this, 'save'));
277 }
278 else
279 {
280 $this->ctrl->setParameter($this, 'class_id', $this->object->id);
281
282 $this->form_gui->addCommandButton('updateClassroom', $this->lng->txt('save'));
283 $this->form_gui->addCommandButton('cancel', $this->lng->txt('cancel'));
284 $this->form_gui->setFormAction($this->ctrl->getFormAction($this, 'updateClassroom'));
285 }
286 }
287
293 function getTabs(&$tabs_gui)
294 {
295 // tabs are defined manually here. The autogeneration via objects.xml will be deprecated in future
296 // for usage examples see ilObjGroupGUI or ilObjSystemFolderGUI
297 }
298
306 function removeClassroom($a_error = false)
307 {
308 // display confirmation message
309 $obj_str = "&class_id=".$this->object->id;
310 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
311 $cgui = new ilConfirmationGUI();
312 $cgui->setFormAction($this->getFormAction("delete",$this->ctrl->getFormAction($this).$obj_str));
313 $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
314 $cgui->setCancel($this->lng->txt("cancelDeleteClassroom"), "cancel");
315 $cgui->setConfirm($this->lng->txt("confirmedDeleteClassroom"), "confirm");
316
317 $caption = ilUtil::getImageTagByType($this->object->getType(), $this->tpl->tplPath).
318 " ".$this->object->getTitle().
319 " ".$this->object->getDescription();
320
321 $cgui->addItem("id[]", $this->object->getId(), $caption);
322 }
323
329 public function updateClassroom()
330 {
331 $this->initSettingsForm('edit');
332 if($this->form_gui->checkInput())
333 {
334 $this->object->setTitle( $this->form_gui->getInput('title' ));
335 $this->object->setDescription( $this->form_gui->getInput('desc') );
336 $this->object->setDocentId( $this->form_gui->getInput('instructoruserid') );
337 $this->object->setStatus( $this->form_gui->getInput('alwaysopen') );
338
339 if(!$this->object->update())
340 {
341 $this->ilErr->raiseError($this->object->getErrorMsg(), $this->ilErr->MESSAGE);
342 }
343
344 ilUtil::sendInfo($this->getResultMsg(), true);
345
346 $this->ctrl->redirectByClass('ilobjilinccoursegui');
347 }
348 else
349 {
350 if($this->ilias->getSetting('ilinc_akclassvalues_active'))
351 {
352 $icrs_obj_id = ilObject::_lookupObjectId( $this->parent );
353 include_once 'Modules/ILinc/classes/class.ilObjiLincCourse.php';
354 $akclassvalues = ilObjiLincCourse::_getAKClassValues( $icrs_obj_id );
355
356 $_POST['akclassvalue1'] = $akclassvalues[0];
357 $_POST['akclassvalue2'] = $akclassvalues[1];
358 }
359
360 $this->form_gui->setValuesByPost();
361 return $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
362 }
363 }
364
365 function &executeCommand()
366 {
367 $next_class = $this->ctrl->getNextClass($this);
368 $cmd = $this->ctrl->getCmd();
369
370 switch($next_class)
371 {
372 default:
373 $this->$cmd();
374 break;
375 }
376
377 return true;
378 }
379
386 {
387 ilSession::clear("saved_post");
388
389 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
390
391 $this->ctrl->redirectByClass("ilobjilinccoursegui");
392 }
393
398 {
399 if (!$this->object->delete())
400 {
401 $msg = $this->object->getErrorMsg();
402 }
403 else
404 {
405 $msg = $this->lng->txt('icla_deleted');
406 }
407
408 // Feedback
409 ilUtil::sendInfo($msg,true);
410
411 $this->ctrl->redirectByClass("ilobjilinccoursegui");
412 }
413
414 function getResultMsg()
415 {
416 return $this->object->result_msg;
417 }
418
423 function cancel()
424 {
425 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
426
427 $this->ctrl->redirectByClass("ilobjilinccoursegui");
428 }
429} // END class.ilObjiLincClassroomGUI
430?>
$_GET["client_id"]
Confirmation screen class.
Class ilObjectGUI Basic methods of all Output classes.
getFormAction($a_cmd, $a_formaction="")
get form action for command (command is method name without "Object", e.g.
prepareOutput()
prepare output
static _lookupObjectId($a_ref_id)
lookup object id
Class ilObjiLincClassroomGUI.
save()
save object @access public
cancel()
cancel is called when an operation is canceled, method links back @access public
updateClassroom()
updates class room on ilinc server
getTabs(&$tabs_gui)
get tabs @access public
removeClassroom($a_error=false)
display deletion confirmation screen only for referenced objects.
cancelDeleteClassroom()
cancel deletion of classroom object
ilObjiLincClassroomGUI($a_icla_id, $a_icrs_id, $a_call_by_reference=false, $a_prepare_output=false)
Constructor @access public 2 last parameters actually not used.
Class ilObjiLincClassroom.
_getAKClassValues($a_course_obj_id)
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.
This class represents a selection list property in a property form.
static clear($a_var)
Unset a value.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static getImageTagByType($a_type, $a_path, $a_big=false)
Builds an html image tag TODO: function still in use, but in future use getImagePath and move HTML-Co...
static redirect($a_script)
http redirect to other script
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
$cmd
Definition: sahs_server.php:35