1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-23 18:11:47 +02:00

Merge branch 'develop' into ticket/11215

* develop: (53 commits)
  [ticket/11671] Update composer.lock
  [ticket/11671] Update composer.lock
  [ticket/11671] Add phing as a dependency and upgrade deps
  [ticket/11668] Move lint test to the end for travis
  [ticket/11626] Remove last reference to template in ldap
  [ticket/11626] Remove LDAP dependency on template
  [develop-olympus] Increment version number to 3.0.13-dev.
  [develop-olympus] Add changelog for 3.0.12 release.
  [develop-olympus] Bump version numbers for 3.0.12-RC1 release.
  [develop-olympus] Bumping version numbers to final for 3.0.12 releases.
  [ticket/11669] Fix PHP bug #55124 (recursive mkdir on /./)
  [ticket/11668] Run lint test at the end of the test suite
  [ticket/11548] Fix test errors in groups test on develop
  [ticket/11548] Check upload avatar URL the same way as in phpBB 3.0
  [ticket/11548] Fix incorrect usage of array_map on acp groups page
  [ticket/11665] Fix test class name
  [ticket/11664] Stop creating php.html file in root path in tests
  [ticket/11665] Can't change file names already sent to set_filenames
  [ticket/11662] Typos: occured -> occurred
  [ticket/11662] Typos: occured -> occurred
  ...
This commit is contained in:
David King
2013-07-13 11:33:49 -04:00
45 changed files with 970 additions and 304 deletions

View File

@@ -528,10 +528,10 @@ class acp_board
$old_auth_config = array();
foreach ($auth_providers as $provider)
{
if ($fields = $provider->acp($this->new_config))
if ($fields = $provider->acp())
{
// 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 as $field)
{
if (!isset($config[$field]))
{
@@ -655,15 +655,14 @@ class acp_board
foreach ($auth_providers as $provider)
{
$fields = $provider->acp($this->new_config);
if ($fields['tpl'])
$auth_tpl = $provider->get_acp_template($this->new_config);
if ($auth_tpl)
{
$template->assign_vars($auth_tpl['TEMPLATE_VARS']);
$template->assign_block_vars('auth_tpl', array(
'TPL' => $fields['tpl'],
'TEMPLATE_FILE' => $auth_tpl['TEMPLATE_FILE'],
));
}
unset($fields);
}
}
}
@@ -678,8 +677,12 @@ class acp_board
$auth_plugins = array();
$auth_providers = $phpbb_container->get('auth.provider_collection');
foreach($auth_providers as $key => $value)
foreach ($auth_providers as $key => $value)
{
if (!($value instanceof phpbb_auth_provider_interface))
{
continue;
}
$auth_plugins[] = str_replace('auth.provider.', '', $key);
}

View File

@@ -410,7 +410,7 @@ class acp_groups
if ($validation_error = validate_data($submit_ary, $validation_checks))
{
// Replace "error" string with its real, localised form
$error = array_merge($error, array_map(array(&$user, 'lang'), $validation_error));
$error = array_merge($error, $validation_error);
}
if (!sizeof($error))
@@ -507,6 +507,7 @@ class acp_groups
if (sizeof($error))
{
$error = array_map(array(&$user, 'lang'), $error);
$group_rank = $submit_ary['rank'];
$group_desc_data = array(

View File

@@ -20,7 +20,7 @@ if (!defined('IN_PHPBB'))
*
* @package auth
*/
class phpbb_auth_provider_apache implements phpbb_auth_provider_interface
class phpbb_auth_provider_apache extends phpbb_auth_provider_base
{
/**
* Apache Authentication Constructor
@@ -256,20 +256,4 @@ class phpbb_auth_provider_apache implements phpbb_auth_provider_interface
return false;
}
/**
* {@inheritdoc}
*/
public function acp($new)
{
return;
}
/**
* {@inheritdoc}
*/
public function logout($data, $new_session)
{
return;
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
*
* @package auth
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Base authentication provider class that all other providers should implement
*
* @package auth
*/
abstract class phpbb_auth_provider_base implements phpbb_auth_provider_interface
{
/**
* {@inheritdoc}
*/
public function init()
{
return;
}
/**
* {@inheritdoc}
*/
public function autologin()
{
return;
}
/**
* {@inheritdoc}
*/
public function acp()
{
return;
}
/**
* {@inheritdoc}
*/
public function get_acp_template($new_config)
{
return;
}
/**
* {@inheritdoc}
*/
public function logout($data, $new_session)
{
return;
}
/**
* {@inheritdoc}
*/
public function validate_session($user)
{
return;
}
}

View File

@@ -22,7 +22,7 @@ if (!defined('IN_PHPBB'))
*
* @package auth
*/
class phpbb_auth_provider_db implements phpbb_auth_provider_interface
class phpbb_auth_provider_db extends phpbb_auth_provider_base
{
/**
@@ -45,14 +45,6 @@ class phpbb_auth_provider_db implements phpbb_auth_provider_interface
$this->php_ext = $php_ext;
}
/**
* {@inheritdoc}
*/
public function init()
{
return;
}
/**
* {@inheritdoc}
*/
@@ -302,36 +294,4 @@ class phpbb_auth_provider_db implements phpbb_auth_provider_interface
'user_row' => $row,
);
}
/**
* {@inheritdoc}
*/
public function autologin()
{
return;
}
/**
* {@inheritdoc}
*/
public function acp($new)
{
return;
}
/**
* {@inheritdoc}
*/
public function logout($data, $new_session)
{
return;
}
/**
* {@inheritdoc}
*/
public function validate_session($user)
{
return;
}
}

View File

@@ -60,16 +60,28 @@ interface phpbb_auth_provider_interface
* This function is used to output any required fields in the authentication
* admin panel. It also defines any required configuration table fields.
*
* @param array $new Contains the new configuration values that have
* been set in acp_board.
* @return array|null Returns null if not implemented or an array of the
* form:
* configuration fields of the provider.
*/
public function acp();
/**
* This function updates the template with variables related to the acp
* options with whatever configuraton values are passed to it as an array.
* It then returns the name of the acp file related to this authentication
* provider.
* @param array $new_config Contains the new configuration values that
* have been set in acp_board.
* @return array|null Returns null if not implemented or an array with
* the template file name and an array of the vars
* that the template needs that must conform to the
* following example:
* array(
* 'tpl' => string
* 'config' => array
* 'TEMPLATE_FILE' => string,
* 'TEMPLATE_VARS' => array(...),
* )
*/
public function acp($new);
public function get_acp_template($new_config);
/**
* Performs additional actions during logout.

View File

@@ -22,7 +22,7 @@ if (!defined('IN_PHPBB'))
*
* @package auth
*/
class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface
class phpbb_auth_provider_ldap extends phpbb_auth_provider_base
{
/**
* LDAP Authentication Constructor
@@ -286,56 +286,32 @@ class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface
/**
* {@inheritdoc}
*/
public function autologin()
public function acp()
{
return;
// These are fields required in the config table
return array(
'ldap_server', 'ldap_port', 'ldap_base_dn', 'ldap_uid', 'ldap_user_filter', 'ldap_email', 'ldap_user', 'ldap_password',
);
}
/**
* {@inheritdoc}
*/
public function acp($new)
public function get_acp_template($new_config)
{
$tpl = '
<dl>
<dt><label for="ldap_server">' . $this->user->lang['LDAP_SERVER'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_SERVER_EXPLAIN'] . '</span></dt>
<dd><input type="text" id="ldap_server" size="40" name="config[ldap_server]" value="' . $new['ldap_server'] . '" /></dd>
</dl>
<dl>
<dt><label for="ldap_port">' . $this->user->lang['LDAP_PORT'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_PORT_EXPLAIN'] . '</span></dt>
<dd><input type="text" id="ldap_port" size="40" name="config[ldap_port]" value="' . $new['ldap_port'] . '" /></dd>
</dl>
<dl>
<dt><label for="ldap_dn">' . $this->user->lang['LDAP_DN'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_DN_EXPLAIN'] . '</span></dt>
<dd><input type="text" id="ldap_dn" size="40" name="config[ldap_base_dn]" value="' . $new['ldap_base_dn'] . '" /></dd>
</dl>
<dl>
<dt><label for="ldap_uid">' . $this->user->lang['LDAP_UID'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_UID_EXPLAIN'] . '</span></dt>
<dd><input type="text" id="ldap_uid" size="40" name="config[ldap_uid]" value="' . $new['ldap_uid'] . '" /></dd>
</dl>
<dl>
<dt><label for="ldap_user_filter">' . $this->user->lang['LDAP_USER_FILTER'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_USER_FILTER_EXPLAIN'] . '</span></dt>
<dd><input type="text" id="ldap_user_filter" size="40" name="config[ldap_user_filter]" value="' . $new['ldap_user_filter'] . '" /></dd>
</dl>
<dl>
<dt><label for="ldap_email">' . $this->user->lang['LDAP_EMAIL'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_EMAIL_EXPLAIN'] . '</span></dt>
<dd><input type="email" id="ldap_email" size="40" name="config[ldap_email]" value="' . $new['ldap_email'] . '" /></dd>
</dl>
<dl>
<dt><label for="ldap_user">' . $this->user->lang['LDAP_USER'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_USER_EXPLAIN'] . '</span></dt>
<dd><input type="text" id="ldap_user" size="40" name="config[ldap_user]" value="' . $new['ldap_user'] . '" /></dd>
</dl>
<dl>
<dt><label for="ldap_password">' . $this->user->lang['LDAP_PASSWORD'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['LDAP_PASSWORD_EXPLAIN'] . '</span></dt>
<dd><input type="password" id="ldap_password" size="40" name="config[ldap_password]" value="' . $new['ldap_password'] . '" autocomplete="off" /></dd>
</dl>
';
// These are fields required in the config table
return array(
'tpl' => $tpl,
'config' => array('ldap_server', 'ldap_port', 'ldap_base_dn', 'ldap_uid', 'ldap_user_filter', 'ldap_email', 'ldap_user', 'ldap_password')
'TEMPLATE_FILE' => 'auth_provider_ldap.html',
'TEMPLATE_VARS' => array(
'AUTH_LDAP_DN' => $new_config['ldap_base_dn'],
'AUTH_LDAP_EMAIL' => $new_config['ldap_email'],
'AUTH_LDAP_PASSORD' => $new_config['ldap_password'],
'AUTH_LDAP_PORT' => $new_config['ldap_port'],
'AUTH_LDAP_SERVER' => $new_config['ldap_server'],
'AUTH_LDAP_UID' => $new_config['ldap_uid'],
'AUTH_LDAP_USER' => $new_config['ldap_user'],
'AUTH_LDAP_USER_FILTER' => $new_config['ldap_user_filter'],
),
);
}
@@ -367,20 +343,4 @@ class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface
{
return str_replace(array('*', '\\', '(', ')'), array('\\*', '\\\\', '\\(', '\\)'), $string);
}
/**
* {@inheritdoc}
*/
public function logout($data, $new_session)
{
return;
}
/**
* {@inheritdoc}
*/
public function validate_session($user)
{
return;
}
}

