diff options
author | Tristan Darricau <github@nicofuma.fr> | 2014-05-28 00:54:22 +0200 |
---|---|---|
committer | Tristan Darricau <github@nicofuma.fr> | 2014-05-28 00:54:22 +0200 |
commit | 05e76e55e149936d112ccb3441f88bbd3ce235fb (patch) | |
tree | a7d8a00560422128da674df68d7cc301a0c66cc6 /phpBB/phpbb/log | |
parent | ac1eb2d789d81381fd2298c03a1960707e1c90c3 (diff) | |
download | forums-05e76e55e149936d112ccb3441f88bbd3ce235fb.tar forums-05e76e55e149936d112ccb3441f88bbd3ce235fb.tar.gz forums-05e76e55e149936d112ccb3441f88bbd3ce235fb.tar.bz2 forums-05e76e55e149936d112ccb3441f88bbd3ce235fb.tar.xz forums-05e76e55e149936d112ccb3441f88bbd3ce235fb.zip |
[ticket/10899] Add unit tests
PHPBB3-10899
Diffstat (limited to 'phpBB/phpbb/log')
-rw-r--r-- | phpBB/phpbb/log/log.php | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 4b1a8e40ad..8b51ed7758 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -334,19 +334,41 @@ class log implements \phpbb\log\log_interface */ public function delete($mode, $conditions = array()) { - $sql_where = ''; - $started = false; + switch ($mode) + { + case 'admin': + $log_type = LOG_ADMIN; + break; + + case 'mod': + $log_type = LOG_MOD; + break; + + case 'user': + $log_type = LOG_USERS; + break; + + case 'users': + $log_type = LOG_USERS; + break; + + case 'critical': + $log_type = LOG_CRITICAL;; + break; + + default: + $log_type = false; + } + + if ($log_type === false) + { + return; + } + + $sql_where = 'WHERE log_type = ' . $log_type; foreach ($conditions as $field => $field_value) { - if ($started) - { - $sql_where .= ' AND '; - } - else - { - $sql_where = 'WHERE '; - $started = true; - } + $sql_where .= ' AND '; if ($field == 'keywords') { @@ -354,11 +376,11 @@ class log implements \phpbb\log\log_interface } else { - if (is_array($field_value) && sizeof($field_value) == 2) + if (is_array($field_value) && sizeof($field_value) == 2 && is_string($field_value[0])) { $sql_where .= $field . ' ' . $field_value[0] . ' ' . $field_value[1]; } - else if (is_array($field_value) && sizeof($field_value) > 2) + else if (is_array($field_value)) { $sql_where .= $this->db->sql_in_set($field, $field_value); } @@ -366,7 +388,6 @@ class log implements \phpbb\log\log_interface { $sql_where .= $field . ' = ' . $field_value; } - } } |