ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
RemoveUserIdFromPositionInOrgUnit.php
Go to the documentation of this file.
1 <?php
2 
21 
22 use ilObject2;
23 use ilObjUser;
25 use LogicException;
26 use SoapFault;
27 
33 {
37  protected function run(array $params): bool
38  {
39  $position_id = $params[self::POSITION_ID];
40  $user_id = $params[self::USR_ID];
41  $orgu_ref_id = $params[self::ORGU_REF_ID];
42 
44  throw new LogicException("User does not exist");
45  }
46  if (!$this->positionRepo->getSingle($position_id, 'id') instanceof ilOrgUnitPosition) {
47  throw new LogicException("Position does not exist");
48  }
49  if (ilObject2::_lookupType($orgu_ref_id, true) !== 'orgu') {
50  throw new LogicException("OrgUnit does not exist");
51  } else {
52  $assignment = $this->assignmentRepo->find($user_id, $position_id, $orgu_ref_id);
53  if ($assignment) {
54  $this->assignmentRepo->delete($assignment);
55  } else {
56  $this->addError("No assignment found");
57  }
58  }
59 
60  return true;
61  }
62 
66  public function getName(): string
67  {
68  return "removeUserFromPositionInOrgUnit";
69  }
70 
71  protected function getAdditionalInputParams(): array
72  {
73  return array(self::POSITION_ID => Base::TYPE_INT,
74  self::USR_ID => Base::TYPE_INT,
75  self::ORGU_REF_ID => Base::TYPE_INT
76  );
77  }
78 
79  public function getOutputParams(): array
80  {
81  return [];
82  }
83 
84  public function getDocumentation(): string
85  {
86  return "Removes a user from a position in a orgunit";
87  }
88 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
getOutputParams()
Get the output parameters in the same format as the input parameters.
static _lookupType(int $id, bool $reference=false)