mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-27 19:59:56 +03:00
fixes #1604 moved activity download API method to activity php file
This commit is contained in:
parent
0c3ef1d521
commit
1e8b4c747f
3 changed files with 59 additions and 61 deletions
|
@ -650,7 +650,7 @@ $(document).ready(function () {
|
|||
<span class="icon-spin6 animate-spin"></span>
|
||||
</span>
|
||||
</div>
|
||||
<a class="download_csv tiptip" title="{'Download all activities'|translate}" href="ws.php?format=json&method=pwg.activity.downloadLog">
|
||||
<a class="download_csv tiptip" title="{'Download all activities 2'|translate}" href="admin.php?page=user_activity&type=download_logs">
|
||||
<i class="icon-download"> </i>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -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 |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue