ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilObjiLincClassroom.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2005 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
33require_once ('./Services/Object/classes/class.ilObject.php');
34require_once ('./Modules/ILinc/classes/class.ilnetucateXMLAPI.php');
35
37{
44 function ilObjiLincClassroom($a_icla_id,$a_icrs_id)
45 {
46 global $ilErr,$ilias,$lng;
47
48 $this->type = "icla";
49 $this->id = $a_icla_id;
50 $this->parent = $a_icrs_id;
51 $this->ilincAPI = new ilnetucateXMLAPI();
52
53 $this->ilErr =& $ilErr;
54 $this->ilias =& $ilias;
55 $this->lng =& $lng;
56
57 $this->max_title = MAXLENGTH_OBJ_TITLE;
58 $this->max_desc = MAXLENGTH_OBJ_DESC;
59 $this->add_dots = true;
60
61 $this->referenced = false;
62 $this->call_by_reference = false;
63
64 if (!empty($this->id))
65 {
66 $this->read();
67 }
68
69 return $this;
70 }
71
72 function _lookupiCourseId($a_ref_id)
73 {
74 global $ilDB;
75
76 $res = $ilDB->queryf('
77 SELECT course_id FROM ilinc_data
78 LEFT JOIN object_reference ON object_reference.obj_id = ilinc_data.obj_id
79 WHERE object_reference.ref_id = %s',
80 array('integer'), array($a_ref_id));
81
82 $obj_rec = $ilDB->fetchAssoc($res);
83
84 return $obj_rec["course_id"];
85 }
86
91 function read()
92 {
93 $this->ilincAPI->findClass($this->id);
94 $response = $this->ilincAPI->sendRequest();
95
96 if ($response->isError())
97 {
98 if (!$response->getErrorMsg())
99 {
100 $this->error_msg = "err_read_class";
101 }
102 else
103 {
104 $this->error_msg = $response->getErrorMsg();
105 }
106
107 return false;
108 }
109
110 //var_dump($response->data['classes']);
111
112 $this->setTitle($response->data['classes'][$this->id]['name']);
113 $this->setDescription($response->data['classes'][$this->id]['description']);
114 $this->setDocentId($response->data['classes'][$this->id]['instructoruserid']);
115 $this->setStatus($response->data['classes'][$this->id]['alwaysopen']);
116 }
117
118 function joinClass(&$a_user_obj,$a_ilinc_class_id)
119 {
120
121 include_once ('./Modules/ILinc/classes/class.ilObjiLincUser.php');
122 $ilinc_user = new ilObjiLincUser($a_user_obj);
123
124 $this->ilincAPI->joinClass($ilinc_user,$a_ilinc_class_id);
125 $response = $this->ilincAPI->sendRequest("joinClass");
126
127 if ($response->isError())
128 {
129 if (!$response->getErrorMsg())
130 {
131 $this->error_msg = "err_join_classroom";
132 }
133 else
134 {
135 $this->error_msg = $response->getErrorMsg();
136 }
137
138 return false;
139 }
140
141 // return URL to join class room
142 return trim($response->data['url']['cdata']);
143 }
144
145 // not used yet
146 function findUser(&$a_user_obj)
147 {
148 $this->ilincAPI->findUser($a_user_obj);
149 $response = $this->ilincAPI->sendRequest();
150
151 var_dump($response->data);
152 exit;
153 }
154
161 function update($a_data = "")
162 {
163 $data = array(
164 "name" => $this->getTitle(),
165 "description" => $this->getDescription(),
166 "instructoruserid" => $this->getDocentId(),
167 "alwaysopen" => $this->getStatus()
168 );
169
170 if (!is_array($a_data))
171 {
172 $a_data = array();
173 }
174
175 $result = array_merge($data,$a_data);
176
177 $this->ilincAPI->editClass($this->id,$result);
178
179 $response = $this->ilincAPI->sendRequest("editClass");
180
181 if ($response->isError())
182 {
183 if (!$response->getErrorMsg())
184 {
185 $this->error_msg = "err_edit_classroom";
186 }
187 else
188 {
189 $this->error_msg = $response->getErrorMsg();
190 }
191
192 return false;
193 }
194
195 $this->result_msg = $response->getResultMsg();
196
197 return true;
198 }
199
206 function delete()
207 {
208 $this->ilincAPI->removeClass($this->id);
209 $response = $this->ilincAPI->sendRequest();
210
211 if ($response->isError())
212 {
213 if (!$response->getErrorMsg())
214 {
215 $this->error_msg = "err_delete_classroom";
216 }
217 else
218 {
219 $this->error_msg = $response->getErrorMsg();
220 }
221
222 return false;
223 }
224
225 return true;
226 }
227
228 // returns array of docents of course
229 function getDocentList()
230 {
231 $ilinc_crs_id = ilObjiLincClassroom::_lookupiCourseId($this->parent);
232
233 $this->ilincAPI->findRegisteredUsersByRole($ilinc_crs_id,true);
234 $response = $this->ilincAPI->sendRequest();
235
236 if (is_array($response->data['users']))
237 {
238 return $response->data['users'];
239 }
240
241 return array();
242 }
243
244 function _getDocent($a_ilinc_user_id)
245 {
246 global $ilDB, $lng;
247
248 $fullname = false;
249
250 $ilDB->setLimit(1);
251 $r = $ilDB->queryf('
252 SELECT title, firstname, lastname FROM usr_data
253 WHERE ilinc_id = %s',
254 array('integer'), array($a_ilinc_user_id));
255
256 while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
257 {
258 $fullname = ilObjiLincClassroom::_setFullname($row->title,$row->firstname,$row->lastname);
259 }
260
261 return $fullname;
262 }
263
264 function _setFullname($a_title = "",$a_firstname = "",$a_lastname = "")
265 {
266 $fullname = "";
267
268 if ($a_title)
269 {
270 $fullname = $a_title." ";
271 }
272
273 if ($a_firstname)
274 {
275 $fullname .= $a_firstname." ";
276 }
277
278 if ($a_lastname)
279 {
280 return $fullname.$a_lastname;
281 }
282 }
283
284 function setDocentId($a_ilinc_user_id)
285 {
286 $this->docent_id = $a_ilinc_user_id;
287 }
288
289 function getDocentName()
290 {
291 if (!$this->docent_name)
292 {
293 $this->docent_name = $this->_getDocent($this->docent_id);
294 }
295
296 return $this->docent_name;
297 }
298
299 function getDocentId()
300 {
301 return $this->docent_id;
302 }
303
304 function setStatus($a_status)
305 {
306 if ($a_status == "Wahr" or $a_status == "1" or $a_status == true)
307 {
308 $this->status = "1";
309 }
310 else
311 {
312 $this->status = "0";
313 }
314 }
315
316 function getStatus()
317 {
318 return $this->status;
319 }
320
321 function getErrorMsg()
322 {
323 $err_msg = $this->error_msg;
324 $this->error_msg = "";
325
326 return $err_msg;
327 }
328} // END class.ilObjiLincClassroom
329?>
$result
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
Class ilObject Basic functions for all objects.
setTitle($a_title)
set object title
setDescription($a_desc)
set object description
getDescription()
get object description
getTitle()
get object title @access public
Class ilObjiLincClassroom.
_setFullname($a_title="", $a_firstname="", $a_lastname="")
ilObjiLincClassroom($a_icla_id, $a_icrs_id)
Constructor @access public.
update($a_data="")
update object data
joinClass(&$a_user_obj, $a_ilinc_class_id)
Class ilObjiLincUser iLinc related user settings.
API to communicate with a the CMSAPI of centra (c) Sascha Hofmann, 2004.
exit
Definition: login.php:54
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB