ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMyStaffAccess Class Reference

Class ilMyStaffAccess. More...

+ Inheritance diagram for ilMyStaffAccess:
+ Collaboration diagram for ilMyStaffAccess:

Public Member Functions

 hasCurrentUserAccessToMyStaff ()
 
 hasCurrentUserAccessToUser ($usr_id=0)
 
 hasCurrentUserAccessToLearningProgressInObject ($ref_id=0)
 
 hasCurrentUserAccessToCourseLearningProgressForAtLeastOneUser ()
 
 countOrgusOfUserWithAtLeastOneOperation ($user_id)
 
 getUsersForUserOperationAndContext ($user_id, $org_unit_operation_string=self::DEFAULT_ORG_UNIT_OPERATION, $context=self::DEFAULT_CONTEXT, $tmp_table_name_prefix=self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX)
 
 getUsersForUser ($user_id)
 
 buildTempTableCourseMemberships ($temporary_table_name_prefix=self::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS, array $only_courses_of_user_ids=array())
 
 buildTempTableOrguMemberships ($temporary_table_name_prefix=self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS, array $only_orgus_of_user_ids=array())
 
 dropTempTable ($temporary_table_name)
 
- Public Member Functions inherited from ilObjectAccess
 _checkAccess ($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id="")
 Checks wether a user may invoke a command or not (this method is called by ilAccessHandler::checkAccess) More...
 
 _checkCondition ($a_obj_id, $a_operator, $a_value, $a_usr_id)
 check condition More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 
Parameters
ilWACPath$ilWACPath
Returns
bool
More...
 

Static Public Member Functions

static getInstance ()
 
- Static Public Member Functions inherited from ilObjectAccess
static _getCommands ()
 get commands More...
 
static _checkGoto ($a_target)
 check whether goto script will succeed More...
 
static _isOffline ($a_obj_id)
 Type-specific implementation of general status, has to be overwritten if object type does not support centralized offline handling. More...
 
static _preloadData ($a_obj_ids, $a_ref_ids)
 Preload data. More...
 

Data Fields

const TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS = 'tmp_obj_spec_perm'
 
const TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS = 'tmp_obj_def_perm'
 
const TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS = 'tmp_orgu_def_perm'
 
const TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS = 'tmp_crs_members'
 
const TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS = 'tmp_orgu_members'
 
const TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX = 'tmp_obj_user_matr'
 
const DEFAULT_ORG_UNIT_OPERATION = ilOrgUnitOperation::OP_ACCESS_ENROLMENTS
 
const DEFAULT_CONTEXT = 'crs'
 

Static Protected Attributes

static $instance = null
 
static $orgu_users_of_current_user_show_staff_permission
 

Private Member Functions

 __construct ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMyStaffAccess::__construct ( )
private

Definition at line 57 of file class.ilMyStaffAccess.php.

58  {
59  }

Member Function Documentation

◆ buildTempTableCourseMemberships()

ilMyStaffAccess::buildTempTableCourseMemberships (   $temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS,
array  $only_courses_of_user_ids = array() 
)
Parameters
string$temporary_table_name_prefix
array$only_courses_of_user_ids
Returns
string

Definition at line 593 of file class.ilMyStaffAccess.php.

References $DIC, and dropTempTable().

Referenced by getUsersForUser().

