Skip to content

Commit

Permalink
added: user first and last login time to export data
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed Aug 21, 2024
1 parent 272cf25 commit e83136c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
26 changes: 18 additions & 8 deletions classes/ColdTrick/CSVExporter/ExportableValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ protected static function getUserExportableValues(): array {
$result[elgg_echo('email')] = 'email';
$result[elgg_echo('csv_exporter:exportable_value:user:last_action')] = 'csv_exporter_user_last_action';
$result[elgg_echo('csv_exporter:exportable_value:user:last_action_readable')] = 'csv_exporter_user_last_action_readable';
$result[elgg_echo('csv_exporter:exportable_value:user:first_login')] = 'csv_exporter_user_first_login';
$result[elgg_echo('csv_exporter:exportable_value:user:first_login_readable')] = 'csv_exporter_user_first_login_readable';
$result[elgg_echo('csv_exporter:exportable_value:user:last_login')] = 'csv_exporter_user_last_login';
$result[elgg_echo('csv_exporter:exportable_value:user:last_login_readable')] = 'csv_exporter_user_last_login_readable';
$result[elgg_echo('csv_exporter:exportable_value:user:groups_owned_name')] = 'csv_exporter_user_groups_owned_name';
$result[elgg_echo('csv_exporter:exportable_value:user:groups_owned_url')] = 'csv_exporter_user_groups_owned_url';
$result[elgg_echo('csv_exporter:exportable_value:user:friends')] = 'csv_exporter_user_friends';
Expand Down Expand Up @@ -303,14 +307,20 @@ public static function exportUserValue(\Elgg\Event $event) {
];

$exportable_value = $event->getParam('exportable_value');
$exportable_value = substr($exportable_value, strlen('csv_exporter_user_'));
switch ($exportable_value) {
case 'csv_exporter_user_last_action':
return (int) $entity->last_action;
case 'first_login':
case 'last_action':
case 'last_login':
return (int) $entity->{$exportable_value};

case 'csv_exporter_user_last_action_readable':
return csv_exported_get_readable_timestamp($entity->last_action);
case 'first_login_readable':
case 'last_action_readable':
case 'last_login_readable':
$exportable_value = substr($exportable_value, 0, -strlen('_readable'));
return $entity->{$exportable_value} ? csv_exported_get_readable_timestamp((int) $entity->{$exportable_value}) : '';

case 'csv_exporter_user_groups_owned_name':
case 'groups_owned_name':
$result = [];

$batch = elgg_get_entities($group_options);
Expand All @@ -320,7 +330,7 @@ public static function exportUserValue(\Elgg\Event $event) {
}
return $result;

case 'csv_exporter_user_groups_owned_url':
case 'groups_owned_url':
$result = [];

$batch = elgg_get_entities($group_options);
Expand All @@ -330,14 +340,14 @@ public static function exportUserValue(\Elgg\Event $event) {
}
return $result;

case 'csv_exporter_user_friends':
case 'friends':
return (int) $entity->getEntitiesFromRelationship([
'type' => 'user',
'relationship' => 'friend',
'count' => true,
]);

case 'csv_exporter_user_friends_of':
case 'friends_of':
return (int) $entity->getEntitiesFromRelationship([
'type' => 'user',
'relationship' => 'friend',
Expand Down
4 changes: 4 additions & 0 deletions languages/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@

'csv_exporter:exportable_value:user:last_action' => "Last action",
'csv_exporter:exportable_value:user:last_action_readable' => "Last action (readable)",
'csv_exporter:exportable_value:user:first_login' => "First login",
'csv_exporter:exportable_value:user:first_login_readable' => "First login (readable)",
'csv_exporter:exportable_value:user:last_login' => "Last login",
'csv_exporter:exportable_value:user:last_login_readable' => "Last login (readable)",
'csv_exporter:exportable_value:user:groups_owned_name' => "Groups owned name",
'csv_exporter:exportable_value:user:groups_owned_url' => "Groups owned url",
'csv_exporter:exportable_value:user:banned' => "Banned",
Expand Down
8 changes: 6 additions & 2 deletions languages/nl.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php
/**
* This file was created by Translation Editor v11.1
* On 2023-05-17 14:29
* This file was created by Translation Editor v14.0
* On 2024-08-21 12:59
*/

return array (
'csv_exporter:exportable_value:user:first_login' => 'Eerste aanmelding',
'csv_exporter:exportable_value:user:first_login_readable' => 'Eerste aanmelding (leesbaar)',
'csv_exporter:exportable_value:user:last_login' => 'Laatste aanmelding',
'csv_exporter:exportable_value:user:last_login_readable' => 'Laatste aanmelding (leesbaar)',
'csv_exporter:exportable_value:group:postfix' => ' (alleen gedurende groep export)',
'csv_exporter:exportable_value:user:group:member:unix' => 'Lid sinds (UNIX)',
'csv_exporter:exportable_value:user:group:member:readable' => 'Lid sinds',
Expand Down

0 comments on commit e83136c

Please sign in to comment.