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