31 protected ?
int $pos = null;
35 int $a_badge_id = null,
40 $this->db = $DIC->database();
46 $this->
read($a_badge_id, $a_user_id);
55 $db = $DIC->database();
58 $noti_repo = new \ILIAS\Badge\Notification\BadgeNotificationPrefRepository($user);
60 $last = $noti_repo->getLastCheckedTimestamp();
65 $last = time() - (24 * 60 * 60);
70 "SELECT count(*) cnt FROM badge_user_badge " .
71 " WHERE user_id = %s AND tstamp >= %s",
72 [
"integer",
"integer"],
76 return (
int) $rec[
"cnt"];
86 $db = $DIC->database();
89 "SELECT max(tstamp) maxts FROM badge_user_badge " .
90 " WHERE user_id = %s",
95 return (
int) $rec[
"maxts"];
107 $ilDB = $DIC->database();
111 $set =
$ilDB->query(
"SELECT * FROM badge_user_badge" .
112 " WHERE user_id = " .
$ilDB->quote($a_user_id,
"integer") .
114 while ($row =
$ilDB->fetchAssoc($set)) {
116 $obj->importDBRow($row);
132 $ilDB = $DIC->database();
136 $set =
$ilDB->query(
"SELECT * FROM badge_user_badge" .
137 " WHERE badge_id = " .
$ilDB->quote($a_badge_id,
"integer"));
138 while ($row =
$ilDB->fetchAssoc($set)) {
140 $obj->importDBRow($row);
156 $ilDB = $DIC->database();
160 $badge_ids = array();
162 $badge_ids[] = $badge->getId();
164 if (count($badge_ids)) {
165 $set =
$ilDB->query(
"SELECT * FROM badge_user_badge" .
166 " WHERE " .
$ilDB->in(
"badge_id", $badge_ids,
"",
"integer"));
167 while ($row =
$ilDB->fetchAssoc($set)) {
169 $obj->importDBRow($row);
186 foreach (self::getInstancesByBadgeId($a_badge_id) as $ass) {
187 $res[] = $ass->getUserId();
197 $obj =
new self($a_badge_id, $a_user_id);
208 $this->badge_id = $a_value;
218 $this->user_id = $a_value;
228 $this->tstamp = $a_value;
238 $this->awarded_by = $a_id;
248 $this->pos = $a_value;
263 $this->stored =
true;
265 $this->
setUserId((
int) $a_row[
"user_id"]);
277 $set =
$ilDB->query(
"SELECT * FROM badge_user_badge" .
278 " WHERE badge_id = " .
$ilDB->quote($a_badge_id,
"integer") .
279 " AND user_id = " .
$ilDB->quote($a_user_id,
"integer"));
280 $row =
$ilDB->fetchAssoc($set);
281 if ($row && $row[
"user_id"]) {
292 "tstamp" => [
"integer", $this->stored ? $this->
getTimestamp() : time()],
308 "badge_id" => array(
"integer", $this->
getBadgeId()),
309 "user_id" => array(
"integer", $this->
getUserId())
313 if (!$this->stored) {
314 $ilDB->insert(
"badge_user_badge", $fields +
$keys);
316 $ilDB->update(
"badge_user_badge", $fields,
$keys);
320 public function delete():
void 331 $ilDB->manipulate(
"DELETE FROM badge_user_badge" .
332 " WHERE badge_id = " .
$ilDB->quote($this->getBadgeId(),
"integer") .
333 " AND user_id = " .
$ilDB->quote($this->getUserId(),
"integer"));
338 foreach (self::getInstancesByUserId($a_user_id) as $ass) {
345 foreach (self::getInstancesByBadgeId($a_badge_id) as $ass) {
352 foreach (self::getInstancesByParentId($a_parent_obj_id) as $ass) {
362 foreach (self::getInstancesByUserId($a_user_id) as $ass) {
363 $badge =
new ilBadge($ass->getBadgeId());
364 $existing[$badge->getId()] = array($badge->getTitle(), $ass);
368 foreach ($a_positions as $title) {
369 foreach ($existing as
$id => $item) {
370 if ($title == $item[0]) {
371 $item[1]->setPosition(++$new_pos);
373 unset($existing[
$id]);
392 $db = $DIC->database();
395 "SELECT bdg.parent_id, ub.tstamp, bdg.title FROM badge_user_badge ub JOIN badge_badge bdg" .
396 " ON (ub.badge_id = bdg.id) " .
397 " WHERE ub.user_id = %s AND ub.tstamp >= %s AND ub.tstamp <= %s",
398 array(
"integer",
"integer",
"integer"),
399 array($a_user_id, $a_ts_from, $a_ts_to)
413 array_map(
"unlink", glob(
$path));
419 foreach (self::getInstancesByUserId($a_user_id) as $ass) {
420 $ass->deleteStaticFiles();
read(int $a_badge_id, int $a_user_id)
static getNewCounter(int $a_user_id)
fetchAssoc(ilDBStatement $statement)
static getInstancesByUserId(int $a_user_id)
static deleteByParentId(int $a_parent_obj_id)
static getAssignedUsers(int $a_badge_id)
setTimestamp(int $a_value)
__construct(int $a_badge_id=null, int $a_user_id=null)
setPosition(?int $a_value)
static updatePositions(int $a_user_id, array $a_positions)
static getInstancesByBadgeId(int $a_badge_id)
getPropertiesForStorage()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstancesByParentId(int $a_parent_id, array $a_filter=null)
static getInstancesByParentId(int $a_parent_obj_id)
queryF(string $query, array $types, array $values)
static exists(int $a_badge_id, int $a_user_id)
static deleteByUserId(int $a_user_id)
static clearBadgeCache(int $a_user_id)
static deleteByBadgeId(int $a_badge_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static getBadgesForUser(int $a_user_id, int $a_ts_from, int $a_ts_to)
static getLatestTimestamp(int $a_user_id)
importDBRow(array $a_row)