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 define('ILINC_MEMBER_NOTSET','ilinc_notset');
00026 define('ILINC_MEMBER_DOCENT','ilinc_docent');
00027 define('ILINC_MEMBER_STUDENT','ilinc_student');
00028
00029 parent::ilXmlWriter();
00030
00031 $this->ilias =& $ilias;
00032
00033 $this->reg_login = $this->ilias->getSetting("ilinc_registrar_login");
00034 $this->reg_passwd = $this->ilias->getSetting("ilinc_registrar_passwd");
00035 $this->customer_id = $this->ilias->getSetting("ilinc_customer_id");
00036 $this->server_scheme = $this->ilias->getSetting("ilinc_protocol");
00037 $this->server_addr = $this->ilias->getSetting("ilinc_server");
00038 $this->server_path = $this->ilias->getSetting("ilinc_path");
00039 $this->server_port = $this->ilias->getSetting("ilinc_port");
00040 $this->server_timeout = $this->ilias->getSetting("ilinc_timeout");
00041 $this->user_max_strlen = 32;
00042 }
00043
00044 function xmlFormatData($a_data)
00045 {
00046 return $a_data;
00047 }
00048
00049 function setServerAddr($a_server_addr)
00050 {
00051 $this->server_addr = $a_server_addr;
00052 }
00053
00054 function getServerAddr()
00055 {
00056 return $this->server_addr;
00057 }
00058
00059 function getServerPort()
00060 {
00061 return $this->server_port;
00062 }
00063
00064 function getServerTimeOut()
00065 {
00066 return $this->server_timeout;
00067 }
00068
00069 function getServerPath()
00070 {
00071 return $this->server_path;
00072 }
00073
00074 function getServerScheme()
00075 {
00076 return $this->server_scheme;
00077 }
00078
00079 function getCustomerID()
00080 {
00081 return $this->customer_id;
00082 }
00083
00084 function setRequest($a_data)
00085 {
00086 $this->request = $a_data;
00087 }
00088
00089
00090
00091 function sendRequest($a_request = '')
00092 {
00093 $this->request = $this->xmlDumpMem();
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 if ($this->getServerScheme() == "https")
00105 {
00106 $scheme = "ssl";
00107 }
00108 else
00109 {
00110 $scheme = "http";
00111 }
00112
00113 $sock = fsockopen($scheme."://".$this->getServerAddr(), $this->getServerPort(), $errno, $errstr, $this->getServerTimeOut());
00114 if (!$sock) die("$errstr ($errno)\n");
00115
00116
00117
00118
00119
00120 fputs($sock, "POST ".$this->getServerPath()." HTTP/1.0\r\n");
00121 fputs($sock, "Host: ".$this->getServerScheme()."://".$this->getServerAddr().$this->getServerPath()."\r\n");
00122 fputs($sock, "Content-type: text/xml\r\n");
00123 fputs($sock, "Content-length: " . strlen($this->request) . "\r\n");
00124 fputs($sock, "Accept: */*\r\n");
00125 fputs($sock, "\r\n");
00126 fputs($sock, $this->request."\r\n");
00127 fputs($sock, "\r\n");
00128
00129 $headers = "";
00130
00131 while ($str = trim(fgets($sock, 4096)))
00132 {
00133 $headers .= "$str\n";
00134 }
00135
00136 $response = "";
00137
00138 while (!feof($sock))
00139 {
00140 $response .= fgets($sock, 4096);
00141 }
00142
00143 fclose($sock);
00144
00145
00146 $response_obj = new ilnetucateResponse($response);
00147
00148
00149
00150
00151
00152
00153 return $response_obj;
00154 }
00155
00164 function addUser(&$a_login_data,&$a_user_obj,$a_authority = "leader")
00165 {
00166 $this->xmlClear();
00167 $this->xmlHeader();
00168
00169 $this->xmlStartTag('netucate.API.Request');
00170
00171 $attr = array();
00172 $attr['user'] = $this->reg_login;
00173 $attr['password'] = $this->reg_passwd;
00174 $attr['customerid'] = $this->customer_id;
00175 $attr['id'] = "";
00176 $attr['command'] = "Add";
00177 $attr['object'] = "User";
00178 $this->xmlStartTag('netucate.Command',$attr);
00179 $this->xmlEndTag('netucate.Command');
00180
00181 $attr = array();
00182 $attr['loginname'] = $a_login_data["login"];
00183 $attr['fullname'] = $a_user_obj->getFullname($this->user_max_strlen);
00184 $attr['password'] = $a_login_data["passwd"];
00185 $attr['authority'] = $a_authority;
00186 $attr['email'] = $a_user_obj->getEmail();
00187 $this->xmlStartTag('netucate.User',$attr);
00188 $this->xmlEndTag('netucate.User');
00189
00190 $this->xmlEndTag('netucate.API.Request');
00191 }
00192
00193 function registerUser($a_ilinc_course_id,$a_ilinc_user_arr)
00194 {
00195 $this->xmlClear();
00196 $this->xmlHeader();
00197
00198 $this->xmlStartTag('netucate.API.Request');
00199
00200 $attr = array();
00201 $attr['user'] = $this->reg_login;
00202 $attr['password'] = $this->reg_passwd;
00203 $attr['customerid'] = $this->customer_id;
00204 $attr['id'] = "";
00205 $attr['command'] = "Register";
00206 $attr['object'] = "User";
00207 $this->xmlStartTag('netucate.Command',$attr);
00208 $this->xmlEndTag('netucate.Command');
00209
00210 $attr = array();
00211 $attr['courseid'] = $a_ilinc_course_id;
00212 $this->xmlStartTag('netucate.Course',$attr);
00213
00214 $this->xmlStartTag('netucate.User.List');
00215
00216 foreach ($a_ilinc_user_arr as $user)
00217 {
00218 $attr = array();
00219 $attr['userid'] = $user['id'];
00220 $attr['instructorflag'] = $user['instructor'];
00221 $this->xmlStartTag('netucate.User',$attr);
00222 $this->xmlEndTag('netucate.User');
00223 }
00224
00225 $this->xmlEndTag('netucate.User.List');
00226
00227 $this->xmlEndTag('netucate.Course');
00228
00229 $this->xmlEndTag('netucate.API.Request');
00230
00231 }
00232
00233 function findRegisteredUsersByRole($a_ilinc_course_id,$a_instructorflag = false)
00234 {
00235 $this->xmlClear();
00236 $this->xmlHeader();
00237
00238 $this->xmlStartTag('netucate.API.Request');
00239
00240 $attr = array();
00241 $attr['user'] = $this->reg_login;
00242 $attr['password'] = $this->reg_passwd;
00243 $attr['customerid'] = $this->customer_id;
00244 $attr['id'] = "";
00245 $attr['command'] = "Find";
00246 $attr['object'] = "RegisteredUsersByRole";
00247 $this->xmlStartTag('netucate.Command',$attr);
00248 $this->xmlEndTag('netucate.Command');
00249
00250 $attr = array();
00251 $attr['courseid'] = $a_ilinc_course_id;
00252 $attr['instructorflag'] = ($a_instructorflag) ? "True" : "False";
00253 $this->xmlStartTag('netucate.Course',$attr);
00254
00255 $this->xmlEndTag('netucate.Course');
00256
00257 $this->xmlEndTag('netucate.API.Request');
00258 }
00259
00260 function unregisterUser($a_ilinc_course_id, $a_ilinc_user_ids)
00261 {
00262 $this->xmlClear();
00263 $this->xmlHeader();
00264
00265 $this->xmlStartTag('netucate.API.Request');
00266
00267 $attr = array();
00268 $attr['user'] = $this->reg_login;
00269 $attr['password'] = $this->reg_passwd;
00270 $attr['customerid'] = $this->customer_id;
00271 $attr['id'] = "";
00272 $attr['command'] = "UnRegister";
00273 $attr['object'] = "User";
00274 $this->xmlStartTag('netucate.Command',$attr);
00275 $this->xmlEndTag('netucate.Command');
00276
00277 $attr = array();
00278 $attr['courseid'] = $a_ilinc_course_id;
00279 $this->xmlStartTag('netucate.Course',$attr);
00280
00281 $this->xmlStartTag('netucate.User.List');
00282
00283 foreach ($a_ilinc_user_ids as $user_id)
00284 {
00285 $attr = array();
00286 $attr['userid'] = $user_id;
00287 $this->xmlStartTag('netucate.User',$attr);
00288 $this->xmlEndTag('netucate.User');
00289 }
00290
00291 $this->xmlEndTag('netucate.User.List');
00292
00293 $this->xmlEndTag('netucate.Course');
00294
00295 $this->xmlEndTag('netucate.API.Request');
00296 }
00297
00298
00299 function findUser(&$a_user_obj)
00300 {
00301 $this->xmlClear();
00302 $this->xmlHeader();
00303
00304 $this->xmlStartTag('netucate.API.Request');
00305
00306 $attr = array();
00307 $attr['user'] = $this->reg_login;
00308 $attr['password'] = $this->reg_passwd;
00309 $attr['customerid'] = $this->customer_id;
00310 $attr['id'] = "";
00311 $attr['command'] = "Find";
00312 $attr['object'] = "User";
00313 $this->xmlStartTag('netucate.Command',$attr);
00314 $this->xmlEndTag('netucate.Command');
00315
00316 $attr = array();
00317 $attr['userid'] = "2191";
00318 $attr['loginname'] = "ffuss";
00319 $attr['fullname'] = "Fred Fuss";
00320 $attr['lotnumber'] = "1";
00321 $this->xmlStartTag('netucate.User',$attr);
00322 $this->xmlEndTag('netucate.User');
00323
00324 $this->xmlEndTag('netucate.API.Request');
00325 }
00326
00327
00328 function removeUser(&$a_user_obj)
00329 {
00330 $this->xmlClear();
00331 $this->xmlHeader();
00332
00333 $this->xmlStartTag('netucate.API.Request');
00334
00335 $attr = array();
00336 $attr['user'] = $this->reg_login;
00337 $attr['password'] = $this->reg_passwd;
00338 $attr['customerid'] = $this->customer_id;
00339 $attr['id'] = "";
00340 $attr['command'] = "Remove";
00341 $attr['object'] = "User";
00342 $this->xmlStartTag('netucate.Command',$attr);
00343 $this->xmlEndTag('netucate.Command');
00344
00345 $this->xmlStartTag('netucate.User.List');
00346
00347 $attr = array();
00348 $attr['userid'] = "2191";
00349 $attr['instructorflag'] = "True";
00350 $this->xmlStartTag('netucate.User',$attr);
00351 $this->xmlEndTag('netucate.User');
00352
00353 $attr = array();
00354 $attr['userid'] = "2192";
00355 $attr['loginname'] = "ffuss";
00356 $this->xmlStartTag('netucate.User',$attr);
00357 $this->xmlEndTag('netucate.User');
00358
00359 $this->xmlEndTag('netucate.User.List');
00360
00361 $this->xmlEndTag('netucate.API.Request');
00362 }
00363
00364 function addClass($a_course_id,$a_data)
00365 {
00366 $this->xmlClear();
00367 $this->xmlHeader();
00368
00369 $this->xmlStartTag('netucate.API.Request');
00370
00371 $attr = array();
00372 $attr['user'] = $this->reg_login;
00373 $attr['password'] = $this->reg_passwd;
00374 $attr['customerid'] = $this->customer_id;
00375 $attr['id'] = "";
00376 $attr['command'] = "Add";
00377 $attr['object'] = "Class";
00378 $this->xmlStartTag('netucate.Command',$attr);
00379 $this->xmlEndTag('netucate.Command');
00380
00381 $attr = array();
00382 $attr['courseid'] = $a_course_id;
00383 $attr['name'] = $a_data['title'];
00384 $attr['instructoruserid'] = $a_data['instructoruserid'];
00385 $attr['description'] = $a_data['desc'];
00386 $attr['alwaysopen'] = $a_data['alwaysopen'];
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399 $this->xmlStartTag('netucate.Class',$attr);
00400 $this->xmlEndTag('netucate.Class');
00401
00402 $this->xmlEndTag('netucate.API.Request');
00403
00404 }
00405
00406 function editClass($a_class_id,$a_data)
00407 {
00408 $this->xmlClear();
00409 $this->xmlHeader();
00410
00411 $this->xmlStartTag('netucate.API.Request');
00412
00413 $attr = array();
00414 $attr['user'] = $this->reg_login;
00415 $attr['password'] = $this->reg_passwd;
00416 $attr['customerid'] = $this->customer_id;
00417 $attr['id'] = "";
00418 $attr['command'] = "Edit";
00419 $attr['object'] = "Class";
00420 $this->xmlStartTag('netucate.Command',$attr);
00421 $this->xmlEndTag('netucate.Command');
00422
00423 $attr = array();
00424 $attr['classid'] = $a_class_id;
00425 $attr['name'] = $a_data['name'];
00426 $attr['instructoruserid'] = $a_data['instructoruserid'];
00427 $attr['description'] = $a_data['description'];
00428 $attr['alwaysopen'] = $a_data['alwaysopen'];
00429 $attr['password'] = $a_data['password'];
00430 $attr['message'] = $a_data['message'];
00431 $attr['appsharebandwidth'] = $a_data['appsharebandwidth'];
00432 $attr['bandwidth'] = $a_data['bandwidth'];
00433 $attr['floorpolicy'] = $a_data['floorpolicy'];
00434 $attr['conferencetypeid'] = $a_data['conferencetypeid'];
00435 $attr['videobandwidth'] = $a_data['videobandwidth'];
00436 $attr['videoframerate'] = $a_data['videoframerate'];
00437 $attr['enablepush'] = $a_data['enablepush'];
00438 $attr['issecure'] = $a_data['issecure'];
00439 $attr['akclassvalue1'] = $a_data['akclassvalue1'];
00440 $attr['akclassvalue2'] = $a_data['akclassvalue2'];
00441 $this->xmlStartTag('netucate.Class',$attr);
00442 $this->xmlEndTag('netucate.Class');
00443
00444 $this->xmlEndTag('netucate.API.Request');
00445 }
00446
00447 function joinClass(&$a_user_obj,$a_ilinc_class_id)
00448 {
00449 $this->xmlClear();
00450 $this->xmlHeader();
00451
00452 $this->xmlStartTag('netucate.API.Request');
00453
00454 $data = $a_user_obj->getiLincData();
00455
00456 $attr = array();
00457 $attr['user'] = $data['login'];
00458 $attr['password'] = $data['passwd'];
00459 $attr['customerid'] = $this->customer_id;
00460 $attr['id'] = "";
00461 $attr['task'] = "JoinClass";
00462 $attr['classid'] = $a_ilinc_class_id;
00463 $this->xmlStartTag('netucate.Task',$attr);
00464 $this->xmlEndTag('netucate.Task');
00465
00466 $this->xmlEndTag('netucate.API.Request');
00467 }
00468
00469 function userLogin(&$a_user_obj)
00470 {
00471 $this->xmlClear();
00472 $this->xmlHeader();
00473
00474 $this->xmlStartTag('netucate.API.Request');
00475
00476 $ilinc_data = $a_user_obj->getiLincData();
00477
00478 $attr = array();
00479 $attr['user'] = $ilinc_data['login'];
00480 $attr['password'] = $ilinc_data['passwd'];
00481 $attr['customerid'] = $this->customer_id;
00482 $attr['id'] = "";
00483 $attr['locale'] = $a_user_obj->getLanguage();
00484 $attr['task'] = "UserLogin";
00485 $this->xmlStartTag('netucate.Task',$attr);
00486 $this->xmlEndTag('netucate.Task');
00487
00488 $this->xmlEndTag('netucate.API.Request');
00489 }
00490
00491 function uploadPicture(&$a_user_obj)
00492 {
00493 $this->xmlHeader();
00494
00495 $this->xmlStartTag('netucate.API.Request');
00496
00497 $data = $a_user_obj->getiLincData();
00498
00499 $attr = array();
00500 $attr['user'] = $data['login'];
00501 $attr['password'] = $data['passwd'];
00502 $attr['customerid'] = $this->customer_id;
00503 $attr['id'] = "";
00504 $attr['locale'] = $a_user_obj->getLanguage();
00505 $attr['task'] = "UploadPicture";
00506 $this->xmlStartTag('netucate.Task',$attr);
00507 $this->xmlEndTag('netucate.Task');
00508
00509 $this->xmlEndTag('netucate.API.Request');
00510 }
00511
00512 function removeClass($a_icla_id)
00513 {
00514 $this->xmlClear();
00515 $this->xmlHeader();
00516
00517 $this->xmlStartTag('netucate.API.Request');
00518
00519 $attr = array();
00520 $attr['user'] = $this->reg_login;
00521 $attr['password'] = $this->reg_passwd;
00522 $attr['customerid'] = $this->customer_id;
00523 $attr['id'] = "";
00524 $attr['command'] = "Remove";
00525 $attr['object'] = "Class";
00526 $this->xmlStartTag('netucate.Command',$attr);
00527 $this->xmlEndTag('netucate.Command');
00528
00529 $this->xmlStartTag('netucate.Class.List');
00530
00531 $attr = array();
00532 $attr['classid'] = $a_icla_id;
00533 $this->xmlStartTag('netucate.Class',$attr);
00534 $this->xmlEndTag('netucate.Class');
00535
00536 $this->xmlEndTag('netucate.Class.List');
00537
00538 $this->xmlEndTag('netucate.API.Request');
00539 }
00540
00541 function findCourseClasses($a_icrs_id)
00542 {
00543 $this->xmlClear();
00544 $this->xmlHeader();
00545
00546 $this->xmlStartTag('netucate.API.Request');
00547
00548 $attr = array();
00549 $attr['user'] = $this->reg_login;
00550 $attr['password'] = $this->reg_passwd;
00551 $attr['customerid'] = $this->customer_id;
00552 $attr['id'] = "";
00553 $attr['command'] = "Find";
00554 $attr['object'] = "CourseClasses";
00555 $this->xmlStartTag('netucate.Command',$attr);
00556 $this->xmlEndTag('netucate.Command');
00557
00558 $attr = array();
00559 $attr['courseid'] = $a_icrs_id;
00560 $this->xmlStartTag('netucate.Course',$attr);
00561 $this->xmlEndTag('netucate.Course');
00562
00563 $this->xmlEndTag('netucate.API.Request');
00564 }
00565
00566 function findClass($a_class_id)
00567 {
00568 $this->xmlClear();
00569 $this->xmlHeader();
00570
00571 $this->xmlStartTag('netucate.API.Request');
00572
00573 $attr = array();
00574 $attr['user'] = $this->reg_login;
00575 $attr['password'] = $this->reg_passwd;
00576 $attr['customerid'] = $this->customer_id;
00577 $attr['id'] = "";
00578 $attr['command'] = "Find";
00579 $attr['object'] = "Class";
00580 $this->xmlStartTag('netucate.Command',$attr);
00581 $this->xmlEndTag('netucate.Command');
00582
00583 $attr = array();
00584 $attr['classid'] = $a_class_id;
00585 $this->xmlStartTag('netucate.Class',$attr);
00586 $this->xmlEndTag('netucate.Class');
00587
00588 $this->xmlEndTag('netucate.API.Request');
00589 }
00590
00591 function addCourse(&$a_icrs_arr)
00592 {
00593 $this->xmlClear();
00594 $this->xmlHeader();
00595
00596 $this->xmlStartTag('netucate.API.Request');
00597
00598 $attr = array();
00599 $attr['user'] = $this->reg_login;
00600 $attr['password'] = $this->reg_passwd;
00601 $attr['customerid'] = $this->customer_id;
00602 $attr['id'] = "";
00603 $attr['command'] = "Add";
00604 $attr['object'] = "Course";
00605 $this->xmlStartTag('netucate.Command',$attr);
00606 $this->xmlEndTag('netucate.Command');
00607
00608 $attr = array();
00609 $attr['name'] = $a_icrs_arr['title'];
00610 $attr['homepage'] = $a_icrs_arr['homepage'];
00611 $attr['download'] = $a_icrs_arr['download'];
00612 $attr['description'] = $a_icrs_arr['desc'];
00613 $this->xmlStartTag('netucate.Course',$attr);
00614 $this->xmlEndTag('netucate.Course');
00615
00616 $this->xmlEndTag('netucate.API.Request');
00617 }
00618
00619 function editCourse($a_icrs_id,$a_icrs_arr)
00620 {
00621 $this->xmlClear();
00622 $this->xmlHeader();
00623
00624 $this->xmlStartTag('netucate.API.Request');
00625
00626 $attr = array();
00627 $attr['user'] = $this->reg_login;
00628 $attr['password'] = $this->reg_passwd;
00629 $attr['customerid'] = $this->customer_id;
00630 $attr['id'] = "";
00631 $attr['command'] = "Edit";
00632 $attr['object'] = "Course";
00633 $this->xmlStartTag('netucate.Command',$attr);
00634 $this->xmlEndTag('netucate.Command');
00635
00636
00637 $attr = array();
00638 $attr['courseid'] = $a_icrs_id;
00639 $attr['name'] = $a_icrs_arr['title'];
00640 $attr['homepage'] = $a_icrs_arr['homepage'];
00641 $attr['download'] = $a_icrs_arr['download'];
00642 $attr['description'] = $a_icrs_arr['desc'];
00643 $this->xmlStartTag('netucate.Course',$attr);
00644 $this->xmlEndTag('netucate.Course');
00645
00646 $this->xmlEndTag('netucate.API.Request');
00647 }
00648
00649 function removeCourse($a_icrs_id)
00650 {
00651 $this->xmlClear();
00652 $this->xmlHeader();
00653
00654 $this->xmlStartTag('netucate.API.Request');
00655
00656 $attr = array();
00657 $attr['user'] = $this->reg_login;
00658 $attr['password'] = $this->reg_passwd;
00659 $attr['customerid'] = $this->customer_id;
00660 $attr['id'] = "";
00661 $attr['command'] = "Remove";
00662 $attr['object'] = "Course";
00663 $this->xmlStartTag('netucate.Command',$attr);
00664 $this->xmlEndTag('netucate.Command');
00665
00666 $this->xmlStartTag('netucate.Course.List');
00667
00668 $attr = array();
00669 $attr['courseid'] = $a_icrs_id;
00670 $this->xmlStartTag('netucate.Class',$attr);
00671 $this->xmlEndTag('netucate.Class');
00672
00673
00674
00675
00676
00677
00678
00679
00680 $this->xmlEndTag('netucate.Course.List');
00681
00682 $this->xmlEndTag('netucate.API.Request');
00683 }
00684
00685 }
00686 ?>