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()));
281 global $rbacadmin, $rbacreview, $ilDB;
289 $roleObj = $rfoldObj->createRole(
"il_icrs_admin_".$this->
getRefId(),
"LearnLinc admin of seminar obj_no.".$this->
getId());
290 $this->m_roleAdminId = $roleObj->getId();
293 $res = $ilDB->queryf(
'
294 SELECT obj_id FROM object_data WHERE type= %s AND title= %s',
295 array(
'text',
'text'), array(
'rolt',
'il_icrs_admin'));
297 $r = $ilDB->fetchObject(
$res);
299 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
302 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"icrs",$rfoldObj->getRefId());
303 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
311 $roleObj = $rfoldObj->createRole(
"il_icrs_member_".$this->
getRefId(),
"LearnLinc admin of seminar obj_no.".$this->
getId());
312 $this->m_roleMemberId = $roleObj->getId();
315 $res = $ilDB->queryf(
'
316 SELECT obj_id FROM object_data WHERE type= %s AND title= %s',
317 array(
'text',
'text'), array(
'rolt',
'il_icrs_member'));
319 $r = $ilDB->fetchObject(
$res);
321 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
324 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"icrs",$rfoldObj->getRefId());
325 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
334 $roles[] = $this->m_roleAdminId;
335 $roles[] = $this->m_roleMemberId;
341 return $roles ? $roles : array();
357 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
369 function addMember(&$a_user_obj, $a_mem_role, $a_instructor =
false)
373 if (!isset($a_user_obj) && !isset($a_mem_role))
375 $this->error_msg = get_class($this).
"::addMember(): Missing parameters !";
383 if ($this->
addUser($a_user_obj) ==
false)
398 $this->
join($a_user_obj->getId(),$a_mem_role);
408 function join($a_user_id, $a_mem_role=
"")
412 if (is_array($a_mem_role))
414 foreach ($a_mem_role as $role)
416 $rbacadmin->assignUser($role,$a_user_id,
false);
421 $rbacadmin->assignUser($a_mem_role,$a_user_id,
false);
437 if (is_array($arr_groupRoles))
439 foreach ($arr_groupRoles as $groupRole)
441 $rbacadmin->deassignUser($groupRole, $a_user_id);
446 $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
460 global $rbacadmin, $rbacreview;
462 $arr_assignedRoles = array();
464 $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->
getLocalRoles());
466 return $arr_assignedRoles;
477 global $rbacadmin, $rbacreview;
483 foreach ($rol as $value)
485 foreach ($rbacreview->assignedUsers($value) as $member_id)
487 array_push($usr_arr,$member_id);
491 $mem_arr = array_unique($usr_arr);
493 return $mem_arr ? $mem_arr : array();
505 global $rbacadmin, $rbacreview,
$ilBench, $ilDB;
509 $data_types = array();
510 $data_values = array();
511 $cnt_mem_ids = count($a_mem_ids);
513 $query =
'SELECT login,firstname,lastname,title,usr_id,ilinc_id
514 FROM usr_data WHERE usr_id IN ';
516 if (is_array($a_mem_ids) &&
521 foreach($a_mem_ids as $mem_id)
523 array_push($data_values, $mem_id);
524 array_push($data_types,
'integer');
526 if($counter > 0)
$in .=
',';
534 if (is_numeric($active) && $active > -1)
536 $query .=
' AND active = %s';
537 array_push($data_values,$active);
538 array_push($data_types,
'integer');
541 $r = $ilDB->queryf(
$query, $data_types, $data_values);
543 while(
$row = $ilDB->fetchObject($r))
545 $mem_arr[] = array(
"id" =>
$row->usr_id,
546 "login" =>
$row->login,
547 "firstname" =>
$row->firstname,
548 "lastname" =>
$row->lastname,
549 "ilinc_id" =>
$row->ilinc_id
553 return $mem_arr ? $mem_arr : array();
564 global $rbacadmin,$rbacreview;
566 if (empty($this->local_roles))
568 $this->local_roles = array();
569 $rolf = $rbacreview->getRoleFolderOfObject($this->
getRefId());
570 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
572 foreach ($role_arr as $role_id)
574 if ($rbacreview->isAssignable($role_id,$rolf[
"ref_id"]) ==
true)
576 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
584 $role_name = $role_Obj->getTitle();
587 $this->local_roles[$role_name] = $role_Obj->getId();
592 return $this->local_roles;
605 include_once (
'./Services/AccessControl/classes/class.ilObjRole.php');
607 $str_member_roles =
"";
609 $data_types = array();
610 $data_values = array();
612 $query =
'SELECT title FROM object_data
613 LEFT JOIN rbac_ua ON object_data.obj_id = rbac_ua.rol_id
614 WHERE object_data.type = %s
615 AND rbac_ua.usr_id = %s
616 AND rbac_ua.rol_id IN';
618 array_push($data_types,
'text',
'integer');
619 array_push($data_values,
'role', $a_user_id);
622 $cnt_local_roles = count($local_roles);
624 if (is_array($local_roles) &&
625 $cnt_local_roles > 0)
629 foreach($local_roles as $local_role)
631 array_push($data_values, $local_role);
632 array_push($data_types,
'integer');
634 if($counter > 0)
$in .=
',';
641 $cnt_data_values = count($data_values);
642 $cnt_data_types = count($data_types);
644 $r = $ilDB->queryf(
$query, $data_types, $data_values);
652 return substr($str_member_roles,0,-2);
663 return $local_icrs_Roles[
"il_icrs_member_".$this->getRefId()];
674 return $local_icrs_Roles[
"il_icrs_admin_".$this->getRefId()];
681 if (!$this->ilias->getSetting(
"ilinc_active"))
683 $this->error_msg =
"ilinc_server_not_active";
687 $this->ilincAPI->findCourseClasses($this->
getiLincId());
688 $response = $this->ilincAPI->sendRequest();
690 if ($response->isError())
692 if (!$response->getErrorMsg())
694 $this->error_msg =
"err_get_classrooms";
698 $this->error_msg = $response->getErrorMsg();
704 if (!$response->data[
'classes'])
707 $this->error_msg = $response->data[
'result'][
'cdata'];
711 foreach ($response->data[
'classes'] as $class_id => $data)
713 $this->ilincAPI->findClass($class_id);
714 $response = $this->ilincAPI->sendRequest(
"findClass");
716 if ($response->data[
'classes'])
718 $full_class_data[$class_id] = $response->data[
'classes'][$class_id];
722 return $full_class_data;
729 $this->ilincAPI->findCourseClasses($this->
getiLincId());
730 $response = $this->ilincAPI->sendRequest();
732 if ($response->isError())
734 if (!$response->getErrorMsg())
736 $this->error_msg =
"err_get_classrooms";
740 $this->error_msg = $response->getErrorMsg();
746 if (!$response->data[
'classes'])
749 $this->error_msg = $response->data[
'result'][
'cdata'];
753 if (array_key_exists(
'akclassvalue1',
$_POST[
"Fobject"]))
755 $data[
"akclassvalue1"] =
$_POST[
"Fobject"][
"akclassvalue1"];
758 if (array_key_exists(
'akclassvalue2',
$_POST[
"Fobject"]))
760 $data[
"akclassvalue2"] =
$_POST[
"Fobject"][
"akclassvalue2"];
763 foreach ($response->data[
'classes'] as $class_id => $data2)
765 include_once(
"./Modules/ILinc/classes/class.ilObjiLincClassroom.php");
768 if (!$icla_obj->update($data))
770 $this->error_msg = $icla_obj->getErrorMsg();
787 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
790 if (!$ilinc_user->id and !$ilinc_user->login)
801 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
804 return $ilinc_user->add();
809 if (strlen($a_user_id) == 0)
811 $a_user_id = $this->ilias->account->getId();
816 if (in_array($a_user_id, $arr_members))
828 $a_user_obj =& $this->ilias->account;
833 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
836 if (in_array($ilinc_user->id,$docents))
846 if ($a_instructor ===
true)
848 $a_instructor =
"True";
852 $a_instructor =
"False";
855 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
858 $user[] = array(
'id' => $ilinc_user->id,
'instructor' => $a_instructor);
859 $this->ilincAPI->registerUser($this->
getiLincId(),$user);
860 $response = $this->ilincAPI->sendRequest(
"registerUser");
862 if ($response->isError())
864 if (!$response->getErrorMsg())
866 $this->error_msg =
"err_register_user";
870 $this->error_msg = $response->getErrorMsg();
881 foreach ($a_user_arr as $user_id => $instructorflag)
885 if ($instructorflag == ILINC_MEMBER_DOCENT)
890 $ilinc_users[] = array(
'id' => $user_id,
'instructor' => $flag);
893 $this->ilincAPI->registerUser($this->
getiLincId(),$ilinc_users);
894 $response = $this->ilincAPI->sendRequest(
"registerUser");
896 if ($response->isError())
898 if (!$response->getErrorMsg())
900 $this->error_msg =
"err_register_users";
904 $this->error_msg = $response->getErrorMsg();
916 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
920 if ($ilinc_user->id ==
'0')
925 $this->ilincAPI->unregisterUser($this->
getiLincId(),array($ilinc_user->id));
926 $response = $this->ilincAPI->sendRequest();
928 if ($response->isError())
930 if (!$response->getErrorMsg())
932 $this->error_msg =
"err_unregister_user";
936 $this->error_msg = $response->getErrorMsg();
947 $this->ilincAPI->unregisterUser($this->
getiLincId(),$a_ilinc_user_ids);
948 $response = $this->ilincAPI->sendRequest();
950 if ($response->isError())
952 if (!$response->getErrorMsg())
954 $this->error_msg =
"err_unregister_users";
958 $this->error_msg = $response->getErrorMsg();
969 include_once (
'./Modules/ILinc/classes/class.ilObjiLincUser.php');
972 $this->ilincAPI->userLogin($ilinc_user);
973 $response = $this->ilincAPI->sendRequest(
"userLogin");
975 if ($response->isError())
977 if (!$response->getErrorMsg())
979 $this->error_msg =
"err_user_login";
983 $this->error_msg = $response->getErrorMsg();
990 return $response->data[
'url'][
'cdata'];
996 $this->ilincAPI->uploadPicture($a_user_obj,$a_lang);
997 $response = $this->ilincAPI->sendRequest(
"uploadPicture");
999 if ($response->isError())
1001 if (!$response->getErrorMsg())
1003 $this->error_msg =
"err_upload_picture";
1007 $this->error_msg = $response->getErrorMsg();
1014 return $response->data[
'url'][
'cdata'];
1027 if (!empty($a_grpId))
1039 foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
1041 array_push($usr_arr,$member_id);
1053 if (!isset($a_user_obj))
1055 $this->error_msg = get_class($this).
"::removeMember(): Missing parameters !";
1059 if (!$this->
isMember($a_user_obj->getId()))
1068 $this->error_msg =
"ilinc_err_administrator_required";
1080 $this->
leave($a_user_obj->getId());
1097 if (in_array($a_user_id,$rbacreview->assignedUsers($icrs_roles[
"icrs_admin_role"])))
1114 global $rbacadmin, $rbacreview;
1116 if (strlen($a_grp_id) > 0)
1118 $grp_id = $a_grp_id;
1125 $rolf = $rbacreview->getRoleFolderOfObject($grp_id);
1126 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1128 foreach ($role_arr as $role_id)
1130 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1132 $grp_Member =
"il_icrs_member_".$grp_id;
1133 $grp_Admin =
"il_icrs_admin_".$grp_id;
1135 if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
1137 $arr_grpDefaultRoles[
"icrs_member_role"] = $role_Obj->getId();
1140 if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
1142 $arr_grpDefaultRoles[
"icrs_admin_role"] = $role_Obj->getId();
1146 return $arr_grpDefaultRoles;
1152 if ($a_instructorflag ==
true)
1154 if (!empty($this->docent_ids))
1156 return $this->docent_ids;
1161 if (!empty($this->student_ids))
1163 return $this->student_ids;
1167 $this->ilincAPI->findRegisteredUsersByRole($this->
getiLincId(),$a_instructorflag);
1168 $response = $this->ilincAPI->sendRequest();
1170 if (is_array($response->data[
'users']))
1172 if ($a_instructorflag ==
true)
1174 $this->docent_ids = array_keys($response->data[
'users']);
1178 $this->student_ids = array_keys($response->data[
'users']);
1181 return array_keys($response->data[
'users']);
1189 if (in_array($a_ilinc_user_id,$a_docent_ids))
1191 return ILINC_MEMBER_DOCENT;
1194 if (in_array($a_ilinc_user_id,$a_student_ids))
1196 return ILINC_MEMBER_STUDENT;
1199 return ILINC_MEMBER_NOTSET;
1206 if (!$ilias->getSetting(
"ilinc_active"))
1211 $r = $ilDB->queryf(
'
1212 SELECT activation_offline FROM ilinc_data WHERE obj_id = %s',
1213 array(
'integer'), array($a_course_obj_id));
1224 $r = $ilDB->queryf(
'
1225 SELECT akclassvalue1, akclassvalue2 FROM ilinc_data WHERE obj_id = %s',
1226 array(
'integer'), array($a_course_obj_id));
1230 return $akclassvalues = array(
$row->akclassvalue1,
$row->akclassvalue2);
1246 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
1247 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
1248 $user_roles = $rbacreview->assignedRoles($a_user_id);
1250 if (!array_intersect($local_roles,$user_roles))
1277 foreach((array)$objects as $key => $object)
1279 $this->items[
'icla'][$key] = $object;
1282 return is_array($this->items) ? $this->items : array();