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

Public Member Functions

 __construct (?\ilDBInterface $db=null, ?Service\SkillInternalFactoryService $factory_service=null)
 
 get (int $profile_id)
 
 getNextId ()
 
 createProfile (SkillProfile $profile)
 
 updateProfile (SkillProfile $profile)
 
 deleteProfile (int $profile_id)
 
 deleteProfilesFromObject (int $ref_id)
 
 getProfilesForAllSkillTrees ()
 
 getProfilesForSkillTree (int $skill_tree_id)
 
 getAllGlobalProfiles ()
 
 getLocalProfilesForObject (int $ref_id)
 
 lookup (int $id, string $field)
 
 updateRefIdAfterImport (int $profile_id, int $new_ref_id)
 
 getTreeId (int $profile_id)
 

Protected Member Functions

 getFromRecord (array $rec)
 

Protected Attributes

ilDBInterface $db
 
Service SkillInternalFactoryService $factory_service
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 30 of file class.SkillProfileDBRepository.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\SkillProfileDBRepository\$db, $DIC, and ILIAS\Skill\Profile\SkillProfileDBRepository\$factory_service.

Member Function Documentation

◆ createProfile()

ILIAS\Skill\Profile\SkillProfileDBRepository::createProfile ( SkillProfile  $profile)

Definition at line 82 of file class.SkillProfileDBRepository.php.

84 : SkillProfile {
86
87 $new_profile_id = $this->getNextId();
88 $ilDB->manipulate("INSERT INTO skl_profile " .
89 "(id, title, description, skill_tree_id, image_id, ref_id) VALUES (" .
90 $ilDB->quote($new_profile_id, "integer") . "," .
91 $ilDB->quote($profile->getTitle(), "text") . "," .
92 $ilDB->quote($profile->getDescription(), "text") . "," .
93 $ilDB->quote($profile->getSkillTreeId(), "integer") . "," .
94 $ilDB->quote($profile->getImageId(), "text") . "," .
95 $ilDB->quote($profile->getRefId(), "integer") .
96 ")");
97
98 return $this->get($new_profile_id);
99 }

◆ deleteProfile()

ILIAS\Skill\Profile\SkillProfileDBRepository::deleteProfile ( int  $profile_id)

Definition at line 119 of file class.SkillProfileDBRepository.php.

119 : void
120 {
122
123 $ilDB->manipulate(
124 "DELETE FROM skl_profile WHERE " .
125 " id = " . $ilDB->quote($profile_id, "integer")
126 );
127 }

References $ilDB.

◆ deleteProfilesFromObject()

ILIAS\Skill\Profile\SkillProfileDBRepository::deleteProfilesFromObject ( int  $ref_id)

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

129 : void
130 {
132
133 $ilDB->manipulate(
134 "DELETE FROM skl_profile WHERE " .
135 " ref_id = " . $ilDB->quote($ref_id, "integer")
136 );
137 }
$ref_id
Definition: ltiauth.php:66

References $ilDB, and $ref_id.

◆ get()

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

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

40 : SkillProfile
41 {
43
44 $set = $ilDB->query(
45 "SELECT * FROM skl_profile " .
46 " WHERE id = " . $ilDB->quote($profile_id, "integer")
47 );
48
49 if ($rec = $ilDB->fetchAssoc($set)) {
50 return $this->getFromRecord($rec);
51 }
52 throw new \ilSkillProfileNotFoundException("Profile with ID $profile_id not found.");
53 }

References ILIAS\Skill\Profile\SkillProfileDBRepository\$db, $ilDB, and ILIAS\Skill\Profile\SkillProfileDBRepository\getFromRecord().

+ Here is the call graph for this function:

◆ getAllGlobalProfiles()

ILIAS\Skill\Profile\SkillProfileDBRepository::getAllGlobalProfiles ( )
Returns
SkillProfile[]

Definition at line 181 of file class.SkillProfileDBRepository.php.

181 : array
182 {
184
185 $set = $ilDB->query(
186 "SELECT * FROM skl_profile " .
187 " WHERE ref_id = 0 " .
188 " ORDER BY title "
189 );
190 $profiles = [];
191 while ($rec = $ilDB->fetchAssoc($set)) {
192 $profiles[] = $this->getFromRecord($rec);
193 }
194
195 return $profiles;
196 }

References $ilDB.

◆ getFromRecord()

ILIAS\Skill\Profile\SkillProfileDBRepository::getFromRecord ( array  $rec)
protected

Definition at line 55 of file class.SkillProfileDBRepository.php.

55 : SkillProfile
56 {
57 $rec["id"] = (int) $rec["id"];
58 $rec["title"] = (string) $rec["title"];
59 $rec["description"] = (string) $rec["description"];
60 $rec["skill_tree_id"] = (int) $rec["skill_tree_id"];
61 $rec["image_id"] = (string) $rec["image_id"];
62 $rec["ref_id"] = (int) $rec["ref_id"];
63
64 return $this->factory_service->profile()->profile(
65 $rec["id"],
66 $rec["title"],
67 $rec["description"],
68 $rec["skill_tree_id"],
69 $rec["image_id"],
70 $rec["ref_id"]
71 );
72 }

