ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
RemoveUserIdFromPositionInOrgUnit.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use ilObject2;
6 use ilObjUser;
9 
16 {
17 
24  protected function run(array $params)
25  {
26  $position_id = $params[self::POSITION_ID];
27  $user_id = $params[self::USR_ID];
28  $orgu_ref_id = $params[self::ORGU_REF_ID];
29 
30  if (!ilObjUser::_exists($user_id)) {
31  throw new LogicException("User does not exist");
32  }
33  if (!ilOrgUnitPosition::find($position_id) instanceof ilOrgUnitPosition) {
34  throw new LogicException("Position does not exist");
35  }
36  if (ilObject2::_lookupType($orgu_ref_id, true) !== 'orgu') {
37  throw new LogicException("OrgUnit does not exist");
38  } else {
40  array(
41  'user_id' => $user_id,
42  'position_id' => $position_id,
43  'orgu_id' => $orgu_ref_id,
44  )
45  )->first();
46  if ($inst instanceof \ilOrgUnitUserAssignment) {
47  $inst->delete();
48  } else {
49  $this->error("No assignment found");
50  }
51  }
52  }
53 
54 
58  public function getName()
59  {
60  return "removeUserFromPositionInOrgUnit";
61  }
62 
63 
67  protected function getAdditionalInputParams()
68  {
69  return array(self::POSITION_ID => Base::TYPE_INT, self::USR_ID => Base::TYPE_INT, self::ORGU_REF_ID => Base::TYPE_INT);
70  }
71 
72 
76  public function getOutputParams()
77  {
78  return [];
79  }
80 
81 
85  public function getDocumentation()
86  {
87  return "Removes a user from a position in a orgunit";
88  }
89 }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
static where($where, $operator=null)
static _lookupType($a_id, $a_reference=false)
getOutputParams()
Get the output parameters in the same format as the input parameters.array