mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-16 12:29:43 +02:00
[ticket/10899] Using Delete All in log viewer with keyword search
https://tracker.phpbb.com/browse/PHPBB3-10899 PHPBB3-10899
This commit is contained in:
parent
d4fc060bcd
commit
c5a4ad3d31
@ -26,7 +26,7 @@ class acp_logs
|
||||
{
|
||||
global $db, $user, $auth, $template, $cache, $phpbb_container;
|
||||
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
|
||||
global $request;
|
||||
global $request, $phpbb_log;
|
||||
|
||||
$user->add_lang('mcp');
|
||||
|
||||
@ -66,7 +66,15 @@ class acp_logs
|
||||
unset($sql_in);
|
||||
}
|
||||
|
||||
if ($where_sql || $deleteall)
|
||||
if ($deleteall)
|
||||
{
|
||||
$where_sql = ($sort_days) ? 'AND log_time >= ' . (time() - ($sort_days * 86400)) : '';
|
||||
$keywords = utf8_normalize_nfc(request_var('keywords', '', true));
|
||||
$keywords_where = $phpbb_log->generate_sql_keyword($keywords, '');
|
||||
$where_sql .= ' ' . $keywords_where;
|
||||
}
|
||||
|
||||
if ($where_sql)
|
||||
{
|
||||
$sql = 'DELETE FROM ' . LOG_TABLE . "
|
||||
WHERE log_type = {$this->log_type}
|
||||
|
@ -33,7 +33,7 @@ class mcp_logs
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $auth, $db, $user, $template;
|
||||
global $config, $phpbb_root_path, $phpEx, $phpbb_container;
|
||||
global $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_log;
|
||||
|
||||
$user->add_lang('acp/common');
|
||||
|
||||
@ -121,9 +121,15 @@ class mcp_logs
|
||||
}
|
||||
else if ($deleteall)
|
||||
{
|
||||
$where_sql = ($sort_days) ? 'AND log_time >= ' . (time() - ($sort_days * 86400)) : '';
|
||||
$keywords = utf8_normalize_nfc(request_var('keywords', '', true));
|
||||
$keywords_where = $phpbb_log->generate_sql_keyword($keywords, '');
|
||||
$where_sql .= ' ' . $keywords_where;
|
||||
|
||||
$sql = 'DELETE FROM ' . LOG_TABLE . '
|
||||
WHERE log_type = ' . LOG_MOD . '
|
||||
AND ' . $db->sql_in_set('forum_id', $forum_list);
|
||||
AND ' . $db->sql_in_set('forum_id', $forum_list) .
|
||||
$where_sql;
|
||||
|
||||
if ($mode == 'topic_logs')
|
||||
{
|
||||
|
@ -636,11 +636,12 @@ class log implements \phpbb\log\log_interface
|
||||
/**
|
||||
* Generates a sql condition for the specified keywords
|
||||
*
|
||||
* @param string $keywords The keywords the user specified to search for
|
||||
* @param string $keywords The keywords the user specified to search for
|
||||
* @param string $table_alias The alias of the logs' table ('l.' by default)
|
||||
*
|
||||
* @return string Returns the SQL condition searching for the keywords
|
||||
*/
|
||||
protected function generate_sql_keyword($keywords)
|
||||
public function generate_sql_keyword($keywords, $table_alias = 'l.')
|
||||
{
|
||||
// Use no preg_quote for $keywords because this would lead to sole
|
||||
// backslashes being added. We also use an OR connection here for
|
||||
@ -688,9 +689,9 @@ class log implements \phpbb\log\log_interface
|
||||
$sql_keywords = 'AND (';
|
||||
if (!empty($operations))
|
||||
{
|
||||
$sql_keywords .= $this->db->sql_in_set('l.log_operation', $operations) . ' OR ';
|
||||
$sql_keywords .= $this->db->sql_in_set($table_alias . 'log_operation', $operations) . ' OR ';
|
||||
}
|
||||
$sql_lower = $this->db->sql_lower_text('l.log_data');
|
||||
$sql_lower = $this->db->sql_lower_text($table_alias . 'log_data');
|
||||
$sql_keywords .= " $sql_lower " . implode(" OR $sql_lower ", $keywords) . ')';
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user