Merge branch 'develop' of https://github.com/phpbb/phpbb3 into ticket/10714

* 'develop' of https://github.com/phpbb/phpbb3: (119 commits)
  [ticket/10986] message.id fallback to SERVER_NAME or phpbb.generated
  [ticket/11358] Changed the name of post parameter.
  [ticket/11358] Changed the action parameter value to represent the link.
  [ticket/11358] Enabled link making all users default for a group.
  [ticket/11358] Removed redundant code and referred proper variable.
  [ticket/11358] Success message even without selecting a user.
  [ticket/11355] Referred proper variable when validating selection.
  [ticket/11355] Wrong error message when no user is selected.
  [ticket/10896] Add missing email validation lost in develop merge
  [ticket/7262] Add note about set_config() not updating is_dynamic.
  [ticket/7262] Add $is_dynamic example to set_config() and set_config_count().
  [ticket/7262] Backport set_config() and set_config_count() docs from develop.
  [ticket/11122] Move rxu to 'Former Contributors' section.
  [ticket/11122] Add EXreaction to docs/AUTHORS.
  [ticket/11298] Fix typo in language key; EXTENSIONS -> EXTENSION
  [ticket/11361] Make sure that array passed to strtr() has the proper format.
  [ticket/11179] remove extra & in function call
  [ticket/11179] correct start parameter in sphinx search
  [ticket/11179] correct start parameter in native author search
  [ticket/11179] correct start parameter in native keyword search
  ...

Conflicts:
	phpBB/config/tables.yml
This commit is contained in:
Joas Schilling 2013-02-25 16:04:22 +01:00
commit c2974187e5
100 changed files with 4464 additions and 143 deletions

View file

@ -17,12 +17,14 @@ before_script:
- sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres; fi"
- sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'create database phpbb_tests;' -U postgres; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS phpbb_tests;'; fi"
- travis/install-php-extensions.sh
- pyrus set auto_discover 1
- pyrus install --force phpunit/DbUnit
- phpenv rehash
- cd phpBB
- php ../composer.phar install --dev
- cd ../
- cd ..
- sh -c "if [ `php -r "echo (int) version_compare(PHP_VERSION, '5.3.19', '>=');"` = "1" ]; then travis/setup-webserver.sh; fi"
script:
- phpunit --configuration travis/phpunit-$DB-travis.xml

View file

@ -7,7 +7,13 @@
<p>{L_EXTENSIONS_EXPLAIN}</p>
<p>{L_ENABLE_EXPLAIN}</p>
<!-- IF PRE -->
<!-- IF MIGRATOR_ERROR -->
<div class="errorbox">
<p><strong>{L_MIGRATION_EXCEPTION_ERROR}</strong></p>
<p>{MIGRATOR_ERROR}</p>
<p><a href="{U_RETURN}">{L_RETURN}</a></p>
</div>
<!-- ELSEIF PRE -->
<div class="errorbox">
<p>{L_ENABLE_CONFIRM}</p>
</div>

View file

@ -7,7 +7,13 @@
<p>{L_EXTENSIONS_EXPLAIN}</p>
<p>{L_PURGE_EXPLAIN}</p>
<!-- IF PRE -->
<!-- IF MIGRATOR_ERROR -->
<div class="errorbox">
<p><strong>{L_MIGRATION_EXCEPTION_ERROR}</strong></p>
<p>{MIGRATOR_ERROR}</p>
<p><a href="{U_RETURN}">{L_RETURN}</a></p>
</div>
<!-- ELSEIF PRE -->
<div class="errorbox">
<p>{L_PURGE_CONFIRM}</p>
</div>

View file

@ -10,6 +10,10 @@
<dt><label for="aim">{L_UCP_AIM}{L_COLON}</label></dt>
<dd><input type="text" id="aim" name="aim" value="{AIM}" /></dd>
</dl>
<dl>
<dt><label for="msn">{L_UCP_MSNM}{L_COLON}</label></dt>
<dd><input type="text" id="msn" name="msn" value="{MSN}" /></dd>
</dl>
<dl>
<dt><label for="yim">{L_UCP_YIM}{L_COLON}</label></dt>
<dd><input type="text" id="yim" name="yim" value="{YIM}" /></dd>

49
phpBB/config/migrator.yml Normal file
View file

@ -0,0 +1,49 @@
services:
migrator:
class: phpbb_db_migrator
arguments:
- @config
- @dbal.conn
- @dbal.tools
- %tables.migrations%
- %core.root_path%
- %core.php_ext%
- %core.table_prefix%
- @migrator.tool_collection
migrator.tool_collection:
class: phpbb_di_service_collection
arguments:
- @service_container
tags:
- { name: service_collection, tag: migrator.tool }
migrator.tool.config:
class: phpbb_db_migration_tool_config
arguments:
- @config
tags:
- { name: migrator.tool }
migrator.tool.module:
class: phpbb_db_migration_tool_module
arguments:
- @dbal.conn
- @cache
- @user
- %core.root_path%
- %core.php_ext%
- %tables.modules%
tags:
- { name: migrator.tool }
migrator.tool.permission:
class: phpbb_db_migration_tool_permission
arguments:
- @dbal.conn
- @cache
- @auth
- %core.root_path%
- %core.php_ext%
tags:
- { name: migrator.tool }

View file

@ -1,6 +1,7 @@
imports:
- { resource: tables.yml }
- { resource: cron_tasks.yml }
- { resource: migrator.yml }
services:
auth:
@ -94,6 +95,12 @@ services:
calls:
- [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]]
dbal.tools:
file: %core.root_path%includes/db/db_tools.%core.php_ext%
class: phpbb_db_tools
arguments:
- @dbal.conn
event.subscriber_loader:
class: phpbb_event_extension_subscriber_loader
arguments:
@ -105,8 +112,10 @@ services:
ext.manager:
class: phpbb_extension_manager
arguments:
- @service_container
- @dbal.conn
- @config
- @migrator
- %tables.ext%
- %core.root_path%
- .%core.php_ext%

View file

@ -2,3 +2,5 @@ parameters:
tables.config: %core.table_prefix%config
tables.ext: %core.table_prefix%ext
tables.log: %core.table_prefix%log
tables.migrations: %core.table_prefix%migrations
tables.modules: %core.table_prefix%modules

View file

@ -377,6 +377,7 @@ function make_user($username)
$viewemail = 0;
$aim = 0;
$yim = 0;
$msn = 0;
$attachsig = 1;
$allowsmilies = 1;
$allowhtml = 1;
@ -421,8 +422,8 @@ function make_user($username)
}
$sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_attachsig, user_allowsmilies, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey)
VALUES ($new_user_id, '$username', " . time() . ", '$password', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$signature_bbcode_uid', '$avatar_filename', $viewemail, '$aim', '$yim', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', $user_style, 0, 1, ";
$sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmilies, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey)
VALUES ($new_user_id, '$username', " . time() . ", '$password', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$signature_bbcode_uid', '$avatar_filename', $viewemail, '$aim', '$yim', '$msn', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', $user_style, 0, 1, ";
$sql .= "1, '')";

View file

@ -1273,6 +1273,19 @@ function get_schema_struct()
),
);
$schema_data['phpbb_migrations'] = array(
'COLUMNS' => array(
'migration_name' => array('VCHAR', ''),
'migration_depends_on' => array('TEXT', ''),
'migration_schema_done' => array('BOOL', 0),
'migration_data_done' => array('BOOL', 0),
'migration_data_state' => array('TEXT', ''),
'migration_start_time' => array('TIMESTAMP', 0),
'migration_end_time' => array('TIMESTAMP', 0),
),
'PRIMARY_KEY' => 'migration_name',
);
$schema_data['phpbb_modules'] = array(
'COLUMNS' => array(
'module_id' => array('UINT', NULL, 'auto_increment'),
@ -1836,6 +1849,7 @@ function get_schema_struct()
'user_icq' => array('VCHAR:15', ''),
'user_aim' => array('VCHAR_UNI', ''),
'user_yim' => array('VCHAR_UNI', ''),
'user_msnm' => array('VCHAR_UNI', ''),
'user_jabber' => array('VCHAR_UNI', ''),
'user_website' => array('VCHAR_UNI:200', ''),
'user_occ' => array('TEXT_UNI', ''),

View file

@ -1265,6 +1265,7 @@ function get_schema_struct()
'user_icq' => array('VCHAR:15', ''),
'user_aim' => array('VCHAR_UNI', ''),
'user_yim' => array('VCHAR_UNI', ''),
'user_msnm' => array('VCHAR_UNI', ''),
'user_jabber' => array('VCHAR_UNI', ''),
'user_website' => array('VCHAR_UNI:200', ''),
'user_occ' => array('TEXT_UNI', ''),

View file

@ -23,11 +23,11 @@ involved in phpBB.
phpBB Lead Developer: naderman (Nils Adermann)
phpBB Developers: bantu (Andreas Fischer)
EXreaction (Nathan Guse)
igorw (Igor Wiedler)
imkingdavid (David King)
nickvergessen (Joas Schilling)
Oleg (Oleg Pudeyev)
rxu (Ruslan Uzdenov)
Contributions by: leviatan21 (Gabriel Vazquez)
Raimon (Raimon Meuldijk)
@ -53,6 +53,7 @@ phpBB Developers: A_Jelly_Doughnut (Josh Woody) [01/2010 - 11/2010]
dhn (Dominik Dröscher) [05/2007 - 01/2011]
GrahamJE (Graham Eames) [09/2005 - 11/2006]
kellanved (Henry Sudhof) [04/2007 - 03/2011]
rxu (Ruslan Uzdenov) [04/2010 - 12/2012]
TerraFrost (Jim Wigginton) [04/2009 - 01/2011]
ToonArmy (Chris Smith) [06/2008 - 11/2011]
Vic D'Elfant (Vic D'Elfant) [04/2007 - 04/2009]

View file

@ -413,8 +413,8 @@ class acp_board
'board_email_form' => array('lang' => 'BOARD_EMAIL_FORM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true),
'email_function_name' => array('lang' => 'EMAIL_FUNCTION_NAME', 'validate' => 'string', 'type' => 'text:20:50', 'explain' => true),
'email_package_size' => array('lang' => 'EMAIL_PACKAGE_SIZE', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true),
'board_contact' => array('lang' => 'CONTACT_EMAIL', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => true),
'board_email' => array('lang' => 'ADMIN_EMAIL', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => true),
'board_contact' => array('lang' => 'CONTACT_EMAIL', 'validate' => 'email', 'type' => 'text:25:100', 'explain' => true),
'board_email' => array('lang' => 'ADMIN_EMAIL', 'validate' => 'email', 'type' => 'text:25:100', 'explain' => true),
'board_email_sig' => array('lang' => 'EMAIL_SIG', 'validate' => 'string', 'type' => 'textarea:5:30', 'explain' => true),
'board_hide_emails' => array('lang' => 'BOARD_HIDE_EMAILS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),

View file

@ -37,7 +37,7 @@ class acp_extensions
$this->template = $template;
$this->user = $user;
$user->add_lang(array('install', 'acp/extensions'));
$user->add_lang(array('install', 'acp/extensions', 'migrator'));
$this->page_title = 'ACP_EXTENSIONS';
@ -103,11 +103,18 @@ class acp_extensions
trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action));
}
if ($phpbb_extension_manager->enable_step($ext_name))
try
{
$template->assign_var('S_NEXT_STEP', true);
if ($phpbb_extension_manager->enable_step($ext_name))
{
$template->assign_var('S_NEXT_STEP', true);
meta_refresh(0, $this->u_action . '&amp;action=enable&amp;ext_name=' . urlencode($ext_name));
meta_refresh(0, $this->u_action . '&amp;action=enable&amp;ext_name=' . urlencode($ext_name));
}
}
catch (phpbb_db_migration_exception $e)
{
$template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($user));
}
$this->tpl_name = 'acp_ext_enable';
@ -156,11 +163,18 @@ class acp_extensions
break;
case 'purge':
if ($phpbb_extension_manager->purge_step($ext_name))
try
{
$template->assign_var('S_NEXT_STEP', true);
if ($phpbb_extension_manager->purge_step($ext_name))
{
$template->assign_var('S_NEXT_STEP', true);
meta_refresh(0, $this->u_action . '&amp;action=purge&amp;ext_name=' . urlencode($ext_name));
meta_refresh(0, $this->u_action . '&amp;action=purge&amp;ext_name=' . urlencode($ext_name));
}
}
catch (phpbb_db_migration_exception $e)
{
$template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($user));
}
$this->tpl_name = 'acp_ext_purge';

View file

@ -126,13 +126,34 @@ class acp_groups
{
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
}
else if (empty($mark_ary))
{
trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id), E_USER_WARNING);
}
if (confirm_box(true))
{
$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row);
trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id));
}
else
{
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'mark' => $mark_ary,
'g' => $group_id,
'i' => $id,
'mode' => $mode,
'action' => $action))
);
}
if (!sizeof($mark_ary))
break;
case 'set_default_on_all':
if (confirm_box(true))
{
$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
$start = 0;
do
@ -163,28 +184,25 @@ class acp_groups
$db->sql_freeresult($result);
}
while ($start);
trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id));
}
else
{
group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row);
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'mark' => $mark_ary,
'g' => $group_id,
'i' => $id,
'mode' => $mode,
'action' => $action))
);
}
trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id));
}
else
{
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'mark' => $mark_ary,
'g' => $group_id,
'i' => $id,
'mode' => $mode,
'action' => $action))
);
}
break;
case 'deleteusers':
if (empty($mark_ary))
{
trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id), E_USER_WARNING);
}
case 'delete':
if (!$group_id)
{
@ -698,7 +716,7 @@ class acp_groups
'U_ACTION' => $this->u_action . "&amp;g=$group_id",
'U_BACK' => $this->u_action,
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=list&amp;field=usernames'),
'U_DEFAULT_ALL' => "{$this->u_action}&amp;action=default&amp;g=$group_id",
'U_DEFAULT_ALL' => "{$this->u_action}&amp;action=set_default_on_all&amp;g=$group_id",
));
// Grab the members

View file

@ -1352,6 +1352,7 @@ class acp_users
$data = array(
'icq' => request_var('icq', $user_row['user_icq']),
'aim' => request_var('aim', $user_row['user_aim']),
'msn' => request_var('msn', $user_row['user_msnm']),
'yim' => request_var('yim', $user_row['user_yim']),
'jabber' => utf8_normalize_nfc(request_var('jabber', $user_row['user_jabber'], true)),
'website' => request_var('website', $user_row['user_website']),
@ -1381,6 +1382,7 @@ class acp_users
array('string', true, 3, 15),
array('match', true, '#^[0-9]+$#i')),
'aim' => array('string', true, 3, 255),
'msn' => array('string', true, 5, 255),
'jabber' => array(
array('string', true, 5, 255),
array('jabber')),
@ -1414,6 +1416,7 @@ class acp_users
$sql_ary = array(
'user_icq' => $data['icq'],
'user_aim' => $data['aim'],
'user_msnm' => $data['msn'],
'user_yim' => $data['yim'],
'user_jabber' => $data['jabber'],
'user_website' => $data['website'],
@ -1466,6 +1469,7 @@ class acp_users
'ICQ' => $data['icq'],
'YIM' => $data['yim'],
'AIM' => $data['aim'],
'MSN' => $data['msn'],
'JABBER' => $data['jabber'],
'WEBSITE' => $data['website'],
'LOCATION' => $data['location'],

View file

@ -16,10 +16,10 @@ class acp_extensions_info
{
return array(
'filename' => 'acp_extensions',
'title' => 'ACP_EXTENSIONS_MANAGEMENT',
'title' => 'ACP_EXTENSION_MANAGEMENT',
'version' => '1.0.0',
'modes' => array(
'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_EXTENSIONS_MANAGEMENT')),
'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_EXTENSION_MANAGEMENT')),
),
);
}

View file

@ -237,6 +237,7 @@ define('ICONS_TABLE', $table_prefix . 'icons');
define('LANG_TABLE', $table_prefix . 'lang');
define('LOG_TABLE', $table_prefix . 'log');
define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts');
define('MIGRATIONS_TABLE', $table_prefix . 'migrations');
define('MODERATOR_CACHE_TABLE', $table_prefix . 'moderator_cache');
define('MODULES_TABLE', $table_prefix . 'modules');
define('POLL_OPTIONS_TABLE', $table_prefix . 'poll_options');

View file

@ -143,7 +143,7 @@ class phpbb_datetime extends DateTime
'is_short' => strpos($format, self::RELATIVE_WRAPPER) !== false,
'format_short' => substr($format, 0, strpos($format, self::RELATIVE_WRAPPER)) . self::RELATIVE_WRAPPER . self::RELATIVE_WRAPPER . substr(strrchr($format, self::RELATIVE_WRAPPER), 1),
'format_long' => str_replace(self::RELATIVE_WRAPPER, '', $format),
'lang' => $user->lang['datetime'],
'lang' => array_filter($user->lang['datetime'], 'is_string'),
);
// Short representation of month in format? Some languages use different terms for the long and short format of May

View file

@ -303,7 +303,7 @@ class phpbb_db_tools
* @param phpbb_db_driver $db Database connection
* @param bool $return_statements True if only statements should be returned and no SQL being executed
*/
function phpbb_db_tools(&$db, $return_statements = false)
function phpbb_db_tools(phpbb_db_driver $db, $return_statements = false)
{
$this->db = $db;
$this->return_statements = $return_statements;
@ -345,6 +345,17 @@ class phpbb_db_tools
}
}
/**
* Setter for {@link $return_statements return_statements}.
*
* @param bool $return_statements True if SQL should not be executed but returned as strings
* @return null
*/
public function set_return_statements($return_statements)
{
$this->return_statements = $return_statements;
}
/**
* Gets a list of tables in the database.
*
@ -674,6 +685,8 @@ class phpbb_db_tools
* Handle passed database update array.
* Expected structure...
* Key being one of the following
* drop_tables: Drop tables
* add_tables: Add tables
* change_columns: Column changes (only type, not name)
* add_columns: Add columns to a table
* drop_keys: Dropping keys

View file

@ -0,0 +1,79 @@
<?php
/**
*
* @package db
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* The migrator is responsible for applying new migrations in the correct order.
*
* @package db
*/
class phpbb_db_migration_exception extends \Exception
{
/**
* Extra parameters sent to exception to aid in debugging
* @var array
*/
protected $parameters;
/**
* Throw an exception.
*
* First argument is the error message.
* Additional arguments will be output with the error message.
*/
public function __construct()
{
$parameters = func_get_args();
$message = array_shift($parameters);
parent::__construct($message);
$this->parameters = $parameters;
}
/**
* Output the error as a string
*
* @return string
*/
public function __toString()
{
return $this->message . ': ' . var_export($this->parameters, true);
}
/**
* Get the parameters
*
* @return array
*/
public function getParameters()
{
return $this->parameters;
}
/**
* Get localised message (with $user->lang())
*
* @param phpbb_user $user
* @return string
*/
public function getLocalisedMessage(phpbb_user $user)
{
$parameters = $this->getParameters();
array_unshift($parameters, $this->getMessage());
return call_user_func_array(array($user, 'lang'), $parameters);
}
}

View file

