3 declare(strict_types=1);
36 protected \ilLanguage
$lng;
46 $this->profile_repo = (
$profile_repo) ?: $DIC->skills()->internal()->repo()->getProfileRepo();
47 $this->profile_levels_repo = (
$profile_levels_repo) ?: $DIC->skills()->internal()->repo()->getProfileLevelsRepo();
48 $this->profile_user_repo = (
$profile_user_repo) ?: $DIC->skills()->internal()->repo()->getProfileUserRepo();
49 $this->profile_role_repo = (
$profile_role_repo) ?: $DIC->skills()->internal()->repo()->getProfileRoleRepo();
50 $this->rbac_review = $DIC->rbac()->review();
51 $this->
lng = $DIC->language();
59 return $this->profile_repo->get($profile_id);
65 $new_profile = $this->profile_repo->createProfile($profile);
73 $updated_profile = $this->profile_repo->updateProfile($profile);
75 return $updated_profile;
78 public function delete(
int $profile_id):
void 88 $this->profile_repo->deleteProfile($profile_id);
93 $this->profile_levels_repo->deleteAllForProfile($profile_id);
98 $this->profile_levels_repo->deleteAllForSkill($skill_node_id, $is_reference);
103 $this->profile_user_repo->deleteProfileUsers($profile_id);
108 $this->profile_role_repo->deleteProfileRoles($profile_id);
113 $this->profile_repo->deleteProfilesFromObject($ref_id);
121 $levels = $this->profile_levels_repo->getAll($profile_id);
131 $level = $this->profile_levels_repo->get($profile_id, $base_skill_id, $tref_id);
137 $this->profile_levels_repo->createOrUpdate($skill_level_obj);
142 $this->profile_levels_repo->createOrUpdate($skill_level_obj);
147 $this->profile_levels_repo->delete($skill_level_obj);
154 $this->profile_levels_repo->updateSkillOrder($profile_id, $order);
159 $this->profile_levels_repo->fixSkillOrderNumbering($profile_id);
164 $max = $this->profile_levels_repo->getMaxOrderNr($profile_id);
173 $profiles = $this->profile_repo->getProfilesForAllSkillTrees();
182 $profiles = $this->profile_repo->getProfilesForSkillTree($skill_tree_id);
191 $profiles = $this->profile_repo->getAllGlobalProfiles();
200 $profiles = $this->profile_repo->getLocalProfilesForObject($ref_id);
206 $title = $this->profile_repo->lookup($profile_id,
"title");
212 $ref_id = $this->profile_repo->lookup($profile_id,
"ref_id");
221 $this->profile_repo->updateRefIdAfterImport($profile_id, $new_ref_id);
226 $tree_id = $this->profile_repo->getTreeId($profile_id);
242 $users = $this->getUserAssignments($profile_id);
243 $roles = $this->getRoleAssignments($profile_id);
244 $assignments = array_merge($users, $roles);
252 public function getUserAssignments(
int $profile_id): array
256 $users = $this->profile_user_repo->get($profile_id);
259 foreach ($users as $u) {
260 $u[
"user_id"] = (
int) $u[
"user_id"];
261 $u[
"profile_id"] = (
int) $u[
"profile_id"];
264 $user_restructured = [
266 "id" => $u[
"user_id"]
269 $users_as_obj[] = $this->profile_user_repo->getFromRecord($user_restructured);
272 return $users_as_obj;
280 return $this->rbac_review->assignedUsers($role_id);
289 $users = $this->getUserAssignments($profile_id);
290 foreach ($users as $user) {
291 $all[] = $user->getId();
294 $roles = $this->getRoleAssignments($profile_id);
295 foreach ($roles as $role) {
296 $role_users = $this->rbac_review->assignedUsers($role->getId());
297 foreach ($role_users as $user_id) {
298 if (!in_array($user_id, $all)) {
309 $this->profile_user_repo->addUserToProfile($profile_id, $user_id);
314 $this->profile_user_repo->removeUserFromProfile($profile_id, $user_id);
319 $this->profile_user_repo->removeUserFromAllProfiles($user_id);
325 public function getProfilesOfUser(
int $user_id): array
330 $user_profiles = $this->profile_user_repo->getProfilesOfUser($user_id);
334 $user_roles = $this->rbac_review->assignedRoles($user_id);
335 foreach ($user_roles as $role) {
337 foreach ($profiles as $profile) {
338 $role_profiles[] = $profile;
345 $all_profiles = array_merge($user_profiles, $role_profiles);
348 foreach ($all_profiles as $v) {
349 if (!isset($temp_profiles[$v->getId()])) {
350 $temp_profiles[$v->getId()] = $v;
353 $all_profiles = array_values($temp_profiles);
354 return $all_profiles;
359 $count = $this->profile_user_repo->countUsers($profile_id);
366 public function getRoleAssignments(
int $profile_id,
bool $with_objects_in_trash =
false): array
371 $roles = $this->profile_role_repo->get($profile_id);
373 $roles_as_obj_without_trash = [];
375 $roles_as_obj_with_trash = [];
376 foreach ($roles as
$r) {
377 $r[
"role_id"] = (
int) $r[
"role_id"];
378 $r[
"profile_id"] = (
int) $r[
"profile_id"];
385 $role_restructured = [
387 "id" => $r[
"role_id"],
388 "object_title" => $obj_title,
389 "object_type" => $obj_type,
390 "object_id" => $obj_id
394 $roles_as_obj_without_trash[] = $this->profile_role_repo->getRoleAssignmentFromRecord($role_restructured);
396 $roles_as_obj_with_trash[] = $this->profile_role_repo->getRoleAssignmentFromRecord($role_restructured);
399 if ($with_objects_in_trash) {
400 return $roles_as_obj_with_trash;
402 return $roles_as_obj_without_trash;
407 $this->profile_role_repo->addRoleToProfile($profile_id, $role_id);
412 $this->profile_role_repo->removeRoleFromProfile($profile_id, $role_id);
417 $this->profile_role_repo->removeRoleFromAllProfiles($role_id);
426 $profiles = $this->profile_role_repo->getAllProfilesOfRole($role_id);
435 $profiles = $this->profile_role_repo->getGlobalProfilesOfRole($role_id);
444 $profiles = $this->profile_role_repo->getLocalProfilesOfRole($role_id);
450 $count = $this->profile_role_repo->countRoles($profile_id);
461 $usage_manager = $DIC->skills()->internal()->manager()->getUsageManager();
463 return $usage_manager->getUsageInfoGeneric(
deleteProfileRoles(int $profile_id)
deleteProfilesFromObject(int $ref_id)
createProfile(SkillProfile $profile)
addSkillLevel(SkillProfileLevel $skill_level_obj)
deleteProfile(int $profile_id)
Class ChatMainBarProvider .
removeRoleFromAllProfiles(int $role_id)
updateRefIdAfterImport(int $profile_id, int $new_ref_id)
Update the old ref id with the new ref id after import.
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
updateSkillOrder(int $profile_id, array $order)
getSkillLevels(int $profile_id)
SkillProfileLevelsDBRepository $profile_levels_repo
SkillProfileUserDBRepository $profile_user_repo
getLocalProfilesForObject(int $ref_id)
addRoleToProfile(int $profile_id, int $role_id)
countRoles(int $profile_id)
lookupRefId(int $profile_id)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is:
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getTranslation(string $a_role_title)
updateSkillLevel(SkillProfileLevel $skill_level_obj)
static _lookupObjectId(int $ref_id)
removeRoleFromProfile(int $profile_id, int $role_id)
SkillProfileDBRepository $profile_repo
getAssignments(int $profile_id)
Get all assignments (users and roles)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilRbacReview $rbac_review
getLocalProfilesOfRole(int $role_id)
getProfilesForSkillTree(int $skill_tree_id)
removeUserFromProfile(int $profile_id, int $user_id)
getAllProfilesOfRole(int $role_id)
Get global and local profiles of a role.
removeSkillLevel(SkillProfileLevel $skill_level_obj)
SkillProfileRoleDBRepository $profile_role_repo
deleteProfileUsers(int $profile_id)
getProfilesForAllSkillTrees()
__construct(\ILIAS\Skill\Profile\SkillProfileDBRepository $profile_repo=null, \ILIAS\Skill\Profile\SkillProfileLevelsDBRepository $profile_levels_repo=null, \ILIAS\Skill\Profile\SkillProfileUserDBRepository $profile_user_repo=null, \ILIAS\Skill\Profile\SkillProfileRoleDBRepository $profile_role_repo=null)
getSkillLevel(int $profile_id, int $base_skill_id, int $tref_id)
getMaxLevelOrderNr(int $profile_id)
getProfile(int $profile_id)
removeUserFromAllProfiles(int $user_id)
getAssignedUserIdsIncludingRoleAssignments(int $profile_id)
static _lookupType(int $id, bool $reference=false)
getTreeId(int $profile_id)
Get info on usages of skills.
fixSkillOrderNumbering(int $profile_id)
getGlobalProfilesOfRole(int $role_id)
deleteProfileLevelsForSkill(int $skill_node_id, bool $is_reference=false)
deleteProfileLevels(int $profile_id)
lookupTitle(int $profile_id)
addUserToProfile(int $profile_id, int $user_id)
static getUsageInfo(array $a_cskill_ids)
Get title of an assigned item.int, tref_id: int}[] $a_cskill_ids array of common skill idsarray<strin...
updateProfile(SkillProfile $profile)
countUsers(int $profile_id)
getAssignedUsersForRole(int $role_id)