Merge branch 'develop' of https://github.com/phpbb/phpbb3 into feature/softdelete-1-permission

* 'develop' of https://github.com/phpbb/phpbb3: (480 commits)
  [ticket/6723] Show info that message has been deleted before delivery
  [ticket/11385] Fix issue with migration module tool not getting extension module info
  [ticket/11386] Fix failing tests from constructor changes
  [ticket/11386] Fix circular reference error & serialize error
  [ticket/11386] Remove tests that check if finder cache is working
  [ticket/11386] Forgot to get the migration classes
  [ticket/11386] Update tests with new constructors for ext.manager/migrator
  [ticket/11386] Use finder to find migration files
  [ticket/11363] Fix to make get_module_infos get from all extensions
  [ticket/11381] Make finder able to search in all available extensions
  [ticket/11103] Revert whitespace changes
  [ticket/11103] Few more minor language things
  [ticket/11103] Don't call generate_board_url many times
  [ticket/11103] Case time in queries as an int
  [ticket/11103] Fix effectively installed check
  [ticket/11103] Remove padding from notifications for now.
  [ticket/11363] Fix a couple bugs and throw errors if the file not found
  [ticket/11372] Migrator should only check if effectively installed if not
  [ticket/11363] Load module info files for extensions too
  [ticket/11103] Notifications Migration file
  ...

Conflicts:
	phpBB/includes/functions_posting.php
	phpBB/includes/mcp/mcp_queue.php
	phpBB/includes/search/fulltext_mysql.php
	phpBB/includes/search/fulltext_native.php
	phpBB/includes/search/fulltext_postgres.php
	phpBB/includes/search/fulltext_sphinx.php
	phpBB/install/database_update.php
	phpBB/styles/prosilver/template/ajax.js
This commit is contained in:
Joas Schilling 2013-03-03 20:06:52 +01:00
commit 42c062cedf
281 changed files with 19084 additions and 5895 deletions

View file

@ -3,21 +3,28 @@ php:
- 5.3.3
- 5.3
- 5.4
- 5.5
env:
- DB=mysql
- DB=postgres
matrix:
allow_failures:
- php: 5.5
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

@ -2,17 +2,16 @@
<project name="phpBB" description="The phpBB forum software" default="all" basedir="../">
<!-- a few settings for the build -->
<property name="newversion" value="3.0.11" />
<property name="prevversion" value="3.0.10" />
<property name="olderversions" value="3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.7-PL1, 3.0.8, 3.0.9, 3.0.11-RC1, 3.0.11-RC2" />
<property name="newversion" value="3.1.0-dev" />
<property name="prevversion" value="3.0.11" />
<property name="olderversions" value="3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.7-PL1, 3.0.8, 3.0.9, 3.0.10" />
<!-- no configuration should be needed beyond this point -->
<property name="oldversions" value="${olderversions}, ${prevversion}" />
<property name="versions" value="${oldversions}, ${newversion}" />
<!-- These are the main targets which you will probably want to use -->
<target name="package" depends="clean,prepare,composer,create-package" />
<target name="all" depends="clean,prepare,composer,test,docs,create-package" />
<target name="all" depends="clean,prepare,composer,test,docs,package" />
<target name="build" depends="clean,prepare,composer,test,docs" />
<target name="prepare">
@ -43,9 +42,15 @@
<delete dir="build/save" />
</target>
<target name="composer" depends="clean,prepare">
<exec dir="./phpBB/"
command="php ../composer.phar install"
<!--
This target basically just runs composer in the phpBB tree to ensure
all dependencies are loaded. Additional development dependencies are
loaded because testing framework may depend on them.
-->
<target name="composer">
<exec dir="phpBB"
command="php ../composer.phar install --dev"
checkreturn="true"
passthru="true" />
</target>
@ -122,7 +127,7 @@
</target>
<target name="create-package" depends="prepare-new-version,old-version-diffs">
<target name="package" depends="clean,prepare,prepare-new-version,old-version-diffs">
<exec dir="build" command="php -f package.php '${versions}' > logs/package.log" escape="false" />
<exec dir="build" command="php -f build_diff.php '${prevversion}' '${newversion}' > logs/build_diff.log" escape="false" />
@ -162,9 +167,27 @@
command="git archive ${revision} | tar -xf - -C ../${dir}"
checkreturn="true" />
<exec dir="${dir}"
command="php ../composer.phar install"
passthru="true" />
<!--
If composer.phar exists in this version of the tree, also export
it into ${dir}, install dependencies, then delete it again.
-->
<exec dir="."
command="git ls-tree ${revision} composer.phar"
checkreturn="true"
outputProperty='composer-ls-tree-output' />
<if>
<not><equals arg1="${composer-ls-tree-output}" arg2="" trim="true" /></not>
<then>
<exec dir="."
command="git archive ${revision} composer.phar | tar -xf - -C ${dir}"
checkreturn="true" />
<exec dir="${dir}"
command="php composer.phar install"
checkreturn="true"
passthru="true" />
<delete file="${dir}/composer.phar" />
</then>
</if>
<delete file="${dir}/config.php" />
<delete dir="${dir}/develop" />
@ -187,6 +210,7 @@
<delete dir="${dir}/files" />
<delete dir="${dir}/install" />
<delete dir="${dir}/store" />
<delete dir="${dir}/vendor" />
</target>
</project>

View file

@ -42,7 +42,6 @@ if (!$auth->acl_get('a_'))
// We define the admin variables now, because the user is now able to use the admin related features...
define('IN_ADMIN', true);
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
// Some oft used variables
$safe_mode = (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) === 'on') ? true : false;

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

@ -2,11 +2,11 @@
"use strict";
var img_templates = {
var imgTemplates = {
up: $('.template-up-img'),
up_disabled: $('.template-up-img-disabled'),
upDisabled: $('.template-up-img-disabled'),
down: $('.template-down-img'),
down_disabled: $('.template-down-img-disabled')
downDisabled: $('.template-down-img-disabled')
};
/**
@ -15,20 +15,19 @@ var img_templates = {
* an item is moved up. It moves the row up or down, and deactivates /
* activates any up / down icons that require it (the ones at the top or bottom).
*/
phpbb.add_ajax_callback('row_down', function() {
phpbb.addAjaxCallback('row_down', function() {
var el = $(this),
tr = el.parents('tr'),
tr_swap = tr.next();
trSwap = tr.next();
/*
* If the element was the first one, we have to:
* - Add the up-link to the row we moved
* - Remove the up-link on the next row
*/
if (tr.is(':first-child'))
{
var up_img = img_templates.up.clone().attr('href', tr.attr('data-up'));
tr.find('.up').html(up_img);
if (tr.is(':first-child')) {
var upImg = imgTemplates.up.clone().attr('href', tr.attr('data-up'));
tr.find('.up').html(upImg);
phpbb.ajaxify({
selector: tr.find('.up').children('a'),
@ -36,45 +35,43 @@ phpbb.add_ajax_callback('row_down', function() {
overlay: false
});
tr_swap.find('.up').html(img_templates.up_disabled.clone());
trSwap.find('.up').html(imgTemplates.upDisabled.clone());
}
tr.insertAfter(tr_swap);
tr.insertAfter(trSwap);
/*
* As well as:
* - Remove the down-link on the moved row, if it is now the last row
* - Add the down-link to the next row, if it was the last row
*/
if (tr.is(':last-child'))
{
tr.find('.down').html(img_templates.down_disabled.clone());
if (tr.is(':last-child')) {
tr.find('.down').html(imgTemplates.downDisabled.clone());
var down_img = img_templates.down.clone().attr('href', tr_swap.attr('data-down'));
tr_swap.find('.down').html(down_img);
var downImg = imgTemplates.down.clone().attr('href', trSwap.attr('data-down'));
trSwap.find('.down').html(downImg);
phpbb.ajaxify({
selector: tr_swap.find('.down').children('a'),
selector: trSwap.find('.down').children('a'),
callback: 'row_down',
overlay: false
});
}
});
phpbb.add_ajax_callback('row_up', function() {
phpbb.addAjaxCallback('row_up', function() {
var el = $(this),
tr = el.parents('tr'),
tr_swap = tr.prev();
trSwap = tr.prev();
/*
* If the element was the last one, we have to:
* - Add the down-link to the row we moved
* - Remove the down-link on the next row
*/
if (tr.is(':last-child'))
{
var down_img = img_templates.down.clone().attr('href', tr.attr('data-down'));
tr.find('.down').html(down_img);
if (tr.is(':last-child')) {
var downImg = imgTemplates.down.clone().attr('href', tr.attr('data-down'));
tr.find('.down').html(downImg);
phpbb.ajaxify({
selector: tr.find('.down').children('a'),
@ -82,25 +79,24 @@ phpbb.add_ajax_callback('row_up', function() {
overlay: false
});
tr_swap.find('.down').html(img_templates.down_disabled.clone());
trSwap.find('.down').html(imgTemplates.downDisabled.clone());
}
tr.insertBefore(tr_swap);
tr.insertBefore(trSwap);
/*
* As well as:
* - Remove the up-link on the moved row, if it is now the first row
* - Add the up-link to the previous row, if it was the first row
*/
if (tr.is(':first-child'))
{
tr.find('.up').html(img_templates.up_disabled.clone());
if (tr.is(':first-child')) {
tr.find('.up').html(imgTemplates.upDisabled.clone());
var up_img = img_templates.up.clone().attr('href', tr_swap.attr('data-up'));
tr_swap.find('.up').html(up_img);
var upImg = imgTemplates.up.clone().attr('href', trSwap.attr('data-up'));
trSwap.find('.up').html(upImg);
phpbb.ajaxify({
selector: tr_swap.find('.up').children('a'),
selector: trSwap.find('.up').children('a'),
callback: 'row_up',
overlay: false
});
@ -112,29 +108,26 @@ phpbb.add_ajax_callback('row_up', function() {
* It does this by replacing the text, and replacing all instances of "activate"
* in the href with "deactivate", and vice versa.
*/
phpbb.add_ajax_callback('activate_deactivate', function(res) {
phpbb.addAjaxCallback('activate_deactivate', function(res) {
var el = $(this),
new_href = el.attr('href');
newHref = el.attr('href');
el.text(res.text);
if (new_href.indexOf('deactivate') !== -1)
{
new_href = new_href.replace('deactivate', 'activate')
}
else
{
new_href = new_href.replace('activate', 'deactivate')
if (newHref.indexOf('deactivate') !== -1) {
newHref = newHref.replace('deactivate', 'activate')
} else {
newHref = newHref.replace('activate', 'deactivate')
}
el.attr('href', new_href);
el.attr('href', newHref);
});
/**
* The removes the parent row of the link or form that triggered the callback,
* and is good for stuff like the removal of forums.
*/
phpbb.add_ajax_callback('row_delete', function() {
phpbb.addAjaxCallback('row_delete', function() {
$(this).parents('tr').remove();
});
@ -145,8 +138,7 @@ $('[data-ajax]').each(function() {
ajax = $this.attr('data-ajax'),
fn;
if (ajax !== 'false')
{
if (ajax !== 'false') {
fn = (ajax !== 'true') ? ajax : null;
phpbb.ajaxify({
selector: this,

View file

@ -5,7 +5,7 @@
<!-- IF META -->{META}<!-- ENDIF -->
<title>{PAGE_TITLE}</title>
<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />
<link href="{T_TEMPLATE_PATH}/admin.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[

View file

@ -5,7 +5,7 @@
<!-- IF META -->{META}<!-- ENDIF -->
<title>{PAGE_TITLE}</title>
<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />
<link href="{T_TEMPLATE_PATH}/admin.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[

View file

@ -1,11 +1,11 @@
(function($) { // Avoid conflicts with other libraries
$('#tz_date').change(function() {
phpbb.timezone_switch_date(false);
phpbb.timezoneSwitchDate(false);
});
$(document).ready(
phpbb.timezone_enable_date_selection
phpbb.timezoneEnableDateSelection
);
})(jQuery); // Avoid conflicts with other libraries

View file

@ -21,8 +21,6 @@ $user->session_begin(false);
$auth->acl($user->data);
$user->setup();
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
// Set custom template for admin area
$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), '');

View file

@ -1,5 +1,5 @@
var phpbb = {};
phpbb.alert_time = 100;
phpbb.alertTime = 100;
(function($) { // Avoid conflicts with other libraries
@ -12,35 +12,42 @@ var keymap = {
};
var dark = $('#darkenwrapper');
var loading_alert = $('#loadingalert');
var loadingAlert = $('#loadingalert');
var phpbbAlertTimer = null;
/**
* Display a loading screen.
* Display a loading screen
*
* @returns object Returns loading_alert.
* @returns object Returns loadingAlert.
*/
phpbb.loading_alert = function() {
if (dark.is(':visible'))
{
loading_alert.fadeIn(phpbb.alert_time);
}
else
{
loading_alert.show();
dark.fadeIn(phpbb.alert_time, function() {
phpbb.loadingAlert = function() {
if (dark.is(':visible')) {
loadingAlert.fadeIn(phpbb.alertTime);
} else {
loadingAlert.show();
dark.fadeIn(phpbb.alertTime, function() {
// Wait five seconds and display an error if nothing has been returned by then.
setTimeout(function() {
if (loading_alert.is(':visible'))
{
phpbbAlertTimer = setTimeout(function() {
if (loadingAlert.is(':visible')) {
phpbb.alert($('#phpbb_alert').attr('data-l-err'), $('#phpbb_alert').attr('data-l-timeout-processing-req'));
}
}, 5000);
});
}
return loading_alert;
}
return loadingAlert;
};
/**
* Clear loading alert timeout
*/
phpbb.clearLoadingTimeout = function() {
if (phpbbAlertTimer !== null) {
clearTimeout(phpbbAlertTimer);
phpbbAlertTimer = null;
}
};
/**
* Display a simple alert similar to JSs native alert().
@ -67,7 +74,7 @@ phpbb.alert = function(title, msg, fadedark) {
div.find('.alert_close').unbind('click');
fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark;
fade.fadeOut(phpbb.alert_time, function() {
fade.fadeOut(phpbb.alertTime, function() {
div.hide();
});
@ -90,27 +97,22 @@ phpbb.alert = function(title, msg, fadedark) {
e.preventDefault();
});
if (loading_alert.is(':visible'))
{
loading_alert.fadeOut(phpbb.alert_time, function() {
if (loadingAlert.is(':visible')) {
loadingAlert.fadeOut(phpbb.alertTime, function() {
dark.append(div);
div.fadeIn(phpbb.alert_time);
div.fadeIn(phpbb.alertTime);
});
}
else if (dark.is(':visible'))
{
} else if (dark.is(':visible')) {
dark.append(div);
div.fadeIn(phpbb.alert_time);
}
else
{
div.fadeIn(phpbb.alertTime);
} else {
dark.append(div);
div.show();
dark.fadeIn(phpbb.alert_time);
dark.fadeIn(phpbb.alertTime);
}
return div;
}
};
/**
* Display a simple yes / no box to the user.
@ -133,13 +135,13 @@ phpbb.confirm = function(msg, callback, fadedark) {
e.stopPropagation();
});
var click_handler = function(e) {
var clickHandler = function(e) {
var res = this.className === 'button1';
var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark;
fade.fadeOut(phpbb.alert_time, function() {
fade.fadeOut(phpbb.alertTime, function() {
div.hide();
});
div.find('input[type="button"]').unbind('click', click_handler);
div.find('input[type="button"]').unbind('click', clickHandler);
callback(res);
if (e) {
@ -147,11 +149,11 @@ phpbb.confirm = function(msg, callback, fadedark) {
e.stopPropagation();
}
};
div.find('input[type="button"]').one('click', click_handler);
div.find('input[type="button"]').one('click', clickHandler);
dark.one('click', function(e) {
div.find('.alert_close').unbind('click');
dark.fadeOut(phpbb.alert_time, function() {
dark.fadeOut(phpbb.alertTime, function() {
div.hide();
});
callback(false);
@ -174,7 +176,7 @@ phpbb.confirm = function(msg, callback, fadedark) {
div.find('.alert_close').one('click', function(e) {
var fade = (typeof fadedark !== 'undefined' && fadedark) ? div : dark;
fade.fadeOut(phpbb.alert_time, function() {
fade.fadeOut(phpbb.alertTime, function() {
div.hide();
});
callback(false);
@ -182,27 +184,22 @@ phpbb.confirm = function(msg, callback, fadedark) {
e.preventDefault();
});
if (loading_alert.is(':visible'))
{
loading_alert.fadeOut(phpbb.alert_time, function() {
if (loadingAlert.is(':visible')) {
loadingAlert.fadeOut(phpbb.alertTime, function() {
dark.append(div);
div.fadeIn(phpbb.alert_time);
div.fadeIn(phpbb.alertTime);
});
}
else if (dark.is(':visible'))
{
} else if (dark.is(':visible')) {
dark.append(div);
div.fadeIn(phpbb.alert_time);
}
else
{
div.fadeIn(phpbb.alertTime);
} else {
dark.append(div);
div.show();
dark.fadeIn(phpbb.alert_time);
dark.fadeIn(phpbb.alertTime);
}
return div;
}
};
/**
* Turn a querystring into an array.
@ -210,17 +207,16 @@ phpbb.confirm = function(msg, callback, fadedark) {
* @argument string string The querystring to parse.
* @returns object The object created.
*/
phpbb.parse_querystring = function(string) {
phpbb.parseQuerystring = function(string) {
var params = {}, i, split;
string = string.split('&');
for (i = 0; i < string.length; i++)
{
for (i = 0; i < string.length; i++) {
split = string[i].split('=');
params[split[0]] = decodeURIComponent(split[1]);
}
return params;
}
};
/**
@ -246,14 +242,13 @@ phpbb.ajaxify = function(options) {
refresh = options.refresh,
callback = options.callback,
overlay = (typeof options.overlay !== 'undefined') ? options.overlay : true,
is_form = elements.is('form'),
event_name = is_form ? 'submit' : 'click';
isForm = elements.is('form'),
eventName = isForm ? 'submit' : 'click';
elements.bind(event_name, function(event) {
elements.bind(eventName, function(event) {
var action, method, data, submit, that = this, $this = $(this);
if ($this.find('input[type="submit"][data-clicked]').attr('data-ajax') === 'false')
{
if ($this.find('input[type="submit"][data-clicked]').attr('data-ajax') === 'false') {
return;
}
@ -267,104 +262,88 @@ phpbb.ajaxify = function(options) {
*
* @param object res The object sent back by the server.
*/
function return_handler(res)
{
function returnHandler(res) {
var alert;
phpbb.clearLoadingTimeout();
// Is a confirmation required?
if (typeof res.S_CONFIRM_ACTION === 'undefined')
{
if (typeof res.S_CONFIRM_ACTION === 'undefined') {
// If a confirmation is not required, display an alert and call the
// callbacks.
if (typeof res.MESSAGE_TITLE !== 'undefined')
{
if (typeof res.MESSAGE_TITLE !== 'undefined') {
alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
}
else
{
dark.fadeOut(phpbb.alert_time);
} else {
dark.fadeOut(phpbb.alertTime);
}
if (typeof phpbb.ajax_callbacks[callback] === 'function')
{
phpbb.ajax_callbacks[callback].call(that, res);
if (typeof phpbb.ajaxCallbacks[callback] === 'function') {
phpbb.ajaxCallbacks[callback].call(that, res);
}
// If the server says to refresh the page, check whether the page should
// be refreshed and refresh page after specified time if required.
if (res.REFRESH_DATA)
{
if (typeof refresh === 'function')
{
if (res.REFRESH_DATA) {
if (typeof refresh === 'function') {
refresh = refresh(res.REFRESH_DATA.url);
}
else if (typeof refresh !== 'boolean')
{
} else if (typeof refresh !== 'boolean') {
refresh = false;
}
setTimeout(function() {
if (refresh)
{
if (refresh) {
window.location = res.REFRESH_DATA.url;
}
// Hide the alert even if we refresh the page, in case the user
// presses the back button.
dark.fadeOut(phpbb.alert_time, function() {
dark.fadeOut(phpbb.alertTime, function() {
alert.hide();
});
}, res.REFRESH_DATA.time * 1000); // Server specifies time in seconds
}
}
else
{
} else {
// If confirmation is required, display a diologue to the user.
phpbb.confirm(res.MESSAGE_TEXT, function(del) {
if (del)
{
phpbb.loading_alert();
if (del) {
phpbb.loadingAlert();
data = $('<form>' + res.S_HIDDEN_FIELDS + '</form>').serialize();
$.ajax({
url: res.S_CONFIRM_ACTION,
type: 'POST',
data: data + '&confirm=' + res.YES_VALUE,
success: return_handler,
error: error_handler
success: returnHandler,
error: errorHandler
});
}
}, false);
}
}
function error_handler()
{
function errorHandler() {
var alert;
phpbb.clearLoadingTimeout();
alert = phpbb.alert(dark.attr('data-ajax-error-title'), dark.attr('data-ajax-error-text'));
}
// If the element is a form, POST must be used and some extra data must
// be taken from the form.
var run_filter = (typeof options.filter === 'function');
var runFilter = (typeof options.filter === 'function');
if (is_form)
{
if (isForm) {
action = $this.attr('action').replace('&amp;', '&');
data = $this.serializeArray();
method = $this.attr('method') || 'GET';
if ($this.find('input[type="submit"][data-clicked]'))
{
if ($this.find('input[type="submit"][data-clicked]')) {
submit = $this.find('input[type="submit"][data-clicked]');
data.push({
name: submit.attr('name'),
value: submit.val()
});
}
}
else
{
} else {
action = this.href;
data = null;
method = 'GET';
@ -372,28 +351,27 @@ phpbb.ajaxify = function(options) {
// If filter function returns false, cancel the AJAX functionality,
// and return true (meaning that the HTTP request will be sent normally).
if (run_filter && !options.filter.call(this, data))
{
if (runFilter && !options.filter.call(this, data)) {
return;
}
if (overlay && (typeof $this.attr('data-overlay') === 'undefined' || $this.attr('data-overlay') == 'true'))
{
phpbb.loading_alert();
phpbb.loadingAlert();
}
$.ajax({
url: action,
type: method,
data: data,
success: return_handler,
error: error_handler
success: returnHandler,
error: errorHandler
});
event.preventDefault();
});
if (is_form) {
if (isForm) {
elements.find('input:submit').click(function () {
var $this = $(this);
@ -403,14 +381,14 @@ phpbb.ajaxify = function(options) {
}
return this;
}
};
/**
* Hide the optgroups that are not the selected timezone
*
* @param bool keep_selection Shall we keep the value selected, or shall the user be forced to repick one.
* @param bool keepSelection Shall we keep the value selected, or shall the user be forced to repick one.
*/
phpbb.timezone_switch_date = function(keep_selection) {
phpbb.timezoneSwitchDate = function(keepSelection) {
if ($('#timezone_copy').length == 0) {
// We make a backup of the original dropdown, so we can remove optgroups
// instead of setting display to none, because IE and chrome will not
@ -434,27 +412,30 @@ phpbb.timezone_switch_date = function(keep_selection) {
if ($("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option").size() == 1) {
// If there is only one timezone for the selected date, we just select that automatically.
$("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option:first").attr('selected', true);
keep_selection = true;
keepSelection = true;
}
if (typeof keep_selection !== 'undefined' && !keep_selection) {
$('#timezone > option:first').attr('selected', true);
if (typeof keepSelection !== 'undefined' && !keepSelection) {
var timezoneOptions = $('#timezone > optgroup option');
if (timezoneOptions.filter(':selected').length <= 0) {
timezoneOptions.filter(':first').attr('selected', true);
}
}
}
};
/**
* Display the date/time select
*/
phpbb.timezone_enable_date_selection = function() {
phpbb.timezoneEnableDateSelection = function() {
$('#tz_select_date').css('display', 'block');
}
};
/**
* Preselect a date/time or suggest one, if it is not picked.
*
* @param bool force_selector Shall we select the suggestion?
* @param bool forceSelector Shall we select the suggestion?
*/
phpbb.timezone_preselect_select = function(force_selector) {
phpbb.timezonePreselectSelect = function(forceSelector) {
// The offset returned here is in minutes and negated.
// http://www.w3schools.com/jsref/jsref_getTimezoneOffset.asp
@ -483,21 +464,21 @@ phpbb.timezone_preselect_select = function(force_selector) {
}
var prefix = 'GMT' + sign + hours + ':' + minutes;
var prefix_length = prefix.length;
var selector_options = $('#tz_date > option');
var prefixLength = prefix.length;
var selectorOptions = $('#tz_date > option');
for (var i = 0; i < selector_options.length; ++i) {
var option = selector_options[i];
for (var i = 0; i < selectorOptions.length; ++i) {
var option = selectorOptions[i];
if (option.value.substring(0, prefix_length) == prefix) {
if ($('#tz_date').val() != option.value && !force_selector) {
if (option.value.substring(0, prefixLength) == prefix) {
if ($('#tz_date').val() != option.value && !forceSelector) {
// We do not select the option for the user, but notify him,
// that we would suggest a different setting.
phpbb.timezone_switch_date(true);
phpbb.timezoneSwitchDate(true);
$('#tz_select_date_suggest').css('display', 'inline');
} else {
option.selected = true;
phpbb.timezone_switch_date(!force_selector);
phpbb.timezoneSwitchDate(!forceSelector);
$('#tz_select_date_suggest').css('display', 'none');
}
@ -509,9 +490,22 @@ phpbb.timezone_preselect_select = function(force_selector) {
return;
}
}
}
};
phpbb.ajax_callbacks = {};
// Toggle notification list
$('#notification_list_button').click(function(e) {
$('#notification_list').toggle();
e.preventDefault();
});
$('#phpbb').click(function(e) {
var target = $(e.target);
if (!target.is('#notification_list') && !target.is('#notification_list_button') && !target.parents().is('#notification_list')) {
$('#notification_list').hide();
}
});
phpbb.ajaxCallbacks = {};
/**
* Adds an AJAX callback to be used by phpbb.ajaxify.
@ -521,14 +515,12 @@ phpbb.ajax_callbacks = {};
* @param string id The name of the callback.
* @param function callback The callback to be called.
*/
phpbb.add_ajax_callback = function(id, callback)
{
if (typeof callback === 'function')
{
phpbb.ajax_callbacks[id] = callback;
phpbb.addAjaxCallback = function(id, callback) {
if (typeof callback === 'function') {
phpbb.ajaxCallbacks[id] = callback;
}
return this;
}
};
/**
@ -536,14 +528,14 @@ phpbb.add_ajax_callback = function(id, callback)
* the alt-text data attribute, and replaces the text in the attribute with the
* current text so that the process can be repeated.
*/
phpbb.add_ajax_callback('alt_text', function() {
phpbb.addAjaxCallback('alt_text', function() {
var el = $(this),
alt_text;
altText;
alt_text = el.attr('data-alt-text');
altText = el.attr('data-alt-text');
el.attr('data-alt-text', el.text());
el.attr('title', alt_text);
el.text(alt_text);
el.attr('title', altText);
el.text(altText);
});
/**
@ -555,28 +547,28 @@ phpbb.add_ajax_callback('alt_text', function() {
* Additionally it replaces the class of the link's parent
* and changes the link itself.
*/
phpbb.add_ajax_callback('toggle_link', function() {
phpbb.addAjaxCallback('toggle_link', function() {
var el = $(this),
toggle_text,
toggle_url,
toggle_class;
toggleText,
toggleUrl,
toggleClass;
// Toggle link text
toggle_text = el.attr('data-toggle-text');
toggleText = el.attr('data-toggle-text');
el.attr('data-toggle-text', el.text());
el.attr('title', toggle_text);
el.text(toggle_text);
el.attr('title', toggleText);
el.text(toggleText);
// Toggle link url
toggle_url = el.attr('data-toggle-url');
toggleUrl = el.attr('data-toggle-url');
el.attr('data-toggle-url', el.attr('href'));
el.attr('href', toggle_url);
el.attr('href', toggleUrl);
// Toggle class of link parent
toggle_class = el.attr('data-toggle-class');
toggleClass = el.attr('data-toggle-class');
el.attr('data-toggle-class', el.parent().attr('class'));
el.parent().attr('class', toggle_class);
el.parent().attr('class', toggleClass);
});
})(jQuery); // Avoid conflicts with other libraries

View file

@ -63,6 +63,10 @@ if (!defined('PHPBB_INSTALLED'))
exit;
}
// In case $phpbb_adm_relative_path is not set (in case of an update), use the default.
$phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/';
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path;
// Include files
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
@ -83,18 +87,7 @@ $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_pat
$phpbb_class_loader_ext->register();
// Set up container
$phpbb_container = phpbb_create_dumped_container_unless_debug(
array(
new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx),
new phpbb_di_extension_core($phpbb_root_path),
),
array(
new phpbb_di_pass_collection_pass(),
new phpbb_di_pass_kernel_pass(),
),
$phpbb_root_path,
$phpEx
);
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
@ -127,8 +120,9 @@ $phpbb_style = $phpbb_container->get('style');
// Add own hook handler
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('phpbb_template', 'display')));
$phpbb_hook_finder = $phpbb_container->get('hook_finder');
foreach ($cache->obtain_hooks() as $hook)
foreach ($phpbb_hook_finder->find() as $hook)
{
@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
}

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

@ -0,0 +1,51 @@
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
calls:
- [set_extension_manager, [@ext.manager]]
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

@ -0,0 +1,314 @@
services:
notification.type_collection:
class: phpbb_di_service_collection
arguments:
- @service_container
tags:
- { name: service_collection, tag: notification.type }
notification.method_collection:
class: phpbb_di_service_collection
arguments:
- @service_container
tags:
- { name: service_collection, tag: notification.method }
notification.type.approve_post:
class: phpbb_notification_type_approve_post
scope: prototype # scope MUST be prototype for this to work! # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.approve_topic:
class: phpbb_notification_type_approve_topic
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.bookmark:
class: phpbb_notification_type_bookmark
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.disapprove_post:
class: phpbb_notification_type_disapprove_post
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.disapprove_topic:
class: phpbb_notification_type_disapprove_topic
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.pm:
class: phpbb_notification_type_pm
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.post:
class: phpbb_notification_type_post
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.post_in_queue:
class: phpbb_notification_type_post_in_queue
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.quote:
class: phpbb_notification_type_quote
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.report_pm:
class: phpbb_notification_type_report_pm
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.report_pm_closed:
class: phpbb_notification_type_report_pm_closed
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.report_post:
class: phpbb_notification_type_report_post
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.report_post_closed:
class: phpbb_notification_type_report_post
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.topic:
class: phpbb_notification_type_topic
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.type.topic_in_queue:
class: phpbb_notification_type_topic_in_queue
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
notification.method.email:
class: phpbb_notification_method_email
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
tags:
- { name: notification.method }
notification.method.jabber:
class: phpbb_notification_method_jabber
scope: prototype # scope MUST be prototype for this to work!
arguments:
- @user_loader
- @dbal.conn
- @cache.driver
- @user
- @auth
- @config
- %core.root_path%
- %core.php_ext%
tags:
- { name: notification.method }

View file

@ -1,6 +1,8 @@
imports:
- { resource: tables.yml }
- { resource: cron_tasks.yml }
- { resource: notifications.yml }
- { resource: migrator.yml }
services:
auth:
@ -10,6 +12,10 @@ services:
class: phpbb_cache_service
arguments:
- @cache.driver
- @config
- @dbal.conn
- %core.root_path%
- %core.php_ext%
cache.driver:
class: %cache.driver.class%
@ -90,6 +96,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:
@ -101,12 +113,15 @@ services:
ext.manager:
class: phpbb_extension_manager
arguments:
- @service_container
- @dbal.conn
- @config
- %tables.ext%
- %core.root_path%
- .%core.php_ext%
- @cache.driver
calls:
- [set_migrator, [@migrator]]
ext.finder:
class: phpbb_extension_finder
@ -123,6 +138,13 @@ services:
- @dispatcher
- @controller.resolver
hook_finder:
class: phpbb_hook_finder
arguments:
- %core.root_path%
- .%core.php_ext%
- @cache.driver
kernel_request_subscriber:
class: phpbb_event_kernel_request_subscriber
arguments:
@ -145,6 +167,21 @@ services:
tags:
- { name: kernel.event_subscriber }
notification_manager:
class: phpbb_notification_manager
arguments:
- @notification.type_collection
- @notification.method_collection
- @service_container
- @user_loader
- @dbal.conn
- @user
- %core.root_path%
- %core.php_ext%
- %tables.notification_types%
- %tables.notifications%
- %tables.user_notifications%
request:
class: phpbb_request
@ -187,3 +224,11 @@ services:
user:
class: phpbb_user
user_loader:
class: phpbb_user_loader
arguments:
- @dbal.conn
- %core.root_path%
- %core.php_ext%
- %tables.users%

View file

@ -1,3 +1,9 @@
parameters:
tables.config: %core.table_prefix%config
tables.ext: %core.table_prefix%ext
tables.notification_types: %core.table_prefix%notification_types
tables.notifications: %core.table_prefix%notifications
tables.user_notifications: %core.table_prefix%user_notifications
tables.users: %core.table_prefix%users
tables.migrations: %core.table_prefix%migrations
tables.modules: %core.table_prefix%modules

View file

@ -1276,6 +1276,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'),
@ -1298,6 +1311,32 @@ function get_schema_struct()
),
);
$schema_data['phpbb_notification_types'] = array(
'COLUMNS' => array(
'notification_type' => array('VCHAR:255', ''),
'notification_type_enabled' => array('BOOL', 1),
),
'PRIMARY_KEY' => array('notification_type', 'notification_type_enabled'),
);
$schema_data['phpbb_notifications'] = array(
'COLUMNS' => array(
'notification_id' => array('UINT', NULL, 'auto_increment'),
'item_type' => array('VCHAR:255', ''),
'item_id' => array('UINT', 0),
'item_parent_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
'notification_read' => array('BOOL', 0),
'notification_time' => array('TIMESTAMP', 1),
'notification_data' => array('TEXT_UNI', ''),
),
'PRIMARY_KEY' => 'notification_id',
'KEYS' => array(
'item_ident' => array('INDEX', array('item_type', 'item_id')),
'user' => array('INDEX', array('user_id', 'notification_read')),
),
);
$schema_data['phpbb_poll_options'] = array(
'COLUMNS' => array(
'poll_option_id' => array('TINT:4', 0),
@ -1526,18 +1565,21 @@ function get_schema_struct()
$schema_data['phpbb_reports'] = array(
'COLUMNS' => array(
'report_id' => array('UINT', NULL, 'auto_increment'),
'reason_id' => array('USINT', 0),
'post_id' => array('UINT', 0),
'pm_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
'user_notify' => array('BOOL', 0),
'report_closed' => array('BOOL', 0),
'report_time' => array('TIMESTAMP', 0),
'report_text' => array('MTEXT_UNI', ''),
'reported_post_text' => array('MTEXT_UNI', ''),
'reported_post_uid' => array('VCHAR:8', ''),
'reported_post_bitfield' => array('VCHAR:255', ''),
'report_id' => array('UINT', NULL, 'auto_increment'),
'reason_id' => array('USINT', 0),
'post_id' => array('UINT', 0),
'pm_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
'user_notify' => array('BOOL', 0),
'report_closed' => array('BOOL', 0),
'report_time' => array('TIMESTAMP', 0),
'report_text' => array('MTEXT_UNI', ''),
'reported_post_text' => array('MTEXT_UNI', ''),
'reported_post_uid' => array('VCHAR:8', ''),
'reported_post_bitfield' => array('VCHAR:255', ''),
'reported_post_enable_magic_url' => array('BOOL', 1),
'reported_post_enable_smilies' => array('BOOL', 1),
'reported_post_enable_bbcode' => array('BOOL', 1)
),
'PRIMARY_KEY' => 'report_id',
'KEYS' => array(
@ -1763,6 +1805,16 @@ function get_schema_struct()
),
);
$schema_data['phpbb_user_notifications'] = array(
'COLUMNS' => array(
'item_type' => array('VCHAR:255', ''),
'item_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
'method' => array('VCHAR:255', ''),
'notify' => array('BOOL', 1),
),
);
$schema_data['phpbb_user_group'] = array(
'COLUMNS' => array(
'group_id' => array('UINT', 0),

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

@ -72,6 +72,7 @@
<ol style="list-style-type: lower-roman;">
<li><a href="#templates">General Templating</a></li>
<li><a href="#stylestree">Styles Tree</a></li>
<li><a href="#template-events">Template Events</a></li>
</ol></li>
<li><a href="#charsets">Character Sets and Encodings</a></li>
<li><a href="#translation">Translation (<abbr title="Internationalisation">i18n</abbr>/<abbr title="Localisation">L10n</abbr>) Guidelines</a>
@ -1678,6 +1679,57 @@ version = 3.1.0
parent = prosilver
</pre></div>
<a name="template-events"></a><h3>4.iii. Template Events</h3>
<p>Template events must follow this format: <code>&lt;!-- EVENT event_name --&gt;</code></p>
<p>Using the above example, files named <code>event_name.html</code> located within extensions will be injected into the location of the event.</p>
<h4>Template event naming guidelines:</h4>
<ul>
<li>An event name must be all lowercase, with each word separated by an underscore.</li>
<li>An event name must briefly describe the location and purpose of the event.</li>
<li>An event name must end with one of the following suffixes:</li>
<ul>
<li><code>_prepend</code> - This event adds an item to the beginning of a block of related items, or adds to the beginning of individual items in a block.</li>
<li><code>_append</code> - This event adds an item to the end of a block of related items, or adds to the end of individual items in a block.</li>
<li><code>_before</code> - This event adds content directly before the specified block</li>
<li><code>_after</code> - This event adds content directly after the specified block</li>
</ul>
</ul>
<h4>Template event documentation</h4>
<p>Events must be documented in <code>phpBB/docs/events.md</code> in alphabetical order based on the event name. The format is as follows:</p>
<ul><li>An event found in only one template file:
<div class="codebox"><pre>event_name
===
* Location: styles/&lt;style_name&gt;/template/filename.html
* Purpose: A brief description of what this event should be used for.
This may span multiple lines.
</pre></div></li>
<li>An event found in multiple template files:
<div class="codebox"><pre>event_name
===
* Locations:
+ first/file/path.html
+ second/file/path.html
* Purpose: Same as above.
</pre></div>
<li>An event that is found multiple times in a file should have the number of instances in parenthesis next to the filename.
<div class="codebox"><pre>event_name
===
* Locations:
+ first/file/path.html (2)
+ second/file/path.html
* Purpose: Same as above.
</pre></div></li>
<li>An actual example event documentation:
<div class="codebox"><pre>forumlist_body_last_post_title_prepend
====
* Locations:
+ styles/prosilver/template/forumlist_body.html
+ styles/subsilver2/template/forumlist_body.html
* Purpose: Add content before the post title of the latest post in a forum on the forum list.</pre></div></ul><br />
</div>
<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>

View file

@ -10,21 +10,36 @@ source source_phpbb_{SPHINX_ID}_main
sql_query_pre = UPDATE phpbb_sphinx SET max_doc_id = MAX(post_id) WHERE counter_id = 1
sql_query_range = SELECT MIN(post_id), MAX(post_id) FROM phpbb_posts
sql_range_step = 5000
sql_query = SELECT \
p.post_id AS id, \
p.forum_id, \
p.topic_id, \
p.poster_id, \
CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, \
p.post_time, \
p.post_subject, \
p.post_subject as title, \
p.post_text as data, \
t.topic_last_post_time, \
0 as deleted \
FROM phpbb_posts p, phpbb_topics t \
WHERE \
p.topic_id = t.topic_id \
sql_query = SELECT
\
p.post_id AS id,
\
p.forum_id,
\
p.topic_id,
\
p.poster_id,
\
CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post,
\
p.post_time,
\
p.post_subject,
\
p.post_subject as title,
\
p.post_text as data,
\
t.topic_last_post_time,
\
0 as deleted
\
FROM phpbb_posts p, phpbb_topics t
\
WHERE
\
p.topic_id = t.topic_id
\
AND p.post_id >= $start AND p.post_id <= $end
sql_query_post =
sql_query_post_index = UPDATE phpbb_sphinx SET max_doc_id = $maxid WHERE counter_id = 1
@ -42,21 +57,36 @@ source source_phpbb_{SPHINX_ID}_delta : source_phpbb_{SPHINX_ID}_main
{
sql_query_range =
sql_range_step =
sql_query = SELECT \
p.post_id AS id, \
p.forum_id, \
p.topic_id, \
p.poster_id, \
CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, \
p.post_time, \
p.post_subject, \
p.post_subject as title, \
p.post_text as data, \
t.topic_last_post_time, \
0 as deleted \
FROM phpbb_posts p, phpbb_topics t \
WHERE \
p.topic_id = t.topic_id \
sql_query = SELECT
\
p.post_id AS id,
\
p.forum_id,
\
p.topic_id,
\
p.poster_id,
\
CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post,
\
p.post_time,
\
p.post_subject,
\
p.post_subject as title,
\
p.post_text as data,
\
t.topic_last_post_time,
\
0 as deleted
\
FROM phpbb_posts p, phpbb_topics t
\
WHERE
\
p.topic_id = t.topic_id
\
AND p.post_id >= ( SELECT max_doc_id FROM phpbb_sphinx WHERE counter_id=1 )
sql_query_pre =
}

View file

@ -56,18 +56,7 @@ if (isset($_GET['avatar']))
$phpbb_class_loader_ext->register();
// Set up container
$phpbb_container = phpbb_create_dumped_container_unless_debug(
array(
new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx),
new phpbb_di_extension_core($phpbb_root_path),
),
array(
new phpbb_di_pass_collection_pass(),
new phpbb_di_pass_kernel_pass(),
),
$phpbb_root_path,
$phpEx
);
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));

View file

@ -314,6 +314,7 @@ class acp_board
'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'validate' => 'int:0', 'type' => 'text:4:3', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
'legend2' => 'GENERAL_OPTIONS',
'load_notifications' => array('lang' => 'LOAD_NOTIFICATIONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'load_db_track' => array('lang' => 'YES_POST_MARKING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'load_db_lastread' => array('lang' => 'YES_READ_MARKING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'load_anon_lastread' => array('lang' => 'YES_ANON_READ_MARKING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
@ -413,8 +414,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

@ -206,7 +206,7 @@ class acp_forums
($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))))
{
copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false);
cache_moderators();
phpbb_cache_moderators($db, $cache, $auth);
$copied_permissions = true;
}
/* Commented out because of questionable UI workflow - re-visit for 3.0.7
@ -767,7 +767,7 @@ class acp_forums
if (!empty($forum_perm_from) && $forum_perm_from != $forum_id)
{
copy_forum_permissions($forum_perm_from, $forum_id, true);
cache_moderators();
phpbb_cache_moderators($db, $cache, $auth);
$auth->acl_clear_prefetch();
$cache->destroy('sql', FORUMS_TABLE);

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)
{
@ -439,7 +457,7 @@ class acp_groups
foreach ($test_variables as $test => $type)
{
if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test] || in_array($test, $set_attributes)))
if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test] || isset($group_attributes['group_avatar']) && strpos($test, 'avatar') === 0 || in_array($test, $set_attributes)))
{
settype($submit_ary[$test], $type);
$group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
@ -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

@ -24,7 +24,7 @@ class acp_main
function main($id, $mode)
{
global $config, $db, $user, $auth, $template, $request;
global $config, $db, $cache, $user, $auth, $template, $request;
global $phpbb_root_path, $phpbb_admin_path, $phpEx;
// Show restore permissions notice
@ -359,7 +359,7 @@ class acp_main
// Clear permissions
$auth->acl_clear_prefetch();
cache_moderators();
phpbb_cache_moderators($db, $cache, $auth);
add_log('admin', 'LOG_PURGE_CACHE');

View file

@ -535,8 +535,14 @@ class acp_modules
/**
* Get available module information from module files
*
* @param string $module
* @param bool|string $module_class
* @param bool $use_all_available Use all available instead of just all
* enabled extensions
* @return array
*/
function get_module_infos($module = '', $module_class = false)
function get_module_infos($module = '', $module_class = false, $use_all_available = false)
{
global $phpbb_root_path, $phpEx;
@ -556,7 +562,7 @@ class acp_modules
->extension_directory("/$module_class")
->core_path("includes/$module_class/info/")
->core_prefix($module_class . '_')
->get_classes();
->get_classes(true, $use_all_available);
foreach ($modules as $module)
{
@ -740,15 +746,15 @@ class acp_modules
*/
function remove_cache_file()
{
global $cache;
global $phpbb_container;
// Sanitise for future path use, it's escaped as appropriate for queries
$p_class = str_replace(array('.', '/', '\\'), '', basename($this->module_class));
$cache->destroy('_modules_' . $p_class);
$phpbb_container->get('cache.driver')->destroy('_modules_' . $p_class);
// Additionally remove sql cache
$cache->destroy('sql', MODULES_TABLE);
$phpbb_container->get('cache.driver')->destroy('sql', MODULES_TABLE);
}
/**

View file

@ -656,7 +656,7 @@ class acp_permissions
*/
function set_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id)
{
global $user, $auth;
global $db, $cache, $user, $auth;
global $request;
$psubmit = request_var('psubmit', array(0 => array(0 => 0)));
@ -726,13 +726,13 @@ class acp_permissions
// Do we need to recache the moderator lists?
if ($permission_type == 'm_')
{
cache_moderators();
phpbb_cache_moderators($db, $cache, $auth);
}
// Remove users who are now moderators or admins from everyones foes list
if ($permission_type == 'm_' || $permission_type == 'a_')
{
update_foes($group_id, $user_id);
phpbb_update_foes($db, $auth, $group_id, $user_id);
}
$this->log_action($mode, 'add', $permission_type, $ug_type, $ug_id, $forum_id);
@ -745,7 +745,7 @@ class acp_permissions
*/
function set_all_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id)
{
global $user, $auth;
global $db, $cache, $user, $auth;
global $request;
// User or group to be set?
@ -794,13 +794,13 @@ class acp_permissions
// Do we need to recache the moderator lists?
if ($permission_type == 'm_')
{
cache_moderators();
phpbb_cache_moderators($db, $cache, $auth);
}
// Remove users who are now moderators or admins from everyones foes list
if ($permission_type == 'm_' || $permission_type == 'a_')
{
update_foes($group_id, $user_id);
phpbb_update_foes($db, $auth, $group_id, $user_id);
}
$this->log_action($mode, 'add', $permission_type, $ug_type, $ug_ids, $forum_ids);
@ -858,7 +858,7 @@ class acp_permissions
*/
function remove_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id, &$forum_id)
{
global $user, $db, $auth;
global $user, $db, $cache, $auth;
// User or group to be set?
$ug_type = (sizeof($user_id)) ? 'user' : 'group';
@ -874,7 +874,7 @@ class acp_permissions
// Do we need to recache the moderator lists?
if ($permission_type == 'm_')
{
cache_moderators();
phpbb_cache_moderators($db, $cache, $auth);
}
$this->log_action($mode, 'del', $permission_type, $ug_type, (($ug_type == 'user') ? $user_id : $group_id), (sizeof($forum_id) ? $forum_id : array(0 => 0)));
@ -952,12 +952,7 @@ class acp_permissions
if ($user_id != $user->data['user_id'])
{
$sql = 'SELECT user_id, username, user_permissions, user_type
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
$userdata = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$userdata = $auth->obtain_user_data($user_id);
}
else
{
@ -1172,7 +1167,7 @@ class acp_permissions
*/
function copy_forum_permissions()
{
global $auth, $cache, $template, $user;
global $db, $auth, $cache, $template, $user;
$user->add_lang('acp/forums');
@ -1187,7 +1182,7 @@ class acp_permissions
{
if (copy_forum_permissions($src, $dest))
{
cache_moderators();
phpbb_cache_moderators($db, $cache, $auth);
$auth->acl_clear_prefetch();
$cache->destroy('sql', FORUMS_TABLE);

View file

@ -209,7 +209,7 @@ class acp_ranks
'RANK_TITLE' => (isset($ranks['rank_title'])) ? $ranks['rank_title'] : '',
'S_FILENAME_LIST' => $filename_list,
'RANK_IMAGE' => ($edit_img) ? $phpbb_root_path . $config['ranks_path'] . '/' . $edit_img : $phpbb_admin_path . 'images/spacer.gif',
'RANK_IMAGE' => ($edit_img) ? $phpbb_root_path . $config['ranks_path'] . '/' . $edit_img : htmlspecialchars($phpbb_admin_path) . 'images/spacer.gif',
'S_SPECIAL_RANK' => (isset($ranks['rank_special']) && $ranks['rank_special']) ? true : false,
'MIN_POSTS' => (isset($ranks['rank_min']) && !$ranks['rank_special']) ? $ranks['rank_min'] : 0)
);

View file

@ -137,11 +137,13 @@ class acp_styles
*/
protected function action_cache()
{
global $db, $cache, $auth;
$this->cache->purge();
// Clear permissions
$this->auth->acl_clear_prefetch();
cache_moderators();
phpbb_cache_moderators($db, $cache, $auth);
add_log('admin', 'LOG_PURGE_CACHE');

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

@ -102,6 +102,26 @@ class phpbb_auth
return;
}
/**
* Retrieves data wanted by acl function from the database for the
* specified user.
*
* @param int $user_id User ID
* @return array User attributes
*/
public function obtain_user_data($user_id)
{
global $db;
$sql = 'SELECT user_id, username, user_permissions, user_type
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
$user_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
return $user_data;
}
/**
* Fill ACL array with relevant bitstrings from user_permissions column
* @access private
@ -191,7 +211,7 @@ class phpbb_auth
/**
* Get forums with the specified permission setting
* if the option is prefixed with !, then the result becomes nagated
* if the option is prefixed with !, then the result becomes negated
*
* @param bool $clean set to true if only values needs to be returned which are set/unset
*/

View file

@ -367,12 +367,10 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
}
/**
* Save sql query
* {@inheritDoc}
*/
function sql_save($query, $query_result, $ttl)
function sql_save(phpbb_db_driver $db, $query, $query_result, $ttl)
{
global $db;
// Remove extra spaces and tabs
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);

View file

@ -85,6 +85,7 @@ interface phpbb_cache_driver_interface
* result to persistent storage. In other words, there is no need
* to call save() afterwards.
*
* @param phpbb_db_driver $db Database connection
* @param string $query SQL query, should be used for generating storage key
* @param mixed $query_result The result from dbal::sql_query, to be passed to
* dbal::sql_fetchrow to get all rows and store them
@ -95,7 +96,7 @@ interface phpbb_cache_driver_interface
* representing the query should be returned. Otherwise
* the original $query_result should be returned.
*/
public function sql_save($query, $query_result, $ttl);
public function sql_save(phpbb_db_driver $db, $query, $query_result, $ttl);
/**
* Check if result for a given SQL query exists in cache.

View file

@ -283,12 +283,10 @@ abstract class phpbb_cache_driver_memory extends phpbb_cache_driver_base
}
/**
* Save sql query
* {@inheritDoc}
*/
function sql_save($query, $query_result, $ttl)
function sql_save(phpbb_db_driver $db, $query, $query_result, $ttl)
{
global $db;
// Remove extra spaces and tabs
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
$hash = md5($query);

View file

@ -105,9 +105,9 @@ class phpbb_cache_driver_null extends phpbb_cache_driver_base
}
/**
* Save sql query
* {@inheritDoc}
*/
function sql_save($query, $query_result, $ttl)
function sql_save(phpbb_db_driver $db, $query, $query_result, $ttl)
{
return $query_result;
}

View file

@ -21,16 +21,57 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cache_service
{
private $driver;
/**
* Cache driver.
*
* @var phpbb_cache_driver_interface
*/
protected $driver;
/**
* The config.
*
* @var phpbb_config
*/
protected $config;
/**
* Database connection.
*
* @var phpbb_db_driver
*/
protected $db;
/**
* Root path.
*
* @var string
*/
protected $phpbb_root_path;
/**
* PHP extension.
*
* @var string
*/
protected $php_ext;
/**
* Creates a cache service around a cache driver
*
* @param phpbb_cache_driver_interface $driver The cache driver
* @param phpbb_config $config The config
* @param phpbb_db_driver $db Database connection
* @param string $phpbb_root_path Root path
* @param string $php_ext PHP extension
*/
public function __construct(phpbb_cache_driver_interface $driver = null)
public function __construct(phpbb_cache_driver_interface $driver, phpbb_config $config, phpbb_db_driver $db, $phpbb_root_path, $php_ext)
{
$this->set_driver($driver);
$this->config = $config;
$this->db = $db;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
}
/**
@ -64,21 +105,19 @@ class phpbb_cache_service
*/
function obtain_word_list()
{
global $db;
if (($censors = $this->driver->get('_word_censors')) === false)
{
$sql = 'SELECT word, replacement
FROM ' . WORDS_TABLE;
$result = $db->sql_query($sql);
$result = $this->db->sql_query($sql);
$censors = array();
while ($row = $db->sql_fetchrow($result))
while ($row = $this->db->sql_fetchrow($result))
{
$censors['match'][] = get_censor_preg_expression($row['word']);
$censors['replace'][] = $row['replacement'];
}
$db->sql_freeresult($result);
$this->db->sql_freeresult($result);
$this->driver->put('_word_censors', $censors);
}
@ -93,23 +132,21 @@ class phpbb_cache_service
{
if (($icons = $this->driver->get('_icons')) === false)
{
global $db;
// Topic icons
$sql = 'SELECT *
FROM ' . ICONS_TABLE . '
ORDER BY icons_order';
$result = $db->sql_query($sql);
$result = $this->db->sql_query($sql);
$icons = array();
while ($row = $db->sql_fetchrow($result))
while ($row = $this->db->sql_fetchrow($result))
{
$icons[$row['icons_id']]['img'] = $row['icons_url'];
$icons[$row['icons_id']]['width'] = (int) $row['icons_width'];
$icons[$row['icons_id']]['height'] = (int) $row['icons_height'];
$icons[$row['icons_id']]['display'] = (bool) $row['display_on_posting'];
}
$db->sql_freeresult($result);
$this->db->sql_freeresult($result);
$this->driver->put('_icons', $icons);
}
@ -124,15 +161,13 @@ class phpbb_cache_service
{
if (($ranks = $this->driver->get('_ranks')) === false)
{
global $db;
$sql = 'SELECT *
FROM ' . RANKS_TABLE . '
ORDER BY rank_min DESC';
$result = $db->sql_query($sql);
$result = $this->db->sql_query($sql);
$ranks = array();
while ($row = $db->sql_fetchrow($result))
while ($row = $this->db->sql_fetchrow($result))
{
if ($row['rank_special'])
{
@ -150,7 +185,7 @@ class phpbb_cache_service
);
}
}
$db->sql_freeresult($result);
$this->db->sql_freeresult($result);
$this->driver->put('_ranks', $ranks);
}
@ -169,8 +204,6 @@ class phpbb_cache_service
{
if (($extensions = $this->driver->get('_extensions')) === false)
{
global $db;
$extensions = array(
'_allowed_post' => array(),
'_allowed_pm' => array(),
@ -181,9 +214,9 @@ class phpbb_cache_service
FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g
WHERE e.group_id = g.group_id
AND (g.allow_group = 1 OR g.allow_in_pm = 1)';
$result = $db->sql_query($sql);
$result = $this->db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
while ($row = $this->db->sql_fetchrow($result))
{
$extension = strtolower(trim($row['extension']));
@ -210,7 +243,7 @@ class phpbb_cache_service
$extensions['_allowed_pm'][$extension] = 0;
}
}
$db->sql_freeresult($result);
$this->db->sql_freeresult($result);
$this->driver->put('_extensions', $extensions);
}
@ -275,9 +308,7 @@ class phpbb_cache_service
{
if (($bots = $this->driver->get('_bots')) === false)
{
global $db;
switch ($db->sql_layer)
switch ($this->db->sql_layer)
{
case 'mssql':
case 'mssql_odbc':
@ -303,14 +334,14 @@ class phpbb_cache_service
ORDER BY LENGTH(bot_agent) DESC';
break;
}
$result = $db->sql_query($sql);
$result = $this->db->sql_query($sql);
$bots = array();
while ($row = $db->sql_fetchrow($result))
while ($row = $this->db->sql_fetchrow($result))
{
$bots[] = $row;
}
$db->sql_freeresult($result);
$this->db->sql_freeresult($result);
$this->driver->put('_bots', $bots);
}
@ -323,8 +354,6 @@ class phpbb_cache_service
*/
function obtain_cfg_items($style)
{
global $config, $phpbb_root_path;
$parsed_array = $this->driver->get('_cfg_' . $style['style_path']);
if ($parsed_array === false)
@ -332,14 +361,14 @@ class phpbb_cache_service
$parsed_array = array();
}
$filename = $phpbb_root_path . 'styles/' . $style['style_path'] . '/style.cfg';
$filename = $this->phpbb_root_path . 'styles/' . $style['style_path'] . '/style.cfg';
if (!file_exists($filename))
{
return $parsed_array;
}
if (!isset($parsed_array['filetime']) || (($config['load_tplcompile'] && @filemtime($filename) > $parsed_array['filetime'])))
if (!isset($parsed_array['filetime']) || (($this->config['load_tplcompile'] && @filemtime($filename) > $parsed_array['filetime'])))
{
// Re-parse cfg file
$parsed_array = parse_cfg_file($filename);
@ -358,54 +387,20 @@ class phpbb_cache_service
{
if (($usernames = $this->driver->get('_disallowed_usernames')) === false)
{
global $db;
$sql = 'SELECT disallow_username
FROM ' . DISALLOW_TABLE;
$result = $db->sql_query($sql);
$result = $this->db->sql_query($sql);
$usernames = array();
while ($row = $db->sql_fetchrow($result))
while ($row = $this->db->sql_fetchrow($result))
{
$usernames[] = str_replace('%', '.*?', preg_quote(utf8_clean_string($row['disallow_username']), '#'));
}
$db->sql_freeresult($result);
$this->db->sql_freeresult($result);
$this->driver->put('_disallowed_usernames', $usernames);
}
return $usernames;
}
/**
* Obtain hooks...
*/
function obtain_hooks()
{
global $phpbb_root_path, $phpEx;
if (($hook_files = $this->driver->get('_hooks')) === false)
{
$hook_files = array();
// Now search for hooks...
$dh = @opendir($phpbb_root_path . 'includes/hooks/');
if ($dh)
{
while (($file = readdir($dh)) !== false)
{
if (strpos($file, 'hook_') === 0 && substr($file, -(strlen($phpEx) + 1)) === '.' . $phpEx)
{
$hook_files[] = substr($file, 0, -(strlen($phpEx) + 1));
}
}
closedir($dh);
}
$this->driver->put('_hooks', $hook_files);
}
return $hook_files;
}
}

View file

@ -118,7 +118,7 @@ class captcha
$new_line = '';
$end = strlen($scanline) - ceil($width/2);
for ($i = floor($width/2); $i < $end; $i++)
for ($i = (int) floor($width / 2); $i < $end; $i++)
{
$pixel = ord($scanline{$i});

View file

@ -241,8 +241,11 @@ 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('NOTIFICATION_TYPES_TABLE', $table_prefix . 'notification_types');
define('NOTIFICATIONS_TABLE', $table_prefix . 'notifications');
define('POLL_OPTIONS_TABLE', $table_prefix . 'poll_options');
define('POLL_VOTES_TABLE', $table_prefix . 'poll_votes');
define('POSTS_TABLE', $table_prefix . 'posts');
@ -276,6 +279,7 @@ define('TOPICS_POSTED_TABLE', $table_prefix . 'topics_posted');
define('TOPICS_TRACK_TABLE', $table_prefix . 'topics_track');
define('TOPICS_WATCH_TABLE', $table_prefix . 'topics_watch');
define('USER_GROUP_TABLE', $table_prefix . 'user_group');
define('USER_NOTIFICATIONS_TABLE', $table_prefix . 'user_notifications');
define('USERS_TABLE', $table_prefix . 'users');
define('WARNINGS_TABLE', $table_prefix . 'warnings');
define('WORDS_TABLE', $table_prefix . 'words');

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
@ -1817,6 +1830,22 @@ class phpbb_db_tools
case 'mssql':
case 'mssqlnative':
// remove default cosntraints first
// http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx
$statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000)
SET @drop_default_name =
(SELECT so.name FROM sysobjects so
JOIN sysconstraints sc ON so.id = sc.constid
WHERE object_name(so.parent_obj) = '{$table_name}'
AND so.xtype = 'D'
AND sc.colid = (SELECT colid FROM syscolumns
WHERE id = object_id('{$table_name}')
AND name = '{$column_name}'))
IF @drop_default_name <> ''
BEGIN
SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']'
EXEC(@cmd)
END";
$statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']';
break;

View file

@ -206,7 +206,7 @@ class phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@ -256,7 +256,7 @@ class phpbb_db_driver
$this->sql_rowseek($rownum, $query_id);
}
if (!is_object($query_id) && $cache->sql_exists($query_id))
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_fetchfield($query_id, $field);
}
@ -822,7 +822,7 @@ class phpbb_db_driver
*/
function sql_report($mode, $query = '')
{
global $cache, $starttime, $phpbb_root_path, $user;
global $cache, $starttime, $phpbb_root_path, $phpbb_admin_path, $user;
global $request;
if (is_object($request) && !$request->variable('explain', false))
@ -852,7 +852,7 @@ class phpbb_db_driver
<head>
<meta charset="utf-8">
<title>SQL Report</title>
<link href="' . $phpbb_root_path . 'adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />
<link href="' . htmlspecialchars($phpbb_admin_path) . 'style/admin.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body id="errorpage">
<div id="wrap">

View file

@ -154,7 +154,7 @@ class phpbb_db_driver_firebird extends phpbb_db_driver
}
$this->last_query_text = $query;
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@ -267,10 +267,10 @@ class phpbb_db_driver_firebird extends phpbb_db_driver
}
}
if ($cache_ttl)
if ($cache && $cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@ -330,7 +330,7 @@ class phpbb_db_driver_firebird extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@ -396,7 +396,7 @@ class phpbb_db_driver_firebird extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}

View file

@ -150,7 +150,7 @@ class phpbb_db_driver_mssql extends phpbb_db_driver
$this->sql_report('start', $query);
}
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@ -165,10 +165,10 @@ class phpbb_db_driver_mssql extends phpbb_db_driver
$this->sql_report('stop', $query);
}
if ($cache_ttl)
if ($cache && $cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@ -240,7 +240,7 @@ class phpbb_db_driver_mssql extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@ -277,7 +277,7 @@ class phpbb_db_driver_mssql extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@ -316,7 +316,7 @@ class phpbb_db_driver_mssql extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}

View file

@ -179,7 +179,7 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
}
$this->last_query_text = $query;
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@ -194,10 +194,10 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
$this->sql_report('stop', $query);
}
if ($cache_ttl)
if ($cache && $cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@ -270,7 +270,7 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@ -311,7 +311,7 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}

View file

@ -317,7 +317,7 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver
}
$this->last_query_text = $query;
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@ -337,7 +337,7 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver
if ($cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{

View file

@ -188,7 +188,7 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
$this->sql_report('start', $query);
}
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@ -203,10 +203,10 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
$this->sql_report('stop', $query);
}
if ($cache_ttl)
if ($cache && $cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@ -265,7 +265,7 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@ -286,7 +286,7 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@ -314,7 +314,7 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}

View file

@ -184,7 +184,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
$this->sql_report('start', $query);
}
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@ -199,9 +199,9 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
$this->sql_report('stop', $query);
}
if ($cache_ttl)
if ($cache && $cache_ttl)
{
$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
}
}
else if (defined('DEBUG'))
@ -256,7 +256,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
$query_id = $this->query_result;
}
if (!is_object($query_id) && $cache->sql_exists($query_id))
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@ -283,7 +283,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
$query_id = $this->query_result;
}
if (!is_object($query_id) && $cache->sql_exists($query_id))
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@ -311,7 +311,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
$query_id = $this->query_result;
}
if (!is_object($query_id) && $cache->sql_exists($query_id))
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}

View file

@ -267,7 +267,7 @@ class phpbb_db_driver_oracle extends phpbb_db_driver
}
$this->last_query_text = $query;
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@ -443,10 +443,10 @@ class phpbb_db_driver_oracle extends phpbb_db_driver
$this->sql_report('stop', $query);
}
if ($cache_ttl)
if ($cache && $cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@ -498,7 +498,7 @@ class phpbb_db_driver_oracle extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@ -550,7 +550,7 @@ class phpbb_db_driver_oracle extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@ -619,7 +619,7 @@ class phpbb_db_driver_oracle extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}

View file

@ -193,7 +193,7 @@ class phpbb_db_driver_postgres extends phpbb_db_driver
}
$this->last_query_text = $query;
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@ -208,10 +208,10 @@ class phpbb_db_driver_postgres extends phpbb_db_driver
$this->sql_report('stop', $query);
}
if ($cache_ttl)
if ($cache && $cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@ -278,7 +278,7 @@ class phpbb_db_driver_postgres extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@ -299,7 +299,7 @@ class phpbb_db_driver_postgres extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@ -348,7 +348,7 @@ class phpbb_db_driver_postgres extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}

View file

@ -134,7 +134,7 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver
$this->sql_report('start', $query);
}
$this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@ -149,10 +149,10 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver
$this->sql_report('stop', $query);
}
if ($cache_ttl)
if ($cache && $cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
$this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@ -210,7 +210,7 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@ -231,7 +231,7 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@ -259,7 +259,7 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver
$query_id = $this->query_result;
}
if ($cache->sql_exists($query_id))
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_1_rc1');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.1')),
);
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_10 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.10', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_10_rc3');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.10')),
);
}
}

View file

@ -0,0 +1,30 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_10_rc1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.10-rc1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_9');
}
public function update_data()
{
return array(
array('config.add', array('email_max_chunk_size', 50)),
array('config.update', array('version', '3.0.10-rc1')),
);
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_10_rc2 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.10-rc2', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_10_rc1');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.10-rc2')),
);
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_10_rc3 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.10-rc3', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_10_rc2');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.10-rc3')),
);
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_11 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.11', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_11_rc2');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.11')),
);
}
}

View file

@ -0,0 +1,95 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_11_rc1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.11-rc1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_10');
}
public function update_data()
{
return array(
array('custom', array(array(&$this, 'cleanup_deactivated_styles'))),
array('custom', array(array(&$this, 'delete_orphan_private_messages'))),
array('config.update', array('version', '3.0.11-rc1')),
);
}
public function cleanup_deactivated_styles()
{
// Updates users having current style a deactivated one
$sql = 'SELECT style_id
FROM ' . STYLES_TABLE . '
WHERE style_active = 0';
$result = $this->sql_query($sql);
$deactivated_style_ids = array();
while ($style_id = $this->db->sql_fetchfield('style_id', false, $result))
{
$deactivated_style_ids[] = (int) $style_id;
}
$this->db->sql_freeresult($result);
if (!empty($deactivated_style_ids))
{
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_style = ' . (int) $this->config['default_style'] .'
WHERE ' . $this->db->sql_in_set('user_style', $deactivated_style_ids);
$this->sql_query($sql);
}
}
public function delete_orphan_private_messages()
{
// Delete orphan private messages
$batch_size = 500;
$sql_array = array(
'SELECT' => 'p.msg_id',
'FROM' => array(
PRIVMSGS_TABLE => 'p',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(PRIVMSGS_TO_TABLE => 't'),
'ON' => 'p.msg_id = t.msg_id',
),
),
'WHERE' => 't.user_id IS NULL',
);
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query_limit($sql, $batch_size);
$delete_pms = array();
while ($row = $this->db->sql_fetchrow($result))
{
$delete_pms[] = (int) $row['msg_id'];
}
$this->db->sql_freeresult($result);
if (!empty($delete_pms))
{
$sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
WHERE ' . $this->db->sql_in_set('msg_id', $delete_pms);
$this->sql_query($sql);
// Return false to have the Migrator call this function again
return false;
}
}
}

View file

@ -0,0 +1,50 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_11_rc2 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.11-rc2', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_11_rc1');
}
public function update_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'profile_fields' => array(
'field_show_novalue' => array('BOOL', 0),
),
),
);
}
public function revert_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'profile_fields' => array(
'field_show_novalue',
),
),
);
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.11-rc2')),
);
}
}

View file

@ -0,0 +1,123 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
/** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 **/
class phpbb_db_migration_data_30x_3_0_12_rc1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.12-rc1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_11');
}
public function update_data()
{
return array(
array('custom', array(array(&$this, 'update_module_auth'))),
array('custom', array(array(&$this, 'update_bots'))),
array('custom', array(array(&$this, 'disable_bots_from_receiving_pms'))),
array('config.update', array('version', '3.0.12-rc1')),
);
}
public function disable_bots_from_receiving_pms()
{
// Disable receiving pms for bots
$sql = 'SELECT user_id
FROM ' . BOTS_TABLE;
$result = $this->db->sql_query($sql);
$bot_user_ids = array();
while ($row = $this->db->sql_fetchrow($result))
{
$bot_user_ids[] = (int) $row['user_id'];
}
$this->db->sql_freeresult($result);
if (!empty($bot_user_ids))
{
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_allow_pm = 0
WHERE ' . $this->db->sql_in_set('user_id', $bot_user_ids);
$this->sql_query($sql);
}
}
public function update_module_auth()
{
$sql = 'UPDATE ' . MODULES_TABLE . '
SET module_auth = \'acl_u_sig\'
WHERE module_class = \'ucp\'
AND module_basename = \'profile\'
AND module_mode = \'signature\'';
$this->sql_query($sql);
}
public function update_bots()
{
// Update bots
if (!function_exists('user_delete'))
{
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
}
$bots_updates = array(
// Bot Deletions
'NG-Search [Bot]' => false,
'Nutch/CVS [Bot]' => false,
'OmniExplorer [Bot]' => false,
'Seekport [Bot]' => false,
'Synoo [Bot]' => false,
'WiseNut [Bot]' => false,
// Bot Updates
// Bot name to bot user agent map
'Baidu [Spider]' => 'Baiduspider',
'Exabot [Bot]' => 'Exabot',
'Voyager [Bot]' => 'voyager/',
'W3C [Validator]' => 'W3C_Validator',
);
foreach ($bots_updates as $bot_name => $bot_agent)
{
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . '
WHERE user_type = ' . USER_IGNORE . "
AND username_clean = '" . $this->db->sql_escape(utf8_clean_string($bot_name)) . "'";
$result = $this->db->sql_query($sql);
$bot_user_id = (int) $this->db->sql_fetchfield('user_id');
$this->db->sql_freeresult($result);
if ($bot_user_id)
{
if ($bot_agent === false)
{
$sql = 'DELETE FROM ' . BOTS_TABLE . "
WHERE user_id = $bot_user_id";
$this->sql_query($sql);
user_delete('remove', $bot_user_id);
}
else
{
$sql = 'UPDATE ' . BOTS_TABLE . "
SET bot_agent = '" . $this->db->sql_escape($bot_agent) . "'
WHERE user_id = $bot_user_id";
$this->sql_query($sql);
}
}
}
}
}

View file

@ -0,0 +1,108 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_1_rc1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.1-rc1', '>=');
}
public function update_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'forums' => array(
'display_subforum_list' => array('BOOL', 1),
),
$this->table_prefix . 'sessions' => array(
'session_forum_id' => array('UINT', 0),
),
),
'drop_keys' => array(
$this->table_prefix . 'groups' => array(
'group_legend',
),
),
'add_index' => array(
$this->table_prefix . 'sessions' => array(
'session_forum_id' => array('session_forum_id'),
),
$this->table_prefix . 'groups' => array(
'group_legend_name' => array('group_legend', 'group_name'),
),
),
);
}
public function revert_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'forums' => array(
'display_subforum_list',
),
$this->table_prefix . 'sessions' => array(
'session_forum_id',
),
),
'add_index' => array(
$this->table_prefix . 'groups' => array(
'group_legend' => array('group_legend'),
),
),
'drop_keys' => array(
$this->table_prefix . 'sessions' => array(
'session_forum_id',
),
$this->table_prefix . 'groups' => array(
'group_legend_name',
),
),
);
}
public function update_data()
{
return array(
array('custom', array(array(&$this, 'fix_unset_last_view_time'))),
array('custom', array(array(&$this, 'reset_smiley_size'))),
array('config.update', array('version', '3.0.1-rc1')),
);
}
public function fix_unset_last_view_time()
{
$sql = 'UPDATE ' . $this->table_prefix . "topics
SET topic_last_view_time = topic_last_post_time
WHERE topic_last_view_time = 0";
$this->sql_query($sql);
}
public function reset_smiley_size()
{
// Update smiley sizes
$smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif');
foreach ($smileys as $smiley)
{
if (file_exists($this->phpbb_root_path . 'images/smilies/' . $smiley))
{
list($width, $height) = getimagesize($this->phpbb_root_path . 'images/smilies/' . $smiley);
$sql = 'UPDATE ' . SMILIES_TABLE . '
SET smiley_width = ' . $width . ', smiley_height = ' . $height . "
WHERE smiley_url = '" . $this->db->sql_escape($smiley) . "'";
$this->sql_query($sql);
}
}
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_2 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.2', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_2_rc2');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.2')),
);
}
}

View file

@ -0,0 +1,32 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_2_rc1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.2-rc1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_1');
}
public function update_data()
{
return array(
array('config.add', array('referer_validation', '1')),
array('config.add', array('check_attachment_content', '1')),
array('config.add', array('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title')),
array('config.update', array('version', '3.0.2-rc1')),
);
}
}

