19 declare(strict_types=1);
29 'login' => $this->data[
'login'],
30 'firstname' => $this->data[
'firstname'],
31 'lastname' => $this->data[
'lastname'],
35 public function key(): string
37 return $this->data[
'login'];
42 if ($this->res !==
null) {
43 $this->db->free($this->res);
50 $query = implode(
' ', [
51 'SELECT ' . $select_part,
53 $where_part !==
'' ?
'WHERE ' . $where_part :
'',
54 $order_by_part !==
'' ?
'ORDER BY ' . $order_by_part :
'',
57 $this->res = $this->db->query($query);
65 '(CASE WHEN (firstname IS NOT NULL AND (profpref.value = %s OR profpref.value = %s)) THEN firstname ELSE \'\' END) firstname',
66 $this->db->quote(
'y',
'text'),
67 $this->db->quote(
'g',
'text')
70 '(CASE WHEN (lastname IS NOT NULL AND (profpref.value = %s OR profpref.value = %s)) THEN lastname ELSE \'\' END) lastname',
71 $this->db->quote(
'y',
'text'),
72 $this->db->quote(
'g',
'text')
75 '(CASE WHEN (email IS NOT NULL AND (profpref.value = %s OR profpref.value = %s) ' .
76 "AND pubemail.value = %s) THEN email ELSE '' END) email",
77 $this->db->quote(
'y',
'text'),
78 $this->db->quote(
'g',
'text'),
79 $this->db->quote(
'y',
'text')
83 $fields[] =
'profpref.value profile_value';
84 $fields[] =
'pubemail.value email_value';
86 return implode(
', ', $fields);
94 LEFT JOIN usr_pref profpref 95 ON profpref.usr_id = usr_data.usr_id 96 AND profpref.keyword = ' . $this->db->quote(
'public_profile',
'text');
99 LEFT JOIN usr_pref pubemail 100 ON pubemail.usr_id = usr_data.usr_id 101 AND pubemail.keyword = ' . $this->db->quote(
'public_email',
'text');
103 return 'usr_data ' . implode(
' ', $joins);
108 $outer_conditions = [];
109 $outer_conditions[] =
'usr_data.usr_id != ' . $this->db->quote(
ANONYMOUS_USER_ID,
'integer');
110 $outer_conditions[] =
'usr_data.active != ' . $this->db->quote(0,
'integer');
112 $field_conditions = [];
116 if (
'email' === $field) {
121 $email_query[] = $field_condition;
122 $email_query[] =
'pubemail.value = ' . $this->db->quote(
'y',
'text');
123 $field_conditions[] =
'(' . implode(
' AND ', $email_query) .
')';
125 $field_conditions[] = $field_condition;
134 if ($field_conditions !== []) {
135 $fields =
'(' . implode(
' OR ', $field_conditions) .
')';
137 $field_conditions = [
'(' . implode(
' AND ', [
139 $this->db->in(
'profpref.value', [
'y',
'g'],
false,
'text'),
148 $outer_conditions[] = $this->db->in(
156 if ($field_conditions !== []) {
157 $outer_conditions[] =
'(' . implode(
' OR ', $field_conditions) .
')';
160 return implode(
' AND ', $outer_conditions);
170 return $this->db->like($field,
'text', $a_str .
'%');
178 $available_fields = [];
179 foreach ([
'firstname',
'lastname'] as $field) {
181 $available_fields[] = $field;
184 return $available_fields;
getWherePart(string $search_query)
getQueryConditionByFieldAndValue(string $field, $a_str)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _isEnabled($a_key)