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