ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilMailAutoCompleteUserProvider Class Reference

Class ilMailAutoCompleteUserProvider. More...

+ Inheritance diagram for ilMailAutoCompleteUserProvider:
+ Collaboration diagram for ilMailAutoCompleteUserProvider:

Public Member Functions

 __construct ($quoted_term, $term)
 
 valid ()
 "Valid" implementation of iterator interface More...
 
 current ()
 "Current" implementation of iterator interface More...
 
 key ()
 "Key" implementation of iterator interface More...
 
 rewind ()
 "Rewind "implementation of iterator interface More...
 
- Public Member Functions inherited from ilMailAutoCompleteRecipientProvider
 __construct ($quoted_term, $term)
 
 valid ()
 "Valid" implementation of iterator interface More...
 
 next ()
 "Next" implementation of iterator interface More...
 
 __destruct ()
 Destructor Free the result. More...
 

Protected Member Functions

 getSelectPart ()
 
 getFromPart ()
 
 getWherePart ($search_query)
 
 getOrderByPart ()
 
 getQueryConditionByFieldAndValue ($field, $a_str)
 
 getFields ()
 Get searchable fields. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilMailAutoCompleteRecipientProvider
 $db
 
 $res
 
 $data = array()
 
 $quoted_term = ''
 
 $term = ''
 
 $user_id = 0
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMailAutoCompleteUserProvider::__construct (   $quoted_term,
  $term 
)

Member Function Documentation

◆ current()

ilMailAutoCompleteUserProvider::current ( )

"Current" implementation of iterator interface

Returns
array

Definition at line 36 of file class.ilMailAutoCompleteUserProvider.php.

References array, and data.

37  {
38  return array(
39  'login' => $this->data['login'],
40  'firstname' => $this->data['firstname'],
41  'lastname' => $this->data['lastname']
42  );
43  }
Add some data
Create styles array
The data for the language used.

◆ getFields()

ilMailAutoCompleteUserProvider::getFields ( )
protected

Get searchable fields.

Returns
array

Definition at line 208 of file class.ilMailAutoCompleteUserProvider.php.

References ilUserSearchOptions\_isEnabled(), and array.

Referenced by getWherePart().

