19declare(strict_types=1);
34 'login' => $this->data[
'login'],
35 'firstname' => $this->data[
'firstname'],
36 'lastname' => $this->data[
'lastname'],
40 public function key(): string
42 return $this->data[
'login'];
47 if ($this->res !==
null) {
48 $this->db->free($this->res);
55 $query = implode(
' ', [
56 'SELECT ' . $select_part,
58 $where_part !==
'' ?
'WHERE ' . $where_part :
'',
59 $order_by_part !==
'' ?
'ORDER BY ' . $order_by_part :
'',
62 $this->res = $this->db->query($query);
70 '(CASE WHEN (firstname IS NOT NULL AND (profpref.value = %s OR profpref.value = %s)) THEN firstname ELSE \'\' END) firstname',
71 $this->db->quote(
'y',
'text'),
72 $this->db->quote(
'g',
'text')
75 '(CASE WHEN (lastname IS NOT NULL AND (profpref.value = %s OR profpref.value = %s)) THEN lastname ELSE \'\' END) lastname',
76 $this->db->quote(
'y',
'text'),
77 $this->db->quote(
'g',
'text')
80 '(CASE WHEN (email IS NOT NULL AND (profpref.value = %s OR profpref.value = %s) ' .
81 "AND pubemail.value = %s) THEN email ELSE '' END) email",
82 $this->db->quote(
'y',
'text'),
83 $this->db->quote(
'g',
'text'),
84 $this->db->quote(
'y',
'text')
88 $fields[] =
'profpref.value profile_value';
89 $fields[] =
'pubemail.value email_value';
91 return implode(
', ', $fields);
99 LEFT JOIN usr_pref profpref
100 ON profpref.usr_id = usr_data.usr_id
101 AND profpref.keyword = ' . $this->db->quote(
'public_profile',
'text');
104 LEFT JOIN usr_pref pubemail
105 ON pubemail.usr_id = usr_data.usr_id
106 AND pubemail.keyword = ' . $this->db->quote(
'public_email',
'text');
108 return 'usr_data ' . implode(
' ', $joins);
113 $outer_conditions = [];
114 $outer_conditions[] =
'usr_data.usr_id != ' . $this->db->quote(
ANONYMOUS_USER_ID,
'integer');
115 $outer_conditions[] =
'usr_data.active != ' . $this->db->quote(0,
'integer');
117 $field_conditions = [];
121 if ($field ===
'email') {
126 $email_query[] = $field_condition;
127 $email_query[] =
'pubemail.value = ' . $this->db->quote(
'y',
'text');
128 $field_conditions[] =
'(' . implode(
' AND ', $email_query) .
')';
130 $field_conditions[] = $field_condition;
139 if ($field_conditions !== []) {
140 $fields =
'(' . implode(
' OR ', $field_conditions) .
')';
142 $field_conditions = [
143 '(' . implode(
' AND ', [
145 $this->db->in(
'profpref.value', [
'y',
'g'],
false,
'text'),
155 $outer_conditions[] = $this->db->in(
163 if ($field_conditions !== []) {
164 $outer_conditions[] =
'(' . implode(
' OR ', $field_conditions) .
')';
167 return implode(
' AND ', $outer_conditions);
177 return $this->db->like($field,
'text', $a_str .
'%');
185 $available_fields = [];
186 foreach ([
'firstname',
'lastname'] as $field) {
187 if (\ilUserSearchOptions::_isEnabled($field)) {
188 $available_fields[] = $field;
192 return $available_fields;
@phpstan-import-type AutoCompleteUserRecord from RecipientSearchProvider
getWherePart(string $search_query)
getQueryConditionByFieldAndValue(string $field, $a_str)
@phpstan-type AutoCompleteUserRecord array{login?: string, firstname?: string, lastname?...