@ -0,0 +1,190 @@
<?php
/**
*
* @package db
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Abstract base class for database migrations
*
* Each migration consists of a set of schema and data changes to be implemented
* in a subclass. This class provides various utility methods to simplify editing
* a phpBB.
*
* @package db
*/
abstract class phpbb_db_migration
{
/** @var phpbb_config */
protected $config;
/** @var phpbb_db_driver */
protected $db;
/** @var phpbb_db_tools */
protected $db_tools;
/** @var string */
protected $table_prefix;
/** @var string */
protected $phpbb_root_path;
/** @var string */
protected $php_ext;
/** @var array Errors, if any occured */
protected $errors;
/** @var array List of queries executed through $this->sql_query() */
protected $queries = array();
/**
* Constructor
*
* @param phpbb_config $config
* @param phpbb_db_driver $db
* @param phpbb_db_tools $db_tools
* @param string $phpbb_root_path
* @param string $php_ext
* @param string $table_prefix
*/
public function __construct(phpbb_config $config, phpbb_db_driver $db, phpbb_db_tools $db_tools, $phpbb_root_path, $php_ext, $table_prefix)
{
$this->config = $config;
$this->db = $db;
$this->db_tools = $db_tools;
$this->table_prefix = $table_prefix;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->errors = array();
}
/**
* Defines other migrations to be applied first
*
* @return array An array of migration class names
*/
static public function depends_on()
{
return array();
}
/**
* Allows you to check if the migration is effectively installed (entirely optional)
*
* This is checked when a migration is installed. If true is returned, the migration will be set as
* installed without performing the database changes.
* This function is intended to help moving to migrations from a previous database updater, where some
* migrations may have been installed already even though they are not yet listed in the migrations table.
*
* @return bool True if this migration is installed, False if this migration is not installed (checked on install)
*/
public function effectively_installed()
{
return false;
}
/**
* Updates the database schema by providing a set of change instructions
*
* @return array Array of schema changes (compatible with db_tools->perform_schema_changes())
*/
public function update_schema()
{
return array();
}
/**
* Reverts the database schema by providing a set of change instructions
*
* @return array Array of schema changes (compatible with db_tools->perform_schema_changes())
*/
public function revert_schema()
{
return array();
}
/**
* Updates data by returning a list of instructions to be executed
*
* @return array Array of data update instructions
*/
public function update_data()
{
return array();
}
/**
* Reverts data by returning a list of instructions to be executed
*
* @return array Array of data instructions that will be performed on revert
* NOTE: calls to tools (such as config.add) are automatically reverted when
* possible, so you should not attempt to revert those, this is mostly for
* otherwise unrevertable calls (custom functions for example)
*/
public function revert_data()
{
return array();
}
/**
* Wrapper for running queries to generate user feedback on updates
*
* @param string $sql SQL query to run on the database
* @return mixed Query result from db->sql_query()
*/
protected function sql_query($sql)
{
$this->queries[] = $sql;
$this->db->sql_return_on_error(true);
if ($sql === 'begin')
{
$result = $this->db->sql_transaction('begin');
}
else if ($sql === 'commit')
{
$result = $this->db->sql_transaction('commit');
}
else
{
$result = $this->db->sql_query($sql);
if ($this->db->sql_error_triggered)
{
$this->errors[] = array(
'sql' => $this->db->sql_error_sql,
'code' => $this->db->sql_error_returned,
);
}
}
$this->db->sql_return_on_error(false);
return $result;
}
/**
* Get the list of queries run
*
* @return array
*/
public function get_queries()
{
return $this->queries;
}
}

View file

@ -0,0 +1,150 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
/**
* Migration config tool
*
* @package db
*/
class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interface
{
/** @var phpbb_config */
protected $config;
/**
* Constructor
*
* @param phpbb_config $config
*/
public function __construct(phpbb_config $config)
{
$this->config = $config;
}
/**
* {@inheritdoc}
*/
public function get_name()
{
return 'config';
}
/**
* Add a config setting.
*
* @param string $config_name The name of the config setting
* you would like to add
* @param mixed $config_value The value of the config setting
* @param bool $is_dynamic True if it is dynamic (changes very often)
* and should not be stored in the cache, false if not.
* @return null
*/
public function add($config_name, $config_value, $is_dynamic = false)
{
if (isset($this->config[$config_name]))
{
throw new phpbb_db_migration_exception('CONFIG_ALREADY_EXIST', $config_name);
}
$this->config->set($config_name, $config_value, !$is_dynamic);
}
/**
* Update an existing config setting.
*
* @param string $config_name The name of the config setting you would
* like to update
* @param mixed $config_value The value of the config setting
* @return null
*/
public function update($config_name, $config_value)
{
if (!isset($this->config[$config_name]))
{
throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name);
}
$this->config->set($config_name, $config_value);
}
/**
* Update a config setting if the first argument equal to the
* current config value
*
* @param string $compare If equal to the current config value, will be
* updated to the new config value, otherwise not
* @param string $config_name The name of the config setting you would
* like to update
* @param mixed $config_value The value of the config setting
* @return null
*/
public function update_if_equals($compare, $config_name, $config_value)
{
if (!isset($this->config[$config_name]))
{
throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name);
}
$this->config->set_atomic($config_name, $compare, $config_value);
}
/**
* Remove an existing config setting.
*
* @param string $config_name The name of the config setting you would
* like to remove
* @return null
*/
public function remove($config_name)
{
if (!isset($this->config[$config_name]))
{
throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name);
}
$this->config->delete($config_name);
}
/**
* {@inheritdoc}
*/
public function reverse()
{
$arguments = func_get_args();
$original_call = array_shift($arguments);
$call = false;
switch ($original_call)
{
case 'add':
$call = 'remove';
break;
case 'remove':
$call = 'add';
break;
case 'update_if_equals':
$call = 'update_if_equals';
// Set to the original value if the current value is what we compared to originally
$arguments = array(
$arguments[2],
$arguments[1],
$arguments[0],
);
break;
}
if ($call)
{
return call_user_func_array(array(&$this, $call), $arguments);
}
}
}

View file

@ -0,0 +1,33 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
/**
* Migration tool interface
*
* @package db
*/
interface phpbb_db_migration_tool_interface
{
/**
* Retrieve a short name used for commands in migrations.
*
* @return string short name
*/
public function get_name();
/**
* Reverse an original install action
*
* First argument is the original call to the class (e.g. add, remove)
* After the first argument, send the original arguments to the function in the original call
*
* @return null
*/
public function reverse();
}

View file

@ -0,0 +1,513 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
/**
* Migration module management tool
*
* @package db
*/
class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interface
{
/** @var phpbb_cache_service */
protected $cache;
/** @var dbal */
protected $db;
/** @var phpbb_user */
protected $user;
/** @var string */
protected $phpbb_root_path;
/** @var string */
protected $php_ext;
/** @var string */
protected $modules_table;
/**
* Constructor
*
* @param phpbb_db_driver $db
* @param mixed $cache
* @param phpbb_user $user
* @param string $phpbb_root_path
* @param string $php_ext
* @param string $modules_table
*/
public function __construct(phpbb_db_driver $db, phpbb_cache_service $cache, phpbb_user $user, $phpbb_root_path, $php_ext, $modules_table)
{
$this->db = $db;
$this->cache = $cache;
$this->user = $user;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->modules_table = $modules_table;
}
/**
* {@inheritdoc}
*/
public function get_name()
{
return 'module';
}
/**
* Module Exists
*
* Check if a module exists
*
* @param string $class The module class(acp|mcp|ucp)
* @param int|string|bool $parent The parent module_id|module_langname (0 for no parent).
* Use false to ignore the parent check and check class wide.
* @param int|string $module The module_id|module_langname you would like to
* check for to see if it exists
* @return bool true/false if module exists
*/
public function exists($class, $parent, $module)
{
// the main root directory should return true
if (!$module)
{
return true;
}
$parent_sql = '';
if ($parent !== false)
{
// Allows '' to be sent as 0
$parent = $parent ?: 0;
if (!is_numeric($parent))
{
$sql = 'SELECT module_id
FROM ' . $this->modules_table . "
WHERE module_langname = '" . $this->db->sql_escape($parent) . "'
AND module_class = '" . $this->db->sql_escape($class) . "'";
$result = $this->db->sql_query($sql);
$module_id = $this->db->sql_fetchfield('module_id');
$this->db->sql_freeresult($result);
if (!$module_id)
{
return false;
}
$parent_sql = 'AND parent_id = ' . (int) $module_id;
}
else
{
$parent_sql = 'AND parent_id = ' . (int) $parent;
}
}
$sql = 'SELECT module_id
FROM ' . $this->modules_table . "
WHERE module_class = '" . $this->db->sql_escape($class) . "'
$parent_sql
AND " . ((is_numeric($module)) ? 'module_id = ' . (int) $module : "module_langname = '" . $this->db->sql_escape($module) . "'");
$result = $this->db->sql_query($sql);
$module_id = $this->db->sql_fetchfield('module_id');
$this->db->sql_freeresult($result);
if ($module_id)
{
return true;
}
return false;
}
/**
* Module Add
*
* Add a new module
*
* @param string $class The module class(acp|mcp|ucp)
* @param int|string $parent The parent module_id|module_langname (0 for no parent)
* @param array $data an array of the data on the new module.
* This can be setup in two different ways.
* 1. The "manual" way. For inserting a category or one at a time.
* It will be merged with the base array shown a bit below,
* but at the least requires 'module_langname' to be sent, and,
* if you want to create a module (instead of just a category) you must
* send module_basename and module_mode.
* array(
* 'module_enabled' => 1,
* 'module_display' => 1,
* 'module_basename' => '',
* 'module_class' => $class,
* 'parent_id' => (int) $parent,
* 'module_langname' => '',
* 'module_mode' => '',
* 'module_auth' => '',
* )
* 2. The "automatic" way. For inserting multiple at a time based on the
* specs in the info file for the module(s). For this to work the
* modules must be correctly setup in the info file.
* An example follows (this would insert the settings, log, and flag
* modes from the includes/acp/info/acp_asacp.php file):
* array(
* 'module_basename' => 'asacp',
* 'modes' => array('settings', 'log', 'flag'),
* )
* Optionally you may not send 'modes' and it will insert all of the
* modules in that info file.
* @param string|bool $include_path If you would like to use a custom include
* path, specify that here
* @return null
*/
public function add($class, $parent = 0, $data = array(), $include_path = false)
{
// Allows '' to be sent as 0
$parent = $parent ?: 0;
// allow sending the name as a string in $data to create a category
if (!is_array($data))
{
$data = array('module_langname' => $data);
}
if (!isset($data['module_langname']))
{
// The "automatic" way
$basename = (isset($data['module_basename'])) ? $data['module_basename'] : '';
$basename = str_replace(array('/', '\\'), '', $basename);
$class = str_replace(array('/', '\\'), '', $class);
$include_path = ($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path;
$info_file = "$class/info/$basename.{$this->php_ext}";
// The manual and automatic ways both failed...
if (!file_exists($include_path . $info_file))
{
throw new phpbb_db_migration_exception('MODULE_INFO_FILE_NOT_EXIST', $class, $info_file);
}
$classname = "{$basename}_info";
if (!class_exists($classname))
{
include($include_path . $info_file);
}
$info = new $classname;
$module = $info->module();
unset($info);
$result = '';
foreach ($module['modes'] as $mode => $module_info)
{
if (!isset($data['modes']) || in_array($mode, $data['modes']))
{
$new_module = array(
'module_basename' => $basename,
'module_langname' => $module_info['title'],
'module_mode' => $mode,
'module_auth' => $module_info['auth'],
'module_display' => (isset($module_info['display'])) ? $module_info['display'] : true,
'before' => (isset($module_info['before'])) ? $module_info['before'] : false,
'after' => (isset($module_info['after'])) ? $module_info['after'] : false,
);
// Run the "manual" way with the data we've collected.
$this->add($class, $parent, $new_module);
}
}
return;
}
// The "manual" way
$module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']);
add_log('admin', 'LOG_MODULE_ADD', $module_log_name);
if (!is_numeric($parent))
{
$sql = 'SELECT module_id
FROM ' . $this->modules_table . "
WHERE module_langname = '" . $this->db->sql_escape($parent) . "'
AND module_class = '" . $this->db->sql_escape($class) . "'";
$result = $this->db->sql_query($sql);
$module_id = $this->db->sql_fetchfield('module_id');
$this->db->sql_freeresult($result);
if (!$module_id)
{
throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $parent);
}
$parent = $data['parent_id'] = $module_id;
}
else if (!$this->exists($class, false, $parent))
{
throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $parent);
}
if ($this->exists($class, $parent, $data['module_langname']))
{
throw new phpbb_db_migration_exception('MODULE_ALREADY_EXIST', $data['module_langname']);
}
if (!class_exists('acp_modules'))
{
include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
$this->user->add_lang('acp/modules');
}
$acp_modules = new acp_modules();
$module_data = array(
'module_enabled' => (isset($data['module_enabled'])) ? $data['module_enabled'] : 1,
'module_display' => (isset($data['module_display'])) ? $data['module_display'] : 1,
'module_basename' => (isset($data['module_basename'])) ? $data['module_basename'] : '',
'module_class' => $class,
'parent_id' => (int) $parent,
'module_langname' => (isset($data['module_langname'])) ? $data['module_langname'] : '',
'module_mode' => (isset($data['module_mode'])) ? $data['module_mode'] : '',
'module_auth' => (isset($data['module_auth'])) ? $data['module_auth'] : '',
);
$result = $acp_modules->update_module_data($module_data, true);
// update_module_data can either return a string or an empty array...
if (is_string($result))
{
// Error
throw new phpbb_db_migration_exception('MODULE_ERROR', $result);
}
else
{
// Success
// Move the module if requested above/below an existing one
if (isset($data['before']) && $data['before'])
{
$sql = 'SELECT left_id
FROM ' . $this->modules_table . "
WHERE module_class = '" . $this->db->sql_escape($class) . "'
AND parent_id = " . (int) $parent . "
AND module_langname = '" . $this->db->sql_escape($data['before']) . "'";
$this->db->sql_query($sql);
$to_left = (int) $this->db->sql_fetchfield('left_id');
$sql = 'UPDATE ' . $this->modules_table . "
SET left_id = left_id + 2, right_id = right_id + 2
WHERE module_class = '" . $this->db->sql_escape($class) . "'
AND left_id >= $to_left
AND left_id < {$module_data['left_id']}";
$this->db->sql_query($sql);
$sql = 'UPDATE ' . $this->modules_table . "
SET left_id = $to_left, right_id = " . ($to_left + 1) . "
WHERE module_class = '" . $this->db->sql_escape($class) . "'
AND module_id = {$module_data['module_id']}";
$this->db->sql_query($sql);
}
else if (isset($data['after']) && $data['after'])
{
$sql = 'SELECT right_id
FROM ' . $this->modules_table . "
WHERE module_class = '" . $this->db->sql_escape($class) . "'
AND parent_id = " . (int) $parent . "
AND module_langname = '" . $this->db->sql_escape($data['after']) . "'";
$this->db->sql_query($sql);
$to_right = (int) $this->db->sql_fetchfield('right_id');
$sql = 'UPDATE ' . $this->modules_table . "
SET left_id = left_id + 2, right_id = right_id + 2
WHERE module_class = '" . $this->db->sql_escape($class) . "'
AND left_id >= $to_right
AND left_id < {$module_data['left_id']}";
$this->db->sql_query($sql);
$sql = 'UPDATE ' . $this->modules_table . '
SET left_id = ' . ($to_right + 1) . ', right_id = ' . ($to_right + 2) . "
WHERE module_class = '" . $this->db->sql_escape($class) . "'
AND module_id = {$module_data['module_id']}";
$this->db->sql_query($sql);
}
}
// Clear the Modules Cache
$this->cache->destroy("_modules_$class");
}
/**
* Module Remove
*
* Remove a module
*
* @param string $class The module class(acp|mcp|ucp)
* @param int|string|bool $parent The parent module_id|module_langname(0 for no parent).
* Use false to ignore the parent check and check class wide.
* @param int|string $module The module id|module_langname
* @param string|bool $include_path If you would like to use a custom include path,
* specify that here
* @return null
*/
public function remove($class, $parent = 0, $module = '', $include_path = false)
{
// Imitation of module_add's "automatic" and "manual" method so the uninstaller works from the same set of instructions for umil_auto
if (is_array($module))
{
if (isset($module['module_langname']))
{
// Manual Method
return $this->remove($class, $parent, $module['module_langname'], $include_path);
}
// Failed.
if (!isset($module['module_basename']))
{
throw new phpbb_db_migration_exception('MODULE_NOT_EXIST');
}
// Automatic method
$basename = str_replace(array('/', '\\'), '', $module['module_basename']);
$class = str_replace(array('/', '\\'), '', $class);
$include_path = ($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path;
$info_file = "$class/info/$basename.{$this->php_ext}";
if (!file_exists($include_path . $info_file))
{
throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $info_file);
}
$classname = "{$basename}_info";
if (!class_exists($classname))
{
include($include_path . $info_file);
}
$info = new $classname;
$module_info = $info->module();
unset($info);
foreach ($module_info['modes'] as $mode => $info)
{
if (!isset($module['modes']) || in_array($mode, $module['modes']))
{
$this->remove($class, $parent, $info['title']) . '<br />';
}
}
}
else
{
if (!$this->exists($class, $parent, $module))
{
throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', ((isset($this->user->lang[$module])) ? $this->user->lang[$module] : $module));
}
$parent_sql = '';
if ($parent !== false)
{
// Allows '' to be sent as 0
$parent = ($parent) ?: 0;
if (!is_numeric($parent))
{
$sql = 'SELECT module_id
FROM ' . $this->modules_table . "
WHERE module_langname = '" . $this->db->sql_escape($parent) . "'
AND module_class = '" . $this->db->sql_escape($class) . "'";
$result = $this->db->sql_query($sql);
$module_id = $this->db->sql_fetchfield('module_id');
$this->db->sql_freeresult($result);
// we know it exists from the module_exists check
$parent_sql = 'AND parent_id = ' . (int) $module_id;
}
else
{
$parent_sql = 'AND parent_id = ' . (int) $parent;
}
}
$module_ids = array();
if (!is_numeric($module))
{
$sql = 'SELECT module_id
FROM ' . $this->modules_table . "
WHERE module_langname = '" . $this->db->sql_escape($module) . "'
AND module_class = '" . $this->db->sql_escape($class) . "'
$parent_sql";
$result = $this->db->sql_query($sql);
while ($module_id = $this->db->sql_fetchfield('module_id'))
{
$module_ids[] = (int) $module_id;
}
$this->db->sql_freeresult($result);
$module_name = $module;
}
else
{
$module = (int) $module;
$sql = 'SELECT module_langname
FROM ' . $this->modules_table . "
WHERE module_id = $module
AND module_class = '" . $this->db->sql_escape($class) . "'
$parent_sql";
$result = $this->db->sql_query($sql);
$module_name = $this->db->sql_fetchfield('module_id');
$this->db->sql_freeresult($result);
$module_ids[] = $module;
}
if (!class_exists('acp_modules'))
{
include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
$this->user->add_lang('acp/modules');
}
$acp_modules = new acp_modules();
$acp_modules->module_class = $class;
foreach ($module_ids as $module_id)
{
$result = $acp_modules->delete_module($module_id);
if (!empty($result))
{
throw new phpbb_db_migration_exception('MODULE_NOT_REMOVABLE', $module_id, $result);
}
}
$this->cache->destroy("_modules_$class");
}
}
/**
* {@inheritdoc}
*/
public function reverse()
{
$arguments = func_get_args();
$original_call = array_shift($arguments);
$call = false;
switch ($original_call)
{
case 'add':
$call = 'remove';
break;
case 'remove':
$call = 'add';
break;
}
if ($call)
{
return call_user_func_array(array(&$this, $call), $arguments);
}
}
}

View file

