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

* 'develop' of https://github.com/phpbb/phpbb3: (799 commits)
  [ticket/11402] Fix undefined index in post/topic_in_queue
  [ticket/11400] If email is disabled, disable it for notifications
  [ticket/11398] Correctly call permission_set method in permission tool
  [ticket/11394] Relax Migration Tools
  [ticket/11386] Fix missing ;
  [ticket/10714] Get log from container in install, update and download/file
  [feature/avatars] Update module_auth of ucp module and fix small issues
  [ticket/11396] Rename insert_migration to set_migration_state
  [ticket/11395] Prevent acp_modules::get_modules_info from reincluding files
  [ticket/11393] Give more information on database updater
  [ticket/11386] Send list of migrations instead of using load_migrations
  [feature/avatars] Add migrations data file for avatars
  [feature/avatars] Reduce module auth of ucp avatar settings
  [ticket/10714] Use $phpbb_adm_relative_path instead of hardcoded adm/
  [ticket/10714] Logs are disabled for this page call only
  [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
  ...

Conflicts:
	phpBB/assets/javascript/core.js
This commit is contained in:
Joas Schilling 2013-03-06 07:35:47 +01:00
commit 0bbde4c122
368 changed files with 26237 additions and 7976 deletions

View file

@ -3,21 +3,28 @@ php:
- 5.3.3 - 5.3.3
- 5.3 - 5.3
- 5.4 - 5.4
- 5.5
env: env:
- DB=mysql - DB=mysql
- DB=postgres - DB=postgres
matrix:
allow_failures:
- php: 5.5
before_script: 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 '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' = '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" - 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 set auto_discover 1
- pyrus install --force phpunit/DbUnit - pyrus install --force phpunit/DbUnit
- phpenv rehash - phpenv rehash
- cd phpBB - cd phpBB
- php ../composer.phar install --dev - 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: script:
- phpunit --configuration travis/phpunit-$DB-travis.xml - phpunit --configuration travis/phpunit-$DB-travis.xml

View file

@ -2,17 +2,16 @@
<project name="phpBB" description="The phpBB forum software" default="all" basedir="../"> <project name="phpBB" description="The phpBB forum software" default="all" basedir="../">
<!-- a few settings for the build --> <!-- a few settings for the build -->
<property name="newversion" value="3.0.11" /> <property name="newversion" value="3.1.0-dev" />
<property name="prevversion" value="3.0.10" /> <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.11-RC1, 3.0.11-RC2" /> <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 --> <!-- no configuration should be needed beyond this point -->
<property name="oldversions" value="${olderversions}, ${prevversion}" /> <property name="oldversions" value="${olderversions}, ${prevversion}" />
<property name="versions" value="${oldversions}, ${newversion}" /> <property name="versions" value="${oldversions}, ${newversion}" />
<!-- These are the main targets which you will probably want to use --> <!-- 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,package" />
<target name="all" depends="clean,prepare,composer,test,docs,create-package" />
<target name="build" depends="clean,prepare,composer,test,docs" /> <target name="build" depends="clean,prepare,composer,test,docs" />
<target name="prepare"> <target name="prepare">
@ -43,9 +42,15 @@
<delete dir="build/save" /> <delete dir="build/save" />
</target> </target>
<target name="composer" depends="clean,prepare"> <!--
<exec dir="./phpBB/" This target basically just runs composer in the phpBB tree to ensure
command="php ../composer.phar install" 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" /> passthru="true" />
</target> </target>
@ -122,7 +127,7 @@
</target> </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 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" /> <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}" command="git archive ${revision} | tar -xf - -C ../${dir}"
checkreturn="true" /> checkreturn="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}" <exec dir="${dir}"
command="php ../composer.phar install" command="php composer.phar install"
checkreturn="true"
passthru="true" /> passthru="true" />
<delete file="${dir}/composer.phar" />
</then>
</if>
<delete file="${dir}/config.php" /> <delete file="${dir}/config.php" />
<delete dir="${dir}/develop" /> <delete dir="${dir}/develop" />
@ -187,6 +210,7 @@
<delete dir="${dir}/files" /> <delete dir="${dir}/files" />
<delete dir="${dir}/install" /> <delete dir="${dir}/install" />
<delete dir="${dir}/store" /> <delete dir="${dir}/store" />
<delete dir="${dir}/vendor" />
</target> </target>
</project> </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... // We define the admin variables now, because the user is now able to use the admin related features...
define('IN_ADMIN', true); define('IN_ADMIN', true);
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
// Some oft used variables // Some oft used variables
$safe_mode = (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) === 'on') ? true : false; $safe_mode = (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) === 'on') ? true : false;

View file

@ -0,0 +1,11 @@
<dl>
<dt><label for="avatar_gravatar_email">{L_GRAVATAR_AVATAR_EMAIL}{L_COLON}</label><br /><span>{L_GRAVATAR_AVATAR_EMAIL_EXPLAIN}</span></dt>
<dd><input type="text" name="avatar_gravatar_email" id="avatar_gravatar_email" value="{AVATAR_GRAVATAR_EMAIL}" class="inputbox" /></dd>
</dl>
<dl>
<dt><label for="avatar_gravatar_width">{L_GRAVATAR_AVATAR_SIZE}{L_COLON}</label><br /><span>{L_GRAVATAR_AVATAR_SIZE_EXPLAIN}</span></dt>
<dd>
<input type="text" name="avatar_gravatar_width" id="avatar_gravatar_width" size="3" value="{AVATAR_GRAVATAR_WIDTH}" class="inputbox autowidth" /> {L_PIXEL} &times;&nbsp;
<input type="text" name="avatar_gravatar_height" id="avatar_gravatar_height" size="3" value="{AVATAR_GRAVATAR_HEIGHT}" class="inputbox autowidth" /> {L_PIXEL}
</dd>
</dl>

View file

@ -0,0 +1,25 @@
<dl>
<dt><label for="category">{L_AVATAR_CATEGORY}{L_COLON}</label></dt>
<dd><select name="avatar_local_cat" id="category">
<option value="">{L_NO_AVATAR_CATEGORY}</option>
<!-- BEGIN avatar_local_cats -->
<option value="{avatar_local_cats.NAME}"<!-- IF avatar_local_cats.SELECTED --> selected="selected"<!-- ENDIF -->>{avatar_local_cats.NAME}</option>
<!-- END avatar_local_cats -->
</select>&nbsp;<input type="submit" value="{L_GO}" name="avatar_local_go" class="button2" /></dd>
</dl>
<!-- IF AVATAR_LOCAL_SHOW -->
<table>
<!-- BEGIN avatar_local_row -->
<tr>
<!-- BEGIN avatar_local_col -->
<td class="row1" style="text-align: center;"><img src="{avatar_local_row.avatar_local_col.AVATAR_IMAGE}" alt="{avatar_local_row.avatar_local_col.AVATAR_NAME}" title="{avatar_local_row.avatar_local_col.AVATAR_NAME}"/></td>
<!-- END avatar_local_col -->
</tr>
<tr>
<!-- BEGIN avatar_local_option -->
<td class="row2" style="text-align: center;"><input type="radio" name="avatar_local_file" id="av-{avatar_local_row.S_ROW_COUNT}-{avatar_local_row.avatar_local_option.S_ROW_COUNT}" value="{avatar_local_row.avatar_local_option.AVATAR_FILE}" /></td>
<!-- END avatar_local_option -->
</tr>
<!-- END avatar_local_row -->
</table>
<!-- ENDIF -->

View file

@ -0,0 +1,11 @@
<dl>
<dt><label for="avatar_remote_url">{L_LINK_REMOTE_AVATAR}{L_COLON}</label><br /><span>{L_LINK_REMOTE_AVATAR_EXPLAIN}</span></dt>
<dd><input type="text" name="avatar_remote_url" id="avatar_remote_url" value="{AVATAR_REMOTE_URL}" class="inputbox" /></dd>
</dl>
<dl>
<dt><label for="avatar_remote_width">{L_LINK_REMOTE_SIZE}{L_COLON}</label><br /><span>{L_LINK_REMOTE_SIZE_EXPLAIN}</span></dt>
<dd>
<input type="text" name="avatar_remote_width" id="avatar_remote_width" size="3" value="{AVATAR_REMOTE_WIDTH}" class="inputbox autowidth" /> {L_PIXEL} &times;&nbsp;
<input type="text" name="avatar_remote_height" id="avatar_remote_height" size="3" value="{AVATAR_REMOTE_HEIGHT}" class="inputbox autowidth" /> {L_PIXEL}
</dd>
</dl>

View file

@ -0,0 +1,11 @@
<dl>
<dt><label for="avatar_upload_file">{L_UPLOAD_AVATAR_FILE}{L_COLON}</label></dt>
<dd><input type="hidden" name="MAX_FILE_SIZE" value="{AVATAR_UPLOAD_SIZE}" /><input type="file" name="avatar_upload_file" id="avatar_upload_file" class="inputbox autowidth" /></dd>
</dl>
<!-- IF S_UPLOAD_AVATAR_URL -->
<dl>
<dt><label for="avatar_upload_url">{L_UPLOAD_AVATAR_URL}{L_COLON}</label><br /><span>{L_UPLOAD_AVATAR_URL_EXPLAIN}</span></dt>
<dd><input type="text" name="avatar_upload_url" id="avatar_upload_url" value="" class="inputbox" /></dd>
</dl>
<!-- ENDIF -->

View file

