ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilOrgUnitOperationQueries.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
24  public static function registerNewOperation($operation_name, $description, $context = ilOrgUnitOperationContext::CONTEXT_OBJECT)
25  {
26  $contextList = ilOrgUnitOperationContext::where(array( 'context' => $context ));
27  if (!$contextList->hasSets()) {
28  throw new ilException('Context does not exist! register context first using ilOrgUnitOperationContext::registerNewContext()');
29  }
33  $ilOrgUnitOperationContext = $contextList->first();
34 
35  if (ilOrgUnitOperation::where(array(
36  'context_id' => $ilOrgUnitOperationContext->getId(),
37  'operation_string' => $operation_name,
38  ))->hasSets()) {
39  throw new ilException('This operation in this context has already been registered.');
40  }
41  $operation = new ilOrgUnitOperation();
42  $operation->setOperationString($operation_name);
43  $operation->setContextId($ilOrgUnitOperationContext->getId());
44  $operation->setDescription($description);
45  $operation->create();
46  }
47 
48 
56  public static function registerNewOperationForMultipleContexts($operation_name, $description, array $contexts)
57  {
58  foreach ($contexts as $context) {
59  self::registerNewOperation($operation_name, $description, $context);
60  }
61  }
62 
63 
69  public static function getOperationsForContextName($context_name)
70  {
75 
76  return ilOrgUnitOperation::where(array( 'context_id' => $context->getPopulatedContextIds() ))
77  ->get();
78  }
79 
80 
86  public static function getOperationsForContextId($context_id)
87  {
92 
93  return ilOrgUnitOperation::where(array( 'context_id' => $context->getPopulatedContextIds() ))
94  ->get();
95  }
96 
97 
103  public static function findById($operation_id)
104  {
105  return ilOrgUnitOperation::findOrFail($operation_id);
106  }
107 
108 
114  public static function findByOperationString($operation_string, $context_name)
115  {
117 
118  return ilOrgUnitOperation::where([ 'operation_string' => $operation_string, 'context_id' => $context->getId() ])->first();
119  }
120 }
static registerNewOperationForMultipleContexts($operation_name, $description, array $contexts)
$context
Definition: webdav.php:25
Class ilOrgUnitOperationQueries.
static where($where, $operator=null)
static findOrFail($primary_key, array $add_constructor_args=array())
Tries to find the object and throws an Exception if object is not found, instead of returning null...
Class ilOrgUnitOperation.
static findByOperationString($operation_string, $context_name)