1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-04 14:47:52 +02:00

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

* 'develop' of https://github.com/phpbb/phpbb3: (29 commits)
  [ticket/11588] Also use version.phpbb.com in install_update.php.
  [ticket/11587] Add functional tests for group teampage settings
  [ticket/11538] Add admin as admins leader and moderator in memberlist_test
  [ticket/11587] Pass legend and teampage settings to group_create()
  [ticket/11586] Move $filedata['thumbnail'] to where it might be returned.
  [ticket/11586] Combine $filedata['post_attach'] assign into a single statement.
  [ticket/11586] Use a variable for $cat_id == ATTACHMENT_CATEGORY_IMAGE.
  [ticket/11586] Combine administrator/moderator checks together.
  [ticket/11583] Use a new lang key instead of giving the old one a new meaning.
  [ticket/11122] Add dhruv to active authors
  [ticket/11122] Remove Oleg and igorw from active authors
  [ticket/10840] Add check_form_key to acp_groups.php
  [ticket/11583] Allow FULLTEXT indexes on InnoDB when on MySQL 5.6.4 or higher.
  [ticket/11409] Add success message after updating group position settings
  [ticket/11549] Add functional test for ACP Extension Module with Template
  [ticket/11570] Fix link and make the notice more conspiciuous
  [ticket/11549] Do not set extension dir path for style in adm/index.php
  [ticket/11570] Add link back to update process
  [ticket/11569] Add type parameter and fix language variable
  [ticket/11569] Add parameter to URL and remove comment
  ...

Conflicts:
	tests/functional/common_groups_test.php
This commit is contained in:
Joas Schilling 2013-06-07 00:15:28 +02:00
commit 1d7c80b912
26 changed files with 640 additions and 145 deletions

View File

@ -50,7 +50,6 @@ $module_id = request_var('i', '');
$mode = request_var('mode', '');
// Set custom style for admin area
$phpbb_style->set_ext_dir_prefix('adm/');
$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), '');
$template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets');
$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');

View File

@ -152,7 +152,7 @@
</dl>
<dl>
<dt><label for="forum_desc">{L_FORUM_DESC}{L_COLON}</label><br /><span>{L_FORUM_DESC_EXPLAIN}</span></dt>
<dd><textarea id="forum_desc" name="forum_desc" rows="5" cols="45">{FORUM_DESC}</textarea></dd>
<dd><textarea id="forum_desc" name="forum_desc" rows="5" cols="45" data-bbcode="true">{FORUM_DESC}</textarea></dd>
<dd><label><input type="checkbox" class="radio" name="desc_parse_bbcode"<!-- IF S_DESC_BBCODE_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_PARSE_BBCODE}</label>
<label><input type="checkbox" class="radio" name="desc_parse_smilies"<!-- IF S_DESC_SMILIES_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_PARSE_SMILIES}</label>
<label><input type="checkbox" class="radio" name="desc_parse_urls"<!-- IF S_DESC_URLS_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_PARSE_URLS}</label></dd>
@ -316,7 +316,7 @@
<!-- ENDIF -->
<dl>
<dt><label for="forum_rules">{L_FORUM_RULES}{L_COLON}</label><br /><span>{L_FORUM_RULES_EXPLAIN}</span></dt>
<dd><textarea id="forum_rules" name="forum_rules" rows="4" cols="70">{FORUM_RULES_PLAIN}</textarea></dd>
<dd><textarea id="forum_rules" name="forum_rules" rows="4" cols="70" data-bbcode="true">{FORUM_RULES_PLAIN}</textarea></dd>
<dd><label><input type="checkbox" class="radio" name="rules_parse_bbcode"<!-- IF S_BBCODE_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_PARSE_BBCODE}</label>
<label><input type="checkbox" class="radio" name="rules_parse_smilies"<!-- IF S_SMILIES_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_PARSE_SMILIES}</label>
<label><input type="checkbox" class="radio" name="rules_parse_urls"<!-- IF S_URLS_CHECKED --> checked="checked"<!-- ENDIF --> /> {L_PARSE_URLS}</label></dd>

View File

