35 ?
int $a_badge_id =
null,
36 ?
int $a_user_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"];
106 $ilDB = $DIC->database();
110 $set =
$ilDB->query(
"SELECT * FROM badge_user_badge" .
111 " WHERE user_id = " .
$ilDB->quote($a_user_id,
"integer") .
113 while ($row =
$ilDB->fetchAssoc($set)) {
115 $obj->importDBRow($row);
130 $ilDB = $DIC->database();
134 $set =
$ilDB->query(
"SELECT * FROM badge_user_badge" .
135 " WHERE badge_id = " .
$ilDB->quote($a_badge_id,
"integer"));
136 while ($row =
$ilDB->fetchAssoc($set)) {
138 $obj->importDBRow($row);
153 $ilDB = $DIC->database();
157 $badge_ids = array();
159 $badge_ids[] = $badge->getId();
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)) {
166 $obj->importDBRow($row);
182 foreach (self::getInstancesByBadgeId($a_badge_id) as $ass) {
183 $res[] = $ass->getUserId();
193 $obj =
new self($a_badge_id, $a_user_id);
204 $this->badge_id = $a_value;
214 $this->user_id = $a_value;
224 $this->tstamp = $a_value;
234 $this->awarded_by = $a_id;
244 $this->pos = $a_value;
259 $this->stored =
true;
261 $this->
setUserId((
int) $a_row[
"user_id"]);
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"]) {
288 "tstamp" => [
"integer", $this->stored ? $this->
getTimestamp() : time()],
304 "badge_id" => array(
"integer", $this->
getBadgeId()),
305 "user_id" => array(
"integer", $this->
getUserId())
309 if (!$this->stored) {
310 $ilDB->insert(
"badge_user_badge", $fields + $keys);
312 $ilDB->update(
"badge_user_badge", $fields, $keys);
316 public function delete():
void 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"));
334 foreach (self::getInstancesByUserId($a_user_id) as $ass) {
341 foreach (self::getInstancesByBadgeId($a_badge_id) as $ass) {
348 foreach (self::getInstancesByParentId($a_parent_obj_id) as $ass) {
358 foreach (self::getInstancesByUserId($a_user_id) as $ass) {
359 $badge =
new ilBadge($ass->getBadgeId());
360 $existing[$badge->getId()] = array($badge->getTitle(), $ass);
364 foreach ($a_positions as $title) {
365 foreach ($existing as
$id => $item) {
366 if ($title == $item[0]) {
367 $item[1]->setPosition(++$new_pos);
369 unset($existing[
$id]);
385 $db = $DIC->database();
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)
412 foreach (self::getInstancesByUserId($a_user_id) as $ass) {
413 $ass->deleteStaticFiles();
read(int $a_badge_id, int $a_user_id)
static getInstancesByParentId(int $a_parent_id, ?array $a_filter=null)
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)
__construct(?int $a_badge_id=null, ?int $a_user_id=null)
setTimestamp(int $a_value)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setPosition(?int $a_value)
static updatePositions(int $a_user_id, array $a_positions)
static getInstancesByBadgeId(int $a_badge_id)
getPropertiesForStorage()
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)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static deleteByBadgeId(int $a_badge_id)
static getBadgesForUser(int $a_user_id, int $a_ts_from, int $a_ts_to)
static getLatestTimestamp(int $a_user_id)
importDBRow(array $a_row)