19 declare(strict_types=1);
56 public function __construct($a_parent_obj, $a_parent_cmd, $a_admin_mode =
false, $a_type = self::TYPE_STANDARD)
60 $this->
user = $DIC->user();
61 $this->review = $DIC->rbac()->review();
62 $this->
ui = $DIC->ui();
63 $this->
http = $DIC->http();
66 $this->admin_mode = (bool) $a_admin_mode;
67 $this->type = $a_type;
69 $this->
setId(
"rep_search_" . $this->
user->getId());
79 if ($this->
getType() == self::TYPE_STANDARD) {
80 $this->
setRowTemplate(
"tpl.rep_search_usr_result_row.html",
"components/ILIAS/Search");
82 $this->
enable(
'select_all');
87 $this->
setRowTemplate(
"tpl.global_search_usr_result_row.html",
"components/ILIAS/Search");
95 if ($this->
getType() == self::TYPE_STANDARD) {
98 $this->
addColumn($all_cols[$col][
'txt'], $sort_field);
102 $this->
getType() != self::TYPE_STANDARD &&
116 $this->lucene_result =
$res;
126 $this->user_limitations = $a_limitations;
139 if (!self::$all_selectable_cols) {
142 if ($this->admin_mode) {
144 $columns[
'access_until'] = array(
'txt' => $this->
lng->txt(
'access_until'));
145 $columns[
'last_login'] = array(
'txt' => $this->
lng->txt(
'last_login'));
148 self::$all_selectable_cols = $columns;
150 return self::$all_selectable_cols;
155 if (!count($a_commands)) {
163 protected function fillRow(array $a_set): void
165 $this->tpl->setVariable(
"VAL_ID", $a_set[
"usr_id"]);
168 if ($this->
getType() == self::TYPE_GLOBAL_SEARCH) {
171 $this->tpl->setVariable(
'IMG_LINKED_TO_PROFILE', $link);
172 $this->tpl->setVariable(
173 'USR_IMG_SRC_LINKED',
177 $this->tpl->setVariable(
188 $a_set[
'gender'] = $a_set[
'gender'] ? $this->
lng->txt(
'gender_' . $a_set[
'gender']) :
'';
189 $this->tpl->setCurrentBlock(
'custom_fields');
190 $this->tpl->setVariable(
'VAL_CUST', $a_set[$field]);
191 $this->tpl->parseCurrentBlock();
196 $this->tpl->setCurrentBlock(
'custom_fields');
197 $this->tpl->setVariable(
'VAL_CUST', $a_set[$field]);
198 $this->tpl->parseCurrentBlock();
202 $this->tpl->setCurrentBlock(
'custom_fields');
203 $this->tpl->setVariable(
'CUST_CLASS',
' ' . $a_set[
'access_class']);
204 $this->tpl->setVariable(
'VAL_CUST', $a_set[$field]);
205 $this->tpl->parseCurrentBlock();
210 $this->tpl->setCurrentBlock(
'custom_fields');
211 $this->tpl->setVariable(
'VAL_CUST', $a_set[$field]);
212 $this->tpl->parseCurrentBlock();
215 case 'interests_general':
216 case 'interests_help_offered':
217 case 'interests_help_looking':
218 $this->tpl->setCurrentBlock(
'custom_fields');
219 $this->tpl->setVariable(
'VAL_CUST', implode(
', ', (array) $a_set[$field]));
220 $this->tpl->parseCurrentBlock();
224 $this->tpl->setCurrentBlock(
'custom_fields');
225 $this->tpl->setVariable(
227 ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits((
int) $a_set[
'usr_id'])
229 $this->tpl->parseCurrentBlock();
234 if ($this->admin_mode) {
235 $this->
ctrl->setParameterByClass(
"ilobjusergui",
"ref_id",
"7");
236 $this->
ctrl->setParameterByClass(
"ilobjusergui",
"obj_id", $a_set[
"usr_id"]);
237 $this->
ctrl->setParameterByClass(
"ilobjusergui",
"search",
"1");
238 $link = $this->
ctrl->getLinkTargetByClass(array(
"iladministrationgui",
"ilobjusergui"),
"view");
239 $a_set[$field] =
"<a href=\"" . $link .
"\">" . $a_set[$field] .
"</a>";
240 } elseif ($this->
getType() == self::TYPE_GLOBAL_SEARCH) {
241 $a_set[$field] =
"<a href=\"" . $link .
"\">" . $a_set[$field] .
"</a>";
247 $this->tpl->setCurrentBlock(
'custom_fields');
248 $this->tpl->setVariable(
'VAL_CUST', (
string) ($a_set[$field] ?:
''));
249 $this->tpl->parseCurrentBlock();
254 if ($this->
getType() == self::TYPE_GLOBAL_SEARCH) {
258 $this->tpl->setVariable(
'CONTACT_ACTIONS',
'');
272 $parse_access =
false;
273 if (isset($additional_fields[
'access_until'])) {
274 $parse_access =
true;
275 unset($additional_fields[
'access_until']);
278 $udf_ids = $usr_data_fields = $odf_ids = array();
279 foreach ($additional_fields as $field) {
280 if ($field ==
'org_units') {
283 if (substr($field, 0, 3) ==
'udf') {
284 $udf_ids[] = substr($field, 4);
287 $usr_data_fields[] = $field;
291 $u_query->setOrderField(
'login');
292 $u_query->setOrderDirection(
'ASC');
293 $u_query->setLimit(999999);
296 $u_query->setActionFilter(
"active");
300 $u_query->setAccessFilter(
true);
303 $u_query->setAdditionalFields($usr_data_fields);
304 $u_query->setUserFilter($a_user_ids);
306 $usr_data = $u_query->query();
309 if ($this->admin_mode && $parse_access) {
311 $current_time = time();
312 foreach ($usr_data[
'set'] as $k => $user) {
313 if ($user[
'active']) {
314 if ($user[
"time_limit_unlimited"]) {
315 $txt_access = $this->
lng->txt(
"access_unlimited");
316 $usr_data[
"set"][$k][
"access_class"] =
"smallgreen";
317 } elseif ($user[
"time_limit_until"] < $current_time) {
318 $txt_access = $this->
lng->txt(
"access_expired");
319 $usr_data[
"set"][$k][
"access_class"] =
"smallred";
322 $usr_data[
"set"][$k][
"access_class"] =
"small";
325 $txt_access = $this->
lng->txt(
"inactive");
326 $usr_data[
"set"][$k][
"access_class"] =
"smallred";
328 $usr_data[
"set"][$k][
"access_until"] = $txt_access;
338 foreach ($usr_data[
'set'] as $set) {
339 $users[$counter] = $set;
340 foreach ($udf_ids as $udf_field) {
341 $users[$counter][
'udf_' . $udf_field] = (
$data[(
int) ($set[
'usr_id'] ?? 0)][$udf_field] ??
'');
346 $users = $usr_data[
'set'];
349 if ($this->
getType() == self::TYPE_GLOBAL_SEARCH) {
351 foreach ($users as $counter => $ud) {
352 $users[$counter][
'relevance'] = $this->
getLuceneResult()->getRelevance((
int) ($ud[
'usr_id']) ?? 0);
356 if ($this->
getType() === self::TYPE_GLOBAL_SEARCH) {
365 $html = parent::getHTML();
366 if ($this->
getType() == self::TYPE_GLOBAL_SEARCH) {
376 if ($sort ===
'relevance') {
377 usort($set,
function (
$a,
$b) {
378 return $b[
'relevance'] <=>
$a[
'relevance'];
383 if (str_ends_with($sort,
'_asc')) {
384 $col = substr($sort, 0, -4);
385 usort($set,
function (
$a,
$b) use ($col) {
386 return [
$a[$col],
$b[
'relevance'] ??
''] <=> [$b[$col],
$a[
'relevance'] ??
''];
388 } elseif (str_ends_with($sort,
'_desc')) {
389 $col = substr($sort, 0, -5);
390 usort($set,
function (
$a,
$b) use ($col) {
391 return [
$b[$col],
$b[
'relevance'] ??
''] <=> [
$a[$col],
$a[
'relevance'] ??
''];
400 $sorts = [
'relevance' => $this->
lng->txt(
'search_sort_relevance')];
403 $sorts[$col .
'_asc'] = sprintf(
404 $this->
lng->txt(
'search_sort_generic_asc'),
405 $all_cols[$col][
'txt']
407 $sorts[$col .
'_desc'] = sprintf(
408 $this->
lng->txt(
'search_sort_generic_desc'),
409 $all_cols[$col][
'txt']
417 $lucene_enabled = ($this->
getType() == self::TYPE_GLOBAL_SEARCH) &&
419 return $lucene_enabled ?
'relevance' :
'login_asc';
static lookupData(array $a_user_ids, array $a_field_ids)
Lookup data.
TableGUI class user search results.
static array $all_selectable_cols
enable(string $a_module_name)
setFormAction(string $a_form_action, bool $a_multipart=false)
setEnableTitle(bool $a_enabletitle)
buildSortationViewControl()
trait ilSearchResultTableHelper
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
applySortation(array $set)
static getProfileLink(int $a_usr_id)
Get link to personal profile Return empty string in case of not public profile.
__construct($a_parent_obj, $a_parent_cmd, $a_admin_mode=false, $a_type=self::TYPE_STANDARD)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
addMultiItemSelectionButton(string $a_sel_var, array $a_options, string $a_cmd, string $a_text, string $a_default_selection='')
Provides fluid interface to RBAC services.
Search result implementing iterator interface.
setExternalSorting(bool $a_val)
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
static http()
Fetches the global http state from ILIAS.
setDefaultOrderField(string $a_defaultorderfield)
ilLuceneSearchResult $lucene_result
setUserLimitations(bool $a_limitations)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
initMultiCommands(array $a_commands)
static _getPersonalPicturePath(int $a_usr_id, string $a_size='small', bool $a_force_pic=false, bool $a_prevent_no_photo_image=false, bool $html_export=false)
setLuceneResult(ilLuceneSearchResult $res)
static getSelectableColumnInfo(bool $a_admin=false)
Get info of searchable fields for selectable columns in table gui.
__construct(Container $dic, ilPlugin $plugin)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
addMultiCommand(string $a_cmd, string $a_text)
parseUserIds(array $a_user_ids)