diff --git a/admin/themes/default/template/user_activity.tpl b/admin/themes/default/template/user_activity.tpl index b57dad41e..69d6bedb1 100644 --- a/admin/themes/default/template/user_activity.tpl +++ b/admin/themes/default/template/user_activity.tpl @@ -650,7 +650,7 @@ $(document).ready(function () { - + diff --git a/admin/user_activity.php b/admin/user_activity.php index 948eefc1e..434629104 100644 --- a/admin/user_activity.php +++ b/admin/user_activity.php @@ -25,6 +25,64 @@ check_status(ACCESS_ADMINISTRATOR); $page['tab'] = 'user_activity'; include(PHPWG_ROOT_PATH.'admin/include/user_tabs.inc.php'); + +if (isset($_GET['type']) && 'download_logs' == $_GET['type']) { + + 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); + + exit(); +} + // +-----------------------------------------------------------------------+ // | template initialization | // +-----------------------------------------------------------------------+ diff --git a/include/ws_functions/pwg.php b/include/ws_functions/pwg.php index 255692649..7bb2d136b 100644 --- a/include/ws_functions/pwg.php +++ b/include/ws_functions/pwg.php @@ -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); -} - ?> \ No newline at end of file