mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-10 18:53:01 +02:00
fixes #1604 moved activity download API method to activity php file
This commit is contained in:
@@ -650,7 +650,7 @@ $(document).ready(function () {
|
|||||||
<span class="icon-spin6 animate-spin"></span>
|
<span class="icon-spin6 animate-spin"></span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</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>
|
<i class="icon-download"> </i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -25,6 +25,64 @@ check_status(ACCESS_ADMINISTRATOR);
|
|||||||
$page['tab'] = 'user_activity';
|
$page['tab'] = 'user_activity';
|
||||||
include(PHPWG_ROOT_PATH.'admin/include/user_tabs.inc.php');
|
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 |
|
// | 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user