aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/adm/style/acp_permissions.html11
-rw-r--r--phpBB/adm/style/admin.css34
-rw-r--r--phpBB/adm/style/permission_mask.html20
-rw-r--r--phpBB/adm/style/tooltip.js304
-rw-r--r--phpBB/assets/javascript/core.js15
-rw-r--r--phpBB/docs/CREDITS.txt1
-rw-r--r--phpBB/docs/events.md56
-rw-r--r--phpBB/includes/acp/auth.php34
-rw-r--r--phpBB/includes/functions.php26
-rw-r--r--phpBB/includes/functions_compatibility.php5
-rw-r--r--phpBB/phpbb/di/container_builder.php3
-rw-r--r--phpBB/phpbb/notification/type/admin_activate_user.php2
-rw-r--r--phpBB/phpbb/notification/type/group_request.php2
-rw-r--r--phpBB/phpbb/notification/type/pm.php2
-rw-r--r--phpBB/phpbb/notification/type/post.php2
-rw-r--r--phpBB/phpbb/notification/type/report_pm.php2
-rw-r--r--phpBB/phpbb/notification/type/report_pm_closed.php2
-rw-r--r--phpBB/phpbb/notification/type/report_post.php2
-rw-r--r--phpBB/phpbb/notification/type/report_post_closed.php2
-rw-r--r--phpBB/phpbb/notification/type/topic.php2
-rw-r--r--phpBB/phpbb/user_loader.php5
-rw-r--r--phpBB/posting.php13
-rw-r--r--tests/functional/posting_test.php22
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php20
24 files changed, 337 insertions, 250 deletions
diff --git a/phpBB/adm/style/acp_permissions.html b/phpBB/adm/style/acp_permissions.html
index 6dc9dca2e7..004027df41 100644
--- a/phpBB/adm/style/acp_permissions.html
+++ b/phpBB/adm/style/acp_permissions.html
@@ -327,14 +327,9 @@
<br class="responsive-hide" /><br class="responsive-hide" />
<!-- include tooltip file -->
- <script type="text/javascript" src="style/tooltip.js"></script>
- <script type="text/javascript">
- // <![CDATA[
- window.onload = function(){enable_tooltips_select('set-permissions', '{LA_ROLE_DESCRIPTION}', 'role')};
- // ]]>
- </script>
-
- <form id="set-permissions" method="post" action="{U_ACTION}">
+ <!-- INCLUDEJS tooltip.js -->
+
+ <form id="set-permissions" method="post" action="{U_ACTION}" data-role-description="{L_ROLE_DESCRIPTION}">
{S_HIDDEN_FIELDS}
diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css
index b03cb0ba24..145bcfaec1 100644
--- a/phpBB/adm/style/admin.css
+++ b/phpBB/adm/style/admin.css
@@ -1858,6 +1858,7 @@ li.pagination ul {
color: #000;
text-align: center;
border: 1px solid #AAA;
+ opacity: .95;
}
.tooltip span.top {
@@ -2435,6 +2436,39 @@ fieldset.permissions .padding {
display: none !important;
}
+.roles-options > .dropdown {
+ left: auto;
+ top: 3em;
+ width: 250px;
+}
+
+.roles-options {
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ -o-user-select: none;
+ user-select: none;
+ width: 250px;
+}
+
+.roles-options > span {
+ border: 1px solid #DEDEDE;
+ border-radius: 3px;
+ padding: 4px;
+ width: 250px;
+ display: block;
+ background: url('../images/arrow_down.gif') no-repeat 245px .7em;
+}
+
+.roles-options li {
+ list-style: none;
+}
+
+.roles-highlight {
+ background-color: #1e90ff;
+ color: #fff;
+}
+
/* Classes for additional tasks
---------------------------------------- */
diff --git a/phpBB/adm/style/permission_mask.html b/phpBB/adm/style/permission_mask.html
index 7b5c071693..347da3181e 100644
--- a/phpBB/adm/style/permission_mask.html
+++ b/phpBB/adm/style/permission_mask.html
@@ -39,11 +39,23 @@
</div>
<dl class="permissions-simple">
<dt style="width: 20%"><label for="role{p_mask.S_ROW_COUNT}{p_mask.f_mask.S_ROW_COUNT}">{L_ROLE}{L_COLON}</label></dt>
- <!-- IF p_mask.f_mask.S_ROLE_OPTIONS -->
- <dd style="margin-{S_CONTENT_FLOW_BEGIN}{L_COLON} 20%"><select id="role{p_mask.S_ROW_COUNT}{p_mask.f_mask.S_ROW_COUNT}" name="role[{p_mask.f_mask.UG_ID}][{p_mask.f_mask.FORUM_ID}]" onchange="set_role_settings(this.options[selectedIndex].value, 'advanced{p_mask.S_ROW_COUNT}{p_mask.f_mask.S_ROW_COUNT}'); init_colours('{p_mask.S_ROW_COUNT}{p_mask.f_mask.S_ROW_COUNT}')">{p_mask.f_mask.S_ROLE_OPTIONS}</select></dd>
- <!-- ELSE -->
+ {% if role_options %}
+ <dd style="margin-{S_CONTENT_FLOW_BEGIN}{L_COLON} 20%">
+ <div class="dropdown-container dropdown-button-control roles-options" data-alt-text="{LA_ROLE_DESCRIPTION}">
+ <span title="Roles" class="button icon-button tools-icon dropdown-trigger dropdown-select">{L_NO_ROLE_ASSIGNED}</span>
+ <div class="dropdown hidden">
+ <ul class="dropdown-contents" id="role{p_mask.S_ROW_COUNT}{p_mask.f_mask.S_ROW_COUNT}" >
+ {% for role in loops.role_options %}
+ <li data-id="{{ role.ID }}" data-target-id="advanced{p_mask.S_ROW_COUNT}{p_mask.f_mask.S_ROW_COUNT}" data-title="{{ role.TITLE }}"{% if role.SELECTED == true %} data-selected="{{ role.SELECTED }}"{% endif %}>{{ role.ROLE_NAME }}</li>
+ {% endfor %}
+ </ul>
+ </div>
+ <input type="hidden" name="role[{p_mask.f_mask.UG_ID}][{p_mask.f_mask.FORUM_ID}]"{% if S_ROLE_ID %}value="{{ S_ROLE_ID }}"{% endif %} />
+ </div>
+ </dd>
+ {% else %}
<dd>{L_NO_ROLE_AVAILABLE}</dd>
- <!-- ENDIF -->
+ {% endif %}
</dl>
<!-- ENDIF -->
diff --git a/phpBB/adm/style/tooltip.js b/phpBB/adm/style/tooltip.js
index 3a89008706..68964034f0 100644
--- a/phpBB/adm/style/tooltip.js
+++ b/phpBB/adm/style/tooltip.js
@@ -10,206 +10,196 @@ phpBB Development Team:
- further adjustements
*/
-var head_text, tooltip_mode;
+(function($) { // Avoid conflicts with other libraries
-/**
-* Enable tooltip replacements for links
-*/
-function enable_tooltips_link(id, headline, sub_id) {
- var links, i, hold;
-
- head_text = headline;
-
- if (!document.getElementById || !document.getElementsByTagName) {
- return;
- }
-
- hold = document.createElement('span');
- hold.id = '_tooltip_container';
- hold.setAttribute('id', '_tooltip_container');
- hold.style.position = 'absolute';
+'use strict';
- document.getElementsByTagName('body')[0].appendChild(hold);
-
- if (id === null) {
- links = document.getElementsByTagName('a');
- } else {
- links = document.getElementById(id).getElementsByTagName('a');
- }
-
- for (i = 0; i < links.length; i++) {
- if (sub_id) {
- if (links[i].id.substr(0, sub_id.length) === sub_id) {
- prepare(links[i]);
- }
- } else {
- prepare(links[i]);
- }
- }
-
- tooltip_mode = 'link';
-}
+var tooltips = [];
/**
-* Enable tooltip replacements for selects
+ * Enable tooltip replacements for selects
+ * @param {string} id ID tag of select
+ * @param {string} headline Text that should appear on top of tooltip
+ * @param {string} [subId] Sub ID that should only be using tooltips (optional)
*/
-function enable_tooltips_select(id, headline, sub_id) {
- var links, i, hold;
-
- head_text = headline;
-
- if (!document.getElementById || !document.getElementsByTagName) {
- return;
- }
+phpbb.enableTooltipsSelect = function (id, headline, subId) {
+ var $links, hold;
- hold = document.createElement('span');
- hold.id = '_tooltip_container';
- hold.setAttribute('id', '_tooltip_container');
- hold.style.position = 'absolute';
+ hold = $('<span />', {
+ id: '_tooltip_container',
+ css: {
+ position: 'absolute'
+ }
+ });
- document.getElementsByTagName('body')[0].appendChild(hold);
+ $('body').append(hold);
- if (id === null) {
- links = document.getElementsByTagName('option');
+ if (!id) {
+ $links = $('.roles-options li');
} else {
- links = document.getElementById(id).getElementsByTagName('option');
+ $links = $('.roles-options li', '#' + id);
}
- for (i = 0; i < links.length; i++) {
- if (sub_id) {
- if (links[i].parentNode.id.substr(0, sub_id.length) === sub_id) {
- prepare(links[i]);
+ $links.each(function () {
+ var $this = $(this);
+
+ if (subId) {
+ if ($this.parent().attr('id').substr(0, subId.length) === subId) {
+ phpbb.prepareTooltips($this, headline);
}
} else {
- prepare(links[i]);
+ phpbb.prepareTooltips($this, headline);
}
- }
-
- tooltip_mode = 'select';
-}
+ });
+};
/**
-* Prepare elements to replace
+ * Prepare elements to replace
+ *
+ * @param {jQuery} $element Element to prepare for tooltips
+ * @param {string} headText Text heading to display
*/
-function prepare(element) {
- var tooltip, text, desc, title;
+phpbb.prepareTooltips = function ($element, headText) {
+ var $tooltip, text, $desc, $title;
- text = element.getAttribute('title');
+ text = $element.attr('data-title');
if (text === null || text.length === 0) {
return;
}
- element.removeAttribute('title');
- tooltip = create_element('span', 'tooltip');
-
- title = create_element('span', 'top');
- title.appendChild(document.createTextNode(head_text));
- tooltip.appendChild(title);
-
- desc = create_element('span', 'bottom');
- desc.innerHTML = text;
- tooltip.appendChild(desc);
-
- set_opacity(tooltip);
+ $title = $('<span />', {
+ class: 'top',
+ css: {
+ display: 'block'
+ }
+ })
+ .append(document.createTextNode(headText));
+
+ $desc = $('<span />', {
+ class: 'bottom',
+ html: text,
+ css: {
+ display: 'block'
+ }
+ });
- element.tooltip = tooltip;
- element.onmouseover = show_tooltip;
- element.onmouseout = hide_tooltip;
+ $tooltip = $('<span />', {
+ class: 'tooltip',
+ css: {
+ display: 'block'
+ }
+ })
+ .append($title)
+ .append($desc);
- if (tooltip_mode === 'link') {
- element.onmousemove = locate;
- }
-}
+ tooltips[$element.attr('data-id')] = $tooltip;
+ $element.on('mouseover', phpbb.showTooltip);
+ $element.on('mouseout', phpbb.hideTooltip);
+};
/**
-* Show tooltip
+ * Show tooltip
+ *
+ * @param {object} $element Element passed by .on()
*/
-function show_tooltip(e) {
- document.getElementById('_tooltip_container').appendChild(this.tooltip);
- locate(this);
-}
+phpbb.showTooltip = function ($element) {
+ var $this = $($element.target);
+ $('#_tooltip_container').append(tooltips[$this.attr('data-id')]);
+ phpbb.positionTooltip($this);
+};
/**
-* Hide tooltip
+ * Hide tooltip
*/
-function hide_tooltip(e) {
+phpbb.hideTooltip = function () {
var d = document.getElementById('_tooltip_container');
if (d.childNodes.length > 0) {
d.removeChild(d.firstChild);
}
-}
+};
/**
-* Set opacity on tooltip element
+ * Correct positioning of tooltip container
+ *
+ * @param {jQuery} $element Tooltip element that should be positioned
*/
-function set_opacity(element) {
- element.style.filter = 'alpha(opacity:95)';
- element.style.KHTMLOpacity = '0.95';
- element.style.MozOpacity = '0.95';
- element.style.opacity = '0.95';
-}
+phpbb.positionTooltip = function ($element) {
+ var offset;
-/**
-* Create new element
-*/
-function create_element(tag, c) {
- var x = document.createElement(tag);
- x.className = c;
- x.style.display = 'block';
- return x;
-}
-
-/**
-* Correct positioning of tooltip container
-*/
-function locate(e) {
- var posx = 0;
- var posy = 0;
+ $element = $element.parent();
+ offset = $element.offset();
- e = e.parentNode;
+ $('#_tooltip_container').css({
+ top: offset.top + 30,
+ left: offset.left - 205
+ });
+};
- if (e.offsetParent) {
- for (posx = 0, posy = 0; e.offsetParent; e = e.offsetParent) {
- posx += e.offsetLeft;
- posy += e.offsetTop;
+/**
+ * Prepare roles drop down select
+ */
+phpbb.prepareRolesDropdown = function () {
+ var $options = $('.roles-options li');
+ var $rolesOptions = $options.closest('.roles-options');
+ var $span = $rolesOptions.children('span');
+
+ // Prepare highlighting of select options and settings update
+ $options.each(function () {
+ var $this = $(this);
+
+ // Correctly show selected option
+ if (typeof $this.attr('data-selected') !== 'undefined') {
+ $rolesOptions.closest('.roles-options')
+ .children('span')
+ .text($this.text())
+ .attr('data-default', $this.text())
+ .attr('data-default-val', $this.attr('data-id'));
}
- } else {
- posx = e.offsetLeft;
- posy = e.offsetTop;
- }
- if (tooltip_mode === 'link') {
- document.getElementById('_tooltip_container').style.top=(posy+20) + 'px';
- document.getElementById('_tooltip_container').style.left=(posx-20) + 'px';
- } else {
- document.getElementById('_tooltip_container').style.top=(posy+30) + 'px';
- document.getElementById('_tooltip_container').style.left=(posx-205) + 'px';
+ $this.on('mouseover', function () {
+ var $this = $(this);
+ $options.removeClass('roles-highlight');
+ $this.addClass('roles-highlight');
+ }).on('click', function () {
+ var $this = $(this);
+
+ // Update settings
+ set_role_settings($this.attr('data-id'), $this.attr('data-target-id'));
+ init_colours($this.attr('data-target-id').replace('advanced', ''));
+
+ // Set selected setting
+ $rolesOptions.children('span')
+ .text($this.text());
+ $rolesOptions.children('input[type=hidden]')
+ .val($this.attr('data-id'));
+
+ // Trigger hiding of selection options
+ $('body').trigger('click');
+ });
+ });
+
+ // Save default text of drop down if there is no default set yet
+ if (typeof $span.attr('data-default') === 'undefined') {
+ $span.attr('data-default', $span.text());
}
-/*
- if (e == null)
- {
- e = window.event;
- }
+ // Prepare resetting drop down on form reset
+ $options.closest('form').on('reset', function () {
+ $span.text($span.attr('data-default'));
+ $rolesOptions.children('input[type=hidden]')
+ .val($span.attr('data-id'));
+ });
- if (e.pageX || e.pageY)
- {
- posx = e.pageX;
- posy = e.pageY;
- }
- else if (e.clientX || e.clientY)
- {
- if (document.documentElement.scrollTop)
- {
- posx = e.clientX+document.documentElement.scrollLeft;
- posy = e.clientY+document.documentElement.scrollTop;
- }
- else
- {
- posx = e.clientX+document.body.scrollLeft;
- posy = e.clientY+document.body.scrollTop;
- }
- }
-*/
-}
+};
+
+// Run onload functions for RolesDropdown and tooltips
+$(function() {
+ // Enable tooltips
+ phpbb.enableTooltipsSelect('set-permissions', $('#set-permissions').attr('data-role-description'), 'role');
+
+ // Prepare dropdown
+ phpbb.prepareRolesDropdown();
+});
+
+})(jQuery); // Avoid conflicts with other libraries
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index 84e27c3a49..953b6be0bd 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -1608,6 +1608,21 @@ phpbb.registerPageDropdowns = function() {
};
/**
+ * Handle avatars to be lazy loaded.
+ */
+phpbb.lazyLoadAvatars = function loadAvatars() {
+ $('.avatar[data-src]').each(function () {
+ var $avatar = $(this);
+
+ $avatar
+ .attr('src', $avatar.data('src'))
+ .removeAttr('data-src');
+ });
+};
+
+$(window).load(phpbb.lazyLoadAvatars);
+
+/**
* Apply code editor to all textarea elements with data-bbcode attribute
*/
$(function() {
diff --git a/phpBB/docs/CREDITS.txt b/phpBB/docs/CREDITS.txt
index e3f2b325e8..deb36339b0 100644
--- a/phpBB/docs/CREDITS.txt
+++ b/phpBB/docs/CREDITS.txt
@@ -23,6 +23,7 @@ phpBB Project Manager: Marshalrusty (Yuriy Rusko)
phpBB Lead Developer: naderman (Nils Adermann)
phpBB Developers: bantu (Andreas Fischer)
+ CHItA (Máté Bartus)
dhruv.goel92 (Dhruv Goel)
Elsensee (Oliver Schramm)
marc1706 (Marc Alexander)
diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md
index 7836ae08f8..d15f86a6a3 100644
--- a/phpBB/docs/events.md
+++ b/phpBB/docs/events.md
@@ -508,6 +508,34 @@ mcp_post_additional_options
* Since: 3.1.5-RC1
* Purpose: Add content within the list of post moderation actions
+mcp_warn_post_add_warning_field_after
+===
+* Locations:
+ + styles/prosilver/template/mcp_warn_post.html
+* Since: 3.1.0-RC4
+* Purpose: Add content during warning for a post - after add warning field.
+
+mcp_warn_post_add_warning_field_before
+===
+* Locations:
+ + styles/prosilver/template/mcp_warn_post.html
+* Since: 3.1.0-RC4
+* Purpose: Add content during warning for a post - before add warning field.
+
+mcp_warn_user_add_warning_field_after
+===
+* Locations:
+ + styles/prosilver/template/mcp_warn_user.html
+* Since: 3.1.0-RC4
+* Purpose: Add content during warning a user - after add warning field.
+
+mcp_warn_user_add_warning_field_before
+===
+* Locations:
+ + styles/prosilver/template/mcp_warn_user.html
+* Since: 3.1.0-RC4
+* Purpose: Add content during warning a user - before add warning field.
+
memberlist_body_username_append
===
* Locations:
@@ -587,34 +615,6 @@ memberlist_view_user_statistics_before
* Since: 3.1.0-a1
* Purpose: Add entries before the user statistics part of any user profile
-mcp_warn_post_add_warning_field_after
-===
-* Locations:
- + styles/prosilver/template/mcp_warn_post.html
-* Since: 3.1.0-RC4
-* Purpose: Add content during warning for a post - after add warning field.
-
-mcp_warn_post_add_warning_field_before
-===
-* Locations:
- + styles/prosilver/template/mcp_warn_post.html
-* Since: 3.1.0-RC4
-* Purpose: Add content during warning for a post - before add warning field.
-
-mcp_warn_user_add_warning_field_after
-===
-* Locations:
- + styles/prosilver/template/mcp_warn_user.html
-* Since: 3.1.0-RC4
-* Purpose: Add content during warning a user - after add warning field.
-
-mcp_warn_user_add_warning_field_before
-===
-* Locations:
- + styles/prosilver/template/mcp_warn_user.html
-* Since: 3.1.0-RC4
-* Purpose: Add content during warning a user - before add warning field.
-
navbar_header_logged_out_content
===
* Locations:
diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php
index 644b1ac7a5..b13b1ee040 100644
--- a/phpBB/includes/acp/auth.php
+++ b/phpBB/includes/acp/auth.php
@@ -470,7 +470,8 @@ class auth_admin extends \phpbb\auth\auth
// Build role dropdown options
$current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0;
- $s_role_options = '';
+ // Output current role id to template
+ $template->assign_var('S_ROLE_ID', $current_role_id);
@reset($roles);
while (list($role_id, $role_row) = each($roles))
@@ -478,13 +479,12 @@ class auth_admin extends \phpbb\auth\auth
$role_description = (!empty($user->lang[$role_row['role_description']])) ? $user->lang[$role_row['role_description']] : nl2br($role_row['role_description']);
$role_name = (!empty($user->lang[$role_row['role_name']])) ? $user->lang[$role_row['role_name']] : $role_row['role_name'];
- $title = ($role_description) ? ' title="' . $role_description . '"' : '';
- $s_role_options .= '<option value="' . $role_id . '"' . (($role_id == $current_role_id) ? ' selected="selected"' : '') . $title . '>' . $role_name . '</option>';
- }
-
- if ($s_role_options)
- {
- $s_role_options = '<option value="0"' . ((!$current_role_id) ? ' selected="selected"' : '') . ' title="' . htmlspecialchars($user->lang['NO_ROLE_ASSIGNED_EXPLAIN']) . '">' . $user->lang['NO_ROLE_ASSIGNED'] . '</option>' . $s_role_options;
+ $template->assign_block_vars('role_options', array(
+ 'ID' => $role_id,
+ 'ROLE_NAME' => $role_name,
+ 'TITLE' => $role_description,
+ 'SELECTED' => $role_id == $current_role_id,
+ ));
}
if (!$current_role_id && $mode != 'view')
@@ -507,7 +507,6 @@ class auth_admin extends \phpbb\auth\auth
$template->assign_block_vars($tpl_pmask . '.' . $tpl_fmask, array(
'NAME' => $ug_names_ary[$ug_id],
- 'S_ROLE_OPTIONS' => $s_role_options,
'UG_ID' => $ug_id,
'S_CUSTOM' => $s_custom_permissions,
'FORUM_ID' => $forum_id)
@@ -556,7 +555,8 @@ class auth_admin extends \phpbb\auth\auth
// Build role dropdown options
$current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0;
- $s_role_options = '';
+ // Output current role id to template
+ $template->assign_var('S_ROLE_ID', $current_role_id);
@reset($roles);
while (list($role_id, $role_row) = each($roles))
@@ -564,13 +564,12 @@ class auth_admin extends \phpbb\auth\auth
$role_description = (!empty($user->lang[$role_row['role_description']])) ? $user->lang[$role_row['role_description']] : nl2br($role_row['role_description']);
$role_name = (!empty($user->lang[$role_row['role_name']])) ? $user->lang[$role_row['role_name']] : $role_row['role_name'];
- $title = ($role_description) ? ' title="' . $role_description . '"' : '';
- $s_role_options .= '<option value="' . $role_id . '"' . (($role_id == $current_role_id) ? ' selected="selected"' : '') . $title . '>' . $role_name . '</option>';
- }
-
- if ($s_role_options)
- {
- $s_role_options = '<option value="0"' . ((!$current_role_id) ? ' selected="selected"' : '') . ' title="' . htmlspecialchars($user->lang['NO_ROLE_ASSIGNED_EXPLAIN']) . '">' . $user->lang['NO_ROLE_ASSIGNED'] . '</option>' . $s_role_options;
+ $template->assign_block_vars('role_options', array(
+ 'ID' => $role_id,
+ 'ROLE_NAME' => $role_name,
+ 'TITLE' => $role_description,
+ 'SELECTED' => $role_id == $current_role_id,
+ ));
}
if (!$current_role_id && $mode != 'view')
@@ -594,7 +593,6 @@ class auth_admin extends \phpbb\auth\auth
$template->assign_block_vars($tpl_pmask . '.' . $tpl_fmask, array(
'NAME' => ($forum_id == 0) ? $forum_names_ary[0] : $forum_names_ary[$forum_id]['forum_name'],
'PADDING' => ($forum_id == 0) ? '' : $forum_names_ary[$forum_id]['padding'],
- 'S_ROLE_OPTIONS' => $s_role_options,
'S_CUSTOM' => $s_custom_permissions,
'UG_ID' => $ug_id,
'FORUM_ID' => $forum_id)
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index aeabe751aa..6a1a50952f 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -3987,10 +3987,11 @@ function phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config
* @param array $row Row cleaned by \phpbb\avatar\manager::clean_row
* @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 phpbb_get_avatar($row, $alt, $ignore_config = false)
+function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false)
{
global $user, $config, $cache, $phpbb_root_path, $phpEx;
global $request;
@@ -4029,7 +4030,28 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false)
if (!empty($avatar_data['src']))
{
- $html = '<img src="' . $avatar_data['src'] . '" ' .
+ if ($lazy)
+ {
+ // Determine board url - we may need it later
+ $board_url = generate_board_url() . '/';
+ // This path is sent with the base template paths in the assign_vars()
+ // call below. We need to correct it in case we are accessing from a
+ // controller because the web paths will be incorrect otherwise.
+ $phpbb_path_helper = $phpbb_container->get('path_helper');
+ $corrected_path = $phpbb_path_helper->get_web_root_path();
+
+ $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path;
+
+ $theme = "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme';
+
+ $src = 'src="' . $theme . '/images/no_avatar.gif" data-src="' . $avatar_data['src'] . '"';
+ }
+ else
+ {
+ $src = 'src="' . $avatar_data['src'] . '"';
+ }
+
+ $html = '<img class="avatar" ' . $src .
($avatar_data['width'] ? ('width="' . $avatar_data['width'] . '" ') : '') .
($avatar_data['height'] ? ('height="' . $avatar_data['height'] . '" ') : '') .
'alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php
index 31019061a9..4b085a6050 100644
--- a/phpBB/includes/functions_compatibility.php
+++ b/phpBB/includes/functions_compatibility.php
@@ -30,10 +30,11 @@ if (!defined('IN_PHPBB'))
* @param string $avatar_height Height of users avatar
* @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 image
*/
-function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false)
+function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false, $lazy = false)
{
// map arguments to new function phpbb_get_avatar()
$row = array(
@@ -43,7 +44,7 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $
'avatar_height' => $avatar_height,
);
- return phpbb_get_avatar($row, $alt, $ignore_config);
+ return phpbb_get_avatar($row, $alt, $ignore_config, $lazy);
}
/**
diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php
index 4a31339b9a..c9adbe7d63 100644
--- a/phpBB/phpbb/di/container_builder.php
+++ b/phpBB/phpbb/di/container_builder.php
@@ -499,8 +499,7 @@ class container_builder
*/
protected function get_container_filename()
{
- $filename = str_replace(array('/', '.'), array('slash', 'dot'), $this->phpbb_root_path);
- return $this->get_cache_dir() . 'container_' . $filename . '.' . $this->php_ext;
+ return $this->get_cache_dir() . 'container_' . md5($this->phpbb_root_path) . '.' . $this->php_ext;
}
/**
diff --git a/phpBB/phpbb/notification/type/admin_activate_user.php b/phpBB/phpbb/notification/type/admin_activate_user.php
index 73ed612480..0e2924e29c 100644
--- a/phpBB/phpbb/notification/type/admin_activate_user.php
+++ b/phpBB/phpbb/notification/type/admin_activate_user.php
@@ -104,7 +104,7 @@ class admin_activate_user extends \phpbb\notification\type\base
*/
public function get_avatar()
{
- return $this->user_loader->get_avatar($this->item_id);
+ return $this->user_loader->get_avatar($this->item_id, false, true);
}
/**
diff --git a/phpBB/phpbb/notification/type/group_request.php b/phpBB/phpbb/notification/type/group_request.php
index 19665624df..2d7925c1b4 100644
--- a/phpBB/phpbb/notification/type/group_request.php
+++ b/phpBB/phpbb/notification/type/group_request.php
@@ -96,7 +96,7 @@ class group_request extends \phpbb\notification\type\base
*/
public function get_avatar()
{
- return $this->user_loader->get_avatar($this->item_id);
+ return $this->user_loader->get_avatar($this->item_id, false, true);
}
/**
diff --git a/phpBB/phpbb/notification/type/pm.php b/phpBB/phpbb/notification/type/pm.php
index 29b4b79216..5d4f7fe0c6 100644
--- a/phpBB/phpbb/notification/type/pm.php
+++ b/phpBB/phpbb/notification/type/pm.php
@@ -100,7 +100,7 @@ class pm extends \phpbb\notification\type\base
*/
public function get_avatar()
{
- return $this->user_loader->get_avatar($this->get_data('from_user_id'));
+ return $this->user_loader->get_avatar($this->get_data('from_user_id'), false, true);
}
/**
diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php
index d6aa8a8af9..f6b3136a21 100644
--- a/phpBB/phpbb/notification/type/post.php
+++ b/phpBB/phpbb/notification/type/post.php
@@ -165,7 +165,7 @@ class post extends \phpbb\notification\type\base
*/
public function get_avatar()
{
- return $this->user_loader->get_avatar($this->get_data('poster_id'));
+ return $this->user_loader->get_avatar($this->get_data('poster_id'), false, true);
}
/**
diff --git a/phpBB/phpbb/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php
index 1904680d5a..e7d385f59f 100644
--- a/phpBB/phpbb/notification/type/report_pm.php
+++ b/phpBB/phpbb/notification/type/report_pm.php
@@ -223,7 +223,7 @@ class report_pm extends \phpbb\notification\type\pm
*/
public function get_avatar()
{
- return $this->user_loader->get_avatar($this->get_data('reporter_id'));
+ return $this->user_loader->get_avatar($this->get_data('reporter_id'), false, true);
}
/**
diff --git a/phpBB/phpbb/notification/type/report_pm_closed.php b/phpBB/phpbb/notification/type/report_pm_closed.php
index 9f301ee2cc..1c99db60c3 100644
--- a/phpBB/phpbb/notification/type/report_pm_closed.php
+++ b/phpBB/phpbb/notification/type/report_pm_closed.php
@@ -130,7 +130,7 @@ class report_pm_closed extends \phpbb\notification\type\pm
*/
public function get_avatar()
{
- return $this->user_loader->get_avatar($this->get_data('closer_id'));
+ return $this->user_loader->get_avatar($this->get_data('closer_id'), false, true);
}
/**
diff --git a/phpBB/phpbb/notification/type/report_post.php b/phpBB/phpbb/notification/type/report_post.php
index b64862078a..8289a04cf1 100644
--- a/phpBB/phpbb/notification/type/report_post.php
+++ b/phpBB/phpbb/notification/type/report_post.php
@@ -196,7 +196,7 @@ class report_post extends \phpbb\notification\type\post_in_queue
*/
public function get_avatar()
{
- return $this->user_loader->get_avatar($this->get_data('reporter_id'));
+ return $this->user_loader->get_avatar($this->get_data('reporter_id'), false, true);
}
/**
diff --git a/phpBB/phpbb/notification/type/report_post_closed.php b/phpBB/phpbb/notification/type/report_post_closed.php
index a0bb187a0d..3f4378628b 100644
--- a/phpBB/phpbb/notification/type/report_post_closed.php
+++ b/phpBB/phpbb/notification/type/report_post_closed.php
@@ -137,7 +137,7 @@ class report_post_closed extends \phpbb\notification\type\post
*/
public function get_avatar()
{
- return $this->user_loader->get_avatar($this->get_data('closer_id'));
+ return $this->user_loader->get_avatar($this->get_data('closer_id'), false, true);
}
/**
diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php
index a1a17535b5..f0681b9eb8 100644
--- a/phpBB/phpbb/notification/type/topic.php
+++ b/phpBB/phpbb/notification/type/topic.php
@@ -119,7 +119,7 @@ class topic extends \phpbb\notification\type\base
*/
public function get_avatar()
{
- return $this->user_loader->get_avatar($this->get_data('poster_id'));
+ return $this->user_loader->get_avatar($this->get_data('poster_id'), false, true);
}
/**
diff --git a/phpBB/phpbb/user_loader.php b/phpBB/phpbb/user_loader.php
index 0b192e4452..cdd28329db 100644
--- a/phpBB/phpbb/user_loader.php
+++ b/phpBB/phpbb/user_loader.php
@@ -179,9 +179,10 @@ class user_loader
* @param bool $query Should we query the database if this user has not yet been loaded?
* Typically this should be left as false and you should make sure
* you load users ahead of time with load_users()
+ * @param bool @lazy If true, will be lazy loaded (requires JS)
* @return string
*/
- public function get_avatar($user_id, $query = false)
+ public function get_avatar($user_id, $query = false, $lazy = false)
{
if (!($user = $this->get_user($user_id, $query)))
{
@@ -195,7 +196,7 @@ class user_loader
'avatar_height' => $user['user_avatar_height'],
);
- return phpbb_get_avatar($row, 'USER_AVATAR');
+ return phpbb_get_avatar($row, 'USER_AVATAR', false, $lazy);
}
/**
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 4a8da8e7ce..ed6a9713e7 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -1490,14 +1490,11 @@ if (!sizeof($error) && $preview)
// Signature
if ($post_data['enable_sig'] && $config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id))
{
- $parse_sig = new parse_message($preview_signature);
- $parse_sig->bbcode_uid = $preview_signature_uid;
- $parse_sig->bbcode_bitfield = $preview_signature_bitfield;
-
- // Not sure about parameters for bbcode/smilies/urls... in signatures
- $parse_sig->format_display($config['allow_sig_bbcode'], $config['allow_sig_links'], $config['allow_sig_smilies']);
- $preview_signature = $parse_sig->message;
- unset($parse_sig);
+ $flags = ($config['allow_sig_bbcode']) ? OPTION_FLAG_BBCODE : 0;
+ $flags |= ($config['allow_sig_links']) ? OPTION_FLAG_LINKS : 0;
+ $flags |= ($config['allow_sig_smilies']) ? OPTION_FLAG_SMILIES : 0;
+
+ $preview_signature = generate_text_for_display($preview_signature, $preview_signature_uid, $preview_signature_bitfield, $flags, false);
}
else
{
diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php
index 49f0c1d749..ccfeb10deb 100644
--- a/tests/functional/posting_test.php
+++ b/tests/functional/posting_test.php
@@ -180,4 +180,26 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
$crawler = self::submit($form);
$this->assertEquals($text, $crawler->filter('#message')->text());
}
+
+ public function test_old_signature_in_preview()
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_sig = '[b:2u8sdcwb]My signature[/b:2u8sdcwb]',
+ user_sig_bbcode_uid = '2u8sdcwb',
+ user_sig_bbcode_bitfield = 'QA=='
+ WHERE user_id = 2";
+ $this->get_db()->sql_query($sql);
+
+ $this->login();
+ $crawler = self::request('GET', 'posting.php?mode=post&f=2');
+ $form = $crawler->selectButton('Preview')->form(array(
+ 'subject' => 'Test subject',
+ 'message' => 'My post',
+ ));
+ $crawler = self::submit($form);
+ $this->assertContains(
+ '<span style="font-weight: bold">My signature</span>',
+ $crawler->filter('#preview .signature')->html()
+ );
+ }
}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 0fec3c2dff..bef1208609 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -863,15 +863,15 @@ class phpbb_functional_test_case extends phpbb_test_case
*/
static public function assert_response_html($status_code = 200)
{
- if ($status_code !== false)
- {
- self::assert_response_status_code($status_code);
- }
-
// Any output before the doc type means there was an error
$content = self::$client->getResponse()->getContent();
self::assertNotContains('[phpBB Debug]', $content);
self::assertStringStartsWith('<!DOCTYPE', trim($content), 'Output found before DOCTYPE specification.');
+
+ if ($status_code !== false)
+ {
+ self::assert_response_status_code($status_code);
+ }
}
/*
@@ -884,15 +884,15 @@ class phpbb_functional_test_case extends phpbb_test_case
*/
static public function assert_response_xml($status_code = 200)
{
- if ($status_code !== false)
- {
- self::assert_response_status_code($status_code);
- }
-
// Any output before the xml opening means there was an error
$content = self::$client->getResponse()->getContent();
self::assertNotContains('[phpBB Debug]', $content);
self::assertStringStartsWith('<?xml', trim($content), 'Output found before XML specification.');
+
+ if ($status_code !== false)
+ {
+ self::assert_response_status_code($status_code);
+ }
}
/**