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