209  {
210  $available_fields = array();
211  foreach (array('firstname', 'lastname') as $field) {
212  include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
213  if (ilUserSearchOptions::_isEnabled($field)) {
214  $available_fields[] = $field;
215  }
216  }
217  return $available_fields;
218  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFromPart()

ilMailAutoCompleteUserProvider::getFromPart ( )
protected
Returns
string

Definition at line 110 of file class.ilMailAutoCompleteUserProvider.php.

References array.

Referenced by rewind().

111  {
112  $joins = array();
113 
114  $joins[] = '
115  LEFT JOIN usr_pref profpref
116  ON profpref.usr_id = usr_data.usr_id
117  AND profpref.keyword = ' . $this->db->quote('public_profile', 'text');
118 
119  $joins[] = '
120  LEFT JOIN usr_pref pubemail
121  ON pubemail.usr_id = usr_data.usr_id
122  AND pubemail.keyword = ' . $this->db->quote('public_email', 'text');
123 
124  if ($joins) {
125  return 'usr_data ' . implode(' ', $joins);
126  } else {
127  return 'usr_data ';
128  }
129  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getOrderByPart()

ilMailAutoCompleteUserProvider::getOrderByPart ( )
protected
Returns
string

Definition at line 189 of file class.ilMailAutoCompleteUserProvider.php.

Referenced by rewind().

190  {
191  return 'login ASC';
192  }
+ Here is the caller graph for this function:

◆ getQueryConditionByFieldAndValue()

ilMailAutoCompleteUserProvider::getQueryConditionByFieldAndValue (   $field,
  $a_str 
)
protected
Parameters
string$field
mixed$a_str
Returns
string

Definition at line 199 of file class.ilMailAutoCompleteUserProvider.php.

Referenced by getWherePart().

200  {
201  return $this->db->like($field, 'text', $a_str . '%');
202  }
+ Here is the caller graph for this function:

◆ getSelectPart()

ilMailAutoCompleteUserProvider::getSelectPart ( )
protected
Returns
string

Definition at line 79 of file class.ilMailAutoCompleteUserProvider.php.

References array.

Referenced by rewind().

80  {
81  $fields = array(
82  'login',
83  sprintf(
84  "(CASE WHEN (profpref.value = %s OR profpref.value = %s OR profpref.value IS NULL) THEN firstname ELSE '' END) firstname",
85  $this->db->quote('y', 'text'),
86  $this->db->quote('g', 'text')
87  ),
88  sprintf(
89  "(CASE WHEN (profpref.value = %s OR profpref.value = %s OR profpref.value IS NULL) THEN lastname ELSE '' END) lastname",
90  $this->db->quote('y', 'text'),
91  $this->db->quote('g', 'text')
92  ),
93  sprintf(
94  "(CASE WHEN ((profpref.value = %s OR profpref.value = %s OR profpref.value IS NULL) AND pubemail.value = %s) THEN email ELSE '' END) email",
95  $this->db->quote('y', 'text'),
96  $this->db->quote('g', 'text'),
97  $this->db->quote('y', 'text')
98  ),
99  );
100 
101  $fields[] = 'profpref.value profile_value';
102  $fields[] = 'pubemail.value email_value';
103 
104  return implode(', ', $fields);
105  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getWherePart()

ilMailAutoCompleteUserProvider::getWherePart (   $search_query)
protected
Parameters
string
Returns
string

Definition at line 135 of file class.ilMailAutoCompleteUserProvider.php.

References array, getFields(), ilUserAccountSettings\getInstance(), ilUserFilter\getInstance(), and getQueryConditionByFieldAndValue().

Referenced by rewind().

136  {
137  $outer_conditions = array();
138  $outer_conditions[] = 'usr_data.usr_id != ' . $this->db->quote(ANONYMOUS_USER_ID, 'integer');
139 
140  $field_conditions = array();
141  foreach ($this->getFields() as $field) {
142  $field_condition = $this->getQueryConditionByFieldAndValue($field, $search_query);
143 
144  if ('email' == $field) {
145  // If privacy should be respected, the profile setting of every user concerning the email address has to be
146  // respected (in every user context, no matter if the user is 'logged in' or 'anonymous').
147  $email_query = array();
148  $email_query[] = $field_condition;
149  $email_query[] = 'pubemail.value = ' . $this->db->quote('y', 'text');
150  $field_conditions[] = '(' . implode(' AND ', $email_query) . ')';
151  } else {
152  $field_conditions[] = $field_condition;
153  }
154  }
155 
156  // If the current user context ist 'logged in' and privacy should be respected, all fields >>>except the login<<<
157  // should only be searchable if the users' profile is published (y oder g)
158  // In 'anonymous' context we do not need this additional conditions,
159  // because we checked the privacy setting in the condition above: profile = 'g'
160  if ($field_conditions) {
161  $fields = '(' . implode(' OR ', $field_conditions) . ')';
162 
163  $field_conditions = ['(' . implode(' AND ', array(
164  $fields,
165  $this->db->in('profpref.value', array('y', 'g'), false, 'text')
166  )) . ')'];
167  }
168 
169  // The login field must be searchable regardless (for 'logged in' users) of any privacy settings.
170  // We handled the general condition for 'anonymous' context above: profile = 'g'
171  $field_conditions[] = $this->getQueryConditionByFieldAndValue('login', $search_query);
172 
173  include_once 'Services/User/classes/class.ilUserAccountSettings.php';
174  if (ilUserAccountSettings::getInstance()->isUserAccessRestricted()) {
175  include_once './Services/User/classes/class.ilUserFilter.php';
176  $outer_conditions[] = $this->db->in('time_limit_owner', ilUserFilter::getInstance()->getFolderIds(), false, 'integer');
177  }
178 
179  if ($field_conditions) {
180  $outer_conditions[] = '(' . implode(' OR ', $field_conditions) . ')';
181  }
182 
183  return implode(' AND ', $outer_conditions);
184  }
static getInstance()
Singelton get instance.
Create styles array
The data for the language used.
static getInstance()
Singelton get instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ key()

ilMailAutoCompleteUserProvider::key ( )

"Key" implementation of iterator interface

Returns
boolean true/false

Definition at line 49 of file class.ilMailAutoCompleteUserProvider.php.

References data.

50  {
51  return $this->data['login'];
52  }
Add some data

◆ rewind()

ilMailAutoCompleteUserProvider::rewind ( )

"Rewind "implementation of iterator interface

Definition at line 57 of file class.ilMailAutoCompleteUserProvider.php.

References $query, array, getFromPart(), getOrderByPart(), getSelectPart(), and getWherePart().

58  {
59  if ($this->res) {
60  $this->db->free($this->res);
61  $this->res = null;
62  }
63  $select_part = $this->getSelectPart();
64  $where_part = $this->getWherePart($this->quoted_term);
65  $order_by_part = $this->getOrderByPart();
66  $query = implode(" ", array(
67  'SELECT ' . $select_part,
68  'FROM ' . $this->getFromPart(),
69  $where_part ? 'WHERE ' . $where_part : '',
70  $order_by_part ? 'ORDER BY ' . $order_by_part : ''
71  ));
72 
73  $this->res = $this->db->query($query);
74  }
$query
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ valid()

ilMailAutoCompleteUserProvider::valid ( )

"Valid" implementation of iterator interface

Returns
boolean true/false

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

References data.

26  {
27  $this->data = $this->db->fetchAssoc($this->res);
28 
29  return is_array($this->data);
30  }
Add some data

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