34 require_once
'Services/Container/classes/class.ilContainer.php';
35 require_once
'Modules/ILinc/classes/class.ilnetucateXMLAPI.php';
48 $this->
ilObject($a_id,$a_call_by_reference);
52 $this->docent_ids = array();
53 $this->student_ids = array();
72 $q =
"SELECT * FROM ilinc_data ".
73 "WHERE obj_id = ".$ilDB->quote($this->
id);
74 $r = $ilDB->query($q);
80 $this->ilinc_id =
$data->course_id;
82 $this->akclassvalue1 =
$data->akclassvalue1;
83 $this->akclassvalue2 =
$data->akclassvalue2;
87 $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);
93 return $this->ilinc_id;
98 $err_msg = $this->error_msg;
99 $this->error_msg =
"";
106 return $this->akclassvalue1;
111 return $this->akclassvalue2;
116 $this->akclassvalue1 = $a_str;
121 $this->akclassvalue2 = $a_str;
134 $this->ilincAPI->editCourse($this->
getiLincId(),$_POST[
"Fobject"]);
135 $response = $this->ilincAPI->sendRequest();
137 if ($response->isError())
139 $this->error_msg = $response->getErrorMsg();
145 if (!parent::update())
147 $this->error_msg =
"database_error";
151 $q =
"UPDATE ilinc_data SET ".
152 "activation_offline = ".$ilDB->quote($this->activated).
", ".
153 "akclassvalue1 = ".$ilDB->quote($this->akclassvalue1).
", ".
154 "akclassvalue2 = ".$ilDB->quote($this->akclassvalue2).
" ".
155 "WHERE obj_id = ".$ilDB->quote($this->
getId());
156 $r = $ilDB->query($q);
169 $this->ilincAPI->addCourse($_POST[
"Fobject"]);
170 $response = $this->ilincAPI->sendRequest();
172 if ($response->isError())
174 $this->error_msg = $response->getErrorMsg();
178 $this->ilinc_id = $response->getFirstID();
195 if (!parent::delete())
201 $q =
"DELETE FROM ilinc_data WHERE course_id = ".$ilDB->quote($this->
getiLincId());
207 $this->ilincAPI->removeCourse($this->
getiLincId());
208 $response = $this->ilincAPI->sendRequest();
218 $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).
")";
221 $this->ilinc_id = $a_icrs_id;
229 $q =
"UPDATE ilinc_data SET activation_offline = ".$ilDB->quote($a_activated).
" WHERE obj_id = ".$ilDB->quote($this->
getId());
230 $r = $ilDB->query($q);
238 $q =
"UPDATE ilinc_data SET ".
239 "akclassvalue1= ".$ilDB->quote($a_akclassvalue1).
", ".
240 "akclassvalue2= ".$ilDB->quote($a_akclassvalue2).
" ".
241 "WHERE obj_id= ".$ilDB->quote($this->
getId());
242 $r = $ilDB->query($q);
253 global $rbacadmin, $rbacreview;
260 $roleObj = $rfoldObj->createRole(
"il_icrs_admin_".$this->
getRefId(),
"LearnLinc admin of seminar obj_no.".$this->
getId());
261 $this->m_roleAdminId = $roleObj->getId();
264 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_icrs_admin'";
266 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
269 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"icrs",$rfoldObj->getRefId());
270 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
278 $roleObj = $rfoldObj->createRole(
"il_icrs_member_".$this->
getRefId(),
"LearnLinc admin of seminar obj_no.".$this->
getId());
279 $this->m_roleMemberId = $roleObj->getId();
282 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_icrs_member'";
284 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
287 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"icrs",$rfoldObj->getRefId());
288 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
297 $roles[] = $this->m_roleAdminId;
298 $roles[] = $this->m_roleMemberId;
304 return $roles ? $roles : array();
320 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
332 function addMember(&$a_user_obj, $a_mem_role, $a_instructor =
false)
336 if (!isset($a_user_obj) && !isset($a_mem_role))
338 $this->error_msg = get_class($this).
"::addMember(): Missing parameters !";
346 if ($this->
addUser($a_user_obj) ==
false)
361 $this->
join($a_user_obj->getId(),$a_mem_role);
371 function join($a_user_id, $a_mem_role=
"")
375 if (is_array($a_mem_role))
377 foreach ($a_mem_role as $role)
379 $rbacadmin->assignUser($role,$a_user_id,
false);
384 $rbacadmin->assignUser($a_mem_role,$a_user_id,
false);
400 if (is_array($arr_groupRoles))
402 foreach ($arr_groupRoles as $groupRole)
404 $rbacadmin->deassignUser($groupRole, $a_user_id);
409 $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
423 global $rbacadmin, $rbacreview;
425 $arr_assignedRoles = array();
427 $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->
getLocalRoles());
429 return $arr_assignedRoles;
440 global $rbacadmin, $rbacreview;
446 foreach ($rol as $value)
448 foreach ($rbacreview->assignedUsers($value) as $member_id)
450 array_push($usr_arr,$member_id);
454 $mem_arr = array_unique($usr_arr);
456 return $mem_arr ? $mem_arr : array();
468 global $rbacadmin, $rbacreview,
$ilBench, $ilDB;
472 $q =
"SELECT login,firstname,lastname,title,usr_id,ilinc_id ".
474 "WHERE usr_id IN (".implode(
',',$a_mem_ids).
")";
476 if (is_numeric($active) && $active > -1)
477 $q .=
"AND active = ".$ilDB->quote($active);
479 $r = $ilDB->query($q);
483 $mem_arr[] = array(
"id" => $row->usr_id,
484 "login" => $row->login,
485 "firstname" => $row->firstname,
486 "lastname" => $row->lastname,
487 "ilinc_id" => $row->ilinc_id
491 return $mem_arr ? $mem_arr : array();
502 global $rbacadmin,$rbacreview;
504 if (empty($this->local_roles))
506 $this->local_roles = array();
507 $rolf = $rbacreview->getRoleFolderOfObject($this->
getRefId());
508 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
510 foreach ($role_arr as $role_id)
512 if ($rbacreview->isAssignable($role_id,$rolf[
"ref_id"]) ==
true)
514 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
522 $role_name = $role_Obj->getTitle();
525 $this->local_roles[$role_name] = $role_Obj->getId();
530 return $this->local_roles;
543 include_once (
'./Services/AccessControl/classes/class.ilObjRole.php');
545 $str_member_roles =
"";
547 $q =
"SELECT title ".
549 "LEFT JOIN rbac_ua ON object_data.obj_id=rbac_ua.rol_id ".
550 "WHERE object_data.type = 'role' ".
551 "AND rbac_ua.usr_id = ".$ilDB->quote($a_user_id).
" ".
552 "AND rbac_ua.rol_id IN (".implode(
',',$this->
getLocalRoles()).
")";
554 $r = $ilDB->query($q);
562 return substr($str_member_roles,0,-2);
573 return $local_icrs_Roles[
"il_icrs_member_".$this->getRefId()];
584 return $local_icrs_Roles[
"il_icrs_admin_".$this->getRefId()];
591 if (!$this->ilias->getSetting(
"ilinc_active"))
593 $this->error_msg =
"ilinc_server_not_active";
597 $this->ilincAPI->findCourseClasses($this->
getiLincId());
598 $response = $this->ilincAPI->sendRequest();
600 if ($response->isError())
602 if (!$response->getErrorMsg())
604 $this->error_msg =
"err_get_classrooms";
608 $this->error_msg = $response->getErrorMsg();
614 if (!$response->data[
'classes'])
617 $this->error_msg = $response->data[
'result'][
'cdata'];
621 foreach ($response->data[
'classes'] as $class_id =>
$data)
623 $this->ilincAPI->findClass($class_id);
624 $response = $this->ilincAPI->sendRequest(
"findClass");
626 if ($response->data[
'classes'])
628 $full_class_data[$class_id] = $response->data[
'classes'][$class_id];
632 return $full_class_data;
639 $this->ilincAPI->findCourseClasses($this->
getiLincId());
640 $response = $this->ilincAPI->sendRequest();
642 if ($response->isError())
644 if (!$response->getErrorMsg())
646 $this->error_msg =
"err_get_classrooms";
650 $this->error_msg = $response->getErrorMsg();
656 if (!$response->data[
'classes'])
659 $this->error_msg = $response->data[
'result'][
'cdata'];
663 if (array_key_exists(
'akclassvalue1',$_POST[
"Fobject"]))
665 $data[
"akclassvalue1"] = $_POST[
"Fobject"][
"akclassvalue1"];
668 if (array_key_exists(
'akclassvalue2',$_POST[
"Fobject"]))
670 $data[
"akclassvalue2"] = $_POST[
"Fobject"][
"akclassvalue2"];
673 foreach ($response->data[
'classes'] as $class_id => $data2)
675 include_once(
"./Modules/ILinc/classes/class.ilObjiLincClassroom.php");
678 if (!$icla_obj->update(
$data))
680 $this->error_msg = $icla_obj->getErrorMsg();
697 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
700 if (!$ilinc_user->id and !$ilinc_user->login)
711 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
714 return $ilinc_user->add();
719 if (strlen($a_user_id) == 0)
721 $a_user_id = $this->ilias->account->getId();
726 if (in_array($a_user_id, $arr_members))
738 $a_user_obj =& $this->ilias->account;
743 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
746 if (in_array($ilinc_user->id,$docents))
756 if ($a_instructor ===
true)
758 $a_instructor =
"True";
762 $a_instructor =
"False";
765 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
768 $user[] = array(
'id' => $ilinc_user->id,
'instructor' => $a_instructor);
770 $response = $this->ilincAPI->sendRequest(
"registerUser");
772 if ($response->isError())
774 if (!$response->getErrorMsg())
776 $this->error_msg =
"err_register_user";
780 $this->error_msg = $response->getErrorMsg();
791 foreach ($a_user_arr as $user_id => $instructorflag)
795 if ($instructorflag == ILINC_MEMBER_DOCENT)
800 $ilinc_users[] = array(
'id' => $user_id,
'instructor' => $flag);
803 $this->ilincAPI->registerUser($this->
getiLincId(),$ilinc_users);
804 $response = $this->ilincAPI->sendRequest(
"registerUser");
806 if ($response->isError())
808 if (!$response->getErrorMsg())
810 $this->error_msg =
"err_register_users";
814 $this->error_msg = $response->getErrorMsg();
826 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
830 if ($ilinc_user->id ==
'0')
835 $this->ilincAPI->unregisterUser($this->
getiLincId(),array($ilinc_user->id));
836 $response = $this->ilincAPI->sendRequest();
838 if ($response->isError())
840 if (!$response->getErrorMsg())
842 $this->error_msg =
"err_unregister_user";
846 $this->error_msg = $response->getErrorMsg();
857 $this->ilincAPI->unregisterUser($this->
getiLincId(),$a_ilinc_user_ids);
858 $response = $this->ilincAPI->sendRequest();
860 if ($response->isError())
862 if (!$response->getErrorMsg())
864 $this->error_msg =
"err_unregister_users";
868 $this->error_msg = $response->getErrorMsg();
879 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
882 $this->ilincAPI->userLogin($ilinc_user);
883 $response = $this->ilincAPI->sendRequest(
"userLogin");
885 if ($response->isError())
887 if (!$response->getErrorMsg())
889 $this->error_msg =
"err_user_login";
893 $this->error_msg = $response->getErrorMsg();
900 return $response->data[
'url'][
'cdata'];
906 $this->ilincAPI->uploadPicture($a_user_obj,$a_lang);
907 $response = $this->ilincAPI->sendRequest(
"uploadPicture");
909 if ($response->isError())
911 if (!$response->getErrorMsg())
913 $this->error_msg =
"err_upload_picture";
917 $this->error_msg = $response->getErrorMsg();
924 return $response->data[
'url'][
'cdata'];
937 if (!empty($a_grpId))
949 foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
951 array_push($usr_arr,$member_id);
963 if (!isset($a_user_obj))
965 $this->error_msg = get_class($this).
"::removeMember(): Missing parameters !";
969 if (!$this->
isMember($a_user_obj->getId()))
978 $this->error_msg =
"ilinc_err_administrator_required";
990 $this->
leave($a_user_obj->getId());
1007 if (in_array($a_user_id,$rbacreview->assignedUsers($icrs_roles[
"icrs_admin_role"])))
1024 global $rbacadmin, $rbacreview;
1026 if (strlen($a_grp_id) > 0)
1028 $grp_id = $a_grp_id;
1035 $rolf = $rbacreview->getRoleFolderOfObject($grp_id);
1036 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1038 foreach ($role_arr as $role_id)
1040 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1042 $grp_Member =
"il_icrs_member_".$grp_id;
1043 $grp_Admin =
"il_icrs_admin_".$grp_id;
1045 if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
1047 $arr_grpDefaultRoles[
"icrs_member_role"] = $role_Obj->getId();
1050 if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
1052 $arr_grpDefaultRoles[
"icrs_admin_role"] = $role_Obj->getId();
1056 return $arr_grpDefaultRoles;
1062 if ($a_instructorflag ==
true)
1064 if (!empty($this->docent_ids))
1066 return $this->docent_ids;
1071 if (!empty($this->student_ids))
1073 return $this->student_ids;
1077 $this->ilincAPI->findRegisteredUsersByRole($this->
getiLincId(),$a_instructorflag);
1078 $response = $this->ilincAPI->sendRequest();
1080 if (is_array($response->data[
'users']))
1082 if ($a_instructorflag ==
true)
1084 $this->docent_ids = array_keys($response->data[
'users']);
1088 $this->student_ids = array_keys($response->data[
'users']);
1091 return array_keys($response->data[
'users']);
1099 if (in_array($a_ilinc_user_id,$a_docent_ids))
1101 return ILINC_MEMBER_DOCENT;
1104 if (in_array($a_ilinc_user_id,$a_student_ids))
1106 return ILINC_MEMBER_STUDENT;
1109 return ILINC_MEMBER_NOTSET;
1116 if (!$ilias->getSetting(
"ilinc_active"))
1121 $q =
"SELECT activation_offline FROM ilinc_data WHERE obj_id=".$ilDB->quote($a_course_obj_id);
1122 $r = $ilDB->query($q);
1133 $q =
"SELECT akclassvalue1, akclassvalue2 FROM ilinc_data WHERE obj_id=".$ilDB->quote($a_course_obj_id);
1134 $r = $ilDB->query($q);
1138 return $akclassvalues = array($row->akclassvalue1,$row->akclassvalue2);
1145 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
1146 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
1147 $user_roles = $rbacreview->assignedRoles($a_user_id);
1149 if (!array_intersect($local_roles,$user_roles))
1176 foreach((array)$objects as $key => $object)
1178 $this->items[
'icla'][$key] = $object;
1181 return is_array($this->items) ? $this->items : array();
1194 return array(
"repository.php?ref_id=".$a_id.
"&set_mode=flat&cmdClass=ilobjilinccoursegui",
"");