4include_once
'Services/User/classes/class.ilUserAutoComplete.php';
5require_once
'Services/Mail/classes/class.ilMailAutoCompleteRecipientProvider.php';
27 $this->data = $this->db->fetchAssoc($this->res);
29 return is_array($this->data);
39 'login' => $this->data[
'login'],
40 'firstname' => $this->data[
'firstname'],
41 'lastname' => $this->data[
'lastname']
51 return $this->data[
'login'];
61 $this->db->free($this->res);
65 $where_part = $this->getWherePart($this->quoted_term);
67 $query = implode(
" ", array(
68 'SELECT ' . $select_part,
69 'FROM ' . $this->getFromPart(),
70 $where_part ?
'WHERE ' . $where_part :
'',
71 $order_by_part ?
'ORDER BY ' . $order_by_part :
''
74 $this->res = $this->db->query(
$query);
85 "(CASE WHEN (profpref.value = %s OR profpref.value = %s OR profpref.value IS NULL) THEN firstname ELSE '' END) firstname",
86 $this->db->quote(
'y',
'text'), $this->db->quote(
'g',
'text')
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'), $this->db->quote(
'g',
'text')
93 "(CASE WHEN ((profpref.value = %s OR profpref.value = %s OR profpref.value IS NULL) AND pubemail.value = %s) THEN email ELSE '' END) email",
94 $this->db->quote(
'y',
'text'), $this->db->quote(
'g',
'text'), $this->db->quote(
'y',
'text')
98 $fields[] =
'profpref.value profile_value';
99 $fields[] =
'pubemail.value email_value';
101 return implode(
', ', $fields);
107 protected function getFromPart()
117 LEFT JOIN usr_pref profpref
118 ON profpref.usr_id = usr_data.usr_id
119 AND profpref.keyword = ' .
$ilDB->quote(
'public_profile',
'text');
122 LEFT JOIN usr_pref pubemail
123 ON pubemail.usr_id = usr_data.usr_id
124 AND pubemail.keyword = ' .
$ilDB->quote(
'public_email',
'text');
128 return 'usr_data ' . implode(
' ', $joins);
140 protected function getWherePart($search_query)
147 $outer_conditions = array();
148 $outer_conditions[] =
'usr_data.usr_id != ' .
$ilDB->quote(ANONYMOUS_USER_ID,
'integer');
150 $field_conditions = array();
153 $field_condition = $this->getQueryConditionByFieldAndValue($field, $search_query);
155 if(
'email' == $field)
159 $email_query = array();
160 $email_query[] = $field_condition;
161 $email_query[] =
'pubemail.value = ' .
$ilDB->quote(
'y',
'text');
162 $field_conditions[] =
'(' . implode(
' AND ', $email_query) .
')';
166 $field_conditions[] = $field_condition;
174 if ($field_conditions) {
175 $fields =
'(' . implode(
' OR ', $field_conditions) .
')';
177 $field_conditions = [
'(' . implode(
' AND ', array(
179 $ilDB->in(
'profpref.value', array(
'y',
'g'),
false,
'text')
185 $field_conditions[] = $this->getQueryConditionByFieldAndValue(
'login', $search_query);
187 include_once
'Services/User/classes/class.ilUserAccountSettings.php';
190 include_once
'./Services/User/classes/class.ilUserFilter.php';
194 if($field_conditions)
196 $outer_conditions[] =
'(' . implode(
' OR ', $field_conditions) .
')';
199 return implode(
' AND ', $outer_conditions);
215 protected function getQueryConditionByFieldAndValue($field, $a_str)
222 return $ilDB->like($field,
'text', $a_str .
'%');
231 $available_fields = array();
232 foreach(array(
'firstname',
'lastname') as $field)
234 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
237 $available_fields[] = $field;
240 return $available_fields;
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
Class ilMailAutoCompleteRecipientProvider.
Class ilMailAutoCompleteUserProvider.
getFields()
Get searchable fields.
rewind()
"Rewind "implementation of iterator interface
key()
"Key" implementation of iterator interface
current()
"Current" implementation of iterator interface
__construct($quoted_term, $term)
valid()
"Valid" implementation of iterator interface
static getInstance()
Singelton get instance.
static getInstance()
Singelton get instance.
static _isEnabled($a_key)