diff --git a/phpBB/config/default/container/services_ban.yml b/phpBB/config/default/container/services_ban.yml index e9665f745f..dfb93cfd39 100644 --- a/phpBB/config/default/container/services_ban.yml +++ b/phpBB/config/default/container/services_ban.yml @@ -6,6 +6,7 @@ services: - '@ban.type_collection' - '@cache' - '@dbal.conn' + - '@user' - '%tables.bans%' - '%tables.users%' diff --git a/phpBB/phpbb/ban/manager.php b/phpBB/phpbb/ban/manager.php index 1a2d5184a2..4dcb3ca397 100644 --- a/phpBB/phpbb/ban/manager.php +++ b/phpBB/phpbb/ban/manager.php @@ -49,15 +49,17 @@ class manager * @param \phpbb\di\service_collection $types A service collection containing all ban types * @param \phpbb\cache\service $cache A cache object * @param \phpbb\db\driver\driver_interface $db A phpBB DBAL object + * @param \phpbb\user $user User object * @param string $bans_table The bans table * @param string $users_table The users table */ - public function __construct($types, \phpbb\cache\service $cache, \phpbb\db\driver\driver_interface $db, $bans_table, $users_table = '') + public function __construct($types, \phpbb\cache\service $cache, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $bans_table, $users_table = '') { $this->bans_table = $bans_table; $this->cache = $cache; $this->db = $db; $this->types = $types; + $this->user = $user; $this->users_table = $users_table; } @@ -264,7 +266,7 @@ class manager * * @return array|bool */ - public function get_bans($mode) + public function get_bans(string $mode) { /** @var type_interface $ban_mode */ $ban_mode = $this->find_type($mode); @@ -370,7 +372,15 @@ class manager }); } - public function get_ban_end(\phpbb\user $user, \DateTimeInterface $ban_start, $length, $end_date): \DateTimeInterface + /** + * Get ban end + * + * @param \DateTimeInterface $ban_start + * @param int $length + * @param string $end_date + * @return \DateTimeInterface + */ + public function get_ban_end(\DateTimeInterface $ban_start, int $length, string $end_date): \DateTimeInterface { $current_time = $ban_start->getTimestamp(); $end_time = 0; @@ -387,7 +397,7 @@ class manager { $end_time = max( $current_time, - \DateTime::createFromFormat('Y-m-d', $end_date, $user->timezone)->getTimestamp() + \DateTime::createFromFormat('Y-m-d', $end_date, $this->user->timezone)->getTimestamp() ); } else @@ -403,16 +413,6 @@ class manager return $ban_end; } - /** - * Sets the current user to exclude from banning - * - * @param \phpbb\user $user An user object - */ - public function set_user(\phpbb\user $user) - { - $this->user = $user; - } - /** * Cleans up the database of e.g. stale bans */