[ticket/12692] Fix coding style

PHPBB3-12692
[ticket/12692] Update comments

PHPBB3-12692
[ticket/12692] Remove a not and swap the blocks in the corresponding if

PHPBB3-12692
[ticket/12692] Cast the ids to int

PHPBB3-12692
[ticket/12692] Update the database regularly

PHPBB3-12692