ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilSkillObjDeletionHandler.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 
32 {
33  protected int $obj_id = 0;
34  protected string $obj_type = "";
35  protected Profile\SkillProfileManager $profile_manager;
36  protected Profile\SkillProfileCompletionManager $profile_completion_manager;
37  protected Personal\PersonalSkillManager $personal_manager;
38  protected Personal\AssignedMaterialManager $assigned_material_manager;
39  protected Usage\SkillUsageManager $usage_manager;
40 
41  public function __construct(int $obj_id, string $obj_type)
42  {
43  global $DIC;
44 
45  $this->obj_type = $obj_type;
46  $this->obj_id = $obj_id;
47  $this->profile_manager = $DIC->skills()->internal()->manager()->getProfileManager();
48  $this->profile_completion_manager = $DIC->skills()->internal()->manager()->getProfileCompletionManager();
49  $this->personal_manager = $DIC->skills()->internal()->manager()->getPersonalSkillManager();
50  $this->assigned_material_manager = $DIC->skills()->internal()->manager()->getAssignedMaterialManager();
51  $this->usage_manager = $DIC->skills()->internal()->manager()->getUsageManager();
52  }
53 
54  public function processDeletion(): void
55  {
56  if ($this->obj_type == "usr" && ilObject::_lookupType($this->obj_id) == "usr") {
57  $this->personal_manager->removePersonalSkillsForUser($this->obj_id);
58  $this->assigned_material_manager->removeAssignedMaterialsForUser($this->obj_id);
59  $this->profile_manager->removeUserFromAllProfiles($this->obj_id);
60  $this->profile_completion_manager->deleteEntriesForUser($this->obj_id);
61  ilBasicSkill::removeAllUserData($this->obj_id);
62  return;
63  } elseif ($this->obj_type == "role" && ilObject::_lookupType($this->obj_id) == "role") {
64  $this->profile_manager->removeRoleFromAllProfiles($this->obj_id);
65  return;
66  } elseif ($this->obj_type == "crs" && ilObject::_lookupType($this->obj_id) == "crs") {
67  foreach (ilContainerReference::_getAllReferences($this->obj_id) as $ref_id) {
68  if ($ref_id != 0) {
69  $this->profile_manager->deleteProfilesFromObject($ref_id);
70  }
71  }
72  } elseif ($this->obj_type == "grp" && ilObject::_lookupType($this->obj_id) == "grp") {
73  foreach (ilContainerReference::_getAllReferences($this->obj_id) as $ref_id) {
74  if ($ref_id != 0) {
75  $this->profile_manager->deleteProfilesFromObject($ref_id);
76  }
77  }
78  }
79  $this->usage_manager->removeUsagesFromObject($this->obj_id);
80  }
81 }
__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:65
global $DIC
Definition: shib_login.php:22
static removeAllUserData(int $a_user_id)
Personal AssignedMaterialManager $assigned_material_manager
Personal PersonalSkillManager $personal_manager
static _lookupType(int $id, bool $reference=false)