@ -0,0 +1,622 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
/**
* Migration permission management tool
*
* @package db
*/
class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_interface
{
/** @var phpbb_auth */
protected $auth;
/** @var phpbb_cache_service */
protected $cache;
/** @var dbal */
protected $db;
/** @var string */
protected $phpbb_root_path;
/** @var string */
protected $php_ext;
/**
* Constructor
*
* @param phpbb_db_driver $db
* @param mixed $cache
* @param phpbb_auth $auth
* @param string $phpbb_root_path
* @param string $php_ext
*/
public function __construct(phpbb_db_driver $db, phpbb_cache_service $cache, phpbb_auth $auth, $phpbb_root_path, $php_ext)
{
$this->db = $db;
$this->cache = $cache;
$this->auth = $auth;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
}
/**
* {@inheritdoc}
*/
public function get_name()
{
return 'permission';
}
/**
* Permission Exists
*
* Check if a permission (auth) setting exists
*
* @param string $auth_option The name of the permission (auth) option
* @param bool $global True for checking a global permission setting,
* False for a local permission setting
* @return bool true if it exists, false if not
*/
public function exists($auth_option, $global = true)
{
if ($global)
{
$type_sql = ' AND is_global = 1';
}
else
{
$type_sql = ' AND is_local = 1';
}
$sql = 'SELECT auth_option_id
FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option = '" . $this->db->sql_escape($auth_option) . "'"
. $type_sql;
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
if ($row)
{
return true;
}
return false;
}
/**
* Permission Add
*
* Add a permission (auth) option
*
* @param string $auth_option The name of the permission (auth) option
* @param bool $global True for checking a global permission setting,
* False for a local permission setting
* @return null
*/
public function add($auth_option, $global = true, $copy_from = false)
{
if ($this->exists($auth_option, $global))
{
throw new phpbb_db_migration_exception('PERMISSION_ALREADY_EXIST', $auth_option);
}
// We've added permissions, so set to true to notify the user.
$this->permissions_added = true;
if (!class_exists('auth_admin'))
{
include($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext);
}
$auth_admin = new auth_admin();
// We have to add a check to see if the !$global (if global, local, and if local, global) permission already exists. If it does, acl_add_option currently has a bug which would break the ACL system, so we are having a work-around here.
if ($this->exists($auth_option, !$global))
{
$sql_ary = array(
'is_global' => 1,
'is_local' => 1,
);
$sql = 'UPDATE ' . ACL_OPTIONS_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . "
WHERE auth_option = '" . $this->db->sql_escape($auth_option) . "'";
$this->db->sql_query($sql);
}
else
{
if ($global)
{
$auth_admin->acl_add_option(array('global' => array($auth_option)));
}
else
{
$auth_admin->acl_add_option(array('local' => array($auth_option)));
}
}
// The permission has been added, now we can copy it if needed
if ($copy_from && isset($auth_admin->acl_options['id'][$copy_from]))
{
$old_id = $auth_admin->acl_options['id'][$copy_from];
$new_id = $auth_admin->acl_options['id'][$auth_option];
$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);
foreach ($tables as $table)
{
$sql = 'SELECT *
FROM ' . $table . '
WHERE auth_option_id = ' . $old_id;
$result = $this->db->sql_query($sql);
$sql_ary = array();
while ($row = $this->db->sql_fetchrow($result))
{
$row['auth_option_id'] = $new_id;
$sql_ary[] = $row;
}
$this->db->sql_freeresult($result);
if (!empty($sql_ary))
{
$this->db->sql_multi_insert($table, $sql_ary);
}
}
$auth_admin->acl_clear_prefetch();
}
}
/**
* Permission Remove
*
* Remove a permission (auth) option
*
* @param string $auth_option The name of the permission (auth) option
* @param bool $global True for checking a global permission setting,
* False for a local permission setting
* @return null
*/
public function remove($auth_option, $global = true)
{
if (!$this->exists($auth_option, $global))
{
throw new phpbb_db_migration_exception('PERMISSION_NOT_EXIST', $auth_option);
}
if ($global)
{
$type_sql = ' AND is_global = 1';
}
else
{
$type_sql = ' AND is_local = 1';
}
$sql = 'SELECT auth_option_id, is_global, is_local
FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option = '" . $this->db->sql_escape($auth_option) . "'" .
$type_sql;
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
$id = (int) $row['auth_option_id'];
// If it is a local and global permission, do not remove the row! :P
if ($row['is_global'] && $row['is_local'])
{
$sql = 'UPDATE ' . ACL_OPTIONS_TABLE . '
SET ' . (($global) ? 'is_global = 0' : 'is_local = 0') . '
WHERE auth_option_id = ' . $id;
$this->db->sql_query($sql);
}
else
{
// Delete time
$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE, ACL_OPTIONS_TABLE);
foreach ($tables as $table)
{
$this->db->sql_query('DELETE FROM ' . $table . '
WHERE auth_option_id = ' . $id);
}
}
// Purge the auth cache
$this->cache->destroy('_acl_options');
$this->auth->acl_clear_prefetch();
}
/**
* Add a new permission role
*
* @param string $role_name The new role name
* @param sting $role_type The type (u_, m_, a_)
* @return null
*/
public function role_add($role_name, $role_type, $role_description = '')
{
$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = '" . $this->db->sql_escape($role_name) . "'";
$this->db->sql_query($sql);
$role_id = (int) $this->db->sql_fetchfield('role_id');
if ($role_id)
{
return;
}
$sql = 'SELECT MAX(role_order) AS max_role_order
FROM ' . ACL_ROLES_TABLE . "
WHERE role_type = '" . $this->db->sql_escape($role_type) . "'";
$this->db->sql_query($sql);
$role_order = (int) $this->db->sql_fetchfield('max_role_order');
$role_order = (!$role_order) ? 1 : $role_order + 1;
$sql_ary = array(
'role_name' => $role_name,
'role_description' => $role_description,
'role_type' => $role_type,
'role_order' => $role_order,
);
$sql = 'INSERT INTO ' . ACL_ROLES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
$this->db->sql_query($sql);
}
/**
* Update the name on a permission role
*
* @param string $old_role_name The old role name
* @param string $new_role_name The new role name
* @return null
*/
public function role_update($old_role_name, $new_role_name)
{
$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = '" . $this->db->sql_escape($old_role_name) . "'";
$this->db->sql_query($sql);
$role_id = (int) $this->db->sql_fetchfield('role_id');
if (!$role_id)
{
throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $old_role_name);
}
$sql = 'UPDATE ' . ACL_ROLES_TABLE . "
SET role_name = '" . $this->db->sql_escape($new_role_name) . "'
WHERE role_name = '" . $this->db->sql_escape($old_role_name) . "'";
$this->db->sql_query($sql);
}
/**
* Remove a permission role
*
* @param string $role_name The role name to remove
* @return null
*/
public function role_remove($role_name)
{
$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = '" . $this->db->sql_escape($role_name) . "'";
$this->db->sql_query($sql);
$role_id = (int) $this->db->sql_fetchfield('role_id');
if (!$role_id)
{
throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $role_name);
}
$sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . '
WHERE role_id = ' . $role_id;
$this->db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_ROLES_TABLE . '
WHERE role_id = ' . $role_id;
$this->db->sql_query($sql);
$this->auth->acl_clear_prefetch();
}
/**
* Permission Set
*
* Allows you to set permissions for a certain group/role
*
* @param string $name The name of the role/group
* @param string|array $auth_option The auth_option or array of
* auth_options you would like to set
* @param string $type The type (role|group)
* @param bool $has_permission True if you want to give them permission,
* false if you want to deny them permission
* @return null
*/
public function permission_set($name, $auth_option, $type = 'role', $has_permission = true)
{
if (!is_array($auth_option))
{
$auth_option = array($auth_option);
}
$new_auth = array();
$sql = 'SELECT auth_option_id
FROM ' . ACL_OPTIONS_TABLE . '
WHERE ' . $this->db->sql_in_set('auth_option', $auth_option);
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$new_auth[] = (int) $row['auth_option_id'];
}
$this->db->sql_freeresult($result);
if (empty($new_auth))
{
return;
}
$current_auth = array();
$type = (string) $type; // Prevent PHP bug.
switch ($type)
{
case 'role':
$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = '" . $this->db->sql_escape($name) . "'";
$this->db->sql_query($sql);
$role_id = (int) $this->db->sql_fetchfield('role_id');
if (!$role_id)
{
throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $name);
}
$sql = 'SELECT auth_option_id, auth_setting
FROM ' . ACL_ROLES_DATA_TABLE . '
WHERE role_id = ' . $role_id;
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$current_auth[$row['auth_option_id']] = $row['auth_setting'];
}
$this->db->sql_freeresult($result);
break;
case 'group':
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "
WHERE group_name = '" . $this->db->sql_escape($name) . "'";
$this->db->sql_query($sql);
$group_id = (int) $this->db->sql_fetchfield('group_id');
if (!$group_id)
{
throw new phpbb_db_migration_exception('GROUP_NOT_EXIST', $name);
}
// If the group has a role set for them we will add the requested permissions to that role.
$sql = 'SELECT auth_role_id
FROM ' . ACL_GROUPS_TABLE . '
WHERE group_id = ' . $group_id . '
AND auth_role_id <> 0
AND forum_id = 0';
$this->db->sql_query($sql);
$role_id = (int) $this->db->sql_fetchfield('auth_role_id');
if ($role_id)
{
$sql = 'SELECT role_name
FROM ' . ACL_ROLES_TABLE . '
WHERE role_id = ' . $role_id;
$this->db->sql_query($sql);
$role_name = $this->db->sql_fetchfield('role_name');
return $this->set($role_name, $auth_option, 'role', $has_permission);
}
$sql = 'SELECT auth_option_id, auth_setting
FROM ' . ACL_GROUPS_TABLE . '
WHERE group_id = ' . $group_id;
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$current_auth[$row['auth_option_id']] = $row['auth_setting'];
}
$this->db->sql_freeresult($result);
break;
}
$sql_ary = array();
switch ($type)
{
case 'role':
foreach ($new_auth as $auth_option_id)
{
if (!isset($current_auth[$auth_option_id]))
{
$sql_ary[] = array(
'role_id' => $role_id,
'auth_option_id' => $auth_option_id,
'auth_setting' => $has_permission,
);
}
}
$this->db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary);
break;
case 'group':
foreach ($new_auth as $auth_option_id)
{
if (!isset($current_auth[$auth_option_id]))
{
$sql_ary[] = array(
'group_id' => $group_id,
'auth_option_id' => $auth_option_id,
'auth_setting' => $has_permission,
);
}
}
$this->db->sql_multi_insert(ACL_GROUPS_TABLE, $sql_ary);
break;
}
$this->auth->acl_clear_prefetch();
}
/**
* Permission Unset
*
* Allows you to unset (remove) permissions for a certain group/role
*
* @param string $name The name of the role/group
* @param string|array $auth_option The auth_option or array of
* auth_options you would like to set
* @param string $type The type (role|group)
* @return null
*/
public function permission_unset($name, $auth_option, $type = 'role')
{
if (!is_array($auth_option))
{
$auth_option = array($auth_option);
}
$to_remove = array();
$sql = 'SELECT auth_option_id
FROM ' . ACL_OPTIONS_TABLE . '
WHERE ' . $this->db->sql_in_set('auth_option', $auth_option);
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$to_remove[] = (int) $row['auth_option_id'];
}
$this->db->sql_freeresult($result);
if (empty($to_remove))
{
return;
}
$type = (string) $type; // Prevent PHP bug.
switch ($type)
{
case 'role':
$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = '" . $this->db->sql_escape($name) . "'";
$this->db->sql_query($sql);
$role_id = (int) $this->db->sql_fetchfield('role_id');
if (!$role_id)
{
throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $name);
}
$sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . '
WHERE ' . $this->db->sql_in_set('auth_option_id', $to_remove);
$this->db->sql_query($sql);
break;
case 'group':
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "
WHERE group_name = '" . $this->db->sql_escape($name) . "'";
$this->db->sql_query($sql);
$group_id = (int) $this->db->sql_fetchfield('group_id');
if (!$group_id)
{
throw new phpbb_db_migration_exception('GROUP_NOT_EXIST', $name);
}
// If the group has a role set for them we will remove the requested permissions from that role.
$sql = 'SELECT auth_role_id
FROM ' . ACL_GROUPS_TABLE . '
WHERE group_id = ' . $group_id . '
AND auth_role_id <> 0';
$this->db->sql_query($sql);
$role_id = (int) $this->db->sql_fetchfield('auth_role_id');
if ($role_id)
{
$sql = 'SELECT role_name
FROM ' . ACL_ROLES_TABLE . '
WHERE role_id = ' . $role_id;
$this->db->sql_query($sql);
$role_name = $this->db->sql_fetchfield('role_name');
return $this->permission_unset($role_name, $auth_option, 'role');
}
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
WHERE ' . $this->db->sql_in_set('auth_option_id', $to_remove);
$this->db->sql_query($sql);
break;
}
$this->auth->acl_clear_prefetch();
}
/**
* {@inheritdoc}
*/
public function reverse()
{
$arguments = func_get_args();
$original_call = array_shift($arguments);
$call = false;
switch ($original_call)
{
case 'add':
$call = 'remove';
break;
case 'remove':
$call = 'add';
break;
case 'permission_set':
$call = 'permission_unset';
break;
case 'permission_unset':
$call = 'permission_set';
break;
case 'role_add':
$call = 'role_remove';
break;
case 'role_remove':
$call = 'role_add';
break;
case 'role_update':
// Set to the original value if the current value is what we compared to originally
$arguments = array(
$arguments[1],
$arguments[0],
);
break;
}
if ($call)
{
return call_user_func_array(array(&$this, $call), $arguments);
}
}
}

View file

@ -0,0 +1,764 @@
<?php
/**
*
* @package db
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* The migrator is responsible for applying new migrations in the correct order.
*
* @package db
*/
class phpbb_db_migrator
{
/** @var phpbb_config */
protected $config;
/** @var phpbb_db_driver */
protected $db;
/** @var phpbb_db_tools */
protected $db_tools;
/** @var string */
protected $table_prefix;
/** @var string */
protected $phpbb_root_path;
/** @var string */
protected $php_ext;
/** @var string */
protected $migrations_table;
/**
* State of all migrations
*
* (SELECT * FROM migrations table)
*
* @var array
*/
protected $migration_state = array();
/**
* Array of all migrations available to be run
*
* @var array
*/
protected $migrations = array();
/**
* 'name' and 'class' of the last migration run
*
* @var array
*/
public $last_run_migration = false;
/**
* Constructor of the database migrator
*/
public function __construct(phpbb_config $config, phpbb_db_driver $db, phpbb_db_tools $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tools)
{
$this->config = $config;
$this->db = $db;
$this->db_tools = $db_tools;
$this->migrations_table = $migrations_table;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->table_prefix = $table_prefix;
foreach ($tools as $tool)
{
$this->tools[$tool->get_name()] = $tool;
}
$this->load_migration_state();
}
/**
* Loads all migrations and their application state from the database.
*
* @return null
*/
public function load_migration_state()
{
$this->migration_state = array();
$sql = "SELECT *
FROM " . $this->migrations_table;
$result = $this->db->sql_query($sql);
while ($migration = $this->db->sql_fetchrow($result))
{
$this->migration_state[$migration['migration_name']] = $migration;
$this->migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']);
}
$this->db->sql_freeresult($result);
}
/**
* Sets the list of available migration class names to the given array.
*
* @param array $class_names An array of migration class names
* @return null
*/
public function set_migrations($class_names)
{
$this->migrations = $class_names;
}
/**
* This function adds all migrations in a specified directory to the migrations table
*
* THIS SHOULD NOT GENERALLY BE USED! THIS IS FOR THE PHPBB INSTALLER.
* THIS WILL THROW ERRORS IF MIGRATIONS ALREADY EXIST IN THE TABLE, DO NOT CALL MORE THAN ONCE!
*
* @param string $path Path to migration data files
* @param bool $recursive Set to true to also load data files from subdirectories
* @return null
*/
public function populate_migrations_from_directory($path, $recursive = true)
{
$existing_migrations = $this->migrations;
$this->migrations = array();
$this->load_migrations($path, true, $recursive);
foreach ($this->migrations as $name)
{
if ($this->migration_state($name) === false)
{
$state = array(
'migration_depends_on' => $name::depends_on(),
'migration_schema_done' => true,
'migration_data_done' => true,
'migration_data_state' => '',
'migration_start_time' => time(),
'migration_end_time' => time(),
);
$this->insert_migration($name, $state);
}
}
$this->migrations = $existing_migrations;
}
/**
* Load migration data files from a directory
*
* Migration data files loaded with this function MUST contain
* ONLY ONE class in them (or an exception will be thrown).
*
* @param string $path Path to migration data files
* @param bool $check_fulfillable If TRUE (default), we will check
* if all of the migrations are fulfillable after loading them.
* If FALSE, we will not check. You SHOULD check at least once
* to prevent errors (if including multiple directories, check
* with the last call to prevent throwing errors unnecessarily).
* @param bool $recursive Set to true to also load data files from subdirectories
* @return array Array of migration names
*/
public function load_migrations($path, $check_fulfillable = true, $recursive = true)
{
if (!is_dir($path))
{
throw new phpbb_db_migration_exception('DIRECTORY INVALID', $path);
}
$handle = opendir($path);
while (($file = readdir($handle)) !== false)
{
if ($file == '.' || $file == '..')
{
continue;
}
// Recursion through subdirectories
if (is_dir($path . $file) && $recursive)
{
$this->load_migrations($path . $file . '/', $check_fulfillable, $recursive);
}
if (strpos($file, '_') !== 0 && strrpos($file, '.' . $this->php_ext) === (strlen($file) - strlen($this->php_ext) - 1))
{
// We try to find what class existed by comparing the classes declared before and after including the file.
$declared_classes = get_declared_classes();
include ($path . $file);
$added_classes = array_diff(get_declared_classes(), $declared_classes);
if (
// If two classes have been added and phpbb_db_migration is one of them, we've only added one real migration
!(sizeof($added_classes) == 2 && in_array('phpbb_db_migration', $added_classes)) &&
// Otherwise there should only be one class added
sizeof($added_classes) != 1
)
{
throw new phpbb_db_migration_exception('MIGRATION DATA FILE INVALID', $path . $file);
}
$name = array_pop($added_classes);
if (!in_array($name, $this->migrations))
{
$this->migrations[] = $name;
}
}
}
if ($check_fulfillable)
{
foreach ($this->migrations as $name)
{
$unfulfillable = $this->unfulfillable($name);
if ($unfulfillable !== false)
{
throw new phpbb_db_migration_exception('MIGRATION_NOT_FULFILLABLE', $name, $unfulfillable);
}
}
}
return $this->migrations;
}
/**
* Runs a single update step from the next migration to be applied.
*
* The update step can either be a schema or a (partial) data update. To
* check if update() needs to be called again use the finished() method.
*
* @return null
*/
public function update()
{
foreach ($this->migrations as $name)
{
if (!isset($this->migration_state[$name]) ||
!$this->migration_state[$name]['migration_schema_done'] ||
!$this->migration_state[$name]['migration_data_done'])
{
if (!$this->try_apply($name))
{
continue;
}
else
{
return;
}
}
}
}
/**
* Attempts to apply a step of the given migration or one of its dependencies
*
* @param string The class name of the migration
* @return bool Whether any update step was successfully run
*/
protected function try_apply($name)
{
if (!class_exists($name))
{
return false;
}
$migration = $this->get_migration($name);
$state = (isset($this->migration_state[$name])) ?
$this->migration_state[$name] :
array(
'migration_depends_on' => $migration->depends_on(),
'migration_schema_done' => false,
'migration_data_done' => false,
'migration_data_state' => '',
'migration_start_time' => 0,
'migration_end_time' => 0,
);
foreach ($state['migration_depends_on'] as $depend)
{
if (!isset($this->migration_state[$depend]) ||
!$this->migration_state[$depend]['migration_schema_done'] ||
!$this->migration_state[$depend]['migration_data_done'])
{
return $this->try_apply($depend);
}
}
$this->last_run_migration = array(
'name' => $name,
'class' => $migration,
);
if ($migration->effectively_installed())
{
$state = array(
'migration_depends_on' => $migration->depends_on(),
'migration_schema_done' => true,
'migration_data_done' => true,
'migration_data_state' => '',
'migration_start_time' => 0,
'migration_end_time' => 0,
);
}
else
{
if (!isset($this->migration_state[$name]))
{
$state['migration_start_time'] = time();
$this->insert_migration($name, $state);
}
}
if (!$state['migration_schema_done'])
{
$this->apply_schema_changes($migration->update_schema());
$state['migration_schema_done'] = true;
}
else if (!$state['migration_data_done'])
{
try
{
$result = $this->process_data_step($migration->update_data(), $state['migration_data_state']);
$state['migration_data_state'] = ($result === true) ? '' : $result;
$state['migration_data_done'] = ($result === true);
$state['migration_end_time'] = ($result === true) ? time() : 0;
}
catch (phpbb_db_migration_exception $e)
{
// Revert the schema changes
$this->revert($name);
// Rethrow exception
throw $e;
}
}
$insert = $state;
$insert['migration_depends_on'] = serialize($state['migration_depends_on']);
$sql = 'UPDATE ' . $this->migrations_table . '
SET ' . $this->db->sql_build_array('UPDATE', $insert) . "
WHERE migration_name = '" . $this->db->sql_escape($name) . "'";
$this->db->sql_query($sql);
$this->migration_state[$name] = $state;
return true;
}
/**
* Runs a single revert step from the last migration installed
*
* YOU MUST ADD/SET ALL MIGRATIONS THAT COULD BE DEPENDENT ON THE MIGRATION TO REVERT TO BEFORE CALLING THIS METHOD!
* The revert step can either be a schema or a (partial) data revert. To
* check if revert() needs to be called again use the migration_state() method.
*
* @param string $migration String migration name to revert (including any that depend on this migration)
* @return null
*/
public function revert($migration)
{
if (!isset($this->migration_state[$migration]))
{
// Not installed
return;
}
foreach ($this->migration_state as $name => $state)
{
if (!empty($state['migration_depends_on']) && in_array($migration, $state['migration_depends_on']))
{
$this->revert($name);
}
}
$this->try_revert($migration);
}
/**
* Attempts to revert a step of the given migration or one of its dependencies
*
* @param string The class name of the migration
* @return bool Whether any update step was successfully run
*/
protected function try_revert($name)
{
if (!class_exists($name))
{
return false;
}
$migration = $this->get_migration($name);
$state = $this->migration_state[$name];
$this->last_run_migration = array(
'name' => $name,
'class' => $migration,
);
if ($state['migration_data_done'])
{
if ($state['migration_data_state'] !== 'revert_data')
{
$result = $this->process_data_step($migration->update_data(), $state['migration_data_state'], true);
$state['migration_data_state'] = ($result === true) ? 'revert_data' : $result;
}
else
{
$result = $this->process_data_step($migration->revert_data(), $state['migration_data_state'], false);
$state['migration_data_state'] = ($result === true) ? '' : $result;
$state['migration_data_done'] = ($result === true) ? false : true;
}
$insert = $state;
$insert['migration_depends_on'] = serialize($state['migration_depends_on']);
$sql = 'UPDATE ' . $this->migrations_table . '
SET ' . $this->db->sql_build_array('UPDATE', $insert) . "
WHERE migration_name = '" . $this->db->sql_escape($name) . "'";
$this->db->sql_query($sql);
$this->migration_state[$name] = $state;
}
else
{
$this->apply_schema_changes($migration->revert_schema());
$sql = 'DELETE FROM ' . $this->migrations_table . "
WHERE migration_name = '" . $this->db->sql_escape($name) . "'";
$this->db->sql_query($sql);
unset($this->migration_state[$name]);
}
return true;
}
/**
* Apply schema changes from a migration
*
* Just calls db_tools->perform_schema_changes
*
* @param array $schema_changes from migration
*/
protected function apply_schema_changes($schema_changes)
{
$this->db_tools->perform_schema_changes($schema_changes);
}
/**
* Process the data step of the migration
*
* @param array $steps The steps to run
* @param bool|string $state Current state of the migration
* @param bool $revert true to revert a data step
* @return bool|string migration state. True if completed, serialized array if not finished
*/
protected function process_data_step($steps, $state, $revert = false)
{
$state = ($state) ? unserialize($state) : false;
foreach ($steps as $step_identifier => $step)
{
$last_result = false;
if ($state)
{
// Continue until we reach the step that matches the last step called
if ($state['step'] != $step_identifier)
{
continue;
}
// We send the result from last time to the callable function
$last_result = $state['result'];
// Set state to false since we reached the point we were at
$state = false;
}
try
{
// Result will be null or true if everything completed correctly
$result = $this->run_step($step, $last_result, $revert);
if ($result !== null && $result !== true)
{
return serialize(array(
'result' => $result,
'step' => $step_identifier,
));
}
}
catch (phpbb_db_migration_exception $e)
{
// We should try rolling back here
foreach ($steps as $reverse_step_identifier => $reverse_step)
{
// If we've reached the current step we can break because we reversed everything that was run
if ($reverse_step_identifier == $step_identifier)
{
break;
}
// Reverse the step that was run
$result = $this->run_step($reverse_step, false, !$revert);
}
// rethrow the exception
throw $e;
}
}
return true;
}
/**
* Run a single step
*
* An exception should be thrown if an error occurs
*
* @param mixed $step Data step from migration
* @param mixed $last_result Result to pass to the callable (only for 'custom' method)
* @param bool $reverse False to install, True to attempt uninstallation by reversing the call
* @return null
*/
protected function run_step($step, $last_result = false, $reverse = false)
{
$callable_and_parameters = $this->get_callable_from_step($step, $last_result, $reverse);
if ($callable_and_parameters === false)
{
return;
}
$callable = $callable_and_parameters[0];
$parameters = $callable_and_parameters[1];
return call_user_func_array($callable, $parameters);
}
/**
* Get a callable statement from a data step
*
* @param array $step Data step from migration
* @param mixed $last_result Result to pass to the callable (only for 'custom' method)
* @param bool $reverse False to install, True to attempt uninstallation by reversing the call
* @return array Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters
*/
protected function get_callable_from_step(array $step, $last_result = false, $reverse = false)
{
$type = $step[0];
$parameters = $step[1];
$parts = explode('.', $type);
$class = $parts[0];
$method = false;
if (isset($parts[1]))
{
$method = $parts[1];
}
switch ($class)
{
case 'if':
if (!isset($parameters[0]))
{
throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_MISSING_CONDITION', $step);
}
if (!isset($parameters[1]))
{
throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_MISSING_STEP', $step);
}
$condition = $parameters[0];
if (!$condition)
{
return false;
}
$step = $parameters[1];
return $this->get_callable_from_step($step);
break;
case 'custom':
if (!is_callable($parameters[0]))
{
throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_CUSTOM_NOT_CALLABLE', $step);
}
return array(
$parameters[0],
array($last_result),
);
break;
default:
if (!$method)
{
throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_UNKNOWN_TYPE', $step);
}
if (!isset($this->tools[$class]))
{
throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_UNDEFINED_TOOL', $step);
}
if (!method_exists(get_class($this->tools[$class]), $method))
{
throw new phpbb_db_migration_exception('MIGRATION_INVALID_DATA_UNDEFINED_METHOD', $step);
}
// Attempt to reverse operations
if ($reverse)
{
array_unshift($parameters, $method);
return array(
array($this->tools[$class], 'reverse'),
$parameters,
);
}
return array(
array($this->tools[$class], $method),
$parameters,
);
break;
}
}
/**
* Insert migration row into the database
*
* @param string $name Name of the migration
* @param array $state
* @return null
*/
protected function insert_migration($name, $state)
{
$migration_row = $state;
$migration_row['migration_name'] = $name;
$migration_row['migration_depends_on'] = serialize($state['migration_depends_on']);
$sql = 'INSERT INTO ' . $this->migrations_table . '
' . $this->db->sql_build_array('INSERT', $migration_row);
$this->db->sql_query($sql);
$this->migration_state[$name] = $state;
}
/**
* Checks if a migration's dependencies can even theoretically be satisfied.
*
* @param string $name The class name of the migration
* @return bool|string False if fulfillable, string of missing migration name if unfulfillable
*/
public function unfulfillable($name)
{
if (isset($this->migration_state[$name]))
{
return false;
}
if (!class_exists($name))
{
return $name;
}
$migration = $this->get_migration($name);
$depends = $migration->depends_on();
foreach ($depends as $depend)
{
$unfulfillable = $this->unfulfillable($depend);
if ($unfulfillable !== false)
{
return $unfulfillable;
}
}
return false;
}
/**
* Checks whether all available, fulfillable migrations have been applied.
*
* @return bool Whether the migrations have been applied
*/
public function finished()
{
foreach ($this->migrations as $name)
{
if (!isset($this->migration_state[$name]))
{
// skip unfulfillable migrations, but fulfillables mean we
// are not finished yet
if ($this->unfulfillable($name) !== false)
{
continue;
}
return false;
}
$migration = $this->migration_state[$name];
if (!$migration['migration_schema_done'] || !$migration['migration_data_done'])
{
return false;
}
}
return true;
}
/**
* Gets a migration state (whether it is installed and to what extent)
*
* @param string $migration String migration name to check if it is installed
* @return bool|array False if the migration has not at all been installed, array
*/
public function migration_state($migration)
{
if (!isset($this->migration_state[$migration]))
{
return false;
}
return $this->migration_state[$migration];
}
/**
* Helper to get a migration
*
* @param string $name Name of the migration
* @return phpbb_db_migration
*/
protected function get_migration($name)
{
return new $name($this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix);
}
}

View file

@ -15,6 +15,8 @@ if (!defined('IN_PHPBB'))
exit;
}
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* A base class for extensions without custom enable/disable/purge code.
*
@ -22,6 +24,19 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_extension_base implements phpbb_extension_interface
{
/** @var ContainerInterface */
protected $container;
/**
* Constructor
*
* @param ContainerInterface $container Container object
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
/**
* Single enable step that does nothing
*

View file

@ -15,6 +15,8 @@ if (!defined('IN_PHPBB'))
exit;
}
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* The extension manager provides means to activate/deactivate extensions.
*
@ -22,8 +24,12 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_extension_manager
{
/** @var ContainerInterface */
protected $container;
protected $db;
protected $config;
protected $migrator;
protected $cache;
protected $php_ext;
protected $extensions;
@ -34,6 +40,7 @@ class phpbb_extension_manager
/**
* Creates a manager and loads information from database
*
* @param ContainerInterface $container A container
* @param phpbb_db_driver $db A database connection
* @param phpbb_config $config phpbb_config
* @param string $extension_table The name of the table holding extensions
@ -42,11 +49,13 @@ class phpbb_extension_manager
* @param phpbb_cache_driver_interface $cache A cache instance or null
* @param string $cache_name The name of the cache variable, defaults to _ext
*/
public function __construct(phpbb_db_driver $db, phpbb_config $config, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext')
public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, phpbb_db_migrator $migrator, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext')
{
$this->container = $container;
$this->phpbb_root_path = $phpbb_root_path;
$this->db = $db;
$this->config = $config;
$this->migrator = $migrator;
$this->cache = $cache;
$this->php_ext = $php_ext;
$this->extension_table = $extension_table;
@ -126,11 +135,11 @@ class phpbb_extension_manager
if (class_exists($extension_class_name))
{
return new $extension_class_name;
return new $extension_class_name($this->container);
}
else
{
return new phpbb_extension_base;
return new phpbb_extension_base($this->container);
}
}
@ -166,6 +175,12 @@ class phpbb_extension_manager
$old_state = (isset($this->extensions[$name]['ext_state'])) ? unserialize($this->extensions[$name]['ext_state']) : false;
// Returns false if not completed
if (!$this->handle_migrations($name, 'enable'))
{
return true;
}
$extension = $this->get_extension($name);
$state = $extension->enable_step($old_state);
@ -317,6 +332,12 @@ class phpbb_extension_manager
$old_state = unserialize($this->extensions[$name]['ext_state']);
// Returns false if not completed
if (!$this->handle_migrations($name, 'purge'))
{
return true;
}
$extension = $this->get_extension($name);
$state = $extension->purge_step($old_state);
@ -490,4 +511,58 @@ class phpbb_extension_manager
{
return new phpbb_extension_finder($this, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder');
}
/**
* Handle installing/reverting migrations
*
* @param string $extension_name Name of the extension
* @param string $mode enable or purge
* @return bool True if completed, False if not completed
*/
protected function handle_migrations($extension_name, $mode)
{
$migrations_path = $this->phpbb_root_path . $this->get_extension_path($extension_name) . 'migrations/';
if (!file_exists($migrations_path) || !is_dir($migrations_path))
{
return true;
}
$migrations = $this->migrator->load_migrations($migrations_path);
// What is a safe limit of execution time? Half the max execution time should be safe.
$safe_time_limit = (ini_get('max_execution_time') / 2);
$start_time = time();
if ($mode == 'enable')
{
while (!$this->migrator->finished())
{
$this->migrator->update();
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
if ((time() - $start_time) >= $safe_time_limit)
{
return false;
}
}
}
else if ($mode == 'purge')
{
foreach ($migrations as $migration)
{
while ($this->migrator->migration_state($migration) !== false)
{
$this->migrator->revert($migration);
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
if ((time() - $start_time) >= $safe_time_limit)
{
return false;
}
}
}
}
return true;
}
}

View file

@ -97,7 +97,18 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, $
}
/**
* Set config value. Creates missing config entry.
* Sets a configuration option's value.
*
* Please note that this function does not update the is_dynamic value for
* an already existing config option.
*
* @param string $config_name The configuration option's name
* @param string $config_value New configuration value
* @param bool $is_dynamic Whether this variable should be cached (false) or
* if it changes too frequently (true) to be
* efficiently cached.
*
* @return null
*
* @deprecated
*/
@ -119,7 +130,15 @@ function set_config($config_name, $config_value, $is_dynamic = false, phpbb_conf
}
/**
* Set dynamic config value with arithmetic operation.
* Increments an integer config value directly in the database.
*
* @param string $config_name The configuration option's name
* @param int $increment Amount to increment by
* @param bool $is_dynamic Whether this variable should be cached (false) or
* if it changes too frequently (true) to be
* efficiently cached.
*
* @return null
*
* @deprecated
*/
@ -5562,7 +5581,7 @@ function phpbb_convert_30_dbms_to_31($dbms)
/*
$reflection = new \ReflectionClass($dbms);
if ($reflection->isSubclassOf('phpbb_db_driver'))
{
return $dbms;

View file

@ -443,6 +443,13 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
}
break;
case 'email':
if (!preg_match('/^' . get_preg_expression('email') . '$/i', $cfg_array[$config_name]))
{
$error[] = $user->lang['EMAIL_INVALID_EMAIL'];
}
break;
// Absolute path
case 'script_path':
if (!$cfg_array[$config_name])

View file

@ -392,6 +392,28 @@ class messenger
}
}
/**
* Generates a valid message id to be used in emails
*
* @return string message id
*/
function generate_message_id()
{
global $config;
$domain = 'phpbb.generated';
if ($config['server_name'])
{
$domain = $config['server_name'];
}
else if (!empty($_SERVER['SERVER_NAME']))
{
$domain = $_SERVER['SERVER_NAME'];
}
return md5(unique_id(time())) . '@' . $domain;
}
/**
* Return email header
*/
@ -418,7 +440,7 @@ class messenger
$headers[] = 'Return-Path: <' . $config['board_email'] . '>';
$headers[] = 'Sender: <' . $config['board_email'] . '>';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Message-ID: <' . md5(unique_id(time())) . '@' . $config['server_name'] . '>';
$headers[] = 'Message-ID: <' . $this->generate_message_id() . '>';
$headers[] = 'Date: ' . date('r', time());
$headers[] = 'Content-Type: text/plain; charset=UTF-8'; // format=flowed
$headers[] = 'Content-Transfer-Encoding: 8bit'; // 7bit

View file

@ -94,7 +94,7 @@ class phpbb_search_base
*
* @return int SEARCH_RESULT_NOT_IN_CACHE or SEARCH_RESULT_IN_CACHE or SEARCH_RESULT_INCOMPLETE
*/
function obtain_ids($search_key, &$result_count, &$id_ary, $start, $per_page, $sort_dir)
function obtain_ids($search_key, &$result_count, &$id_ary, &$start, $per_page, $sort_dir)
{
global $cache;
@ -109,6 +109,19 @@ class phpbb_search_base
$reverse_ids = ($stored_ids[-2] != $sort_dir) ? true : false;
$complete = true;
// Change start parameter in case out of bounds
if ($result_count)
{
if ($start < 0)
{
$start = 0;
}
else if ($start >= $result_count)
{
$start = floor(($result_count - 1) / $per_page) * $per_page;
}
}
// change the start to the actual end of the current request if the sort direction differs
// from the dirction in the cache and reverse the ids later
if ($reverse_ids)

View file

@ -353,7 +353,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
*/
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{
// No keywords? No posts
if (!$this->search_query)
@ -375,6 +375,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
implode(',', $author_ary)
)));
if ($start < 0)
{
$start = 0;
}
// try reading the results from cache
$result_count = 0;
if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE)
@ -488,16 +493,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
$id_ary = array_unique($id_ary);
if (!sizeof($id_ary))
{
return false;
}
// if the total result count is not cached yet, retrieve it from the db
if (!$result_count)
{
$sql = 'SELECT FOUND_ROWS() as result_count';
$result = $this->db->sql_query($sql);
$sql_found_rows = 'SELECT FOUND_ROWS() as result_count';
$result = $this->db->sql_query($sql_found_rows);
$result_count = (int) $this->db->sql_fetchfield('result_count');
$this->db->sql_freeresult($result);
@ -507,6 +507,21 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
}
}
if ($start >= $result_count)
{
$start = floor(($result_count - 1) / $per_page) * $per_page;
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[$field];
}
$this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
}
// store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page
$this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir);
$id_ary = array_slice($id_ary, 0, (int) $per_page);
@ -533,7 +548,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
*/
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{
// No author? No posts
if (!sizeof($author_ary))
@ -557,6 +572,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
$author_name,
)));
if ($start < 0)
{
$start = 0;
}
// try reading the results from cache
$result_count = 0;
if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE)
@ -662,8 +682,8 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
// retrieve the total result count if needed
if (!$result_count)
{
$sql = 'SELECT FOUND_ROWS() as result_count';
$result = $this->db->sql_query($sql);
$sql_found_rows = 'SELECT FOUND_ROWS() as result_count';
$result = $this->db->sql_query($sql_found_rows);
$result_count = (int) $this->db->sql_fetchfield('result_count');
$this->db->sql_freeresult($result);
@ -673,6 +693,20 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
}
}
if ($start >= $result_count)
{
$start = floor(($result_count - 1) / $per_page) * $per_page;
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[$field];
}
$this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
}
if (sizeof($id_ary))
{
$this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir);

View file

@ -516,7 +516,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
*/
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{
// No keywords? No posts.
if (empty($this->search_query))
@ -855,10 +855,6 @@ class phpbb_search_fulltext_native extends phpbb_search_base
}
$this->db->sql_freeresult($result);
if (!sizeof($id_ary))
{
return false;
}
// if we use mysql and the total result count is not cached yet, retrieve it from the db
if (!$total_results && $is_mysql)
@ -867,14 +863,14 @@ class phpbb_search_fulltext_native extends phpbb_search_base
$sql_array_copy = $sql_array;
$sql_array_copy['SELECT'] = 'SQL_CALC_FOUND_ROWS p.post_id ';
$sql = $this->db->sql_build_query('SELECT', $sql_array_copy);
$sql_calc = $this->db->sql_build_query('SELECT', $sql_array_copy);
unset($sql_array_copy);
$this->db->sql_query($sql);
$this->db->sql_query($sql_calc);
$this->db->sql_freeresult($result);
$sql = 'SELECT FOUND_ROWS() as total_results';
$result = $this->db->sql_query($sql);
$sql_count = 'SELECT FOUND_ROWS() as total_results';
$result = $this->db->sql_query($sql_count);
$total_results = (int) $this->db->sql_fetchfield('total_results');
$this->db->sql_freeresult($result);
@ -884,6 +880,20 @@ class phpbb_search_fulltext_native extends phpbb_search_base
}
}
if ($start >= $total_results)
{
$start = floor(($total_results - 1) / $per_page) * $per_page;
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[(($type == 'posts') ? 'post_id' : 'topic_id')];
}
$this->db->sql_freeresult($result);
}
// store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page
$this->save_ids($search_key, $this->search_query, $author_ary, $total_results, $id_ary, $start, $sort_dir);
$id_ary = array_slice($id_ary, 0, (int) $per_page);
@ -910,7 +920,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
*/
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{
// No author? No posts
if (!sizeof($author_ary))
@ -1096,13 +1106,13 @@ class phpbb_search_fulltext_native extends phpbb_search_base
if (!$total_results && $is_mysql)
{
// Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it.
$sql = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql);
$sql_calc = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql);
$this->db->sql_query($sql);
$this->db->sql_query($sql_calc);
$this->db->sql_freeresult($result);
$sql = 'SELECT FOUND_ROWS() as total_results';
$result = $this->db->sql_query($sql);
$sql_count = 'SELECT FOUND_ROWS() as total_results';
$result = $this->db->sql_query($sql_count);
$total_results = (int) $this->db->sql_fetchfield('total_results');
$this->db->sql_freeresult($result);
@ -1112,6 +1122,19 @@ class phpbb_search_fulltext_native extends phpbb_search_base
}
}
if ($start >= $total_results)
{
$start = floor(($total_results - 1) / $per_page) * $per_page;
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[$field];
}
$this->db->sql_freeresult($result);
}
if (sizeof($id_ary))
{
$this->save_ids($search_key, '', $author_ary, $total_results, $id_ary, $start, $sort_dir);

View file

@ -343,7 +343,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
*/
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{
// No keywords? No posts
if (!$this->search_query)
@ -371,6 +371,11 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
implode(',', $author_ary)
)));
if ($start < 0)
{
$start = 0;
}
// try reading the results from cache
$result_count = 0;
if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE)
@ -495,11 +500,6 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$id_ary = array_unique($id_ary);
if (!sizeof($id_ary))
{
return false;
}
// if the total result count is not cached yet, retrieve it from the db
if (!$result_count)
{
@ -518,6 +518,21 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$this->db->sql_transaction('commit');
if ($start >= $result_count)
{
$start = floor(($result_count - 1) / $per_page) * $per_page;
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = $row[$field];
}
$this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
}
// store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page
$this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir);
$id_ary = array_slice($id_ary, 0, (int) $per_page);
@ -544,7 +559,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
*/
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{
// No author? No posts
if (!sizeof($author_ary))
@ -568,6 +583,11 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$author_name,
)));
if ($start < 0)
{
$start = 0;
}
// try reading the results from cache
$result_count = 0;
if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE)
@ -710,6 +730,20 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$this->db->sql_transaction('commit');
if ($start >= $result_count)
{
$start = floor(($result_count - 1) / $per_page) * $per_page;
$result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[$field];
}
$this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
}
if (sizeof($id_ary))
{
$this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir);

