69 $this->result_field =
'login';
129 $this->searchable_check = $a_status;
148 $this->user_access_check = $a_status;
166 $this->possible_fields = $a_fields;
188 $available_fields = array();
191 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
194 $available_fields[] = $field;
197 return $available_fields;
206 $this->result_field = $a_field;
214 public function getList($a_str)
223 $where_part = $this->getWherePart($a_str);
225 $query = implode(
" ", array(
226 'SELECT ' . $select_part,
227 'FROM ' . $this->getFromPart(),
228 $where_part ?
'WHERE ' . $where_part :
'',
229 $order_by_part ?
'ORDER BY ' . $order_by_part :
''
232 $ilLog->write(__METHOD__ .
': Query: ' .
$query);
234 $res = $ilDB->query($query);
238 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
244 include_once
'./Services/Search/classes/class.ilSearchSettings.php';
248 while(($rec = $ilDB->fetchAssoc(
$res)) && $cnt < $max)
251 $label = $rec[
'lastname'] .
', ' . $rec[
'firstname'] .
' [' . $rec[
'login'] .
']';
253 if($add_email && $rec[
'email'] && (self::PRIVACY_MODE_RESPECT_USER_SETTING != $this->
getPrivacyMode() ||
'y' == $rec[
'email_value']))
255 $label .=
', ' . $rec[
'email'];
258 $result[$cnt] =
new stdClass();
259 $result[$cnt]->value = (string)$rec[$this->result_field];
264 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
280 if(self::PRIVACY_MODE_RESPECT_USER_SETTING == $this->
getPrivacyMode())
282 $fields[] =
'profpref.value profile_value';
283 $fields[] =
'pubemail.value email_value';
286 return implode(
', ', $fields);
292 protected function getFromPart()
301 if(self::PRIVACY_MODE_RESPECT_USER_SETTING == $this->
getPrivacyMode())
303 $joins[] =
'LEFT JOIN usr_pref profpref
304 ON profpref.usr_id = usr_data.usr_id
305 AND profpref.keyword = ' . $ilDB->quote(
'public_profile',
'text');
307 $joins[] =
'LEFT JOIN usr_pref pubemail
308 ON pubemail.usr_id = usr_data.usr_id
309 AND pubemail.keyword = ' . $ilDB->quote(
'public_email',
'text');
314 return 'usr_data ' . implode(
' ', $joins);
326 protected function getWherePart($search_query)
334 $outer_conditions = array();
337 if(self::PRIVACY_MODE_RESPECT_USER_SETTING == $this->
getPrivacyMode() &&
339 $this->
getUser()->isAnonymous()
342 if(!$ilSetting->get(
'enable_global_profiles', 0))
350 $outer_conditions[] =
'profpref.value = ' . $ilDB->quote(
'g',
'text');
354 $outer_conditions[] =
'usr_data.usr_id != ' . $ilDB->quote(ANONYMOUS_USER_ID,
'integer');
356 $field_conditions = array();
359 $field_condition = $this->getQueryConditionByFieldAndValue($field, $search_query);
361 if(
'email' == $field && self::PRIVACY_MODE_RESPECT_USER_SETTING == $this->
getPrivacyMode())
365 $email_query = array();
366 $email_query[] = $field_condition;
367 $email_query[] =
'pubemail.value = ' . $ilDB->quote(
'y',
'text');
368 $field_conditions[] =
'(' . implode(
' AND ', $email_query) .
')';
372 $field_conditions[] = $field_condition;
380 if(self::PRIVACY_MODE_RESPECT_USER_SETTING == $this->
getPrivacyMode() &&
385 $fields = implode(
' OR ', $field_conditions);
387 $field_conditions[] =
'(' . implode(
' AND ', array(
389 $ilDB->in(
'profpref.value', array(
'y',
'g'),
false,
'text')
395 $field_conditions[] = $this->getQueryConditionByFieldAndValue(
'login', $search_query);
397 include_once
'Services/User/classes/class.ilUserAccountSettings.php';
400 include_once
'./Services/User/classes/class.ilUserFilter.php';
404 if($field_conditions)
406 $outer_conditions[] =
'(' . implode(
' OR ', $field_conditions) .
')';
409 return implode(
' AND ', $outer_conditions);
425 protected function getQueryConditionByFieldAndValue($field, $a_str)
433 if(!stristr($a_str,
'\\'))
435 $a_str = str_replace(
'%',
'\%', $a_str);
436 $a_str = str_replace(
'_',
'\_', $a_str);
441 return $ilDB->like($field,
'text', $a_str .
'%');
445 return $ilDB->like($field,
'text', $a_str);