• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

ilinc/classes/class.ilObjiLincClassroomGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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                 //$this->ctrl->saveParameter($this,'parent');
00063                 
00064                 $this->formaction = array();
00065                 $this->return_location = array();
00066                 $this->target_frame = array();
00067                 //$this->tab_target_script = "adm_object.php";
00068                 $this->actions = "";
00069                 $this->sub_objects = "";
00070 
00071                 //prepare output
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                 // fill in saved values in case of error
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                 $data["fields"]["homepage"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["homepage"],true);
00097                 $data["fields"]["download"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["download"],true);
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                 // get all docents of course
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                 /*$docent = 0; $student = 0;
00122 
00123                 if ($ilinc_status == ILINC_MEMBER_DOCENT)
00124                 {
00125                         $docent = 1;
00126                 }
00127                 elseif ($ilinc_status == ILINC_MEMBER_STUDENT)
00128                 {
00129                         $student = 1;
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                 $this->tpl->setVariable("FORMACTION", $this->getFormAction("save",$this->ctrl->getFormAction($this)."&new_type=".$new_type));
00139 
00140                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
00141                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00142                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
00143                 $this->tpl->setVariable("CMD_SUBMIT", "save");
00144                 $this->tpl->setVariable("TARGET", $this->getTargetFrame("save"));
00145                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00146         }
00147 
00152         function save()
00153         {
00154                 $ilinc_course_id = ilObjiLincClassroom::_lookupiCourseId($this->parent);
00155 
00156                 $this->object->ilincAPI->addClass($ilinc_course_id,$_POST['Fobject']);
00157                 $response = $this->object->ilincAPI->sendRequest('addClass');
00158                 
00159                 if ($response->isError())
00160                 {
00161                         $this->ilErr->raiseError($response->getErrorMsg(),$this->ilErr->MESSAGE);
00162                 }
00163 
00164                 //$iClaObj->saveID($response->getFirstID(),$icrs_id);
00165 
00166                 // always send a message
00167                 sendInfo($response->getResultMsg(),true);
00168                 
00169                 $this->ctrl->redirectByClass("ilobjilinccoursegui");
00170         }
00171         
00172         function joinClassroom()
00173         {
00174                 // join class
00175                 $url = $this->object->joinClass($this->ilias->account,$_GET['class_id']);
00176 
00177                 if (!$url)
00178                 {
00179                         $this->ilias->raiseError($this->object->getErrorMsg(),$this->ilias->error_obj->FATAL);
00180                 }
00181 
00182                 ilUtil::redirect(trim($url));
00183         }
00184         
00185         function editClassroom()
00186         {
00187                 $fields = array();
00188 
00189                 if ($_SESSION["error_post_vars"])
00190                 {
00191                         // fill in saved values in case of error
00192                         $fields["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
00193                         $fields["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
00194                 }
00195                 else
00196                 {
00197                         $fields["title"] = ilUtil::prepareFormOutput($this->object->getTitle());
00198                         $fields["desc"] = ilUtil::stripSlashes($this->object->getDescription());
00199                 }
00200 
00201                 $this->displayEditForm($fields);
00202         }
00203         
00210         function displayEditForm($fields)
00211         {
00212                 //$this->getTemplateFile("edit");
00213                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.icla_edit.html","ilinc");
00214 
00215                 foreach ($fields as $key => $val)
00216                 {
00217                         $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
00218                         $this->tpl->setVariable(strtoupper($key), $val);
00219                         $this->tpl->parseCurrentBlock();
00220                 }
00221 
00222                 // get all docents of course
00223                 $docentlist = $this->object->getDocentList();
00224                 
00225                 $docent_options[0] = $this->lng->txt('please_choose');
00226 
00227                 foreach ($docentlist as $id => $data)
00228                 {
00229                         $docent_options[$id] = $data['fullname'];
00230                 }
00231                 
00232                 $sel_docents = ilUtil::formSelect($this->object->getDocentId(),"Fobject[instructoruserid]",$docent_options,false,true);
00233                 
00234                 $this->tpl->setVariable("TXT_DOCENT", $this->lng->txt(ILINC_MEMBER_DOCENT));
00235                 $this->tpl->setVariable("SEL_DOCENT", $sel_docents);
00236                 
00237                 
00238                 $open = 0; $closed = 0;
00239 
00240                 if ($this->object->getStatus())
00241                 {
00242                         $open = 1;
00243                 }
00244                 else
00245                 {
00246                         $closed = 1;
00247                 }
00248                 
00249                 $radio1 = ilUtil::formRadioButton($open,"Fobject[alwaysopen]","1");
00250                 $radio2 = ilUtil::formRadioButton($closed,"Fobject[alwaysopen]","0");
00251                 
00252                 $this->tpl->setVariable("TXT_ACCESS", $this->lng->txt("access"));
00253                 $this->tpl->setVariable("SEL_ACCESS", $radio1." ".$this->lng->txt("ilinc_classroom_open").$radio2." ".$this->lng->txt("ilinc_classroom_closed"));
00254 
00255                 $obj_str = "&class_id=".$this->object->id;
00256                 $this->tpl->setVariable("FORMACTION", $this->getFormAction("update",$this->ctrl->getFormAction($this).$obj_str));
00257 
00258                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
00259                 $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
00260                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00261                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00262                 $this->tpl->setVariable("CMD_SUBMIT", "updateClassroom");
00263                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00264 
00265         }
00266         
00272         function getTabs(&$tabs_gui)
00273         {
00274                 // tabs are defined manually here. The autogeneration via objects.xml will be deprecated in future
00275                 // for usage examples see ilObjGroupGUI or ilObjSystemFolderGUI
00276         }
00277         
00285         function removeClassroom($a_error = false)
00286         {
00287                 unset($this->data);
00288                 $this->data["cols"] = array("type", "title", "last_change");
00289 
00290                 $this->data["data"][$_GET['class_id']] = array(
00291                                                                                         "type"        => $this->object->getType(),
00292                                                                                         "title"       => $this->object->getTitle()."#separator#".$this->object->getDescription()." ",   // workaround for empty desc
00293                                                                                         "last_update" => "n/a"
00294                                                                                 );
00295 
00296                 $this->data["buttons"] = array( "confirmedDeleteClassroom"  => $this->lng->txt("confirm"),
00297                                                                   "cancelDeleteClassroom"  => $this->lng->txt("cancel"));
00298 
00299                 $this->getTemplateFile("confirm");
00300 
00301                 if(!$a_error)
00302                 {
00303                         sendInfo($this->lng->txt("info_delete_sure"));
00304                 }
00305 
00306                 $obj_str = "&class_id=".$this->object->id;
00307                 $this->tpl->setVariable("FORMACTION", $this->getFormAction("delete",$this->ctrl->getFormAction($this).$obj_str));
00308 
00309                 // BEGIN TABLE HEADER
00310                 foreach ($this->data["cols"] as $key)
00311                 {
00312                         $this->tpl->setCurrentBlock("table_header");
00313                         $this->tpl->setVariable("TEXT",$this->lng->txt($key));
00314                         $this->tpl->parseCurrentBlock();
00315                 }
00316                 // END TABLE HEADER
00317 
00318                 // BEGIN TABLE DATA
00319                 $counter = 0;
00320 
00321                 foreach ($this->data["data"] as $key => $value)
00322                 {
00323                         // BEGIN TABLE CELL
00324                         foreach ($value as $key => $cell_data)
00325                         {
00326                                 $this->tpl->setCurrentBlock("table_cell");
00327 
00328                                 // CREATE TEXT STRING
00329                                 if ($key == "type")
00330                                 {
00331                                         $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($cell_data,$this->tpl->tplPath));
00332                                 }
00333                                 elseif ($key == "title")
00334                                 {
00335                                         $name_field = explode("#separator#",$cell_data);
00336 
00337                                         $this->tpl->setVariable("TEXT_CONTENT", "<b>".$name_field[0]."</b>");
00338                                                 
00339                                         $this->tpl->setCurrentBlock("subtitle");
00340                                         $this->tpl->setVariable("DESC", $name_field[1]);
00341                                         $this->tpl->parseCurrentBlock();
00342                                         $this->tpl->setCurrentBlock("table_cell");
00343                                 }
00344                                 else
00345                                 {
00346                                         $this->tpl->setVariable("TEXT_CONTENT",$cell_data);
00347                                 }
00348 
00349                                 $this->tpl->parseCurrentBlock();
00350                         }
00351 
00352                         $this->tpl->setCurrentBlock("table_row");
00353                         $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00354                         $this->tpl->parseCurrentBlock();
00355                         // END TABLE CELL
00356                 }
00357                 // END TABLE DATA
00358 
00359                 // BEGIN OPERATION_BTN
00360                 foreach ($this->data["buttons"] as $name => $value)
00361                 {
00362                         $this->tpl->setCurrentBlock("operation_btn");
00363                         $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
00364                         $this->tpl->setVariable("BTN_NAME",$name);
00365                         $this->tpl->setVariable("BTN_VALUE",$value);
00366                         $this->tpl->parseCurrentBlock();
00367                 }
00368         }
00369         
00375         function updateClassroom()
00376         {
00377                 $this->object->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
00378                 $this->object->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
00379                 $this->object->setDocentId($_POST["Fobject"]["instructoruserid"]);
00380                 $this->object->setStatus($_POST["Fobject"]["alwaysopen"]);
00381 
00382                 if (!$this->object->update())
00383                 {
00384                         $this->ilErr->raiseError($this->object->getErrorMsg(),$this->ilErr->MESSAGE);
00385                 }
00386                 
00387                 //sendInfo($this->lng->txt("msg_icla_updated"),true);
00388                 sendInfo($this->getResultMsg(),true);
00389                 
00390                 $this->ctrl->redirectByClass("ilobjilinccoursegui");
00391                 //ilUtil::redirect($this->getReturnLocation("update",$this->ctrl->getLinkTarget($this)));
00392         }
00393         
00394         function &executeCommand()
00395         {
00396                 $next_class = $this->ctrl->getNextClass($this);
00397                 $cmd = $this->ctrl->getCmd();
00398 
00399                 switch($next_class)
00400                 {
00401                         default:
00402                                 $this->$cmd();
00403                                 break;
00404                 }
00405 
00406                 return true;
00407         }
00408         
00414         function cancelDeleteClassroom()
00415         {
00416                 session_unregister("saved_post");
00417                 
00418                 sendInfo($this->lng->txt("msg_cancel"),true);
00419 
00420                 $this->ctrl->redirectByClass("ilobjilinccoursegui");
00421         }
00422         
00426         function confirmedDeleteClassroom()
00427         {
00428                 if (!$this->object->delete())
00429                 {
00430                         $msg = $this->object->getErrorMsg();
00431                 }
00432                 else
00433                 {
00434                         $msg = $this->lng->txt('icla_deleted');
00435                 }
00436                 
00437                 // Feedback
00438                 sendInfo($msg,true);
00439                 
00440                 $this->ctrl->redirectByClass("ilobjilinccoursegui");
00441         }
00442         
00443         function getResultMsg()
00444         {
00445                 return $this->object->result_msg;
00446         }
00447         
00453         function cancel()
00454         {
00455                 session_unregister("saved_post");
00456 
00457                 sendInfo($this->lng->txt("msg_cancel"),true);
00458 
00459                 $this->ctrl->returnToParent($this);
00460 
00461         }
00462 } // END class.ilObjiLincClassroomGUI
00463 ?>

Generated on Fri Dec 13 2013 11:57:58 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1