@ -92,7 +92,7 @@
// ]]>
</script>
</dt>
<dd style="margin-{S_CONTENT_FLOW_BEGIN}{L_COLON} 90px;"><textarea name="signature" rows="10" cols="60" style="width: 95%;" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onfocus="initInsertions();">{SIGNATURE}</textarea></dd>
<dd style="margin-{S_CONTENT_FLOW_BEGIN}{L_COLON} 90px;"><textarea name="signature" rows="10" cols="60" style="width: 95%;" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onfocus="initInsertions();" data-bbcode="true">{SIGNATURE}</textarea></dd>
<dd style="margin-{S_CONTENT_FLOW_BEGIN}{L_COLON} 90px; margin-top: 5px;">
<!-- IF S_BBCODE_ALLOWED -->
<label><input type="checkbox" class="radio" name="disable_bbcode"{S_BBCODE_CHECKED} /> {L_DISABLE_BBCODE}</label>

View File

@ -678,5 +678,164 @@ phpbb.resizeTextArea = function(items, options) {
});
};
/**
* Check if cursor in textarea is currently inside a bbcode tag
*
* @param {object} textarea Textarea DOM object
* @param {Array} startTags List of start tags to look for
* For example, Array('[code]', '[code=')
* @param {Array} endTags List of end tags to look for
* For example, Array('[/code]')
*
* @return {boolean} True if cursor is in bbcode tag
*/
phpbb.inBBCodeTag = function(textarea, startTags, endTags) {
var start = textarea.selectionStart,
lastEnd = -1,
lastStart = -1,
i, index, value;
if (typeof start !== 'number') {
return false;
}
value = textarea.value.toLowerCase();
for (i = 0; i < startTags.length; i++) {
var tagLength = startTags[i].length;
if (start >= tagLength) {
index = value.lastIndexOf(startTags[i], start - tagLength);
lastStart = Math.max(lastStart, index);
}
}
if (lastStart == -1) return false;
if (start > 0) {
for (i = 0; i < endTags.length; i++) {
index = value.lastIndexOf(endTags[i], start - 1);
lastEnd = Math.max(lastEnd, index);
}
}
return (lastEnd < lastStart);
}
/**
* Adjust textarea to manage code bbcode
*
* This function allows to use tab characters when typing code
* and keeps indentation of previous line of code when adding new
* line while typing code.
*
* Editor's functionality is changed only when cursor is between
* [code] and [/code] bbcode tags.
*
* @param {object} textarea Textarea DOM object to apply editor to
*/
phpbb.applyCodeEditor = function(textarea) {
// list of allowed start and end bbcode code tags, in lower case
var startTags = ['[code]', '[code='],
startTagsEnd = ']',
endTags = ['[/code]'];
if (!textarea || typeof textarea.selectionStart !== 'number') {
return;
}
if ($(textarea).data('code-editor') === true) {
return;
}
function inTag() {
return phpbb.inBBCodeTag(textarea, startTags, endTags);
}
/**
* Get line of text before cursor
*
* @param {boolean} stripCodeStart If true, only part of line
* after [code] tag will be returned.
*
* @return {string} Line of text
*/
function getLastLine(stripCodeStart) {
var start = textarea.selectionStart,
value = textarea.value,
index = value.lastIndexOf("\n", start - 1);
value = value.substring(index + 1, start);
if (stripCodeStart) {
for (var i = 0; i < startTags.length; i++) {
index = value.lastIndexOf(startTags[i]);
if (index >= 0) {
var tagLength = startTags[i].length;
value = value.substring(index + tagLength);
if (startTags[i].lastIndexOf(startTagsEnd) != tagLength) {
index = value.indexOf(startTagsEnd);
if (index >= 0) {
value = value.substr(index + 1);
}
}
}
}
}
return value;
}
/**
* Append text at cursor position
*
* @param {string} Text Text to append
*/
function appendText(text) {
var start = textarea.selectionStart,
end = textarea.selectionEnd,
value = textarea.value;
textarea.value = value.substr(0, start) + text + value.substr(end);
textarea.selectionStart = textarea.selectionEnd = start + text.length;
}
$(textarea).data('code-editor', true).on('keydown', function(event) {
var key = event.keyCode || event.which;
// intercept tabs
if (key == 9) {
if (inTag()) {
appendText("\t");
event.preventDefault();
return;
}
}
// intercept new line characters
if (key == 13) {
if (inTag()) {
var lastLine = getLastLine(true),
code = '' + /^\s*/g.exec(lastLine);
if (code.length > 0) {
appendText("\n" + code);
event.preventDefault();
return;
}
}
}
});
};
/**
* Apply code editor to all textarea elements with data-bbcode attribute
*/
$(document).ready(function() {
$('textarea[data-bbcode]').each(function() {
phpbb.applyCodeEditor(this);
});
});
})(jQuery); // Avoid conflicts with other libraries

View File

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

View File

@ -87,6 +87,11 @@ class acp_groups
case 'approve':
case 'demote':
case 'promote':
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (!$group_id)
{
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
@ -259,6 +264,11 @@ class acp_groups
break;
case 'addusers':
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (!$group_id)
{
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
@ -920,10 +930,12 @@ class acp_groups
case 'set_config_teampage':
$config->set('teampage_forums', $request->variable('teampage_forums', 0));
$config->set('teampage_memberships', $request->variable('teampage_memberships', 0));
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
break;
case 'set_config_legend':
$config->set('legend_sort_groupname', $request->variable('legend_sort_groupname', 0));
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
break;
}
}

View File

@ -209,9 +209,6 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
}
// The "manual" way
$module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']);
add_log('admin', 'LOG_MODULE_ADD', $module_log_name);
if (!is_numeric($parent))
{
$sql = 'SELECT module_id
@ -267,6 +264,8 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
else
{
// Success
$module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']);
add_log('admin', 'LOG_MODULE_ADD', $module_log_name);
// Move the module if requested above/below an existing one
if (isset($data['before']) && $data['before'])

View File

@ -403,14 +403,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
$upload->set_disallowed_content(explode('|', $config['mime_triggers']));
}
if (!$local)
{
$filedata['post_attach'] = ($upload->is_valid($form_name)) ? true : false;
}
else
{
$filedata['post_attach'] = true;
}
$filedata['post_attach'] = $local || $upload->is_valid($form_name);
if (!$filedata['post_attach'])
{
@ -429,30 +422,18 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
return $filedata;
}
$cat_id = (isset($extensions[$file->get('extension')]['display_cat'])) ? $extensions[$file->get('extension')]['display_cat'] : ATTACHMENT_CATEGORY_NONE;
// Whether the uploaded file is in the image category
$is_image = (isset($extensions[$file->get('extension')]['display_cat'])) ? $extensions[$file->get('extension')]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE : false;
// Make sure the image category only holds valid images...
if ($cat_id == ATTACHMENT_CATEGORY_IMAGE && !$file->is_image())
{
$file->remove();
// If this error occurs a user tried to exploit an IE Bug by renaming extensions
// Since the image category is displaying content inline we need to catch this.
trigger_error($user->lang['ATTACHED_IMAGE_NOT_IMAGE']);
}
// Do we have to create a thumbnail?
$filedata['thumbnail'] = ($cat_id == ATTACHMENT_CATEGORY_IMAGE && $config['img_create_thumbnail']) ? 1 : 0;
// Check Image Size, if it is an image
if (!$auth->acl_get('a_') && !$auth->acl_get('m_', $forum_id) && $cat_id == ATTACHMENT_CATEGORY_IMAGE)
{
$file->upload->set_allowed_dimensions(0, 0, $config['img_max_width'], $config['img_max_height']);
}
// Admins and mods are allowed to exceed the allowed filesize
if (!$auth->acl_get('a_') && !$auth->acl_get('m_', $forum_id))
{
// Check Image Size, if it is an image
if ($is_image)
{
$file->upload->set_allowed_dimensions(0, 0, $config['img_max_width'], $config['img_max_height']);
}
// Admins and mods are allowed to exceed the allowed filesize
if (!empty($extensions[$file->get('extension')]['max_filesize']))
{
$allowed_filesize = $extensions[$file->get('extension')]['max_filesize'];
@ -467,10 +448,12 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
$file->clean_filename('unique', $user->data['user_id'] . '_');
// Are we uploading an image *and* this image being within the image category? Only then perform additional image checks.
$no_image = ($cat_id == ATTACHMENT_CATEGORY_IMAGE) ? false : true;
// Are we uploading an image *and* this image being within the image category?
// Only then perform additional image checks.
$file->move_file($config['upload_path'], false, !$is_image);
$file->move_file($config['upload_path'], false, $no_image);
// Do we have to create a thumbnail?
$filedata['thumbnail'] = ($is_image && $config['img_create_thumbnail']) ? 1 : 0;
if (sizeof($file->error))
{
@ -481,6 +464,16 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
return $filedata;
}
// Make sure the image category only holds valid images...
if ($is_image && !$file->is_image())
{
$file->remove();
// If this error occurs a user tried to exploit an IE Bug by renaming extensions
// Since the image category is displaying content inline we need to catch this.
trigger_error($user->lang['ATTACHED_IMAGE_NOT_IMAGE']);
}
$filedata['filesize'] = $file->get('filesize');
$filedata['mimetype'] = $file->get('mimetype');
$filedata['extension'] = $file->get('extension');

View File

@ -163,9 +163,16 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
$engine = $info['Type'];
}
if ($engine != 'MyISAM')
$fulltext_supported =
$engine === 'MyISAM' ||
// FULLTEXT is supported on InnoDB since MySQL 5.6.4 according to
// http://dev.mysql.com/doc/refman/5.6/en/innodb-storage-engine.html
$engine === 'InnoDB' &&
phpbb_version_compare($this->db->sql_server_info(true), '5.6.4', '>=');
if (!$fulltext_supported)
{
return $this->user->lang['FULLTEXT_MYSQL_NOT_MYISAM'];
return $this->user->lang['FULLTEXT_MYSQL_NOT_SUPPORTED'];
}
$sql = 'SHOW VARIABLES

View File

@ -416,9 +416,11 @@ class ucp_groups
if ($group_id)
{
$sql = 'SELECT *
FROM ' . GROUPS_TABLE . "
WHERE group_id = $group_id";
$sql = 'SELECT g.*, t.teampage_position AS group_teampage
FROM ' . GROUPS_TABLE . ' g
LEFT JOIN ' . TEAMPAGE_TABLE . ' t
ON (t.group_id = g.group_id)
WHERE g.group_id = ' . $group_id;
$result = $db->sql_query($sql);
$group_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@ -514,6 +516,8 @@ class ucp_groups
'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0,
'message_limit' => request_var('group_message_limit', 0),
'max_recipients'=> request_var('group_max_recipients', 0),
'legend' => $group_row['group_legend'],
'teampage' => $group_row['group_teampage'],
);
if ($config['allow_avatar'])
@ -569,6 +573,9 @@ class ucp_groups
// Only set the rank, colour, etc. if it's changed or if we're adding a new
// group. This prevents existing group members being updated if no changes
// were made.
// However there are some attributes that need to be set everytime,
// otherwise the group gets removed from the feature.
$set_attributes = array('legend', 'teampage');
$group_attributes = array();
$test_variables = array(
@ -580,13 +587,14 @@ class ucp_groups
'avatar_height' => 'int',
'receive_pm' => 'int',
'legend' => 'int',
'teampage' => 'int',
'message_limit' => 'int',
'max_recipients'=> 'int',
);
foreach ($test_variables as $test => $type)
{
if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test] || isset($group_attributes['group_avatar']) && strpos($test, 'avatar') === 0))
if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test] || isset($group_attributes['group_avatar']) && strpos($test, 'avatar') === 0 || in_array($test, $set_attributes)))
{
settype($submit_ary[$test], $type);
$group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
@ -596,6 +604,7 @@ class ucp_groups
if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies)))
{
$cache->destroy('sql', GROUPS_TABLE);
$cache->destroy('sql', TEAMPAGE_TABLE);
$message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED';
trigger_error($user->lang[$message] . $return_page);

View File

@ -263,9 +263,8 @@ while (!$migrator->finished())
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
if ((time() - $update_start_time) >= $safe_time_limit)
{
//echo '<meta http-equiv="refresh" content="0;url=' . str_replace('&', '&amp;', append_sid($phpbb_root_path . 'test.' . $phpEx)) . '" />';
echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '<br />';
echo '<a href="' . append_sid($phpbb_root_path . 'test.' . $phpEx) . '">' . $user->lang['DATABASE_UPDATE_CONTINUE'] . '</a>';
echo '<a href="' . append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=' . $request->variable('type', 0) . '&amp;language=' . $user->lang['USER_LANG']) . '">' . $user->lang['DATABASE_UPDATE_CONTINUE'] . '</a>';
phpbb_end_update($cache, $config);
}
@ -276,6 +275,17 @@ if ($orig_version != $config['version'])
add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $config['version']);
}
echo $user->lang['DATABASE_UPDATE_COMPLETE'];
echo $user->lang['DATABASE_UPDATE_COMPLETE'] . '<br />';
if ($request->variable('type', 0))
{
echo $user->lang['INLINE_UPDATE_SUCCESSFUL'] . '<br /><br />';
echo '<a href="' . append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update&amp;sub=file_check&amp;language=' . $user->lang['USER_LANG']) . '" class="button1">' . $user->lang['CONTINUE_UPDATE_NOW'] . '</a>';
}
else
{
echo '<div class="errorbox">' . $user->lang['UPDATE_FILES_NOTICE'] . '</div>';
echo $user->lang['COMPLETE_LOGIN_TO_BOARD'];
}
phpbb_end_update($cache, $config);

