ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilNotificationUserIterator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Notifications;
22
25use Iterator;
27
32class ilNotificationUserIterator implements Iterator
33{
35 private readonly ilDBInterface $db;
37 private ?array $data = null;
38
42 public function __construct(private readonly string $module, private readonly array $userids = [])
43 {
44 global $DIC;
45
46 $this->db = $DIC->database();
47 $this->rewind();
48 }
49
50 public function __destruct()
51 {
52 $this->db->free($this->rset);
53 }
54
58 public function current(): array
59 {
60 return $this->data;
61 }
62
63 public function key(): int
64 {
65 return (int) $this->data['usr_id'];
66 }
67
68 public function next(): void
69 {
70 }
71
72 public function rewind(): void
73 {
74 $query = 'SELECT usr_id, module, channel FROM ' . ilNotificationSetupHelper::$tbl_userconfig . ' WHERE module = %s AND ' . $this->db->in(
75 'usr_id',
76 $this->userids,
77 false,
79 );
80 $types = [ilDBConstants::T_TEXT];
81 $values = [$this->module];
82 $this->rset = $this->db->queryF($query, $types, $values);
83 }
84
85 public function valid(): bool
86 {
87 $this->data = $this->db->fetchAssoc($this->rset);
88
89 return is_array($this->data);
90 }
91}
__construct(private readonly string $module, private readonly array $userids=[])
Class ilDBConstants.
Interface ilDBInterface.
Interface ilDBStatement.
global $DIC
Definition: shib_login.php:26