ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
25 return array(
26 'login' => $this->data['login'],
27 'firstname' => '',
28 'lastname' => ''
29 );
30 }
31 else if(count($this->users_stack) > 0)
32 {
33 return array(
34 'login' => array_shift($this->users_stack),
35 'firstname' => '',
36 'lastname' => ''
37 );
38 }
39 }
40
45 public function key()
46 {
47 if(is_array($this->data))
48 {
49 return $this->data['login'];
50 }
51 else if(count($this->users_stack) > 0)
52 {
53 return $this->users_stack[0];
54 }
55 }
56
60 public function valid()
61 {
62 $this->data = $this->db->fetchAssoc($this->res);
63 if(
64 is_array($this->data) &&
65 (
66 strpos($this->data['login'], ',') !== false ||
67 strpos($this->data['login'], ';') !== false
68 )
69 )
70 {
71 $parts = array_filter(array_map('trim', preg_split("/[ ]*[;,][ ]*/", trim($this->data['login']))));
72 foreach($parts as $part)
73 {
74 if(ilStr::strPos(ilStr::strToLower($part), ilStr::strToLower($this->term)) !== false)
75 {
76 $this->users_stack[] = $part;
77 }
78 }
79 if($this->users_stack)
80 {
81 $this->data = null;
82 }
83 }
84 return is_array($this->data) || count($this->users_stack) > 0;
85 }
86
87
88
92 public function rewind()
93 {
94 if($this->res)
95 {
96 $this->db->free($this->res);
97 $this->res = null;
98 }
99
100 $query = "
101 SELECT DISTINCT
102 mail.rcp_to login
103 FROM mail
104 WHERE " . $this->db->like('mail.rcp_to', 'text', $this->quoted_term) . "
105 AND sender_id = " . $this->db->quote($this->user_id, 'integer') . "
106 AND mail.sender_id = mail.user_id";
107
108 $this->res = $this->db->query($query);
109 }
110}
static strPos($a_haystack, $a_needle, $a_offset=NULL)
Definition: class.ilStr.php:34
static strToLower($a_string)
Definition: class.ilStr.php:91