ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Skill\Profile\SkillProfileCompletionDBRepository Class Reference

Repository for skill profile completion. More...

+ Collaboration diagram for ILIAS\Skill\Profile\SkillProfileCompletionDBRepository:

Public Member Functions

 __construct (\ilDBInterface $db=null)
 
 getEntries (int $user_id, int $profile_id)
 Get profile completion entries for given user-profile-combination. More...
 
 addFulfilmentEntry (int $user_id, int $profile_id)
 Add profile fulfilment entry to given user-profile-combination. More...
 
 addNonFulfilmentEntry (int $user_id, int $profile_id)
 Add profile non-fulfilment entry to given user-profile-combination. More...
 
 getFulfilledEntriesForUser (int $user_id)
 Get all profile completion entries for a user. More...
 
 getAllEntriesForUser (int $user_id)
 Get all profile completion entries for a user. More...
 
 getAllEntriesForProfile (int $profile_id)
 Get all completion entries for a single profile. More...
 
 deleteEntriesForProfile (int $profile_id)
 Delete all profile completion entries for a profile. More...
 
 deleteEntriesForUser (int $user_id)
 Delete all profile completion entries for a user. More...
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

Repository for skill profile completion.

Author
Thomas Famula famul.nosp@m.a@le.nosp@m.ifos..nosp@m.de

Definition at line 27 of file class.SkillProfileCompletionDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::__construct ( \ilDBInterface  $db = null)

Definition at line 31 of file class.SkillProfileCompletionDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\$db, and $DIC.

32  {
33  global $DIC;
34 
35  $this->db = ($db) ?: $DIC->database();
36  }
global $DIC
Definition: feed.php:28

Member Function Documentation

◆ addFulfilmentEntry()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::addFulfilmentEntry ( int  $user_id,
int  $profile_id 
)

Add profile fulfilment entry to given user-profile-combination.

Definition at line 66 of file class.SkillProfileCompletionDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\$db, $ilDB, and ilUtil\now().

66  : void
67  {
68  $ilDB = $this->db;
69 
70  $set = $ilDB->query(
71  "SELECT * FROM skl_profile_completion " .
72  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer") .
73  " AND user_id = " . $ilDB->quote($user_id, "integer") .
74  " ORDER BY date DESC" .
75  " LIMIT 1"
76  );
77 
78  $entry = null;
79  while ($rec = $ilDB->fetchAssoc($set)) {
80  $entry = $rec["fulfilled"];
81  }
82 
83  if ($entry == 0) {
84  $now = \ilUtil::now();
85  $ilDB->manipulate("INSERT INTO skl_profile_completion " .
86  "(profile_id, user_id, date, fulfilled) VALUES (" .
87  $ilDB->quote($profile_id, "integer") . "," .
88  $ilDB->quote($user_id, "integer") . "," .
89  $ilDB->quote($now, "timestamp") . "," .
90  $ilDB->quote(1, "integer") .
91  ")");
92  }
93  }
static now()
Return current timestamp in Y-m-d H:i:s format.
+ Here is the call graph for this function:

◆ addNonFulfilmentEntry()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::addNonFulfilmentEntry ( int  $user_id,
int  $profile_id 
)

Add profile non-fulfilment entry to given user-profile-combination.

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

References ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\$db, $ilDB, and ilUtil\now().

98  : void
99  {
100  $ilDB = $this->db;
101 
102  $set = $ilDB->query(
103  "SELECT * FROM skl_profile_completion " .
104  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer") .
105  " AND user_id = " . $ilDB->quote($user_id, "integer") .
106  " ORDER BY date DESC" .
107  " LIMIT 1"
108  );
109 
110  $entry = null;
111  while ($rec = $ilDB->fetchAssoc($set)) {
112  $entry = $rec["fulfilled"];
113  }
114 
115  if (is_null($entry) || $entry == 1) {
116  $now = \ilUtil::now();
117  $ilDB->manipulate("INSERT INTO skl_profile_completion " .
118  "(profile_id, user_id, date, fulfilled) VALUES (" .
119  $ilDB->quote($profile_id, "integer") . "," .
120  $ilDB->quote($user_id, "integer") . "," .
121  $ilDB->quote($now, "timestamp") . "," .
122  $ilDB->quote(0, "integer") .
123  ")");
124  }
125  }
static now()
Return current timestamp in Y-m-d H:i:s format.
+ Here is the call graph for this function:

◆ deleteEntriesForProfile()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::deleteEntriesForProfile ( int  $profile_id)