View file

@ -454,7 +454,7 @@ class phpbb_search_fulltext_sphinx
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
*/
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{
// No keywords? No posts.
if (!strlen($this->search_query) && !sizeof($author_ary))
@ -609,6 +609,25 @@ class phpbb_search_fulltext_sphinx
}
}
$result_count = $result['total_found'];
if ($start >= $result_count)
{
$start = floor(($result_count - 1) / $per_page) * $per_page;
$this->sphinx->SetLimits((int) $start, (int) $per_page, SPHINX_MAX_MATCHES);
$result = $this->sphinx->Query($search_query_prefix . str_replace('&quot;', '"', $this->search_query), $this->indexes);
// Could be connection to localhost:9312 failed (errno=111,
// msg=Connection refused) during rotate, retry if so
$retries = SPHINX_CONNECT_RETRIES;
while (!$result && (strpos($this->sphinx->GetLastError(), "errno=111,") !== false) && $retries--)
{
usleep(SPHINX_CONNECT_WAIT_TIME);
$result = $this->sphinx->Query($search_query_prefix . str_replace('&quot;', '"', $this->search_query), $this->indexes);
}
}
$id_ary = array();
if (isset($result['matches']))
{
@ -629,8 +648,6 @@ class phpbb_search_fulltext_sphinx
return false;
}
$result_count = $result['total_found'];
$id_ary = array_slice($id_ary, 0, (int) $per_page);
return $result_count;
@ -878,8 +895,8 @@ class phpbb_search_fulltext_sphinx
<dd><input id="fulltext_sphinx_indexer_mem_limit" type="text" size="4" maxlength="10" name="config[fulltext_sphinx_indexer_mem_limit]" value="' . $this->config['fulltext_sphinx_indexer_mem_limit'] . '" /> ' . $this->user->lang['MIB'] . '</dd>
</dl>
<dl>
<dt><label for="fulltext_sphinx_config_file">' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '</dt>
<dd>' . (($this->config_generate()) ? '<textarea readonly="readonly" rows="6">' . $this->config_file_data . '</textarea>' : $this->config_file_data) . '</dd>
<dt><label for="fulltext_sphinx_config_file">' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE'] . $this->user->lang['COLON'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '</span></dt>
<dd>' . (($this->config_generate()) ? '<textarea readonly="readonly" rows="6" id="sphinx_config_data">' . htmlspecialchars($this->config_file_data) . '</textarea>' : $this->config_file_data) . '</dd>
<dl>
';

View file

@ -346,7 +346,7 @@ class phpbb_session
$session_id = $request->variable('sid', '');
if (defined('NEED_SID') && (empty($session_id) || $this->session_id !== $session_id))
{
send_status_line(401, 'Not authorized');
send_status_line(401, 'Unauthorized');
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
}

View file

@ -50,7 +50,7 @@ class ucp_activate
trigger_error('ALREADY_ACTIVATED');
}
if (($user_row['user_inactive_reason'] == INACTIVE_MANUAL) || $user_row['user_actkey'] != $key)
if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL || $user_row['user_actkey'] !== $key)
{
trigger_error('WRONG_ACTIVATION');
}

View file

@ -353,7 +353,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$message_attachment = 0;
$message_text = $message_subject = '';
if ($to_user_id && $action == 'post')
if ($to_user_id && $to_user_id != ANONYMOUS && $action == 'post')
{
$address_list['u'][$to_user_id] = 'to';
}

View file

