ILIAS  release_8 Revision v8.24
ilNotificationUserIterator.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21namespace ILIAS\Notifications;
22
25use Iterator;
26
30class ilNotificationUserIterator implements Iterator
31{
35 private array $userids;
38 private array $data;
39 private string $module;
40
41 public function __construct(string $module, array $userids = [])
42 {
43 global $ilDB;
44 $this->db = $ilDB;
45 $this->userids = $userids;
46 $this->module = $module;
47 $this->rewind();
48 }
49
50 public function __destruct()
51 {
52 $this->db->free($this->rset);
53 }
54
55 public function current(): array
56 {
57 return $this->data;
58 }
59
60 public function key(): int
61 {
62 return (int) $this->data['usr_id'];
63 }
64
65 public function next(): void
66 {
67 }
68
69 public function rewind(): void
70 {
71 $query = 'SELECT usr_id, module, channel FROM ' . ilNotificationSetupHelper::$tbl_userconfig . ' WHERE module=%s AND ' . $this->db->in('usr_id', $this->userids, false, 'integer');
72 $types = array('text');
73 $values = array($this->module);
74 $this->rset = $this->db->queryF($query, $types, $values);
75 }
76
77 public function valid(): bool
78 {
79 $this->data = $this->db->fetchAssoc($this->rset);
80 return is_array($this->data);
81 }
82}
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$query