References ILIAS\Repository\int().

Referenced by ILIAS\Skill\Profile\SkillProfileDBRepository\get().

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

◆ getLocalProfilesForObject()

ILIAS\Skill\Profile\SkillProfileDBRepository::getLocalProfilesForObject ( int  $ref_id)
Returns
SkillProfile[]

Definition at line 201 of file class.SkillProfileDBRepository.php.

201 : array
202 {
204
205 $set = $ilDB->query(
206 "SELECT * FROM skl_profile " .
207 " WHERE ref_id = " . $ref_id .
208 " ORDER BY title "
209 );
210 $profiles = [];
211 while ($rec = $ilDB->fetchAssoc($set)) {
212 $profiles[] = $this->getFromRecord($rec);
213 }
214
215 return $profiles;
216 }

References $ilDB, and $ref_id.

◆ getNextId()

ILIAS\Skill\Profile\SkillProfileDBRepository::getNextId ( )

Definition at line 74 of file class.SkillProfileDBRepository.php.

74 : int
75 {
77
78 $next_id = $ilDB->nextId("skl_profile");
79 return $next_id;
80 }

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

◆ getProfilesForAllSkillTrees()

ILIAS\Skill\Profile\SkillProfileDBRepository::getProfilesForAllSkillTrees ( )
Returns
SkillProfile[]

Definition at line 142 of file class.SkillProfileDBRepository.php.

142 : array
143 {
145
146 $set = $ilDB->query(
147 "SELECT * FROM skl_profile " .
148 " ORDER BY title "
149 );
150 $profiles = [];
151 while ($rec = $ilDB->fetchAssoc($set)) {
152 $profiles[] = $this->getFromRecord($rec);
153 }
154
155 return $profiles;
156 }

References $ilDB.

◆ getProfilesForSkillTree()

ILIAS\Skill\Profile\SkillProfileDBRepository::getProfilesForSkillTree ( int  $skill_tree_id)
Returns
SkillProfile[]

Definition at line 161 of file class.SkillProfileDBRepository.php.

161 : array
162 {
164
165 $set = $ilDB->query(
166 "SELECT * FROM skl_profile " .
167 " WHERE skill_tree_id = " . $ilDB->quote($skill_tree_id, "integer") .
168 " ORDER BY title "
169 );
170 $profiles = [];
171 while ($rec = $ilDB->fetchAssoc($set)) {
172 $profiles[] = $this->getFromRecord($rec);
173 }
174
175 return $profiles;
176 }

References $ilDB.

◆ getTreeId()

ILIAS\Skill\Profile\SkillProfileDBRepository::getTreeId ( int  $profile_id)

Definition at line 246 of file class.SkillProfileDBRepository.php.

246 : int
247 {
248 $db = $this->db;
249
250 $set = $db->queryF(
251 "SELECT * FROM skl_profile " .
252 " WHERE id = %s ",
253 ["integer"],
254 [$profile_id]
255 );
256 $rec = $db->fetchAssoc($set);
257 return (int) ($rec["skill_tree_id"] ?? 0);
258 }
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)

◆ lookup()

ILIAS\Skill\Profile\SkillProfileDBRepository::lookup ( int  $id,
string  $field 
)

Definition at line 218 of file class.SkillProfileDBRepository.php.

218 : string
219 {
221
222 $set = $ilDB->query(
223 "SELECT " . $field . " FROM skl_profile " .
224 " WHERE id = " . $ilDB->quote($id, "integer")
225 );
226 $rec = $ilDB->fetchAssoc($set);
227
228 return (string) ($rec[$field] ?? "");
229 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, and $ilDB.

◆ updateProfile()

ILIAS\Skill\Profile\SkillProfileDBRepository::updateProfile ( SkillProfile  $profile)

Definition at line 101 of file class.SkillProfileDBRepository.php.

103 : SkillProfile {
105
106 // profile
107 $ilDB->manipulate(
108 "UPDATE skl_profile SET " .
109 " title = " . $ilDB->quote($profile->getTitle(), "text") . "," .
110 " description = " . $ilDB->quote($profile->getDescription(), "text") . "," .
111 " image_id = " . $ilDB->quote($profile->getImageId(), "text") .
112 " WHERE id = " . $ilDB->quote($profile->getId(), "integer") .
113 " AND ref_id = " . $ilDB->quote($profile->getRefId(), "integer")
114 );
115
116 return $this->get($profile->getId());
117 }

◆ updateRefIdAfterImport()

ILIAS\Skill\Profile\SkillProfileDBRepository::updateRefIdAfterImport ( int  $profile_id,
int  $new_ref_id 
)

Definition at line 231 of file class.SkillProfileDBRepository.php.

231 : void
232 {
234
235 $ilDB->update(
236 "skl_profile",
237 array(
238 "ref_id" => array("integer", $new_ref_id)
239 ),
240 array(
241 "id" => array("integer", $profile_id)
242 )
243 );
244 }

References $ilDB.

Field Documentation

◆ $db

◆ $factory_service

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

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