View file

@ -0,0 +1,80 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_2_rc2 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.2-rc2', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_2_rc1');
}
public function update_schema()
{
return array(
'change_columns' => array(
$this->table_prefix . 'drafts' => array(
'draft_subject' => array('STEXT_UNI', ''),
),
$this->table_prefix . 'forums' => array(
'forum_last_post_subject' => array('STEXT_UNI', ''),
),
$this->table_prefix . 'posts' => array(
'post_subject' => array('STEXT_UNI', '', 'true_sort'),
),
$this->table_prefix . 'privmsgs' => array(
'message_subject' => array('STEXT_UNI', ''),
),
$this->table_prefix . 'topics' => array(
'topic_title' => array('STEXT_UNI', '', 'true_sort'),
'topic_last_post_subject' => array('STEXT_UNI', ''),
),
),
'drop_keys' => array(
$this->table_prefix . 'sessions' => array(
'session_forum_id',
),
),
'add_index' => array(
$this->table_prefix . 'sessions' => array(
'session_fid' => array('session_forum_id'),
),
),
);
}
public function revert_schema()
{
return array(
'add_index' => array(
$this->table_prefix . 'sessions' => array(
'session_forum_id' => array(
'session_forum_id',
),
),
),
'drop_keys' => array(
$this->table_prefix . 'sessions' => array(
'session_fid',
),
),
);
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.2-rc2')),
);
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_3 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.3', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_3_rc1');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.3')),
);
}
}

View file

@ -0,0 +1,83 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_3_rc1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.3-rc1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_2');
}
public function update_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'styles_template' => array(
'template_inherits_id' => array('UINT:4', 0),
'template_inherit_path' => array('VCHAR', ''),
),
$this->table_prefix . 'groups' => array(
'group_max_recipients' => array('UINT', 0),
),
),
);
}
public function revert_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'styles_template' => array(
'template_inherits_id',
'template_inherit_path',
),
$this->table_prefix . 'groups' => array(
'group_max_recipients',
),
),
);
}
public function update_data()
{
return array(
array('config.add', array('enable_queue_trigger', '0')),
array('config.add', array('queue_trigger_posts', '3')),
array('config.add', array('pm_max_recipients', '0')),
array('custom', array(array(&$this, 'set_group_default_max_recipients'))),
array('config.add', array('dbms_version', $this->db->sql_server_info(true))),
array('permission.add', array('u_masspm_group', true, 'u_masspm')),
array('custom', array(array(&$this, 'correct_acp_email_permissions'))),
array('config.update', array('version', '3.0.3-rc1')),
);
}
public function correct_acp_email_permissions()
{
$sql = 'UPDATE ' . $this->table_prefix . 'modules
SET module_auth = \'acl_a_email && cfg_email_enable\'
WHERE module_class = \'acp\'
AND module_basename = \'email\'';
$this->sql_query($sql);
}
public function set_group_default_max_recipients()
{
// Set maximum number of recipients for the registered users, bots, guests group
$sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5
WHERE ' . $this->db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS'));
$this->sql_query($sql);
}
}

View file

@ -0,0 +1,49 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_4 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.4', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_4_rc1');
}
public function update_data()
{
return array(
array('custom', array(array(&$this, 'rename_log_delete_topic'))),
array('config.update', array('version', '3.0.4')),
);
}
public function rename_log_delete_topic()
{
if ($this->db->sql_layer == 'oracle')
{
// log_operation is CLOB - but we can change this later
$sql = 'UPDATE ' . $this->table_prefix . "log
SET log_operation = 'LOG_DELETE_TOPIC'
WHERE log_operation LIKE 'LOG_TOPIC_DELETED'";
$this->sql_query($sql);
}
else
{
$sql = 'UPDATE ' . $this->table_prefix . "log
SET log_operation = 'LOG_DELETE_TOPIC'
WHERE log_operation = 'LOG_TOPIC_DELETED'";
$this->sql_query($sql);
}
}
}

View file

@ -0,0 +1,123 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_4_rc1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.4-rc1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_3');
}
public function update_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'profile_fields' => array(
'field_show_profile' => array('BOOL', 0),
),
),
'change_columns' => array(
$this->table_prefix . 'styles' => array(
'style_id' => array('UINT', NULL, 'auto_increment'),
'template_id' => array('UINT', 0),
'theme_id' => array('UINT', 0),
'imageset_id' => array('UINT', 0),
),
$this->table_prefix . 'styles_imageset' => array(
'imageset_id' => array('UINT', NULL, 'auto_increment'),
),
$this->table_prefix . 'styles_imageset_data' => array(
'image_id' => array('UINT', NULL, 'auto_increment'),
'imageset_id' => array('UINT', 0),
),
$this->table_prefix . 'styles_theme' => array(
'theme_id' => array('UINT', NULL, 'auto_increment'),
),
$this->table_prefix . 'styles_template' => array(
'template_id' => array('UINT', NULL, 'auto_increment'),
),
$this->table_prefix . 'styles_template_data' => array(
'template_id' => array('UINT', 0),
),
$this->table_prefix . 'forums' => array(
'forum_style' => array('UINT', 0),
),
$this->table_prefix . 'users' => array(
'user_style' => array('UINT', 0),
),
),
);
}
public function revert_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'profile_fields' => array(
'field_show_profile',
),
),
);
}
public function update_data()
{
return array(
array('custom', array(array(&$this, 'update_custom_profile_fields'))),
array('config.update', array('version', '3.0.4-rc1')),
);
}
public function update_custom_profile_fields()
{
// Update the Custom Profile Fields based on previous settings to the new format
$sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide
FROM ' . PROFILE_FIELDS_TABLE;
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$sql_ary = array(
'field_required' => 0,
'field_show_on_reg' => 0,
'field_hide' => 0,
'field_show_profile'=> 0,
);
if ($row['field_required'])
{
$sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1;
}
else if ($row['field_show_on_reg'])
{
$sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1;
}
else if ($row['field_hide'])
{
// Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module
$sql_ary['field_hide'] = 1;
}
else
{
// equivelant to "none", which is the "Display in user control panel" option
$sql_ary['field_show_profile'] = 1;
}
$this->sql_query('UPDATE ' . $this->table_prefix . 'profile_fields SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary);
}
$this->db->sql_freeresult($result);
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_5 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.5', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_5_rc1part2');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.5')),
);
}
}

View file

@ -0,0 +1,124 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_5_rc1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.5-rc1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_4');
}
public function update_schema()
{
return array(
'change_columns' => array(
$this->table_prefix . 'forums' => array(
'forum_style' => array('UINT', 0),
),
),
);
}
public function update_data()
{
$search_indexing_state = $this->config['search_indexing_state'];
return array(
array('config.add', array('captcha_gd_wave', 0)),
array('config.add', array('captcha_gd_3d_noise', 1)),
array('config.add', array('captcha_gd_fonts', 1)),
array('config.add', array('confirm_refresh', 1)),
array('config.add', array('max_num_search_keywords', 10)),
array('config.remove', array('search_indexing_state')),
array('config.add', array('search_indexing_state', $search_indexing_state, true)),
array('custom', array(array(&$this, 'hash_old_passwords'))),
array('custom', array(array(&$this, 'update_ichiro_bot'))),
);
}
public function hash_old_passwords()
{
$sql = 'SELECT user_id, user_password
FROM ' . $this->table_prefix . 'users
WHERE user_pass_convert = 1';
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
if (strlen($row['user_password']) == 32)
{
$sql_ary = array(
'user_password' => phpbb_hash($row['user_password']),
);
$this->sql_query('UPDATE ' . $this->table_prefix . 'users SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id']);
}
}
$this->db->sql_freeresult($result);
}
public function update_ichiro_bot()
{
// Adjust bot entry
$sql = 'UPDATE ' . $this->table_prefix . "bots
SET bot_agent = 'ichiro/'
WHERE bot_agent = 'ichiro/2'";
$this->sql_query($sql);
}
public function remove_duplicate_auth_options()
{
// Before we are able to add a unique key to auth_option, we need to remove duplicate entries
$sql = 'SELECT auth_option
FROM ' . $this->table_prefix . 'acl_options
GROUP BY auth_option
HAVING COUNT(*) >= 2';
$result = $this->db->sql_query($sql);
$auth_options = array();
while ($row = $this->db->sql_fetchrow($result))
{
$auth_options[] = $row['auth_option'];
}
$this->db->sql_freeresult($result);
// Remove specific auth options
if (!empty($auth_options))
{
foreach ($auth_options as $option)
{
// Select auth_option_ids... the largest id will be preserved
$sql = 'SELECT auth_option_id
FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option = '" . $db->sql_escape($option) . "'
ORDER BY auth_option_id DESC";
// sql_query_limit not possible here, due to bug in postgresql layer
$result = $this->db->sql_query($sql);
// Skip first row, this is our original auth option we want to preserve
$row = $this->db->sql_fetchrow($result);
while ($row = $this->db->sql_fetchrow($result))
{
// Ok, remove this auth option...
$this->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']);
$this->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']);
$this->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']);
$this->sql_query('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']);
}
$this->db->sql_freeresult($result);
}
}
}
}

View file

@ -0,0 +1,42 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_5_rc1part2 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.5-rc1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_5_rc1');
}
public function update_schema()
{
return array(
'drop_keys' => array(
$this->table_prefix . 'acl_options' => array('auth_option'),
),
'add_unique_index' => array(
$this->table_prefix . 'acl_options' => array(
'auth_option' => array('auth_option'),
),
),
);
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.5-rc1')),
);
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_6 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.6', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_6_rc4');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.6')),
);
}
}

View file

@ -0,0 +1,324 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_6_rc1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.6-rc1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_5');
}
public function update_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'confirm' => array(
'attempts' => array('UINT', 0),
),
$this->table_prefix . 'users' => array(
'user_new' => array('BOOL', 1),
'user_reminded' => array('TINT:4', 0),
'user_reminded_time' => array('TIMESTAMP', 0),
),
$this->table_prefix . 'groups' => array(
'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'),
),
$this->table_prefix . 'privmsgs' => array(
'message_reported' => array('BOOL', 0),
),
$this->table_prefix . 'reports' => array(
'pm_id' => array('UINT', 0),
),
$this->table_prefix . 'profile_fields' => array(
'field_show_on_vt' => array('BOOL', 0),
),
$this->table_prefix . 'forums' => array(
'forum_options' => array('UINT:20', 0),
),
),
'change_columns' => array(
$this->table_prefix . 'users' => array(
'user_options' => array('UINT:11', 230271),
),
),
'add_index' => array(
$this->table_prefix . 'reports' => array(
'post_id' => array('post_id'),
'pm_id' => array('pm_id'),
),
$this->table_prefix . 'posts' => array(
'post_username' => array('post_username:255'),
),
),
);
}
public function revert_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'confirm' => array(
'attempts',
),
$this->table_prefix . 'users' => array(
'user_new',
'user_reminded',
'user_reminded_time',
),
$this->table_prefix . 'groups' => array(
'group_skip_auth',
),
$this->table_prefix . 'privmsgs' => array(
'message_reported',
),
$this->table_prefix . 'reports' => array(
'pm_id',
),
$this->table_prefix . 'profile_fields' => array(
'field_show_on_vt',
),
$this->table_prefix . 'forums' => array(
'forum_options',
),
),
'drop_keys' => array(
$this->table_prefix . 'reports' => array(
'post_id',
'pm_id',
),
$this->table_prefix . 'posts' => array(
'post_username',
),
),
);
}
public function update_data()
{
return array(
array('config.add', array('captcha_plugin', 'phpbb_captcha_nogd')),
array('if', array(
($this->config['captcha_gd']),
array('config.update', array('captcha_plugin', 'phpbb_captcha_gd')),
)),
array('config.add', array('feed_enable', 0)),
array('config.add', array('feed_limit', 10)),
array('config.add', array('feed_overall_forums', 1)),
array('config.add', array('feed_overall_forums_limit', 15)),
array('config.add', array('feed_overall_topics', 0)),
array('config.add', array('feed_overall_topics_limit', 15)),
array('config.add', array('feed_forum', 1)),
array('config.add', array('feed_topic', 1)),
array('config.add', array('feed_item_statistics', 1)),
array('config.add', array('smilies_per_page', 50)),
array('config.add', array('allow_pm_report', 1)),
array('config.add', array('min_post_chars', 1)),
array('config.add', array('allow_quick_reply', 1)),
array('config.add', array('new_member_post_limit', 0)),
array('config.add', array('new_member_group_default', 0)),
array('config.add', array('delete_time', $this->config['edit_time'])),
array('config.add', array('allow_avatar', 0)),
array('if', array(
($this->config['allow_avatar_upload'] || $this->config['allow_avatar_local'] || $this->config['allow_avatar_remote']),
array('config.update', array('allow_avatar', 1)),
)),
array('config.add', array('allow_avatar_remote_upload', 0)),
array('if', array(
($this->config['allow_avatar_remote'] && $this->config['allow_avatar_upload']),
array('config.update', array('allow_avatar_remote_upload', 1)),
)),
array('module.add', array(
'acp',
'ACP_BOARD_CONFIGURATION',
array(
'module_basename' => 'acp_board',
'modes' => array('feed'),
),
)),
array('module.add', array(
'acp',
'ACP_CAT_USERS',
array(
'module_basename' => 'acp_users',
'modes' => array('warnings'),
),
)),
array('module.add', array(
'acp',
'ACP_SERVER_CONFIGURATION',
array(
'module_basename' => 'acp_send_statistics',
'modes' => array('send_statistics'),
),
)),
array('module.add', array(
'acp',
'ACP_FORUM_BASED_PERMISSIONS',
array(
'module_basename' => 'acp_permissions',
'modes' => array('setting_forum_copy'),
),
)),
array('module.add', array(
'mcp',
'MCP_REPORTS',
array(
'module_basename' => 'mcp_pm_reports',
'modes' => array('pm_reports','pm_reports_closed','pm_report_details'),
),
)),
array('custom', array(array(&$this, 'add_newly_registered_group'))),
array('custom', array(array(&$this, 'set_user_options_default'))),
array('config.update', array('version', '3.0.6-rc1')),
);
}
public function set_user_options_default()
{
// 229376 is the added value to enable all three signature options
$sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376';
$this->sql_query($sql);
}
public function add_newly_registered_group()
{
// Add newly_registered group... but check if it already exists (we always supported running the updater on any schema)
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "
WHERE group_name = 'NEWLY_REGISTERED'";
$result = $this->db->sql_query($sql);
$group_id = (int) $this->db->sql_fetchfield('group_id');
$this->db->sql_freeresult($result);
if (!$group_id)
{
$sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)";
$this->sql_query($sql);
$group_id = $this->db->sql_nextid();
}
// Insert new user role... at the end of the chain
$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = 'ROLE_USER_NEW_MEMBER'
AND role_type = 'u_'";
$result = $this->db->sql_query($sql);
$u_role = (int) $this->db->sql_fetchfield('role_id');
$this->db->sql_freeresult($result);
if (!$u_role)
{
$sql = 'SELECT MAX(role_order) as max_order_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_type = 'u_'";
$result = $this->db->sql_query($sql);
$next_order_id = (int) $this->db->sql_fetchfield('max_order_id');
$this->db->sql_freeresult($result);
$next_order_id++;
$sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)";
$this->sql_query($sql);
$u_role = $this->db->sql_nextid();
// Now add the correct data to the roles...
// The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups
$sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')";
$this->sql_query($sql);
// Add user role to group
$sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)";
$this->sql_query($sql);
}
// Insert new forum role
$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = 'ROLE_FORUM_NEW_MEMBER'
AND role_type = 'f_'";
$result = $this->db->sql_query($sql);
$f_role = (int) $this->db->sql_fetchfield('role_id');
$this->db->sql_freeresult($result);
if (!$f_role)
{
$sql = 'SELECT MAX(role_order) as max_order_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_type = 'f_'";
$result = $this->db->sql_query($sql);
$next_order_id = (int) $this->db->sql_fetchfield('max_order_id');
$this->db->sql_freeresult($result);
$next_order_id++;
$sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)";
$this->sql_query($sql);
$f_role = $this->db->sql_nextid();
$sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')";
$this->sql_query($sql);
}
// Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once)
$sql = 'SELECT 1
FROM ' . USERS_TABLE . '
WHERE user_new = 0';
$result = $this->db->sql_query_limit($sql, 1);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
if (!$row)
{
$sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0';
$this->sql_query($sql);
}
// To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts...
// Check if the role is already assigned...
$sql = 'SELECT forum_id
FROM ' . ACL_GROUPS_TABLE . '
WHERE group_id = ' . $group_id . '
AND auth_role_id = ' . $f_role;
$result = $this->db->sql_query($sql);
$is_options = (int) $this->db->sql_fetchfield('forum_id');
$this->db->sql_freeresult($result);
// Not assigned at all... :/
if (!$is_options)
{
// Get postable forums
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE forum_type != ' . FORUM_LINK;
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$this->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)');
}
$this->db->sql_freeresult($result);
}
// Clear permissions...
include_once($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext);
$auth_admin = new auth_admin();
$auth_admin->acl_clear_prefetch();
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_6_rc2 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.6-rc2', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_6_rc1');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.6-rc2')),
);
}
}

View file

@ -0,0 +1,40 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_6_rc3 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.6-rc3', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_6_rc2');
}
public function update_data()
{
return array(
array('custom', array(array(&$this, 'update_cp_fields'))),
array('config.update', array('version', '3.0.6-rc3')),
);
}
public function update_cp_fields()
{
// Update the Custom Profile Fields based on previous settings to the new format
$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . '
SET field_show_on_vt = 1
WHERE field_hide = 0
AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)';
$this->sql_query($sql);
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_6_rc4 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.6-rc4', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_6_rc3');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.6-rc4')),
);
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_7 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.7', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_7_rc2');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.7')),
);
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_7_pl1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.7-pl1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_7');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.7-pl1')),
);
}
}

View file

@ -0,0 +1,76 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_7_rc1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.7-rc1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_6');
}
public function update_schema()
{
return array(
'drop_keys' => array(
$this->table_prefix . 'log' => array(
'log_time',
),
),
'add_index' => array(
$this->table_prefix . 'topics_track' => array(
'topic_id' => array('topic_id'),
),
),
);
}
public function revert_schema()
{
return array(
'add_index' => array(
$this->table_prefix . 'log' => array(
'log_time' => array('log_time'),
),
),
'drop_keys' => array(
$this->table_prefix . 'topics_track' => array(
'topic_id',
),
),
);
}
public function update_data()
{
return array(
array('config.add', array('feed_overall', 1)),
array('config.add', array('feed_http_auth', 0)),
array('config.add', array('feed_limit_post', $this->config['feed_limit'])),
array('config.add', array('feed_limit_topic', $this->config['feed_overall_topics_limit'])),
array('config.add', array('feed_topics_new', $this->config['feed_overall_topics'])),
array('config.add', array('feed_topics_active', $this->config['feed_overall_topics'])),
array('custom', array(array(&$this, 'delete_text_templates'))),
array('config.update', array('version', '3.0.7-rc1')),
);
}
public function delete_text_templates()
{
// Delete all text-templates from the template_data
$sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . '
WHERE template_filename ' . $this->db->sql_like_expression($this->db->any_char . '.txt');
$this->sql_query($sql);
}
}

View file

@ -0,0 +1,73 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_7_rc2 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.7-rc2', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_7_rc1');
}
public function update_data()
{
return array(
array('custom', array(array(&$this, 'update_email_hash'))),
array('config.update', array('version', '3.0.7-rc2')),
);
}
public function update_email_hash($start = 0)
{
$limit = 1000;
$sql = 'SELECT user_id, user_email, user_email_hash
FROM ' . USERS_TABLE . '
WHERE user_type <> ' . USER_IGNORE . "
AND user_email <> ''";
$result = $this->db->sql_query_limit($sql, $limit, $start);
$i = 0;
while ($row = $this->db->sql_fetchrow($result))
{
$i++;
// Snapshot of the phpbb_email_hash() function
// We cannot call it directly because the auto updater updates the DB first. :/
$user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']);
if ($user_email_hash != $row['user_email_hash'])
{
$sql_ary = array(
'user_email_hash' => $user_email_hash,
);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . (int) $row['user_id'];
$this->sql_query($sql);
}
}
$this->db->sql_freeresult($result);
if ($i < $limit)
{
// Completed
return;
}
// Return the next start, will be sent to $start when this function is called again
return $start + $limit;
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_8 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.8', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_8_rc1');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.8')),
);
}
}

View file

@ -0,0 +1,221 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_8_rc1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.8-rc1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_7_pl1');
}
public function update_data()
{
return array(
array('custom', array(array(&$this, 'update_file_extension_group_names'))),
array('custom', array(array(&$this, 'update_module_auth'))),
array('custom', array(array(&$this, 'update_bots'))),
array('custom', array(array(&$this, 'delete_orphan_shadow_topics'))),
array('module.add', array(
'acp',
'ACP_MESSAGES',
array(
'module_basename' => 'acp_board',
'modes' => array('post'),
),
)),
array('config.add', array('load_unreads_search', 1)),
array('config.update_if_equals', array(600, 'queue_interval', 60)),
array('config.update_if_equals', array(50, 'email_package_size', 20)),
array('config.update', array('version', '3.0.8-rc1')),
);
}
public function update_file_extension_group_names()
{
// Update file extension group names to use language strings.
$sql = 'SELECT lang_dir
FROM ' . LANG_TABLE;
$result = $this->db->sql_query($sql);
$extension_groups_updated = array();
while ($lang_dir = $this->db->sql_fetchfield('lang_dir'))
{
$lang_dir = basename($lang_dir);
// The language strings we need are either in language/.../acp/attachments.php
// in the update package if we're updating to 3.0.8-RC1 or later,
// or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier.
// On an already updated board, they can also already be in language/.../acp/attachments.php
// in the board root.
$lang_files = array(
"{$this->phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.{$this->php_ext}",
"{$this->phpbb_root_path}language/$lang_dir/install.{$this->php_ext}",
"{$this->phpbb_root_path}language/$lang_dir/acp/attachments.{$this->php_ext}",
);
foreach ($lang_files as $lang_file)
{
if (!file_exists($lang_file))
{
continue;
}
$lang = array();
include($lang_file);
foreach($lang as $lang_key => $lang_val)
{
if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0)
{
continue;
}
$sql_ary = array(
'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_'
);
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . "
WHERE group_name = '" . $this->db->sql_escape($lang_val) . "'";
$this->sql_query($sql);
$extension_groups_updated[$lang_key] = true;
}
}
}
$this->db->sql_freeresult($result);
}
public function update_module_auth()
{
$sql = 'UPDATE ' . MODULES_TABLE . '
SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\'
WHERE module_class = \'ucp\'
AND module_basename = \'profile\'
AND module_mode = \'avatar\'';
$this->sql_query($sql);
}
public function update_bots()
{
$bot_name = 'Bing [Bot]';
$bot_name_clean = utf8_clean_string($bot_name);
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . "
WHERE username_clean = '" . $this->db->sql_escape($bot_name_clean) . "'";
$result = $this->db->sql_query($sql);
$bing_already_added = (bool) $this->db->sql_fetchfield('user_id');
$this->db->sql_freeresult($result);
if (!$bing_already_added)
{
$bot_agent = 'bingbot/';
$bot_ip = '';
$sql = 'SELECT group_id, group_colour
FROM ' . GROUPS_TABLE . "
WHERE group_name = 'BOTS'";
$result = $this->db->sql_query($sql);
$group_row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
if (!$group_row)
{
// default fallback, should never get here
$group_row['group_id'] = 6;
$group_row['group_colour'] = '9E8DA7';
}
if (!function_exists('user_add'))
{
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
}
$user_row = array(
'user_type' => USER_IGNORE,
'group_id' => $group_row['group_id'],
'username' => $bot_name,
'user_regdate' => time(),
'user_password' => '',
'user_colour' => $group_row['group_colour'],
'user_email' => '',
'user_lang' => $this->config['default_lang'],
'user_style' => $this->config['default_style'],
'user_timezone' => 0,
'user_dateformat' => $this->config['default_dateformat'],
'user_allow_massemail' => 0,
);
$user_id = user_add($user_row);
$sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
'bot_active' => 1,
'bot_name' => (string) $bot_name,
'user_id' => (int) $user_id,
'bot_agent' => (string) $bot_agent,
'bot_ip' => (string) $bot_ip,
));
$this->sql_query($sql);
}
}
public function delete_orphan_shadow_topics()
{
// Delete shadow topics pointing to not existing topics
$batch_size = 500;
// Set of affected forums we have to resync
$sync_forum_ids = array();
$sql_array = array(
'SELECT' => 't1.topic_id, t1.forum_id',
'FROM' => array(
TOPICS_TABLE => 't1',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(TOPICS_TABLE => 't2'),
'ON' => 't1.topic_moved_id = t2.topic_id',
),
),
'WHERE' => 't1.topic_moved_id <> 0
AND t2.topic_id IS NULL',
);
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query_limit($sql, $batch_size);
$topic_ids = array();
while ($row = $this->db->sql_fetchrow($result))
{
$topic_ids[] = (int) $row['topic_id'];
$sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id'];
}
$this->db->sql_freeresult($result);
if (!empty($topic_ids))
{
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE ' . $this->db->sql_in_set('topic_id', $topic_ids);
$this->db->sql_query($sql);
// Sync the forums we have deleted shadow topics from.
sync('forum', 'forum_id', $sync_forum_ids, true, true);
return false;
}
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_9 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.9', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_9_rc4');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.9')),
);
}
}

