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 {
00045 function ilObjiLincClassroomGUI($a_icla_id,$a_icrs_id)
00046 {
00047 global $ilCtrl,$lng,$ilias,$objDefinition,$tpl,$tree,$ilErr;
00048 $this->type = "icla";
00049 $this->id = $a_icla_id;
00050 $this->parent = $a_icrs_id;
00051 $this->ilias =& $ilias;
00052 $this->objDefinition =& $objDefinition;
00053 $this->tpl =& $tpl;
00054 $this->html = "";
00055 $this->ctrl =& $ilCtrl;
00056 $this->lng =& $lng;
00057 $this->tree =& $tree;
00058 $this->ilErr =& $ilErr;
00059
00060 $this->ctrl->saveParameter($this,'parent');
00061
00062 $this->formaction = array();
00063 $this->return_location = array();
00064 $this->target_frame = array();
00065 $this->tab_target_script = "adm_object.php";
00066 $this->actions = "";
00067 $this->sub_objects = "";
00068
00069
00070
00071
00072
00073
00074
00075
00076 if (false)
00077 {
00078 $this->prepareOutput();
00079 }
00080
00081 $this->assignObject();
00082 }
00083
00084 function assignObject()
00085 {
00086 $this->object = new ilObjiLincClassroom($this->id,$this->parent);
00087 }
00088
00089 function createObject()
00090 {
00091 global $rbacsystem;
00092
00093 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
00094
00095
00096 $data = array();
00097 $data["fields"] = array();
00098 $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
00099 $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
00100 $data["fields"]["homepage"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["homepage"],true);
00101 $data["fields"]["download"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["download"],true);
00102
00103 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.icla_edit.html","ilinc");
00104
00105
00106 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00107 $this->tpl->setVariable("TITLE", $data["fields"]["title"]);
00108 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("desc"));
00109 $this->tpl->setVariable("DESC", $data["fields"]["desc"]);
00110
00111
00112 $docentlist = $this->object->getDocentList();
00113
00114 $docent_options[0] = $this->lng->txt('please_choose');
00115
00116 foreach ($docentlist as $id => $data)
00117 {
00118 $docent_options[$id] = $data['fullname'];
00119 }
00120
00121 $sel_docents = ilUtil::formSelect("0","Fobject[instructoruserid]",$docent_options,false,true);
00122
00123 $this->tpl->setVariable("TXT_DOCENT", $this->lng->txt(ILINC_MEMBER_DOCENT));
00124 $this->tpl->setVariable("SEL_DOCENT", $sel_docents);
00125
00126
00127 $docent = 0; $student = 0;
00128
00129 if ($ilinc_status == ILINC_MEMBER_DOCENT)
00130 {
00131 $docent = 1;
00132 }
00133 elseif ($ilinc_status == ILINC_MEMBER_STUDENT)
00134 {
00135 $student = 1;
00136 }
00137
00138 $radio1 = ilUtil::formRadioButton(1,"Fobject[alwaysopen]","1");
00139 $radio2 = ilUtil::formRadioButton(0,"Fobject[alwaysopen]","0");
00140
00141 $this->tpl->setVariable("TXT_ACCESS", $this->lng->txt("access"));
00142 $this->tpl->setVariable("SEL_ACCESS", $radio1." ".$this->lng->txt("ilinc_classroom_open").$radio2." ".$this->lng->txt("ilinc_classroom_closed"));
00143
00144 $this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".
00145 $_GET["ref_id"]."&new_type=".$new_type));
00146 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
00147 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00148 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
00149 $this->tpl->setVariable("CMD_SUBMIT", "save");
00150 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00151 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00152 }
00153
00158 function saveObject()
00159 {
00160 global $rbacadmin;
00161
00162 $ilinc_course_id = ilObjiLincClassroom::_lookupiCourseId($this->parent);
00163
00164
00165
00166 $this->object->ilincAPI->addClass($ilinc_course_id,$_POST['Fobject']);
00167 $response = $this->object->ilincAPI->sendRequest('addClass');
00168
00169 if ($response->isError())
00170 {
00171 $this->ilErr->raiseError($response->getErrorMsg(),$this->ilErr->MESSAGE);
00172 }
00173
00174
00175
00176
00177 sendInfo($response->getResultMsg(),true);
00178
00179 ilUtil::redirect($this->getReturnLocation("save",$this->ctrl->getLinkTarget($this,"")));
00180 }
00181
00182 function joinObject()
00183 {
00184
00185 if (!$this->object->userExists($this->ilias->account))
00186 {
00187 $ilinc_user_id = $this->object->addUser($this->ilias->account);
00188 }
00189
00190
00191 if (!$this->object->isMember($this->ilias->account->getiLincID(),$this->ilinc_course_id))
00192 {
00193
00194 $this->object->registerUser($this->ilias->account,$this->object->ilinc_course_id,"True");
00195 }
00196
00197
00198
00199 $url = $this->object->joinClass($this->ilias->account,$this->object->ilinc_id);
00200 ilUtil::redirect(trim($url));
00201 }
00202
00203 function editClassroomObject()
00204 {
00205 $fields = array();
00206
00207 if ($_SESSION["error_post_vars"])
00208 {
00209
00210 $fields["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
00211 $fields["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
00212 }
00213 else
00214 {
00215 $fields["title"] = ilUtil::prepareFormOutput($this->object->getTitle());
00216 $fields["desc"] = ilUtil::stripSlashes($this->object->getDescription());
00217 }
00218
00219 $this->displayEditForm($fields);
00220 }
00221
00228 function displayEditForm($fields)
00229 {
00230
00231 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.icla_edit.html","ilinc");
00232
00233 foreach ($fields as $key => $val)
00234 {
00235 $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
00236 $this->tpl->setVariable(strtoupper($key), $val);
00237 $this->tpl->parseCurrentBlock();
00238 }
00239
00240
00241 $docentlist = $this->object->getDocentList();
00242
00243 $docent_options[0] = $this->lng->txt('please_choose');
00244
00245 foreach ($docentlist as $id => $data)
00246 {
00247 $docent_options[$id] = $data['fullname'];
00248 }
00249
00250 $sel_docents = ilUtil::formSelect($this->object->getDocentId(),"Fobject[instructoruserid]",$docent_options,false,true);
00251
00252 $this->tpl->setVariable("TXT_DOCENT", $this->lng->txt(ILINC_MEMBER_DOCENT));
00253 $this->tpl->setVariable("SEL_DOCENT", $sel_docents);
00254
00255
00256 $open = 0; $closed = 0;
00257
00258 if ($this->object->getStatus())
00259 {
00260 $open = 1;
00261 }
00262 else
00263 {
00264 $closed = 1;
00265 }
00266
00267 $radio1 = ilUtil::formRadioButton($open,"Fobject[alwaysopen]","1");
00268 $radio2 = ilUtil::formRadioButton($closed,"Fobject[alwaysopen]","0");
00269
00270 $this->tpl->setVariable("TXT_ACCESS", $this->lng->txt("access"));
00271 $this->tpl->setVariable("SEL_ACCESS", $radio1." ".$this->lng->txt("ilinc_classroom_open").$radio2." ".$this->lng->txt("ilinc_classroom_closed"));
00272
00273 $obj_str = "&class_id=".$this->object->id;
00274
00275 $this->tpl->setVariable("FORMACTION", $this->getFormAction("update",$this->ctrl->getFormAction($this).$obj_str));
00276
00277 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
00278 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
00279 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00280 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00281 $this->tpl->setVariable("CMD_SUBMIT", "updateClassroom");
00282 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00283
00284 }
00285
00291 function getTabs(&$tabs_gui)
00292 {
00293
00294
00295 }
00296
00304 function removeClassroomObject($a_error = false)
00305 {
00306 unset($this->data);
00307 $this->data["cols"] = array("type", "title", "last_change");
00308
00309 $this->data["data"][$_GET['class_id']] = array(
00310 "type" => $this->object->getType(),
00311 "title" => $this->object->getTitle()."#separator#".$this->object->getDescription()." ",
00312 "last_update" => "n/a"
00313 );
00314
00315 $this->data["buttons"] = array( "confirmedDeleteClassroom" => $this->lng->txt("confirm"),
00316 "cancelDeleteClassroom" => $this->lng->txt("cancel"));
00317
00318 $this->getTemplateFile("confirm");
00319
00320 if(!$a_error)
00321 {
00322 sendInfo($this->lng->txt("info_delete_sure"));
00323 }
00324
00325 $this->tpl->setVariable("FORMACTION", $this->getFormAction("delete",
00326 "adm_object.php?ref_id=".$_GET["ref_id"]."&class_id=".$_GET["class_id"]."&cmd=gateway"));
00327
00328
00329 foreach ($this->data["cols"] as $key)
00330 {
00331 $this->tpl->setCurrentBlock("table_header");
00332 $this->tpl->setVariable("TEXT",$this->lng->txt($key));
00333 $this->tpl->parseCurrentBlock();
00334 }
00335
00336
00337
00338 $counter = 0;
00339
00340 foreach ($this->data["data"] as $key => $value)
00341 {
00342
00343 foreach ($value as $key => $cell_data)
00344 {
00345 $this->tpl->setCurrentBlock("table_cell");
00346
00347
00348 if ($key == "type")
00349 {
00350 $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
00351 }
00352 elseif ($key == "title")
00353 {
00354 $name_field = explode("#separator#",$cell_data);
00355
00356 $this->tpl->setVariable("TEXT_CONTENT", "<b>".$name_field[0]."</b>");
00357
00358 $this->tpl->setCurrentBlock("subtitle");
00359 $this->tpl->setVariable("DESC", $name_field[1]);
00360 $this->tpl->parseCurrentBlock();
00361 $this->tpl->setCurrentBlock("table_cell");
00362 }
00363 else
00364 {
00365 $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
00366 }
00367
00368 $this->tpl->parseCurrentBlock();
00369 }
00370
00371 $this->tpl->setCurrentBlock("table_row");
00372 $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00373 $this->tpl->parseCurrentBlock();
00374
00375 }
00376
00377
00378
00379 foreach ($this->data["buttons"] as $name => $value)
00380 {
00381 $this->tpl->setCurrentBlock("operation_btn");
00382 $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00383 $this->tpl->setVariable("BTN_NAME",$name);
00384 $this->tpl->setVariable("BTN_VALUE",$value);
00385 $this->tpl->parseCurrentBlock();
00386 }
00387 }
00388
00394 function updateClassroomObject()
00395 {
00396 $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00397 $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00398 $this->object->setDocentId($_POST["Fobject"]["instructoruserid"]);
00399 $this->object->setStatus($_POST["Fobject"]["alwaysopen"]);
00400
00401
00402 if (!$this->object->update())
00403 {
00404 $this->ilErr->raiseError($this->object->getErrorMsg(),$this->ilErr->MESSAGE);
00405 }
00406
00407 sendInfo($this->lng->txt("msg_obj_modified"),true);
00408
00409 ilUtil::redirect($this->getReturnLocation("update",$this->ctrl->getLinkTarget($this)));
00410 }
00411 }
00412 ?>