Sfoglia il codice sorgente

Merge pull request #2 from emanuele45/master

Two fixes and one minor feature
Spuds 13 anni fa
parent
commit
87f1d1e611

+ 2 - 0
Sources/DbPackages-postgresql.php

@@ -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)
 	{

+ 2 - 0
Sources/DbPackages-sqlite.php

@@ -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)
 	{

+ 1 - 1
Sources/Display.php

@@ -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

+ 73 - 13
Sources/ManageMembergroups.php

@@ -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');
 }
@@ -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.

+ 2 - 2
Sources/ManageSmileys.php

@@ -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" />',
 			),
 		),
 	);
@@ -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" />',
 			),
 		),
 	);

+ 1 - 1
Sources/Packages.php

@@ -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']))
 	{

+ 1 - 1
Sources/Register.php

@@ -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']));
 

+ 3 - 4
Sources/Search.php

@@ -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'])
 	{
@@ -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];
 		}
 	}
@@ -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.

+ 5 - 1
Sources/Subs-Editor.php

@@ -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')

+ 4 - 1
Sources/Themes.php

@@ -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))

+ 51 - 7
Themes/default/ManageMembergroups.template.php

@@ -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 />
@@ -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>
@@ -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 />

+ 0 - 13
Themes/default/Profile.template.php

@@ -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">