ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

37 {
38 return array(
39 'login' => $this->data['login'],
40 'firstname' => $this->data['firstname'],
41 'lastname' => $this->data['lastname']
42 );
43 }
$this data['403_header']

References data.

◆ getFields()

ilMailAutoCompleteUserProvider::getFields ( )
protected

Get searchable fields.

Returns
array

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

210 {
211 $available_fields = array();
212 foreach (array('firstname', 'lastname') as $field) {
213 include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
215 $available_fields[] = $field;
216 }
217 }
218 return $available_fields;
219 }

References ilUserSearchOptions\_isEnabled().

Referenced by getWherePart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFromPart()

ilMailAutoCompleteUserProvider::getFromPart ( )
protected
Returns
string

Reimplemented in ilMailAutoCompleteBuddyRecipientsProvider.

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

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 }

Referenced by rewind().

+ Here is the caller graph for this function:

◆ getOrderByPart()

ilMailAutoCompleteUserProvider::getOrderByPart ( )
protected
Returns
string

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

191 {
192 return 'login ASC';
193 }

Referenced by rewind().

+ 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 200 of file class.ilMailAutoCompleteUserProvider.php.

201 {
202 return $this->db->like($field, 'text', $a_str . '%');
203 }

Referenced by getWherePart().

+ Here is the caller graph for this function:

◆ getSelectPart()

ilMailAutoCompleteUserProvider::getSelectPart ( )
protected
Returns
string

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

80 {
81 $fields = array(
82 'login',
83 sprintf(
84 "(CASE WHEN (profpref.value = %s OR profpref.value = %s) 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) 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) 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 }

Referenced by rewind().

+ 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.

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

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

Referenced by rewind().

+ 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.

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

References data.

◆ rewind()

ilMailAutoCompleteUserProvider::rewind ( )

"Rewind "implementation of iterator interface

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

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

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

+ Here is the call graph for this function:

◆ valid()

ilMailAutoCompleteUserProvider::valid ( )

"Valid" implementation of iterator interface

Returns
boolean true/false

Reimplemented from ilMailAutoCompleteRecipientProvider.

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

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

References data.


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