ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilSkillObjDeletionHandler.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
25 
33 {
34  protected int $obj_id = 0;
35  protected string $obj_type = "";
36  protected Profile\SkillProfileManager $profile_manager;
37  protected Profile\SkillProfileCompletionManager $profile_completion_manager;
38  protected Personal\PersonalSkillManager $personal_manager;
39  protected Personal\AssignedMaterialManager $assigned_material_manager;
40  protected Usage\SkillUsageManager $usage_manager;
41 
42  public function __construct(int $obj_id, string $obj_type)
43  {
44  global $DIC;
45 
46  $this->obj_type = $obj_type;
47  $this->obj_id = $obj_id;
48  $this->profile_manager = $DIC->skills()->internal()->manager()->getProfileManager();
49  $this->profile_completion_manager = $DIC->skills()->internal()->manager()->getProfileCompletionManager();
50  $this->personal_manager = $DIC->skills()->internal()->manager()->getPersonalSkillManager();
51  $this->assigned_material_manager = $DIC->skills()->internal()->manager()->getAssignedMaterialManager();
52  $this->usage_manager = $DIC->skills()->internal()->manager()->getUsageManager();
53  }
54 
55  public function processDeletion(): void
56  {
57  if ($this->obj_type == "usr" && ilObject::_lookupType($this->obj_id) == "usr") {
58  $this->personal_manager->removePersonalSkillsForUser($this->obj_id);
59  $this->assigned_material_manager->removeAssignedMaterialsForUser($this->obj_id);
60  $this->profile_manager->removeUserFromAllProfiles($this->obj_id);
61  $this->profile_completion_manager->deleteEntriesForUser($this->obj_id);
62  ilBasicSkill::removeAllUserData($this->obj_id);
63  return;
64  } elseif ($this->obj_type == "role" && ilObject::_lookupType($this->obj_id) == "role") {
65  $this->profile_manager->removeRoleFromAllProfiles($this->obj_id);
66  return;
67  } elseif ($this->obj_type == "crs" && ilObject::_lookupType($this->obj_id) == "crs") {
68  foreach (ilContainerReference::_getAllReferences($this->obj_id) as $ref_id) {
69  if ($ref_id != 0) {
70  $this->profile_manager->deleteProfilesFromObject($ref_id);
71  }
72  }
73  } elseif ($this->obj_type == "grp" && ilObject::_lookupType($this->obj_id) == "grp") {
74  foreach (ilContainerReference::_getAllReferences($this->obj_id) as $ref_id) {
75  if ($ref_id != 0) {
76  $this->profile_manager->deleteProfilesFromObject($ref_id);
77  }
78  }
79  }
80  $this->usage_manager->removeUsagesFromObject($this->obj_id);
81  }
82 }
__construct(int $obj_id, string $obj_type)
Profile SkillProfileCompletionManager $profile_completion_manager
Handles deletion of (user) objects.
static _getAllReferences(int $id)
get all reference ids for object ID
Profile SkillProfileManager $profile_manager
$ref_id
Definition: ltiauth.php:66
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:25
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static removeAllUserData(int $a_user_id)
Personal AssignedMaterialManager $assigned_material_manager
Personal PersonalSkillManager $personal_manager
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)