@ -7,7 +7,13 @@
<p>{L_EXTENSIONS_EXPLAIN}</p> <p>{L_EXTENSIONS_EXPLAIN}</p>
<p>{L_ENABLE_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"> <div class="errorbox">
<p>{L_ENABLE_CONFIRM}</p> <p>{L_ENABLE_CONFIRM}</p>
</div> </div>

View file

@ -7,7 +7,13 @@
<p>{L_EXTENSIONS_EXPLAIN}</p> <p>{L_EXTENSIONS_EXPLAIN}</p>
<p>{L_PURGE_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"> <div class="errorbox">
<p>{L_PURGE_CONFIRM}</p> <p>{L_PURGE_CONFIRM}</p>
</div> </div>

View file

@ -241,6 +241,7 @@
<dt><label for="topics_per_page">{L_FORUM_TOPICS_PAGE}{L_COLON}</label><br /><span>{L_FORUM_TOPICS_PAGE_EXPLAIN}</span></dt> <dt><label for="topics_per_page">{L_FORUM_TOPICS_PAGE}{L_COLON}</label><br /><span>{L_FORUM_TOPICS_PAGE_EXPLAIN}</span></dt>
<dd><input type="text" id="topics_per_page" name="topics_per_page" value="{TOPICS_PER_PAGE}" size="4" maxlength="4" /></dd> <dd><input type="text" id="topics_per_page" name="topics_per_page" value="{TOPICS_PER_PAGE}" size="4" maxlength="4" /></dd>
</dl> </dl>
<!-- EVENT acp_forums_normal_settings_append -->
</fieldset> </fieldset>
<fieldset> <fieldset>

View file

@ -17,7 +17,7 @@
</div> </div>
<!-- ENDIF --> <!-- ENDIF -->
<form id="settings" method="post" action="{U_ACTION}"<!-- IF S_CAN_UPLOAD --> enctype="multipart/form-data"<!-- ENDIF -->> <form id="settings" method="post" action="{U_ACTION}" enctype="multipart/form-data">
<fieldset> <fieldset>
<legend>{L_GROUP_DETAILS}</legend> <legend>{L_GROUP_DETAILS}</legend>
@ -104,66 +104,26 @@
<legend>{L_GROUP_AVATAR}</legend> <legend>{L_GROUP_AVATAR}</legend>
<dl> <dl>
<dt><label>{L_CURRENT_IMAGE}{L_COLON}</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt> <dt><label>{L_CURRENT_IMAGE}{L_COLON}</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt>
<dd>{AVATAR_IMAGE}</dd> <dd>{AVATAR}</dd>
<dd><label><input type="checkbox" class="radio" name="delete" /> {L_DELETE_AVATAR}</label></dd> <dd><label for="avatar_delete"><input type="checkbox" name="avatar_delete" id="avatar_delete" /> {L_DELETE_AVATAR}</label></dd>
</dl>
<!-- IF not S_IN_AVATAR_GALLERY -->
<!-- IF S_CAN_UPLOAD -->
<dl>
<dt><label for="uploadfile">{L_UPLOAD_AVATAR_FILE}{L_COLON}</label></dt>
<dd><input type="file" id="uploadfile" name="uploadfile" /></dd>
</dl> </dl>
<dl> <dl>
<dt><label for="uploadurl">{L_UPLOAD_AVATAR_URL}{L_COLON}</label><br /><span>{L_UPLOAD_AVATAR_URL_EXPLAIN}</span></dt> <dt><label>{L_AVATAR_TYPE}{L_COLON}</label></dt>
<dd><input name="uploadurl" type="text" id="uploadurl" value="" /></dd> <dd><select name="avatar_driver" id="avatar_driver">
<option value="">{L_NO_AVATAR_CATEGORY}</option>
<!-- BEGIN avatar_drivers -->
<option value="{avatar_drivers.DRIVER}"<!-- IF avatar_drivers.SELECTED --> selected="selected"<!-- ENDIF -->>{avatar_drivers.L_TITLE}</option>
<!-- END avatar_drivers -->
</select></dd>
</dl> </dl>
<!-- ENDIF --> <div id="avatar_options">
<dl> <!-- BEGIN avatar_drivers -->
<dt><label for="remotelink">{L_LINK_REMOTE_AVATAR}{L_COLON}</label><br /><span>{L_LINK_REMOTE_AVATAR_EXPLAIN}</span></dt> <div id="avatar_option_{avatar_drivers.DRIVER}">
<dd><input name="remotelink" type="text" id="remotelink" value="" /></dd> <p>{avatar_drivers.L_EXPLAIN}</p>
</dl> {avatar_drivers.OUTPUT}
<dl> </div>
<dt><label for="width">{L_LINK_REMOTE_SIZE}{L_COLON}</label><br /><span>{L_LINK_REMOTE_SIZE_EXPLAIN}</span></dt> <!-- END avatar_drivers -->
<dd><input name="width" type="text" id="width" size="3" value="{AVATAR_WIDTH}" /> <span>{L_PIXEL} &times; </span> <input type="text" name="height" size="3" value="{AVATAR_HEIGHT}" /> <span>{L_PIXEL}</span></dd> </div>
</dl>
<!-- IF S_DISPLAY_GALLERY -->
<dl>
<dt><label>{L_AVATAR_GALLERY}{L_COLON}</label></dt>
<dd><input class="button2" type="submit" name="display_gallery" value="{L_DISPLAY_GALLERY}" /></dd>
</dl>
<!-- ENDIF -->
<!-- ELSE -->
</fieldset>
<fieldset>
<legend>{L_AVATAR_GALLERY}</legend>
<dl>
<dt><label for="category">{L_AVATAR_CATEGORY}{L_COLON}</label></dt>
<dd><select name="category" id="category">{S_CAT_OPTIONS}</select>&nbsp;<input class="button2" type="submit" value="{L_GO}" name="display_gallery" /></dd>
</dl>
<dl>
<table cellspacing="1">
<!-- BEGIN avatar_row -->
<tr>
<!-- BEGIN avatar_column -->
<td class="row1" style="text-align: center;"><img src="{avatar_row.avatar_column.AVATAR_IMAGE}" alt="{avatar_row.avatar_column.AVATAR_NAME}" title="{avatar_row.avatar_column.AVATAR_NAME}" /></td>
<!-- END avatar_column -->
</tr>
<tr>
<!-- BEGIN avatar_option_column -->
<td class="row2" style="text-align: center;"><input type="radio" class="radio" name="avatar_select" value="{avatar_row.avatar_option_column.S_OPTIONS_AVATAR}" /></td>
<!-- END avatar_option_column -->
</tr>
<!-- END avatar_row -->
</table>
</dl>
</fieldset>
<fieldset class="quick" style="margin-top: -15px;">
<input class="button2" type="submit" name="cancel" value="{L_CANCEL}" />
</fieldset>
<!-- ENDIF -->
</fieldset> </fieldset>
<fieldset class="submit-buttons"> <fieldset class="submit-buttons">
@ -174,6 +134,8 @@
</fieldset> </fieldset>
</form> </form>
<!-- INCLUDEJS avatars.js -->
<!-- ELSEIF S_LIST --> <!-- ELSEIF S_LIST -->
<a href="{U_BACK}" style="float: {S_CONTENT_FLOW_END};">&laquo; {L_BACK}</a> <a href="{U_BACK}" style="float: {S_CONTENT_FLOW_END};">&laquo; {L_BACK}</a>

View file

@ -17,8 +17,8 @@
</dl> </dl>
<p class="submit-buttons"> <p class="submit-buttons">
<input class="button1" type="submit" id="submit" name="update" value="{L_SUBMIT}" />&nbsp; <input class="button1" type="submit" name="update" value="{L_SUBMIT}" />&nbsp;
<input class="button2" type="reset" id="reset" name="reset" value="{L_RESET}" /> <input class="button2" type="reset" name="reset" value="{L_RESET}" />
<input type="hidden" name="action" value="set_config_legend" /> <input type="hidden" name="action" value="set_config_legend" />
{S_FORM_TOKEN} {S_FORM_TOKEN}
</p> </p>
@ -38,22 +38,22 @@
</thead> </thead>
<tbody> <tbody>
<!-- BEGIN legend --> <!-- BEGIN legend -->
<tr> <tr data-down="{legend.U_MOVE_DOWN}" data-up="{legend.U_MOVE_UP}">
<td><strong{legend.GROUP_COLOUR}>{legend.GROUP_NAME}</strong></td> <td><strong<!-- IF legend.GROUP_COLOUR --> style="color: {legend.GROUP_COLOUR}"<!-- ENDIF -->>{legend.GROUP_NAME}</strong></td>
<td style="text-align: center;">{legend.GROUP_TYPE}</td> <td style="text-align: center;">{legend.GROUP_TYPE}</td>
<td style="vertical-align: top; width: 100px; text-align: right; white-space: nowrap;"> <td style="vertical-align: top; width: 100px; text-align: right; white-space: nowrap;">
<!-- IF legend.S_FIRST_ROW && not legend.S_LAST_ROW --> <!-- IF legend.S_FIRST_ROW && not legend.S_LAST_ROW -->
{ICON_MOVE_UP_DISABLED} <span class="up">{ICON_MOVE_UP_DISABLED}</span>
<a href="{legend.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> <span class="down"><a href="{legend.U_MOVE_DOWN}" data-ajax="row_down" data-overlay="false">{ICON_MOVE_DOWN}</a></span>
<!-- ELSEIF not legend.S_FIRST_ROW && not legend.S_LAST_ROW --> <!-- ELSEIF not legend.S_FIRST_ROW && not legend.S_LAST_ROW -->
<a href="{legend.U_MOVE_UP}">{ICON_MOVE_UP}</a> <span class="up"><a href="{legend.U_MOVE_UP}" data-ajax="row_up" data-overlay="false">{ICON_MOVE_UP}</a></span>
<a href="{legend.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> <span class="down"><a href="{legend.U_MOVE_DOWN}" data-ajax="row_down" data-overlay="false">{ICON_MOVE_DOWN}</a></span>
<!-- ELSEIF legend.S_LAST_ROW && not legend.S_FIRST_ROW --> <!-- ELSEIF legend.S_LAST_ROW && not legend.S_FIRST_ROW -->
<a href="{legend.U_MOVE_UP}">{ICON_MOVE_UP}</a> <span class="up"><a href="{legend.U_MOVE_UP}" data-ajax="row_up" data-overlay="false">{ICON_MOVE_UP}</a></span>
{ICON_MOVE_DOWN_DISABLED} <span class="down">{ICON_MOVE_DOWN_DISABLED}</span>
<!-- ELSE --> <!-- ELSE -->
{ICON_MOVE_UP_DISABLED} <span class="up">{ICON_MOVE_UP_DISABLED}</span>
{ICON_MOVE_DOWN_DISABLED} <span class="down">{ICON_MOVE_DOWN_DISABLED}</span>
<!-- ENDIF --> <!-- ENDIF -->
<a href="{legend.U_DELETE}">{ICON_DELETE}</a> <a href="{legend.U_DELETE}">{ICON_DELETE}</a>
</td> </td>
@ -66,9 +66,14 @@
</tbody> </tbody>
</table> </table>
<form id="acp_groups" method="post" action="{U_ACTION_LEGEND}"> <form id="legend_add_group" method="post" action="{U_ACTION_LEGEND}">
<fieldset class="quick"> <fieldset class="quick">
<select name="g"><option value="0">{L_SELECT_GROUP}</option>{S_GROUP_SELECT_LEGEND}</select> <select name="g">
<option value="0">{L_SELECT_GROUP}</option>
<!-- BEGIN add_legend -->
<option<!-- IF add_legend.GROUP_SPECIAL --> class="sep"<!-- ENDIF --> value="{add_legend.GROUP_ID}">{add_legend.GROUP_NAME}</option>
<!-- END add_legend -->
</select>
<input class="button2" type="submit" name="submit" value="{L_ADD}" /> <input class="button2" type="submit" name="submit" value="{L_ADD}" />
<input type="hidden" name="action" value="add" /> <input type="hidden" name="action" value="add" />
{S_FORM_TOKEN} {S_FORM_TOKEN}
@ -82,7 +87,7 @@
<fieldset> <fieldset>
<legend>{L_TEAMPAGE_SETTINGS}</legend> <legend>{L_TEAMPAGE_SETTINGS}</legend>
<dl> <dl>
<dt><label for="teampage_multiple">{L_TEAMPAGE_MEMBERSHIPS}{L_COLON}</label></dt> <dt><label for="teampage_memberships">{L_TEAMPAGE_MEMBERSHIPS}{L_COLON}</label></dt>
<dd> <dd>
<label><input type="radio" name="teampage_memberships" class="radio" value="0"<!-- IF DISPLAY_MEMBERSHIPS == 0 --> checked="checked"<!-- ENDIF --> /> {L_TEAMPAGE_DISP_FIRST}</label><br /> <label><input type="radio" name="teampage_memberships" class="radio" value="0"<!-- IF DISPLAY_MEMBERSHIPS == 0 --> checked="checked"<!-- ENDIF --> /> {L_TEAMPAGE_DISP_FIRST}</label><br />
<label><input type="radio" name="teampage_memberships" class="radio" value="1"<!-- IF DISPLAY_MEMBERSHIPS == 1 --> checked="checked"<!-- ENDIF --> /> {L_TEAMPAGE_DISP_DEFAULT}</label><br /> <label><input type="radio" name="teampage_memberships" class="radio" value="1"<!-- IF DISPLAY_MEMBERSHIPS == 1 --> checked="checked"<!-- ENDIF --> /> {L_TEAMPAGE_DISP_DEFAULT}</label><br />
@ -98,8 +103,8 @@
</dl> </dl>
<p class="submit-buttons"> <p class="submit-buttons">
<input class="button1" type="submit" id="submit" name="update" value="{L_SUBMIT}" />&nbsp; <input class="button1" type="submit" name="update" value="{L_SUBMIT}" />&nbsp;
<input class="button2" type="reset" id="reset" name="reset" value="{L_RESET}" /> <input class="button2" type="reset" name="reset" value="{L_RESET}" />
<input type="hidden" name="action" value="set_config_teampage" /> <input type="hidden" name="action" value="set_config_teampage" />
{S_FORM_TOKEN} {S_FORM_TOKEN}
</p> </p>
@ -108,6 +113,8 @@
<p>{L_TEAMPAGE_EXPLAIN}</p> <p>{L_TEAMPAGE_EXPLAIN}</p>
<!-- IF S_TEAMPAGE_CATEGORY and CURRENT_CATEGORY_NAME --><p><strong><a href="{U_ACTION}">{L_TEAMPAGE}</a> &raquo; {CURRENT_CATEGORY_NAME}</strong></p><!-- ENDIF -->
<table cellspacing="1"> <table cellspacing="1">
<col class="col1" /><col class="col2" /><col class="col2" /> <col class="col1" /><col class="col2" /><col class="col2" />
<thead> <thead>
@ -119,22 +126,29 @@
</thead> </thead>
<tbody> <tbody>
<!-- BEGIN teampage --> <!-- BEGIN teampage -->
<tr> <tr data-down="{teampage.U_MOVE_DOWN}" data-up="{teampage.U_MOVE_UP}">
<td><strong{teampage.GROUP_COLOUR}>{teampage.GROUP_NAME}</strong></td> <td>
<td style="text-align: center;">{teampage.GROUP_TYPE}</td> <!-- IF teampage.U_CATEGORY -->
<a href="{teampage.U_CATEGORY}">{teampage.GROUP_NAME}</a>
<!-- ELSE -->
<strong<!-- IF teampage.GROUP_COLOUR --> style="color: {teampage.GROUP_COLOUR}"<!-- ENDIF -->>{teampage.GROUP_NAME}</strong>
<!-- ENDIF -->
</td>
<td style="text-align: center;"><!-- IF teampage.GROUP_TYPE -->{teampage.GROUP_TYPE}<!-- ELSE -->-<!-- ENDIF -->
</td></td>
<td style="vertical-align: top; width: 100px; text-align: right; white-space: nowrap;"> <td style="vertical-align: top; width: 100px; text-align: right; white-space: nowrap;">
<!-- IF teampage.S_FIRST_ROW && not teampage.S_LAST_ROW --> <!-- IF teampage.S_FIRST_ROW && not teampage.S_LAST_ROW -->
{ICON_MOVE_UP_DISABLED} <span class="up">{ICON_MOVE_UP_DISABLED}</span>
<a href="{teampage.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> <span class="down"><a href="{teampage.U_MOVE_DOWN}" data-ajax="row_down" data-overlay="false">{ICON_MOVE_DOWN}</a></span>
<!-- ELSEIF not teampage.S_FIRST_ROW && not teampage.S_LAST_ROW --> <!-- ELSEIF not teampage.S_FIRST_ROW && not teampage.S_LAST_ROW -->
<a href="{teampage.U_MOVE_UP}">{ICON_MOVE_UP}</a> <span class="up"><a href="{teampage.U_MOVE_UP}" data-ajax="row_up" data-overlay="false">{ICON_MOVE_UP}</a></span>
<a href="{teampage.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> <span class="down"><a href="{teampage.U_MOVE_DOWN}" data-ajax="row_down" data-overlay="false">{ICON_MOVE_DOWN}</a></span>
<!-- ELSEIF teampage.S_LAST_ROW && not teampage.S_FIRST_ROW --> <!-- ELSEIF teampage.S_LAST_ROW && not teampage.S_FIRST_ROW -->
<a href="{teampage.U_MOVE_UP}">{ICON_MOVE_UP}</a> <span class="up"><a href="{teampage.U_MOVE_UP}" data-ajax="row_up" data-overlay="false">{ICON_MOVE_UP}</a></span>
{ICON_MOVE_DOWN_DISABLED} <span class="down">{ICON_MOVE_DOWN_DISABLED}</span>
<!-- ELSE --> <!-- ELSE -->
{ICON_MOVE_UP_DISABLED} <span class="up">{ICON_MOVE_UP_DISABLED}</span>
{ICON_MOVE_DOWN_DISABLED} <span class="down">{ICON_MOVE_DOWN_DISABLED}</span>
<!-- ENDIF --> <!-- ENDIF -->
<a href="{teampage.U_DELETE}">{ICON_DELETE}</a> <a href="{teampage.U_DELETE}">{ICON_DELETE}</a>
</td> </td>
@ -147,13 +161,37 @@
</tbody> </tbody>
</table> </table>
<form id="acp_groups" method="post" action="{U_ACTION_TEAMPAGE}"> <!-- IF not S_TEAMPAGE_CATEGORY -->
<form id="teampage_add_category" method="post" action="{U_ACTION_TEAMPAGE}">
<fieldset class="quick"> <fieldset class="quick">
<select name="g"><option value="0">{L_SELECT_GROUP}</option>{S_GROUP_SELECT_TEAMPAGE}</select> <input class="inputbox autowidth" type="text" maxlength="255" name="category_name" placeholder="{L_GROUP_CATEGORY_NAME}" />
<input class="button2" type="submit" name="submit" value="{L_ADD_GROUP_CATEGORY}" />
<input type="hidden" name="action" value="add_category" />
{S_FORM_TOKEN}
</fieldset>
</form>
<!-- ENDIF -->
<form id="teampage_add_group" method="post" action="{U_ACTION_TEAMPAGE}">
<fieldset class="quick">
<select name="g">
<option value="0">{L_SELECT_GROUP}</option>
<!-- BEGIN add_teampage -->
<option<!-- IF add_teampage.GROUP_SPECIAL --> class="sep"<!-- ENDIF --> value="{add_teampage.GROUP_ID}">{add_teampage.GROUP_NAME}</option>
<!-- END add_teampage -->
</select>
<input class="button2" type="submit" name="submit" value="{L_ADD}" /> <input class="button2" type="submit" name="submit" value="{L_ADD}" />
<input type="hidden" name="action" value="add" /> <input type="hidden" name="action" value="add" />
{S_FORM_TOKEN} {S_FORM_TOKEN}
</fieldset> </fieldset>
</form> </form>
<div class="hidden">
<a class="template-up-img" href="#">{ICON_MOVE_UP}</a>
<span class="template-up-img-disabled">{ICON_MOVE_UP_DISABLED}</span>
<a class="template-down-img" href="#">{ICON_MOVE_DOWN}</a>
<span class="template-down-img-disabled">{ICON_MOVE_DOWN_DISABLED}</span>
</div>
<!-- INCLUDE overall_footer.html --> <!-- INCLUDE overall_footer.html -->

View file

@ -76,6 +76,8 @@
</div> </div>
<!-- ENDIF --> <!-- ENDIF -->
<!-- EVENT acp_main_notice_after -->
<table cellspacing="1"> <table cellspacing="1">
<caption>{L_FORUM_STATS}</caption> <caption>{L_FORUM_STATS}</caption>
<col class="col1" /><col class="col2" /><col class="col1" /><col class="col2" /> <col class="col1" /><col class="col2" /><col class="col1" /><col class="col2" />
@ -202,6 +204,8 @@
<dd><input type="hidden" name="action" value="purge_cache" /><input class="button2" type="submit" id="action_purge_cache" name="action_purge_cache" value="{L_RUN}" /></dd> <dd><input type="hidden" name="action" value="purge_cache" /><input class="button2" type="submit" id="action_purge_cache" name="action_purge_cache" value="{L_RUN}" /></dd>
</dl> </dl>
</form> </form>
<!-- EVENT acp_main_actions_append -->
</fieldset> </fieldset>
<!-- ENDIF --> <!-- ENDIF -->

View file

@ -1,78 +1,39 @@
<form id="avatar_settings" method="post" action="{U_ACTION}"<!-- IF S_CAN_UPLOAD --> enctype="multipart/form-data"<!-- ENDIF -->> <form id="avatar_settings" method="post" action="{U_ACTION}" enctype="multipart/form-data">
<fieldset> <fieldset>
<legend>{L_ACP_USER_AVATAR}</legend> <legend>{L_ACP_USER_AVATAR}</legend>
<!-- IF ERROR --><p class="error">{ERROR}</p><!-- ENDIF -->
<dl> <dl>
<dt><label>{L_CURRENT_IMAGE}{L_COLON}</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt> <dt><label>{L_CURRENT_IMAGE}{L_COLON}</label><br /><span>{L_AVATAR_EXPLAIN}</span></dt>
<dd>{AVATAR_IMAGE}</dd> <dd>{AVATAR}</dd>
<dd><label><input type="checkbox" class="radio" name="delete" /> {L_DELETE_AVATAR}</label></dd> <dd><label for="avatar_delete"><input type="checkbox" name="avatar_delete" id="avatar_delete" /> {L_DELETE_AVATAR}</label></dd>
</dl> </dl>
<!-- IF not S_IN_AVATAR_GALLERY -->
<!-- IF S_UPLOAD_FILE -->
<dl>
<dt><label for="uploadfile">{L_UPLOAD_AVATAR_FILE}{L_COLON}</label></dt>
<dd><input type="hidden" name="MAX_FILE_SIZE" value="{AVATAR_MAX_FILESIZE}" /><input type="file" id="uploadfile" name="uploadfile" /></dd>
</dl>
<!-- ENDIF -->
<!-- IF S_REMOTE_UPLOAD -->
<dl>
<dt><label for="uploadurl">{L_UPLOAD_AVATAR_URL}{L_COLON}</label><br /><span>{L_UPLOAD_AVATAR_URL_EXPLAIN}</span></dt>
<dd><input name="uploadurl" type="text" id="uploadurl" value="" /></dd>
</dl>
<!-- ENDIF -->
<!-- IF S_ALLOW_REMOTE -->
<dl>
<dt><label for="remotelink">{L_LINK_REMOTE_AVATAR}{L_COLON}</label><br /><span>{L_LINK_REMOTE_AVATAR_EXPLAIN}</span></dt>
<dd><input name="remotelink" type="text" id="remotelink" value="" /></dd>
</dl>
<dl>
<dt><label for="width">{L_LINK_REMOTE_SIZE}{L_COLON}</label><br /><span>{L_LINK_REMOTE_SIZE_EXPLAIN}</span></dt>
<dd><input name="width" type="text" id="width" size="3" value="{USER_AVATAR_WIDTH}" /> <span>{L_PIXEL} &times; </span> <input type="text" name="height" size="3" value="{USER_AVATAR_HEIGHT}" /> <span>{L_PIXEL}</span></dd>
</dl>
<!-- ENDIF -->
<!-- IF S_DISPLAY_GALLERY -->
<dl>
<dt><label>{L_AVATAR_GALLERY}{L_COLON}</label></dt>
<dd><input class="button2" type="submit" name="display_gallery" value="{L_DISPLAY_GALLERY}" /></dd>
</dl>
<!-- ENDIF -->
<!-- ELSE -->
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend>{L_AVATAR_GALLERY}</legend> <legend>{L_AVATAR_SELECT}</legend>
<dl> <dl>
<dt><label for="category">{L_AVATAR_CATEGORY}{L_COLON}</label></dt> <dt><label>{L_AVATAR_TYPE}</label></dt>
<dd><select name="category" id="category">{S_CAT_OPTIONS}</select>&nbsp;<input class="button2" type="submit" value="{L_GO}" name="display_gallery" /></dd> <dd><select name="avatar_driver" id="avatar_driver">
<option value="">{L_NO_AVATAR_CATEGORY}</option>
<!-- BEGIN avatar_drivers -->
<option value="{avatar_drivers.DRIVER}"<!-- IF avatar_drivers.SELECTED --> selected="selected"<!-- ENDIF -->>{avatar_drivers.L_TITLE}</option>
<!-- END avatar_drivers -->
</select></dd>
</dl> </dl>
<dl> <div id="avatar_options">
<table cellspacing="1"> <!-- BEGIN avatar_drivers -->
<!-- BEGIN avatar_row --> <div id="avatar_option_{avatar_drivers.DRIVER}">
<tr> <p>{avatar_drivers.L_EXPLAIN}</p>
<!-- BEGIN avatar_column --> {avatar_drivers.OUTPUT}
<td class="row1" style="text-align: center;"><img src="{avatar_row.avatar_column.AVATAR_IMAGE}" alt="{avatar_row.avatar_column.AVATAR_NAME}" title="{avatar_row.avatar_column.AVATAR_NAME}" /></td> </div>
<!-- END avatar_column --> <!-- END avatar_drivers -->
</tr> </div>
<tr>
<!-- BEGIN avatar_option_column -->
<td class="row2" style="text-align: center;"><input type="radio" class="radio" name="avatar_select" value="{avatar_row.avatar_option_column.S_OPTIONS_AVATAR}" /></td>
<!-- END avatar_option_column -->
</tr>
<!-- END avatar_row -->
</table>
</dl>
</fieldset>
<fieldset class="quick" style="margin-top: -15px;">
<input class="button2" type="submit" name="cancel" value="{L_CANCEL}" />
</fieldset>
<!-- ENDIF -->
</fieldset> </fieldset>
<fieldset class="quick"> <fieldset class="quick">
<input class="button1" type="submit" name="update" value="{L_SUBMIT}" /> <input type="submit" name="update" value="{L_SUBMIT}" class="button1" />
{S_FORM_TOKEN} {S_FORM_TOKEN}
</fieldset> </fieldset>
</form> </form>
<!-- INCLUDEJS avatars.js -->

View file

@ -53,6 +53,7 @@
<dt><label for="password_confirm">{L_CONFIRM_PASSWORD}{L_COLON}</label><br /><span>{L_CONFIRM_PASSWORD_EXPLAIN}</span></dt> <dt><label for="password_confirm">{L_CONFIRM_PASSWORD}{L_COLON}</label><br /><span>{L_CONFIRM_PASSWORD_EXPLAIN}</span></dt>
<dd><input type="password" id="password_confirm" name="password_confirm" value="" autocomplete="off" /></dd> <dd><input type="password" id="password_confirm" name="password_confirm" value="" autocomplete="off" /></dd>
</dl> </dl>
<!-- EVENT acp_users_overview_options_append -->
<p class="quick"> <p class="quick">
<input class="button1" type="submit" name="update" value="{L_SUBMIT}" /> <input class="button1" type="submit" name="update" value="{L_SUBMIT}" />

View file

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

View file

@ -0,0 +1,15 @@
(function($) { // Avoid conflicts with other libraries
"use strict";
function avatarHide() {
$('#avatar_options > div').hide();
var selected = $('#avatar_driver').val();
$('#avatar_option_' + selected).show();
}
avatarHide();
$('#avatar_driver').bind('change', avatarHide);
})(jQuery); // Avoid conflicts with other libraries

View file

@ -5,7 +5,7 @@
<!-- IF META -->{META}<!-- ENDIF --> <!-- IF META -->{META}<!-- ENDIF -->
<title>{PAGE_TITLE}</title> <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"> <script type="text/javascript">
// <![CDATA[ // <![CDATA[

View file

@ -5,7 +5,7 @@
<!-- IF META -->{META}<!-- ENDIF --> <!-- IF META -->{META}<!-- ENDIF -->
<title>{PAGE_TITLE}</title> <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"> <script type="text/javascript">
// <![CDATA[ // <![CDATA[

View file

@ -40,5 +40,7 @@
<!-- INCLUDEJS ajax.js --> <!-- INCLUDEJS ajax.js -->
{SCRIPTS} {SCRIPTS}
<!-- EVENT acp_overall_footer_after -->
</body> </body>
</html> </html>

View file

@ -155,6 +155,7 @@ function switch_menu()
// ]]> // ]]>
</script> </script>
<!-- EVENT acp_overall_header_head_append -->
</head> </head>
<body class="{S_CONTENT_DIRECTION}"> <body class="{S_CONTENT_DIRECTION}">

View file

@ -18,6 +18,7 @@
<script type="text/javascript" src="{T_JQUERY_LINK}"></script> <script type="text/javascript" src="{T_JQUERY_LINK}"></script>
<!-- IF S_JQUERY_FALLBACK --><script type="text/javascript">window.jQuery || document.write(unescape('%3Cscript src="{T_ASSETS_PATH}/javascript/jquery.js?assets_version={T_ASSETS_VERSION}" type="text/javascript"%3E%3C/script%3E'));</script><!-- ENDIF --> <!-- IF S_JQUERY_FALLBACK --><script type="text/javascript">window.jQuery || document.write(unescape('%3Cscript src="{T_ASSETS_PATH}/javascript/jquery.js?assets_version={T_ASSETS_VERSION}" type="text/javascript"%3E%3C/script%3E'));</script><!-- ENDIF -->
<!-- EVENT acp_simple_footer_after -->
</body> </body>
</html> </html>

View file

@ -101,6 +101,7 @@ function find_username(url)
// ]]> // ]]>
</script> </script>
<!-- EVENT acp_simple_header_head_append -->
</head> </head>
<body class="{S_CONTENT_DIRECTION}"> <body class="{S_CONTENT_DIRECTION}">

View file

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

View file

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

View file

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

View file

@ -63,12 +63,17 @@ if (!defined('PHPBB_INSTALLED'))
exit; 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 // Include files
require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx);
require($phpbb_root_path . 'includes/functions_content.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
require($phpbb_root_path . 'includes/functions_container.' . $phpEx); require($phpbb_root_path . 'includes/functions_container.' . $phpEx);
include($phpbb_root_path . 'includes/functions_compatibility.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
@ -83,18 +88,7 @@ $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_pat
$phpbb_class_loader_ext->register(); $phpbb_class_loader_ext->register();
// Set up container // Set up container
$phpbb_container = phpbb_create_dumped_container_unless_debug( $phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
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_class_loader->set_cache($phpbb_container->get('cache.driver')); $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
@ -117,6 +111,8 @@ $config = $phpbb_container->get('config');
set_config(null, null, null, $config); set_config(null, null, null, $config);
set_config_count(null, null, null, $config); set_config_count(null, null, null, $config);
$phpbb_log = $phpbb_container->get('log');
// load extensions // load extensions
$phpbb_extension_manager = $phpbb_container->get('ext.manager'); $phpbb_extension_manager = $phpbb_container->get('ext.manager');
$phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader'); $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader');
@ -127,8 +123,9 @@ $phpbb_style = $phpbb_container->get('style');
// Add own hook handler // Add own hook handler
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); 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 = 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); @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
} }

