This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
More...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.
If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilBadgeAssignment
- Author
- Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Definition at line 24 of file class.ilBadgeAssignment.php.
◆ __construct()
ilBadgeAssignment::__construct |
( |
?int |
$a_badge_id = null , |
|
|
?int |
$a_user_id = null |
|
) |
| |
◆ clearBadgeCache()
static ilBadgeAssignment::clearBadgeCache |
( |
int |
$a_user_id | ) |
|
|
static |
◆ delete()
ilBadgeAssignment::delete |
( |
| ) |
|
Definition at line 316 of file class.ilBadgeAssignment.php.
316 : void
317 {
319
322 return;
323 }
324
326
327 $ilDB->manipulate(
"DELETE FROM badge_user_badge" .
328 " WHERE badge_id = " .
$ilDB->quote($this->getBadgeId(),
"integer") .
329 " AND user_id = " .
$ilDB->quote($this->getUserId(),
"integer"));
330 }
References $ilDB.
◆ deleteByBadgeId()
static ilBadgeAssignment::deleteByBadgeId |
( |
int |
$a_badge_id | ) |
|
|
static |
◆ deleteByParentId()
static ilBadgeAssignment::deleteByParentId |
( |
int |
$a_parent_obj_id | ) |
|
|
static |
Definition at line 346 of file class.ilBadgeAssignment.php.
346 : void
347 {
348 foreach (self::getInstancesByParentId($a_parent_obj_id) as $ass) {
349 $ass->delete();
350 }
351 }
◆ deleteByUserId()
static ilBadgeAssignment::deleteByUserId |
( |
int |
$a_user_id | ) |
|
|
static |
◆ deleteStaticFiles()
ilBadgeAssignment::deleteStaticFiles |
( |
| ) |
|
◆ exists()
static ilBadgeAssignment::exists |
( |
int |
$a_badge_id, |
|
|
int |
$a_user_id |
|
) |
| |
|
static |
◆ getAssignedUsers()
static ilBadgeAssignment::getAssignedUsers |
( |
int |
$a_badge_id | ) |
|
|
static |
◆ getAwardedBy()
ilBadgeAssignment::getAwardedBy |
( |
| ) |
|
◆ getBadgeId()
ilBadgeAssignment::getBadgeId |
( |
| ) |
|
◆ getBadgesForUser()
static ilBadgeAssignment::getBadgesForUser |
( |
int |
$a_user_id, |
|
|
int |
$a_ts_from, |
|
|
int |
$a_ts_to |
|
) |
| |
|
static |
- Returns
- array[]
Definition at line 378 of file class.ilBadgeAssignment.php.
382 : array {
384
386
388 "SELECT bdg.parent_id, ub.tstamp, bdg.title FROM badge_user_badge ub JOIN badge_badge bdg" .
389 " ON (ub.badge_id = bdg.id) " .
390 " WHERE ub.user_id = %s AND ub.tstamp >= %s AND ub.tstamp <= %s",
391 array("integer","integer","integer"),
392 array($a_user_id, $a_ts_from, $a_ts_to)
393 );
397 }
399 }
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
References $res.
Referenced by ilBadgeLearningHistoryProvider\getEntries().
◆ getInstancesByBadgeId()
static ilBadgeAssignment::getInstancesByBadgeId |
( |
int |
$a_badge_id | ) |
|
|
static |
◆ getInstancesByParentId()
static ilBadgeAssignment::getInstancesByParentId |
( |
int |
$a_parent_obj_id | ) |
|
|
static |
- Returns
- self[]
Definition at line 148 of file class.ilBadgeAssignment.php.
150 : array {
152
154
156
157 $badge_ids = array();
159 $badge_ids[] = $badge->getId();
160 }
161 if (count($badge_ids)) {
162 $set =
$ilDB->query(
"SELECT * FROM badge_user_badge" .
163 " WHERE " .
$ilDB->in(
"badge_id", $badge_ids,
"",
"integer"));
164 while ($row =
$ilDB->fetchAssoc($set)) {
165 $obj = new self();
166 $obj->importDBRow($row);
168 }
169 }
170
172 }
static getInstancesByParentId(int $a_parent_id, ?array $a_filter=null)
◆ getInstancesByUserId()
static ilBadgeAssignment::getInstancesByUserId |
( |
int |
$a_user_id | ) |
|
|
static |
◆ getLatestTimestamp()
static ilBadgeAssignment::getLatestTimestamp |
( |
int |
$a_user_id | ) |
|
|
static |
Definition at line 81 of file class.ilBadgeAssignment.php.
83 : int {
85
87
89 "SELECT max(tstamp) maxts FROM badge_user_badge " .
90 " WHERE user_id = %s",
91 ["integer"],
92 [$a_user_id]
93 );
95 return (int) $rec["maxts"];
96 }
◆ getNewCounter()
static ilBadgeAssignment::getNewCounter |
( |
int |
$a_user_id | ) |
|
|
static |
Definition at line 50 of file class.ilBadgeAssignment.php.
52 : int {
54
56
58 $noti_repo = new \ILIAS\Badge\Notification\BadgeNotificationPrefRepository($user);
59
60 $last = $noti_repo->getLastCheckedTimestamp();
61
62
63
64 if ($last === 0) {
65 $last = time() - (24 * 60 * 60);
66 }
67
68 if ($last > 0) {
70 "SELECT count(*) cnt FROM badge_user_badge " .
71 " WHERE user_id = %s AND tstamp >= %s",
72 ["integer", "integer"],
73 [$a_user_id, $last]
74 );
76 return (int) $rec["cnt"];
77 }
78 return 0;
79 }
◆ getPosition()
ilBadgeAssignment::getPosition |
( |
| ) |
|
◆ getPropertiesForStorage()
ilBadgeAssignment::getPropertiesForStorage |
( |
| ) |
|
|
protected |
◆ getTimestamp()
ilBadgeAssignment::getTimestamp |
( |
| ) |
|
◆ getUserId()
ilBadgeAssignment::getUserId |
( |
| ) |
|
◆ importDBRow()
ilBadgeAssignment::importDBRow |
( |
array |
$a_row | ) |
|
|
protected |
Definition at line 257 of file class.ilBadgeAssignment.php.
257 : void
258 {
259 $this->stored = true;
261 $this->
setUserId((
int) $a_row[
"user_id"]);
265 }
setTimestamp(int $a_value)
setPosition(?int $a_value)
◆ read()
ilBadgeAssignment::read |
( |
int |
$a_badge_id, |
|
|
int |
$a_user_id |
|
) |
| |
|
protected |
Definition at line 267 of file class.ilBadgeAssignment.php.
270 : void {
272
273 $set =
$ilDB->query(
"SELECT * FROM badge_user_badge" .
274 " WHERE badge_id = " .
$ilDB->quote($a_badge_id,
"integer") .
275 " AND user_id = " .
$ilDB->quote($a_user_id,
"integer"));
276 $row =
$ilDB->fetchAssoc($set);
277 if ($row && $row["user_id"]) {
279 }
280 }
importDBRow(array $a_row)
Referenced by __construct().
◆ setAwardedBy()
ilBadgeAssignment::setAwardedBy |
( |
int |
$a_id | ) |
|
◆ setBadgeId()
ilBadgeAssignment::setBadgeId |
( |
int |
$a_value | ) |
|
|
protected |
◆ setPosition()
ilBadgeAssignment::setPosition |
( |
?int |
$a_value | ) |
|
◆ setTimestamp()
ilBadgeAssignment::setTimestamp |
( |
int |
$a_value | ) |
|
|
protected |
◆ setUserId()
ilBadgeAssignment::setUserId |
( |
int |
$a_value | ) |
|
|
protected |
◆ store()
ilBadgeAssignment::store |
( |
| ) |
|
Definition at line 294 of file class.ilBadgeAssignment.php.
294 : void
295 {
297
300 return;
301 }
302
303 $keys = array(
304 "badge_id" => array(
"integer", $this->
getBadgeId()),
305 "user_id" => array(
"integer", $this->
getUserId())
306 );
308
309 if (!$this->stored) {
310 $ilDB->insert(
"badge_user_badge", $fields + $keys);
311 } else {
312 $ilDB->update(
"badge_user_badge", $fields, $keys);
313 }
314 }
getPropertiesForStorage()
References $ilDB.
◆ updatePositions()
static ilBadgeAssignment::updatePositions |
( |
int |
$a_user_id, |
|
|
array |
$a_positions |
|
) |
| |
|
static |
Definition at line 353 of file class.ilBadgeAssignment.php.
356 : void {
357 $existing = array();
358 foreach (self::getInstancesByUserId($a_user_id) as $ass) {
359 $badge =
new ilBadge($ass->getBadgeId());
360 $existing[$badge->getId()] = array($badge->getTitle(), $ass);
361 }
362
363 $new_pos = 0;
364 foreach ($a_positions as $title) {
365 foreach ($existing as
$id => $item) {
366 if ($title == $item[0]) {
367 $item[1]->setPosition(++$new_pos);
368 $item[1]->store();
369 unset($existing[
$id]);
370 }
371 }
372 }
373 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Referenced by ILIAS\User\Profile\PersonalProfileGUI\savePublicProfile().
◆ $awarded_by
int ilBadgeAssignment::$awarded_by = 0 |
|
protected |
◆ $badge_id
int ilBadgeAssignment::$badge_id = 0 |
|
protected |
◆ $db
◆ $pos
int ilBadgeAssignment::$pos = null |
|
protected |
◆ $stored
bool ilBadgeAssignment::$stored = false |
|
protected |
◆ $tstamp
int ilBadgeAssignment::$tstamp = 0 |
|
protected |
◆ $user_id
int ilBadgeAssignment::$user_id = 0 |
|
protected |
The documentation for this class was generated from the following file: