ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilMailAutoCompleteRecipientResult Class Reference
+ Collaboration diagram for ilMailAutoCompleteRecipientResult:

Public Member Functions

array __construct (int $mode)
 
 isResultAddable ()
 
 addResult (string $login, string $firstname, string $lastname)
 
 getItems ()
 
 numItems ()
 

Data Fields

final const int MODE_STOP_ON_MAX_ENTRIES = 1
 
final const int MODE_FETCH_ALL = 2
 
final const int MAX_RESULT_ENTRIES = 1000
 
array $result
 

Protected Member Functions

 initMode (int $mode)
 

Protected Attributes

bool $allow_smtp
 
int $user_id
 
array $handled_recipients = []
 
int $mode = self::MODE_STOP_ON_MAX_ENTRIES
 
int $max_entries
 

Detailed Description

Definition at line 21 of file class.ilMailAutoCompleteRecipientResult.php.

Constructor & Destructor Documentation

◆ __construct()

array ilMailAutoCompleteRecipientResult::__construct ( int  $mode)

Definition at line 39 of file class.ilMailAutoCompleteRecipientResult.php.

References $DIC, ilSearchSettings\getInstance(), initMode(), and MAIL_SETTINGS_ID.

40  {
41  global $DIC;
42 
43  $this->allow_smtp = $DIC->rbac()->system()->checkAccess('smtp_mail', MAIL_SETTINGS_ID);
44  $this->user_id = $DIC->user()->getId();
45  $this->max_entries = ilSearchSettings::getInstance()->getAutoCompleteLength();
46 
47  $this->initMode($mode);
48  }
global $DIC
Definition: shib_login.php:26
const MAIL_SETTINGS_ID
Definition: constants.php:36
+ Here is the call graph for this function:

Member Function Documentation

◆ addResult()

ilMailAutoCompleteRecipientResult::addResult ( string  $login,
string  $firstname,
string  $lastname 
)

Definition at line 76 of file class.ilMailAutoCompleteRecipientResult.php.

76  : void
77  {
78  if ($login !== '' && !isset($this->handled_recipients[$login])) {
79  $recipient = [];
80  $recipient['value'] = $login;
81 
82  $label = $login;
83  if ($firstname && $lastname) {
84  $label .= " [" . $firstname . ", " . $lastname . "]";
85  }
86  $recipient['label'] = $label;
87 
88  $this->result['items'][] = $recipient;
89  $this->handled_recipients[$login] = 1;
90  }
91  }

◆ getItems()

ilMailAutoCompleteRecipientResult::getItems ( )
Returns
array{hasMoreResults: bool, items: array{value: string, label: string}[]}

Definition at line 96 of file class.ilMailAutoCompleteRecipientResult.php.

References $result.

96  : array
97  {
98  return $this->result;
99  }

◆ initMode()

ilMailAutoCompleteRecipientResult::initMode ( int  $mode)
protected
Exceptions
InvalidArgumentException

Definition at line 53 of file class.ilMailAutoCompleteRecipientResult.php.

References $mode.

Referenced by __construct().

53  : void
54  {
55  if (!in_array($mode, [self::MODE_FETCH_ALL, self::MODE_STOP_ON_MAX_ENTRIES], true)) {
56  throw new InvalidArgumentException("Wrong mode passed!");
57  }
58  $this->mode = $mode;
59  }
+ Here is the caller graph for this function:

◆ isResultAddable()

ilMailAutoCompleteRecipientResult::isResultAddable ( )

Definition at line 61 of file class.ilMailAutoCompleteRecipientResult.php.

61  : bool
62  {
63  if ($this->mode === self::MODE_STOP_ON_MAX_ENTRIES &&
64  $this->max_entries >= 0 && count($this->result['items']) >= $this->max_entries) {
65  return false;
66  }
67 
68  if ($this->mode === self::MODE_FETCH_ALL &&
69  count($this->result['items']) >= self::MAX_RESULT_ENTRIES) {
70  return false;
71  }
72 
73  return true;
74  }

◆ numItems()

ilMailAutoCompleteRecipientResult::numItems ( )

Definition at line 101 of file class.ilMailAutoCompleteRecipientResult.php.

101  : int
102  {
103  return count($this->result['items']);
104  }

Field Documentation

◆ $allow_smtp

bool ilMailAutoCompleteRecipientResult::$allow_smtp
protected

Definition at line 27 of file class.ilMailAutoCompleteRecipientResult.php.

◆ $handled_recipients

array ilMailAutoCompleteRecipientResult::$handled_recipients = []
protected

Definition at line 30 of file class.ilMailAutoCompleteRecipientResult.php.

◆ $max_entries

int ilMailAutoCompleteRecipientResult::$max_entries
protected

Definition at line 32 of file class.ilMailAutoCompleteRecipientResult.php.

◆ $mode

int ilMailAutoCompleteRecipientResult::$mode = self::MODE_STOP_ON_MAX_ENTRIES
protected

Definition at line 31 of file class.ilMailAutoCompleteRecipientResult.php.

Referenced by initMode().

◆ $result

array ilMailAutoCompleteRecipientResult::$result
Initial value:
= [
'items' => []

Definition at line 34 of file class.ilMailAutoCompleteRecipientResult.php.

Referenced by getItems().

◆ $user_id

int ilMailAutoCompleteRecipientResult::$user_id
protected

Definition at line 28 of file class.ilMailAutoCompleteRecipientResult.php.

◆ MAX_RESULT_ENTRIES

final const int ilMailAutoCompleteRecipientResult::MAX_RESULT_ENTRIES = 1000

Definition at line 25 of file class.ilMailAutoCompleteRecipientResult.php.

◆ MODE_FETCH_ALL

final const int ilMailAutoCompleteRecipientResult::MODE_FETCH_ALL = 2

◆ MODE_STOP_ON_MAX_ENTRIES

final const int ilMailAutoCompleteRecipientResult::MODE_STOP_ON_MAX_ENTRIES = 1

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