ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Skill\Profile\SkillProfileUserDBRepository Class Reference
+ Collaboration diagram for ILIAS\Skill\Profile\SkillProfileUserDBRepository:

Public Member Functions

 __construct (?\ilDBInterface $db=null, ?Service\SkillInternalFactoryService $factory_service=null)
 
 get (int $profile_id)
 
 getFromRecord (array $rec)
 
 addUserToProfile (int $profile_id, int $user_id)
 
 removeUserFromProfile (int $profile_id, int $user_id)
 
 removeUserFromAllProfiles (int $user_id)
 
 deleteProfileUsers (int $profile_id)
 
 getProfilesOfUser (int $user_id)
 
 countUsers (int $profile_id)
 

Protected Member Functions

 getProfileFromRecord (array $rec)
 

Protected Attributes

ilDBInterface $db
 
Service SkillInternalFactoryService $factory_service
 

Detailed Description

Definition at line 25 of file class.SkillProfileUserDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::__construct ( ?\ilDBInterface  $db = null,
?Service\SkillInternalFactoryService  $factory_service = null 
)

Definition at line 30 of file class.SkillProfileUserDBRepository.php.

33 {
34 global $DIC;
35
36 $this->db = ($db) ?: $DIC->database();
37 $this->factory_service = ($factory_service) ?: $DIC->skills()->internal()->factory();
38 }
global $DIC
Definition: shib_login.php:26

References ILIAS\Skill\Profile\SkillProfileUserDBRepository\$db, $DIC, and ILIAS\Skill\Profile\SkillProfileUserDBRepository\$factory_service.

Member Function Documentation

◆ addUserToProfile()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::addUserToProfile ( int  $profile_id,
int  $user_id 
)

Definition at line 64 of file class.SkillProfileUserDBRepository.php.

64 : void
65 {
67
68 $ilDB->replace(
69 "skl_profile_user",
70 array("profile_id" => array("integer", $profile_id),
71 "user_id" => array("integer", $user_id),
72 ),
73 []
74 );
75 }

References ILIAS\Skill\Profile\SkillProfileUserDBRepository\$db, $ilDB, and $user_id.

◆ countUsers()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::countUsers ( int  $profile_id)

Definition at line 148 of file class.SkillProfileUserDBRepository.php.

148 : int
149 {
151
152 $set = $ilDB->query(
153 "SELECT count(*) ucnt FROM skl_profile_user " .
154 " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
155 );
156 $rec = $ilDB->fetchAssoc($set);
157 return (int) $rec["ucnt"];
158 }

References ILIAS\Skill\Profile\SkillProfileUserDBRepository\$db, and $ilDB.

◆ deleteProfileUsers()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::deleteProfileUsers ( int  $profile_id)

Definition at line 98 of file class.SkillProfileUserDBRepository.php.

98 : void
99 {
101
102 $ilDB->manipulate(
103 "DELETE FROM skl_profile_user WHERE " .
104 " profile_id = " . $ilDB->quote($profile_id, "integer")
105 );
106 }

References ILIAS\Skill\Profile\SkillProfileUserDBRepository\$db, and $ilDB.

◆ get()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::get ( int  $profile_id)

Definition at line 40 of file class.SkillProfileUserDBRepository.php.

40 : array
41 {
43
44 $set = $ilDB->query(
45 "SELECT * FROM skl_profile_user " .
46 " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
47 );
48 $users = [];
49 while ($rec = $ilDB->fetchAssoc($set)) {
50 $users[] = $rec;
51 }
52
53 return $users;
54 }

References ILIAS\Skill\Profile\SkillProfileUserDBRepository\$db, and $ilDB.

◆ getFromRecord()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::getFromRecord ( array  $rec)

Definition at line 56 of file class.SkillProfileUserDBRepository.php.

56 : SkillProfileUserAssignment
57 {
58 return $this->factory_service->profile()->profileUserAssignment(
59 $rec["name"],
60 $rec["id"]
61 );
62 }

◆ getProfileFromRecord()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::getProfileFromRecord ( array  $rec)
protected

Definition at line 129 of file class.SkillProfileUserDBRepository.php.

129 : SkillProfile
130 {
131 $rec["id"] = (int) $rec["id"];
132 $rec["title"] = (string) $rec["title"];
133 $rec["description"] = (string) $rec["description"];
134 $rec["skill_tree_id"] = (int) $rec["skill_tree_id"];
135 $rec["image_id"] = (string) $rec["image_id"];
136 $rec["ref_id"] = (int) $rec["ref_id"];
137
138 return $this->factory_service->profile()->profile(
139 $rec["id"],
140 $rec["title"],
141 $rec["description"],
142 $rec["skill_tree_id"],
143 $rec["image_id"],
144 $rec["ref_id"]
145 );
146 }

References ILIAS\Repository\int().

Referenced by ILIAS\Skill\Profile\SkillProfileUserDBRepository\getProfilesOfUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProfilesOfUser()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::getProfilesOfUser ( int  $user_id)
Returns
SkillProfile[]

Definition at line 111 of file class.SkillProfileUserDBRepository.php.

111 : array
112 {
114
115 $user_profiles = [];
116 $set = $ilDB->query(
117 "SELECT p.id, p.title, p.description, p.ref_id, p.skill_tree_id, p.image_id " .
118 " FROM skl_profile_user u JOIN skl_profile p ON (u.profile_id = p.id) " .
119 " WHERE u.user_id = " . $ilDB->quote($user_id, "integer") .
120 " ORDER BY p.title ASC"
121 );
122 while ($rec = $ilDB->fetchAssoc($set)) {
123 $user_profiles[] = $this->getProfileFromRecord($rec);
124 }
125
126 return $user_profiles;
127 }

References ILIAS\Skill\Profile\SkillProfileUserDBRepository\$db, $ilDB, $user_id, and ILIAS\Skill\Profile\SkillProfileUserDBRepository\getProfileFromRecord().

+ Here is the call graph for this function:

◆ removeUserFromAllProfiles()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::removeUserFromAllProfiles ( int  $user_id)

Definition at line 88 of file class.SkillProfileUserDBRepository.php.

88 : void
89 {
91
92 $ilDB->manipulate(
93 "DELETE FROM skl_profile_user WHERE " .
94 " user_id = " . $ilDB->quote($user_id, "integer")
95 );
96 }

References ILIAS\Skill\Profile\SkillProfileUserDBRepository\$db, $ilDB, and $user_id.

◆ removeUserFromProfile()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::removeUserFromProfile ( int  $profile_id,
int  $user_id 
)

Definition at line 77 of file class.SkillProfileUserDBRepository.php.

77 : void
78 {
80
81 $ilDB->manipulate(
82 "DELETE FROM skl_profile_user WHERE " .
83 " profile_id = " . $ilDB->quote($profile_id, "integer") .
84 " AND user_id = " . $ilDB->quote($user_id, "integer")
85 );
86 }

References ILIAS\Skill\Profile\SkillProfileUserDBRepository\$db, $ilDB, and $user_id.

Field Documentation

◆ $db

◆ $factory_service

Service SkillInternalFactoryService ILIAS\Skill\Profile\SkillProfileUserDBRepository::$factory_service
protected

The documentation for this class was generated from the following file: