mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/17414] Replace confirm types with enum
PHPBB-17414
This commit is contained in:
parent
589fe70be6
commit
48454308ae
8 changed files with 36 additions and 19 deletions
|
@ -152,13 +152,13 @@ define('FULL_FOLDER_DELETE', -2);
|
||||||
define('FULL_FOLDER_HOLD', -1);
|
define('FULL_FOLDER_HOLD', -1);
|
||||||
|
|
||||||
// Confirm types
|
// Confirm types
|
||||||
/** @deprecated 4.0.0-a1 Replaced by \phpbb\captcha\plugins\plugin_interface::CONFIRM_REGISTRATION, to be removed in 5.0.0-a1 */
|
/** @deprecated 4.0.0-a1 Replaced by \phpbb\captcha\plugins\confirm_type::REGISTRATION, to be removed in 5.0.0-a1 */
|
||||||
define('CONFIRM_REG', 1);
|
define('CONFIRM_REG', 1);
|
||||||
/** @deprecated 4.0.0-a1 Replaced by \phpbb\captcha\plugins\plugin_interface::CONFIRM_LOGIN, to be removed in 5.0.0-a1 */
|
/** @deprecated 4.0.0-a1 Replaced by \phpbb\captcha\plugins\confirm_type::LOGIN, to be removed in 5.0.0-a1 */
|
||||||
define('CONFIRM_LOGIN', 2);
|
define('CONFIRM_LOGIN', 2);
|
||||||
/** @deprecated 4.0.0-a1 Replaced by \phpbb\captcha\plugins\plugin_interface::CONFIRM_POST, to be removed in 5.0.0-a1 */
|
/** @deprecated 4.0.0-a1 Replaced by \phpbb\captcha\plugins\confirm_type::POST, to be removed in 5.0.0-a1 */
|
||||||
define('CONFIRM_POST', 3);
|
define('CONFIRM_POST', 3);
|
||||||
/** @deprecated 4.0.0-a1 Replaced by \phpbb\captcha\plugins\plugin_interface::CONFIRM_REPORT, to be removed in 5.0.0-a1 */
|
/** @deprecated 4.0.0-a1 Replaced by \phpbb\captcha\plugins\confirm_type::REPORT, to be removed in 5.0.0-a1 */
|
||||||
define('CONFIRM_REPORT', 4);
|
define('CONFIRM_REPORT', 4);
|
||||||
|
|
||||||
// Categories - Attachments
|
// Categories - Attachments
|
||||||
|
|
|
@ -238,7 +238,7 @@ class ucp_register
|
||||||
/** @var \phpbb\captcha\factory $captcha_factory */
|
/** @var \phpbb\captcha\factory $captcha_factory */
|
||||||
$captcha_factory = $phpbb_container->get('captcha.factory');
|
$captcha_factory = $phpbb_container->get('captcha.factory');
|
||||||
$captcha = $captcha_factory->get_instance($config['captcha_plugin']);
|
$captcha = $captcha_factory->get_instance($config['captcha_plugin']);
|
||||||
$captcha->init(\phpbb\captcha\plugins\plugin_interface::CONFIRM_REGISTRATION);
|
$captcha->init(\phpbb\captcha\plugins\confirm_type::REGISTRATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
$timezone = $config['board_timezone'];
|
$timezone = $config['board_timezone'];
|
||||||
|
|
|
@ -176,7 +176,7 @@ class db extends base
|
||||||
// Every auth module is able to define what to do by itself...
|
// Every auth module is able to define what to do by itself...
|
||||||
if ($show_captcha)
|
if ($show_captcha)
|
||||||
{
|
{
|
||||||
$captcha->init(\phpbb\captcha\plugins\plugin_interface::CONFIRM_LOGIN);
|
$captcha->init(\phpbb\captcha\plugins\confirm_type::LOGIN);
|
||||||
if ($captcha->validate() !== true)
|
if ($captcha->validate() !== true)
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
|
24
phpBB/phpbb/captcha/plugins/confirm_type.php
Normal file
24
phpBB/phpbb/captcha/plugins/confirm_type.php
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\captcha\plugins;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirmation types for CAPTCHA plugins
|
||||||
|
*/
|
||||||
|
enum confirm_type: int {
|
||||||
|
case REGISTRATION = 1;
|
||||||
|
case LOGIN = 2;
|
||||||
|
case POST = 3;
|
||||||
|
case REPORT = 4;
|
||||||
|
}
|
|
@ -15,14 +15,6 @@ namespace phpbb\captcha\plugins;
|
||||||
|
|
||||||
interface plugin_interface
|
interface plugin_interface
|
||||||
{
|
{
|
||||||
const CONFIRM_REGISTRATION = 1;
|
|
||||||
const CONFIRM_LOGIN = 2;
|
|
||||||
|
|
||||||
const CONFIRM_POST = 3;
|
|
||||||
|
|
||||||
const CONFIRM_REPORT = 4;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the plugin is available
|
* Check if the plugin is available
|
||||||
*
|
*
|
||||||
|
@ -54,10 +46,10 @@ interface plugin_interface
|
||||||
/**
|
/**
|
||||||
* Display the captcha for the specified type
|
* Display the captcha for the specified type
|
||||||
*
|
*
|
||||||
* @param int $type Type of captcha, should be one of the CONFIRMATION_* constants
|
* @param confirm_type $type Type of captcha, should be one of the CONFIRMATION_* constants
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function init(int $type): void;
|
public function init(confirm_type $type): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get hidden form fields for this captcha plugin
|
* Get hidden form fields for this captcha plugin
|
||||||
|
|
|
@ -121,7 +121,7 @@ class turnstile extends base
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function init(int $type): void
|
public function init(confirm_type $type): void
|
||||||
{
|
{
|
||||||
$this->language->add_lang('captcha_turnstile');
|
$this->language->add_lang('captcha_turnstile');
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
namespace phpbb\report\controller;
|
namespace phpbb\report\controller;
|
||||||
|
|
||||||
|
use phpbb\captcha\plugins\confirm_type;
|
||||||
use phpbb\captcha\plugins\plugin_interface;
|
use phpbb\captcha\plugins\plugin_interface;
|
||||||
use phpbb\exception\http_exception;
|
use phpbb\exception\http_exception;
|
||||||
use phpbb\report\report_handler_interface;
|
use phpbb\report\report_handler_interface;
|
||||||
|
@ -132,7 +133,7 @@ class report
|
||||||
if ($this->config['enable_post_confirm'] && !$this->user->data['is_registered'])
|
if ($this->config['enable_post_confirm'] && !$this->user->data['is_registered'])
|
||||||
{
|
{
|
||||||
$captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']);
|
$captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']);
|
||||||
$captcha->init(plugin_interface::CONFIRM_REPORT);
|
$captcha->init(confirm_type::REPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Has the report been cancelled?
|
//Has the report been cancelled?
|
||||||
|
|
|
@ -458,7 +458,7 @@ if ($config['enable_post_confirm'] && !$user->data['is_registered'])
|
||||||
/** @var \phpbb\captcha\factory $captcha_factory */
|
/** @var \phpbb\captcha\factory $captcha_factory */
|
||||||
$captcha_factory = $phpbb_container->get('captcha.factory');
|
$captcha_factory = $phpbb_container->get('captcha.factory');
|
||||||
$captcha = $captcha_factory->get_instance($config['captcha_plugin']);
|
$captcha = $captcha_factory->get_instance($config['captcha_plugin']);
|
||||||
$captcha->init(\phpbb\captcha\plugins\plugin_interface::CONFIRM_POST);
|
$captcha->init(\phpbb\captcha\plugins\confirm_type::POST);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the user able to post within this forum?
|
// Is the user able to post within this forum?
|
||||||
|
|
Loading…
Add table
Reference in a new issue