ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilOrgUnitPermissionQueries Class Reference

Class ilOrgUnitPermissionQueries. More...

+ Collaboration diagram for ilOrgUnitPermissionQueries:

Static Public Member Functions

static getTemplateSetForContextName ($context_name, $position_id, $editable=false)
 
static hasLocalSet ($ref_id, $position_id)
 
static getAllTemplateSetsForAllActivedContexts ($position_id, $editable=false)
 
static getRelevantPermissionSetsForUserIdAndRefIdAndOperation ($user_id, $ref_id, $operation_string)
 

Static Protected Member Functions

static getContextByRefId ($ref_id)
 
static checkRefIdAndPositionId ($ref_id, $position_id)
 

Static Private Member Functions

static getAllowedOperationsOnRefIdAndPosition ($ref_id, $position_id)
 

Detailed Description

Member Function Documentation

◆ checkRefIdAndPositionId()

static ilOrgUnitPermissionQueries::checkRefIdAndPositionId (   $ref_id,
  $position_id 
)
staticprotected
Parameters
$ref_id
$position_id
Exceptions

Definition at line 277 of file class.ilOrgUnitPermissionQueries.php.

278  {
279  if (!$ref_id) {
280  throw new ilException('$ref_id cannot be null');
281  }
282  if (!$position_id) {
283  throw new ilException('$position_id cannot be null');
284  }
285  }

◆ getAllowedOperationsOnRefIdAndPosition()

static ilOrgUnitPermissionQueries::getAllowedOperationsOnRefIdAndPosition (   $ref_id,
  $position_id 
)
staticprivate

Definition at line 231 of file class.ilOrgUnitPermissionQueries.php.

References $DIC, and $r.

232  {
233  global $DIC;
234  $db = $DIC->database();
235 
236  $q = 'SELECT @CONTEXT_TYPE:= object_data.type
237  FROM object_reference
238  JOIN object_data ON object_data.obj_id = object_reference.obj_id
239  WHERE object_reference.ref_id = %s;';
240  $db->queryF($q, [ 'integer' ], [ $ref_id ]);
241 
242  $q = 'SELECT @OP_ID:= CONCAT("%\"", il_orgu_operations.operation_id, "%\"")
243  FROM il_orgu_operations
244  JOIN il_orgu_op_contexts ON il_orgu_op_contexts.context = @CONTEXT_TYPE -- AND il_orgu_op_contexts.id = il_orgu_operations.context_id
245  WHERE il_orgu_operations.operation_string = %s';
246  $db->queryF($q, [ 'text' ], [ $pos_perm ]);
247  $q = 'SELECT * FROM il_orgu_permissions WHERE operations LIKE @OP_ID AND position_id = %s;';
248  $r = $db->queryF($q, [ 'integer' ], [ $position_id ]);
249 
250  ($r->numRows() > 0);
251  }
global $DIC
Definition: saml.php:7
$r
Definition: example_031.php:79

◆ getAllTemplateSetsForAllActivedContexts()

static ilOrgUnitPermissionQueries::getAllTemplateSetsForAllActivedContexts (   $position_id,
  $editable = false 
)
static
Parameters
$position_id
bool$editable
Returns
[]

Definition at line 201 of file class.ilOrgUnitPermissionQueries.php.

References $sets, ilOrgUnitGlobalSettings\getInstance(), and getTemplateSetForContextName().

Referenced by ilOrgUnitDefaultPermissionGUI\index(), and ilOrgUnitDefaultPermissionGUI\update().

202  {
203  $activated_components = [];
204  foreach (ilOrgUnitGlobalSettings::getInstance()->getPositionSettings() as $ilOrgUnitObjectPositionSetting) {
205  if ($ilOrgUnitObjectPositionSetting->isActive()) {
206  $activated_components[] = $ilOrgUnitObjectPositionSetting->getType();
207  }
208  }
209  $sets = [];
210  foreach ($activated_components as $context) {
211  $sets[] = ilOrgUnitPermissionQueries::getTemplateSetForContextName($context, $position_id, $editable);
212  }
213 
214  return $sets;
215  }
$sets
Definition: fetch.php:11
static getTemplateSetForContextName($context_name, $position_id, $editable=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContextByRefId()

static ilOrgUnitPermissionQueries::getContextByRefId (   $ref_id)
staticprotected
Parameters
$ref_id
Returns
Exceptions

Definition at line 260 of file class.ilOrgUnitPermissionQueries.php.

References ilOrgUnitOperationContextQueries\findByRefId().

261  {
263  if (!$context) {
264  throw new ilException('Context not found');
265  }
266 
267  return $context;
268  }
+ Here is the call graph for this function:

◆ getRelevantPermissionSetsForUserIdAndRefIdAndOperation()

static ilOrgUnitPermissionQueries::getRelevantPermissionSetsForUserIdAndRefIdAndOperation (   $user_id,
  $ref_id,
  $operation_string 
)
static
Parameters
$user_id
$ref_id
$operation_string

Definition at line 223 of file class.ilOrgUnitPermissionQueries.php.

224  {
225  $q = 'SELECT @OP_ID:= CONCAT("%\"",operation_id, "\"%") FROM il_orgu_op_contexts
226 JOIN il_orgu_operations ON il_orgu_operations.context_id = il_orgu_op_contexts.id
227 WHERE il_orgu_op_contexts.context IN(\'crs\', \'object\') AND operation_string = \'viewmembers\';';
228  }

◆ getTemplateSetForContextName()

static ilOrgUnitPermissionQueries::getTemplateSetForContextName (   $context_name,
  $position_id,
  $editable = false 
)
static
Parameters
$context_name
$position_id
bool$editable
Returns
Exceptions

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

References ilOrgUnitOperationContextQueries\findByName(), ilOrgUnitPermission\PARENT_TEMPLATE, and ActiveRecord\where().

Referenced by getAllTemplateSetsForAllActivedContexts(), and hasLocalSet().

22  {
23  // TODO write performant query
24  $context = ilOrgUnitOperationContextQueries::findByName($context_name);
25  if (!$context) {
26  throw new ilException('No context found');
27  }
28  if (!$position_id) {
29  throw new ilException('$position_id cannot be null');
30  }
31 
32  $template_set = ilOrgUnitPermission::where([
34  'context_id' => $context->getId(),
35  'position_id' => $position_id,
36  ])->first();
37 
38  if (!$template_set) {
39  $template_set = new ilOrgUnitPermission();
40  $template_set->setParentId(ilOrgUnitPermission::PARENT_TEMPLATE);
41  $template_set->setContextId($context->getId());
42  $template_set->setPositionId($position_id);
43  $template_set->setNewlyCreated(true);
44  $template_set->create();
45  $template_set->afterObjectLoad();
46  }
47 
48  $template_set->setProtected(!$editable);
49 
50  return $template_set;
51  }
static where($where, $operator=null)
Class ilOrgUnitPermissionGUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasLocalSet()

static ilOrgUnitPermissionQueries::hasLocalSet (   $ref_id,
  $position_id 
)
static
Parameters
$ref_id
$position_id
Returns
bool

Definition at line 60 of file class.ilOrgUnitPermissionQueries.php.

References $template, ilOrgUnitGlobalSettings\getInstance(), getTemplateSetForContextName(), and ActiveRecord\where().

Referenced by ilOrgUnitPermissionTableGUI\dic().

61  {
63  'parent_id' => $ref_id,
64  'position_id' => $position_id,
65  ])->hasSets());
66  }
static where($where, $operator=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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