(cp 1e8b4c747) fixes #1604 moved activity download API method to activity php file

This commit is contained in:
Matthieu Leproux
2022-02-02 14:45:34 +01:00
parent e760d0ec95
commit 691f3fc84d
3 changed files with 59 additions and 61 deletions
-60
View File
@@ -576,64 +576,4 @@ SELECT
);
}
/**
* API method
* Returns lines of users activity
* @since 12
*/
function ws_activity_downloadLog($param, &$service)
{
global $conf;
$output_lines = array();
$query = '
SELECT
activity_id,
performed_by,
object,
object_id,
action,
ip_address,
occured_on,
details,
'.$conf['user_fields']['username'].' AS username
FROM '.ACTIVITY_TABLE.'
JOIN '.USERS_TABLE.' AS u ON performed_by = u.'.$conf['user_fields']['id'].'
ORDER BY activity_id DESC
;';
$result = pwg_query($query);
array_push($output_lines, ['User', 'ID_User', 'Object', 'Object_ID', 'Action', 'Date', 'Hour', 'IP_Address', 'Details']);
while ($row = pwg_db_fetch_assoc($result))
{
$row['details'] = str_replace('`groups`', 'groups', $row['details']);
$row['details'] = str_replace('`rank`', 'rank', $row['details']);
list($date, $hour) = explode(' ', $row['occured_on']);
$output_lines[] = array(
'username' => $row['username'],
'user_id' => $row['performed_by'],
'object' => $row['object'],
'object_id' => $row['object_id'],
'action' => $row['action'],
'date' => $date,
'hour' => $hour,
'ip_address' => $row['ip_address'],
'details' => $row['details'],
);
}
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename='.date('YmdGis').'piwigo_activity_log.csv');
header("Content-Transfer-Encoding: UTF-8");
$f = fopen('php://output', 'w');
foreach ($output_lines as $line) {
fputcsv($f, $line, ";");
}
fclose($f);
}
?>