594  {
595  global $DIC;
596 
597  $temporary_table_name = $temporary_table_name_prefix . "_user_id_" . $DIC->user()->getId();
598 
599  if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS . "_user_id_" . $DIC->user()->getId()
600  || count($only_courses_of_user_ids) > 0) {
601  $this->dropTempTable($temporary_table_name);
602  }
603 
604  $q = "CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name . "
605  (INDEX i1(ref_id), INDEX i2 (usr_id), INDEX i3 (position_id), INDEX i4 (orgu_id))
606  AS (
607  SELECT crs_members_crs_ref.ref_id, crs_members.usr_id, orgu_ua.position_id, orgu_ua.orgu_id
608  FROM (
609  SELECT obj_id, usr_id FROM obj_members WHERE member = 1
610  AND " . $DIC->database()->in('obj_members.usr_id', $only_courses_of_user_ids, false, 'integer') . "
611  UNION
612  SELECT obj_id, usr_id FROM crs_waiting_list
613  WHERE " . $DIC->database()->in('crs_waiting_list.usr_id', $only_courses_of_user_ids, false, 'integer') . "
614  UNION
615  SELECT obj_id, usr_id FROM il_subscribers
616  WHERE " . $DIC->database()->in('il_subscribers.usr_id', $only_courses_of_user_ids, false, 'integer') . "
617  ) AS crs_members
618  INNER JOIN object_reference AS crs_members_crs_ref on crs_members_crs_ref.obj_id = crs_members.obj_id
619  INNER JOIN il_orgu_ua AS orgu_ua on orgu_ua.user_id = crs_members.usr_id
620  );";
621 
622  $DIC->database()->manipulate($q);
623 
624  return $temporary_table_name;
625  }
global $DIC
Definition: saml.php:7
dropTempTable($temporary_table_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildTempTableOrguMemberships()

ilMyStaffAccess::buildTempTableOrguMemberships (   $temporary_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS,
array  $only_orgus_of_user_ids = array() 
)
Parameters
string$temporary_table_name_prefix
array$only_orgus_of_user_ids
Returns
string

Definition at line 634 of file class.ilMyStaffAccess.php.

References $DIC, and dropTempTable().

Referenced by getUsersForUser().

635  {
636  global $DIC;
637 
638  $temporary_table_name = $temporary_table_name_prefix . "_user_id_" . $DIC->user()->getId();
639 
640  if ($temporary_table_name != self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS . "_user_id_" . $DIC->user()->getId()
641  || count($only_orgus_of_user_ids) > 0) {
642  $this->dropTempTable($temporary_table_name);
643  }
644 
645  $q = "CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name . "
646  (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))
647  AS (
648  SELECT orgu_ua.orgu_id AS orgu_id,
649  tree_orgu.path AS tree_path,
650  tree_orgu.child AS tree_child,
651  tree_orgu.parent AS tree_parent,
652  tree_orgu.lft AS tree_lft,
653  tree_orgu.rgt AS tree_rgt,
654  orgu_ua.position_id AS user_position_id,
655  orgu_ua.user_id AS user_id
656  FROM
657  il_orgu_ua AS orgu_ua
658  INNER JOIN object_reference AS obj_ref on obj_ref.ref_id = orgu_ua.orgu_id AND obj_ref.deleted is null
659  LEFT JOIN tree AS tree_orgu ON tree_orgu.child = orgu_ua.orgu_id";
660 
661  if (count($only_orgus_of_user_ids) > 0) {
662  $q .= " WHERE " . $DIC->database()->in('orgu_ua.user_id', $only_orgus_of_user_ids, false, 'integer') . " ";
663  }
664 
665  $q .= ");";
666 
667  $DIC->database()->manipulate($q);
668 
669  return $temporary_table_name;
670  }
global $DIC
Definition: saml.php:7
dropTempTable($temporary_table_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ countOrgusOfUserWithAtLeastOneOperation()

ilMyStaffAccess::countOrgusOfUserWithAtLeastOneOperation (   $user_id)
Parameters
int$user_id
Returns
int

Definition at line 138 of file class.ilMyStaffAccess.php.

References $context, $DIC, and ilOrgUnitOperationQueries\findByOperationString().

139  {
140  global $DIC;
141 
142  $q = "SELECT COUNT(orgu_ua.orgu_id) AS 'cnt' FROM il_orgu_permissions AS perm
143  INNER JOIN il_orgu_ua AS orgu_ua ON orgu_ua.position_id = perm.position_id
144  INNER JOIN il_orgu_op_contexts AS contexts on contexts.id = perm.context_id AND contexts.context is not NULL
145  WHERE orgu_ua.user_id = " . $DIC->database()->quote($user_id, 'integer') . " AND perm.operations is not NULL AND perm.parent_id = -1";
146 
147  $set = $DIC->database()->query($q);
148  $rec = $DIC->database()->fetchAssoc($set);
149 
150  return $rec['cnt'];
151  }
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:

◆ dropTempTable()

ilMyStaffAccess::dropTempTable (   $temporary_table_name)
Parameters
string$temporary_table_name
Returns
bool

Definition at line 678 of file class.ilMyStaffAccess.php.

References $DIC.

Referenced by buildTempTableCourseMemberships(), buildTempTableOrguMemberships(), and getUsersForUser().

679  {
680  global $DIC;
681 
682  $q = "DROP TABLE IF EXISTS " . $temporary_table_name;
683  $DIC->database()->manipulate($q);
684 
685  return true;
686  }
global $DIC
Definition: saml.php:7
+ Here is the caller graph for this function:

◆ getInstance()

static ilMyStaffAccess::getInstance ( )
static
Returns
self

Definition at line 31 of file class.ilMyStaffAccess.php.

References $DIC.

Referenced by ilMStListCoursesTableGUI\__construct(), ilMStListUsersTableGUI\__construct(), ilMStShowUserCoursesTableGUI\__construct(), ilMStListCoursesGUI\__construct(), ilMStListUsersGUI\__construct(), ilMStShowUserGUI\__construct(), ilMStListCourses\getData(), ilUserUtil\getPossibleStartingPoints(), ilStaffGlobalScreenProvider\getStaticSubItems(), ilMyStaffGUI\getUserLpStatusAsHtml(), and ilMyStaffGUI\getUserLpStatusAsText().

32  {
33  global $DIC;
34 
35  if (self::$instance === null) {
36  self::$instance = new self();
37 
38  self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS . "_" . self::DEFAULT_ORG_UNIT_OPERATION . "_"
39  . self::DEFAULT_CONTEXT);
40  self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS . "_" . self::DEFAULT_ORG_UNIT_OPERATION
41  . "_" . self::DEFAULT_CONTEXT);
42  self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS . "_" . self::DEFAULT_ORG_UNIT_OPERATION
43  . "_" . self::DEFAULT_CONTEXT);
44  self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS . "_user_id_" . $DIC->user()->getId());
45  self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS . "_user_id_" . $DIC->user()->getId());
46  self::$instance->dropTempTable(self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX . "_" . self::DEFAULT_ORG_UNIT_OPERATION . "_"
47  . self::DEFAULT_CONTEXT);
48  }
49 
50  return self::$instance;
51  }
global $DIC
Definition: saml.php:7
+ Here is the caller graph for this function:

◆ getUsersForUser()

ilMyStaffAccess::getUsersForUser (   $user_id)
Parameters
int$user_id
Returns
array

Definition at line 217 of file class.ilMyStaffAccess.php.

References $context, $DIC, $GLOBALS, buildTempTableCourseMemberships(), buildTempTableOrguMemberships(), dropTempTable(), ilOrgUnitOperationQueries\findByOperationString(), ilOrgUnitOperation\OP_ACCESS_ENROLMENTS, and user().

Referenced by hasCurrentUserAccessToUser().

218  {
219  global $DIC;
220 
221  $tmp_orgu_members = $this->buildTempTableOrguMemberships(self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS, array());
222 
223  $q = "SELECT " . $tmp_orgu_members . ".user_id AS usr_id
224  FROM
225  " . $tmp_orgu_members . "
226  INNER JOIN il_orgu_ua AS orgu_ua_current_user on orgu_ua_current_user.user_id = " . $DIC->database()->quote($user_id, 'integer') . "
227  INNER JOIN il_orgu_authority AS auth ON auth.position_id = orgu_ua_current_user.position_id
228  WHERE
229  (
230  /* Identische OrgUnit wie Current User; Nicht Rekursiv; Fixe Position */
231  (orgu_ua_current_user.orgu_id = " . $tmp_orgu_members . ".orgu_id AND auth.scope = 1
232  AND auth.over = " . $tmp_orgu_members . ".user_position_id AND auth.over <> -1
233  )
234  OR
235  /* Identische OrgUnit wie Current User; Nicht Rekursiv; Position egal */
236  (orgu_ua_current_user.orgu_id = " . $tmp_orgu_members . ".orgu_id AND auth.scope = 1 AND auth.over = -1)
237  OR
238  /* Kinder OrgUnit wie Current User */
239  (
240  (
241  " . $tmp_orgu_members . ".orgu_id = orgu_ua_current_user.orgu_id OR
242  " . $tmp_orgu_members . ".tree_path LIKE CONCAT(\"%.\",orgu_ua_current_user.orgu_id ,\".%\")
243  OR
244  " . $tmp_orgu_members . ".tree_path LIKE CONCAT(\"%.\",orgu_ua_current_user.orgu_id )
245  )
246  AND
247  (
248  (
249  (
250  /* Gleiche Position */
251  auth.over = " . $tmp_orgu_members . ".user_position_id AND auth.over <> -1
252  )
253  OR
254  (
255  /* Position Egal */
256  auth.over = -1
257  )
258  )
259  AND auth.scope = 2
260  )
261  )
262  )";
263 
264  $user_set = $DIC->database()->query($q);
265 
266  $arr_users = array();
267 
268  while ($rec = $DIC->database()->fetchAssoc($user_set)) {
269  $arr_users[$rec['usr_id']] = $rec['usr_id'];
270  }
271 
272  return $arr_users;
273  }
global $DIC
Definition: saml.php:7
buildTempTableOrguMemberships($temporary_table_name_prefix=self::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS, array $only_orgus_of_user_ids=array())
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUsersForUserOperationAndContext()

ilMyStaffAccess::getUsersForUserOperationAndContext (   $user_id,
  $org_unit_operation_string = self::DEFAULT_ORG_UNIT_OPERATION,
  $context = self::DEFAULT_CONTEXT,
  $tmp_table_name_prefix = self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX 
)
Parameters
int$user_id
string$org_unit_operation_string
string$context
string$tmp_table_name_prefix
Returns
array

Definition at line 192 of file class.ilMyStaffAccess.php.

References $context, and $DIC.

Referenced by hasCurrentUserAccessToCourseLearningProgressForAtLeastOneUser().

193  {
194  global $DIC;
195 
196  $tmp_table_name = $this->buildTempTableIlobjectsUserMatrixForUserOperationAndContext($user_id, $org_unit_operation_string, $context, $tmp_table_name_prefix);
197 
198  $q = 'SELECT usr_id FROM ' . $tmp_table_name;
199 
200  $user_set = $DIC->database()->query($q);
201 
202  $arr_users = array();
203 
204  while ($rec = $DIC->database()->fetchAssoc($user_set)) {
205  $arr_users[$rec['usr_id']] = $rec['usr_id'];
206  }
207 
208  return $arr_users;
209  }
$context
Definition: webdav.php:25
global $DIC
Definition: saml.php:7
+ Here is the caller graph for this function:

◆ hasCurrentUserAccessToCourseLearningProgressForAtLeastOneUser()

ilMyStaffAccess::hasCurrentUserAccessToCourseLearningProgressForAtLeastOneUser ( )
Returns
bool

Definition at line 119 of file class.ilMyStaffAccess.php.

References $DIC, getUsersForUserOperationAndContext(), and ilOrgUnitOperation\OP_READ_LEARNING_PROGRESS.

120  {
121  global $DIC;
122 
123  $arr_usr_id = $this->getUsersForUserOperationAndContext($DIC->user()
124  ->getId(), ilOrgUnitOperation::OP_READ_LEARNING_PROGRESS, self::DEFAULT_CONTEXT);
125  if (count($arr_usr_id) > 0) {
126  return true;
127  }
128 
129  return false;
130  }
global $DIC
Definition: saml.php:7
getUsersForUserOperationAndContext($user_id, $org_unit_operation_string=self::DEFAULT_ORG_UNIT_OPERATION, $context=self::DEFAULT_CONTEXT, $tmp_table_name_prefix=self::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX)
+ Here is the call graph for this function:

◆ hasCurrentUserAccessToLearningProgressInObject()

ilMyStaffAccess::hasCurrentUserAccessToLearningProgressInObject (   $ref_id = 0)
Parameters
int$ref_id
Returns
bool

Definition at line 108 of file class.ilMyStaffAccess.php.

References $DIC, and ilOrgUnitOperation\OP_READ_LEARNING_PROGRESS.

109  {
110  global $DIC;
111 
112  return $DIC->access()->checkPositionAccess(ilOrgUnitOperation::OP_READ_LEARNING_PROGRESS, $ref_id);
113  }
global $DIC
Definition: saml.php:7

◆ hasCurrentUserAccessToMyStaff()

ilMyStaffAccess::hasCurrentUserAccessToMyStaff ( )
Returns
bool

Definition at line 65 of file class.ilMyStaffAccess.php.

References $DIC, ilOrgUnitOperationQueries\findByOperationString(), and ilOrgUnitOperation\OP_ACCESS_ENROLMENTS.

66  {
67  global $DIC;
68 
69  if (!$DIC->settings()->get("enable_my_staff")) {
70  return false;
71  }
72 
74  if (!$operation) {
75  return false;
76  }
77  if ($this->countOrgusOfUserWithOperationAndContext($DIC->user()->getId(), ilOrgUnitOperation::OP_ACCESS_ENROLMENTS, self::DEFAULT_CONTEXT)
78  > 0) {
79  return true;
80  }
81 
82  return false;
83  }
global $DIC
Definition: saml.php:7
static findByOperationString($operation_string, $context_name)
+ Here is the call graph for this function:

◆ hasCurrentUserAccessToUser()

ilMyStaffAccess::hasCurrentUserAccessToUser (   $usr_id = 0)
Parameters
int$usr_id
Returns
bool

Definition at line 91 of file class.ilMyStaffAccess.php.

References $DIC, and getUsersForUser().

92  {
93  global $DIC;
94 
95  if (in_array($usr_id, $this->getUsersForUser($DIC->user()->getId()))) {
96  return true;
97  }
98 
99  return false;
100  }
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:

Field Documentation

◆ $instance

ilMyStaffAccess::$instance = null
staticprotected

Definition at line 21 of file class.ilMyStaffAccess.php.

◆ $orgu_users_of_current_user_show_staff_permission

ilMyStaffAccess::$orgu_users_of_current_user_show_staff_permission
staticprotected

Definition at line 25 of file class.ilMyStaffAccess.php.

◆ DEFAULT_CONTEXT

◆ DEFAULT_ORG_UNIT_OPERATION

const ilMyStaffAccess::DEFAULT_ORG_UNIT_OPERATION = ilOrgUnitOperation::OP_ACCESS_ENROLMENTS

Definition at line 16 of file class.ilMyStaffAccess.php.

◆ TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS

const ilMyStaffAccess::TMP_DEFAULT_TABLE_NAME_PREFIX_CRS_MEMBERS = 'tmp_crs_members'

Definition at line 13 of file class.ilMyStaffAccess.php.

◆ TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS

const ilMyStaffAccess::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_DEFAULT_PERMISSIONS = 'tmp_obj_def_perm'

Definition at line 11 of file class.ilMyStaffAccess.php.

◆ TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS

const ilMyStaffAccess::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_SPEC_PERMISSIONS = 'tmp_obj_spec_perm'

Definition at line 10 of file class.ilMyStaffAccess.php.

◆ TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX

const ilMyStaffAccess::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_OBJ_USER_MATRIX = 'tmp_obj_user_matr'

Definition at line 15 of file class.ilMyStaffAccess.php.

Referenced by ilMStListCourses\getData().

◆ TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS

const ilMyStaffAccess::TMP_DEFAULT_TABLE_NAME_PREFIX_IL_ORGU_DEFAULT_PERMISSIONS = 'tmp_orgu_def_perm'

Definition at line 12 of file class.ilMyStaffAccess.php.

◆ TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS

const ilMyStaffAccess::TMP_DEFAULT_TABLE_NAME_PREFIX_ORGU_MEMBERS = 'tmp_orgu_members'

Definition at line 14 of file class.ilMyStaffAccess.php.


The documentation for this class was generated from the following file: