ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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  ) {
40  throw new ilException('This operation in this context has already been registered.');
41  }
42  $operation = new ilOrgUnitOperation();
43  $operation->setOperationString($operation_name);
44  $operation->setContextId($ilOrgUnitOperationContext->getId());
45  $operation->setDescription($description);
46  $operation->create();
47  }
48 
49 
57  public static function registerNewOperationForMultipleContexts($operation_name, $description, array $contexts)
58  {
59  foreach ($contexts as $context) {
60  self::registerNewOperation($operation_name, $description, $context);
61  }
62  }
63 
64 
70  public static function getOperationsForContextName($context_name)
71  {
76 
77  return ilOrgUnitOperation::where(array('context_id' => $context->getPopulatedContextIds()))
78  ->get();
79  }
80 
81 
87  public static function getOperationsForContextId($context_id)
88  {
93 
94  return ilOrgUnitOperation::where(array('context_id' => $context->getPopulatedContextIds()))
95  ->get();
96  }
97 
98 
104  public static function findById($operation_id)
105  {
106  return ilOrgUnitOperation::findOrFail($operation_id);
107  }
108 
109 
115  public static function findByOperationString($operation_string, $context_name)
116  {
118 
119  return ilOrgUnitOperation::where(['operation_string' => $operation_string, 'context_id' => $context->getId()])->first();
120  }
121 }
static registerNewOperationForMultipleContexts($operation_name, $description, array $contexts)
$context
Definition: webdav.php:26
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...
static findByOperationString($operation_string, $context_name)