55
phpBB/config/avatars.yml Normal file
View file

@ -0,0 +1,55 @@
services:
avatar.driver.gravatar:
class: phpbb_avatar_driver_gravatar
arguments:
- @config
- %core.root_path%
- .%core.php_ext%
- @cache.driver
calls:
- [set_name, [avatar.driver.gravatar]]
tags:
- { name: avatar.driver }
avatar.driver.local:
class: phpbb_avatar_driver_local
arguments:
- @config
- %core.root_path%
- .%core.php_ext%
- @cache.driver
calls:
- [set_name, [avatar.driver.local]]
tags:
- { name: avatar.driver }
avatar.driver.remote:
class: phpbb_avatar_driver_remote
arguments:
- @config
- %core.root_path%
- .%core.php_ext%
- @cache.driver
calls:
- [set_name, [avatar.driver.remote]]
tags:
- { name: avatar.driver }
avatar.driver.upload:
class: phpbb_avatar_driver_upload
arguments:
- @config
- %core.root_path%
- .%core.php_ext%
- @cache.driver
calls:
- [set_name, [avatar.driver.upload]]
tags:
- { name: avatar.driver }
avatar.driver_collection:
class: phpbb_di_service_collection
arguments:
- @service_container
tags:
- { name: service_collection, tag: avatar.driver }

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

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

View file