View File

@@ -77,6 +77,32 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver
}
elseif (!empty($this->config['allow_avatar_remote_upload']) && !empty($url))
{
if (!preg_match('#^(http|https|ftp)://#i', $url))
{
$url = 'http://' . $url;
}
if (!function_exists('validate_data'))
{
require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
}
$validate_array = validate_data(
array(
'url' => $url,
),
array(
'url' => array('string', true, 5, 255),
)
);
$error = array_merge($error, $validate_array);
if (!empty($error))
{
return false;
}
$file = $upload->remote_upload($url);
}
else

View File

@@ -27,8 +27,8 @@ class phpbb_db_migration_data_30x_3_0_9_rc1 extends phpbb_db_migration
'COLUMNS' => array(
// this column was removed from the database updater
// after 3.0.9-RC3 was released. It might still exist
// in 3.0.9-RCX installations and has to be dropped in
// 3.0.12 after the db_tools class is capable of properly
// in 3.0.9-RCX installations and has to be dropped as
// soon as the db_tools class is capable of properly
// removing a primary key.
// 'attempt_id' => array('UINT', NULL, 'auto_increment'),
'attempt_ip' => array('VCHAR:40', ''),

View File

@@ -0,0 +1,118 @@
<?php
/**
*
* @package migration
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
class phpbb_db_migration_data_310_notification_options_reconvert extends phpbb_db_migration
{
static public function depends_on()
{
return array('phpbb_db_migration_data_310_notifications_schema_fix');
}
public function update_data()
{
return array(
array('custom', array(array($this, 'convert_notifications'))),
);
}
public function convert_notifications()
{
$insert_table = $this->table_prefix . 'user_notifications';
$insert_buffer = new phpbb_db_sql_insert_buffer($this->db, $insert_table);
$this->perform_conversion($insert_buffer, $insert_table);
}
/**
* Perform the conversion (separate for testability)
*
* @param phpbb_db_sql_insert_buffer $insert_buffer
* @param string $insert_table
*/
public function perform_conversion(phpbb_db_sql_insert_buffer $insert_buffer, $insert_table)
{
$sql = 'DELETE FROM ' . $insert_table;
$this->db->sql_query($sql);
$sql = 'SELECT user_id, user_notify_type, user_notify_pm
FROM ' . USERS_TABLE;
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$notification_methods = array();
// In-board notification
$notification_methods[] = '';
if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH)
{
$notification_methods[] = 'email';
}
if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH)
{
$notification_methods[] = 'jabber';
}
// Notifications for posts
foreach (array('post', 'topic') as $item_type)
{
$this->add_method_rows(
$insert_buffer,
$item_type,
0,
$row['user_id'],
$notification_methods
);
}
if ($row['user_notify_pm'])
{
// Notifications for private messages
// User either gets all methods or no method
$this->add_method_rows(
$insert_buffer,
'pm',
0,
$row['user_id'],
$notification_methods
);
}
}
$this->db->sql_freeresult($result);
$insert_buffer->flush();
}
/**
* Insert method rows to DB
*
* @param phpbb_db_sql_insert_buffer $insert_buffer
* @param string $item_type
* @param int $item_id
* @param int $user_id
* @param string $methods
*/
protected function add_method_rows(phpbb_db_sql_insert_buffer $insert_buffer, $item_type, $item_id, $user_id, array $methods)
{
$row_base = array(
'item_type' => $item_type,
'item_id' => (int) $item_id,
'user_id' => (int) $user_id,
'notify' => 1
);
foreach ($methods as $method)
{
$row_base['method'] = $method;
$insert_buffer->insert($row_base);
}
}
}