View file

@ -0,0 +1,124 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_9_rc1 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.9-rc1', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_8');
}
public function update_schema()
{
return array(
'add_tables' => array(
$this->table_prefix . 'login_attempts' => array(
'COLUMNS' => array(
// this column was removed from the database updater
// after 3.0.9-RC3 was released. It might still exist
// in 3.0.9-RCX installations and has to be dropped in
// 3.0.12 after the db_tools class is capable of properly
// removing a primary key.
// 'attempt_id' => array('UINT', NULL, 'auto_increment'),
'attempt_ip' => array('VCHAR:40', ''),
'attempt_browser' => array('VCHAR:150', ''),
'attempt_forwarded_for' => array('VCHAR:255', ''),
'attempt_time' => array('TIMESTAMP', 0),
'user_id' => array('UINT', 0),
'username' => array('VCHAR_UNI:255', 0),
'username_clean' => array('VCHAR_CI', 0),
),
//'PRIMARY_KEY' => 'attempt_id',
'KEYS' => array(
'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')),
'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')),
'att_time' => array('INDEX', array('attempt_time')),
'user_id' => array('INDEX', 'user_id'),
),
),
),
'change_columns' => array(
$this->table_prefix . 'bbcodes' => array(
'bbcode_id' => array('USINT', 0),
),
),
);
}
public function revert_schema()
{
return array(
'drop_tables' => array(
$this->table_prefix . 'login_attempts',
),
);
}
public function update_data()
{
return array(
array('config.add', array('ip_login_limit_max', 50)),
array('config.add', array('ip_login_limit_time', 21600)),
array('config.add', array('ip_login_limit_use_forwarded', 0)),
array('custom', array(array(&$this, 'update_file_extension_group_names'))),
array('custom', array(array(&$this, 'fix_firebird_qa_captcha'))),
array('config.update', array('version', '3.0.9-rc1')),
);
}
public function update_file_extension_group_names()
{
// Update file extension group names to use language strings, again.
$sql = 'SELECT group_id, group_name
FROM ' . EXTENSION_GROUPS_TABLE . '
WHERE group_name ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->any_char);
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$sql_ary = array(
'group_name' => substr($row['group_name'], 10), // Strip off 'EXT_GROUP_'
);
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
WHERE group_id = ' . $row['group_id'];
$this->sql_query($sql);
}
$this->db->sql_freeresult($result);
}
public function fix_firebird_qa_captcha()
{
// Recover from potentially broken Q&A CAPTCHA table on firebird
// Q&A CAPTCHA was uninstallable, so it's safe to remove these
// without data loss
if ($this->db_tools->sql_layer == 'firebird')
{
$tables = array(
$this->table_prefix . 'captcha_questions',
$this->table_prefix . 'captcha_answers',
$this->table_prefix . 'qa_confirm',
);
foreach ($tables as $table)
{
if ($this->db_tools->sql_table_exists($table))
{
$this->db_tools->sql_table_drop($table);
}
}
}
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_9_rc2 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.9-rc2', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_9_rc1');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.9-rc2')),
);
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_9_rc3 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.9-rc3', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_9_rc2');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.9-rc3')),
);
}
}

View file

@ -0,0 +1,28 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_30x_3_0_9_rc4 extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.0.9-rc4', '>=');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_9_rc3');
}
public function update_data()
{
return array(
array('config.update', array('version', '3.0.9-rc4')),
);
}
}

View file

@ -0,0 +1,405 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_310_dev extends phpbb_db_migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.1.0-dev', '>=');
}
static public function depends_on()
{
return array(
'phpbb_db_migration_data_310_extensions',
'phpbb_db_migration_data_310_style_update_p2',
'phpbb_db_migration_data_310_timezone_p2',
'phpbb_db_migration_data_310_reported_posts_display',
);
}
public function update_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'groups' => array(
'group_teampage' => array('UINT', 0, 'after' => 'group_legend'),
),
$this->table_prefix . 'profile_fields' => array(
'field_show_on_pm' => array('BOOL', 0),
),
$this->table_prefix . 'styles' => array(
'style_path' => array('VCHAR:100', ''),
'bbcode_bitfield' => array('VCHAR:255', 'kNg='),
'style_parent_id' => array('UINT:4', 0),
'style_parent_tree' => array('TEXT', ''),
),
$this->table_prefix . 'reports' => array(
'reported_post_text' => array('MTEXT_UNI', ''),
'reported_post_uid' => array('VCHAR:8', ''),
'reported_post_bitfield' => array('VCHAR:255', ''),
),
),
'change_columns' => array(
$this->table_prefix . 'groups' => array(
'group_legend' => array('UINT', 0),
),
),
);
}
public function revert_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'groups' => array(
'group_teampage',
),
$this->table_prefix . 'profile_fields' => array(
'field_show_on_pm',
),
$this->table_prefix . 'styles' => array(
'style_path',
'bbcode_bitfield',
'style_parent_id',
'style_parent_tree',
),
$this->table_prefix . 'reports' => array(
'reported_post_text',
'reported_post_uid',
'reported_post_bitfield',
),
),
);
}
public function update_data()
{
return array(
array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])),
array('config.add', array('fulltext_postgres_ts_name', 'simple')),
array('config.add', array('fulltext_postgres_min_word_len', 4)),
array('config.add', array('fulltext_postgres_max_word_len', 254)),
array('config.add', array('fulltext_sphinx_stopwords', 0)),
array('config.add', array('fulltext_sphinx_indexer_mem_limit', 512)),
array('config.add', array('load_jquery_cdn', 0)),
array('config.add', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js')),
array('config.add', array('use_system_cron', 0)),
array('config.add', array('legend_sort_groupname', 0)),
array('config.add', array('teampage_forums', 1)),
array('config.add', array('teampage_memberships', 1)),
array('config.add', array('load_cpf_pm', 0)),
array('config.add', array('display_last_subject', 1)),
array('config.add', array('assets_version', 1)),
array('config.add', array('site_home_url', '')),
array('config.add', array('site_home_text', '')),
array('permission.add', array('u_chgprofileinfo', true, 'u_sig')),
array('module.add', array(
'acp',
'ACP_GROUPS',
array(
'module_basename' => 'acp_groups',
'modes' => array('position'),
),
)),
array('module.add', array(
'acp',
'ACP_ATTACHMENTS',
array(
'module_basename' => 'acp_attachments',
'modes' => array('manage'),
),
)),
array('module.add', array(
'acp',
'ACP_STYLE_MANAGEMENT',
array(
'module_basename' => 'acp_styles',
'modes' => array('install', 'cache'),
),
)),
array('module.add', array(
'ucp',
'UCP_PROFILE',
array(
'module_basename' => 'ucp_profile',
'modes' => array('autologin_keys'),
),
)),
// Module will be renamed later
array('module.add', array(
'acp',
'ACP_CAT_STYLES',
'ACP_LANGUAGE'
)),
array('module.remove', array(
'acp',
false,
'ACP_TEMPLATES',
)),
array('module.remove', array(
'acp',
false,
'ACP_THEMES',
)),
array('module.remove', array(
'acp',
false,
'ACP_IMAGESETS',
)),
array('custom', array(array($this, 'rename_module_basenames'))),
array('custom', array(array($this, 'rename_styles_module'))),
array('custom', array(array($this, 'add_group_teampage'))),
array('custom', array(array($this, 'update_group_legend'))),
array('custom', array(array($this, 'localise_global_announcements'))),
array('custom', array(array($this, 'update_ucp_pm_basename'))),
array('custom', array(array($this, 'update_ucp_profile_auth'))),
array('custom', array(array($this, 'move_customise_modules'))),
array('config.update', array('version', '3.1.0-dev')),
);
}
public function move_customise_modules()
{
// Move language management to new location in the Customise tab
// First get language module id
$sql = 'SELECT module_id FROM ' . MODULES_TABLE . "
WHERE module_basename = 'acp_language'";
$result = $this->db->sql_query($sql);
$language_module_id = $this->db->sql_fetchfield('module_id');
$this->db->sql_freeresult($result);
// Next get language management module id of the one just created
$sql = 'SELECT module_id FROM ' . MODULES_TABLE . "
WHERE module_langname = 'ACP_LANGUAGE'";
$result = $this->db->sql_query($sql);
$language_management_module_id = $this->db->sql_fetchfield('module_id');
$this->db->sql_freeresult($result);
if (!class_exists('acp_modules'))
{
include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
}
// acp_modules calls adm_back_link, which is undefined at this point
if (!function_exists('adm_back_link'))
{
include($this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext);
}
$module_manager = new acp_modules();
$module_manager->module_class = 'acp';
$module_manager->move_module($language_module_id, $language_management_module_id);
}
public function update_ucp_pm_basename()
{
$sql = 'SELECT module_id, module_basename
FROM ' . MODULES_TABLE . "
WHERE module_basename <> 'ucp_pm' AND
module_langname='UCP_PM'";
$result = $this->db->sql_query_limit($sql, 1);
if ($row = $this->db->sql_fetchrow($result))
{
// This update is still not applied. Applying it
$sql = 'UPDATE ' . MODULES_TABLE . "
SET module_basename = 'ucp_pm'
WHERE module_id = " . (int) $row['module_id'];
$this->sql_query($sql);
}
$this->db->sql_freeresult($result);
}
public function update_ucp_profile_auth()
{
// Update the auth setting for the module
$sql = 'UPDATE ' . MODULES_TABLE . "
SET module_auth = 'acl_u_chgprofileinfo'
WHERE module_class = 'ucp'
AND module_basename = 'ucp_profile'
AND module_mode = 'profile_info'";
$this->sql_query($sql);
}
public function rename_styles_module()
{
// Rename styles module to Customise
$sql = 'UPDATE ' . MODULES_TABLE . "
SET module_langname = 'ACP_CAT_CUSTOMISE'
WHERE module_langname = 'ACP_CAT_STYLES'";
$this->sql_query($sql);
}
public function rename_module_basenames()
{
// rename all module basenames to full classname
$sql = 'SELECT module_id, module_basename, module_class
FROM ' . MODULES_TABLE;
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$module_id = (int) $row['module_id'];
unset($row['module_id']);
if (!empty($row['module_basename']) && !empty($row['module_class']))
{
// all the class names start with class name or with phpbb_ for auto loading
if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 &&
strpos($row['module_basename'], 'phpbb_') !== 0)
{
$row['module_basename'] = $row['module_class'] . '_' . $row['module_basename'];
$sql_update = $this->db->sql_build_array('UPDATE', $row);
$sql = 'UPDATE ' . MODULES_TABLE . '
SET ' . $sql_update . '
WHERE module_id = ' . $module_id;
$this->sql_query($sql);
}
}
}
$this->db->sql_freeresult($result);
}
public function add_group_teampage()
{
$sql = 'UPDATE ' . GROUPS_TABLE . '
SET group_teampage = 1
WHERE group_type = ' . GROUP_SPECIAL . "
AND group_name = 'ADMINISTRATORS'";
$this->sql_query($sql);
$sql = 'UPDATE ' . GROUPS_TABLE . '
SET group_teampage = 2
WHERE group_type = ' . GROUP_SPECIAL . "
AND group_name = 'GLOBAL_MODERATORS'";
$this->sql_query($sql);
}
public function update_group_legend()
{
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . '
WHERE group_legend = 1
ORDER BY group_name ASC';
$result = $this->db->sql_query($sql);
$next_legend = 1;
while ($row = $this->db->sql_fetchrow($result))
{
$sql = 'UPDATE ' . GROUPS_TABLE . '
SET group_legend = ' . $next_legend . '
WHERE group_id = ' . (int) $row['group_id'];
$this->sql_query($sql);
$next_legend++;
}
$this->db->sql_freeresult($result);
}
public function localise_global_announcements()
{
// Localise Global Announcements
$sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour
FROM ' . TOPICS_TABLE . '
WHERE forum_id = 0
AND topic_type = ' . POST_GLOBAL;
$result = $this->db->sql_query($sql);
$global_announcements = $update_lastpost_data = array();
$update_lastpost_data['forum_last_post_time'] = 0;
$update_forum_data = array(
'forum_posts' => 0,
'forum_topics' => 0,
'forum_topics_real' => 0,
);
while ($row = $this->db->sql_fetchrow($result))
{
$global_announcements[] = (int) $row['topic_id'];
$update_forum_data['forum_posts'] += (int) $row['topic_posts'];
$update_forum_data['forum_topics_real']++;
if ($row['topic_approved'])
{
$update_forum_data['forum_topics']++;
}
if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time'])
{
$update_lastpost_data = array(
'forum_last_post_id' => (int) $row['topic_last_post_id'],
'forum_last_post_subject' => $row['topic_last_post_subject'],
'forum_last_post_time' => (int) $row['topic_last_post_time'],
'forum_last_poster_id' => (int) $row['topic_last_poster_id'],
'forum_last_poster_name' => $row['topic_last_poster_name'],
'forum_last_poster_colour' => $row['topic_last_poster_colour'],
);
}
}
$this->db->sql_freeresult($result);
if (!empty($global_announcements))
{
// Update the post/topic-count for the forum and the last-post if needed
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST;
$result = $this->db->sql_query_limit($sql, 1);
$ga_forum_id = $this->db->sql_fetchfield('forum_id');
$this->db->sql_freeresult($result);
$sql = 'SELECT forum_last_post_time
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $ga_forum_id;
$result = $this->db->sql_query($sql);
$lastpost = (int) $this->db->sql_fetchfield('forum_last_post_time');
$this->db->sql_freeresult($result);
$sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', ';
$sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', ';
$sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics'];
if ($lastpost < $update_lastpost_data['forum_last_post_time'])
{
$sql_update .= ', ' . $this->db->sql_build_array('UPDATE', $update_lastpost_data);
}
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . $sql_update . '
WHERE forum_id = ' . $ga_forum_id;
$this->sql_query($sql);
// Update some forum_ids
$table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
foreach ($table_ary as $table)
{
$sql = "UPDATE $table
SET forum_id = $ga_forum_id
WHERE " . $this->db->sql_in_set('topic_id', $global_announcements);
$this->sql_query($sql);
}
unset($table_ary);
}
}
}

View file

