ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
AddUserIdToPositionInOrgUnit.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use ilObject2;
6 use ilObjUser;
8 
15 {
16 
23  protected function run(array $params)
24  {
25  $position_id = $params[self::POSITION_ID];
26  $user_id = $params[self::USR_ID];
27  $orgu_ref_id = $params[self::ORGU_REF_ID];
28 
29  if (!ilObjUser::_exists($user_id)) {
30  $this->error("user does not exist");
31  } elseif (!ilOrgUnitPosition::find($position_id) instanceof ilOrgUnitPosition) {
32  $this->error("Position does not exist");
33  } elseif (ilObject2::_lookupType($orgu_ref_id, true) !== 'orgu') {
34  $this->error("OrgUnit does not exist");
35  } else {
36  \ilOrgUnitUserAssignment::findOrCreateAssignment($user_id, $position_id, $orgu_ref_id);
37  }
38  }
39 
40 
44  public function getName()
45  {
46  return "addUserToPositionInOrgUnit";
47  }
48 
49 
53  protected function getAdditionalInputParams()
54  {
55  return array(self::POSITION_ID => Base::TYPE_INT, self::USR_ID => Base::TYPE_INT, self::ORGU_REF_ID => Base::TYPE_INT);
56  }
57 
58 
62  public function getOutputParams()
63  {
64  return [];
65  }
66 
67 
71  public function getDocumentation()
72  {
73  return "Adds a user to a position in a orgunit";
74  }
75 }
static findOrCreateAssignment($user_id, $position_id, $orgu_id)
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
getDocumentation()
Get the documentation of this method.string
getOutputParams()
Get the output parameters in the same format as the input parameters.array
static _lookupType($a_id, $a_reference=false)