Delete all profile completion entries for a profile.

Definition at line 210 of file class.SkillProfileCompletionDBRepository.php.

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

210  : void
211  {
212  $ilDB = $this->db;
213 
214  $ilDB->manipulate(
215  "DELETE FROM skl_profile_completion WHERE "
216  . " profile_id = " . $ilDB->quote($profile_id, "integer")
217  );
218  }

◆ deleteEntriesForUser()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::deleteEntriesForUser ( int  $user_id)

Delete all profile completion entries for a user.

Definition at line 223 of file class.SkillProfileCompletionDBRepository.php.

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

223  : void
224  {
225  $ilDB = $this->db;
226 
227  $ilDB->manipulate(
228  "DELETE FROM skl_profile_completion WHERE "
229  . " user_id = " . $ilDB->quote($user_id, "integer")
230  );
231  }

◆ getAllEntriesForProfile()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::getAllEntriesForProfile ( int  $profile_id)

Get all completion entries for a single profile.

Definition at line 184 of file class.SkillProfileCompletionDBRepository.php.

References $DIC, and $ilDB.

184  : array
185  {
186  global $DIC;
187 
188  $ilDB = $DIC->database();
189 
190  $set = $ilDB->query(
191  "SELECT * FROM skl_profile_completion " .
192  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
193  );
194  $entries = [];
195  while ($rec = $ilDB->fetchAssoc($set)) {
196  $entries[] = array(
197  "profile_id" => $rec["profile_id"],
198  "user_id" => $rec["user_id"],
199  "date" => $rec["date"],
200  "fulfilled" => $rec["fulfilled"]
201  );
202  }
203 
204  return $entries;
205  }
global $DIC
Definition: feed.php:28

◆ getAllEntriesForUser()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::getAllEntriesForUser ( int  $user_id)

Get all profile completion entries for a user.

Definition at line 158 of file class.SkillProfileCompletionDBRepository.php.

References $DIC, and $ilDB.

158  : array
159  {
160  global $DIC;
161 
162  $ilDB = $DIC->database();
163 
164  $set = $ilDB->query(
165  "SELECT * FROM skl_profile_completion " .
166  " WHERE user_id = " . $ilDB->quote($user_id, "integer")
167  );
168  $entries = [];
169  while ($rec = $ilDB->fetchAssoc($set)) {
170  $entries[] = array(
171  "profile_id" => $rec["profile_id"],
172  "user_id" => $rec["user_id"],
173  "date" => $rec["date"],
174  "fulfilled" => $rec["fulfilled"]
175  );
176  }
177 
178  return $entries;
179  }
global $DIC
Definition: feed.php:28

◆ getEntries()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::getEntries ( int  $user_id,
int  $profile_id 
)

Get profile completion entries for given user-profile-combination.

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

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

41  : array
42  {
43  $ilDB = $this->db;
44 
45  $set = $ilDB->query(
46  "SELECT * FROM skl_profile_completion " .
47  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer") .
48  " AND user_id = " . $ilDB->quote($user_id, "integer")
49  );
50  $entries = [];
51  while ($rec = $ilDB->fetchAssoc($set)) {
52  $entries[] = array(
53  "profile_id" => $rec["profile_id"],
54  "user_id" => $rec["user_id"],
55  "date" => $rec["date"],
56  "fulfilled" => $rec["fulfilled"]
57  );
58  }
59 
60  return $entries;
61  }

◆ getFulfilledEntriesForUser()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::getFulfilledEntriesForUser ( int  $user_id)

Get all profile completion entries for a user.

Returns
array{profile_id: int, user_id: int, date: string, fulfilled: int}[]

Definition at line 131 of file class.SkillProfileCompletionDBRepository.php.

References $DIC, and $ilDB.

131  : array
132  {
133  global $DIC;
134 
135  $ilDB = $DIC->database();
136 
137  $set = $ilDB->query(
138  "SELECT * FROM skl_profile_completion " .
139  " WHERE user_id = " . $ilDB->quote($user_id, "integer") .
140  " AND fulfilled = 1"
141  );
142  $entries = [];
143  while ($rec = $ilDB->fetchAssoc($set)) {
144  $entries[] = array(
145  "profile_id" => (int) $rec["profile_id"],
146  "user_id" => (int) $rec["user_id"],
147  "date" => $rec["date"],
148  "fulfilled" => (int) $rec["fulfilled"]
149  );
150  }
151 
152  return $entries;
153  }
global $DIC
Definition: feed.php:28

Field Documentation

◆ $db


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