00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00035 include_once "./classes/class.ilObjectGUI.php";
00036 include_once "class.ilObjiLincClassroom.php";
00037
00038 class ilObjiLincClassroomGUI extends ilObjectGUI
00039 {
00045 function ilObjiLincClassroomGUI($a_icla_id,$a_icrs_id,$a_call_by_reference = false,$a_prepare_output = false)
00046 {
00047 global $ilCtrl,$lng,$ilias,$objDefinition,$tpl,$tree,$ilErr;
00048
00049 $this->type = "icla";
00050 $this->id = $a_icla_id;
00051 $this->parent = $a_icrs_id;
00052 $this->ilias =& $ilias;
00053 $this->objDefinition =& $objDefinition;
00054 $this->tpl =& $tpl;
00055 $this->html = "";
00056 $this->ctrl =& $ilCtrl;
00057 $this->lng =& $lng;
00058 $this->tree =& $tree;
00059 $this->ilErr =& $ilErr;
00060
00061
00062 $this->lng->loadLanguageModule('ilinc');
00063
00064 $this->formaction = array();
00065 $this->return_location = array();
00066 $this->target_frame = array();
00067
00068 $this->actions = "";
00069 $this->sub_objects = "";
00070
00071
00072 if (false)
00073 {
00074 $this->prepareOutput();
00075 }
00076
00077 $this->assignObject();
00078 }
00079
00080 function assignObject()
00081 {
00082 $this->object = new ilObjiLincClassroom($this->id,$this->parent);
00083 }
00084
00085 function create()
00086 {
00087 $this->prepareOutput();
00088
00089 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
00090
00091
00092 $data = array();
00093 $data["fields"] = array();
00094 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
00095 $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
00096
00097
00098
00099 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.icla_edit.html","ilinc");
00100
00101 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00102 $this->tpl->setVariable("TITLE", $data["fields"]["title"]);
00103 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("desc"));
00104 $this->tpl->setVariable("DESC", $data["fields"]["desc"]);
00105
00106
00107 $docentlist = $this->object->getDocentList();
00108
00109 $docent_options[0] = $this->lng->txt('please_choose');
00110
00111 foreach ($docentlist as $id => $data)
00112 {
00113 $docent_options[$id] = $data['fullname'];
00114 }
00115
00116 $sel_docents = ilUtil::formSelect("0","Fobject[instructoruserid]",$docent_options,false,true);
00117
00118 $this->tpl->setVariable("TXT_DOCENT", $this->lng->txt(ILINC_MEMBER_DOCENT));
00119 $this->tpl->setVariable("SEL_DOCENT", $sel_docents);
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 $radio1 = ilUtil::formRadioButton(1,"Fobject[alwaysopen]","1");
00133 $radio2 = ilUtil::formRadioButton(0,"Fobject[alwaysopen]","0");
00134
00135 $this->tpl->setVariable("TXT_ACCESS", $this->lng->txt("access"));
00136 $this->tpl->setVariable("SEL_ACCESS", $radio1." ".$this->lng->txt("ilinc_classroom_open").$radio2." ".$this->lng->txt("ilinc_classroom_closed"));
00137
00138
00139 if ($this->ilias->getSetting("ilinc_akclassvalues_active"))
00140 {
00141 $icrs_obj_id = ilObject::_lookupObjectId($this->parent);
00142 include_once('class.ilObjiLincCourse.php');
00143 $akclassvalues = ilObjiLincCourse::_getAKClassValues($icrs_obj_id);
00144
00145 $this->tpl->setVariable("TXT_AKCLASSVALUE1", $this->lng->txt("akclassvalue1"));
00146 $this->tpl->setVariable("TXT_AKCLASSVALUE2", $this->lng->txt("akclassvalue2"));
00147
00148 $this->tpl->setVariable("AKCLASSVALUE1", $akclassvalues[0]);
00149 $this->tpl->setVariable("AKCLASSVALUE2", $akclassvalues[1]);
00150 }
00151
00152 $this->tpl->setVariable("FORMACTION", $this->getFormAction("save",$this->ctrl->getFormAction($this)."&new_type=".$new_type));
00153
00154 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
00155 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00156 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
00157 $this->tpl->setVariable("CMD_SUBMIT", "save");
00158 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00159 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00160 }
00161
00166 function save()
00167 {
00168
00169 if ($this->ilias->getSetting("ilinc_akclassvalues_active"))
00170 {
00171 $icrs_obj_id = ilObject::_lookupObjectId($this->parent);
00172 include_once('class.ilObjiLincCourse.php');
00173 $akclassvalues = ilObjiLincCourse::_getAKClassValues($icrs_obj_id);
00174
00175 $_POST['Fobject']['akclassvalue1'] = $akclassvalues[0];
00176 $_POST['Fobject']['akclassvalue2'] = $akclassvalues[1];
00177 }
00178
00179 $ilinc_course_id = ilObjiLincClassroom::_lookupiCourseId($this->parent);
00180
00181 $this->object->ilincAPI->addClass($ilinc_course_id,$_POST['Fobject']);
00182 $response = $this->object->ilincAPI->sendRequest('addClass');
00183
00184 if ($response->isError())
00185 {
00186 $this->ilErr->raiseError($response->getErrorMsg(),$this->ilErr->MESSAGE);
00187 }
00188
00189
00190 ilUtil::sendInfo($response->getResultMsg(),true);
00191
00192 $this->ctrl->redirectByClass("ilobjilinccoursegui");
00193 }
00194
00195 function joinClassroom()
00196 {
00197
00198 $url = $this->object->joinClass($this->ilias->account,$_GET['class_id']);
00199
00200 if (!$url)
00201 {
00202 $this->ilias->raiseError($this->object->getErrorMsg(),$this->ilias->error_obj->FATAL);
00203 }
00204
00205 ilUtil::redirect(trim($url));
00206 }
00207
00208 function editClassroom()
00209 {
00210 $fields = array();
00211
00212 if ($_SESSION["error_post_vars"])
00213 {
00214
00215 $fields["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
00216 $fields["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
00217 }
00218 else
00219 {
00220 $fields["title"] = ilUtil::prepareFormOutput($this->object->getTitle());
00221 $fields["desc"] = ilUtil::stripSlashes($this->object->getDescription());
00222 }
00223
00224 $this->displayEditForm($fields);
00225 }
00226
00233 function displayEditForm($fields)
00234 {
00235
00236 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.icla_edit.html","ilinc");
00237
00238 foreach ($fields as $key => $val)
00239 {
00240 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
00241 $this->tpl->setVariable(strtoupper($key), $val);
00242 $this->tpl->parseCurrentBlock();
00243 }
00244
00245
00246 $docentlist = $this->object->getDocentList();
00247
00248 $docent_options[0] = $this->lng->txt('please_choose');
00249
00250 foreach ($docentlist as $id => $data)
00251 {
00252 $docent_options[$id] = $data['fullname'];
00253 }
00254
00255 $sel_docents = ilUtil::formSelect($this->object->getDocentId(),"Fobject[instructoruserid]",$docent_options,false,true);
00256
00257 $this->tpl->setVariable("TXT_DOCENT", $this->lng->txt(ILINC_MEMBER_DOCENT));
00258 $this->tpl->setVariable("SEL_DOCENT", $sel_docents);
00259
00260
00261 $open = 0; $closed = 0;
00262
00263 if ($this->object->getStatus())
00264 {
00265 $open = 1;
00266 }
00267 else
00268 {
00269 $closed = 1;
00270 }
00271
00272 $radio1 = ilUtil::formRadioButton($open,"Fobject[alwaysopen]","1");
00273 $radio2 = ilUtil::formRadioButton($closed,"Fobject[alwaysopen]","0");
00274
00275 $this->tpl->setVariable("TXT_ACCESS", $this->lng->txt("access"));
00276 $this->tpl->setVariable("SEL_ACCESS", $radio1." ".$this->lng->txt("ilinc_classroom_open").$radio2." ".$this->lng->txt("ilinc_classroom_closed"));
00277
00278
00279 if ($this->ilias->getSetting("ilinc_akclassvalues_active"))
00280 {
00281 $icrs_obj_id = ilObject::_lookupObjectId($this->parent);
00282 include_once('class.ilObjiLincCourse.php');
00283 $akclassvalues = ilObjiLincCourse::_getAKClassValues($icrs_obj_id);
00284
00285 $this->tpl->setVariable("TXT_AKCLASSVALUE1", $this->lng->txt("akclassvalue1"));
00286 $this->tpl->setVariable("TXT_AKCLASSVALUE2", $this->lng->txt("akclassvalue2"));
00287
00288 $this->tpl->setVariable("AKCLASSVALUE1", $akclassvalues[0]);
00289 $this->tpl->setVariable("AKCLASSVALUE2", $akclassvalues[1]);
00290 }
00291
00292 $obj_str = "&class_id=".$this->object->id;
00293 $this->tpl->setVariable("FORMACTION", $this->getFormAction("update",$this->ctrl->getFormAction($this).$obj_str));
00294
00295 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
00296 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
00297 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00298 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00299 $this->tpl->setVariable("CMD_SUBMIT", "updateClassroom");
00300 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00301
00302 }
00303
00309 function getTabs(&$tabs_gui)
00310 {
00311
00312
00313 }
00314
00322 function removeClassroom($a_error = false)
00323 {
00324 unset($this->data);
00325 $this->data["cols"] = array("type", "title", "last_change");
00326
00327 $this->data["data"][$_GET['class_id']] = array(
00328 "type" => $this->object->getType(),
00329 "title" => $this->object->getTitle()."#separator#".$this->object->getDescription()." ",
00330 "last_update" => "n/a"
00331 );
00332
00333 $this->data["buttons"] = array( "confirmedDeleteClassroom" => $this->lng->txt("confirm"),
00334 "cancelDeleteClassroom" => $this->lng->txt("cancel"));
00335
00336 $this->getTemplateFile("confirm");
00337
00338 if(!$a_error)
00339 {
00340 ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
00341 }
00342
00343 $obj_str = "&class_id=".$this->object->id;
00344 $this->tpl->setVariable("FORMACTION", $this->getFormAction("delete",$this->ctrl->getFormAction($this).$obj_str));
00345
00346
00347 foreach ($this->data["cols"] as $key)
00348 {
00349 $this->tpl->setCurrentBlock("table_header");
00350 $this->tpl->setVariable("TEXT",$this->lng->txt($key));
00351 $this->tpl->parseCurrentBlock();
00352 }
00353
00354
00355
00356 $counter = 0;
00357
00358 foreach ($this->data["data"] as $key => $value)
00359 {
00360
00361 foreach ($value as $key => $cell_data)
00362 {
00363 $this->tpl->setCurrentBlock("table_cell");
00364
00365
00366 if ($key == "type")
00367 {
00368 $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
00369 }
00370 elseif ($key == "title")
00371 {
00372 $name_field = explode("#separator#",$cell_data);
00373
00374 $this->tpl->setVariable("TEXT_CONTENT", "<b>".$name_field[0]."</b>");
00375
00376 $this->tpl->setCurrentBlock("subtitle");
00377 $this->tpl->setVariable("DESC", $name_field[1]);
00378 $this->tpl->parseCurrentBlock();
00379 $this->tpl->setCurrentBlock("table_cell");
00380 }
00381 else
00382 {
00383 $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
00384 }
00385
00386 $this->tpl->parseCurrentBlock();
00387 }
00388
00389 $this->tpl->setCurrentBlock("table_row");
00390 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00391 $this->tpl->parseCurrentBlock();
00392
00393 }
00394
00395
00396
00397 foreach ($this->data["buttons"] as $name => $value)
00398 {
00399 $this->tpl->setCurrentBlock("operation_btn");
00400 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00401 $this->tpl->setVariable("BTN_NAME",$name);
00402 $this->tpl->setVariable("BTN_VALUE",$value);
00403 $this->tpl->parseCurrentBlock();
00404 }
00405 }
00406
00412 function updateClassroom()
00413 {
00414 $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00415 $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00416 $this->object->setDocentId($_POST["Fobject"]["instructoruserid"]);
00417 $this->object->setStatus($_POST["Fobject"]["alwaysopen"]);
00418
00419
00420
00421 if (!$this->object->update())
00422 {
00423 $this->ilErr->raiseError($this->object->getErrorMsg(),$this->ilErr->MESSAGE);
00424 }
00425
00426
00427 ilUtil::sendInfo($this->getResultMsg(),true);
00428
00429 $this->ctrl->redirectByClass("ilobjilinccoursegui");
00430
00431 }
00432
00433 function &executeCommand()
00434 {
00435 $next_class = $this->ctrl->getNextClass($this);
00436 $cmd = $this->ctrl->getCmd();
00437
00438 switch($next_class)
00439 {
00440 default:
00441 $this->$cmd();
00442 break;
00443 }
00444
00445 return true;
00446 }
00447
00453 function cancelDeleteClassroom()
00454 {
00455 session_unregister("saved_post");
00456
00457 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
00458
00459 $this->ctrl->redirectByClass("ilobjilinccoursegui");
00460 }
00461
00465 function confirmedDeleteClassroom()
00466 {
00467 if (!$this->object->delete())
00468 {
00469 $msg = $this->object->getErrorMsg();
00470 }
00471 else
00472 {
00473 $msg = $this->lng->txt('icla_deleted');
00474 }
00475
00476
00477 ilUtil::sendInfo($msg,true);
00478
00479 $this->ctrl->redirectByClass("ilobjilinccoursegui");
00480 }
00481
00482 function getResultMsg()
00483 {
00484 return $this->object->result_msg;
00485 }
00486
00491 function cancel()
00492 {
00493 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
00494
00495 $this->ctrl->redirectByClass("ilobjilinccoursegui");
00496 }
00497 }
00498 ?>