ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilMailAutoCompleteSentMailsRecipientsProvider.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Mail/classes/class.ilMailAutoCompleteRecipientProvider.php';
5require_once 'Services/Utilities/classes/class.ilStr.php';
6
11{
15 protected $users_stack = array();
16
21 public function current()
22 {
23 if (is_array($this->data)) {
24 return array(
25 'login' => $this->data['login'],
26 'firstname' => '',
27 'lastname' => ''
28 );
29 } elseif (count($this->users_stack) > 0) {
30 return array(
31 'login' => array_shift($this->users_stack),
32 'firstname' => '',
33 'lastname' => ''
34 );
35 }
36 }
37
42 public function key()
43 {
44 if (is_array($this->data)) {
45 return $this->data['login'];
46 } elseif (count($this->users_stack) > 0) {
47 return $this->users_stack[0];
48 }
49 }
50
54 public function valid()
55 {
56 $this->data = $this->db->fetchAssoc($this->res);
57 if (
58 is_array($this->data) &&
59 (
60 strpos($this->data['login'], ',') !== false ||
61 strpos($this->data['login'], ';') !== false
62 )
63 ) {
64 $parts = array_filter(array_map('trim', preg_split("/[ ]*[;,][ ]*/", trim($this->data['login']))));
65 foreach ($parts as $part) {
66 if (ilStr::strPos(ilStr::strToLower($part), ilStr::strToLower($this->term)) !== false) {
67 $this->users_stack[] = $part;
68 }
69 }
70 if ($this->users_stack) {
71 $this->data = null;
72 }
73 }
74 return is_array($this->data) || count($this->users_stack) > 0;
75 }
76
77
78
82 public function rewind()
83 {
84 if ($this->res) {
85 $this->db->free($this->res);
86 $this->res = null;
87 }
88
89 $query = "
90 SELECT DISTINCT
91 mail.rcp_to login
92 FROM mail
93 WHERE " . $this->db->like('mail.rcp_to', 'text', $this->quoted_term) . "
94 AND sender_id = " . $this->db->quote($this->user_id, 'integer') . "
95 AND mail.sender_id = mail.user_id";
96
97 $this->res = $this->db->query($query);
98 }
99}
An exception for terminatinating execution or to throw for unit testing.
static strPos($a_haystack, $a_needle, $a_offset=null)
Definition: class.ilStr.php:30
static strToLower($a_string)
Definition: class.ilStr.php:87
$query