View File

@ -1618,7 +1618,9 @@ class install_update extends module
{
case 'version_info':
global $phpbb_root_path, $phpEx;
$info = get_remote_file('www.phpbb.com', '/updatecheck', ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno);
$info = get_remote_file('version.phpbb.com', '/phpbb',
((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno);
if ($info !== false)
{

View File

@ -52,7 +52,7 @@ $lang = array_merge($lang, array(
'DELETING_INDEX_IN_PROGRESS_EXPLAIN' => 'The search backend is currently cleaning its index. This can take a few minutes.',
'FULLTEXT_MYSQL_INCOMPATIBLE_DATABASE' => 'The MySQL fulltext backend can only be used with MySQL4 and above.',
'FULLTEXT_MYSQL_NOT_MYISAM' => 'MySQL fulltext indexes can only be used with MyISAM tables.',
'FULLTEXT_MYSQL_NOT_SUPPORTED' => 'MySQL fulltext indexes can only be used with MyISAM or InnoDB tables. MySQL 5.6.4 or later is required for fulltext indexes on InnoDB tables.',
'FULLTEXT_MYSQL_TOTAL_POSTS' => 'Total number of indexed posts',
'FULLTEXT_MYSQL_MIN_SEARCH_CHARS_EXPLAIN' => 'Words with at least this many characters will be indexed for searching. You or your host can only change this setting by changing the mysql configuration.',
'FULLTEXT_MYSQL_MAX_SEARCH_CHARS_EXPLAIN' => 'Words with no more than this many characters will be indexed for searching. You or your host can only change this setting by changing the mysql configuration.',

View File

@ -401,7 +401,7 @@ function getCaretPosition(txtarea) {
*/
(function($) {
$(document).ready(function() {
var doc, textarea, startTags, endTags;
var doc, textarea;
// find textarea, make sure browser supports necessary functions
if (document.forms[form_name]) {
@ -415,81 +415,8 @@ function getCaretPosition(txtarea) {
}
textarea = doc.forms[form_name].elements[text_name];
if (!textarea || typeof textarea.selectionStart !== 'number') {
return;
}
// list of allowed start and end bbcode code tags, in lower case
startTags = ['[code]', '[code='];
endTags = ['[/code]'];
function inTag() {
var start = textarea.selectionStart,
lastEnd = -1,
lastStart = -1,
i, index, value;
value = textarea.value.toLowerCase();
for (i = 0; i < startTags.length; i++) {
var tagLength = startTags[i].length;
if (start >= tagLength) {
index = value.lastIndexOf(startTags[i], start - tagLength);
lastStart = Math.max(lastStart, index);
}
}
if (lastStart == -1) return false;
if (start > 0) {
for (i = 0; i < endTags.length; i++) {
index = value.lastIndexOf(endTags[i], start - 1);
lastEnd = Math.max(lastEnd, index);
}
}
return (lastEnd < lastStart);
}
function getLastLine() {
var start = textarea.selectionStart,
value = textarea.value,
index = value.lastIndexOf("\n", start - 1);
return value.substring(index + 1, start);
}
function appendCode(code) {
var start = textarea.selectionStart,
end = textarea.selectionEnd,
value = textarea.value;
textarea.value = value.substr(0, start) + code + value.substr(end);
textarea.selectionStart = textarea.selectionEnd = start + code.length;
}
$(textarea).on('keydown', function(event) {
var key = event.keyCode || event.which;
// intercept tabs
if (key == 9) {
if (inTag()) {
appendCode("\t");
event.preventDefault();
return;
}
}
// intercept new line characters
if (key == 13) {
if (inTag()) {
var lastLine = getLastLine(),
code = '' + /^\s*/g.exec(lastLine);
if (code.length > 0) {
appendCode("\n" + code);
event.preventDefault();
return;
}
}
}
});
phpbb.applyCodeEditor(textarea);
});
})(jQuery);

View File

@ -306,8 +306,12 @@ a#logo:hover {
ul.linklist {
display: block;
margin: 0;
height: 4%;
overflow: hidden;
}
ul.linklist:after {
content: '';
display: block;
clear: both;
}
#cp-main .panel {
@ -689,28 +693,33 @@ p.rules a {
vertical-align: text-bottom;
}
.icon-notification {
position: relative;
}
#notification_list {
display: none;
position: absolute;
left: 0;
width: 330px;
z-index: 1;
border: 1px solid;
box-shadow: 3px 3px 5px darkgray;
border-radius: 5px;
margin-top: 8px;
top: 32px;
}
#notification_list ul {
max-height: 350px;
overflow-y: auto;
overflow-x: hidden;
clear: both;
}
#notification_list ul li {
width: 310px;
padding: 10px;
margin: 0;
float: left;
float: none;
border-bottom: 1px solid;
list-style-type: none;
font-size: 0.95em;

View File

@ -9,6 +9,10 @@ tweaks required due to its poor CSS support.
zoom: 1;
}
ul.linklist {
zoom: 1;
}
/* Align checkboxes/radio buttons nicely */
dd label input {
vertical-align: text-bottom;
@ -47,3 +51,18 @@ dd.lastpost, dd.redirect, dd.moderation, dd.time, dd.info {
dd.option {
*width: 124px;
}
/* Notifications list for IE7 */
#notification_list {
*left: 0;
}
#notification_list .header_settings {
*position: absolute;
*right: 10px;
*top: 0;
}
.icon-notification {
*z-index: 2;
}

View File

@ -38,6 +38,7 @@ function initInsertions() {
}
var textarea = doc.forms[form_name].elements[text_name];
phpbb.applyCodeEditor(textarea);
if (is_ie && typeof(baseHeight) !== 'number') {
textarea.focus();

View File

@ -14,8 +14,107 @@ require_once dirname(__FILE__) . '/common_groups_test.php';
*/
class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_test
{
protected $form_data;
protected function get_url()
{
return 'adm/index.php?i=groups&mode=manage&action=edit';
}
public function acp_group_test_data()
{
return array(
'both_yes' => array(
5,
true,
true,
),
'legend_no_teampage' => array(
5,
true,
false,
),
'no_legend_teampage' => array(
5,
false,
true,
),
'both_no' => array(
5,
false,
false,
),
'no_change' => array(
5,
NULL,
NULL,
),
'back_to_default' => array(
5,
true,
true,
),
// Remove and add moderators back in order to reset
// group order to default one
'mods_both_no' => array(
4,
false,
false,
),
'mods_back_to_default' => array(
4,
true,
true,
),
);
}
/**
* @dataProvider acp_group_test_data
*/
public function test_acp_groups_teampage($group_id, $tick_legend, $tick_teampage)
{
$this->group_manage_login();
// Manage Administrators group
$form = $this->get_group_manage_form($group_id);
$this->form_data[0] = $form->getValues();
if (isset($tick_legend) && isset($tick_teampage))
{
if ($tick_legend)
{
$form['group_legend']->tick();
}
else
{
$form['group_legend']->untick();
}
if ($tick_teampage)
{
$form['group_teampage']->tick();
}
else
{
$form['group_teampage']->untick();
}
}
$crawler = self::submit($form);
$this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text());
$form = $this->get_group_manage_form($group_id);
if (!isset($tick_legend) && !isset($tick_teampage))
{
$this->form_data[1] = $form->getValues();
unset($this->form_data[0]['creation_time'], $this->form_data[0]['form_token'], $this->form_data[1]['creation_time'], $this->form_data[1]['form_token']);
$this->assertEquals($this->form_data[0], $this->form_data[1]);
}
else
{
$this->form_data = $form->getValues();
$this->assertEquals($tick_legend, $this->form_data['group_legend']);
$this->assertEquals($tick_teampage, $this->form_data['group_teampage']);
}
}
}

View File

@ -14,6 +14,28 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test
{
abstract protected function get_url();
/**
* Get group_manage form
* @param int $group_id ID of the group that should be managed
*/
protected function get_group_manage_form($group_id = 5)
{
// Manage Administrators group
$crawler = self::request('GET', $this->get_url() . "&g=$group_id&sid=" . $this->sid);
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
return $form;
}
/**
* Execute login calls and add_lang() calls for tests
*/
protected function group_manage_login()
{
$this->login();
$this->admin_login();
$this->add_lang(array('ucp', 'acp/groups'));
}
public function groups_manage_test_data()
{
return array(
@ -30,19 +52,10 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test
*/
public function test_groups_manage($input, $expected)
{
$this->markTestIncomplete(
'Test fails on develop due to another test deleting the Administrators group.'
);
// See https://github.com/phpbb/phpbb3/pull/1407#issuecomment-18465480
// and https://gist.github.com/bantu/22dc4f6c6c0b8f9e0fa1
$this->login();
$this->admin_login();
$this->add_lang(array('ucp', 'acp/groups'));
$this->group_manage_login();
// Manage Administrators group
$crawler = self::request('GET', $this->get_url() . '&g=5&sid=' . $this->sid);
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$form = $this->get_group_manage_form();
$form['group_colour']->setValue($input);
$crawler = self::submit($form);
$this->assertContains($this->lang($expected), $crawler->text());

View File

@ -0,0 +1,129 @@
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php';
/**
* @group functional
*/
class phpbb_functional_extension_module_test extends phpbb_functional_test_case
{
protected $phpbb_extension_manager;
static private $copied_files = array();
static private $helper;
/**
* This should only be called once before the tests are run.
* This is used to copy the fixtures to the phpBB install
*/
static public function setUpBeforeClass()
{
global $phpbb_root_path;
parent::setUpBeforeClass();
self::$helper = new phpbb_test_case_helpers(self);
self::$copied_files = array();
if (file_exists($phpbb_root_path . 'ext/'))
{
// First, move any extensions setup on the board to a temp directory
self::$copied_files = self::$helper->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/');
// Then empty the ext/ directory on the board (for accurate test cases)
self::$helper->empty_dir($phpbb_root_path . 'ext/');
}
// Copy our ext/ files from the test case to the board
self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/fixtures/ext/', $phpbb_root_path . 'ext/'));
}
/**
* This should only be called once after the tests are run.
* This is used to remove the fixtures from the phpBB install
*/
static public function tearDownAfterClass()
{
global $phpbb_root_path;
if (file_exists($phpbb_root_path . 'store/temp_ext/'))
{
// Copy back the board installed extensions from the temp directory
self::$helper->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/');
}
// Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext)
self::$helper->remove_files(self::$copied_files);
if (file_exists($phpbb_root_path . 'store/temp_ext/'))
{
self::$helper->empty_dir($phpbb_root_path . 'store/temp_ext/');
}
}
public function setUp()
{
global $db;
parent::setUp();
$this->phpbb_extension_manager = $this->get_extension_manager();
$this->phpbb_extension_manager->enable('foo/bar');
$modules = new acp_modules();
$db = $this->get_db();
$sql = 'SELECT module_id
FROM ' . MODULES_TABLE . "
WHERE module_langname = 'acp'
AND module_class = 'ACP_CAT_DOT_MODS'";
$result = $db->sql_query($sql);
$module_id = (int) $db->sql_fetchfield('module_id');
$db->sql_freeresult($result);
$parent_data = array(
'module_basename' => '',
'module_enabled' => 1,
'module_display' => 1,
'parent_id' => $module_id,
'module_class' => 'acp',
'module_langname' => 'ACP_FOOBAR_TITLE',
'module_mode' => '',
'module_auth' => '',
);
$modules->update_module_data($parent_data, true);
$module_data = array(
'module_basename' => 'phpbb_ext_foo_bar_acp_main_module',
'module_enabled' => 1,
'module_display' => 1,
'parent_id' => $parent_data['module_id'],
'module_class' => 'acp',
'module_langname' => 'ACP_FOOBAR_TITLE',
'module_mode' => 'mode',
'module_auth' => '',
);
$modules->update_module_data($module_data, true);
$this->purge_cache();
}
/**
* Check a controller for extension foo/bar.
*/
public function test_foo_bar()
{
$this->login();
$this->admin_login();
$crawler = self::request('GET', 'adm/index.php?i=phpbb_ext_foo_bar_acp_main_module&mode=mode&sid=' . $this->sid);
$this->assertContains("Bertie rulez!", $crawler->filter('#main')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
}

View File

@ -0,0 +1,32 @@
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
class phpbb_ext_foo_bar_acp_main_info
{
function module()
{
return array(
'filename' => 'phpbb_ext_foo_bar_acp_main_module',
'title' => 'ACP_FOOBAR_TITLE',
'version' => '1.0.0',
'modes' => array(
'mode' => array('title' => 'ACP_FOOBAR_MODE', 'auth' => '', 'cat' => array('ACP_FOOBAR_TITLE')),
),
);
}
}

View File

@ -0,0 +1,28 @@
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
class phpbb_ext_foo_bar_acp_main_module
{
var $u_action;
function main($id, $mode)
{
$this->tpl_name = 'foobar';
$this->page_title = 'Bertie';
}
}

View File

@ -0,0 +1,3 @@
<!-- INCLUDE overall_header.html -->
Bertie rulez!
<!-- INCLUDE overall_footer.html -->

View File

@ -89,5 +89,17 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
$crawler = $this->get_memberlist_leaders_table_crawler();
$this->assertNotContains('memberlist-test-moderator', $crawler->eq(0)->text());
$this->assertContains('memberlist-test-moderator', $crawler->eq(1)->text());
// Add admin to moderators, should be visible as moderator
$this->add_user_group('GLOBAL_MODERATORS', array('admin'), true);
$crawler = $this->get_memberlist_leaders_table_crawler();
$this->assertNotContains('admin', $crawler->eq(0)->text());
$this->assertContains('admin', $crawler->eq(1)->text());
// Add admin to admins as leader, should be visible as admin, not moderator
$this->add_user_group('ADMINISTRATORS', array('admin'), true, true);
$crawler = $this->get_memberlist_leaders_table_crawler();
$this->assertContains('admin', $crawler->eq(0)->text());
$this->assertNotContains('admin', $crawler->eq(1)->text());
}
}

View File

@ -14,8 +14,40 @@ require_once dirname(__FILE__) . '/common_groups_test.php';
*/
class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_test
{
protected $db;
protected function get_url()
{
return 'ucp.php?i=groups&mode=manage&action=edit';
}
protected function get_teampage_settings()
{
if (!isset($this->db))
{
$this->db = $this->get_db();
}
$sql = 'SELECT g.group_legend AS group_legend, t.teampage_position AS group_teampage
FROM ' . GROUPS_TABLE . ' g
LEFT JOIN ' . TEAMPAGE_TABLE . ' t
ON (t.group_id = g.group_id)
WHERE g.group_id = 5';
$result = $this->db->sql_query($sql);
$group_row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
return $group_row;
}
public function test_ucp_groups_teampage()
{
$this->group_manage_login();
// Test if group_legend or group_teampage are modified while
// submitting the ucp_group_manage page
$form = $this->get_group_manage_form();
$teampage_settings = $this->get_teampage_settings();
$crawler = self::submit($form);
$this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text());
$this->assertEquals($teampage_settings, $this->get_teampage_settings());
}
}

View File

@ -423,7 +423,7 @@ class phpbb_functional_test_case extends phpbb_test_case
return group_user_del($group_id, false, $usernames, $group_name);
}
protected function add_user_group($group_name, $usernames)
protected function add_user_group($group_name, $usernames, $default = false, $leader = false)
{
global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx;
@ -462,7 +462,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$group_id = (int) $db->sql_fetchfield('group_id');
$db->sql_freeresult($result);
return group_user_add($group_id, false, $usernames, $group_name);
return group_user_add($group_id, false, $usernames, $group_name, $default, $leader);
}
protected function login($username = 'admin')