mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-19 15:22:08 +02:00
Merge remote-tracking branch 'github-nickvergessen/ticket/12113' into develop-ascraeus
* github-nickvergessen/ticket/12113: [ticket/12113] Fix view_log() tests [ticket/12113] Correctly use plurals when deleting user warnings [ticket/12113] Allow log entries to use plurals
This commit is contained in:
commit
497d81af68
@ -1253,17 +1253,13 @@ class acp_users
|
||||
WHERE user_id = $user_id";
|
||||
$db->sql_query($sql);
|
||||
|
||||
switch ($log_warnings)
|
||||
if ($log_warnings)
|
||||
{
|
||||
case 2:
|
||||
add_log('admin', 'LOG_WARNINGS_DELETED', $user_row['username'], $num_warnings);
|
||||
break;
|
||||
case 1:
|
||||
add_log('admin', 'LOG_WARNING_DELETED', $user_row['username']);
|
||||
break;
|
||||
default:
|
||||
add_log('admin', 'LOG_WARNINGS_DELETED_ALL', $user_row['username']);
|
||||
break;
|
||||
add_log('admin', 'LOG_WARNINGS_DELETED', $user_row['username'], $num_warnings);
|
||||
}
|
||||
else
|
||||
{
|
||||
add_log('admin', 'LOG_WARNINGS_DELETED_ALL', $user_row['username']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -776,7 +776,10 @@ $lang = array_merge($lang, array(
|
||||
'LOG_USER_GROUP_RESIGN' => '<strong>User resigned membership from group</strong><br />» %s',
|
||||
|
||||
'LOG_WARNING_DELETED' => '<strong>Deleted user warning</strong><br />» %s',
|
||||
'LOG_WARNINGS_DELETED' => '<strong>Deleted %2$s user warnings</strong><br />» %1$s', // Example: '<strong>Deleted 2 user warnings</strong><br />» username'
|
||||
'LOG_WARNINGS_DELETED' => array(
|
||||
1 => '<strong>Deleted user warning</strong><br />» %1$s',
|
||||
2 => '<strong>Deleted %2$d user warnings</strong><br />» %1$s', // Example: '<strong>Deleted 2 user warnings</strong><br />» username'
|
||||
),
|
||||
'LOG_WARNINGS_DELETED_ALL' => '<strong>Deleted all user warnings</strong><br />» %s',
|
||||
|
||||
'LOG_WORD_ADD' => '<strong>Added word censor</strong><br />» %s',
|
||||
|
@ -490,7 +490,7 @@ class log implements \phpbb\log\log_interface
|
||||
'topic_id' => (int) $row['topic_id'],
|
||||
|
||||
'viewforum' => ($row['forum_id'] && $this->auth->acl_get('f_read', $row['forum_id'])) ? append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $row['forum_id']) : false,
|
||||
'action' => (isset($this->user->lang[$row['log_operation']])) ? $this->user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}',
|
||||
'action' => (isset($this->user->lang[$row['log_operation']])) ? $row['log_operation'] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}',
|
||||
);
|
||||
|
||||
/**
|
||||
@ -517,12 +517,26 @@ class log implements \phpbb\log\log_interface
|
||||
// arguments, if there are we fill out the arguments
|
||||
// array. It doesn't matter if we add more arguments than
|
||||
// placeholders.
|
||||
if ((substr_count($log[$i]['action'], '%') - sizeof($log_data_ary)) > 0)
|
||||
$num_args = 0;
|
||||
if (!is_array($this->user->lang[$row['log_operation']]))
|
||||
{
|
||||
$log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($log[$i]['action'], '%') - sizeof($log_data_ary), ''));
|
||||
$num_args = substr_count($log[$i]['action'], '%');
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($this->user->lang[$row['log_operation']] as $case => $plural_string)
|
||||
{
|
||||
$num_args = max($num_args, substr_count($plural_string, '%'));
|
||||
}
|
||||
}
|
||||
|
||||
$log[$i]['action'] = vsprintf($log[$i]['action'], $log_data_ary);
|
||||
if (($num_args - sizeof($log_data_ary)) > 0)
|
||||
{
|
||||
$log_data_ary = array_merge($log_data_ary, array_fill(0, $num_args - sizeof($log_data_ary), ''));
|
||||
}
|
||||
|
||||
$lang_arguments = array_merge(array($log[$i]['action']), $log_data_ary);
|
||||
$log[$i]['action'] = call_user_func_array(array($this->user, 'lang'), $lang_arguments);
|
||||
|
||||
// If within the admin panel we do not censor text out
|
||||
if ($this->get_is_admin())
|
||||
|
@ -44,7 +44,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
|
||||
'topic_id' => 0,
|
||||
|
||||
'viewforum' => '',
|
||||
'action' => 'installed: 3.1.0-dev',
|
||||
'action' => 'LOG_INSTALL_INSTALLED 3.1.0-dev',
|
||||
),
|
||||
2 => array(
|
||||
'id' => 2,
|
||||
|
@ -46,4 +46,9 @@ class phpbb_mock_user
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function lang()
|
||||
{
|
||||
return implode(' ', func_get_args());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user