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