@ -241,6 +241,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
'U_ICQ' => ($user_info['user_icq']) ? 'http://www.icq.com/people/' . urlencode($user_info['user_icq']) . '/' : '',
'U_AIM' => ($user_info['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=aim&amp;u=' . $author_id) : '',
'U_YIM' => ($user_info['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($user_info['user_yim']) . '&amp;.src=pg' : '',
'U_MSN' => ($user_info['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=msnm&amp;u=' . $author_id) : '',
'U_JABBER' => ($user_info['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=jabber&amp;u=' . $author_id) : '',
'U_DELETE' => ($auth->acl_get('u_pm_delete')) ? "$url&amp;mode=compose&amp;action=delete&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '',

View file

@ -266,6 +266,7 @@ class ucp_profile
$data = array(
'icq' => request_var('icq', $user->data['user_icq']),
'aim' => request_var('aim', $user->data['user_aim']),
'msn' => request_var('msn', $user->data['user_msnm']),
'yim' => request_var('yim', $user->data['user_yim']),
'jabber' => utf8_normalize_nfc(request_var('jabber', $user->data['user_jabber'], true)),
'website' => request_var('website', $user->data['user_website']),
@ -298,6 +299,7 @@ class ucp_profile
array('string', true, 3, 15),
array('match', true, '#^[0-9]+$#i')),
'aim' => array('string', true, 3, 255),
'msn' => array('string', true, 5, 255),
'jabber' => array(
array('string', true, 5, 255),
array('jabber')),
@ -349,6 +351,7 @@ class ucp_profile
$sql_ary = array(
'user_icq' => $data['icq'],
'user_aim' => $data['aim'],
'user_msnm' => $data['msn'],
'user_yim' => $data['yim'],
'user_jabber' => $data['jabber'],
'user_website' => $data['website'],
@ -420,6 +423,7 @@ class ucp_profile
'ICQ' => $data['icq'],
'YIM' => $data['yim'],
'AIM' => $data['aim'],
'MSN' => $data['msn'],
'JABBER' => $data['jabber'],
'WEBSITE' => $data['website'],
'LOCATION' => $data['location'],

View file

@ -896,6 +896,7 @@ if (!$get_info)
array('user_occ', 'users.user_occ', array('function1' => 'phpbb_set_encoding')),
array('user_website', 'users.user_website', 'validate_website'),
array('user_jabber', '', ''),
array('user_msnm', 'users.user_msnm', array('function1' => 'phpbb_set_encoding')),
array('user_yim', 'users.user_yim', array('function1' => 'phpbb_set_encoding')),
array('user_aim', 'users.user_aim', array('function1' => 'phpbb_set_encoding')),
array('user_icq', 'users.user_icq', array('function1' => 'phpbb_set_encoding')),

View file

@ -685,12 +685,12 @@ function _write_result($no_updates, $errored, $error_ary)
function _add_modules($modules_to_install)
{
global $phpbb_root_path, $phpEx, $db, $phpbb_extension_manager, $config;
global $phpbb_root_path, $phpEx, $db, $phpbb_extension_manager, $config, $phpbb_container;
// modules require an extension manager
if (empty($phpbb_extension_manager))
{
$phpbb_extension_manager = new phpbb_extension_manager($db, $config, EXT_TABLE, $phpbb_root_path, ".$phpEx");
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
}
include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);
@ -1196,11 +1196,6 @@ function database_update_info()
'user_timezone' => array('VCHAR:100', ''),
),
),
'drop_columns' => array(
USERS_TABLE => array(
'user_msnm',
),
),
),
);
}

View file

@ -1456,12 +1456,12 @@ class install_install extends module
*/
function add_modules($mode, $sub)
{
global $db, $lang, $phpbb_root_path, $phpEx, $phpbb_extension_manager, $config;
global $db, $lang, $phpbb_root_path, $phpEx, $phpbb_extension_manager, $config, $phpbb_container;
// modules require an extension manager
if (empty($phpbb_extension_manager))
{
$phpbb_extension_manager = new phpbb_extension_manager($db, $config, EXT_TABLE, $phpbb_root_path, ".$phpEx");
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
}
include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);
@ -2098,7 +2098,7 @@ class install_install extends module
),
'ACP_CAT_CUSTOMISE' => array(
'ACP_STYLE_MANAGEMENT',
'ACP_EXTENSIONS_MANAGEMENT',
'ACP_EXTENSION_MANAGEMENT',
'ACP_LANGUAGE',
),
'ACP_CAT_MAINTENANCE' => array(

View file

@ -586,6 +586,20 @@ CREATE TABLE phpbb_moderator_cache (
CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache(display_on_index);;
CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache(forum_id);;
# Table: 'phpbb_migrations'
CREATE TABLE phpbb_migrations (
migration_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
migration_depends_on BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL,
migration_schema_done INTEGER DEFAULT 0 NOT NULL,
migration_data_done INTEGER DEFAULT 0 NOT NULL,
migration_data_state BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL,
migration_start_time INTEGER DEFAULT 0 NOT NULL,
migration_end_time INTEGER DEFAULT 0 NOT NULL
);;
ALTER TABLE phpbb_migrations ADD PRIMARY KEY (migration_name);;
# Table: 'phpbb_modules'
CREATE TABLE phpbb_modules (
module_id INTEGER NOT NULL,
@ -1284,6 +1298,7 @@ CREATE TABLE phpbb_users (
user_icq VARCHAR(15) CHARACTER SET NONE DEFAULT '' NOT NULL,
user_aim VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
user_yim VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
user_msnm VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
user_jabber VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
user_website VARCHAR(200) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
user_occ BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL,

View file

@ -716,6 +716,28 @@ CREATE INDEX [forum_id] ON [phpbb_moderator_cache]([forum_id]) ON [PRIMARY]
GO
/*
Table: 'phpbb_migrations'
*/
CREATE TABLE [phpbb_migrations] (
[migration_name] [varchar] (255) DEFAULT ('') NOT NULL ,
[migration_depends_on] [varchar] (8000) DEFAULT ('') NOT NULL ,
[migration_schema_done] [int] DEFAULT (0) NOT NULL ,
[migration_data_done] [int] DEFAULT (0) NOT NULL ,
[migration_data_state] [varchar] (8000) DEFAULT ('') NOT NULL ,
[migration_start_time] [int] DEFAULT (0) NOT NULL ,
[migration_end_time] [int] DEFAULT (0) NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [phpbb_migrations] WITH NOCHECK ADD
CONSTRAINT [PK_phpbb_migrations] PRIMARY KEY CLUSTERED
(
[migration_name]
) ON [PRIMARY]
GO
/*
Table: 'phpbb_modules'
*/
@ -1568,6 +1590,7 @@ CREATE TABLE [phpbb_users] (
[user_icq] [varchar] (15) DEFAULT ('') NOT NULL ,
[user_aim] [varchar] (255) DEFAULT ('') NOT NULL ,
[user_yim] [varchar] (255) DEFAULT ('') NOT NULL ,
[user_msnm] [varchar] (255) DEFAULT ('') NOT NULL ,
[user_jabber] [varchar] (255) DEFAULT ('') NOT NULL ,
[user_website] [varchar] (200) DEFAULT ('') NOT NULL ,
[user_occ] [varchar] (4000) DEFAULT ('') NOT NULL ,

View file

@ -410,6 +410,19 @@ CREATE TABLE phpbb_moderator_cache (
);
# Table: 'phpbb_migrations'
CREATE TABLE phpbb_migrations (
migration_name varbinary(255) DEFAULT '' NOT NULL,
migration_depends_on blob NOT NULL,
migration_schema_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
migration_data_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
migration_data_state blob NOT NULL,
migration_start_time int(11) UNSIGNED DEFAULT '0' NOT NULL,
migration_end_time int(11) UNSIGNED DEFAULT '0' NOT NULL,
PRIMARY KEY (migration_name)
);
# Table: 'phpbb_modules'
CREATE TABLE phpbb_modules (
module_id mediumint(8) UNSIGNED NOT NULL auto_increment,
@ -932,6 +945,7 @@ CREATE TABLE phpbb_users (
user_icq varbinary(15) DEFAULT '' NOT NULL,
user_aim blob NOT NULL,
user_yim blob NOT NULL,
user_msnm blob NOT NULL,
user_jabber blob NOT NULL,
user_website blob NOT NULL,
user_occ blob NOT NULL,

View file

@ -410,6 +410,19 @@ CREATE TABLE phpbb_moderator_cache (
) CHARACTER SET `utf8` COLLATE `utf8_bin`;
# Table: 'phpbb_migrations'
CREATE TABLE phpbb_migrations (
migration_name varchar(255) DEFAULT '' NOT NULL,
migration_depends_on text NOT NULL,
migration_schema_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
migration_data_done tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
migration_data_state text NOT NULL,
migration_start_time int(11) UNSIGNED DEFAULT '0' NOT NULL,
migration_end_time int(11) UNSIGNED DEFAULT '0' NOT NULL,
PRIMARY KEY (migration_name)
) CHARACTER SET `utf8` COLLATE `utf8_bin`;
# Table: 'phpbb_modules'
CREATE TABLE phpbb_modules (
module_id mediumint(8) UNSIGNED NOT NULL auto_increment,
@ -932,6 +945,7 @@ CREATE TABLE phpbb_users (
user_icq varchar(15) DEFAULT '' NOT NULL,
user_aim varchar(255) DEFAULT '' NOT NULL,
user_yim varchar(255) DEFAULT '' NOT NULL,
user_msnm varchar(255) DEFAULT '' NOT NULL,
user_jabber varchar(255) DEFAULT '' NOT NULL,
user_website varchar(200) DEFAULT '' NOT NULL,
user_occ text NOT NULL,

View file

@ -798,6 +798,22 @@ CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache (display_on
CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id)
/
/*
Table: 'phpbb_migrations'
*/
CREATE TABLE phpbb_migrations (
migration_name varchar2(255) DEFAULT '' ,
migration_depends_on clob DEFAULT '' ,
migration_schema_done number(1) DEFAULT '0' NOT NULL,
migration_data_done number(1) DEFAULT '0' NOT NULL,
migration_data_state clob DEFAULT '' ,
migration_start_time number(11) DEFAULT '0' NOT NULL,
migration_end_time number(11) DEFAULT '0' NOT NULL,
CONSTRAINT pk_phpbb_migrations PRIMARY KEY (migration_name)
)
/
/*
Table: 'phpbb_modules'
*/
@ -1680,6 +1696,7 @@ CREATE TABLE phpbb_users (
user_icq varchar2(15) DEFAULT '' ,
user_aim varchar2(765) DEFAULT '' ,
user_yim varchar2(765) DEFAULT '' ,
user_msnm varchar2(765) DEFAULT '' ,
user_jabber varchar2(765) DEFAULT '' ,
user_website varchar2(600) DEFAULT '' ,
user_occ clob DEFAULT '' ,

View file

@ -572,6 +572,21 @@ CREATE TABLE phpbb_moderator_cache (
CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache (display_on_index);
CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id);
/*
Table: 'phpbb_migrations'
*/
CREATE TABLE phpbb_migrations (
migration_name varchar(255) DEFAULT '' NOT NULL,
migration_depends_on varchar(8000) DEFAULT '' NOT NULL,
migration_schema_done INT2 DEFAULT '0' NOT NULL CHECK (migration_schema_done >= 0),
migration_data_done INT2 DEFAULT '0' NOT NULL CHECK (migration_data_done >= 0),
migration_data_state varchar(8000) DEFAULT '' NOT NULL,
migration_start_time INT4 DEFAULT '0' NOT NULL CHECK (migration_start_time >= 0),
migration_end_time INT4 DEFAULT '0' NOT NULL CHECK (migration_end_time >= 0),
PRIMARY KEY (migration_name)
);
/*
Table: 'phpbb_modules'
*/
@ -1182,6 +1197,7 @@ CREATE TABLE phpbb_users (
user_icq varchar(15) DEFAULT '' NOT NULL,
user_aim varchar(255) DEFAULT '' NOT NULL,
user_yim varchar(255) DEFAULT '' NOT NULL,
user_msnm varchar(255) DEFAULT '' NOT NULL,
user_jabber varchar(255) DEFAULT '' NOT NULL,
user_website varchar(200) DEFAULT '' NOT NULL,
user_occ varchar(4000) DEFAULT '' NOT NULL,

View file

@ -454,10 +454,10 @@ INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id,
INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_subject, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents, forum_flags) VALUES ('{L_FORUMS_TEST_FORUM_TITLE}', '{L_FORUMS_TEST_FORUM_DESC}', 2, 3, 1, 1, 1, 1, 1, 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, '', '', '', '', '', '', '', 0, 0, '', 48);
# -- Users / Anonymous user
INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', 0);
INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0);
# -- username: Admin password: admin (change this or remove it once everything is working!)
INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '');
INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) VALUES (3, 5, 'Admin', 'admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
# -- Groups
INSERT INTO phpbb_groups (group_name, group_type, group_founder_manage, group_colour, group_legend, group_teampage, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('GUESTS', 3, 0, '', 0, 0, '', '', '', 5);

View file

@ -398,6 +398,19 @@ CREATE TABLE phpbb_moderator_cache (
CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache (display_on_index);
CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id);
# Table: 'phpbb_migrations'
CREATE TABLE phpbb_migrations (
migration_name varchar(255) NOT NULL DEFAULT '',
migration_depends_on text(65535) NOT NULL DEFAULT '',
migration_schema_done INTEGER UNSIGNED NOT NULL DEFAULT '0',
migration_data_done INTEGER UNSIGNED NOT NULL DEFAULT '0',
migration_data_state text(65535) NOT NULL DEFAULT '',
migration_start_time INTEGER UNSIGNED NOT NULL DEFAULT '0',
migration_end_time INTEGER UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (migration_name)
);
# Table: 'phpbb_modules'
CREATE TABLE phpbb_modules (
module_id INTEGER PRIMARY KEY NOT NULL ,
@ -906,6 +919,7 @@ CREATE TABLE phpbb_users (
user_icq varchar(15) NOT NULL DEFAULT '',
user_aim varchar(255) NOT NULL DEFAULT '',
user_yim varchar(255) NOT NULL DEFAULT '',
user_msnm varchar(255) NOT NULL DEFAULT '',
user_jabber varchar(255) NOT NULL DEFAULT '',
user_website varchar(200) NOT NULL DEFAULT '',
user_occ text(65535) NOT NULL DEFAULT '',

View file

@ -186,6 +186,7 @@ $lang = array_merge($lang, array(
'IMG_ICON_CONTACT_EMAIL' => 'Send email',
'IMG_ICON_CONTACT_ICQ' => 'ICQ',
'IMG_ICON_CONTACT_JABBER' => 'Jabber',
'IMG_ICON_CONTACT_MSNM' => 'WLM',
'IMG_ICON_CONTACT_PM' => 'Send message',
'IMG_ICON_CONTACT_YAHOO' => 'YIM',
'IMG_ICON_CONTACT_WWW' => 'Website',

View file

@ -187,6 +187,7 @@ $lang = array_merge($lang, array(
'ELLIPSIS' => '…',
'EMAIL' => 'Email', // Short form for EMAIL_ADDRESS
'EMAIL_ADDRESS' => 'Email address',
'EMAIL_INVALID_EMAIL' => 'The email address you entered is invalid.',
'EMAIL_SMTP_ERROR_RESPONSE' => 'Ran into problems sending email at <strong>Line %1$s</strong>. Response: %2$s.',
'EMPTY_SUBJECT' => 'You must specify a subject when posting a new topic.',
'EMPTY_MESSAGE_SUBJECT' => 'You must specify a subject when composing a new message.',
@ -379,6 +380,7 @@ $lang = array_merge($lang, array(
'MODERATORS' => 'Moderators',
'MONTH' => 'Month',
'MOVE' => 'Move',
'MSNM' => 'WLM',
'NA' => 'N/A',
'NEWEST_USER' => 'Our newest member <strong>%s</strong>',
@ -637,6 +639,7 @@ $lang = array_merge($lang, array(
'TOO_LONG_INTERESTS' => 'The interests you entered is too long.',
'TOO_LONG_JABBER' => 'The Jabber account name you entered is too long.',
'TOO_LONG_LOCATION' => 'The location you entered is too long.',
'TOO_LONG_MSN' => 'The WLM name you entered is too long.',
'TOO_LONG_NEW_PASSWORD' => 'The password you entered is too long.',
'TOO_LONG_OCCUPATION' => 'The occupation you entered is too long.',
'TOO_LONG_PASSWORD_CONFIRM' => 'The password confirmation you entered is too long.',
@ -657,6 +660,7 @@ $lang = array_merge($lang, array(
'TOO_SHORT_INTERESTS' => 'The interests you entered is too short.',
'TOO_SHORT_JABBER' => 'The Jabber account name you entered is too short.',
'TOO_SHORT_LOCATION' => 'The location you entered is too short.',
'TOO_SHORT_MSN' => 'The WLM name you entered is too short.',
'TOO_SHORT_NEW_PASSWORD' => 'The password you entered is too short.',
'TOO_SHORT_OCCUPATION' => 'The occupation you entered is too short.',
'TOO_SHORT_PASSWORD_CONFIRM' => 'The password confirmation you entered is too short.',

View file

@ -78,6 +78,9 @@ $lang = array_merge($lang, array(
'IM_JABBER' => 'Please note that users may have selected to not receive unsolicited instant messages.',
'IM_JABBER_SUBJECT' => 'This is an automated message please do not reply! Message from user %1$s at %2$s.',
'IM_MESSAGE' => 'Your message',
'IM_MSNM' => 'Please note that you need Windows Live Messenger installed to use this.',
'IM_MSNM_BROWSER' => 'Your browser does not support this.',
'IM_MSNM_CONNECT' => 'WLM is not connected.\nYou have to connect to WLM to continue.',
'IM_NAME' => 'Your Name',
'IM_NO_DATA' => 'There is no suitable contact information for this user.',
'IM_NO_JABBER' => 'Sorry, direct messaging of Jabber users is not supported on this board. You will need a Jabber client installed on your system to contact the recipient above.',
@ -120,6 +123,7 @@ $lang = array_merge($lang, array(
'SEND_IM' => 'Instant messaging',
'SEND_JABBER_MESSAGE' => 'Send Jabber message',
'SEND_MESSAGE' => 'Message',
'SEND_MSNM_MESSAGE' => 'Send WLM message',
'SEND_YIM_MESSAGE' => 'Send YIM message',
'SORT_EMAIL' => 'Email',
'SORT_LAST_ACTIVE' => 'Last active',

View file

@ -0,0 +1,56 @@
<?php
/**
*
* migrator [English]
*
* @package language
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
$lang = array_merge($lang, array(
'CONFIG_ALREADY_EXIST' => 'The config setting "%s" unexpectedly already exists.',
'CONFIG_NOT_EXIST' => 'The config setting "%s" unexpectedly does not exist.',
'GROUP_NOT_EXIST' => 'The group "%s" unexpectedly does not exist.',
'MIGRATION_EXCEPTION_ERROR' => 'Something went wrong during the request and an exception was thrown. The changes made before the error occurred were reversed to the best of our abilities, but you should check the board for errors.',
'MIGRATION_NOT_FULFILLABLE' => 'The migration "%1$s" is not fulfillable, missing migration "%2$s".',
'MODULE_ALREADY_EXIST' => 'The module "%s" unexpectedly already exists.',
'MODULE_ERROR' => 'An error occured while creating a module: %s',
'MODULE_INFO_FILE_NOT_EXIST' => 'A required module info file is missing: %2$s',
'MODULE_NOT_EXIST' => 'A required module does not exist: %s',
'MODULE_NOT_REMOVABLE' => 'Module %1$s was unable to be removed: %2$s',
'PERMISSION_ALREADY_EXIST' => 'The permission setting "%s" unexpectedly already exists.',
'PERMISSION_NOT_EXIST' => 'The permission setting "%s" unexpectedly does not exist.',
'ROLE_NOT_EXIST' => 'The permission role "%s" unexpectedly does not exist.',
));

View file

@ -53,9 +53,9 @@ $lang = array_merge($lang, array(
'BBCODE_IS_OFF' => '%sBBCode%s is <em>OFF</em>',
'BBCODE_IS_ON' => '%sBBCode%s is <em>ON</em>',
'BBCODE_I_HELP' => 'Italic text: [i]text[/i]',
'BBCODE_L_HELP' => 'List: [list]text[/list]',
'BBCODE_LISTITEM_HELP' => 'List item: [*]text[/*]',
'BBCODE_O_HELP' => 'Ordered list: [list=]text[/list]',
'BBCODE_L_HELP' => 'List: [list][*]text[/list]',
'BBCODE_LISTITEM_HELP' => 'List item: [*]text',
'BBCODE_O_HELP' => 'Ordered list: e.g. [list=1][*]First point[/list] or [list=a][*]Point a[/list]',
'BBCODE_P_HELP' => 'Insert image: [img]http://image_url[/img]',
'BBCODE_Q_HELP' => 'Quote text: [quote]text[/quote]',
'BBCODE_S_HELP' => 'Font colour: [color=red]text[/color] Tip: you can also use color=#FF0000',

View file

@ -173,7 +173,6 @@ $lang = array_merge($lang, array(
'EDIT_DRAFT_EXPLAIN' => 'Here you are able to edit your draft. Drafts do not contain attachment and poll information.',
'EMAIL_BANNED_EMAIL' => 'The email address you entered is not allowed to be used.',
'EMAIL_INVALID_EMAIL' => 'The email address you entered is invalid.',
'EMAIL_REMIND' => 'This must be the email address associated with your account. If you have not changed this via your user control panel then it is the email address you registered your account with.',
'EMAIL_TAKEN_EMAIL' => 'The entered email address is already in use.',
'EMPTY_DRAFT' => 'You must enter a message to submit your changes.',
@ -455,6 +454,7 @@ $lang = array_merge($lang, array(
'UCP_MAIN_FRONT' => 'Front page',
'UCP_MAIN_SUBSCRIBED' => 'Manage subscriptions',
'UCP_MSNM' => 'Windows Live Messenger',
'UCP_NO_ATTACHMENTS' => 'You have posted no files.',
'UCP_PREFS' => 'Board preferences',

View file

@ -287,6 +287,13 @@ switch ($mode)
$s_action = '';
break;
case 'msnm':
$lang = 'MSNM';
$sql_field = 'user_msnm';
$s_select = 'S_SEND_MSNM';
$s_action = '';
break;
case 'jabber':
$lang = 'JABBER';
$sql_field = 'user_jabber';
@ -633,6 +640,7 @@ switch ($mode)
'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']),
'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']),
'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']),
'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']),
'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']),
'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']),
'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']),
@ -976,8 +984,8 @@ switch ($mode)
$template_html = 'memberlist_body.html';
// Sorting
$sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['JABBER']);
$sort_key_sql = array('a' => 'u.username_clean', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'f' => 'u.user_website', 'g' => 'u.user_icq', 'h' => 'u.user_aim', 'j' => 'u.user_yim', 'k' => 'u.user_jabber');
$sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'i' => $user->lang['MSNM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['JABBER']);
$sort_key_sql = array('a' => 'u.username_clean', 'b' => 'u.user_from', 'c' => 'u.user_regdate', 'd' => 'u.user_posts', 'f' => 'u.user_website', 'g' => 'u.user_icq', 'h' => 'u.user_aim', 'i' => 'u.user_msnm', 'j' => 'u.user_yim', 'k' => 'u.user_jabber');
if ($auth->acl_get('a_user'))
{
@ -1020,7 +1028,7 @@ switch ($mode)
$select_single = request_var('select_single', false);
// Search URL parameters, if any of these are in the URL we do a search
$search_params = array('username', 'email', 'icq', 'aim', 'yahoo', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip');
$search_params = array('username', 'email', 'icq', 'aim', 'yahoo', 'msn', 'jabber', 'search_group_id', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'ip');
// We validate form and field here, only id/class allowed
$form = (!preg_match('/^[a-z0-9_-]+$/i', $form)) ? '' : $form;
@ -1032,6 +1040,7 @@ switch ($mode)
$icq = request_var('icq', '');
$aim = request_var('aim', '');
$yahoo = request_var('yahoo', '');
$msn = request_var('msn', '');
$jabber = request_var('jabber', '');
$search_group_id = request_var('search_group_id', 0);
@ -1075,6 +1084,7 @@ switch ($mode)
$sql_where .= ($icq) ? ' AND u.user_icq ' . $db->sql_like_expression(str_replace('*', $db->any_char, $icq)) . ' ' : '';
$sql_where .= ($aim) ? ' AND u.user_aim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $aim)) . ' ' : '';
$sql_where .= ($yahoo) ? ' AND u.user_yim ' . $db->sql_like_expression(str_replace('*', $db->any_char, $yahoo)) . ' ' : '';
$sql_where .= ($msn) ? ' AND u.user_msnm ' . $db->sql_like_expression(str_replace('*', $db->any_char, $msn)) . ' ' : '';
$sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : '';
$sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : '';
@ -1307,6 +1317,7 @@ switch ($mode)
'icq' => array('icq', ''),
'aim' => array('aim', ''),
'yahoo' => array('yahoo', ''),
'msn' => array('msn', ''),
'jabber' => array('jabber', ''),
'search_group_id' => array('search_group_id', 0),
'joined_select' => array('joined_select', 'lt'),
@ -1438,6 +1449,7 @@ switch ($mode)
'ICQ' => $icq,
'AIM' => $aim,
'YAHOO' => $yahoo,
'MSNM' => $msn,
'JABBER' => $jabber,
'JOINED' => implode('-', $joined),
'ACTIVE' => implode('-', $active),
@ -1593,6 +1605,7 @@ switch ($mode)
'WWW_IMG' => $user->img('icon_contact_www', $user->lang['WWW']),
'ICQ_IMG' => $user->img('icon_contact_icq', $user->lang['ICQ']),
'AIM_IMG' => $user->img('icon_contact_aim', $user->lang['AIM']),
'MSN_IMG' => $user->img('icon_contact_msnm', $user->lang['MSNM']),
'YIM_IMG' => $user->img('icon_contact_yahoo', $user->lang['YIM']),
'JABBER_IMG' => $user->img('icon_contact_jabber', $user->lang['JABBER']),
'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']),
@ -1608,6 +1621,7 @@ switch ($mode)
'U_SORT_LOCATION' => $sort_url . '&amp;sk=b&amp;sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_ICQ' => $sort_url . '&amp;sk=g&amp;sd=' . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_AIM' => $sort_url . '&amp;sk=h&amp;sd=' . (($sort_key == 'h' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_MSN' => $sort_url . '&amp;sk=i&amp;sd=' . (($sort_key == 'i' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_YIM' => $sort_url . '&amp;sk=j&amp;sd=' . (($sort_key == 'j' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_ACTIVE' => ($auth->acl_get('u_viewonline')) ? $sort_url . '&amp;sk=l&amp;sd=' . (($sort_key == 'l' && $sort_dir == 'a') ? 'd' : 'a') : '',
'U_SORT_RANK' => $sort_url . '&amp;sk=m&amp;sd=' . (($sort_key == 'm' && $sort_dir == 'a') ? 'd' : 'a'),
@ -1734,12 +1748,14 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f
'U_ICQ' => ($data['user_icq']) ? 'http://www.icq.com/people/' . urlencode($data['user_icq']) . '/' : '',
'U_AIM' => ($data['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=aim&amp;u=' . $user_id) : '',
'U_YIM' => ($data['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($data['user_yim']) . '&amp;.src=pg' : '',
'U_MSN' => ($data['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=msnm&amp;u=' . $user_id) : '',
'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=jabber&amp;u=' . $user_id) : '',
'LOCATION' => ($data['user_from']) ? $data['user_from'] : '',
'USER_ICQ' => $data['user_icq'],
'USER_AIM' => $data['user_aim'],
'USER_YIM' => $data['user_yim'],
'USER_MSN' => $data['user_msnm'],
'USER_JABBER' => $data['user_jabber'],
'USER_JABBER_IMG' => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '',

View file

@ -1,5 +1,6 @@
<!-- INCLUDE simple_header.html -->
<!-- MSNM info from http://www.cdolive.net/ - doesn't seem to work with MSN Messenger -->
<h2 class="solo">{L_SEND_IM}</h2>
<form method="post" action="{S_IM_ACTION}">
@ -12,7 +13,7 @@
<fieldset>
<dl class="fields2">
<dt><label>{L_IM_RECIPIENT}{L_COLON}</label></dt>
<dd><strong>{USERNAME}</strong><!-- IF S_SEND_ICQ or S_SEND_AIM or S_NO_SEND_JABBER --> [ {IM_CONTACT} ]<!-- ENDIF --><!-- IF PRESENCE_IMG --> {PRESENCE_IMG}<!-- ENDIF --></dd>
<dd><strong>{USERNAME}</strong><!-- IF S_SEND_ICQ or S_SEND_AIM or S_SEND_MSNM or S_NO_SEND_JABBER --> [ {IM_CONTACT} ]<!-- ENDIF --><!-- IF PRESENCE_IMG --> {PRESENCE_IMG}<!-- ENDIF --></dd>
</dl>
<!-- IF S_SEND_ICQ -->
@ -42,6 +43,15 @@
</dl>
<!-- ENDIF -->
<!-- IF S_SEND_MSNM -->
<dl class="fields2">
<dt>&nbsp;</dt>
<dd><object classid="clsid:B69003B3-C55E-4B48-836C-BC5946FC3B28" codetype="application/x-oleobject" id="objMessengerApp" width="0" height="0"></object></dd>
<dd><a href="#" onclick="add_contact('{A_IM_CONTACT}'); return false;">{L_IM_ADD_CONTACT}</a></dd>
<dd><a href="#" onclick="im_contact('{A_IM_CONTACT}'); return false;">{L_IM_SEND_MESSAGE}</a></dd>
</dl>
<!-- ENDIF -->
<!-- IF S_SEND_JABBER -->
<dl class="fields2">
<dt><label for="message">{L_IM_MESSAGE}{L_COLON}</label></dt>
@ -75,4 +85,74 @@
<a href="#" onclick="window.close(); return false;">{L_CLOSE_WINDOW}</a>
<script type="text/javascript">
// <![CDATA[
/** The following will not work with Windows Vista **/
var app = document.getElementById('objMessengerApp');
/**
* Check whether the browser supports this and whether MSNM is connected
*/
function msn_supported()
{
// Does the browser support the MSNM object?
if (app.MyStatus)
{
// Is MSNM connected?
if (app.MyStatus == 1)
{
alert('{LA_IM_MSNM_CONNECT}');
return false;
}
}
else
{
alert('{LA_IM_MSNM_BROWSER}');
return false;
}
return true;
}
/**
* Add to your contact list
*/
function add_contact(address)
{
if (msn_supported())
{
// Could return an error while MSNM is connecting, don't want that
try
{
app.AddContact(0, address);
}
catch (e)
{
return;
}
}
}
/**
* Write IM to contact
*/
function im_contact(address)
{
if (msn_supported())
{
// Could return an error while MSNM is connecting, don't want that
try
{
app.InstantMessage(address);
}
catch (e)
{
return;
}
}
}
// ]]>
</script>
<!-- INCLUDE simple_footer.html -->

View file

@ -70,6 +70,10 @@ function insert_single(user)
<dt><label for="yahoo">{L_YIM}{L_COLON}</label></dt>
<dd><input type="text" name="yahoo" id="yahoo" value="{YAHOO}" class="inputbox" /></dd>
</dl>
<dl>
<dt><label for="msn">{L_MSNM}{L_COLON}</label></dt>
<dd><input type="text" name="msn" id="msn" value="{MSNM}" class="inputbox" /></dd>
</dl>
</fieldset>
<fieldset class="fields1 column2">

View file

@ -62,6 +62,7 @@
<!-- IF U_EMAIL --><dt>{L_EMAIL_ADDRESS}{L_COLON}</dt> <dd><a href="{U_EMAIL}">{L_SEND_EMAIL_USER} {USERNAME}</a></dd><!-- ENDIF -->
<!-- IF U_WWW --><dt>{L_WEBSITE}{L_COLON}</dt> <dd><a href="{U_WWW}" title="{L_VISIT_WEBSITE}{L_COLON} {U_WWW}">{U_WWW}</a></dd><!-- ENDIF -->
<!-- IF U_PM --><dt>{L_PM}{L_COLON}</dt> <dd><a href="{U_PM}">{L_SEND_PRIVATE_MESSAGE}</a></dd><!-- ENDIF -->
<!-- IF U_MSN or USER_MSN --><dt>{L_MSNM}{L_COLON}</dt> <dd><!-- IF U_MSN --><a href="{U_MSN}" onclick="popup(this.href, 550, 320); return false;">{L_SEND_MSNM_MESSAGE}</a><!-- ELSE -->{USER_MSN}<!-- ENDIF --></dd><!-- ENDIF -->
<!-- IF U_YIM or USER_YIM --><dt>{L_YIM}{L_COLON}</dt> <dd><!-- IF U_YIM --><a href="{U_YIM}" onclick="popup(this.href, 780, 550); return false;">{L_SEND_YIM_MESSAGE}</a><!-- ELSE -->{USER_YIM}<!-- ENDIF --></dd><!-- ENDIF -->
<!-- IF U_AIM or USER_AIM --><dt>{L_AIM}{L_COLON}</dt> <dd><!-- IF U_AIM --><a href="{U_AIM}" onclick="popup(this.href, 550, 320); return false;">{L_SEND_AIM_MESSAGE}</a><!-- ELSE -->{USER_AIM}<!-- ENDIF --></dd><!-- ENDIF -->
<!-- IF U_ICQ or USER_ICQ --><dt>{L_ICQ}{L_COLON}</dt> <dd><!-- IF U_ICQ --><a href="{U_ICQ}" onclick="popup(this.href, 550, 320); return false;">{L_SEND_ICQ_MESSAGE}</a><!-- ELSE -->{USER_ICQ}<!-- ENDIF --></dd><!-- ENDIF -->

View file

@ -90,12 +90,13 @@
<!-- END custom_fields -->
<!-- IF U_PM or U_EMAIL or U_WWW or U_ICQ or U_YIM or U_AIM or U_JABBER -->
<!-- IF U_PM or U_EMAIL or U_WWW or U_MSN or U_ICQ or U_YIM or U_AIM or U_JABBER -->
<dd>
<ul class="profile-icons">
<!-- IF U_PM --><li class="pm-icon"><a href="{U_PM}" title="{L_PRIVATE_MESSAGE}"><span>{L_PRIVATE_MESSAGE}</span></a></li><!-- ENDIF -->
<!-- IF U_EMAIL --><li class="email-icon"><a href="{U_EMAIL}" title="{L_SEND_EMAIL_USER} {MESSAGE_AUTHOR}"><span>{L_SEND_EMAIL_USER} {MESSAGE_AUTHOR}</span></a></li><!-- ENDIF -->
<!-- IF U_WWW --><li class="web-icon"><a href="{U_WWW}" title="{L_VISIT_WEBSITE}{L_COLON} {U_WWW}"><span>{L_WEBSITE}</span></a></li><!-- ENDIF -->
<!-- IF U_MSN --><li class="msnm-icon"><a href="{U_MSN}" onclick="popup(this.href, 550, 320); return false;" title="{L_MSNM}"><span>{L_MSNM}</span></a></li><!-- ENDIF -->
<!-- IF U_ICQ --><li class="icq-icon"><a href="{U_ICQ}" onclick="popup(this.href, 550, 320); return false;" title="{L_ICQ}"><span>{L_ICQ}</span></a></li><!-- ENDIF -->
<!-- IF U_YIM --><li class="yahoo-icon"><a href="{U_YIM}" onclick="popup(this.href, 780, 550); return false;" title="{L_YIM}"><span>{L_YIM}</span></a></li><!-- ENDIF -->
<!-- IF U_AIM --><li class="aim-icon"><a href="{U_AIM}" onclick="popup(this.href, 550, 320); return false;" title="{L_AIM}"><span>{L_AIM}</span></a></li><!-- ENDIF -->

View file

@ -18,6 +18,10 @@
<dt><label for="aim">{L_UCP_AIM}{L_COLON}</label></dt>
<dd><input type="text" name="aim" id="aim" maxlength="255" value="{AIM}" class="inputbox" /></dd>
</dl>
<dl>
<dt><label for="msn">{L_UCP_MSNM}{L_COLON}</label></dt>
<dd><input type="text" name="msn" id="msn" maxlength="255" value="{MSN}" class="inputbox" /></dd>
</dl>
<dl>
<dt><label for="yim">{L_UCP_YIM}{L_COLON}</label></dt>
<dd><input type="text" name="yim" id="yim" maxlength="255" value="{YIM}" class="inputbox" /></dd>

View file

@ -216,12 +216,13 @@
<!-- END custom_fields -->
<!-- IF not S_IS_BOT -->
<!-- IF postrow.U_PM or postrow.U_EMAIL or postrow.U_WWW or postrow.U_ICQ or postrow.U_YIM or postrow.U_AIM or postrow.U_JABBER -->
<!-- IF postrow.U_PM or postrow.U_EMAIL or postrow.U_WWW or postrow.U_MSN or postrow.U_ICQ or postrow.U_YIM or postrow.U_AIM or postrow.U_JABBER -->
<dd>
<ul class="profile-icons">
<!-- IF postrow.U_PM --><li class="pm-icon"><a href="{postrow.U_PM}" title="{L_PRIVATE_MESSAGE}"><span>{L_PRIVATE_MESSAGE}</span></a></li><!-- ENDIF -->
<!-- IF postrow.U_EMAIL --><li class="email-icon"><a href="{postrow.U_EMAIL}" title="{L_SEND_EMAIL_USER} {postrow.POST_AUTHOR}"><span>{L_SEND_EMAIL_USER} {postrow.POST_AUTHOR}</span></a></li><!-- ENDIF -->
<!-- IF postrow.U_WWW --><li class="web-icon"><a href="{postrow.U_WWW}" title="{L_VISIT_WEBSITE}{L_COLON} {postrow.U_WWW}"><span>{L_WEBSITE}</span></a></li><!-- ENDIF -->
<!-- IF postrow.U_MSN --><li class="msnm-icon"><a href="{postrow.U_MSN}" onclick="popup(this.href, 550, 320); return false;" title="{L_MSNM}"><span>{L_MSNM}</span></a></li><!-- ENDIF -->
<!-- IF postrow.U_ICQ --><li class="icq-icon"><a href="{postrow.U_ICQ}" onclick="popup(this.href, 550, 320); return false;" title="{L_ICQ}"><span>{L_ICQ}</span></a></li><!-- ENDIF -->
<!-- IF postrow.U_YIM --><li class="yahoo-icon"><a href="{postrow.U_YIM}" onclick="popup(this.href, 780, 550); return false;" title="{L_YIM}"><span>{L_YIM}</span></a></li><!-- ENDIF -->
<!-- IF postrow.U_AIM --><li class="aim-icon"><a href="{postrow.U_AIM}" onclick="popup(this.href, 550, 320); return false;" title="{L_AIM}"><span>{L_AIM}</span></a></li><!-- ENDIF -->

View file

@ -786,7 +786,7 @@
padding-right: 11px;
padding-left: 0;
}
.rtl .imageset.icon_contact_aim, .rtl .imageset.icon_contact_email, .rtl .imageset.icon_contact_icq, .rtl .imageset.icon_contact_jabber, .rtl .imageset.icon_contact_www, .rtl .imageset.icon_contact_yahoo, .rtl .imageset.icon_post_delete, .rtl .imageset.icon_post_info, .rtl .imageset.icon_post_report, .rtl .imageset.icon_user_warn {
.rtl .imageset.icon_contact_aim, .rtl .imageset.icon_contact_email, .rtl .imageset.icon_contact_icq, .rtl .imageset.icon_contact_jabber, .rtl .imageset.icon_contact_msnm, .rtl .imageset.icon_contact_www, .rtl .imageset.icon_contact_yahoo, .rtl .imageset.icon_post_delete, .rtl .imageset.icon_post_info, .rtl .imageset.icon_post_report, .rtl .imageset.icon_user_warn {
padding-right: 20px;
padding-left: 0;
}

View file

@ -139,6 +139,7 @@ ul.profile-icons li a:hover { background: none; }
.aim-icon, .aim-icon a { background: none top left no-repeat; }
.yahoo-icon, .yahoo-icon a { background: none top left no-repeat; }
.web-icon, .web-icon a { background: none top left no-repeat; }
.msnm-icon, .msnm-icon a { background: none top left no-repeat; }
.icq-icon, .icq-icon a { background: none top left no-repeat; }
.jabber-icon, .jabber-icon a { background: none top left no-repeat; }
.pm-icon, .pm-icon a { background: none top left no-repeat; }
@ -156,6 +157,7 @@ ul.profile-icons li.email-icon { width: 20px; height: 20px; }
ul.profile-icons li.aim-icon { width: 20px; height: 20px; }
ul.profile-icons li.yahoo-icon { width: 20px; height: 20px; }
ul.profile-icons li.web-icon { width: 20px; height: 20px; }
ul.profile-icons li.msnm-icon { width: 20px; height: 20px; }
ul.profile-icons li.icq-icon { width: 20px; height: 20px; }
ul.profile-icons li.jabber-icon { width: 20px; height: 20px; }
ul.profile-icons li.pm-icon { width: 28px; height: 20px; }

View file

@ -705,6 +705,7 @@ a.sendemail {
.aim-icon, .aim-icon a { background-image: url("./images/icon_contact_aim.gif"); }
.yahoo-icon, .yahoo-icon a { background-image: url("./images/icon_contact_yahoo.gif"); }
.web-icon, .web-icon a { background-image: url("./images/icon_contact_www.gif"); }
.msnm-icon, .msnm-icon a { background-image: url("./images/icon_contact_msnm.gif"); }
.icq-icon, .icq-icon a { background-image: url("./images/icon_contact_icq.gif"); }
.jabber-icon, .jabber-icon a { background-image: url("./images/icon_contact_jabber.gif"); }
.pm-icon, .pm-icon a { background-image: url("./en/icon_contact_pm.gif"); }

View file

@ -280,6 +280,11 @@ span.imageset {
padding-left: 20px;
padding-top: 20px;
}
.imageset.icon_contact_msnm {
background-image: url("./images/icon_contact_msnm.gif");
padding-left: 20px;
padding-top: 20px;
}
.imageset.icon_contact_www {
background-image: url("./images/icon_contact_www.gif");
padding-left: 20px;

View file

@ -2,6 +2,8 @@
<br clear="all" />
<!-- MSNM info from http://www.cdolive.net/ - doesn't seem to work with MSN Messenger -->
<form method="post" action="{S_IM_ACTION}">
<table class="tablebg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
@ -12,7 +14,7 @@
</tr>
<tr>
<td class="row1"><b class="genmed">{L_IM_RECIPIENT}{L_COLON} </b></td>
<td class="row2"><span class="gen"><b>{USERNAME}</b><!-- IF S_SEND_ICQ or S_SEND_AIM or S_NO_SEND_JABBER --> [ {IM_CONTACT} ]<!-- ENDIF --></span> <!-- IF PRESENCE_IMG -->{PRESENCE_IMG}<!-- ENDIF --></td>
<td class="row2"><span class="gen"><b>{USERNAME}</b><!-- IF S_SEND_ICQ or S_SEND_AIM or S_SEND_MSNM or S_NO_SEND_JABBER --> [ {IM_CONTACT} ]<!-- ENDIF --></span> <!-- IF PRESENCE_IMG -->{PRESENCE_IMG}<!-- ENDIF --></td>
</tr>
<!-- IF S_SEND_AIM -->
@ -24,6 +26,85 @@
</tr>
<!-- ENDIF -->
<!-- IF S_SEND_MSNM -->
<tr>
<td class="row1" colspan="2" align="center">
<object classid="clsid:B69003B3-C55E-4B48-836C-BC5946FC3B28" codetype="application/x-oleobject" id="objMessengerApp" width="0" height="0"></object>
<script type="text/javascript">
// <![CDATA[
var app = document.getElementById('objMessengerApp');
/**
* Check whether the browser supports this and whether MSNM is connected
*/
function msn_supported()
{
// Does the browser support the MSNM object?
if (app.MyStatus)
{
// Is MSNM connected?
if (app.MyStatus == 1)
{
alert('{LA_IM_MSNM_CONNECT}');
return false;
}
}
else
{
alert('{LA_IM_MSNM_BROWSER}');
return false;
}
return true;
}
/**
* Add to your contact list
*/
function add_contact(address)
{
if (msn_supported())
{
// Could return an error while MSNM is connecting, don't want that
try
{
app.AddContact(0, address);
}
catch (e)
{
return;
}
}
}
/**
* Write IM to contact
*/
function im_contact(address)
{
if (msn_supported())
{
// Could return an error while MSNM is connecting, don't want that
try
{
app.InstantMessage(address);
}
catch (e)
{
return;
}
}
}
// ]]>
</script>
<a class="gen" href="#" onclick="add_contact('{A_IM_CONTACT}'); return false;">{L_IM_ADD_CONTACT}</a><br /><a class="gen" href="#" onclick="im_contact('{A_IM_CONTACT}'); return false;">{L_IM_SEND_MESSAGE}</a>
</td>
</tr>
<tr>
<td class="cat" colspan="2" align="center">&nbsp;</td>
</tr>
<!-- ENDIF -->
<!-- IF S_SEND_JABBER -->
<tr>
<td class="row1"><b class="genmed">{L_IM_MESSAGE}{L_COLON} </b></td>

View file

@ -102,14 +102,14 @@
<!-- ELSE -->
<td colspan="2" class="row1">&nbsp;</td>
<!-- ENDIF -->
<td class="row1"><b class="genmed">{L_JABBER}{L_COLON}</b></td>
<td class="row2"><input class="post" type="text" name="jabber" value="{JABBER}" /></td>
<td class="row1"><b class="genmed">{L_MSNM}{L_COLON}</b></td>
<td class="row2"><input class="post" type="text" name="msn" value="{MSNM}" /></td>
</tr>
<tr>
<td class="row1"><b class="genmed">{L_POSTS}{L_COLON}</b></td>
<td class="row2"><select name="count_select">{S_COUNT_OPTIONS}</select> <input class="post" type="text" name="count" value="{COUNT}" /></td>
<td class="row1">&nbsp;</td>
<td class="row2">&nbsp;</td>
<td class="row1"><b class="genmed">{L_JABBER}{L_COLON}</b></td>
<td class="row2"><input class="post" type="text" name="jabber" value="{JABBER}" /></td>
</tr>
<tr>
<td class="row1"><b class="genmed">{L_SORT_BY}{L_COLON}</b></td>

View file

@ -116,6 +116,10 @@
<td><a href="{U_PM}" class="imageset">{PM_IMG}</a></td>
</tr>
<!-- ENDIF -->
<tr>
<td class="gen" nowrap="nowrap" align="{S_CONTENT_FLOW_END}">{L_MSNM}{L_COLON} </td>
<td><!-- IF U_MSN --><a href="{U_MSN}" onclick="popup(this.href, 550, 320); return false" class="imageset">{MSN_IMG}</a><!-- ELSEIF USER_MSN -->{USER_MSN}<!-- ENDIF --></td>
</tr>
<tr>
<td class="gen" nowrap="nowrap" align="{S_CONTENT_FLOW_END}">{L_YIM}{L_COLON} </td>
<td><!-- IF U_YIM --><a href="{U_YIM}" onclick="popup(this.href, 780, 550); return false" class="imageset">{YIM_IMG}</a><!-- ELSEIF USER_YIM -->{USER_YIM}<!-- ENDIF --></td>

View file

@ -20,6 +20,10 @@
<td class="row1" width="35%"><b class="genmed">{L_UCP_AIM}{L_COLON} </b></td>
<td class="row2"><input class="post" type="text" name="aim" size="30" maxlength="255" value="{AIM}" /></td>
</tr>
<tr>
<td class="row1" width="35%"><b class="genmed">{L_UCP_MSNM}{L_COLON} </b></td>
<td class="row2"><input class="post" type="text" name="msn" size="30" maxlength="255" value="{MSN}" /></td>
</tr>
<tr>
<td class="row1" width="35%"><b class="genmed">{L_UCP_YIM}{L_COLON} </b></td>
<td class="row2"><input class="post" type="text" name="yim" size="30" maxlength="255" value="{YIM}" /></td>

View file

@ -164,7 +164,7 @@
<table width="100%" cellspacing="0">
<tr class="nav">
<td valign="middle">&nbsp;<!-- IF U_WATCH_FORUM_LINK and not S_IS_BOT --><a href="{U_WATCH_FORUM_LINK}">{S_WATCH_FORUM_TITLE}</a><!-- ENDIF --></td>
<td align="{S_CONTENT_FLOW_END}" valign="middle"><!-- IF not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}">{L_MARK_TOPICS_READ}</a><!-- ENDIF -->&nbsp;</td>
<td align="{S_CONTENT_FLOW_END}" valign="middle"><!-- IF not S_IS_BOT and U_MARK_TOPICS and .topicrow --><a href="{U_MARK_TOPICS}">{L_MARK_TOPICS_READ}</a><!-- ENDIF -->&nbsp;</td>
</tr>
</table>
</td>

View file

@ -19,6 +19,11 @@
padding-left: 72px;
padding-top: 20px;
}
.imageset.icon_contact_msnm {
background-image: url("./icon_contact_msnm.gif");
padding-left: 72px;
padding-top: 20px;
}
.imageset.icon_contact_pm {
background-image: url("./icon_contact_pm.gif");
padding-left: 72px;

View file

@ -1008,6 +1008,11 @@ a.imageset {
padding-left: 72px;
padding-top: 20px;
}
.imageset.icon_contact_msnm {
background-image: url("./en/icon_contact_msnm.gif");
padding-left: 72px;
padding-top: 20px;
}
.imageset.icon_contact_pm {
background-image: url("./en/icon_contact_pm.gif");
padding-left: 72px;

View file

@ -617,6 +617,7 @@ $template->assign_vars(array(
'WWW_IMG' => $user->img('icon_contact_www', 'VISIT_WEBSITE'),
'ICQ_IMG' => $user->img('icon_contact_icq', 'ICQ'),
'AIM_IMG' => $user->img('icon_contact_aim', 'AIM'),
'MSN_IMG' => $user->img('icon_contact_msnm', 'MSNM'),
'YIM_IMG' => $user->img('icon_contact_yahoo', 'YIM'),
'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER') ,
'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'),
@ -1094,6 +1095,7 @@ while ($row = $db->sql_fetchrow($result))
'icq_status_img' => '',
'icq' => '',
'aim' => '',
'msn' => '',
'yim' => '',
'jabber' => '',
'search' => '',
@ -1161,6 +1163,7 @@ while ($row = $db->sql_fetchrow($result))
'profile' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&amp;u=$poster_id"),
'www' => $row['user_website'],
'aim' => ($row['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=aim&amp;u=$poster_id") : '',
'msn' => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=msnm&amp;u=$poster_id") : '',
'yim' => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&amp;.src=pg' : '',
'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&amp;action=jabber&amp;u=$poster_id") : '',
'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$poster_id&amp;sr=posts") : '',
@ -1582,6 +1585,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'U_WWW' => $user_cache[$poster_id]['www'],
'U_ICQ' => $user_cache[$poster_id]['icq'],
'U_AIM' => $user_cache[$poster_id]['aim'],
'U_MSN' => $user_cache[$poster_id]['msn'],
'U_YIM' => $user_cache[$poster_id]['yim'],
'U_JABBER' => $user_cache[$poster_id]['jabber'],

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_migrations">
<column>migration_name</column>
<column>migration_depends_on</column>
<column>migration_schema_done</column>
<column>migration_data_done</column>
<column>migration_data_state</column>
<column>migration_start_time</column>
<column>migration_end_time</column>
<row>
<value>installed_migration</value>
<value></value>
<value>1</value>
<value>1</value>
<value></value>
<value>1234</value>
<value>5678</value>
</row>
</table>
<table name="phpbb_config">
<column>config_name</column>
<column>config_value</column>
<row>
<value>foo</value>
<value>bar</value>
</row>
</table>
</dataset>

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_modules">
<column>module_id</column>
<column>module_enabled</column>
<column>module_display</column>
<column>module_basename</column>
<column>module_class</column>
<column>parent_id</column>
<column>left_id</column>
<column>right_id</column>
<column>module_langname</column>
<column>module_mode</column>
<column>module_auth</column>
<row>
<value>1</value>
<value>1</value>
<value>1</value>
<value></value>
<value>acp</value>
<value>0</value>
<value>1</value>
<value>4</value>
<value>ACP_CAT</value>
<value></value>
<value></value>
</row>
<row>
<value>2</value>
<value>1</value>
<value>1</value>
<value>acp_test</value>
<value>acp</value>
<value>1</value>
<value>2</value>
<value>3</value>
<value>ACP_MODULE</value>
<value>test</value>
<value></value>
</row>
</table>
</dataset>

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_acl_options">
<column>auth_option_id</column>
<column>auth_option</column>
<column>is_global</column>
<column>is_local</column>
<column>founder_only</column>
<row>
<value>1</value>
<value>global</value>
<value>1</value>
<value>0</value>
<value>0</value>
</row>
<row>
<value>2</value>
<value>local</value>
<value>0</value>
<value>1</value>
<value>0</value>
</row>
<row>
<value>3</value>
<value>both</value>
<value>1</value>
<value>1</value>
<value>0</value>
</row>
</table>
</dataset>

View file

@ -0,0 +1,27 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
class phpbb_dbal_migration_dummy extends phpbb_db_migration
{
static public function depends_on()
{
return array('installed_migration');
}
function update_schema()
{
return array(
'add_columns' => array(
'phpbb_config' => array(
'extra_column' => array('UINT', 1),
),
),
);
}
}

View file

@ -0,0 +1,41 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_dbal_migration_fail extends phpbb_db_migration
{
function update_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'config' => array(
'test_column' => array('BOOL', 1),
),
),
);
}
function revert_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'config' => array(
'test_column',
),
),
);
}
function update_data()
{
return array(
array('config.add', array('foobar3', true)),
array('config.update', array('does_not_exist', true)),
);
}
}

View file

@ -0,0 +1,44 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
class phpbb_dbal_migration_if extends phpbb_db_migration
{
function update_schema()
{
return array();
}
function update_data()
{
return array(
array('if', array(
true,
array('custom', array(array(&$this, 'test_true'))),
)),
array('if', array(
false,
array('custom', array(array(&$this, 'test_false'))),
)),
);
}
function test_true()
{
global $migrator_test_if_true_failed;
$migrator_test_if_true_failed = false;
}
function test_false()
{
global $migrator_test_if_false_failed;
$migrator_test_if_false_failed = true;
}
}

View file

@ -0,0 +1,30 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
class phpbb_dbal_migration_installed extends phpbb_db_migration
{
function effectively_installed()
{
return true;
}
function update_data()
{
return array(
array('custom', array(array(&$this, 'test'))),
);
}
function test()
{
global $migrator_test_installed_failed;
$migrator_test_installed_failed = true;
}
}

View file

@ -0,0 +1,38 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
class phpbb_dbal_migration_recall extends phpbb_db_migration
{
function update_schema()
{
return array();
}
function update_data()
{
return array(
array('custom', array(array(&$this, 'test_call'))),
);
}
// This function should be called 10 times
function test_call($input)
{
global $migrator_test_call_input;
$migrator_test_call_input = (int) $input;
if ($migrator_test_call_input < 10)
{
return ($migrator_test_call_input + 1);
}
return;
}
}

View file

@ -0,0 +1,40 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
class phpbb_dbal_migration_revert extends phpbb_db_migration
{
function update_schema()
{
return array(
'add_columns' => array(
'phpbb_config' => array(
'bar_column' => array('UINT', 1),
),
),
);
}
function revert_schema()
{
return array(
'drop_columns' => array(
'phpbb_config' => array(
'bar_column',
),
),
);
}
function update_data()
{
return array(
array('config.add', array('foobartest', 0)),
);
}
}

View file

@ -0,0 +1,16 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
class phpbb_dbal_migration_revert_with_dependency extends phpbb_db_migration
{
static public function depends_on()
{
return array('phpbb_dbal_migration_revert');
}
}

View file

@ -0,0 +1,26 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
class phpbb_dbal_migration_unfulfillable extends phpbb_db_migration
{
static public function depends_on()
{
return array('installed_migration', 'phpbb_dbal_migration_dummy', 'non_existant_migration');
}
function update_schema()
{
trigger_error('Schema update of migration with unfulfillable dependency was run!');
}
function update_data()
{
trigger_error('Data update of migration with unfulfillable dependency was run!');
}
}

View file

@ -0,0 +1,257 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/db/migrator.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/migration.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php';
require_once dirname(__FILE__) . '/migration/dummy.php';
require_once dirname(__FILE__) . '/migration/unfulfillable.php';
require_once dirname(__FILE__) . '/migration/if.php';
require_once dirname(__FILE__) . '/migration/recall.php';
require_once dirname(__FILE__) . '/migration/revert.php';
require_once dirname(__FILE__) . '/migration/revert_with_dependency.php';
require_once dirname(__FILE__) . '/migration/fail.php';
require_once dirname(__FILE__) . '/migration/installed.php';
class phpbb_dbal_migrator_test extends phpbb_database_test_case
{
protected $db;
protected $db_tools;
protected $migrator;
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator.xml');
}
public function setUp()
{
parent::setUp();
$this->db = $this->new_dbal();
$this->db_tools = new phpbb_db_tools($this->db);
$this->config = new phpbb_config_db($this->db, new phpbb_mock_cache, 'phpbb_config');
$tools = array(
new phpbb_db_migration_tool_config($this->config),
);
$this->migrator = new phpbb_db_migrator($this->config, $this->db, $this->db_tools, 'phpbb_migrations', dirname(__FILE__) . '/../../phpBB/', 'php', 'phpbb_', $tools);
}
public function test_update()
{
$this->migrator->set_migrations(array('phpbb_dbal_migration_dummy'));
// schema
$this->migrator->update();
$this->assertFalse($this->migrator->finished());
$this->assertSqlResultEquals(
array(array('success' => '1')),
"SELECT 1 as success
FROM phpbb_migrations
WHERE migration_name = 'phpbb_dbal_migration_dummy'
AND migration_start_time >= " . (time() - 1) . "
AND migration_start_time <= " . (time() + 1),
'Start time set correctly'
);
// data
$this->migrator->update();
$this->assertTrue($this->migrator->finished());
$this->assertSqlResultEquals(
array(array('extra_column' => '1')),
"SELECT extra_column FROM phpbb_config WHERE config_name = 'foo'",
'Dummy migration created extra_column with value 1 in all rows.'
);
$this->assertSqlResultEquals(
array(array('success' => '1')),
"SELECT 1 as success
FROM phpbb_migrations
WHERE migration_name = 'phpbb_dbal_migration_dummy'
AND migration_start_time <= migration_end_time
AND migration_end_time >= " . (time() - 1) . "
AND migration_end_time <= " . (time() + 1),
'End time set correctly'
);
// cleanup
$this->db_tools->sql_column_remove('phpbb_config', 'extra_column');
}
public function test_unfulfillable()
{
$this->migrator->set_migrations(array('phpbb_dbal_migration_unfulfillable', 'phpbb_dbal_migration_dummy'));
while (!$this->migrator->finished())
{
$this->migrator->update();
}
$this->assertTrue($this->migrator->finished());
$this->assertSqlResultEquals(
array(array('extra_column' => '1')),
"SELECT extra_column FROM phpbb_config WHERE config_name = 'foo'",
'Dummy migration was run, even though an unfulfillable migration was found.'
);
$this->db_tools->sql_column_remove('phpbb_config', 'extra_column');
}
public function test_if()
{
$this->migrator->set_migrations(array('phpbb_dbal_migration_if'));
// Don't like this, but I'm not sure there is any other way to do this
global $migrator_test_if_true_failed, $migrator_test_if_false_failed;
$migrator_test_if_true_failed = true;
$migrator_test_if_false_failed = false;
while (!$this->migrator->finished())
{
$this->migrator->update();
}
if ($migrator_test_if_true_failed)
{
$this->fail('True test failed');
}
if ($migrator_test_if_false_failed)
{
$this->fail('False test failed');
}
}
public function test_recall()
{
$this->migrator->set_migrations(array('phpbb_dbal_migration_recall'));
global $migrator_test_call_input;
// Run the schema first
$this->migrator->update();
$i = 0;
while (!$this->migrator->finished())
{
$this->migrator->update();
$this->assertSame($i, $migrator_test_call_input);
$i++;
}
$this->assertSame(10, $migrator_test_call_input);
}
public function test_revert()
{
// Make sure there are no other migrations in the db, this could cause issues
$this->db->sql_query("DELETE FROM phpbb_migrations");
$this->migrator->load_migration_state();
$this->migrator->set_migrations(array('phpbb_dbal_migration_revert', 'phpbb_dbal_migration_revert_with_dependency'));
$this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert'));
$this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert_with_dependency'));
// Install the migration first
while (!$this->migrator->finished())
{
$this->migrator->update();
}
$this->assertTrue($this->migrator->migration_state('phpbb_dbal_migration_revert') !== false);
$this->assertTrue($this->migrator->migration_state('phpbb_dbal_migration_revert_with_dependency') !== false);
$this->assertSqlResultEquals(
array(array('bar_column' => '1')),
"SELECT bar_column FROM phpbb_config WHERE config_name = 'foo'",
'Installing revert migration failed to create bar_column.'
);
$this->assertTrue(isset($this->config['foobartest']));
while ($this->migrator->migration_state('phpbb_dbal_migration_revert') !== false)
{
$this->migrator->revert('phpbb_dbal_migration_revert');
}
$this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert'));
$this->assertFalse($this->migrator->migration_state('phpbb_dbal_migration_revert_with_dependency'));
$this->assertFalse(isset($this->config['foobartest']));
$sql = 'SELECT * FROM phpbb_config';
$result = $this->db->sql_query_limit($sql, 1);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
if (isset($row['bar_column']))
{
$this->fail('Revert did not remove test_column.');
}
}
public function test_fail()
{
$this->migrator->set_migrations(array('phpbb_dbal_migration_fail'));
$this->assertFalse(isset($this->config['foobar3']));
try
{
while (!$this->migrator->finished())
{
$this->migrator->update();
}
}
catch (phpbb_db_migration_exception $e) {}
// Failure should have caused an automatic roll-back, so this should not exist.
$this->assertFalse(isset($this->config['foobar3']));
$sql = 'SELECT * FROM phpbb_config';
$result = $this->db->sql_query_limit($sql, 1);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
if (isset($row['test_column']))
{
$this->fail('Revert did not remove test_column.');
}
}
public function test_installed()
{
$this->migrator->set_migrations(array('phpbb_dbal_migration_installed'));
global $migrator_test_installed_failed;
$migrator_test_installed_failed = false;
while (!$this->migrator->finished())
{
$this->migrator->update();
}
$this->assertTrue($this->migrator->migration_state('phpbb_dbal_migration_installed') !== false);
if ($migrator_test_installed_failed)
{
$this->fail('Installed test failed');
}
}
}

View file

@ -0,0 +1,124 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/tool/config.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/exception.php';
class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case
{
public function setup()
{
$this->config = new phpbb_config(array());
$this->tool = new phpbb_db_migration_tool_config($this->config);
parent::setup();
}
public function test_add()
{
try
{
$this->tool->add('foo', 'bar');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertEquals('bar', $this->config['foo']);
try
{
$this->tool->add('foo', 'bar');
$this->fail('Exception not thrown');
}
catch (Exception $e) {}
}
public function test_update()
{
$this->config->set('foo', 'bar');
try
{
$this->tool->update('foo', 'bar2');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertEquals('bar2', $this->config['foo']);
}
public function test_update_if_equals()
{
$this->config->set('foo', 'bar');
try
{
$this->tool->update_if_equals('', 'foo', 'bar2');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertEquals('bar', $this->config['foo']);
try
{
$this->tool->update_if_equals('bar', 'foo', 'bar2');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertEquals('bar2', $this->config['foo']);
}
public function test_remove()
{
$this->config->set('foo', 'bar');
try
{
$this->tool->remove('foo');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertFalse(isset($this->config['foo']));
}
public function test_reverse()
{
$this->config->set('foo', 'bar');
try
{
$this->tool->reverse('add', 'foo');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertFalse(isset($this->config['foo']));
$this->config->set('foo', 'bar');
try
{
$this->tool->reverse('update_if_equals', 'test', 'foo', 'bar');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertEquals('test', $this->config['foo']);
}
}

View file

@ -0,0 +1,150 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/tool/module.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/exception.php';
class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
{
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_module.xml');
}
public function setup()
{
// Need global $db, $user for delete_module function in acp_modules
global $phpbb_root_path, $phpEx, $skip_add_log, $db, $user;
parent::setup();
// Force add_log function to not be used
$skip_add_log = true;
$db = $this->db = $this->new_dbal();
$this->cache = new phpbb_cache_service(new phpbb_cache_driver_null(), new phpbb_config(array()), $this->db, $phpbb_root_path, $phpEx);
$user = $this->user = new phpbb_user();
$this->tool = new phpbb_db_migration_tool_module($this->db, $this->cache, $this->user, $phpbb_root_path, $phpEx, 'phpbb_modules');
}
public function exists_data()
{
return array(
// Test the category
array(
'',
'ACP_CAT',
true,
),
array(
0,
'ACP_CAT',
true,
),
// Test the module
array(
'',
'ACP_MODULE',
false,
),
array(
false,
'ACP_MODULE',
true,
),
array(
'ACP_CAT',
'ACP_MODULE',
true,
),
);
}
/**
* @dataProvider exists_data
*/
public function test_exists($parent, $module, $expected)
{
$this->assertEquals($expected, $this->tool->exists('acp', $parent, $module));
}
public function test_add()
{
try
{
$this->tool->add('acp', 0, 'ACP_NEW_CAT');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertEquals(true, $this->tool->exists('acp', 0, 'ACP_NEW_CAT'));
// Should throw an exception when trying to add a module that already exists
try
{
$this->tool->add('acp', 0, 'ACP_NEW_CAT');
$this->fail('Exception not thrown');
}
catch (Exception $e) {}
try
{
$this->tool->add('acp', 'ACP_NEW_CAT', array(
'module_basename' => 'acp_new_module',
'module_langname' => 'ACP_NEW_MODULE',
'module_mode' => 'test',
'module_auth' => '',
));
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE'));
}
public function test_remove()
{
try
{
$this->tool->remove('acp', 'ACP_CAT', 'ACP_MODULE');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertEquals(false, $this->tool->exists('acp', 'ACP_CAT', 'ACP_MODULE'));
}
public function test_reverse()
{
try
{
$this->tool->add('acp', 0, 'ACP_NEW_CAT');
}
catch (Exception $e)
{
$this->fail($e);
}
try
{
$this->tool->reverse('add', 'acp', 0, 'ACP_NEW_CAT');
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertFalse($this->tool->exists('acp', 0, 'ACP_NEW_CAT'));
}
}

View file

@ -0,0 +1,159 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/tool/permission.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/exception.php';
class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
{
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_permission.xml');
}
public function setup()
{
// Global $db and $cache are needed in acp/auth.php constructor
global $phpbb_root_path, $phpEx, $db, $cache;
parent::setup();
$db = $this->db = $this->new_dbal();
$cache = $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null(), new phpbb_config(array()), $this->db, $phpbb_root_path, $phpEx);
$this->auth = new phpbb_auth();
$this->tool = new phpbb_db_migration_tool_permission($this->db, $this->cache, $this->auth, $phpbb_root_path, $phpEx);
}
public function exists_data()
{
return array(
array(
'global',
true,
true,
),
array(
'local',
false,
true,
),
array(
'both',
true,
true,
),
array(
'both',
false,
true,
),
array(
'does_not_exist',
true,
false,
),
);
}
/**
* @dataProvider exists_data
*/
public function test_exists($auth_option, $global, $expected)
{
$this->assertEquals($expected, $this->tool->exists($auth_option, $global));
}
public function test_add()
{
try
{
$this->tool->add('new', true);
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertEquals(true, $this->tool->exists('new', true));
$this->assertEquals(false, $this->tool->exists('new', false));
try
{
$this->tool->add('new', false);
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertEquals(true, $this->tool->exists('new', false));
// Should fail (duplicate)
try
{
$this->tool->add('new', true);
$this->fail('Did not throw exception on duplicate');
}
catch (Exception $e) {}
}
public function test_remove()
{
try
{
$this->tool->remove('global', true);
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertEquals(false, $this->tool->exists('global', true));
try
{
$this->tool->remove('both', false);
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertEquals(false, $this->tool->exists('both', false));
// Should fail (does not exist)
try
{
$this->tool->remove('new', true);
$this->fail('Did not throw exception on duplicate');
}
catch (Exception $e) {}
}
public function test_reverse()
{
try
{
$this->tool->reverse('remove', 'global_test', true);
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertTrue($this->tool->exists('global_test', true));
try
{
$this->tool->reverse('add', 'global_test', true);
}
catch (Exception $e)
{
$this->fail($e);
}
$this->assertFalse($this->tool->exists('global_test', true));
}
}

View file

@ -25,14 +25,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
{
parent::setUp();
$this->extension_manager = new phpbb_extension_manager(
$this->new_dbal(),
new phpbb_config(array()),
'phpbb_ext',
dirname(__FILE__) . '/',
'.php',
new phpbb_mock_cache
);
$this->extension_manager = $this->create_extension_manager();
}
public function test_available()
@ -89,15 +82,30 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
public function test_enabled_no_cache()
{
$extension_manager = new phpbb_extension_manager(
$this->new_dbal(),
new phpbb_config(array()),
'phpbb_ext',
dirname(__FILE__) . '/',
'.php'
);
$extension_manager = $this->create_extension_manager(false);
$this->assertEquals(array('foo'), array_keys($extension_manager->all_enabled()));
}
protected function create_extension_manager($with_cache = true)
{
$config = new phpbb_config(array());
$db = $this->new_dbal();
$db_tools = new phpbb_db_tools($db);
$phpbb_root_path = __DIR__ . './../../phpBB/';
$php_ext = 'php';
$table_prefix = 'phpbb_';
return new phpbb_extension_manager(
new phpbb_mock_container_builder(),
$db,
$config,
new phpbb_db_migrator($config, $db, $db_tools, 'phpbb_migrations', $phpbb_root_path, $php_ext, $table_prefix, array()),
'phpbb_ext',
dirname(__FILE__) . '/',
'.' . $php_ext,
($with_cache) ? new phpbb_mock_cache() : null
);
}
}

View file

@ -34,9 +34,11 @@ class metadata_manager_test extends phpbb_database_test_case
'version' => '3.1.0',
));
$this->db = $this->new_dbal();
$this->db_tools = new phpbb_db_tools($this->db);
$this->phpbb_root_path = dirname(__FILE__) . '/';
$this->phpEx = '.php';
$this->user = new phpbb_user();
$this->table_prefix = 'phpbb_';
$this->template = new phpbb_template(
$this->phpbb_root_path,
@ -48,8 +50,10 @@ class metadata_manager_test extends phpbb_database_test_case
);
$this->extension_manager = new phpbb_extension_manager(
new phpbb_mock_container_builder(),
$this->db,
$this->config,
new phpbb_db_migrator($this->config, $this->db, $this->db_tools, 'phpbb_migrations', $this->phpbb_root_path, $this->php_ext, $this->table_prefix, array()),
'phpbb_ext',
$this->phpbb_root_path,
$this->phpEx,

View file

@ -186,6 +186,16 @@ class phpbb_database_test_connection_manager
$this->purge_extras();
break;
case 'phpbb_db_driver_postgres':
$this->connect();
// Drop all of the tables
foreach ($this->get_tables() as $table)
{
$this->pdo->exec('DROP TABLE ' . $table . ' CASCADE');
}
$this->purge_extras();
break;
default:
$this->connect(false);
@ -418,6 +428,19 @@ class phpbb_database_test_connection_manager
$queries[] = 'DROP SEQUENCE ' . current($row);
}
break;
case 'phpbb_db_driver_postgres':
$sql = 'SELECT sequence_name
FROM information_schema.sequences';
$result = $this->pdo->query($sql);
while ($row = $result->fetch(PDO::FETCH_NUM))
{
$queries[] = 'DROP SEQUENCE ' . current($row);
}
$queries[] = 'DROP TYPE IF EXISTS varchar_ci CASCADE';
break;
}
foreach ($queries as $query)

View file

@ -134,19 +134,20 @@ class phpbb_functional_test_case extends phpbb_test_case
{
global $phpbb_root_path, $phpEx;
if (!$this->extension_manager)
{
$this->extension_manager = new phpbb_extension_manager(
$this->get_db(),
new phpbb_config(array()),
self::$config['table_prefix'] . 'ext',
$phpbb_root_path,
".$phpEx",
$this->get_cache_driver()
);
}
$config = new phpbb_config(array());
$db = $this->get_db();
$db_tools = new phpbb_db_tools($db);
return $this->extension_manager;
return new phpbb_extension_manager(
new phpbb_mock_container_builder(),
$db,
$config,
new phpbb_db_migrator($config, $db, $db_tools, self::$config['table_prefix'] . 'migrations', $phpbb_root_path, $php_ext, self::$config['table_prefix'], array()),
self::$config['table_prefix'] . 'ext',
dirname(__FILE__) . '/',
'.' . $php_ext,
$this->get_cache_driver()
);
}
static protected function install_board()

View file

@ -0,0 +1,21 @@
#!/bin/bash
#
# @copyright (c) 2013 phpBB Group
# @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
#
set -e
function add_ext_to_php_ini
{
echo "extension=$1.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
}
# redis
git clone git://github.com/nicolasff/phpredis.git
cd phpredis
phpize
./configure
make
make install
cd ..
add_ext_to_php_ini 'redis'

View file

@ -17,7 +17,7 @@
<exclude>tests/functional</exclude>
</testsuite>
<testsuite name="phpBB Functional Tests">
<directory suffix="_test.php" phpVersion="5.3.0" phpVersionOperator=">=">../tests/functional</directory>
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/functional</directory>
</testsuite>
</testsuites>
@ -34,6 +34,8 @@
<server name="PHPBB_TEST_DBNAME" value="phpbb_tests" />
<server name="PHPBB_TEST_DBUSER" value="root" />
<server name="PHPBB_TEST_DBPASSWD" value="" />
<server name="PHPBB_TEST_REDIS_HOST" value="localhost" />
<server name="PHPBB_TEST_TABLE_PREFIX" value="phpbb_"/>
<server name="PHPBB_FUNCTIONAL_URL" value="http://localhost/" />
</php>
</phpunit>

View file

@ -17,7 +17,7 @@
<exclude>tests/functional</exclude>
</testsuite>
<testsuite name="phpBB Functional Tests">
<directory suffix="_test.php" phpVersion="5.3.0" phpVersionOperator=">=">../tests/functional</directory>
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/functional</directory>
</testsuite>
</testsuites>
@ -36,6 +36,8 @@
<server name="PHPBB_TEST_DBNAME" value="phpbb_tests" />
<server name="PHPBB_TEST_DBUSER" value="postgres" />
<server name="PHPBB_TEST_DBPASSWD" value="" />
<server name="PHPBB_TEST_REDIS_HOST" value="localhost" />
<server name="PHPBB_TEST_TABLE_PREFIX" value="phpbb_"/>
<server name="PHPBB_FUNCTIONAL_URL" value="http://localhost/" />
</php>
</phpunit>

54
travis/setup-webserver.sh Executable file
View file

@ -0,0 +1,54 @@
#!/bin/bash
#
# @copyright (c) 2013 phpBB Group
# @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
#
set -e
sudo apt-get update -qq
sudo apt-get install -qq nginx realpath
sudo service nginx stop
DIR=$(dirname "$0")
PHPBB_ROOT_PATH=$(realpath "$DIR/../phpBB")
NGINX_CONF="/etc/nginx/sites-enabled/default"
PHP_FPM_BIN="$HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/sbin/php-fpm"
PHP_FPM_CONF="$DIR/php-fpm.conf"
PHP_FPM_SOCK=$(realpath "$DIR")/php-fpm.sock
USER=$(whoami)
# php-fpm configuration
echo "
[global]
[travis]
user = $USER
group = $USER
listen = $PHP_FPM_SOCK
pm = static
pm.max_children = 2
php_admin_value[memory_limit] = 128M
" > $PHP_FPM_CONF
# nginx configuration
echo "
server {
listen 80;
root $PHPBB_ROOT_PATH/;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass unix:$PHP_FPM_SOCK;
include fastcgi_params;
}
}
" | sudo tee $NGINX_CONF > /dev/null
# Start daemons
sudo $PHP_FPM_BIN --fpm-config "$DIR/php-fpm.conf"
sudo service nginx start