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