mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-18 21:39:52 +02:00
[feature/auth-refactor] Refactor acp_board for new auth interface
Partially refactors acp_board for the new authentication interface. Leaves some questionable if statements in the file. Modifies the interface to correctly impletment the acp() method. Modifies each provider to comply with the above mentioned interface modification. PHPBB3-9734
This commit is contained in:
parent
553c300688
commit
2445766b92
@ -530,9 +530,9 @@ class acp_board
|
|||||||
{
|
{
|
||||||
while (($file = readdir($dp)) !== false)
|
while (($file = readdir($dp)) !== false)
|
||||||
{
|
{
|
||||||
if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
|
if (preg_match('#^provider_(.*?)\.' . $phpEx . '$#', $file) && !preg_match('#^provider_interface\.' . $phpEx . '$#', $file))
|
||||||
{
|
{
|
||||||
$auth_plugins[] = basename(preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file));
|
$auth_plugins[] = basename(preg_replace('#^provider_(.*?)\.' . $phpEx . '$#', '\1', $file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($dp);
|
closedir($dp);
|
||||||
@ -544,14 +544,13 @@ class acp_board
|
|||||||
$old_auth_config = array();
|
$old_auth_config = array();
|
||||||
foreach ($auth_plugins as $method)
|
foreach ($auth_plugins as $method)
|
||||||
{
|
{
|
||||||
if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
|
if ($method)
|
||||||
{
|
{
|
||||||
include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);
|
$class = 'phpbb_auth_provider_' . $method;
|
||||||
|
if (class_exists($class))
|
||||||
$method = 'acp_' . $method;
|
|
||||||
if (function_exists($method))
|
|
||||||
{
|
{
|
||||||
if ($fields = $method($this->new_config))
|
$provider = new $class();
|
||||||
|
if ($fields = $provider->acp($this->new_config))
|
||||||
{
|
{
|
||||||
// Check if we need to create config fields for this plugin and save config when submit was pressed
|
// Check if we need to create config fields for this plugin and save config when submit was pressed
|
||||||
foreach ($fields['config'] as $field)
|
foreach ($fields['config'] as $field)
|
||||||
@ -585,14 +584,13 @@ class acp_board
|
|||||||
if ($submit && (($cfg_array['auth_method'] != $this->new_config['auth_method']) || $updated_auth_settings))
|
if ($submit && (($cfg_array['auth_method'] != $this->new_config['auth_method']) || $updated_auth_settings))
|
||||||
{
|
{
|
||||||
$method = basename($cfg_array['auth_method']);
|
$method = basename($cfg_array['auth_method']);
|
||||||
if ($method && in_array($method, $auth_plugins))
|
if ($method)
|
||||||
{
|
{
|
||||||
include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);
|
$class = 'phpbb_auth_provider_' . $method;
|
||||||
|
if (class_exists($class))
|
||||||
$method = 'init_' . $method;
|
|
||||||
if (function_exists($method))
|
|
||||||
{
|
{
|
||||||
if ($error = $method())
|
$provider = new $class();
|
||||||
|
if ($error = $provider->init())
|
||||||
{
|
{
|
||||||
foreach ($old_auth_config as $config_name => $config_value)
|
foreach ($old_auth_config as $config_name => $config_value)
|
||||||
{
|
{
|
||||||
@ -685,12 +683,13 @@ class acp_board
|
|||||||
|
|
||||||
foreach ($auth_plugins as $method)
|
foreach ($auth_plugins as $method)
|
||||||
{
|
{
|
||||||
if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
|
if ($method)
|
||||||
{
|
{
|
||||||
$method = 'acp_' . $method;
|
$class = 'phpbb_auth_provider_' . $method;
|
||||||
if (function_exists($method))
|
if (class_exists($class))
|
||||||
{
|
{
|
||||||
$fields = $method($this->new_config);
|
$provider = new $class();
|
||||||
|
$fields = $provider->acp($this->new_config);
|
||||||
|
|
||||||
if ($fields['tpl'])
|
if ($fields['tpl'])
|
||||||
{
|
{
|
||||||
|
@ -258,7 +258,7 @@ class phpbb_auth_provider_apache implements phpbb_auth_provider_interface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function acp()
|
public function acp($new)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ class phpbb_auth_provider_db implements phpbb_auth_provider_interface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function acp()
|
public function acp($new)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -58,5 +58,5 @@ interface phpbb_auth_provider_interface
|
|||||||
* This function is used to output any required fields in the authentication
|
* This function is used to output any required fields in the authentication
|
||||||
* admin panel. It also defines any required configuration table fields.
|
* admin panel. It also defines any required configuration table fields.
|
||||||
*/
|
*/
|
||||||
public function acp();
|
public function acp($new);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ if (!defined('IN_PHPBB'))
|
|||||||
*
|
*
|
||||||
* @package auth
|
* @package auth
|
||||||
*/
|
*/
|
||||||
class phpbb_auth_provider_db implements phpbb_auth_provider_interface
|
class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Connect to ldap server
|
* Connect to ldap server
|
||||||
@ -284,7 +284,7 @@ class phpbb_auth_provider_db implements phpbb_auth_provider_interface
|
|||||||
* This function is used to output any required fields in the authentication
|
* This function is used to output any required fields in the authentication
|
||||||
* admin panel. It also defines any required configuration table fields.
|
* admin panel. It also defines any required configuration table fields.
|
||||||
*/
|
*/
|
||||||
public function acp(&$new)
|
public function acp($new)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user