View File

@@ -91,70 +91,6 @@ class phpbb_db_migration_data_310_notifications extends phpbb_db_migration
),
)),
array('config.add', array('load_notifications', 1)),
array('custom', array(array($this, 'convert_notifications'))),
);
}
public function convert_notifications()
{
$convert_notifications = array(
array(
'check' => ($this->config['allow_topic_notify']),
'item_type' => 'post',
),
array(
'check' => ($this->config['allow_forum_notify']),
'item_type' => 'topic',
),
array(
'check' => ($this->config['allow_bookmarks']),
'item_type' => 'bookmark',
),
array(
'check' => ($this->config['allow_privmsg']),
'item_type' => 'pm',
),
);
foreach ($convert_notifications as $convert_data)
{
if ($convert_data['check'])
{
$sql = 'SELECT user_id, user_notify_type
FROM ' . USERS_TABLE . '
WHERE user_notify = 1';
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array(
'item_type' => $convert_data['item_type'],
'item_id' => 0,
'user_id' => $row['user_id'],
'method' => '',
)));
if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH)
{
$this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array(
'item_type' => $convert_data['item_type'],
'item_id' => 0,
'user_id' => $row['user_id'],
'method' => 'email',
)));
}
if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH)
{
$this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array(
'item_type' => $convert_data['item_type'],
'item_id' => 0,
'user_id' => $row['user_id'],
'method' => 'jabber',
)));
}
}
$this->db->sql_freeresult($result);
}
}
}
}

