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();
73 SELECT * FROM ilinc_data
75 array(
'integer'), array($this->
id));
77 if($ilDB->numRows($r) > 0)
79 $data = $ilDB->fetchObject($r);
81 $this->ilinc_id = $data->course_id;
83 $this->akclassvalue1 = $data->akclassvalue1;
84 $this->akclassvalue2 = $data->akclassvalue2;
88 $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);
94 return $this->ilinc_id;
99 $err_msg = $this->error_msg;
100 $this->error_msg =
"";
107 return $this->akclassvalue1;
112 return $this->akclassvalue2;
117 $this->akclassvalue1 = $a_str;
122 $this->akclassvalue2 = $a_str;
136 $response = $this->ilincAPI->sendRequest();
138 if ($response->isError())
140 $this->error_msg = $response->getErrorMsg();
146 if (!parent::update())
148 $this->error_msg =
"database_error";
152 $db_activated_value = is_bool($this->activated) ? ($this->activated ?
'y' :
'n') : $this->activated;
154 $r = $ilDB->manipulateF(
'
156 SET activation_offline = %s,
160 array(
'text',
'text',
'text',
'integer'),
174 $this->ilincAPI->addCourse(
$_POST[
"Fobject"]);
175 $response = $this->ilincAPI->sendRequest();
177 if ($response->isError())
179 $this->error_msg = $response->getErrorMsg();
183 $this->ilinc_id = $response->getFirstID();
200 if (!parent::delete())
206 $statement = $ilDB->manipulateF(
'
207 DELETE FROM ilinc_data WHERE course_id = %s',
208 array(
'integer'), array($this->
getiLincId()));
223 $this->ilincAPI->removeCourse($this->
getiLincId());
224 $response = $this->ilincAPI->sendRequest();
234 $statement = $ilDB->manipulateF(
'
235 INSERT INTO ilinc_data (
236 obj_id, i_type, course_id, activation_offline)
237 VALUES (%s, %s, %s, %s)',
238 array(
'integer',
'text',
'integer',
'text'),
239 array($this->
id,
'icrs',$a_icrs_id,$this->activated));
241 $this->ilinc_id = $a_icrs_id;
249 $statement = $ilDB->manipulateF(
'
251 SET activation_offline = %s
253 array(
'text',
'integer'),
254 array($a_activated, $this->
getId()));
263 $statement = $ilDB->manipulateF(
'
265 SET akclassvalue1 = %s,
268 array(
'text',
'text',
'integer'),
269 array($a_akclassvalue1, $a_akclassvalue2, $this->
getId()));
287 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
299 function addMember(&$a_user_obj, $a_mem_role, $a_instructor =
false)
303 if (!isset($a_user_obj) && !isset($a_mem_role))
305 $this->error_msg = get_class($this).
"::addMember(): Missing parameters !";
313 if ($this->
addUser($a_user_obj) ==
false)
328 $this->
join($a_user_obj->getId(),$a_mem_role);
338 function join($a_user_id, $a_mem_role=
"")
342 if (is_array($a_mem_role))
344 foreach ($a_mem_role as $role)
346 $rbacadmin->assignUser($role,$a_user_id,
false);
351 $rbacadmin->assignUser($a_mem_role,$a_user_id,
false);
367 if (is_array($arr_groupRoles))
369 foreach ($arr_groupRoles as $groupRole)
371 $rbacadmin->deassignUser($groupRole, $a_user_id);
376 $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
390 global $rbacadmin, $rbacreview;
392 $arr_assignedRoles = array();
394 $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->
getLocalRoles());
396 return $arr_assignedRoles;
407 global $rbacadmin, $rbacreview;
413 foreach ($rol as $value)
415 foreach ($rbacreview->assignedUsers($value) as $member_id)
417 array_push($usr_arr,$member_id);
421 $mem_arr = array_unique($usr_arr);
423 return $mem_arr ? $mem_arr : array();
439 $data_types = array();
440 $data_values = array();
441 $cnt_mem_ids = count($a_mem_ids);
443 $query =
'SELECT login,firstname,lastname,title,usr_id,ilinc_id
444 FROM usr_data WHERE usr_id IN ';
446 if (is_array($a_mem_ids) &&
451 foreach($a_mem_ids as $mem_id)
453 array_push($data_values, $mem_id);
454 array_push($data_types,
'integer');
456 if($counter > 0)
$in .=
',';
464 if (is_numeric($active) && $active > -1)
466 $query .=
' AND active = %s';
467 array_push($data_values,$active);
468 array_push($data_types,
'integer');
471 $r = $ilDB->queryf(
$query, $data_types, $data_values);
473 while(
$row = $ilDB->fetchObject($r))
475 $mem_arr[] = array(
"id" =>
$row->usr_id,
476 "login" =>
$row->login,
477 "firstname" =>
$row->firstname,
478 "lastname" =>
$row->lastname,
479 "ilinc_id" =>
$row->ilinc_id
483 return $mem_arr ? $mem_arr : array();
494 global $rbacadmin,$rbacreview;
496 if (empty($this->local_roles))
498 $this->local_roles = array();
499 $role_arr = $rbacreview->getRolesOfRoleFolder($this->
getRefId());
501 foreach ($role_arr as $role_id)
503 if ($rbacreview->isAssignable($role_id,$this->getRefId()) ==
true)
505 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
513 $role_name = $role_Obj->getTitle();
516 $this->local_roles[$role_name] = $role_Obj->getId();
521 return $this->local_roles;
534 include_once (
'./Services/AccessControl/classes/class.ilObjRole.php');
536 $str_member_roles =
"";
538 $data_types = array();
539 $data_values = array();
541 $query =
'SELECT title FROM object_data
542 LEFT JOIN rbac_ua ON object_data.obj_id = rbac_ua.rol_id
543 WHERE object_data.type = %s
544 AND rbac_ua.usr_id = %s
545 AND rbac_ua.rol_id IN';
547 array_push($data_types,
'text',
'integer');
548 array_push($data_values,
'role', $a_user_id);
551 $cnt_local_roles = count($local_roles);
553 if (is_array($local_roles) &&
554 $cnt_local_roles > 0)
558 foreach($local_roles as $local_role)
560 array_push($data_values, $local_role);
561 array_push($data_types,
'integer');
563 if($counter > 0)
$in .=
',';
570 $cnt_data_values = count($data_values);
571 $cnt_data_types = count($data_types);
573 $r = $ilDB->queryf(
$query, $data_types, $data_values);
581 return substr($str_member_roles,0,-2);
592 return $local_icrs_Roles[
"il_icrs_member_".$this->getRefId()];
603 return $local_icrs_Roles[
"il_icrs_admin_".$this->getRefId()];
610 if (!$this->ilias->getSetting(
"ilinc_active"))
612 $this->error_msg =
"ilinc_server_not_active";
616 $this->ilincAPI->findCourseClasses($this->
getiLincId());
617 $response = $this->ilincAPI->sendRequest();
619 if ($response->isError())
621 if (!$response->getErrorMsg())
623 $this->error_msg =
"err_get_classrooms";
627 $this->error_msg = $response->getErrorMsg();
633 if (!$response->data[
'classes'])
636 $this->error_msg = $response->data[
'result'][
'cdata'];
640 foreach ($response->data[
'classes'] as $class_id => $data)
642 $this->ilincAPI->findClass($class_id);
643 $response = $this->ilincAPI->sendRequest(
"findClass");
645 if ($response->data[
'classes'])
647 $full_class_data[$class_id] = $response->data[
'classes'][$class_id];
651 return $full_class_data;
658 $this->ilincAPI->findCourseClasses($this->
getiLincId());
659 $response = $this->ilincAPI->sendRequest();
661 if ($response->isError())
663 if (!$response->getErrorMsg())
665 $this->error_msg =
"err_get_classrooms";
669 $this->error_msg = $response->getErrorMsg();
675 if (!$response->data[
'classes'])
678 $this->error_msg = $response->data[
'result'][
'cdata'];
682 if (array_key_exists(
'akclassvalue1',
$_POST[
"Fobject"]))
684 $data[
"akclassvalue1"] =
$_POST[
"Fobject"][
"akclassvalue1"];
687 if (array_key_exists(
'akclassvalue2',
$_POST[
"Fobject"]))
689 $data[
"akclassvalue2"] =
$_POST[
"Fobject"][
"akclassvalue2"];
692 foreach ($response->data[
'classes'] as $class_id => $data2)
694 include_once(
"./Modules/ILinc/classes/class.ilObjiLincClassroom.php");
697 if (!$icla_obj->update($data))
699 $this->error_msg = $icla_obj->getErrorMsg();
716 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
719 if (!$ilinc_user->id and !$ilinc_user->login)
730 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
733 return $ilinc_user->add();
738 if (strlen($a_user_id) == 0)
740 $a_user_id = $this->ilias->account->getId();
745 if (in_array($a_user_id, $arr_members))
757 $a_user_obj =& $this->ilias->account;
762 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
765 if (in_array($ilinc_user->id,$docents))
775 if ($a_instructor ===
true)
777 $a_instructor =
"True";
781 $a_instructor =
"False";
784 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
787 $user[] = array(
'id' => $ilinc_user->id,
'instructor' => $a_instructor);
788 $this->ilincAPI->registerUser($this->
getiLincId(),$user);
789 $response = $this->ilincAPI->sendRequest(
"registerUser");
791 if ($response->isError())
793 if (!$response->getErrorMsg())
795 $this->error_msg =
"err_register_user";
799 $this->error_msg = $response->getErrorMsg();
810 foreach ($a_user_arr as $user_id => $instructorflag)
814 if ($instructorflag == ILINC_MEMBER_DOCENT)
819 $ilinc_users[] = array(
'id' => $user_id,
'instructor' => $flag);
822 $this->ilincAPI->registerUser($this->
getiLincId(),$ilinc_users);
823 $response = $this->ilincAPI->sendRequest(
"registerUser");
825 if ($response->isError())
827 if (!$response->getErrorMsg())
829 $this->error_msg =
"err_register_users";
833 $this->error_msg = $response->getErrorMsg();
845 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
849 if ($ilinc_user->id ==
'0')
854 $this->ilincAPI->unregisterUser($this->
getiLincId(),array($ilinc_user->id));
855 $response = $this->ilincAPI->sendRequest();
857 if ($response->isError())
859 if (!$response->getErrorMsg())
861 $this->error_msg =
"err_unregister_user";
865 $this->error_msg = $response->getErrorMsg();
876 $this->ilincAPI->unregisterUser($this->
getiLincId(),$a_ilinc_user_ids);
877 $response = $this->ilincAPI->sendRequest();
879 if ($response->isError())
881 if (!$response->getErrorMsg())
883 $this->error_msg =
"err_unregister_users";
887 $this->error_msg = $response->getErrorMsg();
898 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
901 $this->ilincAPI->userLogin($ilinc_user);
902 $response = $this->ilincAPI->sendRequest(
"userLogin");
904 if ($response->isError())
906 if (!$response->getErrorMsg())
908 $this->error_msg =
"err_user_login";
912 $this->error_msg = $response->getErrorMsg();
919 return $response->data[
'url'][
'cdata'];
925 $this->ilincAPI->uploadPicture($a_user_obj,$a_lang);
926 $response = $this->ilincAPI->sendRequest(
"uploadPicture");
928 if ($response->isError())
930 if (!$response->getErrorMsg())
932 $this->error_msg =
"err_upload_picture";
936 $this->error_msg = $response->getErrorMsg();
943 return $response->data[
'url'][
'cdata'];
956 if (!empty($a_grpId))
968 foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
970 array_push($usr_arr,$member_id);
982 if (!isset($a_user_obj))
984 $this->error_msg = get_class($this).
"::removeMember(): Missing parameters !";
988 if (!$this->
isMember($a_user_obj->getId()))
997 $this->error_msg =
"ilinc_err_administrator_required";
1009 $this->
leave($a_user_obj->getId());
1026 if (in_array($a_user_id,$rbacreview->assignedUsers($icrs_roles[
"icrs_admin_role"])))
1043 global $rbacadmin, $rbacreview;
1045 if (strlen($a_grp_id) > 0)
1047 $grp_id = $a_grp_id;
1054 $role_arr = $rbacreview->getRolesOfRoleFolder($grp_id);
1056 foreach ($role_arr as $role_id)
1058 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1060 $grp_Member =
"il_icrs_member_".$grp_id;
1061 $grp_Admin =
"il_icrs_admin_".$grp_id;
1063 if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
1065 $arr_grpDefaultRoles[
"icrs_member_role"] = $role_Obj->getId();
1068 if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
1070 $arr_grpDefaultRoles[
"icrs_admin_role"] = $role_Obj->getId();
1074 return $arr_grpDefaultRoles;
1080 if ($a_instructorflag ==
true)
1082 if (!empty($this->docent_ids))
1084 return $this->docent_ids;
1089 if (!empty($this->student_ids))
1091 return $this->student_ids;
1095 $this->ilincAPI->findRegisteredUsersByRole($this->
getiLincId(),$a_instructorflag);
1096 $response = $this->ilincAPI->sendRequest();
1098 if (is_array($response->data[
'users']))
1100 if ($a_instructorflag ==
true)
1102 $this->docent_ids = array_keys($response->data[
'users']);
1106 $this->student_ids = array_keys($response->data[
'users']);
1109 return array_keys($response->data[
'users']);
1117 if (in_array($a_ilinc_user_id,$a_docent_ids))
1119 return ILINC_MEMBER_DOCENT;
1122 if (in_array($a_ilinc_user_id,$a_student_ids))
1124 return ILINC_MEMBER_STUDENT;
1127 return ILINC_MEMBER_NOTSET;
1134 if (!$ilias->getSetting(
"ilinc_active"))
1139 $r = $ilDB->queryf(
'
1140 SELECT activation_offline FROM ilinc_data WHERE obj_id = %s',
1141 array(
'integer'), array($a_course_obj_id));
1152 $r = $ilDB->queryf(
'
1153 SELECT akclassvalue1, akclassvalue2 FROM ilinc_data WHERE obj_id = %s',
1154 array(
'integer'), array($a_course_obj_id));
1158 return $akclassvalues = array(
$row->akclassvalue1,
$row->akclassvalue2);
1174 $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
1175 $user_roles = $rbacreview->assignedRoles($a_user_id);
1177 if (!array_intersect($local_roles,$user_roles))
1204 foreach((array)$objects as $key => $object)
1206 $this->items[
'icla'][$key] = $object;
1209 return is_array($this->items) ? $this->items : array();