@ -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,15 +1,29 @@
imports: imports:
- { resource: tables.yml } - { resource: tables.yml }
- { resource: cron_tasks.yml } - { resource: cron_tasks.yml }
- { resource: notifications.yml }
- { resource: migrator.yml }
- { resource: avatars.yml }
services: services:
auth: auth:
class: phpbb_auth class: phpbb_auth
avatar.manager:
class: phpbb_avatar_manager
arguments:
- @config
- @avatar.driver_collection
- @service_container
cache: cache:
class: phpbb_cache_service class: phpbb_cache_service
arguments: arguments:
- @cache.driver - @cache.driver
- @config
- @dbal.conn
- %core.root_path%
- %core.php_ext%
cache.driver: cache.driver:
class: %cache.driver.class% class: %cache.driver.class%
@ -90,6 +104,12 @@ services:
calls: calls:
- [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]] - [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: event.subscriber_loader:
class: phpbb_event_extension_subscriber_loader class: phpbb_event_extension_subscriber_loader
arguments: arguments:
@ -101,8 +121,10 @@ services:
ext.manager: ext.manager:
class: phpbb_extension_manager class: phpbb_extension_manager
arguments: arguments:
- @service_container
- @dbal.conn - @dbal.conn
- @config - @config
- @migrator
- %tables.ext% - %tables.ext%
- %core.root_path% - %core.root_path%
- .%core.php_ext% - .%core.php_ext%
@ -117,12 +139,32 @@ services:
- .%core.php_ext% - .%core.php_ext%
- _ext_finder - _ext_finder
groupposition.legend:
class: phpbb_groupposition_legend
arguments:
- @dbal.conn
- @user
groupposition.teampage:
class: phpbb_groupposition_teampage
arguments:
- @dbal.conn
- @user
- @cache.driver
http_kernel: http_kernel:
class: Symfony\Component\HttpKernel\HttpKernel class: Symfony\Component\HttpKernel\HttpKernel
arguments: arguments:
- @dispatcher - @dispatcher
- @controller.resolver - @controller.resolver
hook_finder:
class: phpbb_hook_finder
arguments:
- %core.root_path%
- .%core.php_ext%
- @cache.driver
kernel_request_subscriber: kernel_request_subscriber:
class: phpbb_event_kernel_request_subscriber class: phpbb_event_kernel_request_subscriber
arguments: arguments:
@ -145,6 +187,33 @@ services:
tags: tags:
- { name: kernel.event_subscriber } - { name: kernel.event_subscriber }
log:
class: phpbb_log
arguments:
- @dbal.conn
- @user
- @auth
- @dispatcher
- %core.root_path%
- %core.adm_relative_path%
- %core.php_ext%
- %tables.log%
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: request:
class: phpbb_request class: phpbb_request
@ -187,3 +256,11 @@ services:
user: user:
class: phpbb_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,10 @@
parameters: parameters:
tables.config: %core.table_prefix%config tables.config: %core.table_prefix%config
tables.ext: %core.table_prefix%ext tables.ext: %core.table_prefix%ext
tables.log: %core.table_prefix%log
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

@ -1168,7 +1168,7 @@ function get_schema_struct()
'group_desc_uid' => array('VCHAR:8', ''), 'group_desc_uid' => array('VCHAR:8', ''),
'group_display' => array('BOOL', 0), 'group_display' => array('BOOL', 0),
'group_avatar' => array('VCHAR', ''), 'group_avatar' => array('VCHAR', ''),
'group_avatar_type' => array('TINT:2', 0), 'group_avatar_type' => array('VCHAR:255', ''),
'group_avatar_width' => array('USINT', 0), 'group_avatar_width' => array('USINT', 0),
'group_avatar_height' => array('USINT', 0), 'group_avatar_height' => array('USINT', 0),
'group_rank' => array('UINT', 0), 'group_rank' => array('UINT', 0),
@ -1178,7 +1178,6 @@ function get_schema_struct()
'group_message_limit' => array('UINT', 0), 'group_message_limit' => array('UINT', 0),
'group_max_recipients' => array('UINT', 0), 'group_max_recipients' => array('UINT', 0),
'group_legend' => array('UINT', 0), 'group_legend' => array('UINT', 0),
'group_teampage' => array('UINT', 0),
), ),
'PRIMARY_KEY' => 'group_id', 'PRIMARY_KEY' => 'group_id',
'KEYS' => array( 'KEYS' => array(
@ -1273,6 +1272,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( $schema_data['phpbb_modules'] = array(
'COLUMNS' => array( 'COLUMNS' => array(
'module_id' => array('UINT', NULL, 'auto_increment'), 'module_id' => array('UINT', NULL, 'auto_increment'),
@ -1295,6 +1307,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( $schema_data['phpbb_poll_options'] = array(
'COLUMNS' => array( 'COLUMNS' => array(
'poll_option_id' => array('TINT:4', 0), 'poll_option_id' => array('TINT:4', 0),
@ -1532,6 +1570,9 @@ function get_schema_struct()
'reported_post_text' => array('MTEXT_UNI', ''), 'reported_post_text' => array('MTEXT_UNI', ''),
'reported_post_uid' => array('VCHAR:8', ''), 'reported_post_uid' => array('VCHAR:8', ''),
'reported_post_bitfield' => array('VCHAR:255', ''), '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', 'PRIMARY_KEY' => 'report_id',
'KEYS' => array( 'KEYS' => array(
@ -1669,6 +1710,17 @@ function get_schema_struct()
), ),
); );
$schema_data['phpbb_teampage'] = array(
'COLUMNS' => array(
'teampage_id' => array('UINT', NULL, 'auto_increment'),
'group_id' => array('UINT', 0),
'teampage_name' => array('VCHAR_UNI:255', ''),
'teampage_position' => array('UINT', 0),
'teampage_parent' => array('UINT', 0),
),
'PRIMARY_KEY' => 'teampage_id',
);
$schema_data['phpbb_topics'] = array( $schema_data['phpbb_topics'] = array(
'COLUMNS' => array( 'COLUMNS' => array(
'topic_id' => array('UINT', NULL, 'auto_increment'), 'topic_id' => array('UINT', NULL, 'auto_increment'),
@ -1753,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( $schema_data['phpbb_user_group'] = array(
'COLUMNS' => array( 'COLUMNS' => array(
'group_id' => array('UINT', 0), 'group_id' => array('UINT', 0),
@ -1823,7 +1885,7 @@ function get_schema_struct()
'user_allow_massemail' => array('BOOL', 1), 'user_allow_massemail' => array('BOOL', 1),
'user_options' => array('UINT:11', 230271), 'user_options' => array('UINT:11', 230271),
'user_avatar' => array('VCHAR', ''), 'user_avatar' => array('VCHAR', ''),
'user_avatar_type' => array('TINT:2', 0), 'user_avatar_type' => array('VCHAR:255', ''),
'user_avatar_width' => array('USINT', 0), 'user_avatar_width' => array('USINT', 0),
'user_avatar_height' => array('USINT', 0), 'user_avatar_height' => array('USINT', 0),
'user_sig' => array('MTEXT_UNI', ''), 'user_sig' => array('MTEXT_UNI', ''),

View file

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

View file

@ -72,6 +72,7 @@
<ol style="list-style-type: lower-roman;"> <ol style="list-style-type: lower-roman;">
<li><a href="#templates">General Templating</a></li> <li><a href="#templates">General Templating</a></li>
<li><a href="#stylestree">Styles Tree</a></li> <li><a href="#stylestree">Styles Tree</a></li>
<li><a href="#template-events">Template Events</a></li>
</ol></li> </ol></li>
<li><a href="#charsets">Character Sets and Encodings</a></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> <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 parent = prosilver
</pre></div> </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>
<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div> <div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>

132
phpBB/docs/events.md Normal file
View file

@ -0,0 +1,132 @@
acp_forums_normal_settings_append
===
* Location: adm/style/acp_forums.html
* Purpose: Add settings to forums
acp_main_actions_append
===
* Location: adm/style/acp_main.html
* Purpose: Add actions to the ACP main page below the cache purge action
acp_main_notice_after
===
* Location: adm/style/acp_main.html
* Purpose: Add notices or other blocks in the ACP below other configuration notices
acp_overall_footer_after
===
* Location: adm/style/overall_footer.html
* Purpose: Add content below the footer in the ACP
acp_overall_header_head_append
===
* Location: adm/style/overall_header.html
* Add assets within the `<head>` tags in the ACP
acp_simple_footer_after
===
* Location: adm/style/simple_footer.html
* Purpose: Add content below the simple footer in the ACP
acp_simple_header_head_append
===
* Location: adm/style/overall_header.html
* Add assets within the `<head>` tags in the simple header of the ACP
acp_users_overview_options_append
===
* Location: adm/style/acp_users.html
* Purpose: Add options and settings on user overview page
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.
index_body_stat_blocks_before
===
* Locations:
+ styles/prosilver/template/index_body.html
+ styles/subsilver2/template/index_body.html
* Purpose: Add new statistic blocks above the Who Is Online and Board Statistics blocks
overall_footer_after
===
* Locations:
+ styles/prosilver/template/overall_footer.html
+ styles/subsilver2/template/overall_footer.html
* Purpose: Add content at the end of the file, directly prior to the `</body>` tag
overall_footer_breadcrumb_append
===
* Location: styles/prosilver/template/overall_footer.html
* Purpose: Add links to the list of breadcrumbs in the footer
overall_footer_copyright_append
===
* Locations:
+ styles/prosilver/template/overall_footer.html
+ styles/subsilver2/template/overall_footer.html
* Purpose: Add content after the copyright line (no new line by default), before the ACP link
overall_footer_copyright_prepend
===
* Locations:
+ styles/prosilver/template/overall_footer.html
+ styles/subsilver2/template/overall_footer.html
* Purpose: Add content before the copyright line
overall_header_breadcrumb_append
===
* Locations:
+ styles/prosilver/template/overall_header.html
+ styles/subsilver2/template/breadcrumbs.html
* Purpose: Add links to the list of breadcrumbs in the header
overall_header_head_append
===
* Locations:
+ styles/prosilver/template/overall_header.html
+ styles/subsilver2/template/overall_header.html
* Purpose: Add asset calls directly before the `</head>` tag
overall_header_navigation_append
===
* Location: styles/prosilver/template/overall_header.html
* Purpose: Add links after the navigation links in the header
overall_header_navigation_prepend
===
* Location: styles/prosilver/template/overall_header.html
* Purpose: Add links before the navigation links in the header
posting_editor_options_prepend
===
* Locations:
+ styles/prosilver/template/posting_editor.html
+ styles/prosilver/template/posting_body.html
* Purpose: Add posting options on the posting screen
simple_footer_after
===
* Location: styles/prosilver/template/simple_footer.html
* Purpose: Add content directly prior to the `</body>` tag of the simple footer
ucp_pm_viewmessage_print_head_append
===
* Location: styles/prosilver/template/ucp_pm_viewmessage_print.html
* Purpose: Add asset calls directly before the `</head>` tag of the Print PM screen
viewtopic_print_head_append
===
* Location: styles/prosilver/template/viewtopic_print.html
* Purpose: Add asset calls directly before the `</head>` tag of the Print Topic screen
viewtopic_topic_title_prepend
===
* Locations:
+ styles/prosilver/template/viewtopic_body.html
+ styles/subsilver2/template/viewtopic_body.html
* Purpose: Add content directly before the topic title link on the View topic screen

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_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_query_range = SELECT MIN(post_id), MAX(post_id) FROM phpbb_posts
sql_range_step = 5000 sql_range_step = 5000
sql_query = SELECT \ sql_query = SELECT
p.post_id AS id, \ \
p.forum_id, \ p.post_id AS id,
p.topic_id, \ \
p.poster_id, \ p.forum_id,
CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, \ \
p.post_time, \ p.topic_id,
p.post_subject, \ \
p.post_subject as title, \ p.poster_id,
p.post_text as data, \ \
t.topic_last_post_time, \ CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post,
0 as deleted \ \
FROM phpbb_posts p, phpbb_topics t \ p.post_time,
WHERE \ \
p.topic_id = t.topic_id \ 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 AND p.post_id >= $start AND p.post_id <= $end
sql_query_post = sql_query_post =
sql_query_post_index = UPDATE phpbb_sphinx SET max_doc_id = $maxid WHERE counter_id = 1 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_query_range =
sql_range_step = sql_range_step =
sql_query = SELECT \ sql_query = SELECT
p.post_id AS id, \ \
p.forum_id, \ p.post_id AS id,
p.topic_id, \ \
p.poster_id, \ p.forum_id,
CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, \ \
p.post_time, \ p.topic_id,
p.post_subject, \ \
p.post_subject as title, \ p.poster_id,
p.post_text as data, \ \
t.topic_last_post_time, \ CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post,
0 as deleted \ \
FROM phpbb_posts p, phpbb_topics t \ p.post_time,
WHERE \ \
p.topic_id = t.topic_id \ 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 ) AND p.post_id >= ( SELECT max_doc_id FROM phpbb_sphinx WHERE counter_id=1 )
sql_query_pre = sql_query_pre =
} }

View file

@ -56,18 +56,7 @@ if (isset($_GET['avatar']))
$phpbb_class_loader_ext->register(); $phpbb_class_loader_ext->register();
// Set up container // Set up container
$phpbb_container = phpbb_create_dumped_container_unless_debug( $phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
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_class_loader->set_cache($phpbb_container->get('cache.driver')); $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
@ -78,6 +67,7 @@ if (isset($_GET['avatar']))
$phpbb_dispatcher = $phpbb_container->get('dispatcher'); $phpbb_dispatcher = $phpbb_container->get('dispatcher');
$request = $phpbb_container->get('request'); $request = $phpbb_container->get('request');
$db = $phpbb_container->get('dbal.conn'); $db = $phpbb_container->get('dbal.conn');
$phpbb_log = $phpbb_container->get('log');
// Connect to DB // Connect to DB
if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false)) if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false))
@ -99,6 +89,8 @@ if (isset($_GET['avatar']))
// worst-case default // worst-case default
$browser = strtolower($request->header('User-Agent', 'msie 6.0')); $browser = strtolower($request->header('User-Agent', 'msie 6.0'));
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
$filename = request_var('avatar', ''); $filename = request_var('avatar', '');
$avatar_group = false; $avatar_group = false;
$exit = false; $exit = false;

View file

@ -28,7 +28,7 @@ class acp_board
{ {
global $db, $user, $auth, $template; global $db, $user, $auth, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
global $cache; global $cache, $phpbb_container;
$user->add_lang('acp/board'); $user->add_lang('acp/board');
@ -107,6 +107,23 @@ class acp_board
break; break;
case 'avatar': case 'avatar':
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
$avatar_drivers = $phpbb_avatar_manager->get_all_drivers();
$avatar_vars = array();
foreach ($avatar_drivers as $current_driver)
{
$driver = $phpbb_avatar_manager->get_driver($current_driver, false);
/*
* First grab the settings for enabling/disabling the avatar
* driver and afterwards grab additional settings the driver
* might have.
*/
$avatar_vars += $phpbb_avatar_manager->get_avatar_settings($driver);
$avatar_vars += $driver->prepare_form_acp($user);
}
$display_vars = array( $display_vars = array(
'title' => 'ACP_AVATAR_SETTINGS', 'title' => 'ACP_AVATAR_SETTINGS',
'vars' => array( 'vars' => array(
@ -118,17 +135,15 @@ class acp_board
'avatar_max_height' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), 'avatar_max_height' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false),
'allow_avatar' => array('lang' => 'ALLOW_AVATARS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'allow_avatar' => array('lang' => 'ALLOW_AVATARS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'allow_avatar_local' => array('lang' => 'ALLOW_LOCAL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'allow_avatar_remote' => array('lang' => 'ALLOW_REMOTE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'allow_avatar_upload' => array('lang' => 'ALLOW_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'allow_avatar_remote_upload'=> array('lang' => 'ALLOW_REMOTE_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'avatar_filesize' => array('lang' => 'MAX_FILESIZE', 'validate' => 'int:0', 'type' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']),
'avatar_min' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'avatar_min' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
'avatar_max' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'avatar_max' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
'avatar_path' => array('lang' => 'AVATAR_STORAGE_PATH', 'validate' => 'rwpath', 'type' => 'text:20:255', 'explain' => true),
'avatar_gallery_path' => array('lang' => 'AVATAR_GALLERY_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true),
) )
); );
if (!empty($avatar_vars))
{
$display_vars['vars'] += $avatar_vars;
}
break; break;
case 'message': case 'message':
@ -314,6 +329,7 @@ class acp_board
'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'validate' => 'int:0', 'type' => 'text:4:3', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']), 'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'validate' => 'int:0', 'type' => 'text:4:3', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
'legend2' => 'GENERAL_OPTIONS', '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_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_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), 'load_anon_lastread' => array('lang' => 'YES_ANON_READ_MARKING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
@ -413,8 +429,8 @@ class acp_board
'board_email_form' => array('lang' => 'BOARD_EMAIL_FORM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), '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_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), '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_contact' => array('lang' => 'CONTACT_EMAIL', 'validate' => 'email', 'type' => 'text:25:100', 'explain' => true),
'board_email' => array('lang' => 'ADMIN_EMAIL', 'validate' => 'string', '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_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), '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->template = $template;
$this->user = $user; $this->user = $user;
$user->add_lang(array('install', 'acp/extensions')); $user->add_lang(array('install', 'acp/extensions', 'migrator'));
$this->page_title = 'ACP_EXTENSIONS'; $this->page_title = 'ACP_EXTENSIONS';
@ -103,12 +103,19 @@ class acp_extensions
trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action)); trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action));
} }
try
{
if ($phpbb_extension_manager->enable_step($ext_name)) if ($phpbb_extension_manager->enable_step($ext_name))
{ {
$template->assign_var('S_NEXT_STEP', true); $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'; $this->tpl_name = 'acp_ext_enable';
@ -156,12 +163,19 @@ class acp_extensions
break; break;
case 'purge': case 'purge':
try
{
if ($phpbb_extension_manager->purge_step($ext_name)) if ($phpbb_extension_manager->purge_step($ext_name))
{ {
$template->assign_var('S_NEXT_STEP', true); $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'; $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')))) ($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); 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; $copied_permissions = true;
} }
/* Commented out because of questionable UI workflow - re-visit for 3.0.7 /* Commented out because of questionable UI workflow - re-visit for 3.0.7
@ -768,7 +768,7 @@ class acp_forums
if (!empty($forum_perm_from) && $forum_perm_from != $forum_id) if (!empty($forum_perm_from) && $forum_perm_from != $forum_id)
{ {
copy_forum_permissions($forum_perm_from, $forum_id, true); copy_forum_permissions($forum_perm_from, $forum_id, true);
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
$auth->acl_clear_prefetch(); $auth->acl_clear_prefetch();
$cache->destroy('sql', FORUMS_TABLE); $cache->destroy('sql', FORUMS_TABLE);

View file

@ -26,7 +26,7 @@ class acp_groups
{ {
global $config, $db, $user, $auth, $template, $cache; global $config, $db, $user, $auth, $template, $cache;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads;
global $request; global $request, $phpbb_container;
$user->add_lang('acp/groups'); $user->add_lang('acp/groups');
$this->tpl_name = 'acp_groups'; $this->tpl_name = 'acp_groups';
@ -55,15 +55,16 @@ class acp_groups
// Clear some vars // Clear some vars
$can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false;
$group_row = array(); $group_row = array();
// Grab basic data for group, if group_id is set and exists // Grab basic data for group, if group_id is set and exists
if ($group_id) if ($group_id)
{ {
$sql = 'SELECT * $sql = 'SELECT g.*, t.teampage_position AS group_teampage
FROM ' . GROUPS_TABLE . " FROM ' . GROUPS_TABLE . ' g
WHERE group_id = $group_id"; LEFT JOIN ' . TEAMPAGE_TABLE . ' t
ON (t.group_id = g.group_id)
WHERE g.group_id = ' . $group_id;
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$group_row = $db->sql_fetchrow($result); $group_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -126,13 +127,34 @@ class acp_groups
{ {
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING); 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)) if (confirm_box(true))
{ {
$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name']; $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);
if (!sizeof($mark_ary)) 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 '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; $start = 0;
do do
@ -163,11 +185,6 @@ class acp_groups
$db->sql_freeresult($result); $db->sql_freeresult($result);
} }
while ($start); while ($start);
}
else
{
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)); trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id));
} }
@ -181,10 +198,12 @@ class acp_groups
'action' => $action)) 'action' => $action))
); );
} }
break; break;
case 'deleteusers': 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': case 'delete':
if (!$group_id) if (!$group_id)
{ {
@ -282,8 +301,21 @@ class acp_groups
$error = array(); $error = array();
$user->add_lang('ucp'); $user->add_lang('ucp');
$avatar_select = basename(request_var('avatar_select', '')); // Setup avatar data for later
$category = basename(request_var('category', '')); $avatars_enabled = false;
$avatar_drivers = null;
$avatar_data = null;
$avatar_error = array();
if ($config['allow_avatar'])
{
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
$avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers();
// This is normalised data, without the group_ prefix
$avatar_data = phpbb_avatar_manager::clean_row($group_row);
}
// Did we submit? // Did we submit?
if ($update) if ($update)
@ -301,12 +333,6 @@ class acp_groups
$allow_desc_urls = request_var('desc_parse_urls', false); $allow_desc_urls = request_var('desc_parse_urls', false);
$allow_desc_smilies = request_var('desc_parse_smilies', false); $allow_desc_smilies = request_var('desc_parse_smilies', false);
$data['uploadurl'] = request_var('uploadurl', '');
$data['remotelink'] = request_var('remotelink', '');
$data['width'] = request_var('width', '');
$data['height'] = request_var('height', '');
$delete = request_var('delete', '');
$submit_ary = array( $submit_ary = array(
'colour' => request_var('group_colour', ''), 'colour' => request_var('group_colour', ''),
'rank' => request_var('group_rank', 0), 'rank' => request_var('group_rank', 0),
@ -324,81 +350,35 @@ class acp_groups
$submit_ary['founder_manage'] = isset($_REQUEST['group_founder_manage']) ? 1 : 0; $submit_ary['founder_manage'] = isset($_REQUEST['group_founder_manage']) ? 1 : 0;
} }
$uploadfile = $request->file('uploadfile'); if ($config['allow_avatar'])
if (!empty($uploadfile['tmp_name']) || $data['uploadurl'] || $data['remotelink'])
{ {
// Avatar stuff // Handle avatar
$var_ary = array( $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', ''));
'uploadurl' => array('string', true, 5, 255),
'remotelink' => array('string', true, 5, 255),
'width' => array('string', true, 1, 3),
'height' => array('string', true, 1, 3),
);
if (!($error = validate_data($data, $var_ary))) if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete'))
{ {
$data['user_id'] = "g$group_id"; $driver = $phpbb_avatar_manager->get_driver($driver_name);
$result = $driver->process_form($request, $template, $user, $avatar_data, $avatar_error);
if ((!empty($uploadfile['tmp_name']) || $data['uploadurl']) && $can_upload) if ($result && empty($avatar_error))
{ {
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error); $result['avatar_type'] = $driver_name;
} $submit_ary = array_merge($submit_ary, $result);
else if ($data['remotelink'])
{
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error);
} }
} }
else
{
$driver = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']);
if ($driver)
{
$driver->delete($avatar_data);
} }
else if ($avatar_select && $config['allow_avatar_local'])
{
// check avatar gallery
if (is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category))
{
$submit_ary['avatar_type'] = AVATAR_GALLERY;
list($submit_ary['avatar_width'], $submit_ary['avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_select); // Removing the avatar
$submit_ary['avatar'] = $category . '/' . $avatar_select; $submit_ary['avatar_type'] = '';
}
}
else if ($delete)
{
$submit_ary['avatar'] = ''; $submit_ary['avatar'] = '';
$submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['avatar_height'] = 0; $submit_ary['avatar_width'] = 0;
} $submit_ary['avatar_height'] = 0;
else if ($data['width'] && $data['height'])
{
// Only update the dimensions?
if ($config['avatar_max_width'] || $config['avatar_max_height'])
{
if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height'])
{
$error[] = phpbb_avatar_error_wrong_size($data['width'], $data['height']);
}
}
if (!sizeof($error))
{
if ($config['avatar_min_width'] || $config['avatar_min_height'])
{
if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height'])
{
$error[] = phpbb_avatar_error_wrong_size($data['width'], $data['height']);
}
}
}
if (!sizeof($error))
{
$submit_ary['avatar_width'] = $data['width'];
$submit_ary['avatar_height'] = $data['height'];
}
}
if ((isset($submit_ary['avatar']) && $submit_ary['avatar'] && (!isset($group_row['group_avatar']))) || $delete)
{
if (isset($group_row['group_avatar']) && $group_row['group_avatar'])
{
avatar_delete('group', $group_row, true);
} }
} }
@ -425,7 +405,7 @@ class acp_groups
'rank' => 'int', 'rank' => 'int',
'colour' => 'string', 'colour' => 'string',
'avatar' => 'string', 'avatar' => 'string',
'avatar_type' => 'int', 'avatar_type' => 'string',
'avatar_width' => 'int', 'avatar_width' => 'int',
'avatar_height' => 'int', 'avatar_height' => 'int',
'receive_pm' => 'int', 'receive_pm' => 'int',
@ -439,7 +419,7 @@ class acp_groups
foreach ($test_variables as $test => $type) 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); settype($submit_ary[$test], $type);
$group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test]; $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
@ -496,7 +476,7 @@ class acp_groups
} }
} }
$cache->destroy('sql', GROUPS_TABLE); $cache->destroy('sql', array(GROUPS_TABLE, TEAMPAGE_TABLE));
$message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED'; $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED';
trigger_error($user->lang[$message] . adm_back_link($this->u_action)); trigger_error($user->lang[$message] . adm_back_link($this->u_action));
@ -555,14 +535,42 @@ class acp_groups
$type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : ''; $type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : '';
$type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : ''; $type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : '';
$avatar_img = (!empty($group_row['group_avatar'])) ? get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR') : '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />'; // Load up stuff for avatars
if ($config['allow_avatar'])
$display_gallery = (isset($_POST['display_gallery'])) ? true : false;
if ($config['allow_avatar_local'] && $display_gallery)
{ {
avatar_gallery($category, $avatar_select, 4); $avatars_enabled = false;
$selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type']));
foreach ($avatar_drivers as $current_driver)
{
$driver = $phpbb_avatar_manager->get_driver($current_driver);
$avatars_enabled = true;
$config_name = $phpbb_avatar_manager->get_driver_config_name($driver);
$template->set_filenames(array(
'avatar' => "acp_avatar_options_{$config_name}.html",
));
if ($driver->prepare_form($request, $template, $user, $avatar_data, $avatar_error))
{
$driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver);
$driver_upper = strtoupper($driver_name);
$template->assign_block_vars('avatar_drivers', array(
'L_TITLE' => $user->lang($driver_upper . '_TITLE'),
'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'),
'DRIVER' => $driver_name,
'SELECTED' => $current_driver == $selected_driver,
'OUTPUT' => $template->assign_display('avatar'),
));
} }
}
}
$avatar = phpbb_get_group_avatar($group_row, 'GROUP_AVATAR', true);
// Merge any avatar errors into the primary error array
$error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error));
$back_link = request_var('back_link', ''); $back_link = request_var('back_link', '');
@ -582,12 +590,10 @@ class acp_groups
'S_ADD_GROUP' => ($action == 'add') ? true : false, 'S_ADD_GROUP' => ($action == 'add') ? true : false,
'S_GROUP_PERM' => ($action == 'add' && $auth->acl_get('a_authgroups') && $auth->acl_gets('a_aauth', 'a_fauth', 'a_mauth', 'a_uauth')) ? true : false, 'S_GROUP_PERM' => ($action == 'add' && $auth->acl_get('a_authgroups') && $auth->acl_gets('a_aauth', 'a_fauth', 'a_mauth', 'a_uauth')) ? true : false,
'S_INCLUDE_SWATCH' => true, 'S_INCLUDE_SWATCH' => true,
'S_CAN_UPLOAD' => $can_upload,
'S_ERROR' => (sizeof($error)) ? true : false, 'S_ERROR' => (sizeof($error)) ? true : false,
'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false, 'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false,
'S_DISPLAY_GALLERY' => ($config['allow_avatar_local'] && !$display_gallery) ? true : false,
'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false,
'S_USER_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false, 'S_USER_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false,
'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled),
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '', 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name, 'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name,
@ -608,8 +614,7 @@ class acp_groups
'S_RANK_OPTIONS' => $rank_options, 'S_RANK_OPTIONS' => $rank_options,
'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == USER_FOUNDER) ? false : 0)), 'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == USER_FOUNDER) ? false : 0)),
'AVATAR' => $avatar_img, 'AVATAR' => empty($avatar) ? '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $avatar,
'AVATAR_IMAGE' => $avatar_img,
'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'],
'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '', 'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '',
'AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '', 'AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '',
@ -698,7 +703,7 @@ class acp_groups
'U_ACTION' => $this->u_action . "&amp;g=$group_id", 'U_ACTION' => $this->u_action . "&amp;g=$group_id",
'U_BACK' => $this->u_action, 'U_BACK' => $this->u_action,
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=list&amp;field=usernames'), '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 // Grab the members
@ -811,36 +816,66 @@ class acp_groups
public function manage_position() public function manage_position()
{ {
global $config, $db, $template, $user; global $config, $db, $template, $user, $request, $phpbb_container;
$this->tpl_name = 'acp_groups_position'; $this->tpl_name = 'acp_groups_position';
$this->page_title = 'ACP_GROUPS_POSITION'; $this->page_title = 'ACP_GROUPS_POSITION';
$field = request_var('field', ''); $field = $request->variable('field', '');
$action = request_var('action', ''); $action = $request->variable('action', '');
$group_id = request_var('g', 0); $group_id = $request->variable('g', 0);
$teampage_id = $request->variable('t', 0);
$category_id = $request->variable('c', 0);
if ($field && !in_array($field, array('legend', 'teampage'))) if ($field && !in_array($field, array('legend', 'teampage')))
{ {
// Invalid mode // Invalid mode
trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
else if ($field) else if ($field && in_array($field, array('legend', 'teampage')))
{ {
$group_position = new phpbb_group_positions($db, $field, $this->u_action);
$group_position = $phpbb_container->get('groupposition.' . $field);
} }
if ($field == 'teampage')
{
try
{
switch ($action) switch ($action)
{ {
case 'set_config_legend': case 'add':
set_config('legend_sort_groupname', request_var('legend_sort_groupname', 0)); $group_position->add_group_teampage($group_id, $category_id);
break; break;
case 'set_config_teampage': case 'add_category':
set_config('teampage_forums', request_var('teampage_forums', 0)); $group_position->add_category_teampage($request->variable('category_name', '', true));
set_config('teampage_memberships', request_var('teampage_memberships', 0));
break; break;
case 'delete':
$group_position->delete_teampage($teampage_id);
break;
case 'move_up':
$group_position->move_up_teampage($teampage_id);
break;
case 'move_down':
$group_position->move_down_teampage($teampage_id);
break;
}
}
catch (phpbb_groupposition_exception $exception)
{
trigger_error($user->lang($exception->getMessage()) . adm_back_link($this->u_action), E_USER_WARNING);
}
}
else if ($field == 'legend')
{
try
{
switch ($action)
{
case 'add': case 'add':
$group_position->add_group($group_id); $group_position->add_group($group_id);
break; break;
@ -857,10 +892,36 @@ class acp_groups
$group_position->move_down($group_id); $group_position->move_down($group_id);
break; break;
} }
}
catch (phpbb_groupposition_exception $exception)
{
trigger_error($user->lang($exception->getMessage()) . adm_back_link($this->u_action), E_USER_WARNING);
}
}
else
{
switch ($action)
{
case 'set_config_teampage':
$config->set('teampage_forums', $request->variable('teampage_forums', 0));
$config->set('teampage_memberships', $request->variable('teampage_memberships', 0));
break;
case 'set_config_legend':
$config->set('legend_sort_groupname', $request->variable('legend_sort_groupname', 0));
break;
}
}
if (($action == 'move_up' || $action == 'move_down') && $request->is_ajax())
{
$json_response = new phpbb_json_response;
$json_response->send(array('success' => true));
}
$sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend
FROM ' . GROUPS_TABLE . ' FROM ' . GROUPS_TABLE . '
ORDER BY group_legend, group_name ASC'; ORDER BY group_legend ASC, group_type DESC, group_name ASC';
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$s_group_select_legend = ''; $s_group_select_legend = '';
@ -871,8 +932,8 @@ class acp_groups
{ {
$template->assign_block_vars('legend', array( $template->assign_block_vars('legend', array(
'GROUP_NAME' => $group_name, 'GROUP_NAME' => $group_name,
'GROUP_COLOUR' => ($row['group_colour']) ? ' style="color: #' . $row['group_colour'] . '"' : '', 'GROUP_COLOUR' => ($row['group_colour']) ? '#' . $row['group_colour'] : '',
'GROUP_TYPE' => $user->lang[phpbb_group_positions::group_type_language($row['group_type'])], 'GROUP_TYPE' => $user->lang[phpbb_groupposition_legend::group_type_language($row['group_type'])],
'U_MOVE_DOWN' => "{$this->u_action}&amp;field=legend&amp;action=move_down&amp;g=" . $row['group_id'], 'U_MOVE_DOWN' => "{$this->u_action}&amp;field=legend&amp;action=move_down&amp;g=" . $row['group_id'],
'U_MOVE_UP' => "{$this->u_action}&amp;field=legend&amp;action=move_up&amp;g=" . $row['group_id'], 'U_MOVE_UP' => "{$this->u_action}&amp;field=legend&amp;action=move_up&amp;g=" . $row['group_id'],
@ -881,46 +942,88 @@ class acp_groups
} }
else else
{ {
$s_group_select_legend .= '<option value="' . (int) $row['group_id'] . '">' . $group_name . '</option>'; $template->assign_block_vars('add_legend', array(
'GROUP_ID' => (int) $row['group_id'],
'GROUP_NAME' => $group_name,
'GROUP_SPECIAL' => ($row['group_type'] == GROUP_SPECIAL),
));
} }
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$sql = 'SELECT group_id, group_name, group_colour, group_type, group_teampage $category_url_param = (($category_id) ? '&amp;c=' . $category_id : '');
FROM ' . GROUPS_TABLE . '
ORDER BY group_teampage, group_name ASC'; $sql = 'SELECT t.*, g.group_name, g.group_colour, g.group_type
FROM ' . TEAMPAGE_TABLE . ' t
LEFT JOIN ' . GROUPS_TABLE . ' g
ON (t.group_id = g.group_id)
WHERE t.teampage_parent = ' . $category_id . '
OR t.teampage_id = ' . $category_id . '
ORDER BY t.teampage_position ASC';
$result = $db->sql_query($sql);
$category_data = array();
while ($row = $db->sql_fetchrow($result))
{
if ($row['teampage_id'] == $category_id)
{
$template->assign_vars(array(
'CURRENT_CATEGORY_NAME' => $row['teampage_name'],
));
continue;
}
if ($row['group_id'])
{
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
$group_type = $user->lang[phpbb_groupposition_teampage::group_type_language($row['group_type'])];
}
else
{
$group_name = $row['teampage_name'];
$group_type = '';
}
$template->assign_block_vars('teampage', array(
'GROUP_NAME' => $group_name,
'GROUP_COLOUR' => ($row['group_colour']) ? '#' . $row['group_colour'] : '',
'GROUP_TYPE' => $group_type,
'U_CATEGORY' => (!$row['group_id']) ? "{$this->u_action}&amp;c=" . $row['teampage_id'] : '',
'U_MOVE_DOWN' => "{$this->u_action}&amp;field=teampage&amp;action=move_down{$category_url_param}&amp;t=" . $row['teampage_id'],
'U_MOVE_UP' => "{$this->u_action}&amp;field=teampage&amp;action=move_up{$category_url_param}&amp;t=" . $row['teampage_id'],
'U_DELETE' => "{$this->u_action}&amp;field=teampage&amp;action=delete{$category_url_param}&amp;t=" . $row['teampage_id'],
));
}
$db->sql_freeresult($result);
$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
FROM ' . GROUPS_TABLE . ' g
LEFT JOIN ' . TEAMPAGE_TABLE . ' t
ON (t.group_id = g.group_id)
WHERE t.teampage_id IS NULL
ORDER BY g.group_type DESC, g.group_name ASC';
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$s_group_select_teampage = ''; $s_group_select_teampage = '';
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']; $group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
if ($row['group_teampage']) $template->assign_block_vars('add_teampage', array(
{ 'GROUP_ID' => (int) $row['group_id'],
$template->assign_block_vars('teampage', array(
'GROUP_NAME' => $group_name, 'GROUP_NAME' => $group_name,
'GROUP_COLOUR' => ($row['group_colour']) ? ' style="color: #' . $row['group_colour'] . '"' : '', 'GROUP_SPECIAL' => ($row['group_type'] == GROUP_SPECIAL),
'GROUP_TYPE' => $user->lang[phpbb_group_positions::group_type_language($row['group_type'])],
'U_MOVE_DOWN' => "{$this->u_action}&amp;field=teampage&amp;action=move_down&amp;g=" . $row['group_id'],
'U_MOVE_UP' => "{$this->u_action}&amp;field=teampage&amp;action=move_up&amp;g=" . $row['group_id'],
'U_DELETE' => "{$this->u_action}&amp;field=teampage&amp;action=delete&amp;g=" . $row['group_id'],
)); ));
} }
else
{
$s_group_select_teampage .= '<option value="' . (int) $row['group_id'] . '">' . $group_name . '</option>';
}
}
$db->sql_freeresult($result); $db->sql_freeresult($result);
$template->assign_vars(array( $template->assign_vars(array(
'U_ACTION' => $this->u_action, 'U_ACTION' => $this->u_action,
'U_ACTION_LEGEND' => $this->u_action . '&amp;field=legend', 'U_ACTION_LEGEND' => $this->u_action . '&amp;field=legend',
'U_ACTION_TEAMPAGE' => $this->u_action . '&amp;field=teampage', 'U_ACTION_TEAMPAGE' => $this->u_action . '&amp;field=teampage' . $category_url_param,
'U_ACTION_TEAMPAGE_CAT' => $this->u_action . '&amp;field=teampage_cat',
'S_GROUP_SELECT_LEGEND' => $s_group_select_legend, 'S_TEAMPAGE_CATEGORY' => $category_id,
'S_GROUP_SELECT_TEAMPAGE' => $s_group_select_teampage,
'DISPLAY_FORUMS' => ($config['teampage_forums']) ? true : false, 'DISPLAY_FORUMS' => ($config['teampage_forums']) ? true : false,
'DISPLAY_MEMBERSHIPS' => $config['teampage_memberships'], 'DISPLAY_MEMBERSHIPS' => $config['teampage_memberships'],
'LEGEND_SORT_GROUPNAME' => ($config['legend_sort_groupname']) ? true : false, 'LEGEND_SORT_GROUPNAME' => ($config['legend_sort_groupname']) ? true : false,

View file

@ -24,7 +24,7 @@ class acp_main
function main($id, $mode) 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; global $phpbb_root_path, $phpbb_admin_path, $phpEx;
// Show restore permissions notice // Show restore permissions notice
@ -359,7 +359,7 @@ class acp_main
// Clear permissions // Clear permissions
$auth->acl_clear_prefetch(); $auth->acl_clear_prefetch();
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
add_log('admin', 'LOG_PURGE_CACHE'); add_log('admin', 'LOG_PURGE_CACHE');

View file

@ -535,8 +535,14 @@ class acp_modules
/** /**
* Get available module information from module files * 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; global $phpbb_root_path, $phpEx;
@ -556,7 +562,7 @@ class acp_modules
->extension_directory("/$module_class") ->extension_directory("/$module_class")
->core_path("includes/$module_class/info/") ->core_path("includes/$module_class/info/")
->core_prefix($module_class . '_') ->core_prefix($module_class . '_')
->get_classes(); ->get_classes(true, $use_all_available);
foreach ($modules as $module) foreach ($modules as $module)
{ {
@ -594,11 +600,11 @@ class acp_modules
if (!class_exists($info_class)) if (!class_exists($info_class))
{ {
if (file_exists($directory . $module . '.' . $phpEx)) $info_class = $module . '_info';
if (!class_exists($info_class) && file_exists($directory . $module . '.' . $phpEx))
{ {
include($directory . $module . '.' . $phpEx); include($directory . $module . '.' . $phpEx);
} }
$info_class = $module . '_info';
} }
// Get module title tag // Get module title tag
@ -740,15 +746,15 @@ class acp_modules
*/ */
function remove_cache_file() function remove_cache_file()
{ {
global $cache; global $phpbb_container;
// Sanitise for future path use, it's escaped as appropriate for queries // Sanitise for future path use, it's escaped as appropriate for queries
$p_class = str_replace(array('.', '/', '\\'), '', basename($this->module_class)); $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 // 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) function set_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id)
{ {
global $user, $auth; global $db, $cache, $user, $auth;
global $request; global $request;
$psubmit = request_var('psubmit', array(0 => array(0 => 0))); $psubmit = request_var('psubmit', array(0 => array(0 => 0)));
@ -726,13 +726,13 @@ class acp_permissions
// Do we need to recache the moderator lists? // Do we need to recache the moderator lists?
if ($permission_type == 'm_') if ($permission_type == 'm_')
{ {
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
} }
// Remove users who are now moderators or admins from everyones foes list // Remove users who are now moderators or admins from everyones foes list
if ($permission_type == 'm_' || $permission_type == 'a_') 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); $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) function set_all_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id)
{ {
global $user, $auth; global $db, $cache, $user, $auth;
global $request; global $request;
// User or group to be set? // User or group to be set?
@ -794,13 +794,13 @@ class acp_permissions
// Do we need to recache the moderator lists? // Do we need to recache the moderator lists?
if ($permission_type == 'm_') if ($permission_type == 'm_')
{ {
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
} }
// Remove users who are now moderators or admins from everyones foes list // Remove users who are now moderators or admins from everyones foes list
if ($permission_type == 'm_' || $permission_type == 'a_') 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); $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) 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? // User or group to be set?
$ug_type = (sizeof($user_id)) ? 'user' : 'group'; $ug_type = (sizeof($user_id)) ? 'user' : 'group';
@ -874,7 +874,7 @@ class acp_permissions
// Do we need to recache the moderator lists? // Do we need to recache the moderator lists?
if ($permission_type == 'm_') 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))); $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']) if ($user_id != $user->data['user_id'])
{ {
$sql = 'SELECT user_id, username, user_permissions, user_type $userdata = $auth->obtain_user_data($user_id);
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
$userdata = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
} }
else else
{ {
@ -1172,7 +1167,7 @@ class acp_permissions
*/ */
function copy_forum_permissions() function copy_forum_permissions()
{ {
global $auth, $cache, $template, $user; global $db, $auth, $cache, $template, $user;
$user->add_lang('acp/forums'); $user->add_lang('acp/forums');
@ -1187,7 +1182,7 @@ class acp_permissions
{ {
if (copy_forum_permissions($src, $dest)) if (copy_forum_permissions($src, $dest))
{ {
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
$auth->acl_clear_prefetch(); $auth->acl_clear_prefetch();
$cache->destroy('sql', FORUMS_TABLE); $cache->destroy('sql', FORUMS_TABLE);

View file

@ -209,7 +209,7 @@ class acp_ranks
'RANK_TITLE' => (isset($ranks['rank_title'])) ? $ranks['rank_title'] : '', 'RANK_TITLE' => (isset($ranks['rank_title'])) ? $ranks['rank_title'] : '',
'S_FILENAME_LIST' => $filename_list, '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, '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) '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() protected function action_cache()
{ {
global $db, $cache, $auth;
$this->cache->purge(); $this->cache->purge();
// Clear permissions // Clear permissions
$this->auth->acl_clear_prefetch(); $this->auth->acl_clear_prefetch();
cache_moderators(); phpbb_cache_moderators($db, $cache, $auth);
add_log('admin', 'LOG_PURGE_CACHE'); add_log('admin', 'LOG_PURGE_CACHE');

View file

@ -33,6 +33,7 @@ class acp_users
global $config, $db, $user, $auth, $template, $cache; global $config, $db, $user, $auth, $template, $cache;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads;
global $phpbb_dispatcher, $request; global $phpbb_dispatcher, $request;
global $phpbb_container;
$user->add_lang(array('posting', 'ucp', 'acp/users')); $user->add_lang(array('posting', 'ucp', 'acp/users'));
$this->tpl_name = 'acp_users'; $this->tpl_name = 'acp_users';
@ -456,7 +457,7 @@ class acp_users
$sql_ary = array( $sql_ary = array(
'user_avatar' => '', 'user_avatar' => '',
'user_avatar_type' => 0, 'user_avatar_type' => '',
'user_avatar_width' => 0, 'user_avatar_width' => 0,
'user_avatar_height' => 0, 'user_avatar_height' => 0,
); );
@ -467,9 +468,11 @@ class acp_users
$db->sql_query($sql); $db->sql_query($sql);
// Delete old avatar if present // Delete old avatar if present
if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY) $phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
$driver = $phpbb_avatar_manager->get_driver($user_row['user_avatar_type']);
if ($driver)
{ {
avatar_delete('user', $user_row); $driver->delete($user_row);
} }
add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']); add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']);
@ -1728,65 +1731,120 @@ class acp_users
case 'avatar': case 'avatar':
include($phpbb_root_path . 'includes/functions_display.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
$can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; $avatars_enabled = false;
if ($config['allow_avatar'])
{
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
$avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers();
// This is normalised data, without the user_ prefix
$avatar_data = phpbb_avatar_manager::clean_row($user_row);
if ($submit) if ($submit)
{ {
if (check_form_key($form_name))
{
$driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', ''));
if (!check_form_key($form_name)) if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete'))
{
$driver = $phpbb_avatar_manager->get_driver($driver_name);
$result = $driver->process_form($request, $template, $user, $avatar_data, $error);
if ($result && empty($error))
{
// Success! Lets save the result in the database
$result = array(
'user_avatar_type' => $driver_name,
'user_avatar' => $result['avatar'],
'user_avatar_width' => $result['avatar_width'],
'user_avatar_height' => $result['avatar_height'],
);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $result) . '
WHERE user_id = ' . (int) $user_id;
$db->sql_query($sql);
trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
}
}
else
{
$driver = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']);
if ($driver)
{
$driver->delete($avatar_data);
}
// Removing the avatar
$result = array(
'user_avatar' => '',
'user_avatar_type' => '',
'user_avatar_width' => 0,
'user_avatar_height' => 0,
);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $result) . '
WHERE user_id = ' . (int) $user_id;
$db->sql_query($sql);
trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
}
}
else
{ {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING); trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
} }
}
if (avatar_process_user($error, $user_row, $can_upload)) $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user_row['user_avatar_type']));
foreach ($avatar_drivers as $current_driver)
{ {
trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&amp;u=' . $user_row['user_id'])); $driver = $phpbb_avatar_manager->get_driver($current_driver);
$avatars_enabled = true;
$config_name = $phpbb_avatar_manager->get_driver_config_name($driver);
$template->set_filenames(array(
'avatar' => "acp_avatar_options_{$config_name}.html",
));
if ($driver->prepare_form($request, $template, $user, $avatar_data, $error))
{
$driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver);
$driver_upper = strtoupper($driver_name);
$template->assign_block_vars('avatar_drivers', array(
'L_TITLE' => $user->lang($driver_upper . '_TITLE'),
'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'),
'DRIVER' => $driver_name,
'SELECTED' => $current_driver == $selected_driver,
'OUTPUT' => $template->assign_display('avatar'),
));
}
}
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = array_map(array($user, 'lang'), $error); $error = $phpbb_avatar_manager->localize_errors($user, $error);
}
if (!$config['allow_avatar'] && $user_row['user_avatar_type']) $avatar = phpbb_get_user_avatar($user_row, 'USER_AVATAR', true);
{
$error[] = $user->lang['USER_AVATAR_NOT_ALLOWED'];
}
else if ((($user_row['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) ||
(($user_row['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) ||
(($user_row['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local']))
{
$error[] = $user->lang['USER_AVATAR_TYPE_NOT_ALLOWED'];
}
// Generate users avatar
$avatar_img = ($user_row['user_avatar']) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height'], 'USER_AVATAR', true) : '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />';
$display_gallery = (isset($_POST['display_gallery'])) ? true : false;
$avatar_select = basename(request_var('avatar_select', ''));
$category = basename(request_var('category', ''));
if ($config['allow_avatar_local'] && $display_gallery)
{
avatar_gallery($category, $avatar_select, 4);
}
$template->assign_vars(array( $template->assign_vars(array(
'S_AVATAR' => true, 'S_AVATAR' => true,
'S_CAN_UPLOAD' => $can_upload, 'ERROR' => (!empty($error)) ? implode('<br />', $error) : '',
'S_UPLOAD_FILE' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_upload']) ? true : false, 'AVATAR' => (empty($avatar) ? '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $avatar),
'S_REMOTE_UPLOAD' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_remote_upload']) ? true : false,
'S_ALLOW_REMOTE' => ($config['allow_avatar'] && $config['allow_avatar_remote']) ? true : false,
'S_DISPLAY_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && !$display_gallery) ? true : false,
'S_IN_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && $display_gallery) ? true : false,
'AVATAR_IMAGE' => $avatar_img, 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"',
'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'],
'USER_AVATAR_WIDTH' => $user_row['user_avatar_width'],
'USER_AVATAR_HEIGHT' => $user_row['user_avatar_height'],
'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024),
'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled),
)); ));
break; break;

View file

@ -16,10 +16,10 @@ class acp_extensions_info
{ {
return array( return array(
'filename' => 'acp_extensions', 'filename' => 'acp_extensions',
'title' => 'ACP_EXTENSIONS_MANAGEMENT', 'title' => 'ACP_EXTENSION_MANAGEMENT',
'version' => '1.0.0', 'version' => '1.0.0',
'modes' => array( '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; 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 * Fill ACL array with relevant bitstrings from user_permissions column
* @access private * @access private
@ -191,7 +211,7 @@ class phpbb_auth
/** /**
* Get forums with the specified permission setting * 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 * @param bool $clean set to true if only values needs to be returned which are set/unset
*/ */

View file

@ -0,0 +1,138 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Base class for avatar drivers
* @package phpBB3
*/
abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface
{
/**
* Avatar driver name
* @var string
*/
protected $name;
/**
* Current board configuration
* @var phpbb_config
*/
protected $config;
/**
* Current $phpbb_root_path
* @var string
*/
protected $phpbb_root_path;
/**
* Current $php_ext
* @var string
*/
protected $php_ext;
/**
* Cache driver
* @var phpbb_cache_driver_interface
*/
protected $cache;
/**
* Array of allowed avatar image extensions
* Array is used for setting the allowed extensions in the fileupload class
* and as a base for a regex of allowed extensions, which will be formed by
* imploding the array with a "|".
*
* @var array
*/
protected $allowed_extensions = array(
'gif',
'jpg',
'jpeg',
'png',
);
/**
* Construct a driver object
*
* @param phpbb_config $config phpBB configuration
* @param phpbb_request $request Request object
* @param string $phpbb_root_path Path to the phpBB root
* @param string $php_ext PHP file extension
* @param phpbb_cache_driver_interface $cache Cache driver
*/
public function __construct(phpbb_config $config, $phpbb_root_path, $php_ext, phpbb_cache_driver_interface $cache = null)
{
$this->config = $config;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->cache = $cache;
}
/**
* @inheritdoc
*/
public function get_custom_html($user, $row, $alt = '')
{
return '';
}
/**
* @inheritdoc
*/
public function prepare_form_acp($user)
{
return array();
}
/**
* @inheritdoc
*/
public function delete($row)
{
return true;
}
/**
* @inheritdoc
*/
public function get_template_name()
{
$driver = preg_replace('#^phpbb_avatar_driver_#', '', get_class($this));
$template = "ucp_avatar_options_$driver.html";
return $template;
}
/**
* @inheritdoc
*/
public function get_name()
{
return $this->name;
}
/**
* Sets the name of the driver.
*
* @param string $name Driver name
*/
public function set_name($name)
{
$this->name = $name;
}
}

View file

@ -0,0 +1,172 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Handles avatars hosted at gravatar.com
* @package phpBB3
*/
class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver
{
/**
* The URL for the gravatar service
*/
const GRAVATAR_URL = '//secure.gravatar.com/avatar/';
/**
* @inheritdoc
*/
public function get_data($row)
{
return array(
'src' => $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);
}
/**
* @inheritdoc
*/
public function get_custom_html($user, $row, $alt = '')
{
return '<img src="' . $this->get_gravatar_url($row) . '" ' .
($row['avatar_width'] ? ('width="' . $row['avatar_width'] . '" ') : '') .
($row['avatar_height'] ? ('height="' . $row['avatar_height'] . '" ') : '') .
'alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}
/**
* @inheritdoc
*/
public function prepare_form($request, $template, $user, $row, &$error)
{
$template->assign_vars(array(
'AVATAR_GRAVATAR_WIDTH' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_width']) ? $row['avatar_width'] : $request->variable('avatar_gravatar_width', 0),
'AVATAR_GRAVATAR_HEIGHT' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_height']) ? $row['avatar_height'] : $request->variable('avatar_gravatar_width', 0),
'AVATAR_GRAVATAR_EMAIL' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar']) ? $row['avatar'] : '',
));
return true;
}
/**
* @inheritdoc
*/
public function process_form($request, $template, $user, $row, &$error)
{
$row['avatar'] = $request->variable('avatar_gravatar_email', '');
$row['avatar_width'] = $request->variable('avatar_gravatar_width', 0);
$row['avatar_height'] = $request->variable('avatar_gravatar_height', 0);
if (!function_exists('validate_data'))
{
require($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext);
}
$validate_array = validate_data(
array(
'email' => $row['avatar'],
),
array(
'email' => array(
array('string', false, 6, 60),
array('email'))
)
);
$error = array_merge($error, $validate_array);
if (!empty($error))
{
return false;
}
// Make sure getimagesize works...
if (function_exists('getimagesize') && ($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0))
{
/**
* default to the minimum of the maximum allowed avatar size if the size
* is not or only partially entered
*/
$row['avatar_width'] = $row['avatar_height'] = min($this->config['avatar_max_width'], $this->config['avatar_max_height']);
$url = $this->get_gravatar_url($row);
if (($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) && (($image_data = getimagesize($url)) === false))
{
$error[] = 'UNABLE_GET_IMAGE_SIZE';
return false;
}
if (!empty($image_data) && ($image_data[0] <= 0 || $image_data[1] <= 0))
{
$error[] = 'AVATAR_NO_SIZE';
return false;
}
$row['avatar_width'] = ($row['avatar_width'] && $row['avatar_height']) ? $row['avatar_width'] : $image_data[0];
$row['avatar_height'] = ($row['avatar_width'] && $row['avatar_height']) ? $row['avatar_height'] : $image_data[1];
}
if ($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0)
{
$error[] = 'AVATAR_NO_SIZE';
return false;
}
if ($this->config['avatar_max_width'] || $this->config['avatar_max_height'])
{
if ($row['avatar_width'] > $this->config['avatar_max_width'] || $row['avatar_height'] > $this->config['avatar_max_height'])
{
$error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $row['avatar_width'], $row['avatar_height']);
return false;
}
}
if ($this->config['avatar_min_width'] || $this->config['avatar_min_height'])
{
if ($row['avatar_width'] < $this->config['avatar_min_width'] || $row['avatar_height'] < $this->config['avatar_min_height'])
{
$error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $row['avatar_width'], $row['avatar_height']);
return false;
}
}
return array(
'avatar' => $row['avatar'],
'avatar_width' => $row['avatar_width'],
'avatar_height' => $row['avatar_height'],
);
}
/**
* Build gravatar URL for output on page
*
* @return string Gravatar URL
*/
protected function get_gravatar_url($row)
{
$url = self::GRAVATAR_URL;
$url .= md5(strtolower(trim($row['avatar'])));
if ($row['avatar_width'] || $row['avatar_height'])
{
$url .= '?s=' . max($row['avatar_width'], $row['avatar_height']);
}
return $url;
}
}

View file

@ -0,0 +1,116 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Interface for avatar drivers
* @package phpBB3
*/
interface phpbb_avatar_driver_interface
{
/**
* Returns the name of the driver.
*
* @return string Name of driver.
*/
public function get_name();
/**
* Get the avatar url and dimensions
*
* @param array $row User data or group data that has been cleaned with
* phpbb_avatar_manager::clean_row
* @return array Avatar data, must have keys src, width and height, e.g.
* ['src' => '', 'width' => 0, 'height' => 0]
*/
public function get_data($row);
/**
* Returns custom html if it is needed for displaying this avatar
*
* @param phpbb_user $user phpBB user object
* @param array $row User data or group data that has been cleaned with
* phpbb_avatar_manager::clean_row
* @param string $alt Alternate text for avatar image
*
* @return string HTML
*/
public function get_custom_html($user, $row, $alt = '');
/**
* Prepare form for changing the settings of this avatar
*
* @param phpbb_request $request Request object
* @param phpbb_template $template Template object
* @param phpbb_user $user User object
* @param array $row User data or group data that has been cleaned with
* phpbb_avatar_manager::clean_row
* @param array &$error Reference to an error array that is filled by this
* function. Key values can either be a string with a language key or
* an array that will be passed to vsprintf() with the language key in
* the first array key.
*
* @return bool True if form has been successfully prepared
*/
public function prepare_form($request, $template, $user, $row, &$error);
/**
* Prepare form for changing the acp settings of this avatar
*
* @param phpbb_user $user phpBB user object
*
* @return array Array of configuration options as consumed by acp_board.
* The setting for enabling/disabling the avatar will be handled by
* the avatar manager.
*/
public function prepare_form_acp($user);
/**
* Process form data
*
* @param phpbb_request $request Request object
* @param phpbb_template $template Template object
* @param phpbb_user $user User object
* @param array $row User data or group data that has been cleaned with
* phpbb_avatar_manager::clean_row
* @param array &$error Reference to an error array that is filled by this
* function. Key values can either be a string with a language key or
* an array that will be passed to vsprintf() with the language key in
* the first array key.
*
* @return array Array containing the avatar data as follows:
* ['avatar'], ['avatar_width'], ['avatar_height']
*/
public function process_form($request, $template, $user, $row, &$error);
/**
* Delete avatar
*
* @param array $row User data or group data that has been cleaned with
* phpbb_avatar_manager::clean_row
*
* @return bool True if avatar has been deleted or there is no need to delete,
* i.e. when the avatar is not hosted locally.
*/
public function delete($row);
/**
* Get the avatar driver's template name
*
* @return string Avatar driver's template name
*/
public function get_template_name();
}

View file

@ -0,0 +1,197 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Handles avatars selected from the board gallery
* @package phpBB3
*/
class phpbb_avatar_driver_local extends phpbb_avatar_driver
{
/**
* @inheritdoc
*/
public function get_data($row)
{
return array(
'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);
}
/**
* @inheritdoc
*/
public function prepare_form($request, $template, $user, $row, &$error)
{
$avatar_list = $this->get_avatar_list($user);
$category = $request->variable('avatar_local_cat', '');
foreach ($avatar_list as $cat => $null)
{
if (!empty($avatar_list[$cat]))
{
$template->assign_block_vars('avatar_local_cats', array(
'NAME' => $cat,
'SELECTED' => ($cat == $category),
));
}
if ($cat != $category)
{
unset($avatar_list[$cat]);
}
}
if (!empty($avatar_list[$category]))
{
$template->assign_vars(array(
'AVATAR_LOCAL_SHOW' => true,
));
$table_cols = isset($row['avatar_gallery_cols']) ? $row['avatar_gallery_cols'] : 4;
$row_count = $col_count = $avatar_pos = 0;
$avatar_count = sizeof($avatar_list[$category]);
reset($avatar_list[$category]);
while ($avatar_pos < $avatar_count)
{
$img = current($avatar_list[$category]);
next($avatar_list[$category]);
if ($col_count == 0)
{
++$row_count;
$template->assign_block_vars('avatar_local_row', array(
));
}
$template->assign_block_vars('avatar_local_row.avatar_local_col', array(
'AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'],
'AVATAR_NAME' => $img['name'],
'AVATAR_FILE' => $img['filename'],
));
$template->assign_block_vars('avatar_local_row.avatar_local_option', array(
'AVATAR_FILE' => $img['filename'],
'S_OPTIONS_AVATAR' => $img['filename']
));
$col_count = ($col_count + 1) % $table_cols;
++$avatar_pos;
}
}
return true;
}
/**
* @inheritdoc
*/
public function prepare_form_acp($user)
{
return array(
'avatar_gallery_path' => array('lang' => 'AVATAR_GALLERY_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true),
);
}
/**
* @inheritdoc
*/
public function process_form($request, $template, $user, $row, &$error)
{
$avatar_list = $this->get_avatar_list($user);
$category = $request->variable('avatar_local_cat', '');
$file = $request->variable('avatar_local_file', '');
if (empty($category) || empty($file))
{
$error[] = 'NO_AVATAR_SELECTED';
return false;
}
if (!isset($avatar_list[$category][urldecode($file)]))
{
$error[] = 'AVATAR_URL_NOT_FOUND';
return false;
}
return array(
'avatar' => ($category != $user->lang['MAIN']) ? $category . '/' . $file : $file,
'avatar_width' => $avatar_list[$category][urldecode($file)]['width'],
'avatar_height' => $avatar_list[$category][urldecode($file)]['height'],
);
}
/**
* Get a list of avatars that are locally available
* Results get cached for 24 hours (86400 seconds)
*
* @param phpbb_user $user User object
*
* @return array Array containing the locally available avatars
*/
protected function get_avatar_list($user)
{
$avatar_list = ($this->cache == null) ? false : $this->cache->get('avatar_local_list');
if ($avatar_list === false)
{
$avatar_list = array();
$path = $this->phpbb_root_path . $this->config['avatar_gallery_path'];
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS), RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $file_info)
{
$file_path = $file_info->getPath();
$image = $file_info->getFilename();
// Match all images in the gallery folder
if (preg_match('#^[^&\'"<>]+\.(?:' . implode('|', $this->allowed_extensions) . ')$#i', $image) && is_file($file_path . '/' . $image))
{
if (function_exists('getimagesize'))
{
$dims = getimagesize($file_path . '/' . $image);
}
else
{
$dims = array(0, 0);
}
$cat = ($path == $file_path) ? $user->lang['MAIN'] : str_replace("$path/", '', $file_path);
$avatar_list[$cat][$image] = array(
'file' => ($cat != $user->lang['MAIN']) ? rawurlencode($cat) . '/' . rawurlencode($image) : rawurlencode($image),
'filename' => rawurlencode($image),
'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $image))),
'width' => $dims[0],
'height' => $dims[1],
);
}
}
ksort($avatar_list);
if ($this->cache != null)
{
$this->cache->put('avatar_local_list', $avatar_list, 86400);
}
}
return $avatar_list;
}
}

View file

@ -0,0 +1,164 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Handles avatars hosted remotely
* @package phpBB3
*/
class phpbb_avatar_driver_remote extends phpbb_avatar_driver
{
/**
* @inheritdoc
*/
public function get_data($row)
{
return array(
'src' => $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);
}
/**
* @inheritdoc
*/
public function prepare_form($request, $template, $user, $row, &$error)
{
$template->assign_vars(array(
'AVATAR_REMOTE_WIDTH' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_width']) ? $row['avatar_width'] : $request->variable('avatar_remote_width', 0),
'AVATAR_REMOTE_HEIGHT' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_height']) ? $row['avatar_height'] : $request->variable('avatar_remote_width', 0),
'AVATAR_REMOTE_URL' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar']) ? $row['avatar'] : '',
));
return true;
}
/**
* @inheritdoc
*/
public function process_form($request, $template, $user, $row, &$error)
{
$url = $request->variable('avatar_remote_url', '');
$width = $request->variable('avatar_remote_width', 0);
$height = $request->variable('avatar_remote_height', 0);
if (!preg_match('#^(http|https|ftp)://#i', $url))
{
$url = 'http://' . $url;
}
if (!function_exists('validate_data'))
{
require($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext);
}
$validate_array = validate_data(
array(
'url' => $url,
),
array(
'url' => array('string', true, 5, 255),
)
);
$error = array_merge($error, $validate_array);
if (!empty($error))
{
return false;
}
// Check if this url looks alright
// This isn't perfect, but it's what phpBB 3.0 did, and might as well make sure everything is compatible
if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.('. implode('|', $this->allowed_extensions) . ')$#i', $url))
{
$error[] = 'AVATAR_URL_INVALID';
return false;
}
// Make sure getimagesize works...
if (function_exists('getimagesize'))
{
if (($width <= 0 || $height <= 0) && (($image_data = getimagesize($url)) === false))
{
$error[] = 'UNABLE_GET_IMAGE_SIZE';
return false;
}
if (!empty($image_data) && ($image_data[0] <= 0 || $image_data[1] <= 0))
{
$error[] = 'AVATAR_NO_SIZE';
return false;
}
$width = ($width && $height) ? $width : $image_data[0];
$height = ($width && $height) ? $height : $image_data[1];
}
if ($width <= 0 || $height <= 0)
{
$error[] = 'AVATAR_NO_SIZE';
return false;
}
if (!class_exists('fileupload'))
{
include($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext);
}
$types = fileupload::image_types();
$extension = strtolower(filespec::get_extension($url));
if (!empty($image_data) && (!isset($types[$image_data[2]]) || !in_array($extension, $types[$image_data[2]])))
{
if (!isset($types[$image_data[2]]))
{
$error[] = 'UNABLE_GET_IMAGE_SIZE';
}
else
{
$error[] = array('IMAGE_FILETYPE_MISMATCH', $types[$image_data[2]][0], $extension);
}
return false;
}
if ($this->config['avatar_max_width'] || $this->config['avatar_max_height'])
{
if ($width > $this->config['avatar_max_width'] || $height > $this->config['avatar_max_height'])
{
$error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height);
return false;
}
}
if ($this->config['avatar_min_width'] || $this->config['avatar_min_height'])
{
if ($width < $this->config['avatar_min_width'] || $height < $this->config['avatar_min_height'])
{
$error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height);
return false;
}
}
return array(
'avatar' => $url,
'avatar_width' => $width,
'avatar_height' => $height,
);
}
}

View file

@ -0,0 +1,159 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Handles avatars uploaded to the board
* @package phpBB3
*/
class phpbb_avatar_driver_upload extends phpbb_avatar_driver
{
/**
* @inheritdoc
*/
public function get_data($row, $ignore_config = false)
{
return array(
'src' => $this->phpbb_root_path . 'download/file' . $this->php_ext . '?avatar=' . $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);
}
/**
* @inheritdoc
*/
public function prepare_form($request, $template, $user, $row, &$error)
{
if (!$this->can_upload())
{
return false;
}
$template->assign_vars(array(
'S_UPLOAD_AVATAR_URL' => ($this->config['allow_avatar_remote_upload']) ? true : false,
'AVATAR_UPLOAD_SIZE' => $this->config['avatar_filesize'],
));
return true;
}
/**
* @inheritdoc
*/
public function process_form($request, $template, $user, $row, &$error)
{
if (!$this->can_upload())
{
return false;
}
if (!class_exists('fileupload'))
{
include($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext);
}
$upload = new fileupload('AVATAR_', $this->allowed_extensions, $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false));
$url = $request->variable('avatar_upload_url', '');
$upload_file = $request->file('avatar_upload_file');
if (!empty($upload_file['name']))
{
$file = $upload->form_upload('avatar_upload_file');
}
elseif (!empty($this->config['allow_avatar_remote_upload']) && !empty($url))
{
$file = $upload->remote_upload($url);
}
else
{
$error[] = 'NO_AVATAR_SELECTED';
return false;
}
$prefix = $this->config['avatar_salt'] . '_';
$file->clean_filename('avatar', $prefix, $row['id']);
$destination = $this->config['avatar_path'];
// Adjust destination path (no trailing slash)
if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\')
{
$destination = substr($destination, 0, -1);
}
$destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
if ($destination && ($destination[0] == '/' || $destination[0] == "\\"))
{
$destination = '';
}
// Move file and overwrite any existing image
$file->move_file($destination, true);
if (sizeof($file->error))
{
$file->remove();
$error = array_merge($error, $file->error);
return false;
}
return array(
'avatar' => $row['id'] . '_' . time() . '.' . $file->get('extension'),
'avatar_width' => $file->get('width'),
'avatar_height' => $file->get('height'),
);
}
/**
* @inheritdoc
*/
public function prepare_form_acp($user)
{
return array(
'allow_avatar_remote_upload'=> array('lang' => 'ALLOW_REMOTE_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'avatar_filesize' => array('lang' => 'MAX_FILESIZE', 'validate' => 'int:0', 'type' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']),
'avatar_path' => array('lang' => 'AVATAR_STORAGE_PATH', 'validate' => 'rwpath', 'type' => 'text:20:255', 'explain' => true),
);
}
/**
* @inheritdoc
*/
public function delete($row)
{
$ext = substr(strrchr($row['avatar'], '.'), 1);
$filename = $this->phpbb_root_path . $this->config['avatar_path'] . '/' . $this->config['avatar_salt'] . '_' . $row['id'] . '.' . $ext;
if (file_exists($filename))
{
@unlink($filename);
}
return true;
}
/**
* Check if user is able to upload an avatar
*
* @return bool True if user can upload, false if not
*/
protected function can_upload()
{
return (file_exists($this->phpbb_root_path . $this->config['avatar_path']) && phpbb_is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on'));
}
}

View file

@ -0,0 +1,292 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package avatar
*/
class phpbb_avatar_manager
{
/**
* phpBB configuration
* @var phpbb_config
*/
protected $config;
/**
* Array that contains a list of enabled drivers
* @var array
*/
static protected $enabled_drivers = false;
/**
* Array that contains all available avatar drivers which are passed via the
* service container
* @var array
*/
protected $avatar_drivers;
/**
* Service container object
* @var object
*/
protected $container;
/**
* Construct an avatar manager object
*
* @param phpbb_config $config phpBB configuration
* @param array $avatar_drivers Avatar drivers passed via the service container
* @param object $container Container object
*/
public function __construct(phpbb_config $config, $avatar_drivers, $container)
{
$this->config = $config;
$this->avatar_drivers = $avatar_drivers;
$this->container = $container;
}
/**
* Get the driver object specified by the avatar type
*
* @param string $avatar_type Avatar type; by default an avatar's service container name
* @param bool $load_enabled Load only enabled avatars
*
* @return object Avatar driver object
*/
public function get_driver($avatar_type, $load_enabled = true)
{
if (self::$enabled_drivers === false)
{
$this->load_enabled_drivers();
}
$avatar_drivers = ($load_enabled) ? self::$enabled_drivers : $this->get_all_drivers();
// Legacy stuff...
switch ($avatar_type)
{
case AVATAR_GALLERY:
$avatar_type = 'avatar.driver.local';
break;
case AVATAR_UPLOAD:
$avatar_type = 'avatar.driver.upload';
break;
case AVATAR_REMOTE:
$avatar_type = 'avatar.driver.remote';
break;
}
if (!isset($avatar_drivers[$avatar_type]))
{
return null;
}
/*
* There is no need to handle invalid avatar types as the following code
* will cause a ServiceNotFoundException if the type does not exist
*/
$driver = $this->container->get($avatar_type);
return $driver;
}
/**
* Load the list of enabled drivers
* This is executed once and fills self::$enabled_drivers
*/
protected function load_enabled_drivers()
{
if (!empty($this->avatar_drivers))
{
self::$enabled_drivers = array();
foreach ($this->avatar_drivers as $driver)
{
if ($this->is_enabled($driver))
{
self::$enabled_drivers[$driver->get_name()] = $driver->get_name();
}
}
asort(self::$enabled_drivers);
}
}
/**
* Get a list of all avatar drivers
*
* As this function will only be called in the ACP avatar settings page, it
* doesn't make much sense to cache the list of all avatar drivers like the
* list of the enabled drivers.
*
* @return array Array containing a list of all avatar drivers
*/
public function get_all_drivers()
{
$drivers = array();
if (!empty($this->avatar_drivers))
{
foreach ($this->avatar_drivers as $driver)
{
$drivers[$driver->get_name()] = $driver->get_name();
}
asort($drivers);
}
return $drivers;
}
/**
* Get a list of enabled avatar drivers
*
* @return array Array containing a list of the enabled avatar drivers
*/
public function get_enabled_drivers()
{
if (self::$enabled_drivers === false)
{
$this->load_enabled_drivers();
}
return self::$enabled_drivers;
}
/**
* Strip out user_ and group_ prefixes from keys
*
* @param array $row User data or group data
*
* @return array User data or group data with keys that have been
* stripped from the preceding "user_" or "group_"
*/
static public function clean_row($row)
{
$keys = array_keys($row);
$values = array_values($row);
$keys = array_map(array('phpbb_avatar_manager', 'strip_prefix'), $keys);
return array_combine($keys, $values);
}
/**
* Strip prepending user_ or group_ prefix from key
*
* @param string Array key
* @return string Key that has been stripped from its prefix
*/
static protected function strip_prefix($key)
{
return preg_replace('#^(?:user_|group_)#', '', $key);
}
/**
* Clean driver names that are returned from template files
* Underscores are replaced with dots
*
* @param string $name Driver name
*
* @return string Cleaned driver name
*/
static public function clean_driver_name($name)
{
return str_replace('_', '.', $name);
}
/**
* Prepare driver names for use in template files
* Dots are replaced with underscores
*
* @param string $name Clean driver name
*
* @return string Prepared driver name
*/
static public function prepare_driver_name($name)
{
return str_replace('.', '_', $name);
}
/**
* Check if avatar is enabled
*
* @param object $driver Avatar driver object
*
* @return bool True if avatar is enabled, false if it's disabled
*/
public function is_enabled($driver)
{
$config_name = $this->get_driver_config_name($driver);
return $this->config["allow_avatar_{$config_name}"];
}
/**
* Get the settings array for enabling/disabling an avatar driver
*
* @param object $driver Avatar driver object
*
* @return array Array of configuration options as consumed by acp_board
*/
public function get_avatar_settings($driver)
{
$config_name = $this->get_driver_config_name($driver);
return array(
'allow_avatar_' . $config_name => array('lang' => 'ALLOW_' . strtoupper($config_name), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
);
}
/**
* Get the config name of an avatar driver
*
* @param object $driver Avatar driver object
*
* @return string Avatar driver config name
*/
public function get_driver_config_name($driver)
{
return preg_replace('#^phpbb_avatar_driver_#', '', get_class($driver));
}
/**
* Replace "error" strings with their real, localized form
*
* @param phpbb_user phpBB User object
* @param array $error Array containing error strings
* Key values can either be a string with a language key or an array
* that will be passed to vsprintf() with the language key in the
* first array key.
*
* @return array Array containing the localized error strings
*/
public function localize_errors(phpbb_user $user, $error)
{
foreach ($error as $key => $lang)
{
if (is_array($lang))
{
$lang_key = array_shift($lang);
$error[$key] = vsprintf($user->lang($lang_key), $lang);
}
else
{
$error[$key] = $user->lang("$lang");
}
}
return $error;
}
}

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 // Remove extra spaces and tabs
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query); $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 * result to persistent storage. In other words, there is no need
* to call save() afterwards. * to call save() afterwards.
* *
* @param phpbb_db_driver $db Database connection
* @param string $query SQL query, should be used for generating storage key * @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 * @param mixed $query_result The result from dbal::sql_query, to be passed to
* dbal::sql_fetchrow to get all rows and store them * 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 * representing the query should be returned. Otherwise
* the original $query_result should be returned. * 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. * 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 // Remove extra spaces and tabs
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query); $query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
$hash = md5($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; return $query_result;
} }

View file

@ -21,16 +21,57 @@ if (!defined('IN_PHPBB'))
*/ */
class phpbb_cache_service 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 * Creates a cache service around a cache driver
* *
* @param phpbb_cache_driver_interface $driver The 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->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() function obtain_word_list()
{ {
global $db;
if (($censors = $this->driver->get('_word_censors')) === false) if (($censors = $this->driver->get('_word_censors')) === false)
{ {
$sql = 'SELECT word, replacement $sql = 'SELECT word, replacement
FROM ' . WORDS_TABLE; FROM ' . WORDS_TABLE;
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
$censors = array(); $censors = array();
while ($row = $db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
$censors['match'][] = get_censor_preg_expression($row['word']); $censors['match'][] = get_censor_preg_expression($row['word']);
$censors['replace'][] = $row['replacement']; $censors['replace'][] = $row['replacement'];
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
$this->driver->put('_word_censors', $censors); $this->driver->put('_word_censors', $censors);
} }
@ -93,23 +132,21 @@ class phpbb_cache_service
{ {
if (($icons = $this->driver->get('_icons')) === false) if (($icons = $this->driver->get('_icons')) === false)
{ {
global $db;
// Topic icons // Topic icons
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . ICONS_TABLE . ' FROM ' . ICONS_TABLE . '
ORDER BY icons_order'; ORDER BY icons_order';
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
$icons = array(); $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']]['img'] = $row['icons_url'];
$icons[$row['icons_id']]['width'] = (int) $row['icons_width']; $icons[$row['icons_id']]['width'] = (int) $row['icons_width'];
$icons[$row['icons_id']]['height'] = (int) $row['icons_height']; $icons[$row['icons_id']]['height'] = (int) $row['icons_height'];
$icons[$row['icons_id']]['display'] = (bool) $row['display_on_posting']; $icons[$row['icons_id']]['display'] = (bool) $row['display_on_posting'];
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
$this->driver->put('_icons', $icons); $this->driver->put('_icons', $icons);
} }
@ -124,15 +161,13 @@ class phpbb_cache_service
{ {
if (($ranks = $this->driver->get('_ranks')) === false) if (($ranks = $this->driver->get('_ranks')) === false)
{ {
global $db;
$sql = 'SELECT * $sql = 'SELECT *
FROM ' . RANKS_TABLE . ' FROM ' . RANKS_TABLE . '
ORDER BY rank_min DESC'; ORDER BY rank_min DESC';
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
$ranks = array(); $ranks = array();
while ($row = $db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
if ($row['rank_special']) 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); $this->driver->put('_ranks', $ranks);
} }
@ -169,8 +204,6 @@ class phpbb_cache_service
{ {
if (($extensions = $this->driver->get('_extensions')) === false) if (($extensions = $this->driver->get('_extensions')) === false)
{ {
global $db;
$extensions = array( $extensions = array(
'_allowed_post' => array(), '_allowed_post' => array(),
'_allowed_pm' => array(), '_allowed_pm' => array(),
@ -181,9 +214,9 @@ class phpbb_cache_service
FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g
WHERE e.group_id = g.group_id WHERE e.group_id = g.group_id
AND (g.allow_group = 1 OR g.allow_in_pm = 1)'; 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'])); $extension = strtolower(trim($row['extension']));
@ -210,7 +243,7 @@ class phpbb_cache_service
$extensions['_allowed_pm'][$extension] = 0; $extensions['_allowed_pm'][$extension] = 0;
} }
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
$this->driver->put('_extensions', $extensions); $this->driver->put('_extensions', $extensions);
} }
@ -275,9 +308,7 @@ class phpbb_cache_service
{ {
if (($bots = $this->driver->get('_bots')) === false) if (($bots = $this->driver->get('_bots')) === false)
{ {
global $db; switch ($this->db->sql_layer)
switch ($db->sql_layer)
{ {
case 'mssql': case 'mssql':
case 'mssql_odbc': case 'mssql_odbc':
@ -303,14 +334,14 @@ class phpbb_cache_service
ORDER BY LENGTH(bot_agent) DESC'; ORDER BY LENGTH(bot_agent) DESC';
break; break;
} }
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
$bots = array(); $bots = array();
while ($row = $db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
$bots[] = $row; $bots[] = $row;
} }
$db->sql_freeresult($result); $this->db->sql_freeresult($result);
$this->driver->put('_bots', $bots); $this->driver->put('_bots', $bots);
} }
@ -323,8 +354,6 @@ class phpbb_cache_service
*/ */
function obtain_cfg_items($style) function obtain_cfg_items($style)
{ {
global $config, $phpbb_root_path;
$parsed_array = $this->driver->get('_cfg_' . $style['style_path']); $parsed_array = $this->driver->get('_cfg_' . $style['style_path']);
if ($parsed_array === false) if ($parsed_array === false)
@ -332,14 +361,14 @@ class phpbb_cache_service
$parsed_array = array(); $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)) if (!file_exists($filename))
{ {
return $parsed_array; 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 // Re-parse cfg file
$parsed_array = parse_cfg_file($filename); $parsed_array = parse_cfg_file($filename);
@ -358,54 +387,20 @@ class phpbb_cache_service
{ {
if (($usernames = $this->driver->get('_disallowed_usernames')) === false) if (($usernames = $this->driver->get('_disallowed_usernames')) === false)
{ {
global $db;
$sql = 'SELECT disallow_username $sql = 'SELECT disallow_username
FROM ' . DISALLOW_TABLE; FROM ' . DISALLOW_TABLE;
$result = $db->sql_query($sql); $result = $this->db->sql_query($sql);
$usernames = array(); $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']), '#')); $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); $this->driver->put('_disallowed_usernames', $usernames);
} }
return $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 = ''; $new_line = '';
$end = strlen($scanline) - ceil($width/2); $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}); $pixel = ord($scanline{$i});

View file

@ -237,8 +237,11 @@ define('ICONS_TABLE', $table_prefix . 'icons');
define('LANG_TABLE', $table_prefix . 'lang'); define('LANG_TABLE', $table_prefix . 'lang');
define('LOG_TABLE', $table_prefix . 'log'); define('LOG_TABLE', $table_prefix . 'log');
define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts'); define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts');
define('MIGRATIONS_TABLE', $table_prefix . 'migrations');
define('MODERATOR_CACHE_TABLE', $table_prefix . 'moderator_cache'); define('MODERATOR_CACHE_TABLE', $table_prefix . 'moderator_cache');
define('MODULES_TABLE', $table_prefix . 'modules'); 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_OPTIONS_TABLE', $table_prefix . 'poll_options');
define('POLL_VOTES_TABLE', $table_prefix . 'poll_votes'); define('POLL_VOTES_TABLE', $table_prefix . 'poll_votes');
define('POSTS_TABLE', $table_prefix . 'posts'); define('POSTS_TABLE', $table_prefix . 'posts');
@ -267,11 +270,13 @@ define('STYLES_TEMPLATE_DATA_TABLE',$table_prefix . 'styles_template_data');
define('STYLES_THEME_TABLE', $table_prefix . 'styles_theme'); define('STYLES_THEME_TABLE', $table_prefix . 'styles_theme');
define('STYLES_IMAGESET_TABLE', $table_prefix . 'styles_imageset'); define('STYLES_IMAGESET_TABLE', $table_prefix . 'styles_imageset');
define('STYLES_IMAGESET_DATA_TABLE',$table_prefix . 'styles_imageset_data'); define('STYLES_IMAGESET_DATA_TABLE',$table_prefix . 'styles_imageset_data');
define('TEAMPAGE_TABLE', $table_prefix . 'teampage');
define('TOPICS_TABLE', $table_prefix . 'topics'); define('TOPICS_TABLE', $table_prefix . 'topics');
define('TOPICS_POSTED_TABLE', $table_prefix . 'topics_posted'); define('TOPICS_POSTED_TABLE', $table_prefix . 'topics_posted');
define('TOPICS_TRACK_TABLE', $table_prefix . 'topics_track'); define('TOPICS_TRACK_TABLE', $table_prefix . 'topics_track');
define('TOPICS_WATCH_TABLE', $table_prefix . 'topics_watch'); define('TOPICS_WATCH_TABLE', $table_prefix . 'topics_watch');
define('USER_GROUP_TABLE', $table_prefix . 'user_group'); define('USER_GROUP_TABLE', $table_prefix . 'user_group');
define('USER_NOTIFICATIONS_TABLE', $table_prefix . 'user_notifications');
define('USERS_TABLE', $table_prefix . 'users'); define('USERS_TABLE', $table_prefix . 'users');
define('WARNINGS_TABLE', $table_prefix . 'warnings'); define('WARNINGS_TABLE', $table_prefix . 'warnings');
define('WORDS_TABLE', $table_prefix . 'words'); 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, '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_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), '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 // 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 phpbb_db_driver $db Database connection
* @param bool $return_statements True if only statements should be returned and no SQL being executed * @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->db = $db;
$this->return_statements = $return_statements; $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. * Gets a list of tables in the database.
* *
@ -674,6 +685,8 @@ class phpbb_db_tools
* Handle passed database update array. * Handle passed database update array.
* Expected structure... * Expected structure...
* Key being one of the following * Key being one of the following
* drop_tables: Drop tables
* add_tables: Add tables
* change_columns: Column changes (only type, not name) * change_columns: Column changes (only type, not name)
* add_columns: Add columns to a table * add_columns: Add columns to a table
* drop_keys: Dropping keys * drop_keys: Dropping keys
@ -1817,6 +1830,22 @@ class phpbb_db_tools
case 'mssql': case 'mssql':
case 'mssqlnative': 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 . ']'; $statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']';
break; break;

View file

@ -206,7 +206,7 @@ class phpbb_db_driver
$query_id = $this->query_result; $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); return $cache->sql_rowseek($rownum, $query_id);
} }
@ -256,7 +256,7 @@ class phpbb_db_driver
$this->sql_rowseek($rownum, $query_id); $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); return $cache->sql_fetchfield($query_id, $field);
} }
@ -822,7 +822,7 @@ class phpbb_db_driver
*/ */
function sql_report($mode, $query = '') function sql_report($mode, $query = '')
{ {
global $cache, $starttime, $phpbb_root_path, $user; global $cache, $starttime, $phpbb_root_path, $phpbb_admin_path, $user;
global $request; global $request;
if (is_object($request) && !$request->variable('explain', false)) if (is_object($request) && !$request->variable('explain', false))
@ -852,7 +852,7 @@ class phpbb_db_driver
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>SQL Report</title> <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> </head>
<body id="errorpage"> <body id="errorpage">
<div id="wrap"> <div id="wrap">

View file

@ -154,7 +154,7 @@ class phpbb_db_driver_firebird extends phpbb_db_driver
} }
$this->last_query_text = $query; $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); $this->sql_add_num_queries($this->query_result);
if ($this->query_result === false) 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->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) 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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_fetchrow($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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_freeresult($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->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); $this->sql_add_num_queries($this->query_result);
if ($this->query_result === false) if ($this->query_result === false)
@ -165,10 +165,10 @@ class phpbb_db_driver_mssql extends phpbb_db_driver
$this->sql_report('stop', $query); $this->sql_report('stop', $query);
} }
if ($cache_ttl) if ($cache && $cache_ttl)
{ {
$this->open_queries[(int) $this->query_result] = $this->query_result; $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) 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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_fetchrow($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; $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); 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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_freeresult($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->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); $this->sql_add_num_queries($this->query_result);
if ($this->query_result === false) if ($this->query_result === false)
@ -194,10 +194,10 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
$this->sql_report('stop', $query); $this->sql_report('stop', $query);
} }
if ($cache_ttl) if ($cache && $cache_ttl)
{ {
$this->open_queries[(int) $this->query_result] = $this->query_result; $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) 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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_fetchrow($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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_freeresult($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->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); $this->sql_add_num_queries($this->query_result);
if ($this->query_result === false) if ($this->query_result === false)
@ -337,7 +337,7 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver
if ($cache_ttl) if ($cache_ttl)
{ {
$this->open_queries[(int) $this->query_result] = $this->query_result; $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) 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->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); $this->sql_add_num_queries($this->query_result);
if ($this->query_result === false) if ($this->query_result === false)
@ -203,10 +203,10 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
$this->sql_report('stop', $query); $this->sql_report('stop', $query);
} }
if ($cache_ttl) if ($cache && $cache_ttl)
{ {
$this->open_queries[(int) $this->query_result] = $this->query_result; $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) 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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_fetchrow($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; $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); 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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_freeresult($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->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); $this->sql_add_num_queries($this->query_result);
if ($this->query_result === false) if ($this->query_result === false)
@ -199,9 +199,9 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
$this->sql_report('stop', $query); $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')) else if (defined('DEBUG'))
@ -256,7 +256,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
$query_id = $this->query_result; $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); return $cache->sql_fetchrow($query_id);
} }
@ -283,7 +283,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
$query_id = $this->query_result; $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); 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; $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); 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->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); $this->sql_add_num_queries($this->query_result);
if ($this->query_result === false) if ($this->query_result === false)
@ -443,10 +443,10 @@ class phpbb_db_driver_oracle extends phpbb_db_driver
$this->sql_report('stop', $query); $this->sql_report('stop', $query);
} }
if ($cache_ttl) if ($cache && $cache_ttl)
{ {
$this->open_queries[(int) $this->query_result] = $this->query_result; $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) 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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_fetchrow($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; $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); 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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_freeresult($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->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); $this->sql_add_num_queries($this->query_result);
if ($this->query_result === false) if ($this->query_result === false)
@ -208,10 +208,10 @@ class phpbb_db_driver_postgres extends phpbb_db_driver
$this->sql_report('stop', $query); $this->sql_report('stop', $query);
} }
if ($cache_ttl) if ($cache && $cache_ttl)
{ {
$this->open_queries[(int) $this->query_result] = $this->query_result; $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) 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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_fetchrow($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; $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); 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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_freeresult($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->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); $this->sql_add_num_queries($this->query_result);
if ($this->query_result === false) if ($this->query_result === false)
@ -149,10 +149,10 @@ class phpbb_db_driver_sqlite extends phpbb_db_driver
$this->sql_report('stop', $query); $this->sql_report('stop', $query);
} }
if ($cache_ttl) if ($cache && $cache_ttl)
{ {
$this->open_queries[(int) $this->query_result] = $this->query_result; $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) 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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_fetchrow($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; $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); 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; $query_id = $this->query_result;
} }
if ($cache->sql_exists($query_id)) if ($cache && $cache->sql_exists($query_id))
{ {
return $cache->sql_freeresult($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);
}
}

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