ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
ILIAS\Mail\RecipientSearch\SentMailsBasedProvider Class Reference

@phpstan-import-type AutoCompleteUserRecord from RecipientSearchProvider More...

+ Inheritance diagram for ILIAS\Mail\RecipientSearch\SentMailsBasedProvider:
+ Collaboration diagram for ILIAS\Mail\RecipientSearch\SentMailsBasedProvider:

Public Member Functions

 current ()
 
 key ()
 
 valid ()
 
 rewind ()
 
- Public Member Functions inherited from ILIAS\Mail\RecipientSearch\RecipientSearchProvider
 __construct (protected string $quoted_term, protected string $term)
 
 valid ()
 
 next ()
 
 __destruct ()
 

Private Attributes

array $users_stack = []
 

Additional Inherited Members

- Protected Attributes inherited from ILIAS\Mail\RecipientSearch\RecipientSearchProvider
ilDBInterface $db
 
ilDBStatement $res = null
 
array $data = null
 
int $user_id = 0
 

Detailed Description

@phpstan-import-type AutoCompleteUserRecord from RecipientSearchProvider

Definition at line 26 of file SentMailsBasedProvider..php.

Member Function Documentation

◆ current()

ILIAS\Mail\RecipientSearch\SentMailsBasedProvider::current ( )
Returns
AutoCompleteUserRecord
Exceptions

OutOfBoundsException

Definition at line 35 of file SentMailsBasedProvider..php.

35 : array
36 {
37 if (\is_array($this->data) && !empty($this->data)) {
38 return [
39 'login' => $this->data['login'],
40 'firstname' => '',
41 'lastname' => '',
42 ];
43 }
44
45 if ($this->users_stack !== []) {
46 return [
47 'login' => array_shift($this->users_stack),
48 'firstname' => '',
49 'lastname' => '',
50 ];
51 }
52
53 throw new \OutOfBoundsException('No more users available');
54 }

◆ key()

ILIAS\Mail\RecipientSearch\SentMailsBasedProvider::key ( )

Definition at line 56 of file SentMailsBasedProvider..php.

56 : string
57 {
58 if (\is_array($this->data) && !empty($this->data)) {
59 return $this->data['login'];
60 }
61
62 if ($this->users_stack !== []) {
63 return $this->users_stack[0]['login'];
64 }
65
66 return '';
67 }

◆ rewind()

ILIAS\Mail\RecipientSearch\SentMailsBasedProvider::rewind ( )

Definition at line 99 of file SentMailsBasedProvider..php.

99 : void
100 {
101 if ($this->res !== null) {
102 $this->db->free($this->res);
103 $this->res = null;
104 }
105
106 $query = '
107 SELECT DISTINCT
108 mail.rcp_to login
109 FROM mail
110 WHERE ' . $this->db->like('mail.rcp_to', 'text', $this->quoted_term) . "
111 AND mail.rcp_to IS NOT NULL AND mail.rcp_to != ''
112 AND sender_id = " . $this->db->quote($this->user_id, 'integer') . '
113 AND mail.sender_id = mail.user_id';
114
115 $this->res = $this->db->query($query);
116 }

◆ valid()

ILIAS\Mail\RecipientSearch\SentMailsBasedProvider::valid ( )

Reimplemented from ILIAS\Mail\RecipientSearch\RecipientSearchProvider.

Definition at line 69 of file SentMailsBasedProvider..php.

69 : bool
70 {
71 $this->data = $this->db->fetchAssoc($this->res);
72 if (\is_array($this->data) &&
73 !empty($this->data) &&
74 (
75 strpos((string) $this->data['login'], ',') ||
76 strpos((string) $this->data['login'], ';')
77 )) {
78 $parts = array_filter(
79 array_map(
80 'trim',
81 preg_split('/[ ]*[;,][ ]*/', trim((string) $this->data['login']))
82 )
83 );
84
85 foreach ($parts as $part) {
86 if (\ilStr::strPos(\ilStr::strToLower($part), \ilStr::strToLower($this->term), 0) !== false) {
87 $this->users_stack[] = $part;
88 }
89 }
90
91 if ($this->users_stack) {
92 $this->data = null;
93 }
94 }
95
96 return (\is_array($this->data) && !empty($this->data)) || $this->users_stack !== [];
97 }
static strPos(string $a_haystack, string $a_needle, int $a_offset=0)
Definition: class.ilStr.php:39
static strToLower(string $a_string)
Definition: class.ilStr.php:69
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61

References $parts, ilStr\strPos(), and ilStr\strToLower().

+ Here is the call graph for this function:

Field Documentation

◆ $users_stack

array ILIAS\Mail\RecipientSearch\SentMailsBasedProvider::$users_stack = []
private

Definition at line 29 of file SentMailsBasedProvider..php.


The documentation for this class was generated from the following file: