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
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
00178
00185 function delete()
00186 {
00187 global $ilDB;
00188
00189
00190 if (!parent::delete())
00191 {
00192 return false;
00193 }
00194
00195
00196 $q = "DELETE FROM ilinc_data WHERE course_id = ".$ilDB->quote($this->getiLincId());
00197 $ilDB->query($q);
00198
00199
00200
00201
00202 $this->ilincAPI->removeCourse($this->getiLincId());
00203 $response = $this->ilincAPI->sendRequest();
00204
00205 return true;
00206 }
00207
00208
00209 function storeiLincId($a_icrs_id)
00210 {
00211 global $ilDB;
00212
00213 $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).")";
00214 $ilDB->query($q);
00215
00216 $this->ilinc_id = $a_icrs_id;
00217 }
00218
00219
00220 function saveActivationStatus($a_activated)
00221 {
00222 global $ilDB;
00223
00224 $q = "UPDATE ilinc_data SET activation_offline = ".$ilDB->quote($a_activated)." WHERE obj_id = ".$ilDB->quote($this->getId());
00225 $r = $ilDB->query($q);
00226 }
00227
00228
00229 function saveAKClassValues($a_akclassvalue1,$a_akclassvalue2)
00230 {
00231 global $ilDB;
00232
00233 $q = "UPDATE ilinc_data SET ".
00234 "akclassvalue1= ".$ilDB->quote($a_akclassvalue1).", ".
00235 "akclassvalue2= ".$ilDB->quote($a_akclassvalue2)." ".
00236 "WHERE obj_id= ".$ilDB->quote($this->getId());
00237 $r = $ilDB->query($q);
00238 }
00239
00246 function initDefaultRoles()
00247 {
00248 global $rbacadmin, $rbacreview;
00249
00250
00251 $rfoldObj =& $this->createRoleFolder();
00252
00253
00254
00255 $roleObj = $rfoldObj->createRole("il_icrs_admin_".$this->getRefId(),"LearnLinc admin of seminar obj_no.".$this->getId());
00256 $this->m_roleAdminId = $roleObj->getId();
00257
00258
00259 $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_icrs_admin'";
00260 $r = $this->ilias->db->getRow($q, DB_FETCHMODE_OBJECT);
00261 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
00262
00263
00264 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"icrs",$rfoldObj->getRefId());
00265 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->getRefId());
00266
00267
00268
00269
00270
00271
00272
00273 $roleObj = $rfoldObj->createRole("il_icrs_member_".$this->getRefId(),"LearnLinc admin of seminar obj_no.".$this->getId());
00274 $this->m_roleMemberId = $roleObj->getId();
00275
00276
00277 $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_icrs_member'";
00278 $r = $this->ilias->db->getRow($q, DB_FETCHMODE_OBJECT);
00279 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
00280
00281
00282 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"icrs",$rfoldObj->getRefId());
00283 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->getRefId());
00284
00285
00286
00287
00288
00289 unset($rfoldObj);
00290 unset($roleObj);
00291
00292 $roles[] = $this->m_roleAdminId;
00293 $roles[] = $this->m_roleMemberId;
00294
00295
00296
00297 $this->__setCourseStatus();
00298
00299 return $roles ? $roles : array();
00300 }
00301
00315 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00316 {
00317 return true;
00318 }
00319
00327 function addMember(&$a_user_obj, $a_mem_role, $a_instructor = false)
00328 {
00329 global $rbacadmin;
00330
00331 if (!isset($a_user_obj) && !isset($a_mem_role))
00332 {
00333 $this->error_msg = get_class($this)."::addMember(): Missing parameters !";
00334 return false;
00335 }
00336
00337
00338 if (!$this->userExists($a_user_obj))
00339 {
00340
00341 if ($this->addUser($a_user_obj) == false)
00342 {
00343
00344 return false;
00345 }
00346 }
00347
00348
00349 if (!$this->registerUser($a_user_obj,$a_instructor))
00350 {
00351
00352 return false;
00353 }
00354
00355
00356 $this->join($a_user_obj->getId(),$a_mem_role);
00357
00358 return true;
00359 }
00360
00366 function join($a_user_id, $a_mem_role="")
00367 {
00368 global $rbacadmin;
00369
00370 if (is_array($a_mem_role))
00371 {
00372 foreach ($a_mem_role as $role)
00373 {
00374 $rbacadmin->assignUser($role,$a_user_id, false);
00375 }
00376 }
00377 else
00378 {
00379 $rbacadmin->assignUser($a_mem_role,$a_user_id, false);
00380 }
00381
00382 return true;
00383 }
00384
00389 function leave($a_user_id)
00390 {
00391 global $rbacadmin;
00392
00393 $arr_groupRoles = $this->getMemberRoles($a_user_id);
00394
00395 if (is_array($arr_groupRoles))
00396 {
00397 foreach ($arr_groupRoles as $groupRole)
00398 {
00399 $rbacadmin->deassignUser($groupRole, $a_user_id);
00400 }
00401 }
00402 else
00403 {
00404 $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
00405 }
00406
00407 return true;
00408 }
00409
00416 function getMemberRoles($a_user_id)
00417 {
00418 global $rbacadmin, $rbacreview;
00419
00420 $arr_assignedRoles = array();
00421
00422 $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->getLocalRoles());
00423
00424 return $arr_assignedRoles;
00425 }
00426
00433 function getMemberIds()
00434 {
00435 global $rbacadmin, $rbacreview;
00436
00437 $usr_arr= array();
00438
00439 $rol = $this->getLocalRoles();
00440
00441 foreach ($rol as $value)
00442 {
00443 foreach ($rbacreview->assignedUsers($value) as $member_id)
00444 {
00445 array_push($usr_arr,$member_id);
00446 }
00447 }
00448
00449 $mem_arr = array_unique($usr_arr);
00450
00451 return $mem_arr ? $mem_arr : array();
00452 }
00453
00461 function getMemberData($a_mem_ids, $active = 1)
00462 {
00463 global $rbacadmin, $rbacreview, $ilBench, $ilDB;
00464
00465 $usr_arr= array();
00466
00467 $q = "SELECT login,firstname,lastname,title,usr_id,ilinc_id ".
00468 "FROM usr_data ".
00469 "WHERE usr_id IN (".implode(',',$a_mem_ids).")";
00470
00471 if (is_numeric($active) && $active > -1)
00472 $q .= "AND active = ".$ilDB->quote($active);
00473
00474 $r = $ilDB->query($q);
00475
00476 while($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
00477 {
00478 $mem_arr[] = array("id" => $row->usr_id,
00479 "login" => $row->login,
00480 "firstname" => $row->firstname,
00481 "lastname" => $row->lastname,
00482 "ilinc_id" => $row->ilinc_id
00483 );
00484 }
00485
00486 return $mem_arr ? $mem_arr : array();
00487 }
00488
00495 function getLocalRoles($a_translate = false)
00496 {
00497 global $rbacadmin,$rbacreview;
00498
00499 if (empty($this->local_roles))
00500 {
00501 $this->local_roles = array();
00502 $rolf = $rbacreview->getRoleFolderOfObject($this->getRefId());
00503 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
00504
00505 foreach ($role_arr as $role_id)
00506 {
00507 if ($rbacreview->isAssignable($role_id,$rolf["ref_id"]) == true)
00508 {
00509 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
00510
00511 if ($a_translate)
00512 {
00513 $role_name = ilObjRole::_getTranslation($role_Obj->getTitle());
00514 }
00515 else
00516 {
00517 $role_name = $role_Obj->getTitle();
00518 }
00519
00520 $this->local_roles[$role_name] = $role_Obj->getId();
00521 }
00522 }
00523 }
00524
00525 return $this->local_roles;
00526 }
00527
00534 function getMemberRolesTitle($a_user_id)
00535 {
00536 global $ilDB,$ilBench;
00537
00538 include_once ('classes/class.ilObjRole.php');
00539
00540 $str_member_roles ="";
00541
00542 $q = "SELECT title ".
00543 "FROM object_data ".
00544 "LEFT JOIN rbac_ua ON object_data.obj_id=rbac_ua.rol_id ".
00545 "WHERE object_data.type = 'role' ".
00546 "AND rbac_ua.usr_id = ".$ilDB->quote($a_user_id)." ".
00547 "AND rbac_ua.rol_id IN (".implode(',',$this->getLocalRoles()).")";
00548
00549 $r = $ilDB->query($q);
00550
00551 while($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
00552 {
00553
00554 $str_member_roles .= ilObjRole::_getTranslation($row["title"]).", ";
00555 }
00556
00557 return substr($str_member_roles,0,-2);
00558 }
00559
00564 function getDefaultMemberRole()
00565 {
00566 $local_icrs_Roles = $this->getLocalRoles();
00567
00568 return $local_icrs_Roles["il_icrs_member_".$this->getRefId()];
00569 }
00570
00575 function getDefaultAdminRole()
00576 {
00577 $local_icrs_Roles = $this->getLocalRoles();
00578
00579 return $local_icrs_Roles["il_icrs_admin_".$this->getRefId()];
00580 }
00581
00582 function getClassrooms()
00583 {
00584 global $ilErr;
00585
00586 if (!$this->ilias->getSetting("ilinc_active"))
00587 {
00588 $this->error_msg = "ilinc_server_not_active";
00589 return false;
00590 }
00591
00592 $this->ilincAPI->findCourseClasses($this->getiLincId());
00593 $response = $this->ilincAPI->sendRequest();
00594
00595 if ($response->isError())
00596 {
00597 if (!$response->getErrorMsg())
00598 {
00599 $this->error_msg = "err_get_classrooms";
00600 }
00601 else
00602 {
00603 $this->error_msg = $response->getErrorMsg();
00604 }
00605
00606 return false;
00607 }
00608
00609 if (!$response->data['classes'])
00610 {
00611
00612 $this->error_msg = $response->data['result']['cdata'];
00613 return false;
00614 }
00615
00616 foreach ($response->data['classes'] as $class_id => $data)
00617 {
00618 $this->ilincAPI->findClass($class_id);
00619 $response = $this->ilincAPI->sendRequest("findClass");
00620
00621 if ($response->data['classes'])
00622 {
00623 $full_class_data[$class_id] = $response->data['classes'][$class_id];
00624 }
00625 }
00626
00627 return $full_class_data;
00628 }
00629
00630 function updateClassrooms()
00631 {
00632 global $ilErr;
00633
00634 $this->ilincAPI->findCourseClasses($this->getiLincId());
00635 $response = $this->ilincAPI->sendRequest();
00636
00637 if ($response->isError())
00638 {
00639 if (!$response->getErrorMsg())
00640 {
00641 $this->error_msg = "err_get_classrooms";
00642 }
00643 else
00644 {
00645 $this->error_msg = $response->getErrorMsg();
00646 }
00647
00648 return false;
00649 }
00650
00651 if (!$response->data['classes'])
00652 {
00653
00654 $this->error_msg = $response->data['result']['cdata'];
00655 return false;
00656 }
00657
00658 if (array_key_exists('akclassvalue1',$_POST["Fobject"]))
00659 {
00660 $data["akclassvalue1"] = $_POST["Fobject"]["akclassvalue1"];
00661 }
00662
00663 if (array_key_exists('akclassvalue2',$_POST["Fobject"]))
00664 {
00665 $data["akclassvalue2"] = $_POST["Fobject"]["akclassvalue2"];
00666 }
00667
00668 foreach ($response->data['classes'] as $class_id => $data2)
00669 {
00670 include_once("class.ilObjiLincClassroom.php");
00671 $icla_obj = new ilObjiLincClassroom($class_id,$this->ref_id);
00672
00673 if (!$icla_obj->update($data))
00674 {
00675 $this->error_msg = $icla_obj->getErrorMsg();
00676
00677 return false;
00678 }
00679
00680 unset($icla_obj);
00681 }
00682
00683 return true;
00684 }
00685
00686
00687
00688 function userExists(&$a_user_obj)
00689 {
00690
00691
00692 include_once ('class.ilObjiLincUser.php');
00693 $ilinc_user = new ilObjiLincUser($a_user_obj);
00694
00695 if (!$ilinc_user->id and !$ilinc_user->login)
00696 {
00697 return false;
00698 }
00699
00700 return true;
00701 }
00702
00703
00704 function addUser(&$a_user_obj)
00705 {
00706 include_once ('class.ilObjiLincUser.php');
00707 $ilinc_user = new ilObjiLincUser($a_user_obj);
00708
00709 return $ilinc_user->add();
00710 }
00711
00712 function isMember($a_user_id = "")
00713 {
00714 if (strlen($a_user_id) == 0)
00715 {
00716 $a_user_id = $this->ilias->account->getId();
00717 }
00718
00719 $arr_members = $this->getMemberIds();
00720
00721 if (in_array($a_user_id, $arr_members))
00722 {
00723 return true;
00724 }
00725
00726 return false;
00727 }
00728
00729 function isDocent($a_user_obj = "")
00730 {
00731 if (!$a_user_obj)
00732 {
00733 $a_user_obj =& $this->ilias->account;
00734 }
00735
00736 $docents = $this->getiLincMemberIds(true);
00737
00738 include_once ('class.ilObjiLincUser.php');
00739 $ilinc_user = new ilObjiLincUser($a_user_obj);
00740
00741 if (in_array($ilinc_user->id,$docents))
00742 {
00743 return true;
00744 }
00745
00746 return false;
00747 }
00748
00749 function registerUser(&$a_user_obj,$a_instructor = false)
00750 {
00751 if ($a_instructor === true)
00752 {
00753 $a_instructor = "True";
00754 }
00755 else
00756 {
00757 $a_instructor = "False";
00758 }
00759
00760 include_once ('class.ilObjiLincUser.php');
00761 $ilinc_user = new ilObjiLincUser($a_user_obj);
00762
00763 $user[] = array('id' => $ilinc_user->id, 'instructor' => $a_instructor);
00764 $this->ilincAPI->registerUser($this->getiLincId(),$user);
00765 $response = $this->ilincAPI->sendRequest("registerUser");
00766
00767 if ($response->isError())
00768 {
00769 if (!$response->getErrorMsg())
00770 {
00771 $this->error_msg = "err_register_user";
00772 }
00773 else
00774 {
00775 $this->error_msg = $response->getErrorMsg();
00776 }
00777
00778 return false;
00779 }
00780
00781 return true;
00782 }
00783
00784 function registerUsers($a_user_arr)
00785 {
00786 foreach ($a_user_arr as $user_id => $instructorflag)
00787 {
00788 $flag = "False";
00789
00790 if ($instructorflag == ILINC_MEMBER_DOCENT)
00791 {
00792 $flag = "True";
00793 }
00794
00795 $ilinc_users[] = array('id' => $user_id,'instructor' => $flag);
00796 }
00797
00798 $this->ilincAPI->registerUser($this->getiLincId(),$ilinc_users);
00799 $response = $this->ilincAPI->sendRequest("registerUser");
00800
00801 if ($response->isError())
00802 {
00803 if (!$response->getErrorMsg())
00804 {
00805 $this->error_msg = "err_register_users";
00806 }
00807 else
00808 {
00809 $this->error_msg = $response->getErrorMsg();
00810 }
00811
00812 return false;
00813 }
00814
00815 return true;
00816 }
00817
00818
00819 function unregisterUser($a_user_obj)
00820 {
00821 include_once ('class.ilObjiLincUser.php');
00822 $ilinc_user = new ilObjiLincUser($a_user_obj);
00823
00824
00825 if ($ilinc_user->id == '0')
00826 {
00827 return true;
00828 }
00829
00830 $this->ilincAPI->unregisterUser($this->getiLincId(),array($ilinc_user->id));
00831 $response = $this->ilincAPI->sendRequest();
00832
00833 if ($response->isError())
00834 {
00835 if (!$response->getErrorMsg())
00836 {
00837 $this->error_msg = "err_unregister_user";
00838 }
00839 else
00840 {
00841 $this->error_msg = $response->getErrorMsg();
00842 }
00843
00844 return false;
00845 }
00846
00847 return true;
00848 }
00849
00850 function unregisterUsers($a_ilinc_user_ids)
00851 {
00852 $this->ilincAPI->unregisterUser($this->getiLincId(),$a_ilinc_user_ids);
00853 $response = $this->ilincAPI->sendRequest();
00854
00855 if ($response->isError())
00856 {
00857 if (!$response->getErrorMsg())
00858 {
00859 $this->error_msg = "err_unregister_users";
00860 }
00861 else
00862 {
00863 $this->error_msg = $response->getErrorMsg();
00864 }
00865
00866 return false;
00867 }
00868
00869 return true;
00870 }
00871
00872 function userLogin(&$a_user_obj)
00873 {
00874 include_once ('class.ilObjiLincUser.php');
00875 $ilinc_user = new ilObjiLincUser($a_user_obj);
00876
00877 $this->ilincAPI->userLogin($ilinc_user);
00878 $response = $this->ilincAPI->sendRequest("userLogin");
00879
00880 if ($response->isError())
00881 {
00882 if (!$response->getErrorMsg())
00883 {
00884 $this->error_msg = "err_user_login";
00885 }
00886 else
00887 {
00888 $this->error_msg = $response->getErrorMsg();
00889 }
00890
00891 return false;
00892 }
00893
00894
00895 return $response->data['url']['cdata'];
00896 }
00897
00898
00899 function uploadPicture(&$a_user_obj,$a_lang)
00900 {
00901 $this->ilincAPI->uploadPicture($a_user_obj,$a_lang);
00902 $response = $this->ilincAPI->sendRequest("uploadPicture");
00903
00904 if ($response->isError())
00905 {
00906 if (!$response->getErrorMsg())
00907 {
00908 $this->error_msg = "err_upload_picture";
00909 }
00910 else
00911 {
00912 $this->error_msg = $response->getErrorMsg();
00913 }
00914
00915 return false;
00916 }
00917
00918
00919 return $response->data['url']['cdata'];
00920 }
00921
00928 function getAdminIds($a_grpId="")
00929 {
00930 global $rbacreview;
00931
00932 if (!empty($a_grpId))
00933 {
00934 $grp_id = $a_grpId;
00935 }
00936 else
00937 {
00938 $grp_id = $this->getRefId();
00939 }
00940
00941 $usr_arr = array();
00942 $roles = $this->getDefaultRoles($this->getRefId());
00943
00944 foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
00945 {
00946 array_push($usr_arr,$member_id);
00947 }
00948
00949 return $usr_arr;
00950 }
00951
00956 function removeMember(&$a_user_obj)
00957 {
00958 if (!isset($a_user_obj))
00959 {
00960 $this->error_msg = get_class($this)."::removeMember(): Missing parameters !";
00961 return false;
00962 }
00963
00964 if (!$this->isMember($a_user_obj->getId()))
00965 {
00966 return true;
00967 }
00968
00969 if (count($this->getMemberIds()) > 1)
00970 {
00971 if ($this->isAdmin($a_user_obj->getId()) && count($this->getAdminIds()) < 2)
00972 {
00973 $this->error_msg = "ilinc_err_administrator_required";
00974 return false;
00975 }
00976 }
00977
00978
00979 if (!$this->unregisterUser($a_user_obj))
00980 {
00981
00982 return false;
00983 }
00984
00985 $this->leave($a_user_obj->getId());
00986
00987 return true;
00988 }
00989
00996 function isAdmin($a_user_id)
00997 {
00998 global $rbacreview;
00999
01000 $icrs_roles = $this->getDefaultRoles();
01001
01002 if (in_array($a_user_id,$rbacreview->assignedUsers($icrs_roles["icrs_admin_role"])))
01003 {
01004 return true;
01005 }
01006 else
01007 {
01008 return false;
01009 }
01010 }
01011
01017 function getDefaultRoles($a_grp_id="")
01018 {
01019 global $rbacadmin, $rbacreview;
01020
01021 if (strlen($a_grp_id) > 0)
01022 {
01023 $grp_id = $a_grp_id;
01024 }
01025 else
01026 {
01027 $grp_id = $this->getRefId();
01028 }
01029
01030 $rolf = $rbacreview->getRoleFolderOfObject($grp_id);
01031 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
01032
01033 foreach ($role_arr as $role_id)
01034 {
01035 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
01036
01037 $grp_Member ="il_icrs_member_".$grp_id;
01038 $grp_Admin ="il_icrs_admin_".$grp_id;
01039
01040 if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
01041 {
01042 $arr_grpDefaultRoles["icrs_member_role"] = $role_Obj->getId();
01043 }
01044
01045 if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
01046 {
01047 $arr_grpDefaultRoles["icrs_admin_role"] = $role_Obj->getId();
01048 }
01049 }
01050
01051 return $arr_grpDefaultRoles;
01052 }
01053
01054
01055 function getiLincMemberIds($a_instructorflag = false)
01056 {
01057 if ($a_instructorflag == true)
01058 {
01059 if (!empty($this->docent_ids))
01060 {
01061 return $this->docent_ids;
01062 }
01063 }
01064 else
01065 {
01066 if (!empty($this->student_ids))
01067 {
01068 return $this->student_ids;
01069 }
01070 }
01071
01072 $this->ilincAPI->findRegisteredUsersByRole($this->getiLincId(),$a_instructorflag);
01073 $response = $this->ilincAPI->sendRequest();
01074
01075 if (is_array($response->data['users']))
01076 {
01077 if ($a_instructorflag == true)
01078 {
01079 $this->docent_ids = array_keys($response->data['users']);
01080 }
01081 else
01082 {
01083 $this->student_ids = array_keys($response->data['users']);
01084 }
01085
01086 return array_keys($response->data['users']);
01087 }
01088
01089 return array();
01090 }
01091
01092 function checkiLincMemberStatus($a_ilinc_user_id,$a_docent_ids,$a_student_ids)
01093 {
01094 if (in_array($a_ilinc_user_id,$a_docent_ids))
01095 {
01096 return ILINC_MEMBER_DOCENT;
01097 }
01098
01099 if (in_array($a_ilinc_user_id,$a_student_ids))
01100 {
01101 return ILINC_MEMBER_STUDENT;
01102 }
01103
01104 return ILINC_MEMBER_NOTSET;
01105 }
01106
01107 function _isActivated($a_course_obj_id)
01108 {
01109 global $ilDB,$ilias;
01110
01111 if (!$ilias->getSetting("ilinc_active"))
01112 {
01113 return false;
01114 }
01115
01116 $q = "SELECT activation_offline FROM ilinc_data WHERE obj_id=".$ilDB->quote($a_course_obj_id);
01117 $r = $ilDB->query($q);
01118
01119 $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
01120
01121 return ilUtil::yn2tf($row->activation_offline);
01122 }
01123
01124 function _getAKClassValues($a_course_obj_id)
01125 {
01126 global $ilDB,$ilias;
01127
01128 $q = "SELECT akclassvalue1, akclassvalue2 FROM ilinc_data WHERE obj_id=".$ilDB->quote($a_course_obj_id);
01129 $r = $ilDB->query($q);
01130
01131 $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
01132
01133 return $akclassvalues = array($row->akclassvalue1,$row->akclassvalue2);
01134 }
01135
01136 function _isMember($a_user_id,$a_ref_id)
01137 {
01138 global $rbacreview;
01139
01140 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
01141 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"],false);
01142 $user_roles = $rbacreview->assignedRoles($a_user_id);
01143
01144 if (!array_intersect($local_roles,$user_roles))
01145 {
01146 return false;
01147 }
01148
01149 return true;
01150 }
01151
01152 function __setCourseStatus()
01153 {
01154
01155 }
01156
01157 function _goto($a_target)
01158 {
01159 global $ilAccess, $ilErr, $lng;
01160
01161 if ($ilAccess->checkAccess("read", "", $a_target))
01162 {
01163 $_GET["cmd"] = "frameset";
01164 $_GET["ref_id"] = $a_target;
01165 }
01166 else
01167 {
01168 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
01169 }
01170 }
01171
01180 function _getLinkToObject($a_id)
01181 {
01182 return array("repository.php?ref_id=".$a_id."&set_mode=flat&cmdClass=ilobjilinccoursegui","");
01183 }
01184 }
01185 ?>