50        if (self::$instance === 
null) {
 
   51            self::$instance = 
new self();
 
   53            self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS . 
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION . 
"_" 
   54                . self::COURSE_CONTEXT);
 
   55            self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS . 
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION
 
   56                . 
"_" . self::COURSE_CONTEXT);
 
   57            self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS . 
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION
 
   58                . 
"_" . self::COURSE_CONTEXT);
 
   59            self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS . 
"_user_id_" . 
$DIC->user()->getId());
 
   60            self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS . 
"_user_id_" . 
$DIC->user()->getId());
 
   61            self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX . 
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION . 
"_" 
   62                . self::COURSE_CONTEXT);
 
   84        if (!
$DIC->settings()->get(
"enable_my_staff")) {
 
  115        if (!
$DIC->settings()->get(
"enable_my_staff")) {
 
  119        $cert_set = new \ilSetting(
"certificate");
 
  120        if (!$cert_set->get(
"active")) {
 
  153        if (!
$DIC->settings()->get(
"enable_my_staff")) {
 
  157        $skmg_set = new \ilSkillManagementSettings();
 
  158        if (!$skmg_set->isActivated()) {
 
  193        if (!
$DIC->settings()->get(
"enable_my_staff")) {
 
  197        if ($this->countOrgusOfUserWithOperationAndContext(
$DIC->user()->getId(), self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION, self::COURSE_CONTEXT)
 
  215        if (!
$DIC->settings()->get(
"enable_my_staff")) {
 
  220        if (count($arr_users) > 0 && $usr_id === 0) {
 
  224        if (count($arr_users) > 0 && in_array($usr_id, $arr_users)) {
 
  254        if (count($arr_usr_id) > 0) {
 
  271        $q = 
"SELECT COUNT(orgu_ua.orgu_id) AS 'cnt' FROM il_orgu_permissions AS perm 
  272                                INNER JOIN il_orgu_ua AS orgu_ua ON orgu_ua.position_id = perm.position_id 
  273                                INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context is not NULL 
  274                                WHERE orgu_ua.user_id = " . 
$DIC->database()->quote($user_id, 
'integer') . 
" AND perm.operations is not NULL AND perm.parent_id = -1";
 
  276        $set = 
$DIC->database()->query($q);
 
  277        $rec = 
$DIC->database()->fetchAssoc($set);
 
  290    public function countOrgusOfUserWithOperationAndContext($user_id, $org_unit_operation_string, 
$context)
 
  299        $q = 
"SELECT COUNT(orgu_ua.orgu_id) AS cnt FROM il_orgu_permissions AS perm 
  300                                INNER JOIN il_orgu_ua AS orgu_ua ON orgu_ua.position_id = perm.position_id 
  301                                INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context = '" . 
$context . 
"' 
  302                                and orgu_ua.user_id = " . 
$DIC->database()->quote($user_id, 
'integer') . 
" AND perm.operations LIKE  '%\"" 
  303            . $operation->getOperationId() . 
"\"%' 
  304                                WHERE perm.parent_id = -1";
 
  306        $set = 
$DIC->database()->query($q);
 
  307        $rec = 
$DIC->database()->fetchAssoc($set);
 
  323        $org_unit_operation_string,
 
  325        $tmp_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX
 
  329        $tmp_table_name = $this->buildTempTableIlobjectsUserMatrixForUserOperationAndContext($user_id, $org_unit_operation_string, 
$context, $tmp_table_name_prefix);
 
  331        $q = 
'SELECT usr_id FROM ' . $tmp_table_name;
 
  333        $user_set = 
$DIC->database()->query($q);
 
  335        $arr_users = array();
 
  337        while ($rec = 
$DIC->database()->fetchAssoc($user_set)) {
 
  338            $arr_users[$rec[
'usr_id']] = $rec[
'usr_id'];
 
  354        foreach ($user_assignments as $user_assignment) {
 
  355            $users[$user_assignment->getPositionId()] = $this->
getUsersForUser($user_id, $user_assignment->getPositionId());
 
  373        if (isset($this->users_for_user[$user_id]) && $position_id === 
null) {
 
  374            return $this->users_for_user[$user_id];
 
  379        $position_limitation = 
'';
 
  380        if (!is_null($position_id)) {
 
  381            $position_limitation = 
' AND orgu_ua_current_user.position_id = ' . $position_id;
 
  384        $q = 
"SELECT  " . $tmp_orgu_members . 
".user_id AS usr_id 
  386                                " . $tmp_orgu_members . 
" 
  387                                INNER JOIN il_orgu_ua AS orgu_ua_current_user on orgu_ua_current_user.user_id = " . 
$DIC->database()->quote($user_id, 
'integer') . 
" 
  388                                INNER JOIN il_orgu_authority AS auth ON auth.position_id = orgu_ua_current_user.position_id " . $position_limitation . 
" 
  391                                /* Identische OrgUnit wie Current User; Nicht Rekursiv; Fixe Position */ 
  392                                        (orgu_ua_current_user.orgu_id = " . $tmp_orgu_members . 
".orgu_id AND auth.scope = 1 
  393                                                AND auth.over = " . $tmp_orgu_members . 
".user_position_id AND auth.over <> -1 
  396                                        /* Identische OrgUnit wie Current User; Nicht Rekursiv; Position egal */ 
  397                                        (orgu_ua_current_user.orgu_id = " . $tmp_orgu_members . 
".orgu_id AND auth.scope = 1 AND auth.over = -1) 
  399                                        /* Kinder OrgUnit wie Current User */ 
  402                                                        " . $tmp_orgu_members . 
".orgu_id = orgu_ua_current_user.orgu_id OR 
  403                                                        " . $tmp_orgu_members . 
".tree_path LIKE CONCAT(\"%.\",orgu_ua_current_user.orgu_id ,\".%\") 
  405                                                        " . $tmp_orgu_members . 
".tree_path LIKE  CONCAT(\"%.\",orgu_ua_current_user.orgu_id ) 
  411                                                                        /* Gleiche Position */ 
  412                                                                        auth.over = " . $tmp_orgu_members . 
".user_position_id AND auth.over <> -1 
  425        $user_set = 
$DIC->database()->query($q);
 
  427        $arr_users = array();
 
  429        while ($rec = 
$DIC->database()->fetchAssoc($user_set)) {
 
  430            $arr_users[$rec[
'usr_id']] = $rec[
'usr_id'];
 
  433        if ($position_id === 
null) {
 
  434            $this->users_for_user[$user_id] = $arr_users;
 
  452        foreach ($user_assignments as $user_assignment) {
 
  454            if(count($ref_ids) > 0) {
 
  455                $ids = array_merge($ids, $ref_ids);
 
  475            if(count($ref_ids) > 0) {
 
  476                $ids = array_merge($ids, $ref_ids);
 
  502        if (is_null($operation_object)) {
 
  506        $operation_id = $operation_object->getOperationId();
 
  509            $query = 
'select ' . ($return_ref_id ? 
'object_reference.ref_id' : 
'object_data.obj_id') . 
' from object_data ' .
 
  510                'inner join object_reference on object_reference.obj_id = object_data.obj_id ' .
 
  511                'where type = "' . 
$context . 
'" ' .
 
  512                'AND object_reference.ref_id not in ' .
 
  513                '   (SELECT parent_id FROM il_orgu_permissions ' .
 
  514                '   where position_id = ' . $position_id . 
' and context_id = ' . $context_id . 
' and operations not like \'%"' . $operation_id . 
'"%\' and parent_id <> -1)';
 
  518                'SELECT parent_id as ref_id FROM il_orgu_permissions ' 
  520                'SELECT obj_id FROM il_orgu_permissions INNER JOIN object_reference ON object_reference.ref_id = il_orgu_permissions.parent_id ';
 
  521            $query .= 
' where position_id = ' . $position_id . 
' and context_id = ' . $context_id . 
' and operations like \'%"' . $operation_id . 
'"%\' and parent_id <> -1';
 
  524        return array_map(
function ($item) use ($return_ref_id) {
 
  525            return $return_ref_id ? $item[
'ref_id'] : $item[
'obj_id'];
 
  540        $res = 
$DIC->database()->query(
'SELECT * FROM il_orgu_permissions ' .
 
  541            ' WHERE context_id = ' . $context_id . 
' ' .
 
  542            'AND operations LIKE \'%"' . $operation_id . 
'"%\' ' .
 
  543            'AND position_id = ' . $position_id . 
' ' .
 
  544            'AND parent_id = -1');
 
  546        return (
bool) 
$DIC->database()->numRows(
$res) > 0;
 
  557    public function getIlobjectsAndUsersForUserOperationAndContext($user_id, $org_unit_operation_string, 
$context)
 
  566        $tmp_table_name = 
'tmp_ilobj_user_matrix_' . $operation->getOperationId();
 
  568        $this->buildTempTableIlobjectsUserMatrixForUserOperationAndContext($user_id, $org_unit_operation_string, 
$context, $tmp_table_name);
 
  570        $q = 
'SELECT * FROM ' . $tmp_table_name;
 
  572        $user_set = 
$DIC->database()->query($q);
 
  574        $arr_user_obj = array();
 
  576        while ($rec = 
$DIC->database()->fetchAssoc($user_set)) {
 
  577            $arr_user_obj[] = $rec;
 
  580        return $arr_user_obj;
 
  592    public function buildTempTableIlobjectsUserMatrixForUserOperationAndContext(
 
  594        $org_unit_operation_string,
 
  596        $temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX
 
  600        $temporary_table_name = $temporary_table_name_prefix . 
"_" . $org_unit_operation_string . 
"_" . 
$context;
 
  609        $tmp_table_objects_specific_perimissions = $this->buildTempTableIlobjectsSpecificPermissionSetForOperationAndContext(
 
  610            $org_unit_operation_string,
 
  612            self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS
 
  615        $tmp_table_objects_default_perimissions = $this->buildTempTableIlobjectsDefaultPermissionSetForOperationAndContext(
 
  616            $org_unit_operation_string,
 
  618            self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS
 
  621        $tmp_table_orgunit_default_perimissions = $this->buildTempTableIlorgunitDefaultPermissionSetForOperationAndContext(
 
  622            $org_unit_operation_string,
 
  624            self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS
 
  633        if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX . 
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION . 
"_" 
  634            . self::COURSE_CONTEXT
 
  639        $q = 
"CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name . 
" AS ( 
  640                                SELECT DISTINCT user_perm_matrix.perm_for_ref_id, user_perm_matrix.usr_id FROM 
  642                                 SELECT crs.*," . $tmp_table_course_members . 
".ref_id," . $tmp_table_course_members . 
".usr_id FROM 
  644                                                SELECT * FROM " . $tmp_table_objects_specific_perimissions . 
" 
  646                                                SELECT * FROM " . $tmp_table_objects_default_perimissions . 
" 
  648                                        INNER JOIN " . $tmp_table_course_members . 
" on " . $tmp_table_course_members . 
".ref_id = crs.perm_for_ref_id  
  651                                                        " . $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 
  653                                                        or perm_orgu_scope = 2 
  656                                        SELECT " . $tmp_table_orgunit_default_perimissions . 
".*, " . $tmp_table_orgu_members . 
".orgu_id AS ref_id, " 
  657            . $tmp_table_orgu_members . 
".user_id FROM " . $tmp_table_orgunit_default_perimissions . 
" 
  658                                        INNER JOIN " . $tmp_table_orgu_members . 
" on " . $tmp_table_orgu_members . 
".orgu_id = " 
  659            . $tmp_table_orgunit_default_perimissions . 
".perm_for_ref_id 
  662                                                        " . $tmp_table_orgu_members . 
".orgu_id = " . $tmp_table_orgunit_default_perimissions . 
".perm_for_orgu_id AND " 
  663            . $tmp_table_orgu_members . 
".user_position_id = " . $tmp_table_orgunit_default_perimissions . 
".perm_over_user_with_position AND perm_orgu_scope = 1 
  665                                                        or perm_orgu_scope = 2 
  668                                ) AS user_perm_matrix   
  669                                INNER JOIN " . $tmp_table_orgu_member_path . 
" AS path on path.user_id = user_perm_matrix.usr_id 
  671                                INNER JOIN il_orgu_ua AS orgu_ua_current_user on orgu_ua_current_user.user_id = " . 
$DIC->database()->quote($user_id, 
'integer') . 
" 
  672                                INNER JOIN il_orgu_permissions AS perm on perm.position_id = orgu_ua_current_user.position_id AND perm.parent_id = -1 
  673                                INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context =  '$context' 
  674                                and perm.operations  LIKE '%\"" . $operation->getOperationId() . 
"\"%' 
  678                                        /* Identische OrgUnit wie Current User; Nicht Rekursiv; Fixe Position */ 
  679                                        (orgu_ua_current_user.orgu_id = user_perm_matrix.perm_for_orgu_id AND user_perm_matrix.perm_orgu_scope = 1 
  680                                        AND orgu_ua_current_user.position_id = user_perm_matrix.perm_for_position_id AND user_perm_matrix.perm_over_user_with_position <> -1 
  683                                        /* Identische OrgUnit wie Current User; Nicht Rekursiv; Position egal */ 
  684                                        (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) 
  686                                        /* Kinder OrgUnit wie Current User */ 
  688                                                orgu_ua_current_user.orgu_id = user_perm_matrix.perm_for_orgu_id 
  691                                                        path.orgu_id = user_perm_matrix.perm_for_orgu_id OR 
  692                                                        path.tree_path LIKE CONCAT(\"%.\",user_perm_matrix.perm_for_orgu_id ,\".%\") 
  694                                                        path.tree_path LIKE  CONCAT(\"%.\",user_perm_matrix.perm_for_orgu_id ) 
  700                                                                        /* Gleiche Position */ 
  701                                                                        orgu_ua_current_user.position_id = user_perm_matrix.perm_for_position_id AND user_perm_matrix.perm_over_user_with_position <> -1 
  706                                                                        user_perm_matrix.perm_over_user_with_position = -1 
  709                                                        AND user_perm_matrix.perm_orgu_scope = 2 
  715        $DIC->database()->manipulate($q);
 
  717        return $temporary_table_name;
 
  728    public function buildTempTableIlobjectsSpecificPermissionSetForOperationAndContext(
 
  729        $org_unit_operation_string,
 
  731        $temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS
 
  735        $temporary_table_name = $temporary_table_name_prefix . 
"_" . $org_unit_operation_string . 
"_" . 
$context;
 
  742        if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS . 
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION . 
"_" 
  743            . self::COURSE_CONTEXT
 
  748        $q = 
"CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name . 
"  
  749                                (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)) 
  752                                        obj_ref.ref_id AS perm_for_ref_id, 
  753                                        orgu_ua.orgu_id AS perm_for_orgu_id, 
  754                                auth.scope AS perm_orgu_scope, 
  755                                        orgu_ua.position_id AS perm_for_position_id, 
  756                                        auth.over AS perm_over_user_with_position 
  758                                        il_orgu_permissions AS perm 
  759                                        INNER JOIN il_orgu_ua AS orgu_ua ON orgu_ua.position_id = perm.position_id 
  760                                        INNER JOIN il_orgu_authority AS auth ON auth.position_id = orgu_ua.position_id AND orgu_ua.user_id = " . 
$GLOBALS[
'DIC']->user()
 
  762                                        INNER JOIN object_reference AS obj_ref ON obj_ref.ref_id =  perm.parent_id 
  763                                        INNER JOIN object_data AS obj ON obj.obj_id = obj_ref.obj_id AND obj.type = '$context' 
  764                                        INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context = '$context' 
  766                                    perm.operations LIKE '%\"" . $operation->getOperationId() . 
"\"%' 
  769        $DIC->database()->manipulate($q);
 
  771        return $temporary_table_name;
 
  782    public function buildTempTableIlobjectsDefaultPermissionSetForOperationAndContext(
 
  783        $org_unit_operation_string,
 
  785        $temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS
 
  789        $temporary_table_name = $temporary_table_name_prefix . 
"_" . $org_unit_operation_string . 
"_" . 
$context;
 
  796        if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS . 
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION . 
"_" 
  797            . self::COURSE_CONTEXT
 
  802        $q = 
"CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name . 
"  
  803                (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)) 
  806                                        obj_ref.ref_id AS perm_for_ref_id, 
  807                                        orgu_ua.orgu_id AS perm_for_orgu_id, 
  808                                auth.scope AS perm_orgu_scope, 
  809                                        orgu_ua.position_id AS perm_for_position_id, 
  810                                        auth.over AS perm_over_user_with_position 
  813                                    INNER JOIN object_reference AS obj_ref ON obj_ref.obj_id = obj.obj_id 
  814                                    INNER JOIN il_orgu_permissions AS perm ON perm.operations LIKE '%\"" . $operation->getOperationId() . 
"\"%' AND perm.parent_id = -1 
  815                                    INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context = '" . 
$context . 
"' 
  816                                    INNER JOIN il_orgu_ua AS orgu_ua ON orgu_ua.position_id = perm.position_id AND orgu_ua.user_id = " . 
$GLOBALS[
'DIC']->user()
 
  818                                    INNER JOIN il_orgu_authority AS auth ON auth.position_id = orgu_ua.position_id 
  822                                            AND (obj_ref.ref_id , orgu_ua.position_id)  
  825                                                perm.parent_id, orgu_ua.position_id 
  827                                                il_orgu_permissions AS perm 
  828                                            INNER JOIN il_orgu_ua AS orgu_ua ON orgu_ua.position_id = perm.position_id 
  829                                            INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context = '" . 
$context . 
"' 
  830                                            WHERE perm.parent_id <> -1) 
  833        $DIC->database()->manipulate($q);
 
  835        return $temporary_table_name;
 
  846    public function buildTempTableIlorgunitDefaultPermissionSetForOperationAndContext(
 
  847        $org_unit_operation_string,
 
  849        $temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS
 
  853        $temporary_table_name = $temporary_table_name_prefix . 
"_" . $org_unit_operation_string . 
"_" . 
$context;
 
  859        if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS . 
"_" . self::ACCESS_ENROLMENTS_ORG_UNIT_OPERATION . 
"_" 
  860            . self::COURSE_CONTEXT
 
  865        $q = 
"CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name . 
"  
  866                          (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)) 
  869                            orgu_ua.orgu_id AS perm_for_ref_id, /* Table has to be identical to the other Permission For Operation And Context-Tables! */ 
  870                                        orgu_ua.orgu_id AS perm_for_orgu_id, 
  871                                auth.scope AS perm_orgu_scope, 
  872                                        orgu_ua.position_id AS perm_for_position_id, 
  873                                        auth.over AS perm_over_user_with_position 
  875                                        il_orgu_permissions AS perm 
  876                                    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 = " 
  877            . 
$GLOBALS[
'DIC']->user()->getId() . 
" 
  878                                    INNER JOIN il_orgu_authority AS auth ON auth.position_id = orgu_ua.position_id 
  879                                    INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context = '" . 
$context . 
"' 
  881                                    perm.operations LIKE '%\"" . $operation->getOperationId() . 
"\"%' 
  884        $DIC->database()->manipulate($q);
 
  886        return $temporary_table_name;
 
  896    public function buildTempTableCourseMemberships($temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS, array $only_courses_of_user_ids = array())
 
  900        $temporary_table_name = $temporary_table_name_prefix . 
"_user_id_" . 
$DIC->user()->getId();
 
  902        if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS . 
"_user_id_" . 
$DIC->user()->getId()
 
  903            || count($only_courses_of_user_ids) > 0
 
  908        $q = 
"CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name . 
"  
  909                (INDEX i1(ref_id), INDEX i2 (usr_id), INDEX i3 (position_id), INDEX i4 (orgu_id)) 
  911                                        SELECT crs_members_crs_ref.ref_id, crs_members.usr_id, orgu_ua.position_id, orgu_ua.orgu_id 
  913                                                        SELECT obj_id, usr_id FROM obj_members WHERE admin > 0 OR tutor > 0 OR member > 0 
  914                                                        AND " . 
$DIC->database()->in(
'obj_members.usr_id', $only_courses_of_user_ids, 
false, 
'integer') . 
"  
  916                                                        SELECT obj_id, usr_id FROM crs_waiting_list 
  917                                                        WHERE " . 
$DIC->database()->in(
'crs_waiting_list.usr_id', $only_courses_of_user_ids, 
false, 
'integer') . 
"  
  919                                                        SELECT obj_id, usr_id FROM il_subscribers 
  920                                                        WHERE " . 
$DIC->database()->in(
'il_subscribers.usr_id', $only_courses_of_user_ids, 
false, 
'integer') . 
"  
  922                                                INNER JOIN object_reference AS crs_members_crs_ref on crs_members_crs_ref.obj_id = crs_members.obj_id 
  923                                                INNER JOIN il_orgu_ua AS orgu_ua on orgu_ua.user_id = crs_members.usr_id 
  926        $DIC->database()->manipulate($q);
 
  928        return $temporary_table_name;
 
  938    public function buildTempTableOrguMemberships($temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS, array $only_orgus_of_user_ids = array())
 
  942        $temporary_table_name = $temporary_table_name_prefix . 
"_user_id_" . 
$DIC->user()->getId();
 
  944        if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS . 
"_user_id_" . 
$DIC->user()->getId()
 
  945            || count($only_orgus_of_user_ids) > 0
 
  950        $q = 
"CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name . 
"  
  951                        (INDEX i1(orgu_id), INDEX i2 (tree_path), 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)) 
  953                                        SELECT  orgu_ua.orgu_id AS orgu_id, 
  954                                                        tree_orgu.path AS tree_path, 
  955                                                        tree_orgu.child AS tree_child, 
  956                                                        tree_orgu.parent AS tree_parent, 
  957                                                        tree_orgu.lft AS tree_lft, 
  958                                                        tree_orgu.rgt AS tree_rgt, 
  959                                                        orgu_ua.position_id AS user_position_id, 
  960                                                        orgu_ua.user_id AS user_id 
  962                                                        il_orgu_ua AS orgu_ua 
  963                                                        INNER JOIN object_reference AS obj_ref on obj_ref.ref_id = orgu_ua.orgu_id AND obj_ref.deleted is null 
  964                                                        LEFT JOIN tree AS tree_orgu ON tree_orgu.child = orgu_ua.orgu_id";
 
  966        if (count($only_orgus_of_user_ids) > 0) {
 
  967            $q .= 
" WHERE " . 
$DIC->database()->in(
'orgu_ua.user_id', $only_orgus_of_user_ids, 
false, 
'integer') . 
" ";
 
  972        $DIC->database()->manipulate($q);
 
  974        return $temporary_table_name;
 
  987        $q = 
"DROP TABLE IF EXISTS " . $temporary_table_name;
 
  988        $DIC->database()->manipulate($q);
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
buildTempTableCourseMemberships($temporary_table_name_prefix=self::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS, array $only_courses_of_user_ids=array())
hasCurrentUserAccessToCourseMemberships()
const TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS
getIdsForPositionAndOperationAndContext(int $position_id, string $operation, string $context, bool $return_ref_id)
returns all obj_ids/ref_ids (depending on flag "ref_id") of objects of type $context,...
dropTempTable($temporary_table_name)
hasCurrentUserAccessToCourseLearningProgressForAtLeastOneUser()
getUsersForUserPerPosition($user_id)
hasCurrentUserAccessToCompetences()
hasPositionDefaultPermissionForOperationInContext(int $position_id, int $operation_id, int $context_id)
const TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS
getUsersForUserOperationAndContext( $user_id, $org_unit_operation_string, $context, $tmp_table_name_prefix=self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX)
const TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX
hasCurrentUserAccessToMyStaff()
const ACCESS_ENROLMENTS_ORG_UNIT_OPERATION
hasCurrentUserAccessToUser($usr_id=0)
getIdsForPositionAndOperation(int $position_id, string $operation, bool $return_ref_id)
const TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS
buildTempTableOrguMemberships($temporary_table_name_prefix=self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS, array $only_orgus_of_user_ids=array())
hasCurrentUserAccessToLearningProgressInObject($ref_id=0)
const TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS
getUsersForUser($user_id, ?int $position_id=null)
const TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS
getIdsForUserAndOperation(int $user_id, string $operation, bool $return_ref_id=false)
hasCurrentUserAccessToCertificates()
countOrgusOfUserWithAtLeastOneOperation($user_id)
Class ilOrgUnitOperationContextQueries.
static findByName($context_name)
Class ilOrgUnitOperationContext.
static $available_contexts
Class ilOrgUnitOperationQueries.
static findByOperationString($operation_string, $context_name)
Class ilOrgUnitOperation.
const OP_VIEW_CERTIFICATES
const OP_VIEW_COMPETENCES
const OP_ACCESS_ENROLMENTS
const OP_READ_LEARNING_PROGRESS
Class ilOrgUnitUserAssignmentQueries.
foreach($_POST as $key=> $value) $res