Elgg  Version 6.3
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  function() use ($entity) {
31  try {
32  $log = null;
33  if (elgg_is_active_plugin('system_log')) {
34  $log = elgg_extract(0, \Elgg\SystemLog\SystemLog::instance()->getAll([
35  'object_id' => $entity->guid,
36  'event' => 'create:user',
37  'object_type' => 'user',
38  'limit' => 1,
39  ]));
40  }
41 
42  if ($log && !empty($log->ip_address)) {
43  return [' - ' . elgg_echo('usersettings:statistics:login_history:ip'), $log->ip_address];
44  }
45  } catch (\DI\NotFoundException $e) {
46  // somehow the service isn't correctly registered or unavailable
47  }
48  },
49  [
50  elgg_echo('table_columns:fromView:time_updated'),
51  elgg_view('output/datetime-local', ['value' => $entity->time_updated, 'format' => elgg_echo('friendlytime:date_format')]),
52  ],
53  [
54  elgg_echo('table_columns:fromView:last_action'),
55  elgg_view('output/datetime-local', ['value' => $entity->last_action, 'format' => elgg_echo('friendlytime:date_format')]),
56  ],
57  [
58  elgg_echo('table_columns:fromView:last_login'),
59  elgg_view('output/datetime-local', ['value' => $entity->last_login, 'format' => elgg_echo('friendlytime:date_format')]),
60  ],
61  [
62  elgg_echo('table_columns:fromView:prev_last_login'),
63  elgg_view('output/datetime-local', ['value' => $entity->prev_last_login, 'format' => elgg_echo('friendlytime:date_format')]),
64  ],
65  [
66  elgg_echo('table_columns:fromView:admin'),
67  $entity->isAdmin() ? elgg_echo('option:yes') : elgg_echo('option:no'),
68  ],
69  [
70  elgg_echo('table_columns:fromView:banned'),
71  $entity->isBanned() ? elgg_echo('option:yes') : elgg_echo('option:no'),
72  ],
73  [
74  elgg_echo('table_columns:fromProperty:validated'),
75  $entity->isValidated() ? elgg_echo('option:yes') : elgg_echo('option:no'),
76  ],
77 ];
78 
79 $rows = [];
80 foreach ($data as $row) {
81  $cells = [];
82 
83  if (is_callable($row)) {
84  $row = call_user_func($row);
85  if (!is_array($row)) {
86  continue;
87  }
88  }
89 
90  foreach ($row as $cell) {
91  $cells[] = elgg_format_element('td', [], (string) $cell);
92  }
93 
94  $rows[] = elgg_format_element('tr', [], implode(PHP_EOL, $cells));
95 }
96 
97 echo elgg_format_element('table', ['class' => 'elgg-table-alt'], implode(PHP_EOL, $rows));
$vars
Definition: theme.php:3
$entity
Show user attributes in admin listings.
Definition: attributes.php:8
if(! $entity instanceof \ElggUser) $data
Definition: attributes.php:13
$rows
Definition: attributes.php:79
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:240
elgg_is_active_plugin(string $plugin_id)
Returns if a plugin is active for a current site.
Definition: plugins.php:27
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_view(string $view, array $vars=[], string $viewtype='')
Return a parsed view.
Definition: views.php:156
elgg_format_element(string $tag_name, array $attributes=[], string $text='', array $options=[])
Format an HTML element.
Definition: output.php:145