00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00035 require_once ('./classes/class.ilObject.php');
00036 require_once ('class.ilnetucateXMLAPI.php');
00037
00038 class ilObjiLincCourse extends ilObject
00039 {
00046 function ilObjiLincCourse($a_id = 0,$a_call_by_reference = true)
00047 {
00048 $this->type = "icrs";
00049 $this->ilObject($a_id,$a_call_by_reference);
00050 $this->setRegisterMode(false);
00051 $this->ilincAPI = new ilnetucateXMLAPI();
00052
00053 $this->docent_ids = array();
00054 $this->student_ids = array();
00055 }
00056
00061 function read()
00062 {
00063 global $ilDB, $ilErr;
00064
00065 parent::read();
00066
00067 $q = "SELECT * FROM ilinc_data ".
00068 "WHERE obj_id= ".$ilDB->quote($this->id);
00069 $r = $ilDB->query($q);
00070
00071 if ($r->numRows() > 0)
00072 {
00073 $data = $r->fetchRow(DB_FETCHMODE_OBJECT);
00074
00075 $this->ilinc_id = $data->course_id;
00076 $this->activated = ilUtil::yn2tf($data->activation_offline);
00077 $this->akclassvalue1 = $data->akclassvalue1;
00078 $this->akclassvalue2 = $data->akclassvalue2;
00079 }
00080 else
00081 {
00082 $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);
00083 }
00084 }
00085
00086 function getiLincId()
00087 {
00088 return $this->ilinc_id;
00089 }
00090
00091 function getErrorMsg()
00092 {
00093 $err_msg = $this->error_msg;
00094 $this->error_msg = "";
00095
00096 return $err_msg;
00097 }
00098
00099 function getAKClassValue1()
00100 {
00101 return $this->akclassvalue1;
00102 }
00103
00104 function getAKClassValue2()
00105 {
00106 return $this->akclassvalue2;
00107 }
00108
00109 function setAKClassValue1($a_str)
00110 {
00111 $this->akclassvalue1 = $a_str;
00112 }
00113
00114 function setAKClassValue2($a_str)
00115 {
00116 $this->akclassvalue2 = $a_str;
00117 }
00118
00125 function update()
00126 {
00127 global $ilDB;
00128
00129 $this->ilincAPI->editCourse($this->getiLincId(),$_POST["Fobject"]);
00130 $response = $this->ilincAPI->sendRequest();
00131
00132 if ($response->isError())
00133 {
00134 $this->error_msg = $response->getErrorMsg();
00135 return false;
00136 }
00137
00138
00139
00140 if (!parent::update())
00141 {
00142 $this->error_msg = "database_error";
00143 return false;
00144 }
00145
00146 $q = "UPDATE ilinc_data SET ".
00147 "activation_offline = ".$ilDB->quote($this->activated).", ".
00148 "akclassvalue1 = ".$ilDB->quote($this->akclassvalue1).", ".
00149 "akclassvalue2 = ".$ilDB->quote($this->akclassvalue2)." ".
00150 "WHERE obj_id = ".$ilDB->quote($this->getId());
00151 $r = $ilDB->query($q);
00152
00153 return true;
00154 }
00155
00162 function addCourse()
00163 {
00164 $this->ilincAPI->addCourse($_POST["Fobject"]);
00165 $response = $this->ilincAPI->sendRequest();
00166
00167 if ($response->isError())
00168 {
00169 $this->error_msg = $response->getErrorMsg();
00170 return false;
00171 }
00172
00173 $this->ilinc_id = $response->getFirstID();
00174
00175 return true;
00176 }
00177
00185 function ilClone($a_parent_ref)
00186 {
00187 global $rbacadmin;
00188
00189
00190 $new_ref_id = parent::ilClone($a_parent_ref);
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205 return $new_ref_id;
00206 }
00207
00214 function delete()
00215 {
00216 global $ilDB;
00217
00218
00219 if (!parent::delete())
00220 {
00221 return false;
00222 }
00223
00224
00225 $q = "DELETE FROM ilinc_data WHERE course_id = ".$ilDB->quote($this->getiLincId());
00226 $ilDB->query($q);
00227
00228
00229
00230
00231 $this->ilincAPI->removeCourse($this->getiLincId());
00232 $response = $this->ilincAPI->sendRequest();
00233
00234 return true;
00235 }
00236
00237
00238 function storeiLincId($a_icrs_id)
00239 {
00240 global $ilDB;
00241
00242 $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).")";
00243 $ilDB->query($q);
00244
00245 $this->ilinc_id = $a_icrs_id;
00246 }
00247
00248
00249 function saveActivationStatus($a_activated)
00250 {
00251 global $ilDB;
00252
00253 $q = "UPDATE ilinc_data SET activation_offline = ".$ilDB->quote($a_activated)." WHERE obj_id = ".$ilDB->quote($this->getId());
00254 $r = $ilDB->query($q);
00255 }
00256
00257
00258 function saveAKClassValues($a_akclassvalue1,$a_akclassvalue2)
00259 {
00260 global $ilDB;
00261
00262 $q = "UPDATE ilinc_data SET ".
00263 "akclassvalue1 = ".$ilDB->quote($a_akclassvalue1).", ".
00264 "akclassvalue2 = ".$ilDB->quote($a_akclassvalue2)." ".
00265 "WHERE obj_id = ".$ilDB->quote($this->getId());
00266 $r = $ilDB->query($q);
00267 }
00268
00275 function initDefaultRoles()
00276 {
00277 global $rbacadmin, $rbacreview;
00278
00279
00280 $rfoldObj =& $this->createRoleFolder();
00281
00282
00283
00284 $roleObj = $rfoldObj->createRole("il_icrs_admin_".$this->getRefId(),"LearnLinc admin of seminar obj_no.".$this->getId());
00285 $this->m_roleAdminId = $roleObj->getId();
00286
00287
00288 $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_icrs_admin'";
00289 $r = $this->ilias->db->getRow($q, DB_FETCHMODE_OBJECT);
00290 $rbacadmin->copyRolePermission($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
00291
00292
00293 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"icrs",$rfoldObj->getRefId());
00294 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->getRefId());
00295
00296
00297
00298
00299
00300
00301
00302 $roleObj = $rfoldObj->createRole("il_icrs_member_".$this->getRefId(),"LearnLinc admin of seminar obj_no.".$this->getId());
00303 $this->m_roleMemberId = $roleObj->getId();
00304
00305
00306 $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_icrs_member'";
00307 $r = $this->ilias->db->getRow($q, DB_FETCHMODE_OBJECT);
00308 $rbacadmin->copyRolePermission($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
00309
00310
00311 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"icrs",$rfoldObj->getRefId());
00312 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->getRefId());
00313
00314
00315
00316
00317
00318 unset($rfoldObj);
00319 unset($roleObj);
00320
00321 $roles[] = $this->m_roleAdminId;
00322 $roles[] = $this->m_roleMemberId;
00323
00324
00325
00326 $this->__setCourseStatus();
00327
00328 return $roles ? $roles : array();
00329 }
00330
00344 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00345 {
00346 return true;
00347 }
00348
00356 function addMember(&$a_user_obj, $a_mem_role, $a_instructor = false)
00357 {
00358 global $rbacadmin;
00359
00360 if (!isset($a_user_obj) && !isset($a_mem_role))
00361 {
00362 $this->error_msg = get_class($this)."::addMember(): Missing parameters !";
00363 return false;
00364 }
00365
00366
00367 if (!$this->userExists($a_user_obj))
00368 {
00369
00370 if ($this->addUser($a_user_obj) == false)
00371 {
00372
00373 return false;
00374 }
00375 }
00376
00377
00378 if (!$this->registerUser($a_user_obj,$a_instructor))
00379 {
00380
00381 return false;
00382 }
00383
00384
00385 $this->join($a_user_obj->getId(),$a_mem_role);
00386
00387 return true;
00388 }
00389
00395 function join($a_user_id, $a_mem_role="")
00396 {
00397 global $rbacadmin;
00398
00399 if (is_array($a_mem_role))
00400 {
00401 foreach ($a_mem_role as $role)
00402 {
00403 $rbacadmin->assignUser($role,$a_user_id, false);
00404 }
00405 }
00406 else
00407 {
00408 $rbacadmin->assignUser($a_mem_role,$a_user_id, false);
00409 }
00410
00411 ilObjUser::updateActiveRoles($a_user_id);
00412 return true;
00413 }
00414
00419 function leave($a_user_id)
00420 {
00421 global $rbacadmin;
00422
00423 $arr_groupRoles = $this->getMemberRoles($a_user_id);
00424
00425 if (is_array($arr_groupRoles))
00426 {
00427 foreach ($arr_groupRoles as $groupRole)
00428 {
00429 $rbacadmin->deassignUser($groupRole, $a_user_id);
00430 }
00431 }
00432 else
00433 {
00434 $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
00435 }
00436
00437 ilObjUser::updateActiveRoles($a_user_id);
00438 return true;
00439 }
00440
00447 function getMemberRoles($a_user_id)
00448 {
00449 global $rbacadmin, $rbacreview;
00450
00451 $arr_assignedRoles = array();
00452
00453 $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->getLocalRoles());
00454
00455 return $arr_assignedRoles;
00456 }
00457
00464 function getMemberIds()
00465 {
00466 global $rbacadmin, $rbacreview;
00467
00468 $usr_arr= array();
00469
00470 $rol = $this->getLocalRoles();
00471
00472 foreach ($rol as $value)
00473 {
00474 foreach ($rbacreview->assignedUsers($value) as $member_id)
00475 {
00476 array_push($usr_arr,$member_id);
00477 }
00478 }
00479
00480 $mem_arr = array_unique($usr_arr);
00481
00482 return $mem_arr ? $mem_arr : array();
00483 }
00484
00492 function getMemberData($a_mem_ids, $active = 1)
00493 {
00494 global $rbacadmin, $rbacreview, $ilBench, $ilDB;
00495
00496 $usr_arr= array();
00497
00498 $q = "SELECT login,firstname,lastname,title,usr_id,ilinc_id ".
00499 "FROM usr_data ".
00500 "WHERE usr_id IN (".implode(',',$a_mem_ids).")";
00501
00502 if (is_numeric($active) && $active > -1)
00503 $q .= "AND active = ".$ilDB->quote($active);
00504
00505 $r = $ilDB->query($q);
00506
00507 while($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
00508 {
00509 $mem_arr[] = array("id" => $row->usr_id,
00510 "login" => $row->login,
00511 "firstname" => $row->firstname,
00512 "lastname" => $row->lastname,
00513 "ilinc_id" => $row->ilinc_id
00514 );
00515 }
00516
00517 return $mem_arr ? $mem_arr : array();
00518 }
00519
00526 function getLocalRoles($a_translate = false)
00527 {
00528 global $rbacadmin,$rbacreview;
00529
00530 if (empty($this->local_roles))
00531 {
00532 $this->local_roles = array();
00533 $rolf = $rbacreview->getRoleFolderOfObject($this->getRefId());
00534 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
00535
00536 foreach ($role_arr as $role_id)
00537 {
00538 if ($rbacreview->isAssignable($role_id,$rolf["ref_id"]) == true)
00539 {
00540 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
00541
00542 if ($a_translate)
00543 {
00544 $role_name = ilObjRole::_getTranslation($role_Obj->getTitle());
00545 }
00546 else
00547 {
00548 $role_name = $role_Obj->getTitle();
00549 }
00550
00551 $this->local_roles[$role_name] = $role_Obj->getId();
00552 }
00553 }
00554 }
00555
00556 return $this->local_roles;
00557 }
00558
00565 function getMemberRolesTitle($a_user_id)
00566 {
00567 global $ilDB,$ilBench;
00568
00569 include_once ('classes/class.ilObjRole.php');
00570
00571 $str_member_roles ="";
00572
00573 $q = "SELECT title ".
00574 "FROM object_data ".
00575 "LEFT JOIN rbac_ua ON object_data.obj_id=rbac_ua.rol_id ".
00576 "WHERE object_data.type = 'role' ".
00577 "AND rbac_ua.usr_id = ".$ilDB->quote($a_user_id)." ".
00578 "AND rbac_ua.rol_id IN (".implode(',',$this->getLocalRoles()).")";
00579
00580 $r = $ilDB->query($q);
00581
00582 while($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
00583 {
00584
00585 $str_member_roles .= ilObjRole::_getTranslation($row["title"]).", ";
00586 }
00587
00588 return substr($str_member_roles,0,-2);
00589 }
00590
00595 function getDefaultMemberRole()
00596 {
00597 $local_icrs_Roles = $this->getLocalRoles();
00598
00599 return $local_icrs_Roles["il_icrs_member_".$this->getRefId()];
00600 }
00601
00606 function getDefaultAdminRole()
00607 {
00608 $local_icrs_Roles = $this->getLocalRoles();
00609
00610 return $local_icrs_Roles["il_icrs_admin_".$this->getRefId()];
00611 }
00612
00613 function getClassrooms()
00614 {
00615 global $ilErr;
00616
00617 if (!$this->ilias->getSetting("ilinc_active"))
00618 {
00619 $this->error_msg = "ilinc_server_not_active";
00620 return false;
00621 }
00622
00623 $this->ilincAPI->findCourseClasses($this->getiLincId());
00624 $response = $this->ilincAPI->sendRequest();
00625
00626 if ($response->isError())
00627 {
00628 if (!$response->getErrorMsg())
00629 {
00630 $this->error_msg = "err_get_classrooms";
00631 }
00632 else
00633 {
00634 $this->error_msg = $response->getErrorMsg();
00635 }
00636
00637 return false;
00638 }
00639
00640 if (!$response->data['classes'])
00641 {
00642
00643 $this->error_msg = $response->data['result']['cdata'];
00644 return false;
00645 }
00646
00647 foreach ($response->data['classes'] as $class_id => $data)
00648 {
00649 $this->ilincAPI->findClass($class_id);
00650 $response = $this->ilincAPI->sendRequest("findClass");
00651
00652 if ($response->data['classes'])
00653 {
00654 $full_class_data[$class_id] = $response->data['classes'][$class_id];
00655 }
00656 }
00657
00658 return $full_class_data;
00659 }
00660
00661 function updateClassrooms()
00662 {
00663 global $ilErr;
00664
00665 $this->ilincAPI->findCourseClasses($this->getiLincId());
00666 $response = $this->ilincAPI->sendRequest();
00667
00668 if ($response->isError())
00669 {
00670 if (!$response->getErrorMsg())
00671 {
00672 $this->error_msg = "err_get_classrooms";
00673 }
00674 else
00675 {
00676 $this->error_msg = $response->getErrorMsg();
00677 }
00678
00679 return false;
00680 }
00681
00682 if (!$response->data['classes'])
00683 {
00684
00685 $this->error_msg = $response->data['result']['cdata'];
00686 return false;
00687 }
00688
00689 if (array_key_exists('akclassvalue1',$_POST["Fobject"]))
00690 {
00691 $data["akclassvalue1"] = $_POST["Fobject"]["akclassvalue1"];
00692 }
00693
00694 if (array_key_exists('akclassvalue2',$_POST["Fobject"]))
00695 {
00696 $data["akclassvalue2"] = $_POST["Fobject"]["akclassvalue2"];
00697 }
00698
00699 foreach ($response->data['classes'] as $class_id => $data2)
00700 {
00701 include_once("class.ilObjiLincClassroom.php");
00702 $icla_obj = new ilObjiLincClassroom($class_id,$this->ref_id);
00703
00704 if (!$icla_obj->update($data))
00705 {
00706 $this->error_msg = $icla_obj->getErrorMsg();
00707
00708 return false;
00709 }
00710
00711 unset($icla_obj);
00712 }
00713
00714 return true;
00715 }
00716
00717
00718
00719 function userExists(&$a_user_obj)
00720 {
00721
00722
00723 include_once ('class.ilObjiLincUser.php');
00724 $ilinc_user = new ilObjiLincUser($a_user_obj);
00725
00726 if (!$ilinc_user->id and !$ilinc_user->login)
00727 {
00728 return false;
00729 }
00730
00731 return true;
00732 }
00733
00734
00735 function addUser(&$a_user_obj)
00736 {
00737 include_once ('class.ilObjiLincUser.php');
00738 $ilinc_user = new ilObjiLincUser($a_user_obj);
00739
00740 return $ilinc_user->add();
00741 }
00742
00743 function isMember($a_user_id = "")
00744 {
00745 if (strlen($a_user_id) == 0)
00746 {
00747 $a_user_id = $this->ilias->account->getId();
00748 }
00749
00750 $arr_members = $this->getMemberIds();
00751
00752 if (in_array($a_user_id, $arr_members))
00753 {
00754 return true;
00755 }
00756
00757 return false;
00758 }
00759
00760 function isDocent($a_user_obj = "")
00761 {
00762 if (!$a_user_obj)
00763 {
00764 $a_user_obj =& $this->ilias->account;
00765 }
00766
00767 $docents = $this->getiLincMemberIds(true);
00768
00769 include_once ('class.ilObjiLincUser.php');
00770 $ilinc_user = new ilObjiLincUser($a_user_obj);
00771
00772 if (in_array($ilinc_user->id,$docents))
00773 {
00774 return true;
00775 }
00776
00777 return false;
00778 }
00779
00780 function registerUser(&$a_user_obj,$a_instructor = false)
00781 {
00782 if ($a_instructor === true)
00783 {
00784 $a_instructor = "True";
00785 }
00786 else
00787 {
00788 $a_instructor = "False";
00789 }
00790
00791 include_once ('class.ilObjiLincUser.php');
00792 $ilinc_user = new ilObjiLincUser($a_user_obj);
00793
00794 $user[] = array('id' => $ilinc_user->id, 'instructor' => $a_instructor);
00795 $this->ilincAPI->registerUser($this->getiLincId(),$user);
00796 $response = $this->ilincAPI->sendRequest("registerUser");
00797
00798 if ($response->isError())
00799 {
00800 if (!$response->getErrorMsg())
00801 {
00802 $this->error_msg = "err_register_user";
00803 }
00804 else
00805 {
00806 $this->error_msg = $response->getErrorMsg();
00807 }
00808
00809 return false;
00810 }
00811
00812 return true;
00813 }
00814
00815 function registerUsers($a_user_arr)
00816 {
00817 foreach ($a_user_arr as $user_id => $instructorflag)
00818 {
00819 $flag = "False";
00820
00821 if ($instructorflag == ILINC_MEMBER_DOCENT)
00822 {
00823 $flag = "True";
00824 }
00825
00826 $ilinc_users[] = array('id' => $user_id,'instructor' => $flag);
00827 }
00828
00829 $this->ilincAPI->registerUser($this->getiLincId(),$ilinc_users);
00830 $response = $this->ilincAPI->sendRequest("registerUser");
00831
00832 if ($response->isError())
00833 {
00834 if (!$response->getErrorMsg())
00835 {
00836 $this->error_msg = "err_register_users";
00837 }
00838 else
00839 {
00840 $this->error_msg = $response->getErrorMsg();
00841 }
00842
00843 return false;
00844 }
00845
00846 return true;
00847 }
00848
00849
00850 function unregisterUser($a_user_obj)
00851 {
00852 include_once ('class.ilObjiLincUser.php');
00853 $ilinc_user = new ilObjiLincUser($a_user_obj);
00854
00855
00856 if ($ilinc_user->id == '0')
00857 {
00858 return true;
00859 }
00860
00861 $this->ilincAPI->unregisterUser($this->getiLincId(),array($ilinc_user->id));
00862 $response = $this->ilincAPI->sendRequest();
00863
00864 if ($response->isError())
00865 {
00866 if (!$response->getErrorMsg())
00867 {
00868 $this->error_msg = "err_unregister_user";
00869 }
00870 else
00871 {
00872 $this->error_msg = $response->getErrorMsg();
00873 }
00874
00875 return false;
00876 }
00877
00878 return true;
00879 }
00880
00881 function unregisterUsers($a_ilinc_user_ids)
00882 {
00883 $this->ilincAPI->unregisterUser($this->getiLincId(),$a_ilinc_user_ids);
00884 $response = $this->ilincAPI->sendRequest();
00885
00886 if ($response->isError())
00887 {
00888 if (!$response->getErrorMsg())
00889 {
00890 $this->error_msg = "err_unregister_users";
00891 }
00892 else
00893 {
00894 $this->error_msg = $response->getErrorMsg();
00895 }
00896
00897 return false;
00898 }
00899
00900 return true;
00901 }
00902
00903 function userLogin(&$a_user_obj)
00904 {
00905 include_once ('class.ilObjiLincUser.php');
00906 $ilinc_user = new ilObjiLincUser($a_user_obj);
00907
00908 $this->ilincAPI->userLogin($ilinc_user);
00909 $response = $this->ilincAPI->sendRequest("userLogin");
00910
00911 if ($response->isError())
00912 {
00913 if (!$response->getErrorMsg())
00914 {
00915 $this->error_msg = "err_user_login";
00916 }
00917 else
00918 {
00919 $this->error_msg = $response->getErrorMsg();
00920 }
00921
00922 return false;
00923 }
00924
00925
00926 return $response->data['url']['cdata'];
00927 }
00928
00929
00930 function uploadPicture(&$a_user_obj,$a_lang)
00931 {
00932 $this->ilincAPI->uploadPicture($a_user_obj,$a_lang);
00933 $response = $this->ilincAPI->sendRequest("uploadPicture");
00934
00935 if ($response->isError())
00936 {
00937 if (!$response->getErrorMsg())
00938 {
00939 $this->error_msg = "err_upload_picture";
00940 }
00941 else
00942 {
00943 $this->error_msg = $response->getErrorMsg();
00944 }
00945
00946 return false;
00947 }
00948
00949
00950 return $response->data['url']['cdata'];
00951 }
00952
00959 function getAdminIds($a_grpId="")
00960 {
00961 global $rbacreview;
00962
00963 if (!empty($a_grpId))
00964 {
00965 $grp_id = $a_grpId;
00966 }
00967 else
00968 {
00969 $grp_id = $this->getRefId();
00970 }
00971
00972 $usr_arr = array();
00973 $roles = $this->getDefaultRoles($this->getRefId());
00974
00975 foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
00976 {
00977 array_push($usr_arr,$member_id);
00978 }
00979
00980 return $usr_arr;
00981 }
00982
00987 function removeMember(&$a_user_obj)
00988 {
00989 if (!isset($a_user_obj))
00990 {
00991 $this->error_msg = get_class($this)."::removeMember(): Missing parameters !";
00992 return false;
00993 }
00994
00995 if (!$this->isMember($a_user_obj->getId()))
00996 {
00997 return true;
00998 }
00999
01000 if (count($this->getMemberIds()) > 1)
01001 {
01002 if ($this->isAdmin($a_user_obj->getId()) && count($this->getAdminIds()) < 2)
01003 {
01004 $this->error_msg = "ilinc_err_administrator_required";
01005 return false;
01006 }
01007 }
01008
01009
01010 if (!$this->unregisterUser($a_user_obj))
01011 {
01012
01013 return false;
01014 }
01015
01016 $this->leave($a_user_obj->getId());
01017
01018 return true;
01019 }
01020
01027 function isAdmin($a_user_id)
01028 {
01029 global $rbacreview;
01030
01031 $icrs_roles = $this->getDefaultRoles();
01032
01033 if (in_array($a_user_id,$rbacreview->assignedUsers($icrs_roles["icrs_admin_role"])))
01034 {
01035 return true;
01036 }
01037 else
01038 {
01039 return false;
01040 }
01041 }
01042
01048 function getDefaultRoles($a_grp_id="")
01049 {
01050 global $rbacadmin, $rbacreview;
01051
01052 if (strlen($a_grp_id) > 0)
01053 {
01054 $grp_id = $a_grp_id;
01055 }
01056 else
01057 {
01058 $grp_id = $this->getRefId();
01059 }
01060
01061 $rolf = $rbacreview->getRoleFolderOfObject($grp_id);
01062 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
01063
01064 foreach ($role_arr as $role_id)
01065 {
01066 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
01067
01068 $grp_Member ="il_icrs_member_".$grp_id;
01069 $grp_Admin ="il_icrs_admin_".$grp_id;
01070
01071 if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
01072 {
01073 $arr_grpDefaultRoles["icrs_member_role"] = $role_Obj->getId();
01074 }
01075
01076 if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
01077 {
01078 $arr_grpDefaultRoles["icrs_admin_role"] = $role_Obj->getId();
01079 }
01080 }
01081
01082 return $arr_grpDefaultRoles;
01083 }
01084
01085
01086 function getiLincMemberIds($a_instructorflag = false)
01087 {
01088 if ($a_instructorflag == true)
01089 {
01090 if (!empty($this->docent_ids))
01091 {
01092 return $this->docent_ids;
01093 }
01094 }
01095 else
01096 {
01097 if (!empty($this->student_ids))
01098 {
01099 return $this->student_ids;
01100 }
01101 }
01102
01103 $this->ilincAPI->findRegisteredUsersByRole($this->getiLincId(),$a_instructorflag);
01104 $response = $this->ilincAPI->sendRequest();
01105
01106 if (is_array($response->data['users']))
01107 {
01108 if ($a_instructorflag == true)
01109 {
01110 $this->docent_ids = array_keys($response->data['users']);
01111 }
01112 else
01113 {
01114 $this->student_ids = array_keys($response->data['users']);
01115 }
01116
01117 return array_keys($response->data['users']);
01118 }
01119
01120 return array();
01121 }
01122
01123 function checkiLincMemberStatus($a_ilinc_user_id,$a_docent_ids,$a_student_ids)
01124 {
01125 if (in_array($a_ilinc_user_id,$a_docent_ids))
01126 {
01127 return ILINC_MEMBER_DOCENT;
01128 }
01129
01130 if (in_array($a_ilinc_user_id,$a_student_ids))
01131 {
01132 return ILINC_MEMBER_STUDENT;
01133 }
01134
01135 return ILINC_MEMBER_NOTSET;
01136 }
01137
01138 function _isActivated($a_course_obj_id)
01139 {
01140 global $ilDB,$ilias;
01141
01142 if (!$ilias->getSetting("ilinc_active"))
01143 {
01144 return false;
01145 }
01146
01147 $q = "SELECT activation_offline FROM ilinc_data WHERE obj_id=".$ilDB->quote($a_course_obj_id);
01148 $r = $ilDB->query($q);
01149
01150 $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
01151
01152 return ilUtil::yn2tf($row->activation_offline);
01153 }
01154
01155 function _getAKClassValues($a_course_obj_id)
01156 {
01157 global $ilDB,$ilias;
01158
01159 $q = "SELECT akclassvalue1, akclassvalue2 FROM ilinc_data WHERE obj_id=".$ilDB->quote($a_course_obj_id);
01160 $r = $ilDB->query($q);
01161
01162 $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
01163
01164 return $akclassvalues = array($row->akclassvalue1,$row->akclassvalue2);
01165 }
01166
01167 function _isMember($a_user_id,$a_ref_id)
01168 {
01169 global $rbacreview;
01170
01171 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
01172 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"],false);
01173 $user_roles = $rbacreview->assignedRoles($a_user_id);
01174
01175 if (!array_intersect($local_roles,$user_roles))
01176 {
01177 return false;
01178 }
01179
01180 return true;
01181 }
01182
01183 function __setCourseStatus()
01184 {
01185
01186 }
01187
01188 function _goto($a_target)
01189 {
01190 global $ilAccess, $ilErr, $lng;
01191
01192 if ($ilAccess->checkAccess("read", "", $a_target))
01193 {
01194 $_GET["cmd"] = "frameset";
01195 $_GET["ref_id"] = $a_target;
01196 }
01197 else
01198 {
01199 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
01200 }
01201 }
01202
01211 function _getLinkToObject($a_id)
01212 {
01213 return array("repository.php?ref_id=".$a_id."&set_mode=flat&cmdClass=ilobjilinccoursegui","");
01214 }
01215 }
01216 ?>