View File

@@ -44,7 +44,7 @@ abstract class phpbb_db_migration
/** @var string */
protected $php_ext;
/** @var array Errors, if any occured */
/** @var array Errors, if any occurred */
protected $errors;
/** @var array List of queries executed through $this->sql_query() */

View File

@@ -33,7 +33,10 @@ function phpbb_bootstrap_db_connection($config_file)
require($config_file);
$dbal_driver_class = phpbb_convert_30_dbms_to_31($dbms);
return new $dbal_driver_class($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, defined('PHPBB_DB_NEW_LINK'));
$db = new $dbal_driver_class();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, defined('PHPBB_DB_NEW_LINK'));
return $db;
}
/**
@@ -56,9 +59,10 @@ function phpbb_bootstrap_table_prefix($config_file)
* Used to bootstrap the container.
*
* @param string $config_file
* @param string $phpbb_root_path
* @return array enabled extensions
*/
function phpbb_bootstrap_enabled_exts($config_file)
function phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path)
{
$db = phpbb_bootstrap_db_connection($config_file);
$table_prefix = phpbb_bootstrap_table_prefix($config_file);
@@ -142,7 +146,7 @@ function phpbb_create_install_container($phpbb_root_path, $php_ext)
*/
function phpbb_create_compiled_container($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext)
{
$installed_exts = phpbb_bootstrap_enabled_exts($config_file);
$installed_exts = phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path);
// Now pass the enabled extension paths into the ext compiler extension
$extensions[] = new phpbb_di_extension_ext($installed_exts);
@@ -179,7 +183,7 @@ function phpbb_create_dumped_container($config_file, array $extensions, array $p
return new phpbb_cache_container();
}
$container = phpbb_create_compiled_container($extensions, $passes, $phpbb_root_path, $php_ext);
$container = phpbb_create_compiled_container($config_file, $extensions, $passes, $phpbb_root_path, $php_ext);
// Lastly, we create our cached container class
$dumper = new PhpDumper($container);
@@ -212,7 +216,7 @@ function phpbb_create_dumped_container($config_file, array $extensions, array $p
function phpbb_create_dumped_container_unless_debug($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext)
{
$container_factory = defined('DEBUG') ? 'phpbb_create_compiled_container' : 'phpbb_create_dumped_container';
return $container_factory($extensions, $passes, $phpbb_root_path, $php_ext);
return $container_factory($config_file, $extensions, $passes, $phpbb_root_path, $php_ext);
}
/**

View File

@@ -249,7 +249,7 @@ class jabber
return true;
}
// Apparently an error occured...
// Apparently an error occurred...
$this->add_to_log('Error: open_socket() - ' . $errorstr);
return false;
}

View File

@@ -140,7 +140,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
/**
* Checks for correct MySQL version and stores min/max word length in the config
*
* @return string|bool Language key of the error/incompatiblity occured
* @return string|bool Language key of the error/incompatiblity occurred
*/
public function init()
{

View File

@@ -185,7 +185,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
/**
* Checks for correct PostgreSQL version and stores min/max word length in the config
*
* @return string|bool Language key of the error/incompatiblity occured
* @return string|bool Language key of the error/incompatiblity occurred
*/
public function init()
{

View File

@@ -404,6 +404,12 @@ class phpbb_session
$method = basename(trim($config['auth_method']));
$provider = $phpbb_container->get('auth.provider.' . $method);
if (!($provider instanceof phpbb_auth_provider_interface))
{
throw new \RuntimeException($provider . ' must implement phpbb_auth_provider_interface');
}
$ret = $provider->validate_session($this->data);
if ($ret !== null && !$ret)
{

View File

@@ -172,7 +172,7 @@ class phpbb_template_twig implements phpbb_template
*/
public function set_filenames(array $filename_array)
{
$this->filenames = array_merge($filename_array, $this->filenames);
$this->filenames = array_merge($this->filenames, $filename_array);
return $this;
}