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 ilObjiLincCourse extends ilObject
00038 {
00045 function ilObjiLincCourse($a_id = 0,$a_call_by_reference = true)
00046 {
00047 $this->type = "icrs";
00048 $this->ilObject($a_id,$a_call_by_reference);
00049 $this->setRegisterMode(false);
00050 $this->ilincAPI = new ilnetucateXMLAPI();
00051
00052 $this->docent_ids = array();
00053 $this->student_ids = array();
00054 }
00055
00060 function read()
00061 {
00062 global $ilDB, $ilErr;
00063
00064 parent::read();
00065
00066 $q = "SELECT * FROM ilinc_data ".
00067 "WHERE obj_id= ".$ilDB->quote($this->id);
00068 $r = $ilDB->query($q);
00069
00070 if ($r->numRows() > 0)
00071 {
00072 $data = $r->fetchRow(DB_FETCHMODE_OBJECT);
00073
00074 $this->ilinc_id = $data->course_id;
00075 $this->activated = ilUtil::yn2tf($data->activation_offline);
00076 }
00077 else
00078 {
00079 $ilErr->raiseError("<b>Error: There is no dataset with id ".$this->id."!</b><br />class: ".get_class($this)."<br />Script: ".__FILE__."<br />Line: ".__LINE__, $ilErr->FATAL);
00080 }
00081 }
00082
00083 function getiLincId()
00084 {
00085 return $this->ilinc_id;
00086 }
00087
00088 function getErrorMsg()
00089 {
00090 $err_msg = $this->error_msg;
00091 $this->error_msg = "";
00092
00093 return $err_msg;
00094 }
00095
00102 function update()
00103 {
00104 global $ilDB;
00105
00106 $this->ilincAPI->editCourse($this->getiLincId(),$_POST["Fobject"]);
00107 $response = $this->ilincAPI->sendRequest();
00108
00109 if ($response->isError())
00110 {
00111 $this->error_msg = $response->getErrorMsg();
00112 return false;
00113 }
00114
00115
00116 if (!parent::update())
00117 {
00118 $this->error_msg = "database_error";
00119 return false;
00120 }
00121
00122 $q = "UPDATE ilinc_data SET activation_offline = ".$ilDB->quote($this->activated)." WHERE obj_id = ".$ilDB->quote($this->getId());
00123 $r = $ilDB->query($q);
00124
00125 return true;
00126 }
00127
00134 function addCourse()
00135 {
00136 $this->ilincAPI->addCourse($_POST["Fobject"]);
00137 $response = $this->ilincAPI->sendRequest();
00138
00139 if ($response->isError())
00140 {
00141 $this->error_msg = $response->getErrorMsg();
00142 return false;
00143 }
00144
00145 $this->ilinc_id = $response->getFirstID();
00146
00147 return true;
00148 }
00149
00157 function ilClone($a_parent_ref)
00158 {
00159 global $rbacadmin;
00160
00161
00162 $new_ref_id = parent::ilClone($a_parent_ref);
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 return $new_ref_id;
00178 }
00179
00186 function delete()
00187 {
00188 global $ilDB;
00189
00190
00191 if (!parent::delete())
00192 {
00193 return false;
00194 }
00195
00196
00197 $q = "DELETE FROM ilinc_data WHERE course_id = ".$ilDB->quote($this->getiLincId());
00198 $ilDB->query($q);
00199
00200
00201
00202
00203 $this->ilincAPI->removeCourse($this->getiLincId());
00204 $response = $this->ilincAPI->sendRequest();
00205
00206 return true;
00207 }
00208
00209
00210 function storeiLincId($a_icrs_id)
00211 {
00212 global $ilDB;
00213
00214 $q = "INSERT INTO ilinc_data (obj_id,type,course_id,activation_offline) VALUES (".$ilDB->quote($this->id).",'icrs',".$ilDB->quote($a_icrs_id).",".$ilDB->quote($this->activated).")";
00215 $ilDB->query($q);
00216
00217 $this->ilinc_id = $a_icrs_id;
00218 }
00219
00220
00221 function saveActivationStatus($a_activated)
00222 {
00223 global $ilDB;
00224
00225 $q = "UPDATE ilinc_data SET activation_offline = ".$ilDB->quote($a_activated)." WHERE obj_id = ".$ilDB->quote($this->getId());
00226 $r = $ilDB->query($q);
00227 }
00228
00235 function initDefaultRoles()
00236 {
00237 global $rbacadmin, $rbacreview;
00238
00239
00240 $rfoldObj =& $this->createRoleFolder();
00241
00242
00243
00244 $roleObj = $rfoldObj->createRole("il_icrs_admin_".$this->getRefId(),"LearnLinc admin of seminar obj_no.".$this->getId());
00245 $this->m_roleAdminId = $roleObj->getId();
00246
00247
00248 $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_icrs_admin'";
00249 $r = $this->ilias->db->getRow($q, DB_FETCHMODE_OBJECT);
00250 $rbacadmin->copyRolePermission($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
00251
00252
00253 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"icrs",$rfoldObj->getRefId());
00254 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->getRefId());
00255
00256
00257
00258
00259
00260
00261
00262 $roleObj = $rfoldObj->createRole("il_icrs_member_".$this->getRefId(),"LearnLinc admin of seminar obj_no.".$this->getId());
00263 $this->m_roleMemberId = $roleObj->getId();
00264
00265
00266 $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_icrs_member'";
00267 $r = $this->ilias->db->getRow($q, DB_FETCHMODE_OBJECT);
00268 $rbacadmin->copyRolePermission($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
00269
00270
00271 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"icrs",$rfoldObj->getRefId());
00272 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->getRefId());
00273
00274
00275
00276
00277
00278 unset($rfoldObj);
00279 unset($roleObj);
00280
00281 $roles[] = $this->m_roleAdminId;
00282 $roles[] = $this->m_roleMemberId;
00283
00284
00285
00286 $this->__setCourseStatus();
00287
00288 return $roles ? $roles : array();
00289 }
00290
00304 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00305 {
00306 return true;
00307 }
00308
00316 function addMember(&$a_user_obj, $a_mem_role, $a_instructor = false)
00317 {
00318 global $rbacadmin;
00319
00320 if (!isset($a_user_obj) && !isset($a_mem_role))
00321 {
00322 $this->error_msg = get_class($this)."::addMember(): Missing parameters !";
00323 return false;
00324 }
00325
00326
00327 if (!$this->userExists($a_user_obj))
00328 {
00329
00330 if ($this->addUser($a_user_obj) == false)
00331 {
00332
00333 return false;
00334 }
00335 }
00336
00337
00338 if (!$this->registerUser($a_user_obj,$a_instructor))
00339 {
00340
00341 return false;
00342 }
00343
00344
00345 $this->join($a_user_obj->getId(),$a_mem_role);
00346
00347 return true;
00348 }
00349
00355 function join($a_user_id, $a_mem_role="")
00356 {
00357 global $rbacadmin;
00358
00359 if (is_array($a_mem_role))
00360 {
00361 foreach ($a_mem_role as $role)
00362 {
00363 $rbacadmin->assignUser($role,$a_user_id, false);
00364 }
00365 }
00366 else
00367 {
00368 $rbacadmin->assignUser($a_mem_role,$a_user_id, false);
00369 }
00370
00371 ilObjUser::updateActiveRoles($a_user_id);
00372 return true;
00373 }
00374
00379 function leave($a_user_id)
00380 {
00381 global $rbacadmin;
00382
00383 $arr_groupRoles = $this->getMemberRoles($a_user_id);
00384
00385 if (is_array($arr_groupRoles))
00386 {
00387 foreach ($arr_groupRoles as $groupRole)
00388 {
00389 $rbacadmin->deassignUser($groupRole, $a_user_id);
00390 }
00391 }
00392 else
00393 {
00394 $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
00395 }
00396
00397 ilObjUser::updateActiveRoles($a_user_id);
00398 return true;
00399 }
00400
00407 function getMemberRoles($a_user_id)
00408 {
00409 global $rbacadmin, $rbacreview;
00410
00411 $arr_assignedRoles = array();
00412
00413 $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->getLocalRoles());
00414
00415 return $arr_assignedRoles;
00416 }
00417
00424 function getMemberIds()
00425 {
00426 global $rbacadmin, $rbacreview;
00427
00428 $usr_arr= array();
00429
00430 $rol = $this->getLocalRoles();
00431
00432 foreach ($rol as $value)
00433 {
00434 foreach ($rbacreview->assignedUsers($value) as $member_id)
00435 {
00436 array_push($usr_arr,$member_id);
00437 }
00438 }
00439
00440 $mem_arr = array_unique($usr_arr);
00441
00442 return $mem_arr ? $mem_arr : array();
00443 }
00444
00452 function getMemberData($a_mem_ids, $active = 1)
00453 {
00454 global $rbacadmin, $rbacreview, $ilBench, $ilDB;
00455
00456 $usr_arr= array();
00457
00458 $q = "SELECT login,firstname,lastname,title,usr_id,ilinc_id ".
00459 "FROM usr_data ".
00460 "WHERE usr_id IN (".implode(',',$a_mem_ids).")";
00461
00462 if (is_numeric($active) && $active > -1)
00463 $q .= "AND active = ".$ilDB->quote($active);
00464
00465 $r = $ilDB->query($q);
00466
00467 while($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
00468 {
00469 $mem_arr[] = array("id" => $row->usr_id,
00470 "login" => $row->login,
00471 "firstname" => $row->firstname,
00472 "lastname" => $row->lastname,
00473 "ilinc_id" => $row->ilinc_id
00474 );
00475 }
00476
00477 return $mem_arr ? $mem_arr : array();
00478 }
00479
00486 function getLocalRoles($a_translate = false)
00487 {
00488 global $rbacadmin,$rbacreview;
00489
00490 if (empty($this->local_roles))
00491 {
00492 $this->local_roles = array();
00493 $rolf = $rbacreview->getRoleFolderOfObject($this->getRefId());
00494 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
00495
00496 foreach ($role_arr as $role_id)
00497 {
00498 if ($rbacreview->isAssignable($role_id,$rolf["ref_id"]) == true)
00499 {
00500 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
00501
00502 if ($a_translate)
00503 {
00504 $role_name = ilObjRole::_getTranslation($role_Obj->getTitle());
00505 }
00506 else
00507 {
00508 $role_name = $role_Obj->getTitle();
00509 }
00510
00511 $this->local_roles[$role_name] = $role_Obj->getId();
00512 }
00513 }
00514 }
00515
00516 return $this->local_roles;
00517 }
00518
00525 function getMemberRolesTitle($a_user_id)
00526 {
00527 global $ilDB,$ilBench;
00528
00529 include_once ('classes/class.ilObjRole.php');
00530
00531 $str_member_roles ="";
00532
00533 $q = "SELECT title ".
00534 "FROM object_data ".
00535 "LEFT JOIN rbac_ua ON object_data.obj_id=rbac_ua.rol_id ".
00536 "WHERE object_data.type = 'role' ".
00537 "AND rbac_ua.usr_id = ".$ilDB->quote($a_user_id)." ".
00538 "AND rbac_ua.rol_id IN (".implode(',',$this->getLocalRoles()).")";
00539
00540 $r = $ilDB->query($q);
00541
00542 while($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
00543 {
00544
00545 $str_member_roles .= ilObjRole::_getTranslation($row["title"]).", ";
00546 }
00547
00548 return substr($str_member_roles,0,-2);
00549 }
00550
00555 function getDefaultMemberRole()
00556 {
00557 $local_icrs_Roles = $this->getLocalRoles();
00558
00559 return $local_icrs_Roles["il_icrs_member_".$this->getRefId()];
00560 }
00561
00566 function getDefaultAdminRole()
00567 {
00568 $local_icrs_Roles = $this->getLocalRoles();
00569
00570 return $local_icrs_Roles["il_icrs_admin_".$this->getRefId()];
00571 }
00572
00573 function getClassrooms()
00574 {
00575 global $ilErr;
00576
00577 if (!$this->ilias->getSetting("ilinc_active"))
00578 {
00579 $this->error_msg = "ilinc_server_not_active";
00580 return false;
00581 }
00582
00583 $this->ilincAPI->findCourseClasses($this->getiLincId());
00584 $response = $this->ilincAPI->sendRequest();
00585
00586 if ($response->isError())
00587 {
00588 if (!$response->getErrorMsg())
00589 {
00590 $this->error_msg = "err_get_classrooms";
00591 }
00592 else
00593 {
00594 $this->error_msg = $response->getErrorMsg();
00595 }
00596
00597 return false;
00598 }
00599
00600 if (!$response->data['classes'])
00601 {
00602
00603 $this->error_msg = $response->data['result']['cdata'];
00604 return false;
00605 }
00606
00607
00608 foreach ($response->data['classes'] as $class_id => $data)
00609 {
00610 $this->ilincAPI->findClass($class_id);
00611 $response = $this->ilincAPI->sendRequest("findClass");
00612
00613 if ($response->data['classes'])
00614 {
00615 $full_class_data[$class_id] = $response->data['classes'][$class_id];
00616 }
00617 }
00618
00619 return $full_class_data;
00620 }
00621
00622
00623
00624 function userExists(&$a_user_obj)
00625 {
00626 $data = $a_user_obj->getiLincData();
00627
00628 if (empty($data["id"]) and empty($data["login"]))
00629 {
00630 return false;
00631 }
00632
00633 return true;
00634 }
00635
00636
00637 function addUser(&$a_user_obj)
00638 {
00639
00640 $login_data = $this->__createLoginData($a_user_obj->getId(),$a_user_obj->getLogin(),$this->ilias->getSetting($inst_id));
00641
00642 $this->ilincAPI->addUser($login_data,$a_user_obj);
00643 $response = $this->ilincAPI->sendRequest();
00644
00645 if ($response->isError())
00646 {
00647 if (!$response->getErrorMsg())
00648 {
00649 $this->error_msg = "err_add_user";
00650 }
00651 else
00652 {
00653 $this->error_msg = $response->getErrorMsg();
00654 }
00655
00656 return false;
00657 }
00658
00659 $ilinc_user_id = $response->getFirstID();
00660 $a_user_obj->setiLincData($ilinc_user_id,$login_data["login"],$login_data["passwd"]);
00661 $a_user_obj->update();
00662
00663 return true;
00664 }
00665
00672 function __createLoginData($a_user_id,$a_user_login,$a_inst_id)
00673 {
00674 if (!$a_inst_id)
00675 {
00676 $a_inst_id = "0";
00677 }
00678
00679 $data["login"] = substr($a_user_login,0,3)."_".$a_user_id."_".$a_inst_id."_".time();
00680 $data["passwd"] = md5(microtime().$a_user_login.rand(10000, 32000));
00681
00682 return $data;
00683 }
00684
00685 function isMember($a_user_id = "")
00686 {
00687 if (strlen($a_user_id) == 0)
00688 {
00689 $a_user_id = $this->ilias->account->getId();
00690 }
00691
00692 $arr_members = $this->getMemberIds();
00693
00694 if (in_array($a_user_id, $arr_members))
00695 {
00696 return true;
00697 }
00698
00699 return false;
00700 }
00701
00702 function isDocent($a_user_obj = "")
00703 {
00704 if (!$a_user_obj)
00705 {
00706 $a_user_obj =& $this->ilias->account;
00707 }
00708
00709 $docents = $this->getiLincMemberIds(true);
00710
00711 $ilinc_data = $a_user_obj->getiLincData();
00712
00713 if (in_array($ilinc_data['id'],$docents))
00714 {
00715 return true;
00716 }
00717
00718 return false;
00719 }
00720
00721 function registerUser(&$a_user_obj,$a_instructor = false)
00722 {
00723 if ($a_instructor === true)
00724 {
00725 $a_instructor = "True";
00726 }
00727 else
00728 {
00729 $a_instructor = "False";
00730 }
00731
00732 $ilinc_data = $a_user_obj->getiLincData();
00733 $user[] = array('id' => $ilinc_data['id'], 'instructor' => $a_instructor);
00734 $this->ilincAPI->registerUser($this->getiLincId(),$user);
00735 $response = $this->ilincAPI->sendRequest("registerUser");
00736
00737 if ($response->isError())
00738 {
00739 if (!$response->getErrorMsg())
00740 {
00741 $this->error_msg = "err_register_user";
00742 }
00743 else
00744 {
00745 $this->error_msg = $response->getErrorMsg();
00746 }
00747
00748 return false;
00749 }
00750
00751 return true;
00752 }
00753
00754 function registerUsers($a_user_arr)
00755 {
00756 foreach ($a_user_arr as $user_id => $instructorflag)
00757 {
00758 $flag = "False";
00759
00760 if ($instructorflag == ILINC_MEMBER_DOCENT)
00761 {
00762 $flag = "True";
00763 }
00764
00765 $ilinc_users[] = array('id' => $user_id,'instructor' => $flag);
00766 }
00767
00768 $this->ilincAPI->registerUser($this->getiLincId(),$ilinc_users);
00769 $response = $this->ilincAPI->sendRequest("registerUser");
00770
00771 if ($response->isError())
00772 {
00773 if (!$response->getErrorMsg())
00774 {
00775 $this->error_msg = "err_register_users";
00776 }
00777 else
00778 {
00779 $this->error_msg = $response->getErrorMsg();
00780 }
00781
00782 return false;
00783 }
00784
00785 return true;
00786 }
00787
00788
00789 function unregisterUser($a_user_obj)
00790 {
00791 $ilinc_data = $a_user_obj->getiLincData();
00792
00793
00794 if ($ilinc_data['id'] == '0')
00795 {
00796 return true;
00797 }
00798
00799 $this->ilincAPI->unregisterUser($this->getiLincId(),array($ilinc_data['id']));
00800 $response = $this->ilincAPI->sendRequest();
00801
00802 if ($response->isError())
00803 {
00804 if (!$response->getErrorMsg())
00805 {
00806 $this->error_msg = "err_unregister_user";
00807 }
00808 else
00809 {
00810 $this->error_msg = $response->getErrorMsg();
00811 }
00812
00813 return false;
00814 }
00815
00816 return true;
00817 }
00818
00819 function unregisterUsers($a_ilinc_user_ids)
00820 {
00821 $this->ilincAPI->unregisterUser($this->getiLincId(),$a_ilinc_user_ids);
00822 $response = $this->ilincAPI->sendRequest();
00823
00824 if ($response->isError())
00825 {
00826 if (!$response->getErrorMsg())
00827 {
00828 $this->error_msg = "err_unregister_users";
00829 }
00830 else
00831 {
00832 $this->error_msg = $response->getErrorMsg();
00833 }
00834
00835 return false;
00836 }
00837
00838 return true;
00839 }
00840
00841 function userLogin(&$a_user_obj)
00842 {
00843 $this->ilincAPI->userLogin($a_user_obj);
00844 $response = $this->ilincAPI->sendRequest("userLogin");
00845
00846 if ($response->isError())
00847 {
00848 if (!$response->getErrorMsg())
00849 {
00850 $this->error_msg = "err_user_login";
00851 }
00852 else
00853 {
00854 $this->error_msg = $response->getErrorMsg();
00855 }
00856
00857 return false;
00858 }
00859
00860
00861 return $response->data['url']['cdata'];
00862 }
00863
00864
00865 function uploadPicture(&$a_user_obj,$a_lang)
00866 {
00867 $this->ilincAPI->uploadPicture($a_user_obj,$a_lang);
00868 $response = $this->ilincAPI->sendRequest("uploadPicture");
00869
00870 if ($response->isError())
00871 {
00872 if (!$response->getErrorMsg())
00873 {
00874 $this->error_msg = "err_upload_picture";
00875 }
00876 else
00877 {
00878 $this->error_msg = $response->getErrorMsg();
00879 }
00880
00881 return false;
00882 }
00883
00884
00885 return $response->data['url']['cdata'];
00886 }
00887
00894 function getAdminIds($a_grpId="")
00895 {
00896 global $rbacreview;
00897
00898 if (!empty($a_grpId))
00899 {
00900 $grp_id = $a_grpId;
00901 }
00902 else
00903 {
00904 $grp_id = $this->getRefId();
00905 }
00906
00907 $usr_arr = array();
00908 $roles = $this->getDefaultRoles($this->getRefId());
00909
00910 foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
00911 {
00912 array_push($usr_arr,$member_id);
00913 }
00914
00915 return $usr_arr;
00916 }
00917
00922 function removeMember(&$a_user_obj)
00923 {
00924 if (!isset($a_user_obj))
00925 {
00926 $this->error_msg = get_class($this)."::removeMember(): Missing parameters !";
00927 return false;
00928 }
00929
00930 if (!$this->isMember($a_user_obj->getId()))
00931 {
00932 return true;
00933 }
00934
00935 if (count($this->getMemberIds()) > 1)
00936 {
00937 if ($this->isAdmin($a_user_obj->getId()) && count($this->getAdminIds()) < 2)
00938 {
00939 $this->error_msg = "ilinc_err_administrator_required";
00940 return false;
00941 }
00942 }
00943
00944
00945 if (!$this->unregisterUser($a_user_obj))
00946 {
00947
00948 return false;
00949 }
00950
00951 $this->leave($a_user_obj->getId());
00952
00953 return true;
00954 }
00955
00962 function isAdmin($a_user_id)
00963 {
00964 global $rbacreview;
00965
00966 $icrs_roles = $this->getDefaultRoles();
00967
00968 if (in_array($a_user_id,$rbacreview->assignedUsers($icrs_roles["icrs_admin_role"])))
00969 {
00970 return true;
00971 }
00972 else
00973 {
00974 return false;
00975 }
00976 }
00977
00983 function getDefaultRoles($a_grp_id="")
00984 {
00985 global $rbacadmin, $rbacreview;
00986
00987 if (strlen($a_grp_id) > 0)
00988 {
00989 $grp_id = $a_grp_id;
00990 }
00991 else
00992 {
00993 $grp_id = $this->getRefId();
00994 }
00995
00996 $rolf = $rbacreview->getRoleFolderOfObject($grp_id);
00997 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
00998
00999 foreach ($role_arr as $role_id)
01000 {
01001 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
01002
01003 $grp_Member ="il_icrs_member_".$grp_id;
01004 $grp_Admin ="il_icrs_admin_".$grp_id;
01005
01006 if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
01007 {
01008 $arr_grpDefaultRoles["icrs_member_role"] = $role_Obj->getId();
01009 }
01010
01011 if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
01012 {
01013 $arr_grpDefaultRoles["icrs_admin_role"] = $role_Obj->getId();
01014 }
01015 }
01016
01017 return $arr_grpDefaultRoles;
01018 }
01019
01020
01021 function getiLincMemberIds($a_instructorflag = false)
01022 {
01023 if ($a_instructorflag == true)
01024 {
01025 if ($this->docent_ids)
01026 {
01027 return $this->docent_ids;
01028 }
01029 }
01030 else
01031 {
01032 if ($this->student_ids)
01033 {
01034 return $this->student_ids;
01035 }
01036 }
01037
01038 $this->ilincAPI->findRegisteredUsersByRole($this->getiLincId(),$a_instructorflag);
01039 $response = $this->ilincAPI->sendRequest();
01040
01041 if (is_array($response->data['users']))
01042 {
01043 if ($a_instructorflag == true)
01044 {
01045 $this->docent_ids = array_keys($response->data['users']);
01046 }
01047 else
01048 {
01049 $this->student_ids = array_keys($response->data['users']);
01050 }
01051
01052 return array_keys($response->data['users']);
01053 }
01054
01055 return array();
01056 }
01057
01058 function checkiLincMemberStatus($a_ilinc_user_id,$a_docent_ids,$a_student_ids)
01059 {
01060 if (in_array($a_ilinc_user_id,$a_docent_ids))
01061 {
01062 return ILINC_MEMBER_DOCENT;
01063 }
01064
01065 if (in_array($a_ilinc_user_id,$a_student_ids))
01066 {
01067 return ILINC_MEMBER_STUDENT;
01068 }
01069
01070 return ILINC_MEMBER_NOTSET;
01071 }
01072
01073 function _isActivated($a_course_obj_id)
01074 {
01075 global $ilDB,$ilias;
01076
01077 if (!$ilias->getSetting("ilinc_active"))
01078 {
01079 return false;
01080 }
01081
01082 $q = "SELECT activation_offline FROM ilinc_data WHERE obj_id = ".$ilDB->quote($a_course_obj_id);
01083 $r = $ilDB->query($q);
01084
01085 $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
01086
01087 return ilUtil::yn2tf($row->activation_offline);
01088 }
01089
01090 function _isMember($a_user_id,$a_ref_id)
01091 {
01092 global $rbacreview;
01093
01094 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
01095 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"],false);
01096 $user_roles = $rbacreview->assignedRoles($a_user_id);
01097
01098 if (!array_intersect($local_roles,$user_roles))
01099 {
01100 return false;
01101 }
01102
01103 return true;
01104 }
01105
01106 function __setCourseStatus()
01107 {
01108
01109 }
01110 }
01111 ?>