Skip to content
2 changes: 2 additions & 0 deletions Sources/DbPackages-postgresql.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,8 @@ function smf_db_remove_index($table_name, $index_name, $parameters = array(), $e
*/
function smf_db_calculate_type($type_name, $type_size = null, $reverse = false)
{
// Let's be sure it's lowercase MySQL likes both, others no.
$type_name = strtolower($type_name);
// Generic => Specific.
if (!$reverse)
{
Expand Down
2 changes: 2 additions & 0 deletions Sources/DbPackages-sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ function smf_db_remove_index($table_name, $index_name, $parameters = array(), $e
*/
function smf_db_calculate_type($type_name, $type_size = null, $reverse = false)
{
// Let's be sure it's lowercase MySQL likes both, others no.
$type_name = strtolower($type_name);
// Generic => Specific.
if (!$reverse)
{
Expand Down
2 changes: 1 addition & 1 deletion Sources/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ function Download()
isAllowedTo('view_attachments');

// Make sure this attachment is on this board.
// NOTE: We must verify that $topic is the attachment's topic, or else the permission check above is broken.
// @todo: We must verify that $topic is the attachment's topic, or else the permission check above is broken.
$request = $smcFunc['db_query']('', '
SELECT a.id_folder, a.filename, a.file_hash, a.fileext, a.id_attach, a.attachment_type, a.mime_type, a.approved, m.id_member
FROM {db_prefix}attachments AS a
Expand Down
86 changes: 73 additions & 13 deletions Sources/ManageMembergroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,22 +562,51 @@ function AddMembergroup()
);
$smcFunc['db_free_result']($result);

$result = $smcFunc['db_query']('', '
SELECT id_board, name, child_level
FROM {db_prefix}boards
$request = $smcFunc['db_query']('', '
SELECT b.id_cat, c.name AS cat_name, b.id_board, b.name, b.child_level
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
ORDER BY board_order',
array(
)
);
$context['boards'] = array();
while ($row = $smcFunc['db_fetch_assoc']($result))
$context['boards'][] = array(
$context['num_boards'] = $smcFunc['db_num_rows']($request);

$context['categories'] = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
// This category hasn't been set up yet..
if (!isset($context['categories'][$row['id_cat']]))
$context['categories'][$row['id_cat']] = array(
'id' => $row['id_cat'],
'name' => $row['cat_name'],
'boards' => array()
);

// Set this board up, and let the template know when it's a child. (indent them..)
$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
'id' => $row['id_board'],
'name' => $row['name'],
'child_level' => $row['child_level'],
'selected' => false
);
$smcFunc['db_free_result']($result);

}
$smcFunc['db_free_result']($request);

// Now, let's sort the list of categories into the boards for templates that like that.
$temp_boards = array();
foreach ($context['categories'] as $category)
{
$temp_boards[] = array(
'name' => $category['name'],
'child_ids' => array_keys($category['boards'])
);
$temp_boards = array_merge($temp_boards, array_values($category['boards']));

// Include a list of boards per category for easy toggling.
$context['categories'][$category['id']]['child_ids'] = array_keys($category['boards']);
}

createToken('admin-mmg');
}
Expand Down Expand Up @@ -1004,22 +1033,53 @@ function EditMembergroup()
$context['boards'] = array();
if ($_REQUEST['group'] == 2 || $_REQUEST['group'] > 3)
{
$result = $smcFunc['db_query']('', '
SELECT id_board, name, child_level, FIND_IN_SET({string:current_group}, member_groups) != 0 AS can_access
FROM {db_prefix}boards
$request = $smcFunc['db_query']('', '
SELECT b.id_cat, c.name as cat_name, b.id_board, b.name, b.child_level, FIND_IN_SET({string:current_group}, b.member_groups) != 0 AS can_access
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
ORDER BY board_order',
array(
'current_group' => (int) $_REQUEST['group'],
)
);
while ($row = $smcFunc['db_fetch_assoc']($result))
$context['boards'][] = array(
$context['categories'] = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
// This category hasn't been set up yet..
if (!isset($context['categories'][$row['id_cat']]))
$context['categories'][$row['id_cat']] = array(
'id' => $row['id_cat'],
'name' => $row['cat_name'],
'boards' => array()
);

// Set this board up, and let the template know when it's a child. (indent them..)
$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
'id' => $row['id_board'],
'name' => $row['name'],
'child_level' => $row['child_level'],
'selected' => !(empty($row['can_access']) || $row['can_access'] == 'f'),
);
$smcFunc['db_free_result']($result);
}
$smcFunc['db_free_result']($request);

// Now, let's sort the list of categories into the boards for templates that like that.
$temp_boards = array();
foreach ($context['categories'] as $category)
{
$temp_boards[] = array(
'name' => $category['name'],
'child_ids' => array_keys($category['boards'])
);
$temp_boards = array_merge($temp_boards, array_values($category['boards']));

// Include a list of boards per category for easy toggling.
$context['categories'][$category['id']]['child_ids'] = array_keys($category['boards']);
}

$max_boards = ceil(count($temp_boards) / 2);
if ($max_boards == 1)
$max_boards = 2;
}

// Finally, get all the groups this could be inherited off.
Expand Down
4 changes: 2 additions & 2 deletions Sources/ManageSmileys.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ function EditSmileySets()
'additional_rows' => array(
array(
'position' => 'below_table_data',
'value' => '<input type="submit" name="delete" value="' . $txt['smiley_sets_delete'] . '" onclick="return confirm(\'' . $txt['smiley_sets_confirm'] . '\');" style="float: right;" class="button_submit" /> [<a href="' . $scripturl . '?action=admin;area=smileys;sa=modifyset' . '">' . $txt['smiley_sets_add'] . '</a>]',
'value' => '[<a href="' . $scripturl . '?action=admin;area=smileys;sa=modifyset' . '">' . $txt['smiley_sets_add'] . '</a>] <input type="submit" name="delete" value="' . $txt['smiley_sets_delete'] . '" onclick="return confirm(\'' . $txt['smiley_sets_confirm'] . '\');" class="button_submit" />',
),
),
);
Expand Down Expand Up @@ -1731,7 +1731,7 @@ function EditMessageIcons()
'additional_rows' => array(
array(
'position' => 'below_table_data',
'value' => '<input type="submit" name="delete" value="' . $txt['quickmod_delete_selected'] . '" style="float: right" class="button_submit" />[<a href="' . $scripturl . '?action=admin;area=smileys;sa=editicon">' . $txt['icons_add_new'] . '</a>]',
'value' => '[<a href="' . $scripturl . '?action=admin;area=smileys;sa=editicon">' . $txt['icons_add_new'] . '</a>] <input type="submit" name="delete" value="' . $txt['quickmod_delete_selected'] . '" class="button_submit" />',
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion Sources/Packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ function PackageBrowse()

function PackageOptions()
{
global $txt, $scripturl, $context, $sourcedir, $modSettings;
global $txt, $scripturl, $context, $sourcedir, $modSettings, $smcFunc;

if (isset($_POST['submit']))
{
Expand Down
2 changes: 1 addition & 1 deletion Sources/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ function Register2($verifiedOpenID = false)
}
else
{
call_integration_hook('integrate_activate', array($row['member_name']));
call_integration_hook('integrate_activate', array($regOptions['username']));

setLoginCookie(60 * $modSettings['cookieTime'], $memberID, sha1(sha1(strtolower($regOptions['username']) . $regOptions['password']) . $regOptions['register_vars']['password_salt']));

Expand Down
7 changes: 3 additions & 4 deletions Sources/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ function PlushSearch1()
'name' => $txt['search']
);

// This is hard coded maximum string length.
$context['search_string_limit'] = 100;

$context['require_verification'] = $user_info['is_guest'] && !empty($modSettings['search_enable_captcha']) && empty($_SESSION['ss_vv_passed']);
if ($context['require_verification'])
{
Expand Down Expand Up @@ -117,6 +114,9 @@ function PlushSearch1()
if ($search_error === 'messages')
continue;

if ($search_error == 'string_too_long')
$txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']);

$context['search_errors']['messages'][] = $txt['error_' . $search_error];
}
}
Expand Down Expand Up @@ -597,7 +597,6 @@ function PlushSearch2()
elseif ($smcFunc['strlen']($search_params['search']) > $context['search_string_limit'])
{
$context['search_errors']['string_too_long'] = true;
$txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']);
}

// Change non-word characters into spaces.
Expand Down
6 changes: 5 additions & 1 deletion Sources/Subs-Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,14 @@ function html_to_bbc($text)
// Now work out what the attributes are.
$attribs = fetchTagAttributes($matches[1]);
$tags = array();
$sizes_equivalence = array(1 => '8pt', '10pt', '12pt', '14pt', '18pt', '24pt', '36pt');
foreach ($attribs as $s => $v)
{
if ($s == 'size')
$tags[] = array('[size=' . (int) trim($v) . ']', '[/size]');
{
$v = empty((int) trim($v)) ? 1 : (int) trim($v);
$tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]');
}
elseif ($s == 'face')
$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
elseif ($s == 'color')
Expand Down
5 changes: 4 additions & 1 deletion Sources/Themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -1178,9 +1178,12 @@ function PickTheme()
$request = $smcFunc['db_query']('', '
SELECT id_theme, value
FROM {db_prefix}themes
WHERE variable = {string:theme_variant}',
WHERE variable = {string:theme_variant}
AND id_member IN ({array_int:id_member})
ORDER BY id_member ASC',
array(
'theme_variant' => 'theme_variant',
'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1),
)
);
while ($row = $smcFunc['db_fetch_assoc']($request))
Expand Down
58 changes: 51 additions & 7 deletions Themes/default/ManageMembergroups.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,32 @@ function template_new_group()
</dt>
<dd>
<fieldset id="visible_boards">
<legend>', $txt['membergroups_new_board_desc'], '</legend>';
foreach ($context['boards'] as $board)
<legend>', $txt['membergroups_new_board_desc'], '</legend>
<ul class="ignoreboards floatleft">';

foreach ($context['categories'] as $category)
{
echo '
<div style="margin-left: ', $board['child_level'], 'em;"><input type="checkbox" name="boardaccess[]" id="boardaccess_', $board['id'], '" value="', $board['id'], '" ', $board['selected'] ? ' checked="checked" disabled="disabled"' : '', ' class="input_check" /> <label for="boardaccess_', $board['id'], '">', $board['name'], '</label></div>';
<li class="category">
<a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), ']); return false;">', $category['name'], '</a>
<ul>';

foreach ($category['boards'] as $board)
{
echo '
<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
<input type="checkbox" name="boardaccess[]" id="brd', $board['id'], '" value="', $board['id'], '" ', $board['selected'] ? ' checked="checked" disabled="disabled"' : '', ' class="input_check" /> <label for="brd', $board['id'], '">', $board['name'], '</label>
</li>';
}

echo '
</ul>
</li>';
}

echo '
</ul>
<br class="clear" />';

echo '
<br />
Expand Down Expand Up @@ -298,7 +320,7 @@ function template_edit_group()
<dd>
<input type="text" name="max_messages" id="max_messages_input" value="', $context['group']['id'] == 1 ? 0 : $context['group']['max_messages'], '" size="6"', $context['group']['id'] == 1 ? ' disabled="disabled"' : '', ' class="input_text" />
</dd>';
if (!empty($context['boards']))
if (!empty($context['categories']))
{
echo '
<dt>
Expand All @@ -307,10 +329,32 @@ function template_edit_group()
</dt>
<dd>
<fieldset id="visible_boards" style="width: 95%;">
<legend><a href="javascript:void(0);" onclick="document.getElementById(\'visible_boards\').style.display = \'none\';document.getElementById(\'visible_boards_link\').style.display = \'block\'; return false;">', $txt['membergroups_new_board_desc'], '</a></legend>';
foreach ($context['boards'] as $board)
<legend><a href="javascript:void(0);" onclick="document.getElementById(\'visible_boards\').style.display = \'none\';document.getElementById(\'visible_boards_link\').style.display = \'block\'; return false;">', $txt['membergroups_new_board_desc'], '</a></legend>
<ul class="ignoreboards floatleft">';

foreach ($context['categories'] as $category)
{
echo '
<div style="margin-left: ', $board['child_level'], 'em;"><input type="checkbox" name="boardaccess[]" id="boardaccess_', $board['id'], '" value="', $board['id'], '" ', $board['selected'] ? ' checked="checked"' : '', ' class="input_check" /> <label for="boardaccess_', $board['id'], '">', $board['name'], '</label></div>';
<li class="category">
<a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), ']); return false;">', $category['name'], '</a>
<ul>';

foreach ($category['boards'] as $board)
{
echo '
<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
<input type="checkbox" name="boardaccess[]" id="brd', $board['id'], '" value="', $board['id'], '" ', $board['selected'] ? ' checked="checked"' : '', ' class="input_check" /> <label for="brd', $board['id'], '">', $board['name'], '</label>
</li>';
}

echo '
</ul>
</li>';
}

echo '
</ul>
<br class="clear" />';

echo '
<br />
Expand Down
13 changes: 0 additions & 13 deletions Themes/default/Profile.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1856,19 +1856,6 @@ function template_ignoreboards()
global $context, $txt, $settings, $scripturl;
// The main containing header.
echo '
<script type="text/javascript"><!-- // --><![CDATA[
function selectBoards(ids)
{
var toggle = true;

for (i = 0; i < ids.length; i++)
toggle = toggle & document.forms.creator["ignore_brd" + ids[i]].checked;

for (i = 0; i < ids.length; i++)
document.forms.creator["ignore_brd" + ids[i]].checked = !toggle;
}
// ]]></script>

<form action="', $scripturl, '?action=profile;area=ignoreboards;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
<div class="cat_bar">
<h3 class="catbg">
Expand Down