@ -0,0 +1,69 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_310_extensions extends phpbb_db_migration
{
public function effectively_installed()
{
return $this->db_tools->sql_table_exists($this->table_prefix . 'ext');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_11');
}
public function update_schema()
{
return array(
'add_tables' => array(
$this->table_prefix . 'ext' => array(
'COLUMNS' => array(
'ext_name' => array('VCHAR', ''),
'ext_active' => array('BOOL', 0),
'ext_state' => array('TEXT', ''),
),
'KEYS' => array(
'ext_name' => array('UNIQUE', 'ext_name'),
),
),
),
);
}
public function revert_schema()
{
return array(
'drop_tables' => array(
$this->table_prefix . 'ext',
),
);
}
public function update_data()
{
return array(
// Module will be renamed later
array('module.add', array(
'acp',
'ACP_CAT_STYLES',
'ACP_EXTENSION_MANAGEMENT'
)),
array('module.add', array(
'acp',
'ACP_EXTENSION_MANAGEMENT',
array(
'module_basename' => 'acp_extensions',
'modes' => array('main'),
),
)),
array('permission.add', array('a_extensions', true, 'a_styles')),
);
}
}

View file

@ -0,0 +1,160 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_310_notifications extends phpbb_db_migration
{
public function effectively_installed()
{
return $this->db_tools->sql_table_exists($this->table_prefix . 'notifications');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_310_dev');
}
public function update_schema()
{
return array(
'add_tables' => array(
$this->table_prefix . 'notification_types' => array(
'COLUMNS' => array(
'notification_type' => array('VCHAR:255', ''),
'notification_type_enabled' => array('BOOL', 1),
),
'PRIMARY_KEY' => array('notification_type', 'notification_type_enabled'),
),
$this->table_prefix . 'notifications' => array(
'COLUMNS' => array(
'notification_id' => array('UINT', NULL, 'auto_increment'),
'item_type' => array('VCHAR:255', ''),
'item_id' => array('UINT', 0),
'item_parent_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
'notification_read' => array('BOOL', 0),
'notification_time' => array('TIMESTAMP', 1),
'notification_data' => array('TEXT_UNI', ''),
),
'PRIMARY_KEY' => 'notification_id',
'KEYS' => array(
'item_ident' => array('INDEX', array('item_type', 'item_id')),
'user' => array('INDEX', array('user_id', 'notification_read')),
),
),
$this->table_prefix . 'user_notifications' => array(
'COLUMNS' => array(
'item_type' => array('VCHAR:255', ''),
'item_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
'method' => array('VCHAR:255', ''),
'notify' => array('BOOL', 1),
),
),
),
);
}
public function revert_schema()
{
return array(
'drop_tables' => array(
$this->table_prefix . 'notification_types',
$this->table_prefix . 'notifications',
$this->table_prefix . 'user_notifications',
),
);
}
public function update_data()
{
return array(
array('module.add', array(
'ucp',
'UCP_MAIN',
array(
'module_basename' => 'ucp_notifications',
'modes' => array('notification_list'),
),
)),
array('module.add', array(
'ucp',
'UCP_PREFS',
array(
'module_basename' => 'ucp_notifications',
'modes' => array('notification_options'),
),
)),
array('config.add', array('load_notifications', 1)),
array('custom', array(array($this, 'convert_notifications'))),
);
}
public function convert_notifications()
{
$convert_notifications = array(
array(
'check' => ($this->config['allow_topic_notify']),
'item_type' => 'post',
),
array(
'check' => ($this->config['allow_forum_notify']),
'item_type' => 'topic',
),
array(
'check' => ($this->config['allow_bookmarks']),
'item_type' => 'bookmark',
),
array(
'check' => ($this->config['allow_privmsg']),
'item_type' => 'pm',
),
);
foreach ($convert_notifications as $convert_data)
{
if ($convert_data['check'])
{
$sql = 'SELECT user_id, user_notify_type
FROM ' . USERS_TABLE . '
WHERE user_notify = 1';
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array(
'item_type' => $convert_data['item_type'],
'item_id' => 0,
'user_id' => $row['user_id'],
'method' => '',
)));
if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH)
{
$this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array(
'item_type' => $convert_data['item_type'],
'item_id' => 0,
'user_id' => $row['user_id'],
'method' => 'email',
)));
}
if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH)
{
$this->sql_query('INSERT INTO ' . $this->table_prefix . 'user_notifications ' . $this->db->sql_build_array('INSERT', array(
'item_type' => $convert_data['item_type'],
'item_id' => 0,
'user_id' => $row['user_id'],
'method' => 'jabber',
)));
}
}
$this->db->sql_freeresult($result);
}
}
}
}

View file

@ -0,0 +1,47 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_310_reported_posts_display extends phpbb_db_migration
{
public function effectively_installed()
{
return $this->db_tools->sql_column_exists($this->table_prefix . 'reports', 'reported_post_enable_bbcode');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_11');
}
public function update_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'reports' => array(
'reported_post_enable_bbcode' => array('BOOL', 1),
'reported_post_enable_smilies' => array('BOOL', 1),
'reported_post_enable_magic_url' => array('BOOL', 1),
),
),
);
}
public function revert_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'reports' => array(
'reported_post_enable_bbcode',
'reported_post_enable_smilies',
'reported_post_enable_magic_url',
),
),
);
}
}

View file

@ -0,0 +1,157 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_310_style_update_p1 extends phpbb_db_migration
{
public function effectively_installed()
{
return !$this->db_tools->sql_table_exists($this->table_prefix . 'styles_imageset');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_11');
}
public function update_data()
{
return array(
array('custom', array(array($this, 'styles_update'))),
);
}
public function styles_update()
{
// Get list of valid 3.1 styles
$available_styles = array('prosilver');
$iterator = new DirectoryIterator($this->phpbb_root_path . 'styles');
$skip_dirs = array('.', '..', 'prosilver');
foreach ($iterator as $fileinfo)
{
if ($fileinfo->isDir() && !in_array($fileinfo->getFilename(), $skip_dirs) && file_exists($fileinfo->getPathname() . '/style.cfg'))
{
$style_cfg = parse_cfg_file($fileinfo->getPathname() . '/style.cfg');
if (isset($style_cfg['phpbb_version']) && version_compare($style_cfg['phpbb_version'], '3.1.0-dev', '>='))
{
// 3.1 style
$available_styles[] = $fileinfo->getFilename();
}
}
}
// Get all installed styles
if ($this->db_tools->sql_table_exists($this->table_prefix . 'styles_imageset'))
{
$sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path
FROM ' . STYLES_TABLE . ' s, ' . $this->table_prefix . 'styles_template t, ' . $this->table_prefix . 'styles_theme c, ' . $this->table_prefix . "styles_imageset i
WHERE t.template_id = s.template_id
AND c.theme_id = s.theme_id
AND i.imageset_id = s.imageset_id";
}
else
{
$sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id
FROM ' . STYLES_TABLE . ' s, ' . $this->table_prefix . 'styles_template t, ' . $this->table_prefix . "stles_theme c
WHERE t.template_id = s.template_id
AND c.theme_id = s.theme_id";
}
$result = $this->db->sql_query($sql);
$styles = array();
while ($row = $this->db->sql_fetchrow($result))
{
$styles[] = $row;
}
$this->db->sql_freeresult($result);
// Decide which styles to keep, all others will be deleted
$valid_styles = array();
foreach ($styles as $style_row)
{
if (
// Delete styles with parent style (not supported yet)
$style_row['template_inherits_id'] == 0 &&
// Check if components match
$style_row['template_path'] == $style_row['theme_path'] && (!isset($style_row['imageset_path']) || $style_row['template_path'] == $style_row['imageset_path']) &&
// Check if components are valid
in_array($style_row['template_path'], $available_styles)
)
{
// Valid style. Keep it
$sql_ary = array(
'style_path' => $style_row['template_path'],
'bbcode_bitfield' => $style_row['bbcode_bitfield'],
'style_parent_id' => 0,
'style_parent_tree' => '',
);
$this->sql_query('UPDATE ' . STYLES_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
WHERE style_id = ' . $style_row['style_id']);
$valid_styles[] = (int) $style_row['style_id'];
}
}
// Remove old entries from styles table
if (!sizeof($valid_styles))
{
// No valid styles: remove everything and add prosilver
$this->sql_query('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary);
$sql_ary = array(
'style_name' => 'prosilver',
'style_copyright' => '&copy; phpBB Group',
'style_active' => 1,
'style_path' => 'prosilver',
'bbcode_bitfield' => 'lNg=',
'style_parent_id' => 0,
'style_parent_tree' => '',
// Will be removed in the next step
'imageset_id' => 0,
'template_id' => 0,
'theme_id' => 0,
);
$sql = 'INSERT INTO ' . STYLES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
$this->sql_query($sql);
$sql = 'SELECT style_id
FROM ' . $table . "
WHERE style_name = 'prosilver'";
$result = $this->sql_query($sql);
$default_style = $this->db->sql_fetchfield($result);
$this->db->sql_freeresult($result);
set_config('default_style', $default_style);
$sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0';
$this->sql_query($sql);
}
else
{
// There are valid styles in styles table. Remove styles that are outdated
$this->sql_query('DELETE FROM ' . STYLES_TABLE . '
WHERE ' . $this->db->sql_in_set('style_id', $valid_styles, true));
// Change default style
if (!in_array($this->config['default_style'], $valid_styles))
{
$this->sql_query('UPDATE ' . CONFIG_TABLE . "
SET config_value = '" . $valid_styles[0] . "'
WHERE config_name = 'default_style'");
}
// Reset styles for users
$this->sql_query('UPDATE ' . USERS_TABLE . '
SET user_style = 0
WHERE ' . $this->db->sql_in_set('user_style', $valid_styles, true));
}
}
}

View file

@ -0,0 +1,129 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_310_style_update_p2 extends phpbb_db_migration
{
public function effectively_installed()
{
return !$this->db_tools->sql_table_exists($this->table_prefix . 'styles_imageset');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_310_style_update_p1');
}
public function update_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'styles' => array(
'imageset_id',
'template_id',
'theme_id',
),
),
'drop_tables' => array(
$this->table_prefix . 'styles_imageset',
$this->table_prefix . 'styles_imageset_data',
$this->table_prefix . 'styles_template',
$this->table_prefix . 'styles_template_data',
$this->table_prefix . 'styles_theme',
),
);
}
public function revert_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'styles' => array(
'imageset_id' => array('UINT', 0),
'template_id' => array('UINT', 0),
'theme_id' => array('UINT', 0),
),
),
'add_tables' => array(
$this->table_prefix . 'styles_imageset' => array(
'COLUMNS' => array(
'imageset_id' => array('UINT', NULL, 'auto_increment'),
'imageset_name' => array('VCHAR_UNI:255', ''),
'imageset_copyright' => array('VCHAR_UNI', ''),
'imageset_path' => array('VCHAR:100', ''),
),
'PRIMARY_KEY' => 'imageset_id',
'KEYS' => array(
'imgset_nm' => array('UNIQUE', 'imageset_name'),
),
),
$this->table_prefix . 'styles_imageset_data' => array(
'COLUMNS' => array(
'image_id' => array('UINT', NULL, 'auto_increment'),
'image_name' => array('VCHAR:200', ''),
'image_filename' => array('VCHAR:200', ''),
'image_lang' => array('VCHAR:30', ''),
'image_height' => array('USINT', 0),
'image_width' => array('USINT', 0),
'imageset_id' => array('UINT', 0),
),
'PRIMARY_KEY' => 'image_id',
'KEYS' => array(
'i_d' => array('INDEX', 'imageset_id'),
),
),
$this->table_prefix . 'styles_template' => array(
'COLUMNS' => array(
'template_id' => array('UINT', NULL, 'auto_increment'),
'template_name' => array('VCHAR_UNI:255', ''),
'template_copyright' => array('VCHAR_UNI', ''),
'template_path' => array('VCHAR:100', ''),
'bbcode_bitfield' => array('VCHAR:255', 'kNg='),
'template_storedb' => array('BOOL', 0),
'template_inherits_id' => array('UINT:4', 0),
'template_inherit_path' => array('VCHAR', ''),
),
'PRIMARY_KEY' => 'template_id',
'KEYS' => array(
'tmplte_nm' => array('UNIQUE', 'template_name'),
),
),
$this->table_prefix . 'styles_template_data' => array(
'COLUMNS' => array(
'template_id' => array('UINT', 0),
'template_filename' => array('VCHAR:100', ''),
'template_included' => array('TEXT', ''),
'template_mtime' => array('TIMESTAMP', 0),
'template_data' => array('MTEXT_UNI', ''),
),
'KEYS' => array(
'tid' => array('INDEX', 'template_id'),
'tfn' => array('INDEX', 'template_filename'),
),
),
$this->table_prefix . 'styles_theme' => array(
'COLUMNS' => array(
'theme_id' => array('UINT', NULL, 'auto_increment'),
'theme_name' => array('VCHAR_UNI:255', ''),
'theme_copyright' => array('VCHAR_UNI', ''),
'theme_path' => array('VCHAR:100', ''),
'theme_storedb' => array('BOOL', 0),
'theme_mtime' => array('TIMESTAMP', 0),
'theme_data' => array('MTEXT_UNI', ''),
),
'PRIMARY_KEY' => 'theme_id',
'KEYS' => array(
'theme_name' => array('UNIQUE', 'theme_name'),
),
),
),
);
}
}

View file

@ -1,16 +1,67 @@
<?php
/**
*
* @package phpBB3
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
/**
* phpBB Update Helpers
*/
class phpbb_update_helpers
class phpbb_db_migration_data_310_timezone extends phpbb_db_migration
{
public function effectively_installed()
{
return !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_dst');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_30x_3_0_11');
}
public function update_schema()
{
return array(
'change_columns' => array(
$this->table_prefix . 'users' => array(
'user_timezone' => array('VCHAR:100', ''),
),
),
);
}
public function update_data()
{
return array(
array('custom', array(array($this, 'update_timezones'))),
);
}
public function update_timezones()
{
// Update user timezones
$sql = 'SELECT user_dst, user_timezone
FROM ' . $this->table_prefix . 'users
GROUP BY user_timezone, user_dst';
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$sql = 'UPDATE ' . $this->table_prefix . "users
SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "'
WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "'
AND user_dst = " . (int) $row['user_dst'];
$this->sql_query($sql);
}
$this->db->sql_freeresult($result);
// Update board default timezone
$sql = 'UPDATE ' . $this->table_prefix . "config
SET config_value = '" . $this->convert_phpbb30_timezone($this->config['board_timezone'], $this->config['board_dst']) . "'
WHERE config_name = 'board_timezone'";
$this->sql_query($sql);
}
/**
* Determine the new timezone for a given phpBB 3.0 timezone and
* "Daylight Saving Time" option
@ -19,7 +70,7 @@ class phpbb_update_helpers
* @param $dst int Users daylight saving time
* @return string Users new php Timezone which is used since 3.1
*/
function convert_phpbb30_timezone($timezone, $dst)
public function convert_phpbb30_timezone($timezone, $dst)
{
$offset = $timezone + $dst;

View file

@ -0,0 +1,43 @@
<?php
/**
*
* @package migration
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
class phpbb_db_migration_data_310_timezone_p2 extends phpbb_db_migration
{
public function effectively_installed()
{
return !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_dst');
}
static public function depends_on()
{
return array('phpbb_db_migration_data_310_timezone');
}
public function update_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'users' => array(
'user_dst',
),
),
);
}
public function revert_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'users' => array(
'user_dst' => array('BOOL', 0),
),
),
);
}
}

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,502 @@
<?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);
$module = $this->get_module_info($class, $basename);
$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);
$module_info = $this->get_module_info($class, $basename);
foreach ($module_info['modes'] as $mode => $info)
{
if (!isset($module['modes']) || in_array($mode, $module['modes']))
{
$this->remove($class, $parent, $info['title']);
}
}
}
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);
}
}
/**
* Wrapper for acp_modules::get_module_infos()
*
* @param string $class Module Class
* @param string $basename Module Basename
* @return array Module Information
*/
protected function get_module_info($class, $basename)
{
if (!class_exists('acp_modules'))
{
include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
}
$acp_modules = new acp_modules();
$module = $acp_modules->get_module_infos($basename, $class, true);
if (empty($module))
{
throw new phpbb_db_migration_exception('MODULE_INFO_FILE_NOT_EXIST', $class, $basename);
}
return array_pop($module);
}
}

Some files were not shown because too many files have changed in this diff Show more