Elgg  Version master
attributes.php
Go to the documentation of this file.
1 <?php
8 $entity = elgg_extract('entity', $vars);
9 if (!$entity instanceof \ElggUser) {
10  return;
11 }
12 
13 $data = [
14  [
15  elgg_echo('table_columns:fromProperty:name'),
16  $entity->getDisplayName(),
17  ],
18  [
19  elgg_echo('table_columns:fromProperty:username'),
20  $entity->username,
21  ],
22  [
23  elgg_echo('table_columns:fromProperty:email'),
24  $entity->email,
25  ],
26  [
27  elgg_echo('table_columns:fromView:time_created'),
28  elgg_view('output/datetime-local', ['value' => $entity->time_created, 'format' => elgg_echo('friendlytime:date_format')]),
29  ],
30  [
31  elgg_echo('table_columns:fromView:time_updated'),
32  elgg_view('output/datetime-local', ['value' => $entity->time_updated, 'format' => elgg_echo('friendlytime:date_format')]),
33  ],
34  [
35  elgg_echo('table_columns:fromView:last_action'),
36  elgg_view('output/datetime-local', ['value' => $entity->last_action, 'format' => elgg_echo('friendlytime:date_format')]),
37  ],
38  [
39  elgg_echo('table_columns:fromView:last_login'),
40  elgg_view('output/datetime-local', ['value' => $entity->last_login, 'format' => elgg_echo('friendlytime:date_format')]),
41  ],
42  [
43  elgg_echo('table_columns:fromView:prev_last_login'),
44  elgg_view('output/datetime-local', ['value' => $entity->prev_last_login, 'format' => elgg_echo('friendlytime:date_format')]),
45  ],
46  [
47  elgg_echo('table_columns:fromView:admin'),
48  $entity->isAdmin() ? elgg_echo('option:yes') : elgg_echo('option:no'),
49  ],
50  [
51  elgg_echo('table_columns:fromView:banned'),
52  $entity->isBanned() ? elgg_echo('option:yes') : elgg_echo('option:no'),
53  ],
54  [
55  elgg_echo('table_columns:fromProperty:validated'),
56  $entity->isValidated() ? elgg_echo('option:yes') : elgg_echo('option:no'),
57  ],
58 ];
59 
60 $rows = [];
61 foreach ($data as $row) {
62  $cells = [];
63 
64  foreach ($row as $cell) {
65  $cells[] = elgg_format_element('td', [], (string) $cell);
66  }
67 
68  $rows[] = elgg_format_element('tr', [], implode(PHP_EOL, $cells));
69 }
70 
71 echo elgg_format_element('table', ['class' => 'elgg-table-alt'], implode(PHP_EOL, $rows));
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
if(!$entity instanceof\ElggUser) $data
Definition: attributes.php:13
$rows
Definition: attributes.php:60
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:177
$entity
Show user attributes in admin listings.
Definition: attributes.php:8
$vars
Definition: theme.php:5
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145