ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 26 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 31 of file class.SkillProfileDBRepository.php.

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

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

Member Function Documentation

◆ createProfile()

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

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

References ILIAS\Skill\Profile\SkillProfileDBRepository\$db, $ilDB, ILIAS\Skill\Profile\SkillProfile\getDescription(), ILIAS\Skill\Profile\SkillProfile\getImageId(), ILIAS\Skill\Profile\SkillProfileDBRepository\getNextId(), ILIAS\Skill\Profile\SkillProfile\getRefId(), ILIAS\Skill\Profile\SkillProfile\getSkillTreeId(), and ILIAS\Skill\Profile\SkillProfile\getTitle().

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

◆ deleteProfile()

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

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

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

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

◆ deleteProfilesFromObject()

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

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

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

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

◆ get()

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

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

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

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

◆ getAllGlobalProfiles()

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

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

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

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

◆ getFromRecord()

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

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

References ILIAS\Repository\int().

Referenced by ILIAS\Skill\Profile\SkillProfileDBRepository\get(), ILIAS\Skill\Profile\SkillProfileDBRepository\getAllGlobalProfiles(), ILIAS\Skill\Profile\SkillProfileDBRepository\getLocalProfilesForObject(), ILIAS\Skill\Profile\SkillProfileDBRepository\getProfilesForAllSkillTrees(), and ILIAS\Skill\Profile\SkillProfileDBRepository\getProfilesForSkillTree().

56  : SkillProfile
57  {
58  $rec["id"] = (int) $rec["id"];
59  $rec["title"] = (string) $rec["title"];
60  $rec["description"] = (string) $rec["description"];
61  $rec["skill_tree_id"] = (int) $rec["skill_tree_id"];
62  $rec["image_id"] = (string) $rec["image_id"];
63  $rec["ref_id"] = (int) $rec["ref_id"];
64 
65  return $this->factory_service->profile()->profile(
66  $rec["id"],
67  $rec["title"],
68  $rec["description"],
69  $rec["skill_tree_id"],
70  $rec["image_id"],
71  $rec["ref_id"]
72  );
73  }
+ 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 202 of file class.SkillProfileDBRepository.php.

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

202  : array
203  {
204  $ilDB = $this->db;
205 
206  $set = $ilDB->query(
207  "SELECT * FROM skl_profile " .
208  " WHERE ref_id = " . $ref_id .
209  " ORDER BY title "
210  );
211  $profiles = [];
212  while ($rec = $ilDB->fetchAssoc($set)) {
213  $profiles[] = $this->getFromRecord($rec);
214  }
215 
216  return $profiles;
217  }
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:

◆ getNextId()

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

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

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

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

75  : int
76  {
77  $ilDB = $this->db;
78 
79  $next_id = $ilDB->nextId("skl_profile");
80  return $next_id;
81  }
+ Here is the caller graph for this function:

◆ getProfilesForAllSkillTrees()

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

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

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

143  : array
144  {
145  $ilDB = $this->db;
146 
147  $set = $ilDB->query(
148  "SELECT * FROM skl_profile " .
149  " ORDER BY title "
150  );
151  $profiles = [];
152  while ($rec = $ilDB->fetchAssoc($set)) {
153  $profiles[] = $this->getFromRecord($rec);
154  }
155 
156  return $profiles;
157  }
+ Here is the call graph for this function:

◆ getProfilesForSkillTree()

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

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

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

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

◆ getTreeId()

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

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

References ILIAS\Skill\Profile\SkillProfileDBRepository\$db, and ilDBInterface\queryF().

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

◆ lookup()

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

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

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

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

◆ updateProfile()

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

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

References ILIAS\Skill\Profile\SkillProfileDBRepository\$db, $ilDB, ILIAS\Skill\Profile\SkillProfile\getDescription(), ILIAS\Skill\Profile\SkillProfile\getId(), ILIAS\Skill\Profile\SkillProfile\getImageId(), ILIAS\Skill\Profile\SkillProfile\getRefId(), and ILIAS\Skill\Profile\SkillProfile\getTitle().

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

◆ updateRefIdAfterImport()

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

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

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

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

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: