4 include_once
'Services/User/classes/class.ilUserAutoComplete.php';
5 require_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);
89 $fields[] =
'profpref.value profile_value';
90 $fields[] =
'pubemail.value email_value';
92 return implode(
', ', $fields);
98 protected function getFromPart()
108 LEFT JOIN usr_pref profpref
109 ON profpref.usr_id = usr_data.usr_id
110 AND profpref.keyword = ' . $ilDB->quote(
'public_profile',
'text');
113 LEFT JOIN usr_pref pubemail
114 ON pubemail.usr_id = usr_data.usr_id
115 AND pubemail.keyword = ' . $ilDB->quote(
'public_email',
'text');
119 return 'usr_data ' . implode(
' ', $joins);
131 protected function getWherePart($search_query)
138 $outer_conditions = array();
139 $outer_conditions[] =
'usr_data.usr_id != ' . $ilDB->quote(ANONYMOUS_USER_ID,
'integer');
141 $field_conditions = array();
144 $field_condition = $this->getQueryConditionByFieldAndValue($field, $search_query);
146 if(
'email' == $field)
150 $email_query = array();
151 $email_query[] = $field_condition;
152 $email_query[] =
'pubemail.value = ' . $ilDB->quote(
'y',
'text');
153 $field_conditions[] =
'(' . implode(
' AND ', $email_query) .
')';
157 $field_conditions[] = $field_condition;
165 if($field_conditions)
167 $fields = implode(
' OR ', $field_conditions);
169 $field_conditions[] =
'(' . implode(
' AND ', array(
171 $ilDB->in(
'profpref.value', array(
'y',
'g'),
false,
'text')
177 $field_conditions[] = $this->getQueryConditionByFieldAndValue(
'login', $search_query);
179 include_once
'Services/User/classes/class.ilUserAccountSettings.php';
182 include_once
'./Services/User/classes/class.ilUserFilter.php';
186 if($field_conditions)
188 $outer_conditions[] =
'(' . implode(
' OR ', $field_conditions) .
')';
191 return implode(
' AND ', $outer_conditions);
207 protected function getQueryConditionByFieldAndValue($field, $a_str)
214 return $ilDB->like($field,
'text', $a_str .
'%');
223 $available_fields = array();
224 foreach(array(
'login',
'firstname',
'lastname') as $field)
226 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
229 $available_fields[] = $field;
232 return $available_fields;