00001 <?php
00002
00003 require_once "class.ilnetucateResponse.php";
00004 require_once "./classes/class.ilXmlWriter.php";
00005
00015 class ilnetucateXMLAPI extends ilXmlWriter
00016 {
00021 function ilnetucateXMLAPI()
00022 {
00023 global $ilias;
00024
00025 parent::ilXmlWriter();
00026
00027 $this->ilias =& $ilias;
00028
00029 $this->login = $this->ilias->ini->readVariable("iLinc","login");
00030 $this->passwd = $this->ilias->ini->readVariable("iLinc","passwd");
00031 $this->customer_id = $this->ilias->ini->readVariable("iLinc","customer_id");
00032 $this->server_addr = $this->ilias->ini->readVariable("iLinc","server_addr");
00033 $this->server_port = $this->ilias->ini->readVariable("iLinc","server_port");
00034
00035 }
00036
00037 function xmlFormatData($a_data)
00038 {
00039 return $a_data;
00040 }
00041
00042 function setServerAddr($a_server_addr)
00043 {
00044 $this->server_addr = $a_server_addr;
00045 }
00046
00047 function getServerAddr()
00048 {
00049 return $this->server_addr;
00050 }
00051
00052 function getServerPort()
00053 {
00054 return $this->server_port;
00055 }
00056
00057 function getCustomerID()
00058 {
00059 return $this->customer_id;
00060 }
00061
00062 function setRequest($a_data)
00063 {
00064 $this->request = $a_data;
00065 }
00066
00067
00068
00069 function sendRequest($a_request = '')
00070 {
00071 $this->request = $this->xmlDumpMem();
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 $sock = fsockopen($this->getServerAddr(), $this->getServerPort(), $errno, $errstr, 30);
00088 if (!$sock) die("$errstr ($errno)\n");
00089
00090 fputs($sock, "POST /campus/XMLAPI/netucateXMLAPI.asp HTTP/1.0\r\n");
00091 fputs($sock, "Host: ".$this->getServerAddr()."\r\n");
00092 fputs($sock, "Content-type: text/xml\r\n");
00093 fputs($sock, "Content-length: " . strlen($this->request) . "\r\n");
00094 fputs($sock, "Accept: */*\r\n");
00095 fputs($sock, "\r\n");
00096 fputs($sock, $this->request."\r\n");
00097 fputs($sock, "\r\n");
00098
00099 $headers = "";
00100
00101 while ($str = trim(fgets($sock, 4096)))
00102 {
00103 $headers .= "$str\n";
00104 }
00105
00106 $response = "";
00107
00108 while (!feof($sock))
00109 {
00110 $response .= fgets($sock, 4096);
00111 }
00112
00113 fclose($sock);
00114
00115
00116
00117 $response_obj = new ilnetucateResponse($response);
00118
00119
00120
00121
00122
00123
00124 return $response_obj;
00125 }
00126
00127 function addUser(&$a_user_obj)
00128 {
00129 $this->xmlHeader();
00130
00131 $this->xmlStartTag('netucate.API.Request');
00132
00133 $attr = array();
00134 $attr['user'] = $this->login;
00135 $attr['password'] = $this->passwd;
00136 $attr['customerid'] = $this->customer_id;
00137 $attr['id'] = "";
00138 $attr['command'] = "Add";
00139 $attr['object'] = "User";
00140 $this->xmlStartTag('netucate.Command',$attr);
00141 $this->xmlEndTag('netucate.Command');
00142
00143 $attr = array();
00144 $attr['loginname'] = $a_user_obj->getLogin();
00145 $attr['fullname'] = $a_user_obj->getFullname();
00146 $attr['password'] = $a_user_obj->getPasswd();
00147 $this->xmlStartTag('netucate.User',$attr);
00148 $this->xmlEndTag('netucate.User');
00149
00150 $this->xmlEndTag('netucate.API.Request');
00151 }
00152
00153 function registerUser($a_ilinc_user_id,$a_ilinc_course_id,$a_instructor = "False")
00154 {
00155 $this->xmlHeader();
00156
00157 $this->xmlStartTag('netucate.API.Request');
00158
00159 $attr = array();
00160 $attr['user'] = $this->login;
00161 $attr['password'] = $this->passwd;
00162 $attr['customerid'] = $this->customer_id;
00163 $attr['id'] = "";
00164 $attr['command'] = "Register";
00165 $attr['object'] = "User";
00166 $this->xmlStartTag('netucate.Command',$attr);
00167 $this->xmlEndTag('netucate.Command');
00168
00169 $attr = array();
00170 $attr['courseid'] = $a_ilinc_course_id;
00171 $this->xmlStartTag('netucate.Course',$attr);
00172
00173 $this->xmlStartTag('netucate.User.List');
00174
00175 $attr = array();
00176 $attr['userid'] = $a_ilinc_user_id;
00177 $attr['instructorflag'] =$a_instructor;
00178 $this->xmlStartTag('netucate.User',$attr);
00179 $this->xmlEndTag('netucate.User');
00180
00181 $this->xmlEndTag('netucate.User.List');
00182
00183 $this->xmlEndTag('netucate.Course');
00184
00185 $this->xmlEndTag('netucate.API.Request');
00186 }
00187
00188 function unregisterUser(&$a_user_obj)
00189 {
00190 $this->xmlHeader();
00191
00192 $this->xmlStartTag('netucate.API.Request');
00193
00194 $attr = array();
00195 $attr['user'] = $this->login;
00196 $attr['password'] = $this->passwd;
00197 $attr['customerid'] = $this->customer_id;
00198 $attr['id'] = "";
00199 $attr['command'] = "UnRegister";
00200 $attr['object'] = "User";
00201 $this->xmlStartTag('netucate.Command',$attr);
00202 $this->xmlEndTag('netucate.Command');
00203
00204 $attr = array();
00205 $attr['courseid'] = "2191";
00206 $this->xmlStartTag('netucate.Course',$attr);
00207
00208 $this->xmlStartTag('netucate.User.List');
00209
00210 $attr = array();
00211 $attr['userid'] = "2191";
00212 $attr['instructorflag'] = "True";
00213 $this->xmlStartTag('netucate.User',$attr);
00214 $this->xmlEndTag('netucate.User');
00215
00216 $attr = array();
00217 $attr['userid'] = "2192";
00218 $attr['instructorflag'] = "False";
00219 $this->xmlStartTag('netucate.User',$attr);
00220 $this->xmlEndTag('netucate.User');
00221
00222 $this->xmlEndTag('netucate.User.List');
00223
00224 $this->xmlEndTag('netucate.Course');
00225
00226 $this->xmlEndTag('netucate.API.Request');
00227 }
00228
00229 function findUser(&$a_user_obj)
00230 {
00231 $this->xmlHeader();
00232
00233 $this->xmlStartTag('netucate.API.Request');
00234
00235 $attr = array();
00236 $attr['user'] = $this->login;
00237 $attr['password'] = $this->passwd;
00238 $attr['customerid'] = $this->customer_id;
00239 $attr['id'] = "";
00240 $attr['command'] = "Find";
00241 $attr['object'] = "User";
00242 $this->xmlStartTag('netucate.Command',$attr);
00243 $this->xmlEndTag('netucate.Command');
00244
00245 $attr = array();
00246 $attr['userid'] = "2191";
00247 $attr['loginname'] = "ffuss";
00248 $attr['fullname'] = "Fred Fuss";
00249 $attr['lotnumber'] = "1";
00250 $this->xmlStartTag('netucate.User',$attr);
00251 $this->xmlEndTag('netucate.User');
00252
00253 $this->xmlEndTag('netucate.API.Request');
00254 }
00255
00256 function removeUser(&$a_user_obj)
00257 {
00258 $this->xmlHeader();
00259
00260 $this->xmlStartTag('netucate.API.Request');
00261
00262 $attr = array();
00263 $attr['user'] = $this->login;
00264 $attr['password'] = $this->passwd;
00265 $attr['customerid'] = $this->customer_id;
00266 $attr['id'] = "";
00267 $attr['command'] = "Remove";
00268 $attr['object'] = "User";
00269 $this->xmlStartTag('netucate.Command',$attr);
00270 $this->xmlEndTag('netucate.Command');
00271
00272 $this->xmlStartTag('netucate.User.List');
00273
00274 $attr = array();
00275 $attr['userid'] = "2191";
00276 $attr['instructorflag'] = "True";
00277 $this->xmlStartTag('netucate.User',$attr);
00278 $this->xmlEndTag('netucate.User');
00279
00280 $attr = array();
00281 $attr['userid'] = "2192";
00282 $attr['loginname'] = "ffuss";
00283 $this->xmlStartTag('netucate.User',$attr);
00284 $this->xmlEndTag('netucate.User');
00285
00286 $this->xmlEndTag('netucate.User.List');
00287
00288 $this->xmlEndTag('netucate.API.Request');
00289 }
00290
00291 function addClass($a_icla_arr,$a_icrs_id)
00292 {
00293 $this->xmlHeader();
00294
00295 $this->xmlStartTag('netucate.API.Request');
00296
00297 $attr = array();
00298 $attr['user'] = $this->login;
00299 $attr['password'] = $this->passwd;
00300 $attr['customerid'] = $this->customer_id;
00301 $attr['id'] = "";
00302 $attr['command'] = "Add";
00303 $attr['object'] = "Class";
00304 $this->xmlStartTag('netucate.Command',$attr);
00305 $this->xmlEndTag('netucate.Command');
00306
00307 $attr = array();
00308 $attr['courseid'] = $a_icrs_id;
00309 $attr['name'] = $a_icla_arr['title'];
00310 $this->xmlStartTag('netucate.Class',$attr);
00311 $this->xmlEndTag('netucate.Class');
00312
00313 $this->xmlEndTag('netucate.API.Request');
00314 }
00315
00316 function editClass(&$a_user_obj)
00317 {
00318 $this->xmlHeader();
00319
00320 $this->xmlStartTag('netucate.API.Request');
00321
00322 $attr = array();
00323 $attr['user'] = $this->login;
00324 $attr['password'] = $this->passwd;
00325 $attr['customerid'] = $this->customer_id;
00326 $attr['id'] = "";
00327 $attr['command'] = "Edit";
00328 $attr['object'] = "Class";
00329 $this->xmlStartTag('netucate.Command',$attr);
00330 $this->xmlEndTag('netucate.Command');
00331
00332 $attr = array();
00333 $attr['classid'] = "2191";
00334 $attr['name'] = "New Name";
00335 $attr['instructoruserid'] = "";
00336 $attr['bandwidth'] = "";
00337 $attr['appsharebandwidth'] = "";
00338 $attr['description'] = "";
00339 $attr['alwaysopen'] = "";
00340 $attr['password'] = "";
00341 $attr['message'] = "";
00342 $attr['floorpolicy'] = "";
00343 $attr['conferencetypeid'] = "";
00344 $attr['videobandwidth'] = "";
00345 $attr['videoframerate'] = "";
00346 $attr['enablepush'] = "";
00347 $attr['issecure'] = "";
00348 $attr['akclassvalue1'] = "";
00349 $attr['akclassvalue2'] = "";
00350 $this->xmlStartTag('netucate.Class',$attr);
00351 $this->xmlEndTag('netucate.Class');
00352
00353 $this->xmlEndTag('netucate.API.Request');
00354 }
00355
00356 function joinClass(&$a_user_obj,$a_ilinc_class_id)
00357 {
00358 $this->xmlHeader();
00359
00360 $this->xmlStartTag('netucate.API.Request');
00361
00362 $attr = array();
00363 $attr['user'] = $a_user_obj->getLogin();
00364 $attr['password'] = $a_user_obj->getPasswd();
00365 $attr['customerid'] = $this->customer_id;
00366 $attr['id'] = "";
00367 $attr['task'] = "JoinClass";
00368 $attr['classid'] = $a_ilinc_class_id;
00369 $this->xmlStartTag('netucate.Task',$attr);
00370 $this->xmlEndTag('netucate.Task');
00371
00372 $this->xmlEndTag('netucate.API.Request');
00373 }
00374
00375 function removeClass($a_icla_id)
00376 {
00377 $this->xmlHeader();
00378
00379 $this->xmlStartTag('netucate.API.Request');
00380
00381 $attr = array();
00382 $attr['user'] = $this->login;
00383 $attr['password'] = $this->passwd;
00384 $attr['customerid'] = $this->customer_id;
00385 $attr['id'] = "";
00386 $attr['command'] = "Remove";
00387 $attr['object'] = "Class";
00388 $this->xmlStartTag('netucate.Command',$attr);
00389 $this->xmlEndTag('netucate.Command');
00390
00391 $this->xmlStartTag('netucate.Class.List');
00392
00393 $attr = array();
00394 $attr['classid'] = $a_icla_id;
00395 $this->xmlStartTag('netucate.Class',$attr);
00396 $this->xmlEndTag('netucate.Class');
00397
00398 $this->xmlEndTag('netucate.Class.List');
00399
00400 $this->xmlEndTag('netucate.API.Request');
00401 }
00402
00403 function findCourseClasses($a_icrs_id)
00404 {
00405 $this->xmlHeader();
00406
00407 $this->xmlStartTag('netucate.API.Request');
00408
00409 $attr = array();
00410 $attr['user'] = $this->login;
00411 $attr['password'] = $this->passwd;
00412 $attr['customerid'] = $this->customer_id;
00413 $attr['id'] = "";
00414 $attr['command'] = "Find";
00415 $attr['object'] = "CourseClasses";
00416 $this->xmlStartTag('netucate.Command',$attr);
00417 $this->xmlEndTag('netucate.Command');
00418
00419 $attr = array();
00420 $attr['courseid'] = $a_icrs_id;
00421 $this->xmlStartTag('netucate.Course',$attr);
00422 $this->xmlEndTag('netucate.Course');
00423
00424 $this->xmlEndTag('netucate.API.Request');
00425 }
00426
00427 function addCourse(&$a_icrs_arr)
00428 {
00429 $this->xmlHeader();
00430
00431 $this->xmlStartTag('netucate.API.Request');
00432
00433 $attr = array();
00434 $attr['user'] = $this->login;
00435 $attr['password'] = $this->passwd;
00436 $attr['customerid'] = $this->customer_id;
00437 $attr['id'] = "";
00438 $attr['command'] = "Add";
00439 $attr['object'] = "Course";
00440 $this->xmlStartTag('netucate.Command',$attr);
00441 $this->xmlEndTag('netucate.Command');
00442
00443 $attr = array();
00444 $attr['name'] = $a_icrs_arr['title'];
00445 $attr['homepage'] = $a_icrs_arr['homepage'];
00446 $attr['download'] = $a_icrs_arr['download'];
00447 $attr['description'] = $a_icrs_arr['desc'];
00448 $this->xmlStartTag('netucate.Course',$attr);
00449 $this->xmlEndTag('netucate.Course');
00450
00451 $this->xmlEndTag('netucate.API.Request');
00452 }
00453
00454 function editCourse(&$a_user_obj)
00455 {
00456 $this->xmlHeader();
00457
00458 $this->xmlStartTag('netucate.API.Request');
00459
00460 $attr = array();
00461 $attr['user'] = $this->login;
00462 $attr['password'] = $this->passwd;
00463 $attr['customerid'] = $this->customer_id;
00464 $attr['id'] = "";
00465 $attr['command'] = "Edit";
00466 $attr['object'] = "Course";
00467 $this->xmlStartTag('netucate.Command',$attr);
00468 $this->xmlEndTag('netucate.Command');
00469
00470
00471 $attr = array();
00472 $attr['courseid'] = "2191";
00473 $attr['name'] = "New Name";
00474 $attr['homepage'] = "";
00475 $attr['download'] = "";
00476 $attr['description'] = "";
00477 $this->xmlStartTag('netucate.Course',$attr);
00478 $this->xmlEndTag('netucate.Course');
00479
00480 $this->xmlEndTag('netucate.API.Request');
00481 }
00482
00483 function removeCourse($a_icrs_id)
00484 {
00485 $this->xmlHeader();
00486
00487 $this->xmlStartTag('netucate.API.Request');
00488
00489 $attr = array();
00490 $attr['user'] = $this->login;
00491 $attr['password'] = $this->passwd;
00492 $attr['customerid'] = $this->customer_id;
00493 $attr['id'] = "";
00494 $attr['command'] = "Remove";
00495 $attr['object'] = "Course";
00496 $this->xmlStartTag('netucate.Command',$attr);
00497 $this->xmlEndTag('netucate.Command');
00498
00499 $this->xmlStartTag('netucate.Course.List');
00500
00501 $attr = array();
00502 $attr['courseid'] = $a_icrs_id;
00503 $this->xmlStartTag('netucate.Class',$attr);
00504 $this->xmlEndTag('netucate.Class');
00505
00506
00507
00508
00509
00510
00511
00512
00513 $this->xmlEndTag('netucate.Course.List');
00514
00515 $this->xmlEndTag('netucate.API.Request');
00516 }
00517 }
00518 ?>