56 if (self::$instance ===
null) {
57 self::$instance =
new self();
59 if (!self::isMyStaffActive()) {
63 self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS .
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION .
"_"
64 . self::COURSE_CONTEXT);
65 self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS .
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION
66 .
"_" . self::COURSE_CONTEXT);
67 self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS .
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION
68 .
"_" . self::COURSE_CONTEXT);
69 self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS .
"_user_id_" .
$DIC->user()->getId());
70 self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS .
"_user_id_" .
$DIC->user()->getId());
71 self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX .
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION .
"_"
72 . self::COURSE_CONTEXT);
86 return (
bool)
$DIC->settings()->get(
'enable_my_staff');
93 if (!self::isMyStaffActive()) {
124 if (!self::isMyStaffActive()) {
128 $cert_set = new \ilSetting(
"certificate");
129 if (!$cert_set->get(
"active")) {
133 if ($this->countOrgusOfUserWithOperationAndContext(
134 $DIC->user()->getId(),
143 if ($this->countOrgusOfUserWithOperationAndContext(
144 $DIC->user()->getId(),
146 self::EXERCISE_CONTEXT
153 if ($this->countOrgusOfUserWithOperationAndContext(
154 $DIC->user()->getId(),
170 if (!self::isMyStaffActive()) {
174 if ($this->countOrgusOfUserWithOperationAndContext(
175 $DIC->user()->getId(),
177 self::EMPLOYEE_TALK_CONTEXT
184 if ($this->countOrgusOfUserWithOperationAndContext(
185 $DIC->user()->getId(),
187 self::EMPLOYEE_TALK_CONTEXT
194 if ($this->countOrgusOfUserWithOperationAndContext(
195 $DIC->user()->getId(),
197 self::EMPLOYEE_TALK_CONTEXT
211 if (!self::isMyStaffActive()) {
215 $skmg_set = new \ilSkillManagementSettings();
216 if (!$skmg_set->isActivated()) {
220 if ($this->countOrgusOfUserWithOperationAndContext(
221 $DIC->user()->getId(),
230 if ($this->countOrgusOfUserWithOperationAndContext(
231 $DIC->user()->getId(),
240 if ($this->countOrgusOfUserWithOperationAndContext(
241 $DIC->user()->getId(),
250 if ($this->countOrgusOfUserWithOperationAndContext(
251 $DIC->user()->getId(),
267 if (!self::isMyStaffActive()) {
271 if ($this->countOrgusOfUserWithOperationAndContext(
272 $DIC->user()->getId(),
273 self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION,
293 if (!self::isMyStaffActive()) {
298 if (count($arr_users) > 0 && $usr_id === 0) {
302 if (count($arr_users) > 0 && in_array($usr_id, $arr_users)) {
321 $DIC->user()->getId(),
325 if (count($arr_usr_id) > 0) {
336 $q =
"SELECT COUNT(orgu_ua.orgu_id) AS 'cnt' FROM il_orgu_permissions AS perm
337 INNER JOIN il_orgu_ua AS orgu_ua ON orgu_ua.position_id = perm.position_id
338 INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context is not NULL
339 WHERE orgu_ua.user_id = " .
$DIC->database()->quote(
342 ) .
" AND perm.operations is not NULL AND perm.parent_id = -1";
344 $set =
$DIC->database()->query(
$q);
345 $rec =
$DIC->database()->fetchAssoc($set);
350 public function countOrgusOfUserWithOperationAndContext(
352 string $org_unit_operation_string,
362 $q =
"SELECT COUNT(orgu_ua.orgu_id) AS cnt FROM il_orgu_permissions AS perm
363 INNER JOIN il_orgu_ua AS orgu_ua ON orgu_ua.position_id = perm.position_id
364 INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context = '" .
$context .
"'
365 and orgu_ua.user_id = " .
$DIC->database()->quote(
368 ) .
" AND perm.operations REGEXP '[\\\[,]\"?"
369 . $operation->getOperationId() .
"\"?[\],]'";
371 $set =
$DIC->database()->query(
$q);
372 $rec =
$DIC->database()->fetchAssoc($set);
379 string $org_unit_operation_string,
381 string $tmp_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX
385 $tmp_table_name = $this->buildTempTableIlobjectsUserMatrixForUserOperationAndContext(
387 $org_unit_operation_string,
389 $tmp_table_name_prefix
392 $q =
'SELECT usr_id FROM ' . $tmp_table_name;
394 $user_set =
$DIC->database()->query(
$q);
396 $arr_users = array();
398 while ($rec =
$DIC->database()->fetchAssoc($user_set)) {
399 $arr_users[$rec[
'usr_id']] = $rec[
'usr_id'];
409 foreach ($user_assignments as $user_assignment) {
410 $users[$user_assignment->getPositionId()] = $this->getUsersForUser(
412 $user_assignment->getPositionId()
426 if (isset($this->users_for_user[
$user_id]) && $position_id ===
null) {
427 return $this->users_for_user[
$user_id];
430 $tmp_orgu_members = $this->buildTempTableOrguMemberships(
431 self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS,
435 $position_limitation =
'';
436 if (!is_null($position_id)) {
437 $position_limitation =
' AND orgu_ua_current_user.position_id = ' . $position_id;
440 $q =
"SELECT " . $tmp_orgu_members .
".user_id AS usr_id
442 " . $tmp_orgu_members .
"
443 INNER JOIN il_orgu_ua AS orgu_ua_current_user on orgu_ua_current_user.user_id = " .
$DIC->database()->quote(
447 INNER JOIN il_orgu_authority AS auth ON auth.position_id = orgu_ua_current_user.position_id " . $position_limitation .
"
450 /* Identische OrgUnit wie Current User; Nicht Rekursiv; Fixe Position */
451 (orgu_ua_current_user.orgu_id = " . $tmp_orgu_members .
".orgu_id AND auth.scope = 1
452 AND auth.over = " . $tmp_orgu_members .
".user_position_id AND auth.over <> -1
455 /* Identische OrgUnit wie Current User; Nicht Rekursiv; Position egal */
456 (orgu_ua_current_user.orgu_id = " . $tmp_orgu_members .
".orgu_id AND auth.scope = 1 AND auth.over = -1)
458 /* Kinder OrgUnit wie Current User */
461 " . $tmp_orgu_members .
".orgu_id = orgu_ua_current_user.orgu_id OR
462 " . $tmp_orgu_members .
".tree_path LIKE CONCAT(\"%.\",orgu_ua_current_user.orgu_id ,\".%\")
464 " . $tmp_orgu_members .
".tree_path LIKE CONCAT(\"%.\",orgu_ua_current_user.orgu_id )
470 /* Gleiche Position */
471 auth.over = " . $tmp_orgu_members .
".user_position_id AND auth.over <> -1
484 $user_set =
$DIC->database()->query(
$q);
486 $arr_users = array();
488 while ($rec =
$DIC->database()->fetchAssoc($user_set)) {
489 $arr_users[$rec[
'usr_id']] = $rec[
'usr_id'];
492 if ($position_id ===
null) {
493 $this->users_for_user[
$user_id] = $arr_users;
503 foreach ($user_assignments as $user_assignment) {
504 $ref_ids = $this->getIdsForPositionAndOperation(
505 $user_assignment->getPositionId(),
509 if (count($ref_ids) > 0) {
510 $ids = array_merge($ids, $ref_ids);
520 $ref_ids = $this->getIdsForPositionAndOperationAndContext(
526 if (count($ref_ids) > 0) {
527 $ids = array_merge($ids, $ref_ids);
539 public function getIdsForPositionAndOperationAndContext(
551 if (is_null($operation_object)) {
555 $operation_id = $operation_object->getOperationId();
557 if ($this->hasPositionDefaultPermissionForOperationInContext($position_id, $operation_id, $context_id)) {
558 $query =
"select " . ($return_ref_id ?
"object_reference.ref_id" :
"object_data.obj_id") .
" from object_data " .
559 "inner join object_reference on object_reference.obj_id = object_data.obj_id " .
560 "where type = '" .
$context .
"' " .
561 "AND object_reference.ref_id not in " .
562 " (SELECT parent_id FROM il_orgu_permissions " .
563 " where position_id = " . $position_id .
" and context_id = " . $context_id .
" and operations NOT REGEXP '[\\\[,]\"?" . $operation_id .
"\"?[\],]' and parent_id <> -1)";
565 $query = $return_ref_id
567 "SELECT parent_id as ref_id FROM il_orgu_permissions "
569 "SELECT obj_id FROM il_orgu_permissions INNER JOIN object_reference ON object_reference.ref_id = il_orgu_permissions.parent_id ";
570 $query .=
" where position_id = " . $position_id .
" and context_id = " . $context_id .
" and operations REGEXP '[\\\[,]\"?" . $operation_id .
"\"?[\],]' and parent_id <> -1";
573 return array_map(
function ($item) use ($return_ref_id) {
574 return $return_ref_id ? $item[
'ref_id'] : $item[
'obj_id'];
575 },
$DIC->database()->fetchAll(
$DIC->database()->query($query)));
584 $res =
$DIC->database()->query(
"SELECT * FROM il_orgu_permissions " .
585 " WHERE context_id = " . $context_id .
" " .
586 "AND operations REGEXP '[\\\[,]\"?" . $operation_id .
"\"?[\],]' " .
587 "AND position_id = " . $position_id .
" " .
588 "AND parent_id = -1");
590 return (
bool)
$DIC->database()->numRows(
$res) > 0;
595 string $org_unit_operation_string,
604 $tmp_table_name =
'tmp_ilobj_user_matrix_' . $operation->getOperationId();
606 $this->buildTempTableIlobjectsUserMatrixForUserOperationAndContext(
608 $org_unit_operation_string,
613 $q =
'SELECT * FROM ' . $tmp_table_name;
615 $user_set =
$DIC->database()->query(
$q);
617 $arr_user_obj = array();
619 while ($rec =
$DIC->database()->fetchAssoc($user_set)) {
620 $arr_user_obj[] = $rec;
623 return $arr_user_obj;
628 string $org_unit_operation_string,
630 string $temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX
634 $temporary_table_name = $temporary_table_name_prefix .
"_" . $org_unit_operation_string .
"_" .
$context;
642 $tmp_table_objects_specific_perimissions = $this->buildTempTableIlobjectsSpecificPermissionSetForOperationAndContext(
643 $org_unit_operation_string,
645 self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS
648 $tmp_table_objects_default_perimissions = $this->buildTempTableIlobjectsDefaultPermissionSetForOperationAndContext(
649 $org_unit_operation_string,
651 self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS
654 $tmp_table_orgunit_default_perimissions = $this->buildTempTableIlorgunitDefaultPermissionSetForOperationAndContext(
655 $org_unit_operation_string,
657 self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS
660 $tmp_table_course_members = $this->buildTempTableCourseMemberships(
661 self::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS,
665 $tmp_table_orgu_members = $this->buildTempTableOrguMemberships(
666 self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS,
670 $tmp_table_orgu_member_path = $this->buildTempTableOrguMemberships(
671 'tmp_orgu_members_path',
675 if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX .
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION .
"_"
676 . self::COURSE_CONTEXT
678 $this->dropTempTable($temporary_table_name);
681 $q =
"CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name .
" AS (
682 SELECT DISTINCT user_perm_matrix.perm_for_ref_id, user_perm_matrix.usr_id FROM
684 SELECT crs.*," . $tmp_table_course_members .
".ref_id," . $tmp_table_course_members .
".usr_id FROM
686 SELECT * FROM " . $tmp_table_objects_specific_perimissions .
"
688 SELECT * FROM " . $tmp_table_objects_default_perimissions .
"
690 INNER JOIN " . $tmp_table_course_members .
" on " . $tmp_table_course_members .
".ref_id = crs.perm_for_ref_id
693 " . $tmp_table_course_members .
".orgu_id = crs.perm_for_orgu_id AND " . $tmp_table_course_members .
".position_id = crs.perm_over_user_with_position AND perm_orgu_scope = 1
695 or perm_orgu_scope = 2
698 SELECT " . $tmp_table_orgunit_default_perimissions .
".*, " . $tmp_table_orgu_members .
".orgu_id AS ref_id, "
699 . $tmp_table_orgu_members .
".user_id FROM " . $tmp_table_orgunit_default_perimissions .
"
700 INNER JOIN " . $tmp_table_orgu_members .
" on " . $tmp_table_orgu_members .
".orgu_id = "
701 . $tmp_table_orgunit_default_perimissions .
".perm_for_ref_id
704 " . $tmp_table_orgu_members .
".orgu_id = " . $tmp_table_orgunit_default_perimissions .
".perm_for_orgu_id AND "
705 . $tmp_table_orgu_members .
".user_position_id = " . $tmp_table_orgunit_default_perimissions .
".perm_over_user_with_position AND perm_orgu_scope = 1
707 or perm_orgu_scope = 2
710 ) AS user_perm_matrix
711 INNER JOIN " . $tmp_table_orgu_member_path .
" AS path on path.user_id = user_perm_matrix.usr_id
713 INNER JOIN il_orgu_ua AS orgu_ua_current_user on orgu_ua_current_user.user_id = " .
$DIC->database()->quote(
717 INNER JOIN il_orgu_permissions AS perm on perm.position_id = orgu_ua_current_user.position_id AND perm.parent_id = -1
718 INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context = '$context'
719 and perm.operations REGEXP '[\\\[,]\"?" . $operation->getOperationId() .
"\"?[\],]'
723 /* Identische OrgUnit wie Current User; Nicht Rekursiv; Fixe Position */
724 (orgu_ua_current_user.orgu_id = user_perm_matrix.perm_for_orgu_id AND user_perm_matrix.perm_orgu_scope = 1
725 AND orgu_ua_current_user.position_id = user_perm_matrix.perm_for_position_id AND user_perm_matrix.perm_over_user_with_position <> -1
728 /* Identische OrgUnit wie Current User; Nicht Rekursiv; Position egal */
729 (orgu_ua_current_user.orgu_id = user_perm_matrix.perm_for_orgu_id AND user_perm_matrix.perm_orgu_scope = 1 AND user_perm_matrix.perm_over_user_with_position = -1)
731 /* Kinder OrgUnit wie Current User */
733 orgu_ua_current_user.orgu_id = user_perm_matrix.perm_for_orgu_id
736 path.orgu_id = user_perm_matrix.perm_for_orgu_id OR
737 path.tree_path LIKE CONCAT(\"%.\",user_perm_matrix.perm_for_orgu_id ,\".%\")
739 path.tree_path LIKE CONCAT(\"%.\",user_perm_matrix.perm_for_orgu_id )
745 /* Gleiche Position */
746 orgu_ua_current_user.position_id = user_perm_matrix.perm_for_position_id AND user_perm_matrix.perm_over_user_with_position <> -1
751 user_perm_matrix.perm_over_user_with_position = -1
754 AND user_perm_matrix.perm_orgu_scope = 2
760 $DIC->database()->manipulate(
$q);
762 return $temporary_table_name;
766 string $org_unit_operation_string,
768 string $temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS
772 $temporary_table_name = $temporary_table_name_prefix .
"_" . $org_unit_operation_string .
"_" .
$context;
777 if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS .
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION .
"_"
778 . self::COURSE_CONTEXT
780 $this->dropTempTable($temporary_table_name);
783 $q =
"CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name .
"
784 (INDEX i1 (perm_for_ref_id), INDEX i2 (perm_for_orgu_id), INDEX i3 (perm_orgu_scope), INDEX i4 (perm_for_position_id), INDEX i5 (perm_over_user_with_position))
787 obj_ref.ref_id AS perm_for_ref_id,
788 orgu_ua.orgu_id AS perm_for_orgu_id,
789 auth.scope AS perm_orgu_scope,
790 orgu_ua.position_id AS perm_for_position_id,
791 auth.over AS perm_over_user_with_position
793 il_orgu_permissions AS perm
794 INNER JOIN il_orgu_ua AS orgu_ua ON orgu_ua.position_id = perm.position_id
795 INNER JOIN il_orgu_authority AS auth ON auth.position_id = orgu_ua.position_id AND orgu_ua.user_id = " .
$GLOBALS[
'DIC']->user()
797 INNER JOIN object_reference AS obj_ref ON obj_ref.ref_id = perm.parent_id
798 INNER JOIN object_data AS obj ON obj.obj_id = obj_ref.obj_id AND obj.type = '$context'
799 INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context = '$context'
801 perm.operations REGEXP '[\\\[,]\"?" . $operation->getOperationId() .
"\"?[\],]'
804 $DIC->database()->manipulate(
$q);
806 return $temporary_table_name;
809 public function buildTempTableIlobjectsDefaultPermissionSetForOperationAndContext(
810 string $org_unit_operation_string,
812 string $temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS
816 $temporary_table_name = $temporary_table_name_prefix .
"_" . $org_unit_operation_string .
"_" .
$context;
823 if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS .
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION .
"_"
824 . self::COURSE_CONTEXT
826 $this->dropTempTable($temporary_table_name);
829 $q =
"CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name .
"
830 (INDEX i1 (perm_for_ref_id), INDEX i2 (perm_for_orgu_id), INDEX i3 (perm_orgu_scope), INDEX i4 (perm_for_position_id),INDEX i5 (perm_over_user_with_position))
833 obj_ref.ref_id AS perm_for_ref_id,
834 orgu_ua.orgu_id AS perm_for_orgu_id,
835 auth.scope AS perm_orgu_scope,
836 orgu_ua.position_id AS perm_for_position_id,
837 auth.over AS perm_over_user_with_position
840 INNER JOIN object_reference AS obj_ref ON obj_ref.obj_id = obj.obj_id
841 INNER JOIN il_orgu_permissions AS perm ON perm.operations REGEXP '[\\\[,]\"?" . $operation->getOperationId() .
"\"?[\],]' AND perm.parent_id = -1
842 INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context = '" .
$context .
"'
843 INNER JOIN il_orgu_ua AS orgu_ua ON orgu_ua.position_id = perm.position_id AND orgu_ua.user_id = " .
$GLOBALS[
'DIC']->user()
845 INNER JOIN il_orgu_authority AS auth ON auth.position_id = orgu_ua.position_id
849 AND (obj_ref.ref_id , orgu_ua.position_id)
852 perm.parent_id, orgu_ua.position_id
854 il_orgu_permissions AS perm
855 INNER JOIN il_orgu_ua AS orgu_ua ON orgu_ua.position_id = perm.position_id
856 INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context = '" .
$context .
"'
857 WHERE perm.parent_id <> -1)
860 $DIC->database()->manipulate(
$q);
862 return $temporary_table_name;
871 public function buildTempTableIlorgunitDefaultPermissionSetForOperationAndContext(
872 string $org_unit_operation_string,
874 string $temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS
878 $temporary_table_name = $temporary_table_name_prefix .
"_" . $org_unit_operation_string .
"_" .
$context;
884 if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS .
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION .
"_"
885 . self::COURSE_CONTEXT
887 $this->dropTempTable($temporary_table_name);
890 $q =
"CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name .
"
891 (INDEX i1 (perm_for_ref_id), INDEX i2 (perm_for_orgu_id), INDEX i3 (perm_orgu_scope), INDEX i4 (perm_for_position_id), INDEX i5 (perm_over_user_with_position))
894 orgu_ua.orgu_id AS perm_for_ref_id, /* Table has to be identical to the other Permission For Operation And Context-Tables! */
895 orgu_ua.orgu_id AS perm_for_orgu_id,
896 auth.scope AS perm_orgu_scope,
897 orgu_ua.position_id AS perm_for_position_id,
898 auth.over AS perm_over_user_with_position
900 il_orgu_permissions AS perm
901 INNER JOIN il_orgu_ua AS orgu_ua ON orgu_ua.position_id = perm.position_id AND perm.parent_id = -1 AND orgu_ua.user_id = "
902 .
$GLOBALS[
'DIC']->user()->getId() .
"
903 INNER JOIN il_orgu_authority AS auth ON auth.position_id = orgu_ua.position_id
904 INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context = '" .
$context .
"'
906 perm.operations REGEXP '[\\\[,]\"?" . $operation->getOperationId() .
"\"?[\],]'
909 $DIC->database()->manipulate(
$q);
911 return $temporary_table_name;
915 string $temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS,
916 array $only_courses_of_user_ids = array()
920 $temporary_table_name = $temporary_table_name_prefix .
"_user_id_" .
$DIC->user()->getId();
922 if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS .
"_user_id_" .
$DIC->user()->getId()
923 || count($only_courses_of_user_ids) > 0
925 $this->dropTempTable($temporary_table_name);
928 $q =
"CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name .
"
929 (INDEX i1(ref_id), INDEX i2 (usr_id), INDEX i3 (position_id), INDEX i4 (orgu_id))
931 SELECT crs_members_crs_ref.ref_id, crs_members.usr_id, orgu_ua.position_id, orgu_ua.orgu_id
933 SELECT obj_id, usr_id FROM obj_members WHERE admin > 0 OR tutor > 0 OR member > 0
934 AND " .
$DIC->database()->in(
935 'obj_members.usr_id',
936 $only_courses_of_user_ids,
941 SELECT obj_id, usr_id FROM crs_waiting_list
942 WHERE " .
$DIC->database()->in(
943 'crs_waiting_list.usr_id',
944 $only_courses_of_user_ids,
949 SELECT obj_id, usr_id FROM il_subscribers
950 WHERE " .
$DIC->database()->in(
951 'il_subscribers.usr_id',
952 $only_courses_of_user_ids,
957 INNER JOIN object_reference AS crs_members_crs_ref on crs_members_crs_ref.obj_id = crs_members.obj_id
958 INNER JOIN il_orgu_ua AS orgu_ua on orgu_ua.user_id = crs_members.usr_id
961 $DIC->database()->manipulate(
$q);
963 return $temporary_table_name;
967 string $temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS,
968 array $only_orgus_of_user_ids = array()
972 $temporary_table_name = $temporary_table_name_prefix .
"_user_id_" .
$DIC->user()->getId();
974 if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS .
"_user_id_" .
$DIC->user()->getId()
975 || count($only_orgus_of_user_ids) > 0
977 $this->dropTempTable($temporary_table_name);
980 $q =
"CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name .
"
981 (INDEX i1(orgu_id), INDEX i2 (tree_path(255)), INDEX i3 (tree_child), INDEX i4 (tree_parent), INDEX i5 (tree_lft), INDEX i6 (tree_rgt), INDEX i7 (user_position_id), INDEX i8 (user_id))
983 SELECT orgu_ua.orgu_id AS orgu_id,
984 tree_orgu.path AS tree_path,
985 tree_orgu.child AS tree_child,
986 tree_orgu.parent AS tree_parent,
987 tree_orgu.lft AS tree_lft,
988 tree_orgu.rgt AS tree_rgt,
989 orgu_ua.position_id AS user_position_id,
990 orgu_ua.user_id AS user_id
992 il_orgu_ua AS orgu_ua
993 INNER JOIN object_reference AS obj_ref on obj_ref.ref_id = orgu_ua.orgu_id AND obj_ref.deleted is null
994 LEFT JOIN tree AS tree_orgu ON tree_orgu.child = orgu_ua.orgu_id";
996 if (count($only_orgus_of_user_ids) > 0) {
997 $q .=
" WHERE " .
$DIC->database()->in(
'orgu_ua.user_id', $only_orgus_of_user_ids,
false,
'integer') .
" ";
1002 $DIC->database()->manipulate(
$q);
1004 return $temporary_table_name;
1011 $q =
"DROP TABLE IF EXISTS " . $temporary_table_name;
1012 $DIC->database()->manipulate(
$q);
const string TEST_CONTEXT
getIlobjectsAndUsersForUserOperationAndContext(int $user_id, string $org_unit_operation_string, string $context)
getUsersForUserPerPosition(int $user_id)
countOrgusOfUserWithAtLeastOneOperation(int $user_id)
getUsersForUserOperationAndContext(int $user_id, string $org_unit_operation_string, string $context, string $tmp_table_name_prefix=self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX)
const string EMPLOYEE_TALK_CONTEXT
hasCurrentUserAccessToStaffList()
hasCurrentUserAccessToCourseMemberships()
buildTempTableOrguMemberships(string $temporary_table_name_prefix=self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS, array $only_orgus_of_user_ids=array())
hasCurrentUserAccessToLearningProgressInObject(int $ref_id=0)
const string TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS
buildTempTableCourseMemberships(string $temporary_table_name_prefix=self::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS, array $only_courses_of_user_ids=array())
hasCurrentUserAccessToCourseLearningProgressForAtLeastOneUser()
hasCurrentUserAccessToCompetences()
hasPositionDefaultPermissionForOperationInContext(int $position_id, int $operation_id, int $context_id)
const string ACCESS_ENROLMENTS_ORG_UNIT_OPERATION
const string TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS
hasCurrentUserAccessToMyStaff()
const string TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS
const string COURSE_CONTEXT
getIdsForPositionAndOperation(int $position_id, string $operation, bool $return_ref_id)
const string GROUP_CONTEXT
const string EXERCISE_CONTEXT
getUsersForUser(int $user_id, ?int $position_id=null)
dropTempTable(string $temporary_table_name)
hasCurrentUserAccessToUser(int $usr_id)
getIdsForUserAndOperation(int $user_id, string $operation, bool $return_ref_id=false)
const string TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS
const string SURVEY_CONTEXT
hasCurrentUserAccessToTalks()
const string TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS
const string TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX
hasCurrentUserAccessToCertificates()
buildTempTableIlobjectsUserMatrixForUserOperationAndContext(int $user_id, string $org_unit_operation_string, string $context, string $temporary_table_name_prefix=self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX)
buildTempTableIlobjectsSpecificPermissionSetForOperationAndContext(string $org_unit_operation_string, string $context, string $temporary_table_name_prefix=self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static findByName(string $context_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static array $available_contexts
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static findByOperationString(string $operation_string, string $context_name)
@deprecated Please use find() from OrgUnitOperationRepository
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const OP_VIEW_CERTIFICATES
const OP_READ_EMPLOYEE_TALK
const OP_VIEW_COMPETENCES
const OP_ACCESS_ENROLMENTS
const OP_EDIT_EMPLOYEE_TALK
const OP_CREATE_EMPLOYEE_TALK
const OP_READ_LEARNING_PROGRESS
Class ilOrgUnitUserAssignmentQueries.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...