mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-28 12:19:57 +03:00
fixes #1529 rewrite list of filter users for activities
* migration task to update activity.performed_by (with object_id) for logout action (was always user guest instead of the real user) * activities: use the actual regrouped lines to list filter users (instead of performing a separate SQL query)
This commit is contained in:
parent
f0110cead6
commit
8e2f12fdf0
4 changed files with 54 additions and 39 deletions
|
@ -547,15 +547,8 @@ function lineConstructor(line) {
|
|||
newLine.find(".date-hour").html(line.hour);
|
||||
|
||||
/* User _Section */
|
||||
|
||||
if (line.user_id != 2) {
|
||||
newLine.find(".user-name").html(line.username);
|
||||
newLine.find(".user-pic").html(get_initials(line.username));
|
||||
} else {
|
||||
newLine.find(".user-name").html(line.details.users_string);
|
||||
newLine.find(".user-pic").html(get_initials(line.details.users_string));
|
||||
}
|
||||
|
||||
|
||||
/* Detail_section */
|
||||
newLine.find(".detail-item-1").html(line.ip_address);
|
||||
|
|
|
@ -582,11 +582,18 @@ function pwg_activity($object, $object_id, $action, $details=array())
|
|||
|
||||
foreach ($object_ids as $loop_object_id)
|
||||
{
|
||||
$performed_by = $user['id'];
|
||||
|
||||
if ('logout' == $action)
|
||||
{
|
||||
$performed_by = $loop_object_id;
|
||||
}
|
||||
|
||||
$inserts[] = array(
|
||||
'object' => $object,
|
||||
'object_id' => $loop_object_id,
|
||||
'action' => $action,
|
||||
'performed_by' => $user['id'],
|
||||
'performed_by' => $performed_by,
|
||||
'session_idx' => session_id(),
|
||||
'ip_address' => $ip_address,
|
||||
'details' => $details_insert,
|
||||
|
|
|
@ -442,10 +442,8 @@ SELECT
|
|||
session_idx,
|
||||
ip_address,
|
||||
occured_on,
|
||||
details,
|
||||
'.$conf['user_fields']['username'].' AS username
|
||||
details
|
||||
FROM '.ACTIVITY_TABLE.'
|
||||
JOIN '.USERS_TABLE.' AS u ON performed_by = u.'.$conf['user_fields']['id'].'
|
||||
ORDER BY activity_id DESC
|
||||
;';
|
||||
|
||||
|
@ -466,11 +464,6 @@ SELECT
|
|||
$detailsType = 'script';
|
||||
}
|
||||
|
||||
if ('user' == $row['object'])
|
||||
{
|
||||
$user_ids[ $row['object_id'] ] = 1;
|
||||
}
|
||||
|
||||
$line_key = $row['session_idx'].'~'.$row['object'].'~'.$row['action'].'~'; // idx~photo~add
|
||||
|
||||
if ($line_key === $current_key)
|
||||
|
@ -491,13 +484,13 @@ SELECT
|
|||
'ip_address' => $row['ip_address'],
|
||||
'date' => format_date($date),
|
||||
'hour' => $hour,
|
||||
'username' => $row['username'],
|
||||
'user_id' => $row['performed_by'],
|
||||
'detailsType' => $detailsType,
|
||||
'details' => $details,
|
||||
'counter' => 1,
|
||||
);
|
||||
|
||||
@$user_ids[ $row['performed_by'] ]++;
|
||||
$current_key = $line_key;
|
||||
$line_id++;
|
||||
}
|
||||
|
@ -515,17 +508,6 @@ SELECT
|
|||
WHERE `'.$conf['user_fields']['id'].'` IN ('.implode(',', array_keys($user_ids)).')
|
||||
;';
|
||||
$username_of = query2array($query, 'user_id', 'username');
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
performed_by,
|
||||
count(*) as nb_lines
|
||||
FROM '.ACTIVITY_TABLE.'
|
||||
GROUP BY
|
||||
performed_by
|
||||
;';
|
||||
|
||||
$user_id_list = query2array($query, 'performed_by', 'nb_lines');
|
||||
}
|
||||
|
||||
foreach ($output_lines as $idx => $output_line)
|
||||
|
@ -542,19 +524,27 @@ SELECT
|
|||
$output_lines[$idx]['details']['users_string'] = implode(', ', $output_lines[$idx]['details']['users']);
|
||||
}
|
||||
}
|
||||
|
||||
$output_lines[$idx]['username'] = 'user#'.$output_lines[$idx]['user_id'];
|
||||
if (isset($username_of[ $output_lines[$idx]['user_id'] ]))
|
||||
{
|
||||
$output_lines[$idx]['username'] = $username_of[ $output_lines[$idx]['user_id'] ];
|
||||
}
|
||||
}
|
||||
|
||||
$filterable_users = array();
|
||||
foreach ($user_id_list as $key => $value) {
|
||||
if (isset($username_of[$key])) {
|
||||
foreach ($user_ids as $key => $value)
|
||||
{
|
||||
if (isset($username_of[$key]))
|
||||
{
|
||||
$filterable_users[$username_of[$key]] = $value;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$filterable_users['user#'.$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
unset($filterable_users['guest']);
|
||||
|
||||
// return $output_lines;
|
||||
return array(
|
||||
'result_lines' => $output_lines,
|
||||
|
|
25
install/db/162-database.php
Normal file
25
install/db/162-database.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This file is part of Piwigo. |
|
||||
// | |
|
||||
// | For copyright and license information, please view the COPYING.txt |
|
||||
// | file that was distributed with this source code. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if (!defined('PHPWG_ROOT_PATH'))
|
||||
{
|
||||
die('Hacking attempt!');
|
||||
}
|
||||
|
||||
$upgrade_description = 'change activity.performed_by for logout';
|
||||
|
||||
$query = '
|
||||
UPDATE '.PREFIX_TABLE.'activity
|
||||
SET performed_by = object_id
|
||||
WHERE action = \'logout\'
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
echo "\n".$upgrade_description."\n";
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue