ILIAS  release_8 Revision v8.24
AddUserIdToPositionInOrgUnit.php
Go to the documentation of this file.
1<?php
20
21use ilObject2;
22use ilObjUser;
24
30{
31 protected function run(array $params): bool
32 {
33 $position_id = $params[self::POSITION_ID];
34 $user_id = $params[self::USR_ID];
35 $orgu_ref_id = $params[self::ORGU_REF_ID];
36
37 if (!ilObjUser::_exists($user_id)) {
38 $this->addError("user does not exist");
39 } elseif (!ilOrgUnitPosition::find($position_id) instanceof ilOrgUnitPosition) {
40 $this->addError("Position does not exist");
41 } elseif (ilObject2::_lookupType($orgu_ref_id, true) !== 'orgu') {
42 $this->addError("OrgUnit does not exist");
43 } else {
44 \ilOrgUnitUserAssignment::findOrCreateAssignment($user_id, $position_id, $orgu_ref_id);
45 }
46
47 return true;
48 }
49
50 public function getName(): string
51 {
52 return "addUserToPositionInOrgUnit";
53 }
54
55 protected function getAdditionalInputParams(): array
56 {
57 return array(self::POSITION_ID => Base::TYPE_INT,
58 self::USR_ID => Base::TYPE_INT,
59 self::ORGU_REF_ID => Base::TYPE_INT
60 );
61 }
62
63 public function getOutputParams(): array
64 {
65 return [];
66 }
67
68 public function getDocumentation(): string
69 {
70 return "Adds a user to a position in a orgunit";
71 }
72}
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...
static findOrCreateAssignment(int $user_id, int $position_id, int $orgu_id)
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...