ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilNotificationUserIterator.php
Go to the documentation of this file.
1<?php
2
3require_once 'Services/Notifications/classes/class.ilNotificationSetupHelper.php';
4
8class ilNotificationUserIterator implements Iterator
9{
10 private $userids;
11 private $rset;
12 private $data;
13 private $module;
14
15 public function __construct($module, array $userids = array())
16 {
17 global $ilDB;
18
19 $this->db = $ilDB;
20 $this->userids = $userids;
21
22 $this->module = $module;
23
24 $this->rewind();
25 }
26
27 public function __destruct()
28 {
29 $this->db->free($this->rset);
30 }
31
32 public function current()
33 {
34 return $this->data;
35 }
36
37 public function key()
38 {
39 return (int) $this->data['usr_id'];
40 }
41
42 public function next()
43 {
44 //$this->data = $this->db->fetchAssoc($this->rset);
45 }
46
47 public function rewind()
48 {
49 $query = 'SELECT usr_id, module, channel FROM ' . ilNotificationSetupHelper::$tbl_userconfig . ' WHERE module=%s AND ' . $this->db->in('usr_id', $this->userids, false, 'integer');
50 $types = array('text');
51 $values = array($this->module);
52 $this->rset = $this->db->queryF($query, $types, $values);
53 }
54
55 public function valid()
56 {
57 $this->data = $this->db->fetchAssoc($this->rset);
58 return is_array($this->data);
59 }
60}
An exception for terminatinating execution or to throw for unit testing.
wrapper for iterating a list of user settings by providing the user ids
__construct($module, array $userids=array())
$query
global $ilDB