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

ilinc/classes/class.ilObjiLincClassroom.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 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 
00033 require_once ('./classes/class.ilObject.php');
00034 require_once ('class.ilnetucateXMLAPI.php');
00035 
00036 class ilObjiLincClassroom extends ilObject
00037 {
00044         function ilObjiLincClassroom($a_icla_id,$a_icrs_id)
00045         {
00046                 global $ilErr,$ilias,$lng;
00047                 
00048                 $this->type = "icla";
00049                 $this->id = $a_icla_id;         
00050                 $this->parent = $a_icrs_id;
00051                 $this->ilincAPI = new ilnetucateXMLAPI();
00052 
00053                 $this->ilErr =& $ilErr;
00054                 $this->ilias =& $ilias;
00055                 $this->lng =& $lng;
00056 
00057                 $this->max_title = MAXLENGTH_OBJ_TITLE;
00058                 $this->max_desc = MAXLENGTH_OBJ_DESC;
00059                 $this->add_dots = true;
00060 
00061                 $this->referenced = false;
00062                 $this->call_by_reference = false;
00063 
00064                 if (!empty($this->id))
00065                 {
00066                         $this->read();
00067                 }
00068                 
00069                 return $this;
00070         }
00071         
00072         function _lookupiCourseId($a_ref_id)
00073         {
00074                 global $ilDB;
00075 
00076                 $q = "SELECT course_id FROM ilinc_data ".
00077                          "LEFT JOIN object_reference ON object_reference.obj_id=ilinc_data.obj_id ".
00078                          "WHERE object_reference.ref_id = ".$ilDB->quote($a_ref_id);
00079                 $obj_set = $ilDB->query($q);
00080                 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00081 
00082                 return $obj_rec["course_id"];
00083         }
00084         
00089         function read()
00090         {
00091                 $this->ilincAPI->findClass($this->id);
00092                 $response = $this->ilincAPI->sendRequest();
00093 
00094                 if ($response->isError())
00095                 {
00096                         if (!$response->getErrorMsg())
00097                         {
00098                                 $this->error_msg = "err_read_class";
00099                         }
00100                         else
00101                         {
00102                                 $this->error_msg = $response->getErrorMsg();
00103                         }
00104                         
00105                         return false;
00106                 }
00107                 
00108                 //var_dump($response->data['classes']);
00109                 
00110                 $this->setTitle($response->data['classes'][$this->id]['name']);
00111                 $this->setDescription($response->data['classes'][$this->id]['description']);
00112                 $this->setDocentId($response->data['classes'][$this->id]['instructoruserid']);
00113                 $this->setStatus($response->data['classes'][$this->id]['alwaysopen']);
00114         }
00115         
00116         function joinClass(&$a_user_obj,$a_ilinc_class_id)
00117         {
00118                 
00119                 include_once ('class.ilObjiLincUser.php');
00120                 $ilinc_user = new ilObjiLincUser($a_user_obj);
00121                 
00122                 $this->ilincAPI->joinClass($ilinc_user,$a_ilinc_class_id);
00123                 $response = $this->ilincAPI->sendRequest("joinClass");
00124                 
00125                 if ($response->isError())
00126                 {
00127                         if (!$response->getErrorMsg())
00128                         {
00129                                 $this->error_msg = "err_join_classroom";
00130                         }
00131                         else
00132                         {
00133                                 $this->error_msg = $response->getErrorMsg();
00134                         }
00135                         
00136                         return false;
00137                 }
00138                 
00139                 // return URL to join class room
00140                 return trim($response->data['url']['cdata']);
00141         }
00142         
00143         // not used yet
00144         function findUser(&$a_user_obj)
00145         {
00146                 $this->ilincAPI->findUser($a_user_obj);
00147                 $response = $this->ilincAPI->sendRequest();
00148                 
00149                 var_dump($response->data);
00150                 exit;
00151         }
00152 
00159         function update($a_data = "")
00160         {
00161                 $data = array(
00162                                                 "name" => $this->getTitle(),
00163                                                 "description" => $this->getDescription(), 
00164                                                 "instructoruserid" => $this->getDocentId(), 
00165                                                 "alwaysopen" => $this->getStatus()
00166                                         );
00167                                 
00168                 if (!is_array($a_data))
00169                 {
00170                         $a_data = array();
00171                 }
00172                 
00173                 $result = array_merge($data,$a_data);
00174 
00175                 $this->ilincAPI->editClass($this->id,$result);
00176 
00177                 $response = $this->ilincAPI->sendRequest("editClass");
00178 
00179                 if ($response->isError())
00180                 {
00181                         if (!$response->getErrorMsg())
00182                         {
00183                                 $this->error_msg = "err_edit_classroom";
00184                         }
00185                         else
00186                         {
00187                                 $this->error_msg = $response->getErrorMsg();
00188                         }
00189                         
00190                         return false;
00191                 }
00192                 
00193                 $this->result_msg = $response->getResultMsg();
00194 
00195                 return true;
00196         }
00197         
00204         function delete()
00205         {               
00206                 $this->ilincAPI->removeClass($this->id);
00207                 $response = $this->ilincAPI->sendRequest();
00208 
00209                 if ($response->isError())
00210                 {
00211                         if (!$response->getErrorMsg())
00212                         {
00213                                 $this->error_msg = "err_delete_classroom";
00214                         }
00215                         else
00216                         {
00217                                 $this->error_msg = $response->getErrorMsg();
00218                         }
00219                         
00220                         return false;
00221                 }
00222                 
00223                 return true;
00224         }
00225         
00226         // returns array of docents of course
00227         function getDocentList()
00228         {
00229                 $ilinc_crs_id = ilObjiLincClassroom::_lookupiCourseId($this->parent);
00230                 
00231                 $this->ilincAPI->findRegisteredUsersByRole($ilinc_crs_id,true);
00232                 $response = $this->ilincAPI->sendRequest();
00233                         
00234                 if (is_array($response->data['users']))
00235                 {
00236                                 return $response->data['users'];
00237                 }
00238                 
00239                 return array();
00240         }
00241         
00242         function _getDocent($a_ilinc_user_id)
00243         {
00244                 global $ilDB, $lng;
00245                 
00246                 $fullname = false;
00247                 
00248                 $q = "SELECT title,firstname,lastname FROM usr_data WHERE ilinc_id = ".$ilDB->quote($a_ilinc_user_id)." LIMIT 1";
00249                 $r = $ilDB->query($q);
00250                 
00251                 while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
00252                 {
00253                         $fullname = ilObjiLincClassroom::_setFullname($row->title,$row->firstname,$row->lastname);
00254                 }
00255                 
00256                 return $fullname;
00257         }
00258         
00259         function _setFullname($a_title = "",$a_firstname = "",$a_lastname = "")
00260         {
00261                 $fullname = "";
00262 
00263                 if ($a_title)
00264                 {
00265                         $fullname = $a_title." ";
00266                 }
00267 
00268                 if ($a_firstname)
00269                 {
00270                         $fullname .= $a_firstname." ";
00271                 }
00272 
00273                 if ($a_lastname)
00274                 {
00275                         return $fullname.$a_lastname;
00276                 }
00277         }
00278         
00279         function setDocentId($a_ilinc_user_id)
00280         {
00281                 $this->docent_id = $a_ilinc_user_id;
00282         }
00283         
00284         function getDocentName()
00285         {
00286                 if (!$this->docent_name)
00287                 {
00288                         $this->docent_name = $this->_getDocent($this->docent_id);
00289                 }
00290                 
00291                 return $this->docent_name;
00292         }
00293         
00294         function getDocentId()
00295         {
00296                 return $this->docent_id;
00297         }
00298         
00299         function setStatus($a_status)
00300         {
00301                 if ($a_status == "Wahr" or $a_status == "1" or $a_status == true)
00302                 {
00303                         $this->status = "1";
00304                 }
00305                 else
00306                 {
00307                         $this->status = "0";
00308                 }
00309         }
00310         
00311         function getStatus()
00312         {
00313                 return $this->status;
00314         }
00315         
00316         function getErrorMsg()
00317         {
00318                 $err_msg = $this->error_msg;
00319                 $this->error_msg = "";
00320 
00321                 return $err_msg;
00322         }
00323 } // END class.ilObjiLincClassroom
00324 ?>

Generated on Fri Dec 13 2013 17:56:49 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1