aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/adm/style/acp_attachments.html22
-rw-r--r--phpBB/composer.json2
-rw-r--r--phpBB/composer.lock109
-rw-r--r--phpBB/config/default/container/services.yml6
-rw-r--r--phpBB/docs/events.md26
-rw-r--r--phpBB/includes/acp/acp_attachments.php24
-rw-r--r--phpBB/includes/acp/acp_users.php2
-rw-r--r--phpBB/includes/functions.php55
-rw-r--r--phpBB/includes/functions_content.php3
-rw-r--r--phpBB/includes/functions_messenger.php12
-rw-r--r--phpBB/includes/functions_privmsgs.php23
-rw-r--r--phpBB/includes/functions_user.php15
-rw-r--r--phpBB/includes/mcp/mcp_main.php16
-rw-r--r--phpBB/includes/ucp/ucp_pm_compose.php10
-rw-r--r--phpBB/includes/ucp/ucp_profile.php3
-rw-r--r--phpBB/language/en/acp/board.php4
-rw-r--r--phpBB/memberlist.php14
-rw-r--r--phpBB/phpbb/captcha/plugins/qa.php2
-rw-r--r--phpBB/phpbb/event/md_exporter.php13
-rw-r--r--phpBB/phpbb/group/helper.php260
-rw-r--r--phpBB/phpbb/search/fulltext_mysql.php14
-rw-r--r--phpBB/posting.php33
-rw-r--r--phpBB/styles/prosilver/template/mcp_move.html2
-rw-r--r--phpBB/styles/prosilver/template/posting_attach_body.html2
-rw-r--r--phpBB/styles/prosilver/theme/plupload.css4
-rw-r--r--phpBB/viewtopic.php32
-rw-r--r--tests/group/helper_get_name_string_test.php115
-rw-r--r--tests/group/helper_get_name_test.php31
-rw-r--r--tests/group/helper_get_rank_test.php43
-rw-r--r--tests/group/helper_test.php68
-rw-r--r--tests/group/helper_test_case.php123
-rw-r--r--tests/notification/group_request_test.php16
32 files changed, 893 insertions, 211 deletions
diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html
index 868e256ef5..6129d6a1a5 100644
--- a/phpBB/adm/style/acp_attachments.html
+++ b/phpBB/adm/style/acp_attachments.html
@@ -421,17 +421,25 @@
</tr>
</thead>
<tbody>
- <!-- BEGIN attachments -->
+ {% for attachments in attachments %}
<tr>
<td>
- <!-- IF attachments.S_IN_MESSAGE -->{L_EXTENSION_GROUP}{L_COLON} <strong><!-- IF attachments.EXT_GROUP_NAME -->{attachments.EXT_GROUP_NAME}<!-- ELSE -->{L_NO_EXT_GROUP}<!-- ENDIF --></strong><br />{attachments.L_DOWNLOAD_COUNT}<br />{L_IN} {L_PRIVATE_MESSAGE}
- <!-- ELSE --><a href="{attachments.U_FILE}" style="font-weight: bold;">{attachments.REAL_FILENAME}</a><br /><!-- IF attachments.COMMENT -->{attachments.COMMENT}<br /><!-- ENDIF -->{attachments.L_DOWNLOAD_COUNT}<br />{L_TOPIC}{L_COLON} <a href="{attachments.U_VIEW_TOPIC}">{attachments.TOPIC_TITLE}</a><!-- ENDIF -->
+ {{ lang('EXTENSION_GROUP') ~ lang('COLON') }} <strong>{{ attachments.EXT_GROUP_NAME }}</strong>
+ {% if attachments.S_IN_MESSAGE %}
+ <br>{{ attachments.L_DOWNLOAD_COUNT }}
+ <br>{{ lang('IN') }} {{ lang('PRIVATE_MESSAGE') }}
+ {% else %}
+ <br><a href="{{ attachments.U_FILE }}"><strong>{{ attachments.REAL_FILENAME }}</strong></a>
+ {% if attachments.COMMENT %}<br>{{ attachments.COMMENT }}{% endif %}
+ <br>{{ attachments.L_DOWNLOAD_COUNT }}
+ <br>{{ lang('TOPIC') ~ lang('COLON') }} <a href="{{ attachments.U_VIEW_TOPIC }}">{{ attachments.TOPIC_TITLE }}</a>
+ {% endif %}
</td>
- <td>{attachments.FILETIME}<br />{L_POST_BY_AUTHOR} {attachments.ATTACHMENT_POSTER}</td>
- <td class="centered-text">{attachments.FILESIZE}</td>
- <td class="centered-text"><input type="checkbox" class="radio" name="delete[{attachments.ATTACH_ID}]" /></td>
+ <td>{{ attachments.FILETIME }}<br>{{ lang('POST_BY_AUTHOR') }} {{ attachments.ATTACHMENT_POSTER }}</td>
+ <td class="centered-text">{{ attachments.FILESIZE }}</td>
+ <td class="centered-text"><input type="checkbox" class="radio" name="delete[{{ attachments.ATTACH_ID }}]" /></td>
</tr>
- <!-- END attachments -->
+ {% endfor %}
</tbody>
</table>
<!-- ELSE -->
diff --git a/phpBB/composer.json b/phpBB/composer.json
index d192fd57c8..33655b865f 100644
--- a/phpBB/composer.json
+++ b/phpBB/composer.json
@@ -31,7 +31,7 @@
"guzzlehttp/guzzle": "~5.3",
"lusitanian/oauth": "^0.8.1",
"marc1706/fast-image-size": "^1.1",
- "paragonie/random_compat": "^1.4",
+ "paragonie/random_compat": "^2.0",
"patchwork/utf8": "^1.1",
"s9e/text-formatter": "^1.3",
"symfony/config": "^2.8",
diff --git a/phpBB/composer.lock b/phpBB/composer.lock
index 7d4f355e64..d2a95fd8a3 100644
--- a/phpBB/composer.lock
+++ b/phpBB/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "6daa2f5f7a161377dee1835bd4d5b463",
+ "content-hash": "cd42964227d699a6923798e33eab3dd5",
"packages": [
{
"name": "bantu/ini-get-wrapper",
@@ -342,7 +342,7 @@
"oauth",
"security"
],
- "time": "2018-02-14T22:37:14+00:00"
+ "time": "2016-07-12T22:15:00+00:00"
},
{
"name": "marc1706/fast-image-size",
@@ -461,16 +461,16 @@
},
{
"name": "paragonie/random_compat",
- "version": "v1.4.3",
+ "version": "v2.0.18",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
- "reference": "9b3899e3c3ddde89016f576edb8c489708ad64cd"
+ "reference": "0a58ef6e3146256cc3dc7cc393927bcc7d1b72db"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/paragonie/random_compat/zipball/9b3899e3c3ddde89016f576edb8c489708ad64cd",
- "reference": "9b3899e3c3ddde89016f576edb8c489708ad64cd",
+ "url": "https://api.github.com/repos/paragonie/random_compat/zipball/0a58ef6e3146256cc3dc7cc393927bcc7d1b72db",
+ "reference": "0a58ef6e3146256cc3dc7cc393927bcc7d1b72db",
"shasum": ""
},
"require": {
@@ -502,10 +502,11 @@
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
"keywords": [
"csprng",
+ "polyfill",
"pseudorandom",
"random"
],
- "time": "2018-04-04T21:48:54+00:00"
+ "time": "2019-01-03T20:59:08+00:00"
},
{
"name": "patchwork/utf8",
@@ -727,7 +728,7 @@
},
{
"name": "symfony/config",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
@@ -784,7 +785,7 @@
},
{
"name": "symfony/console",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
@@ -845,7 +846,7 @@
},
{
"name": "symfony/debug",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
@@ -902,16 +903,16 @@
},
{
"name": "symfony/dependency-injection",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/dependency-injection.git",
- "reference": "a2f40df187f0053bc361bcea3b27ff2b85744d9f"
+ "reference": "c306198fee8f872a8f5f031e6e4f6f83086992d8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/a2f40df187f0053bc361bcea3b27ff2b85744d9f",
- "reference": "a2f40df187f0053bc361bcea3b27ff2b85744d9f",
+ "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/c306198fee8f872a8f5f031e6e4f6f83086992d8",
+ "reference": "c306198fee8f872a8f5f031e6e4f6f83086992d8",
"shasum": ""
},
"require": {
@@ -961,11 +962,11 @@
],
"description": "Symfony DependencyInjection Component",
"homepage": "https://symfony.com",
- "time": "2018-11-11T11:18:13+00:00"
+ "time": "2019-04-16T11:33:46+00:00"
},
{
"name": "symfony/event-dispatcher",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
@@ -1025,7 +1026,7 @@
},
{
"name": "symfony/filesystem",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
@@ -1075,7 +1076,7 @@
},
{
"name": "symfony/finder",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
@@ -1124,16 +1125,16 @@
},
{
"name": "symfony/http-foundation",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
- "reference": "d0ab719bedc9fc6748a95b2dcb04137292a27b92"
+ "reference": "746f8d3638bf46ee8b202e62f2b214c3d61fb06a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/http-foundation/zipball/d0ab719bedc9fc6748a95b2dcb04137292a27b92",
- "reference": "d0ab719bedc9fc6748a95b2dcb04137292a27b92",
+ "url": "https://api.github.com/repos/symfony/http-foundation/zipball/746f8d3638bf46ee8b202e62f2b214c3d61fb06a",
+ "reference": "746f8d3638bf46ee8b202e62f2b214c3d61fb06a",
"shasum": ""
},
"require": {
@@ -1175,20 +1176,20 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
- "time": "2018-11-25T11:27:05+00:00"
+ "time": "2019-04-16T10:00:53+00:00"
},
{
"name": "symfony/http-kernel",
- "version": "v2.8.49",
+ "version": "v2.8.51",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
- "reference": "3df0207d4c973eb9c91b38a608aef4654dc256fa"
+ "reference": "a01e2b4b267fda24dba9b06cd1c575ca87a51ad2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/http-kernel/zipball/3df0207d4c973eb9c91b38a608aef4654dc256fa",
- "reference": "3df0207d4c973eb9c91b38a608aef4654dc256fa",
+ "url": "https://api.github.com/repos/symfony/http-kernel/zipball/a01e2b4b267fda24dba9b06cd1c575ca87a51ad2",
+ "reference": "a01e2b4b267fda24dba9b06cd1c575ca87a51ad2",
"shasum": ""
},
"require": {
@@ -1259,7 +1260,7 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
- "time": "2018-12-06T14:45:07+00:00"
+ "time": "2019-04-17T16:42:28+00:00"
},
{
"name": "symfony/polyfill-ctype",
@@ -1494,16 +1495,16 @@
},
{
"name": "symfony/proxy-manager-bridge",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/proxy-manager-bridge.git",
- "reference": "9c5f8d58e9c8017affdbeaec86c89d558aee4ec8"
+ "reference": "40802595fea26ada845ed58124d8000a13dd4c6f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/proxy-manager-bridge/zipball/9c5f8d58e9c8017affdbeaec86c89d558aee4ec8",
- "reference": "9c5f8d58e9c8017affdbeaec86c89d558aee4ec8",
+ "url": "https://api.github.com/repos/symfony/proxy-manager-bridge/zipball/40802595fea26ada845ed58124d8000a13dd4c6f",
+ "reference": "40802595fea26ada845ed58124d8000a13dd4c6f",
"shasum": ""
},
"require": {
@@ -1544,11 +1545,11 @@
],
"description": "Symfony ProxyManager Bridge",
"homepage": "https://symfony.com",
- "time": "2018-11-11T11:18:13+00:00"
+ "time": "2019-04-16T11:33:46+00:00"
},
{
"name": "symfony/routing",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
@@ -1622,7 +1623,7 @@
},
{
"name": "symfony/twig-bridge",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/twig-bridge.git",
@@ -1707,7 +1708,7 @@
},
{
"name": "symfony/yaml",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
@@ -1757,16 +1758,16 @@
},
{
"name": "twig/twig",
- "version": "v1.39.1",
+ "version": "v1.42.2",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
- "reference": "23e7b6f0cfa1d7ba3de69f30d8e05cf957412fec"
+ "reference": "21707d6ebd05476854805e4f91b836531941bcd4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/twigphp/Twig/zipball/23e7b6f0cfa1d7ba3de69f30d8e05cf957412fec",
- "reference": "23e7b6f0cfa1d7ba3de69f30d8e05cf957412fec",
+ "url": "https://api.github.com/repos/twigphp/Twig/zipball/21707d6ebd05476854805e4f91b836531941bcd4",
+ "reference": "21707d6ebd05476854805e4f91b836531941bcd4",
"shasum": ""
},
"require": {
@@ -1776,12 +1777,12 @@
"require-dev": {
"psr/container": "^1.0",
"symfony/debug": "^2.7",
- "symfony/phpunit-bridge": "^3.4.19|^4.1.8"
+ "symfony/phpunit-bridge": "^3.4.19|^4.1.8|^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.39-dev"
+ "dev-master": "1.42-dev"
}
},
"autoload": {
@@ -1819,7 +1820,7 @@
"keywords": [
"templating"
],
- "time": "2019-04-16T17:12:57+00:00"
+ "time": "2019-06-18T15:35:16+00:00"
},
{
"name": "zendframework/zend-code",
@@ -2362,16 +2363,16 @@
},
{
"name": "phpspec/prophecy",
- "version": "1.8.0",
+ "version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
- "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06"
+ "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06",
- "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06",
+ "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76",
+ "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76",
"shasum": ""
},
"require": {
@@ -2392,8 +2393,8 @@
}
},
"autoload": {
- "psr-0": {
- "Prophecy\\": "src/"
+ "psr-4": {
+ "Prophecy\\": "src/Prophecy"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -2421,7 +2422,7 @@
"spy",
"stub"
],
- "time": "2018-08-05T17:53:17+00:00"
+ "time": "2019-06-13T12:50:23+00:00"
},
{
"name": "phpunit/dbunit",
@@ -3416,7 +3417,7 @@
},
{
"name": "symfony/browser-kit",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/browser-kit.git",
@@ -3473,7 +3474,7 @@
},
{
"name": "symfony/css-selector",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
@@ -3526,7 +3527,7 @@
},
{
"name": "symfony/dom-crawler",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
@@ -3583,7 +3584,7 @@
},
{
"name": "symfony/process",
- "version": "v2.8.49",
+ "version": "v2.8.50",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
diff --git a/phpBB/config/default/container/services.yml b/phpBB/config/default/container/services.yml
index 9bb1d673f4..3ead1e6181 100644
--- a/phpBB/config/default/container/services.yml
+++ b/phpBB/config/default/container/services.yml
@@ -122,7 +122,13 @@ services:
group_helper:
class: phpbb\group\helper
arguments:
+ - '@auth'
+ - '@cache'
+ - '@config'
- '@language'
+ - '@dispatcher'
+ - '@path_helper'
+ - '@user'
log:
class: phpbb\log\log
diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md
index d34ca5eee7..afe4bd7781 100644
--- a/phpBB/docs/events.md
+++ b/phpBB/docs/events.md
@@ -988,6 +988,20 @@ mcp_move_before
* Since: 3.1.10-RC1
* Purpose: Add content before move topic/post form
+mcp_move_destination_forum_after
+===
+* Locations:
+ + styles/prosilver/template/mcp_move.html
+* Since: 3.2.8-RC1
+* Purpose: Add content after the destination select element in the move topic/post form
+
+mcp_move_destination_forum_before
+===
+* Locations:
+ + styles/prosilver/template/mcp_move.html
+* Since: 3.2.8-RC1
+* Purpose: Add content before the destination select element in the move topic/post form
+
mcp_post_additional_options
===
* Locations:
@@ -1740,14 +1754,14 @@ posting_attach_body_file_list_after
* Locations:
+ styles/prosilver/template/posting_attach_body.html
* Since: 3.2.6-RC1
-* Purpose: Add content after attachments list
+* Purpose: Add content after attachments list
posting_attach_body_file_list_before
===
* Locations:
+ styles/prosilver/template/posting_attach_body.html
* Since: 3.2.6-RC1
-* Purpose: Add content before attachments list
+* Purpose: Add content before attachments list
posting_editor_add_panel_tab
===
@@ -2130,14 +2144,14 @@ search_results_header_before
search_results_last_post_author_username_append
===
* Locations:
- + styles/prosilver/template/search_results.html
+ + styles/prosilver/template/search_results.html (2)
* Since: 3.2.4-RC1
* Purpose: Append information to last post author username of member
search_results_last_post_author_username_prepend
===
* Locations:
- + styles/prosilver/template/search_results.html
+ + styles/prosilver/template/search_results.html (2)
* Since: 3.2.4-RC1
* Purpose: Prepend information to last post author username of member
@@ -2672,14 +2686,14 @@ ucp_register_profile_fields_before
viewforum_body_last_post_author_username_append
===
* Locations:
- + styles/prosilver/template/viewforum_body.html
+ + styles/prosilver/template/viewforum_body.html (2)
* Since: 3.2.4-RC1
* Purpose: Append information to last post author username of member
viewforum_body_last_post_author_username_prepend
===
* Locations:
- + styles/prosilver/template/viewforum_body.html
+ + styles/prosilver/template/viewforum_body.html (2)
* Since: 3.2.4-RC1
* Purpose: Prepend information to last post author username of member
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php
index a7035f38b7..94e3660de8 100644
--- a/phpBB/includes/acp/acp_attachments.php
+++ b/phpBB/includes/acp/acp_attachments.php
@@ -27,6 +27,9 @@ class acp_attachments
/** @var \phpbb\config\config */
protected $config;
+ /** @var \phpbb\language\language */
+ protected $language;
+
/** @var ContainerBuilder */
protected $phpbb_container;
@@ -54,6 +57,7 @@ class acp_attachments
$this->id = $id;
$this->db = $db;
$this->config = $config;
+ $this->language = $phpbb_container->get('language');
$this->template = $template;
$this->user = $user;
$this->phpbb_container = $phpbb_container;
@@ -128,7 +132,7 @@ class acp_attachments
$s_assigned_groups = array();
while ($row = $db->sql_fetchrow($result))
{
- $row['group_name'] = (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'];
+ $row['group_name'] = $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) : $row['group_name'];
$s_assigned_groups[$row['cat_id']][] = $row['group_name'];
}
$db->sql_freeresult($result);
@@ -573,7 +577,7 @@ class acp_attachments
$group_id = $db->sql_nextid();
}
- $group_name = (isset($user->lang['EXT_GROUP_' . $group_name])) ? $user->lang['EXT_GROUP_' . $group_name] : $group_name;
+ $group_name = $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($group_name)) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($group_name)) : $group_name;
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_ATTACH_EXTGROUP_' . strtoupper($action), false, array($group_name));
}
@@ -875,7 +879,7 @@ class acp_attachments
'U_EDIT' => $this->u_action . "&amp;action=edit&amp;g={$row['group_id']}",
'U_DELETE' => $this->u_action . "&amp;action=delete&amp;g={$row['group_id']}",
- 'GROUP_NAME' => (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'],
+ 'GROUP_NAME' => $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) : $row['group_name'],
'CATEGORY' => $cat_lang[$row['cat_id']],
)
);
@@ -1240,23 +1244,15 @@ class acp_attachments
$display_cat = isset($extensions[$row['extension']]['display_cat']) ? $extensions[$row['extension']]['display_cat'] : ATTACHMENT_CATEGORY_NONE;
$l_downloaded_viewed = ($display_cat == ATTACHMENT_CATEGORY_NONE) ? 'DOWNLOAD_COUNTS' : 'VIEWED_COUNTS';
- // Capitalises the group name and checks if its key exists in the language file
- $up_group_name = utf8_strtoupper($extensions[$row['extension']]['group_name']);
- $ext_group_name = (!empty($up_group_name)) ? (isset($user->lang['EXT_GROUP_' . $up_group_name]) ? $user->lang['EXT_GROUP_' . $up_group_name] : '') : '';
-
$template->assign_block_vars('attachments', array(
'ATTACHMENT_POSTER' => get_username_string('full', (int) $row['poster_id'], (string) $row['username'], (string) $row['user_colour'], (string) $row['username']),
'FILESIZE' => get_formatted_filesize((int) $row['filesize']),
'FILETIME' => $user->format_date((int) $row['filetime']),
- 'REAL_FILENAME' => (!$row['in_message']) ? utf8_basename((string) $row['real_filename']) : '',
- 'PHYSICAL_FILENAME' => utf8_basename((string) $row['physical_filename']),
- 'EXT_GROUP_NAME' => $ext_group_name,
+ 'REAL_FILENAME' => utf8_basename((string) $row['real_filename']),
+ 'EXT_GROUP_NAME' => $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($extensions[$row['extension']]['group_name'])) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($extensions[$row['extension']]['group_name'])) : $extensions[$row['extension']]['group_name'],
'COMMENT' => $comment,
'TOPIC_TITLE' => (!$row['in_message']) ? (string) $row['topic_title'] : '',
'ATTACH_ID' => (int) $row['attach_id'],
- 'POST_ID' => (int) $row['post_msg_id'],
- 'TOPIC_ID' => (int) $row['topic_id'],
- 'POST_IDS' => (!empty($post_ids[$row['attach_id']])) ? (int) $post_ids[$row['attach_id']] : '',
'L_DOWNLOAD_COUNT' => $user->lang($l_downloaded_viewed, (int) $row['download_count']),
@@ -1438,7 +1434,7 @@ class acp_attachments
$group_name = array();
while ($row = $db->sql_fetchrow($result))
{
- $row['group_name'] = (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'];
+ $row['group_name'] = $this->language->is_set('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) ? $this->language->lang('EXT_GROUP_' . utf8_strtoupper($row['group_name'])) : $row['group_name'];
$group_name[] = $row;
}
$db->sql_freeresult($result);
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index 2d1eaadfae..fd4b5e8c24 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -855,7 +855,7 @@ class acp_users
$check_ary += array(
'username' => array(
array('string', false, $config['min_name_chars'], $config['max_name_chars']),
- array('username', $user_row['username'])
+ array('username', $user_row['username'], true)
),
);
}
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 5234c3472d..47c4197d96 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1843,27 +1843,6 @@ function redirect($url, $return = false, $disable_cd_check = false)
garbage_collection();
}
- // Redirect via an HTML form for PITA webservers
- if (@preg_match('#WebSTAR|Xitami#', getenv('SERVER_SOFTWARE')))
- {
- header('Refresh: 0; URL=' . $url);
-
- echo '<!DOCTYPE html>';
- echo '<html dir="' . $user->lang['DIRECTION'] . '" lang="' . $user->lang['USER_LANG'] . '">';
- echo '<head>';
- echo '<meta charset="utf-8">';
- echo '<meta http-equiv="X-UA-Compatible" content="IE=edge">';
- echo '<meta http-equiv="refresh" content="0; url=' . str_replace('&', '&amp;', $url) . '" />';
- echo '<title>' . $user->lang['REDIRECT'] . '</title>';
- echo '</head>';
- echo '<body>';
- echo '<div style="text-align: center;">' . sprintf($user->lang['URL_REDIRECT'], '<a href="' . str_replace('&', '&amp;', $url) . '">', '</a>') . '</div>';
- echo '</body>';
- echo '</html>';
-
- exit;
- }
-
// Behave as per HTTP/1.1 spec for others
header('Location: ' . $url);
exit;
@@ -2158,7 +2137,7 @@ function check_form_key($form_name, $timespan = false)
function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_body.html', $u_action = '')
{
global $user, $template, $db, $request;
- global $config, $language, $phpbb_path_helper;
+ global $config, $language, $phpbb_path_helper, $phpbb_dispatcher;
if (isset($_POST['cancel']))
{
@@ -2255,8 +2234,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
if ($request->is_ajax())
{
$u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id;
- $json_response = new \phpbb\json_response;
- $json_response->send(array(
+ $data = array(
'MESSAGE_BODY' => $template->assign_display('body'),
'MESSAGE_TITLE' => $confirm_title,
'MESSAGE_TEXT' => $confirm_text,
@@ -2264,7 +2242,28 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo
'YES_VALUE' => $language->lang('YES'),
'S_CONFIRM_ACTION' => str_replace('&amp;', '&', $u_action), //inefficient, rewrite whole function
'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields
- ));
+ );
+
+ /**
+ * This event allows an extension to modify the ajax output of confirm box.
+ *
+ * @event core.confirm_box_ajax_before
+ * @var string u_action Action of the form
+ * @var array data Data to be sent
+ * @var string hidden Hidden fields generated by caller
+ * @var string s_hidden_fields Hidden fields generated by this function
+ * @since 3.2.8-RC1
+ */
+ $vars = array(
+ 'u_action',
+ 'data',
+ 'hidden',
+ 's_hidden_fields',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.confirm_box_ajax_before', compact($vars)));
+
+ $json_response = new \phpbb\json_response;
+ $json_response->send($data);
}
if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin'])
@@ -2365,7 +2364,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
}
// Check form key
- if ($password && !check_form_key($form_name))
+ if ($password && !defined('IN_CHECK_BAN') && !check_form_key($form_name))
{
$result = array(
'status' => false,
@@ -4132,9 +4131,9 @@ function phpbb_get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config =
*
* @return string Avatar html
*/
-function phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false)
+function phpbb_get_group_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false)
{
- $row = \phpbb\avatar\manager::clean_row($user_row, 'group');
+ $row = \phpbb\avatar\manager::clean_row($group_row, 'group');
return phpbb_get_avatar($row, $alt, $ignore_config, $lazy);
}
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index a15a03f966..2542be5e02 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -1482,6 +1482,8 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al
* Get username details for placing into templates.
* This function caches all modes on first call, except for no_profile and anonymous user - determined by $user_id.
*
+* @html Username spans and links
+*
* @param string $mode Can be profile (for getting an url to the profile), username (for obtaining the username), colour (for obtaining the user colour), full (for obtaining a html string representing a coloured link to the users profile) or no_profile (the same as full but forcing no profile link)
* @param int $user_id The users id
* @param string $username The users name
@@ -1501,6 +1503,7 @@ function get_username_string($mode, $user_id, $username, $username_colour = '',
{
global $phpbb_root_path, $phpEx;
+ /** @html Username spans and links for usage in the template */
$_profile_cache['base_url'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u={USER_ID}');
$_profile_cache['tpl_noprofile'] = '<span class="username">{USERNAME}</span>';
$_profile_cache['tpl_noprofile_colour'] = '<span style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</span>';
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index f44bcc6fb7..7f8238e1bf 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -1581,6 +1581,14 @@ class smtp_class
*/
protected function starttls()
{
+ global $config;
+
+ // allow SMTPS (what was used by phpBB 3.0) if hostname is prefixed with tls:// or ssl://
+ if (strpos($config['smtp_host'], 'tls://') === 0 || strpos($config['smtp_host'], 'ssl://') === 0)
+ {
+ return true;
+ }
+
if (!function_exists('stream_socket_enable_crypto'))
{
return false;
@@ -1603,7 +1611,9 @@ class smtp_class
if (socket_set_blocking($this->socket, 1))
{
- $result = stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
+ // https://secure.php.net/manual/en/function.stream-socket-enable-crypto.php#119122
+ $crypto = (phpbb_version_compare(PHP_VERSION, '5.6.7', '<')) ? STREAM_CRYPTO_METHOD_TLS_CLIENT : STREAM_CRYPTO_METHOD_SSLv23_CLIENT;
+ $result = stream_socket_enable_crypto($this->socket, true, $crypto);
socket_set_blocking($this->socket, (int) $stream_meta['blocked']);
}
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index a7a4b050fe..baadf5bdee 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -1966,7 +1966,7 @@ function submit_pm($mode, $subject, &$data_ary, $put_in_outbox = true)
*/
function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode = false)
{
- global $db, $user, $template, $phpbb_root_path, $phpEx, $auth;
+ global $db, $user, $template, $phpbb_root_path, $phpEx, $auth, $phpbb_dispatcher;
// Select all receipts and the author from the pm we currently view, to only display their pm-history
$sql = 'SELECT author_id, user_id
@@ -2087,7 +2087,7 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
$previous_history_pm = $prev_id;
}
- $template->assign_block_vars('history_row', array(
+ $template_vars = array(
'MESSAGE_AUTHOR_QUOTE' => (($decoded_message) ? addslashes(get_username_string('username', $author_id, $row['username'], $row['user_colour'], $row['username'])) : ''),
'MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $row['username'], $row['user_colour'], $row['username']),
'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $author_id, $row['username'], $row['user_colour'], $row['username']),
@@ -2109,8 +2109,25 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
'USER_ID' => $row['user_id'],
'U_VIEW_MESSAGE' => "$url&amp;f=$folder_id&amp;p=" . $row['msg_id'],
'U_QUOTE' => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS) ? "$url&amp;mode=compose&amp;action=quote&amp;f=" . $folder_id . "&amp;p=" . $row['msg_id'] : '',
- 'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&amp;mode=compose&amp;action=reply&amp;f=$folder_id&amp;p=" . $row['msg_id'] : '')
+ 'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&amp;mode=compose&amp;action=reply&amp;f=$folder_id&amp;p=" . $row['msg_id'] : ''
);
+
+ /**
+ * Modify the template vars for displaying the message history in private message
+ *
+ * @event core.message_history_modify_template_vars
+ * @var array template_vars Array containing the query
+ * @var array row Array containing the action user row
+ * @since 3.2.8-RC1
+ */
+ $vars = array(
+ 'template_vars',
+ 'row',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.message_history_modify_template_vars', compact($vars)));
+
+ $template->assign_block_vars('history_row', $template_vars);
+
unset($rowset[$i]);
$prev_id = $id;
}
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index fb9241d4aa..3bf4aa16b7 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1732,7 +1732,7 @@ function phpbb_validate_timezone($timezone)
* @return mixed Either false if validation succeeded or a string which will be
* used as the error message (with the variable name appended)
*/
-function validate_username($username, $allowed_username = false)
+function validate_username($username, $allowed_username = false, $allow_all_names = false)
{
global $config, $db, $user, $cache;
@@ -1815,13 +1815,16 @@ function validate_username($username, $allowed_username = false)
return 'USERNAME_TAKEN';
}
- $bad_usernames = $cache->obtain_disallowed_usernames();
-
- foreach ($bad_usernames as $bad_username)
+ if (!$allow_all_names)
{
- if (preg_match('#^' . $bad_username . '$#', $clean_username))
+ $bad_usernames = $cache->obtain_disallowed_usernames();
+
+ foreach ($bad_usernames as $bad_username)
{
- return 'USERNAME_DISALLOWED';
+ if (preg_match('#^' . $bad_username . '$#', $clean_username))
+ {
+ return 'USERNAME_DISALLOWED';
+ }
}
}
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index 4bd783b279..744eaebd7d 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -41,6 +41,22 @@ class mcp_main
$quickmod = ($mode == 'quickmod') ? true : false;
+ /**
+ * Event to perform additional actions before an MCP action is executed.
+ *
+ * @event core.mcp_main_before
+ * @var string action The action that is about to be performed
+ * @var string mode The mode in which the MCP is accessed, e.g. front, forum_view, topic_view, post_details, quickmod
+ * @var boolean quickmod Whether or not the action is performed via QuickMod
+ * @since 3.2.8-RC1
+ */
+ $vars = [
+ 'action',
+ 'mode',
+ 'quickmod',
+ ];
+ extract($phpbb_dispatcher->trigger_event('core.mcp_main_before', compact($vars)));
+
switch ($action)
{
case 'lock':
diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php
index 543db4f889..cb45112b01 100644
--- a/phpBB/includes/ucp/ucp_pm_compose.php
+++ b/phpBB/includes/ucp/ucp_pm_compose.php
@@ -1007,6 +1007,16 @@ function compose_pm($id, $mode, $action, $user_folders = array())
if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !$preview && !$refresh)
{
$message_subject = ((!preg_match('/^Re:/', $message_subject)) ? 'Re: ' : '') . censor_text($message_subject);
+
+ /**
+ * This event allows you to modify the PM subject of the PM being quoted
+ *
+ * @event core.pm_modify_message_subject
+ * @var string message_subject String with the PM subject already censored.
+ * @since 3.2.8-RC1
+ */
+ $vars = array('message_subject');
+ extract($phpbb_dispatcher->trigger_event('core.pm_modify_message_subject', compact($vars)));
}
if ($action == 'forward' && !$preview && !$refresh && !$submit)
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index 9a1284083f..36ab3d0463 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -133,7 +133,6 @@ class ucp_profile
'user_email' => ($auth->acl_get('u_chgemail')) ? $data['email'] : $user->data['user_email'],
'user_email_hash' => ($auth->acl_get('u_chgemail')) ? phpbb_email_hash($data['email']) : $user->data['user_email_hash'],
'user_password' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? $passwords_manager->hash($data['new_password']) : $user->data['user_password'],
- 'user_passchg' => ($auth->acl_get('u_chgpasswd') && $data['new_password']) ? time() : 0,
);
if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $data['username'] != $user->data['username'])
@@ -147,6 +146,8 @@ class ucp_profile
if ($auth->acl_get('u_chgpasswd') && $data['new_password'] && !$passwords_manager->check($data['new_password'], $user->data['user_password']))
{
+ $sql_ary['user_passchg'] = time();
+
$user->reset_login_keys();
$phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_NEW_PASSWORD', false, array(
'reportee_id' => $user->data['user_id'],
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index 378dd3fc38..9b637ff9d3 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -587,8 +587,8 @@ $lang = array_merge($lang, array(
'SMTP_POP_BEFORE_SMTP' => 'POP-BEFORE-SMTP',
'SMTP_PORT' => 'SMTP server port',
'SMTP_PORT_EXPLAIN' => 'Only change this if you know your SMTP server is on a different port.',
- 'SMTP_SERVER' => 'SMTP server address and protocol',
- 'SMTP_SERVER_EXPLAIN' => 'Note that you have to provide the protocol that your server uses. If you are using SSL, this has to be "ssl://your.mailserver.com"',
+ 'SMTP_SERVER' => 'SMTP server address',
+ 'SMTP_SERVER_EXPLAIN' => 'Do not provide a protocol (<samp>ssl://</samp> or <samp>tsl://</samp>) unless your mail host tells you to do so.',
'SMTP_SETTINGS' => 'SMTP settings',
'SMTP_USERNAME' => 'SMTP username',
'SMTP_USERNAME_EXPLAIN' => 'Only enter a username if your SMTP server requires it.',
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index b26d7c8f94..8f4d54b2c7 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -1223,18 +1223,18 @@ switch ($mode)
$avatar_img = phpbb_get_group_avatar($group_row);
// ... same for group rank
- $user_rank_data = array(
+ $group_rank_data = array(
'title' => null,
'img' => null,
'img_src' => null,
);
if ($group_row['group_rank'])
{
- $user_rank_data = phpbb_get_user_rank($group_row, false);
+ $group_rank_data = $group_helper->get_rank($group_row);
- if ($user_rank_data['img'])
+ if ($group_rank_data['img'])
{
- $user_rank_data['img'] .= '<br />';
+ $group_rank_data['img'] .= '<br />';
}
}
// include modules for manage groups link display or not
@@ -1261,11 +1261,11 @@ switch ($mode)
'GROUP_NAME' => $group_helper->get_name($group_row['group_name']),
'GROUP_COLOR' => $group_row['group_colour'],
'GROUP_TYPE' => $user->lang['GROUP_IS_' . $group_row['l_group_type']],
- 'GROUP_RANK' => $user_rank_data['title'],
+ 'GROUP_RANK' => $group_rank_data['title'],
'AVATAR_IMG' => $avatar_img,
- 'RANK_IMG' => $user_rank_data['img'],
- 'RANK_IMG_SRC' => $user_rank_data['img_src'],
+ 'RANK_IMG' => $group_rank_data['img'],
+ 'RANK_IMG_SRC' => $group_rank_data['img_src'],
'U_PM' => ($auth->acl_get('u_sendpm') && $auth->acl_get('u_masspm_group') && $group_row['group_receive_pm'] && $config['allow_privmsg'] && $config['allow_mass_pm']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;g=' . $group_id) : '',
'U_MANAGE' => ($can_manage_group) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_groups&amp;mode=manage') : false,)
diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php
index 70b3f72cc3..966b8d32f2 100644
--- a/phpBB/phpbb/captcha/plugins/qa.php
+++ b/phpBB/phpbb/captcha/plugins/qa.php
@@ -21,7 +21,7 @@ class qa
{
var $confirm_id;
var $answer;
- var $question_ids;
+ var $question_ids = [];
var $question_text;
var $question_lang;
var $question_strict;
diff --git a/phpBB/phpbb/event/md_exporter.php b/phpBB/phpbb/event/md_exporter.php
index c3942bd7ce..1a2d7c989e 100644
--- a/phpBB/phpbb/event/md_exporter.php
+++ b/phpBB/phpbb/event/md_exporter.php
@@ -389,9 +389,16 @@ class md_exporter
$files = explode("\n + ", $file_details);
foreach ($files as $file)
{
+ if (!preg_match('#^([^ ]+)( \([0-9]+\))?$#', $file))
+ {
+ throw new \LogicException("Invalid event instances for file '{$file}' found for event '{$this->current_event}'", 1);
+ }
+
+ list($file) = explode(" ", $file);
+
if (!file_exists($this->path . $file) || substr($file, -5) !== '.html')
{
- throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 1);
+ throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 2);
}
if (($this->filter !== 'adm') && strpos($file, 'styles/prosilver/template/') === 0)
@@ -404,7 +411,7 @@ class md_exporter
}
else
{
- throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 2);
+ throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 3);
}
$this->events_by_file[$file][] = $this->current_event;
@@ -424,7 +431,7 @@ class md_exporter
}
else
{
- throw new \LogicException("Invalid file list found for event '{$this->current_event}'", 2);
+ throw new \LogicException("Invalid file list found for event '{$this->current_event}'", 1);
}
return $files_list;
diff --git a/phpBB/phpbb/group/helper.php b/phpBB/phpbb/group/helper.php
index 5befddfc53..aa3876b325 100644
--- a/phpBB/phpbb/group/helper.php
+++ b/phpBB/phpbb/group/helper.php
@@ -13,19 +13,74 @@
namespace phpbb\group;
+use phpbb\auth\auth;
+use phpbb\cache\service as cache;
+use phpbb\config\config;
+use phpbb\language\language;
+use phpbb\event\dispatcher_interface;
+use phpbb\path_helper;
+use phpbb\user;
+
class helper
{
- /** @var \phpbb\language\language */
+ /** @var auth */
+ protected $auth;
+
+ /** @var cache */
+ protected $cache;
+
+ /** @var config */
+ protected $config;
+
+ /** @var language */
protected $language;
+ /** @var dispatcher_interface */
+ protected $dispatcher;
+
+ /** @var path_helper */
+ protected $path_helper;
+
+ /** @var user */
+ protected $user;
+
+ /** @var string phpBB root path */
+ protected $phpbb_root_path;
+
+ /** @var array Return templates for a group name string */
+ protected $name_strings;
+
/**
* Constructor
*
- * @param \phpbb\language\language $language Language object
+ * @param auth $auth Authentication object
+ * @param cache $cache Cache service object
+ * @param config $config Configuration object
+ * @param language $language Language object
+ * @param dispatcher_interface $dispatcher Event dispatcher object
+ * @param path_helper $path_helper Path helper object
+ * @param user $user User object
*/
- public function __construct(\phpbb\language\language $language)
+ public function __construct(auth $auth, cache $cache, config $config, language $language, dispatcher_interface $dispatcher, path_helper $path_helper, user $user)
{
+ $this->auth = $auth;
+ $this->cache = $cache;
+ $this->config = $config;
$this->language = $language;
+ $this->dispatcher = $dispatcher;
+ $this->path_helper = $path_helper;
+ $this->user = $user;
+
+ $this->phpbb_root_path = $path_helper->get_phpbb_root_path();
+
+ /** @html Group name spans and links for usage in the template */
+ $this->name_strings = array(
+ 'base_url' => "{$path_helper->get_phpbb_root_path()}memberlist.{$path_helper->get_php_ext()}?mode=group&amp;g={GROUP_ID}",
+ 'tpl_noprofile' => '<span class="username">{GROUP_NAME}</span>',
+ 'tpl_noprofile_colour' => '<span class="username-coloured" style="color: {GROUP_COLOUR};">{GROUP_NAME}</span>',
+ 'tpl_profile' => '<a class="username" href="{PROFILE_URL}">{GROUP_NAME}</a>',
+ 'tpl_profile_colour' => '<a class="username-coloured" href="{PROFILE_URL}" style="color: {GROUP_COLOUR};">{GROUP_NAME}</a>',
+ );
}
/**
@@ -37,4 +92,203 @@ class helper
{
return $this->language->is_set('G_' . utf8_strtoupper($group_name)) ? $this->language->lang('G_' . utf8_strtoupper($group_name)) : $group_name;
}
+
+ /**
+ * Get group name details for placing into templates.
+ *
+ * @html Group name spans and links
+ *
+ * @param string $mode Profile (for getting an url to the profile),
+ * group_name (for obtaining the group name),
+ * colour (for obtaining the group colour),
+ * full (for obtaining a coloured group name link to the group's profile),
+ * no_profile (the same as full but forcing no profile link)
+ * @param int $group_id The group id
+ * @param string $group_name The group name
+ * @param string $group_colour The group colour
+ * @param mixed $custom_profile_url optional parameter to specify a profile url. The group id gets appended to this url as &amp;g={group_id}
+ *
+ * @return string A string consisting of what is wanted based on $mode.
+ */
+ public function get_name_string($mode, $group_id, $group_name, $group_colour = '', $custom_profile_url = false)
+ {
+ $s_is_bots = ($group_name === 'BOTS');
+
+ // This switch makes sure we only run code required for the mode
+ switch ($mode)
+ {
+ case 'full':
+ case 'no_profile':
+ case 'colour':
+
+ // Build correct group colour
+ $group_colour = $group_colour ? '#' . $group_colour : '';
+
+ // Return colour
+ if ($mode === 'colour')
+ {
+ $group_name_string = $group_colour;
+ break;
+ }
+
+ // no break;
+
+ case 'group_name':
+
+ // Build correct group name
+ $group_name = $this->get_name($group_name);
+
+ // Return group name
+ if ($mode === 'group_name')
+ {
+ $group_name_string = $group_name;
+ break;
+ }
+
+ // no break;
+
+ case 'profile':
+
+ // Build correct profile url - only show if not anonymous and permission to view profile if registered user
+ // For anonymous the link leads to a login page.
+ if ($group_id && !$s_is_bots && ($this->user->data['user_id'] == ANONYMOUS || $this->auth->acl_get('u_viewprofile')))
+ {
+ $profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&amp;g=' . (int) $group_id : str_replace(array('={GROUP_ID}', '=%7BGROUP_ID%7D'), '=' . (int) $group_id, append_sid($this->name_strings['base_url']));
+ }
+ else
+ {
+ $profile_url = '';
+ }
+
+ // Return profile
+ if ($mode === 'profile')
+ {
+ $group_name_string = $profile_url;
+ break;
+ }
+
+ // no break;
+ }
+
+ if (!isset($group_name_string))
+ {
+ if (($mode === 'full' && empty($profile_url)) || $mode === 'no_profile' || $s_is_bots)
+ {
+ $group_name_string = str_replace(array('{GROUP_COLOUR}', '{GROUP_NAME}'), array($group_colour, $group_name), (!$group_colour) ? $this->name_strings['tpl_noprofile'] : $this->name_strings['tpl_noprofile_colour']);
+ }
+ else
+ {
+ $group_name_string = str_replace(array('{PROFILE_URL}', '{GROUP_COLOUR}', '{GROUP_NAME}'), array($profile_url, $group_colour, $group_name), (!$group_colour) ? $this->name_strings['tpl_profile'] : $this->name_strings['tpl_profile_colour']);
+ }
+ }
+
+ $name_strings = $this->name_strings;
+
+ /**
+ * Use this event to change the output of the group name
+ *
+ * @event core.modify_group_name_string
+ * @var string mode profile|group_name|colour|full|no_profile
+ * @var int group_id The group identifier
+ * @var string group_name The group name
+ * @var string group_colour The group colour
+ * @var string custom_profile_url Optional parameter to specify a profile url.
+ * @var string group_name_string The string that has been generated
+ * @var array name_strings Array of original return templates
+ * @since 3.2.8-RC1
+ */
+ $vars = array(
+ 'mode',
+ 'group_id',
+ 'group_name',
+ 'group_colour',
+ 'custom_profile_url',
+ 'group_name_string',
+ 'name_strings',
+ );
+ extract($this->dispatcher->trigger_event('core.modify_group_name_string', compact($vars)));
+
+ return $group_name_string;
+ }
+
+ /**
+ * Get group rank title and image
+ *
+ * @html Group rank image element
+ *
+ * @param array $group_data The current stored group data
+ *
+ * @return array An associative array containing the rank title (title),
+ * the rank image as full img tag (img) and the rank image source (img_src)
+ */
+ public function get_rank($group_data)
+ {
+ $group_rank_data = array(
+ 'title' => null,
+ 'img' => null,
+ 'img_src' => null,
+ );
+
+ /**
+ * Preparing a group's rank before displaying
+ *
+ * @event core.get_group_rank_before
+ * @var array group_data Array with group's data
+ * @since 3.2.8-RC1
+ */
+
+ $vars = array('group_data');
+ extract($this->dispatcher->trigger_event('core.get_group_rank_before', compact($vars)));
+
+ if (!empty($group_data['group_rank']))
+ {
+ // Only obtain ranks if group rank is set
+ $ranks = $this->cache->obtain_ranks();
+
+ if (isset($ranks['special'][$group_data['group_rank']]))
+ {
+ $rank = $ranks['special'][$group_data['group_rank']];
+
+ $group_rank_data['title'] = $rank['rank_title'];
+
+ $group_rank_data['img_src'] = (!empty($rank['rank_image'])) ? $this->path_helper->update_web_root_path($this->phpbb_root_path . $this->config['ranks_path'] . '/' . $rank['rank_image']) : '';
+
+ /** @html Group rank image element for usage in the template */
+ $group_rank_data['img'] = (!empty($rank['rank_image'])) ? '<img src="' . $group_rank_data['img_src'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : '';
+ }
+ }
+
+ /**
+ * Modify a group's rank before displaying
+ *
+ * @event core.get_group_rank_after
+ * @var array group_data Array with group's data
+ * @var array group_rank_data Group rank data
+ * @since 3.2.8-RC1
+ */
+
+ $vars = array(
+ 'group_data',
+ 'group_rank_data',
+ );
+ extract($this->dispatcher->trigger_event('core.get_group_rank_after', compact($vars)));
+
+ return $group_rank_data;
+ }
+
+ /**
+ * Get group avatar.
+ * Wrapper function for phpbb_get_group_avatar()
+ *
+ * @param array $group_row Row from the groups table
+ * @param string $alt Optional language string for alt tag within image, can be a language key or text
+ * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
+ * @param bool $lazy If true, will be lazy loaded (requires JS)
+ *
+ * @return string Avatar html
+ */
+ function get_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false, $lazy = false)
+ {
+ return phpbb_get_group_avatar($group_row, $alt, $ignore_config, $lazy);
+ }
}
diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php
index 137ed7433d..1105d0892f 100644
--- a/phpBB/phpbb/search/fulltext_mysql.php
+++ b/phpBB/phpbb/search/fulltext_mysql.php
@@ -188,7 +188,7 @@ class fulltext_mysql extends \phpbb\search\base
}
$sql = 'SHOW VARIABLES
- LIKE \'ft\_%\'';
+ LIKE \'%ft\_%\'';
$result = $this->db->sql_query($sql);
$mysql_info = array();
@@ -198,8 +198,16 @@ class fulltext_mysql extends \phpbb\search\base
}
$this->db->sql_freeresult($result);
- $this->config->set('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']);
- $this->config->set('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']);
+ if ($engine === 'MyISAM')
+ {
+ $this->config->set('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']);
+ $this->config->set('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']);
+ }
+ else if ($engine === 'InnoDB')
+ {
+ $this->config->set('fulltext_mysql_max_word_len', $mysql_info['innodb_ft_max_token_size']);
+ $this->config->set('fulltext_mysql_min_word_len', $mysql_info['innodb_ft_min_token_size']);
+ }
return false;
}
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 75085a5635..5089448483 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -222,6 +222,25 @@ if (!$post_data)
trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST');
}
+/**
+* This event allows you to bypass reply/quote test of an unapproved post.
+*
+* @event core.posting_modify_row_data
+* @var array post_data All post data from database
+* @var string mode What action to take if the form has been submitted
+* post|reply|quote|edit|delete|bump|smilies|popup
+* @var int topic_id ID of the topic
+* @var int forum_id ID of the forum
+* @since 3.2.8-RC1
+*/
+$vars = array(
+ 'post_data',
+ 'mode',
+ 'topic_id',
+ 'forum_id',
+);
+extract($phpbb_dispatcher->trigger_event('core.posting_modify_row_data', compact($vars)));
+
// Not able to reply to unapproved posts/topics
// TODO: add more descriptive language key
if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && $post_data['topic_visibility'] != ITEM_APPROVED) || ($mode == 'quote' && $post_data['post_visibility'] != ITEM_APPROVED)))
@@ -1671,6 +1690,20 @@ if ($generate_quote)
if (($mode == 'reply' || $mode == 'quote') && !$submit && !$preview && !$refresh)
{
$post_data['post_subject'] = ((strpos($post_data['post_subject'], 'Re: ') !== 0) ? 'Re: ' : '') . censor_text($post_data['post_subject']);
+
+ $post_subject = $post_data['post_subject'];
+
+ /**
+ * This event allows you to modify the post subject of the post being quoted
+ *
+ * @event core.posting_modify_post_subject
+ * @var string post_subject String with the post subject already censored.
+ * @since 3.2.8-RC1
+ */
+ $vars = array('post_subject');
+ extract($phpbb_dispatcher->trigger_event('core.posting_modify_post_subject', compact($vars)));
+
+ $post_data['post_subject'] = $post_subject;
}
$attachment_data = $message_parser->attachment_data;
diff --git a/phpBB/styles/prosilver/template/mcp_move.html b/phpBB/styles/prosilver/template/mcp_move.html
index 45a9ae83bc..63197ef274 100644
--- a/phpBB/styles/prosilver/template/mcp_move.html
+++ b/phpBB/styles/prosilver/template/mcp_move.html
@@ -43,12 +43,14 @@
<!-- IF ADDITIONAL_MSG --><p>{ADDITIONAL_MSG}</p><!-- ENDIF -->
<fieldset>
+ {% EVENT mcp_move_destination_forum_before %}
<dl class="fields2">
<dt><label>{L_SELECT_DESTINATION_FORUM}{L_COLON}</label></dt>
<dd><select name="to_forum_id">{S_FORUM_SELECT}</select></dd>
<!-- IF S_CAN_LEAVE_SHADOW --><dd><label for="move_leave_shadow"><input type="checkbox" name="move_leave_shadow" id="move_leave_shadow" />{L_LEAVE_SHADOW}</label></dd><!-- ENDIF -->
<!-- IF S_CAN_LOCK_TOPIC --><dd><label for="move_lock_topics"><input type="checkbox" name="move_lock_topics" id="move_lock_topics" />{L_LOCK_TOPIC}</label></dd><!-- ENDIF -->
</dl>
+ {% EVENT mcp_move_destination_forum_after %}
<dl class="fields2">
<dt>&nbsp;</dt>
<dd><strong>{MESSAGE_TEXT}</strong></dd>
diff --git a/phpBB/styles/prosilver/template/posting_attach_body.html b/phpBB/styles/prosilver/template/posting_attach_body.html
index b46e9c9175..ff5bfe1b55 100644
--- a/phpBB/styles/prosilver/template/posting_attach_body.html
+++ b/phpBB/styles/prosilver/template/posting_attach_body.html
@@ -34,7 +34,7 @@
</tr>
</thead>
<tbody class="responsive-skip-empty file-list" id="file-list">
- <tr class="attach-row" id="attach-row-tpl">
+ <tr class="attach-row attach-row-tpl" id="attach-row-tpl">
<td class="attach-name">
<span class="file-name ellipsis-text"></span>
<span class="attach-controls">
diff --git a/phpBB/styles/prosilver/theme/plupload.css b/phpBB/styles/prosilver/theme/plupload.css
index f466803964..b1f3ae2da8 100644
--- a/phpBB/styles/prosilver/theme/plupload.css
+++ b/phpBB/styles/prosilver/theme/plupload.css
@@ -3,6 +3,10 @@
margin-bottom: 1em;
}
+.attach-row-tpl {
+ display: none;
+}
+
.file-list td {
vertical-align: middle;
}
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index eb2d52cf61..0c2be8c52e 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -453,6 +453,38 @@ $join_user_sql = array('a' => true, 't' => false, 's' => false);
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
+/**
+* Event to add new sorting options
+*
+* @event core.viewtopic_gen_sort_selects_before
+* @var array limit_days Limit results by time
+* @var array sort_by_text Language strings for sorting options
+* @var array sort_by_sql SQL conditions for sorting options
+* @var array join_user_sql SQL joins required for sorting options
+* @var int sort_days User selected sort days
+* @var string sort_key User selected sort key
+* @var string sort_dir User selected sort direction
+* @var string s_limit_days Initial value of limit days selectbox
+* @var string s_sort_key Initial value of sort key selectbox
+* @var string s_sort_dir Initial value of sort direction selectbox
+* @var string u_sort_param Initial value of sorting form action
+* @since 3.2.8-RC1
+*/
+$vars = array(
+ 'limit_days',
+ 'sort_by_text',
+ 'sort_by_sql',
+ 'join_user_sql',
+ 'sort_days',
+ 'sort_key',
+ 'sort_dir',
+ 's_limit_days',
+ 's_sort_key',
+ 's_sort_dir',
+ 'u_sort_param',
+);
+extract($phpbb_dispatcher->trigger_event('core.viewtopic_gen_sort_selects_before', compact($vars)));
+
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir);
// Obtain correct post count and ordering SQL if user has
diff --git a/tests/group/helper_get_name_string_test.php b/tests/group/helper_get_name_string_test.php
new file mode 100644
index 0000000000..c626328dcc
--- /dev/null
+++ b/tests/group/helper_get_name_string_test.php
@@ -0,0 +1,115 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+require_once dirname(__FILE__) . '/helper_test_case.php';
+
+class phpbb_group_helper_get_name_string_test extends phpbb_group_helper_test_case
+{
+
+ public function get_name_string_profile_data()
+ {
+ global $phpbb_root_path, $phpEx;
+
+ return array(
+ array(0, 'Non existing group', '', false, ''),
+ array(2, 'Administrators', 'AA0000', false, "{$phpbb_root_path}memberlist.$phpEx?mode=group&amp;g=2"),
+ array(42, 'Example Group', '', 'http://www.example.org/group.php?mode=show', 'http://www.example.org/group.php?mode=show&amp;g=42'),
+ );
+ }
+
+ /**
+ * @dataProvider get_name_string_profile_data
+ */
+ public function test_get_name_string_profile($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, $this->group_helper->get_name_string('profile', $group_id, $group_name, $group_colour, $custom_profile_url));
+ }
+
+ public function get_name_string_group_name_data()
+ {
+ return array(
+ // Should be fine
+ array(0, 'BOTS', 'AA0000', false, 'Bots'),
+ array(1, 'new_group', '', false, 'Some new group'),
+ array(2, 'group_with_ümlauts', '', 'http://www.example.org/group.php?mode=show', 'Should work'),
+
+ // Should fail and thus return the same
+ array(3, 'not_uppercase', 'FFFFFF', false, 'not_uppercase'),
+ array(4, 'Awesome group', '', false, 'Awesome group'),
+ );
+ }
+
+ /**
+ * @dataProvider get_name_string_group_name_data
+ */
+ public function test_get_name_string_group_name($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, $this->group_helper->get_name_string('group_name', $group_id, $group_name, $group_colour, $custom_profile_url));
+ }
+
+ public function get_name_string_colour_data()
+ {
+ return array(
+ array(0, '', '', false, ''),
+ array(0, '', 'F0F0F0', false, '#F0F0F0'),
+ array(1, 'Guests', '000000', false, '#000000'),
+ array(2, 'Administrators', '', false, ''),
+ );
+ }
+
+ /**
+ * @dataProvider get_name_string_colour_data
+ */
+ public function test_get_name_string_colour($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, $this->group_helper->get_name_string('colour', $group_id, $group_name, $group_colour, $custom_profile_url));
+ }
+
+ public function get_name_string_full_data()
+ {
+ global $phpbb_root_path, $phpEx;
+
+ return array(
+ array(0, 'BOTS', '000000', false, '<span class="username-coloured" style="color: #000000;">Bots</span>'),
+ array(1, 'BOTS', '111111', false, '<span class="username-coloured" style="color: #111111;">Bots</span>'),
+ array(7, 'new_group', 'FFA500', false, '<a class="username-coloured" href="' . $phpbb_root_path . 'memberlist.' . $phpEx . '?mode=group&amp;g=7" style="color: #FFA500;">Some new group</a>'),
+ array(14, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', '<a class="username" href="http://www.example.org/group.php?mode=show&amp;g=14">Awesome group</a>'),
+ );
+ }
+
+ /**
+ * @dataProvider get_name_string_full_data
+ */
+ public function test_get_name_string_full($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, $this->group_helper->get_name_string('full', $group_id, $group_name, $group_colour, $custom_profile_url));
+ }
+
+ public function get_name_string_no_profile_data()
+ {
+ return array(
+ array(0, 'BOTS', '000000', false, '<span class="username-coloured" style="color: #000000;">Bots</span>'),
+ array(1, 'new_group', '', false, '<span class="username">Some new group</span>'),
+ array(2, 'not_uppercase', 'FF0000', false, '<span class="username-coloured" style="color: #FF0000;">not_uppercase</span>'),
+ array(5, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', '<span class="username">Awesome group</span>'),
+ );
+ }
+
+ /**
+ * @dataProvider get_name_string_no_profile_data
+ */
+ public function test_get_name_string_no_profile($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, $this->group_helper->get_name_string('no_profile', $group_id, $group_name, $group_colour, $custom_profile_url));
+ }
+}
diff --git a/tests/group/helper_get_name_test.php b/tests/group/helper_get_name_test.php
new file mode 100644
index 0000000000..b39b2cbedd
--- /dev/null
+++ b/tests/group/helper_get_name_test.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+require_once dirname(__FILE__) . '/helper_test_case.php';
+
+class phpbb_group_helper_get_name_test extends phpbb_group_helper_test_case
+{
+ public function test_get_name()
+ {
+ // They should be totally fine
+ $this->assertEquals('Bots', $this->group_helper->get_name('Bots'));
+ $this->assertEquals('Some new group', $this->group_helper->get_name('new_group'));
+ $this->assertEquals('Should work', $this->group_helper->get_name('group_with_ümlauts'));
+
+ // This should fail (obviously)
+ $this->assertNotEquals('The key does not contain uppercase letters', $this->group_helper->get_name('not_uppercase'));
+
+ // The key doesn't exist so just return group name...
+ $this->assertEquals('Awesome group', $this->group_helper->get_name('Awesome group'));
+ }
+}
diff --git a/tests/group/helper_get_rank_test.php b/tests/group/helper_get_rank_test.php
new file mode 100644
index 0000000000..5efd8ad95e
--- /dev/null
+++ b/tests/group/helper_get_rank_test.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+require_once dirname(__FILE__) . '/helper_test_case.php';
+
+class phpbb_group_helper_get_rank_test extends phpbb_group_helper_test_case
+{
+ public function get_rank_data()
+ {
+ global $phpbb_root_path;
+
+ return array(
+ array(
+ array('group_id' => 0, 'group_rank' => 1),
+ array(
+ 'title' => 'Site admin',
+ 'img' => '<img src="' . $phpbb_root_path . 'images/ranks/siteadmin.png' . '" alt="Site admin" title="Site admin" />',
+ 'img_src' => $phpbb_root_path . 'images/ranks/siteadmin.png',
+ )
+ ),
+ array(array('group_id' => 1, 'group_rank' => 0), array('title' => null, 'img' => null, 'img_src' => null)),
+ array(array('group_id' => 2, 'group_rank' => 2), array('title' => 'Test member', 'img' => '', 'img_src' => '')),
+ );
+ }
+
+ /**
+ * @dataProvider get_rank_data
+ */
+ public function test_get_rank($group_data, $expected)
+ {
+ $this->assertEquals($expected, $this->group_helper->get_rank($group_data));
+ }
+}
diff --git a/tests/group/helper_test.php b/tests/group/helper_test.php
deleted file mode 100644
index 2377a6f47c..0000000000
--- a/tests/group/helper_test.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-/**
- *
- * This file is part of the phpBB Forum Software package.
- *
- * @copyright (c) phpBB Limited <https://www.phpbb.com>
- * @license GNU General Public License, version 2 (GPL-2.0)
- *
- * For full copyright and license information, please see
- * the docs/CREDITS.txt file.
- *
- */
-
-class phpbb_group_helper_test extends phpbb_test_case
-{
- /** @var \phpbb\group\helper */
- protected $group_helper;
-
- public function setUp()
- {
- global $phpbb_root_path, $phpEx;
-
- // Set up language service
- $lang = new \phpbb\language\language(
- new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
- );
-
- // Set up language data for testing
- $reflection_class = new ReflectionClass('\phpbb\language\language');
-
- // Set default language files loaded flag to true
- $loaded_flag = $reflection_class->getProperty('common_language_files_loaded');
- $loaded_flag->setAccessible(true);
- $loaded_flag->setValue($lang, true);
-
- // Set up test language data
- $lang_array = $reflection_class->getProperty('lang');
- $lang_array->setAccessible(true);
- $lang_array->setValue($lang, $this->get_test_language_data_set());
-
- // Set up group helper
- $this->group_helper = new \phpbb\group\helper($lang);
- }
-
- public function test_get_name()
- {
- // They should be totally fine
- $this->assertEquals('Bots', $this->group_helper->get_name('Bots'));
- $this->assertEquals('Some new group', $this->group_helper->get_name('new_group'));
- $this->assertEquals('Should work', $this->group_helper->get_name('group_with_ümlauts'));
-
- // This should fail (obviously)
- $this->assertNotEquals('They key does not contain uppercase letters', $this->group_helper->get_name('not_uppercase'));
-
- // The key doesn't exist so just return group name...
- $this->assertEquals('Awesome group', $this->group_helper->get_name('Awesome group'));
- }
-
- protected function get_test_language_data_set()
- {
- return array(
- 'G_BOTS' => 'Bots',
- 'G_NEW_GROUP' => 'Some new group',
- 'G_not_uppercase' => 'The key does not contain uppercase letters',
- 'G_GROUP_WITH_ÜMLAUTS' => 'Should work',
- );
- }
-}
diff --git a/tests/group/helper_test_case.php b/tests/group/helper_test_case.php
new file mode 100644
index 0000000000..e298770331
--- /dev/null
+++ b/tests/group/helper_test_case.php
@@ -0,0 +1,123 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+class phpbb_group_helper_test_case extends phpbb_test_case
+{
+ /** @var \phpbb\group\helper */
+ protected $group_helper;
+
+ protected function config_defaults()
+ {
+ $defaults = array(
+ 'ranks_path' => 'images/ranks'
+ );
+ return $defaults;
+ }
+
+ protected function get_test_language_data_set()
+ {
+ return array(
+ 'G_BOTS' => 'Bots',
+ 'G_NEW_GROUP' => 'Some new group',
+ 'G_not_uppercase' => 'The key does not contain uppercase letters',
+ 'G_GROUP_WITH_ÜMLAUTS' => 'Should work',
+ );
+ }
+
+ protected function get_test_rank_data_set()
+ {
+ return array(
+ 'special' => array(
+ 1 => array(
+ 'rank_id' => 1,
+ 'rank_title' => 'Site admin',
+ 'rank_special' => 1,
+ 'rank_image' => 'siteadmin.png',
+ ),
+ 2 => array(
+ 'rank_id' => 2,
+ 'rank_title' => 'Test member',
+ 'rank_special' => 1,
+ 'rank_image' => '',
+ )
+ )
+ );
+ }
+
+ protected function setup_engine(array $new_config = array())
+ {
+ global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
+
+ // Set up authentication data for testing
+ $auth = $this->getMock('\phpbb\auth\auth');
+ $auth->expects($this->any())
+ ->method('acl_get')
+ ->with($this->stringContains('_'), $this->anything())
+ ->will($this->returnValueMap(array(
+ array('u_viewprofile', true),
+ )));
+
+ // Set up cache service
+ $cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock();
+ $cache_service->expects($this->any())
+ ->method('obtain_ranks')
+ ->will($this->returnValue($this->get_test_rank_data_set()));
+
+ // Set up configuration
+ $defaults = $this->config_defaults();
+ $config = new \phpbb\config\config(array_merge($defaults, $new_config));
+
+ // Set up language service
+ $lang = new \phpbb\language\language(
+ new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
+ );
+
+ // Set up language data for testing
+ $reflection_class = new ReflectionClass('\phpbb\language\language');
+
+ // Set default language files loaded flag to true
+ $loaded_flag = $reflection_class->getProperty('common_language_files_loaded');
+ $loaded_flag->setAccessible(true);
+ $loaded_flag->setValue($lang, true);
+
+ // Set up test language data
+ $lang_array = $reflection_class->getProperty('lang');
+ $lang_array->setAccessible(true);
+ $lang_array->setValue($lang, $this->get_test_language_data_set());
+
+ // Set up event dispatcher
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+
+ // Set up path helper
+ $path_helper = $this->getMockBuilder('\phpbb\path_helper')
+ ->disableOriginalConstructor()
+ ->setMethods(array())
+ ->getMock();
+ $path_helper->method('get_phpbb_root_path')
+ ->willReturn($phpbb_root_path);
+ $path_helper->method('get_php_ext')
+ ->willReturn($phpEx);
+ $path_helper->method('update_web_root_path')
+ ->will($this->returnArgument(0));
+
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
+ $user->data['user_id'] = ANONYMOUS;
+
+ $this->group_helper = new \phpbb\group\helper($auth, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user);
+ }
+
+ public function setUp()
+ {
+ $this->setup_engine();
+ }
+}
diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php
index 92e758a336..e849c66fa5 100644
--- a/tests/notification/group_request_test.php
+++ b/tests/notification/group_request_test.php
@@ -49,9 +49,23 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
$this->cache->get_driver()
));
$this->container->set('group_helper', new \phpbb\group\helper(
+ $this->getMock('\phpbb\auth\auth'),
+ $this->cache,
+ $this->config,
new \phpbb\language\language(
new phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
- )
+ ),
+ new phpbb_mock_event_dispatcher(),
+ new \phpbb\path_helper(
+ new \phpbb\symfony_request(
+ new phpbb_mock_request()
+ ),
+ new \phpbb\filesystem\filesystem(),
+ $this->getMock('\phpbb\request\request'),
+ $phpbb_root_path,
+ $phpEx
+ ),
+ $this->user
));
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
$phpbb_log = new \phpbb\log\dummy();