Browse Source

Merge branch 'master' of https://github.com/emanuele45/playpen

Conflicts:
	Sources/ManageSettings.php
Spuds 13 years ago
parent
commit
8c7e53bb5e

+ 1 - 1
Sources/Admin.php

@@ -165,7 +165,7 @@ function AdminMain()
 					'label' => $txt['theme_admin'],
 					'file' => 'Themes.php',
 					'function' => 'ThemesMain',
-					'custom_url' => $scripturl . '?action=admin;area=theme;sa=admin',
+					'custom_url' => $scripturl . '?action=admin;area=theme',
 					'icon' => 'themes.gif',
 					'subsections' => array(
 						'admin' => array($txt['themeadmin_admin_title']),

+ 3 - 5
Sources/DbPackages-mysql.php

@@ -121,7 +121,7 @@ function smf_db_create_table($table_name, $columns, $indexes = array(), $paramet
 	// Righty - let's do the damn thing!
 	$table_query = 'CREATE TABLE ' . $table_name . "\n" . '(';
 	foreach ($columns as $column)
-		$table_query .= "\n\t" . smf_db_create_query_column($column);
+		$table_query .= "\n\t" . smf_db_create_query_column($column)  . ',';
 
 	// Loop through the indexes next...
 	foreach ($indexes as $index)
@@ -236,9 +236,7 @@ function smf_db_add_column($table_name, $column_info, $parameters = array(), $if
 	// Now add the thing!
 	$query = '
 		ALTER TABLE ' . $table_name . '
-		ADD `' . $column_info['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (empty($column_info['null']) ? 'NOT NULL' : '') . ' ' .
-			(!isset($column_info['default']) ? '' : 'default \'' . $smcFunc['db_escape_string']($column_info['default']) . '\'') . ' ' .
-			(empty($column_info['auto']) ? '' : 'auto_increment primary key') . ' ';
+		ADD ' . smf_db_create_query_column($column_info) . (empty($column_info['auto']) ? '' : ' primary key');
 	$smcFunc['db_query']('', $query,
 		array(
 			'security_override' => true,
@@ -645,7 +643,7 @@ function smf_db_create_query_column($column)
 		$type = $type . '(' . $size . ')';
 
 	// Now just put it together!
-	return '`' .$column['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ',';
+	return '`' .$column['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default;
 }
 
 ?>

+ 3 - 3
Sources/DbPackages-postgresql.php

@@ -397,12 +397,12 @@ function smf_db_change_column($table_name, $old_column, $column_info, $parameter
 		$smcFunc['db_transaction']('begin');
 		if (!$column_info['null'])
 		{
-			// We have to set it to something if we are making it NOT NULL.
-			$setTo = isset($column_info['default']) ? $column_info['default'] : '';
+			// We have to set it to something if we are making it NOT NULL. And we must comply with the current column format.
+			$setTo = isset($column_info['default']) ? $column_info['default'] : (strpos($old_info['type'], 'int') !== false ? 0 : '');
 			$smcFunc['db_query']('', '
 				UPDATE ' . $table_name . '
 				SET ' . $column_info['name'] . ' = \'' . $setTo . '\'
-				WHERE ' . $column_info['name'] . ' = NULL',
+				WHERE ' . $column_info['name'] . ' IS NULL',
 				array(
 					'security_override' => true,
 				)

+ 16 - 0
Sources/Display.php

@@ -1622,6 +1622,22 @@ function QuickInTopicModeration()
 	// We are restoring messages. We handle this in another place.
 	if (isset($_REQUEST['restore_selected']))
 		redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
+	if (isset($_REQUEST['split_selection']))
+	{
+		$request = $smcFunc['db_query']('', '
+			SELECT subject
+			FROM {db_prefix}messages
+			WHERE id_msg = {int:message}
+			LIMIT 1',
+			array(
+				'message' => min($messages),
+			)
+		);
+		list($subname) = $smcFunc['db_fetch_row']($request);
+		$smcFunc['db_free_result']($request);
+		$_SESSION['split_selection'][$topic] = $messages;
+		redirectexit('action=splittopics;sa=selectTopics;topic=' . $topic . '.0;subname_enc=' .urlencode($subname) . ';' . $context['session_var'] . '=' . $context['session_id']);
+	}
 
 	// Allowed to delete any message?
 	if (allowedTo('delete_any'))

+ 1 - 1
Sources/LogInOut.php

@@ -135,7 +135,7 @@ function Login2()
 	spamProtection('login');
 
 	// Set the login_url if it's not already set (but careful not to send us to an attachment).
-	if (empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
+	if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false))
 		$_SESSION['login_url'] = $_SESSION['old_url'];
 
 	// Been guessing a lot, haven't we?

+ 4 - 4
Sources/ManageMembergroups.php

@@ -328,7 +328,7 @@ function AddMembergroup()
 	global $context, $txt, $sourcedir, $modSettings, $smcFunc;
 
 	// A form was submitted, we can start adding.
-	if (!empty($_POST['group_name']))
+	if (isset($_POST['group_name']) && trim($_POST['group_name']) != '')
 	{
 		checkSession();
 		validateToken('admin-mmg');
@@ -355,7 +355,7 @@ function AddMembergroup()
 				'stars' => 'string', 'online_color' => 'string', 'group_type' => 'int',
 			),
 			array(
-				$id_group, '', $_POST['group_name'], ($postCountBasedGroup ? (int) $_POST['min_posts'] : '-1'),
+				$id_group, '', $smcFunc['htmlspecialchars']($_POST['group_name'], ENT_QUOTES), ($postCountBasedGroup ? (int) $_POST['min_posts'] : '-1'),
 				'1#star.gif', '', $_POST['group_type'],
 			),
 			array('id_group')
@@ -732,7 +732,7 @@ function EditMembergroup()
 				'group_hidden' => $_POST['group_hidden'],
 				'group_inherit' => $_POST['group_inherit'],
 				'current_group' => (int) $_REQUEST['group'],
-				'group_name' => $_POST['group_name'],
+				'group_name' => $smcFunc['htmlspecialchars']($_POST['group_name']),
 				'online_color' => $_POST['online_color'],
 				'stars' => $_POST['stars'],
 				'group_desc' => $_POST['group_desc'],
@@ -992,7 +992,7 @@ function EditMembergroup()
 		'id' => $_REQUEST['group'],
 		'name' => $row['group_name'],
 		'description' => htmlspecialchars($row['description']),
-		'editable_name' => htmlspecialchars($row['group_name']),
+		'editable_name' => $row['group_name'],
 		'color' => $row['online_color'],
 		'min_posts' => $row['min_posts'],
 		'max_messages' => $row['max_messages'],

+ 1 - 1
Sources/ManageMembers.php

@@ -281,7 +281,7 @@ function ViewMemberlist()
 		call_integration_hook('integrate_view_members_params', array(&$params));
 
 		$search_params = array();
-		if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST))
+		if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types']))
 			$search_params = @unserialize(base64_decode($_REQUEST['params']));
 		elseif (!empty($_POST))
 		{

+ 12 - 1
Sources/ManageSettings.php

@@ -39,7 +39,7 @@ function loadGeneralSettingParameters($subActions = array(), $defaultAction = ''
 	$context['sub_template'] = 'show_settings';
 
 	// By default do the basic settings.
-	$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (!empty($defaultAction) ? $defaultAction : array_pop($dummy = array_keys($subActions)));
+	$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (!empty($defaultAction) ? $defaultAction : array_pop($temp = array_keys($subActions)));
 	$context['sub_action'] = $_REQUEST['sa'];
 }
 
@@ -63,6 +63,13 @@ function ModifyFeatureSettings()
 
 	call_integration_hook('integrate_modify_features', array(&$subActions));
 
+	if (!in_array('cp', $context['admin_features']))
+		unset($subActions['profile']);
+
+	// Same for Karma
+	if (!in_array('k', $context['admin_features']))
+		unset($subActions['karma']);
+
 	loadGeneralSettingParameters($subActions, 'basic');
 
 	// Load up all the tabs...
@@ -107,6 +114,10 @@ function ModifySecuritySettings()
 
 	call_integration_hook('integrate_modify_security', array(&$subActions));
 
+	// If Warning System is disabled don't show the setting page
+	if (!in_array('w', $context['admin_features']))
+		unset($subActions['moderation']);
+
 	loadGeneralSettingParameters($subActions, 'general');
 
 	// Load up all the tabs...

+ 4 - 0
Sources/SplitTopics.php

@@ -197,6 +197,10 @@ function SplitSelectTopics()
 	// Haven't selected anything have we?
 	$_SESSION['split_selection'][$topic] = empty($_SESSION['split_selection'][$topic]) ? array() : $_SESSION['split_selection'][$topic];
 
+	// This is a special case for split topics from quick-moderation checkboxes
+	if (isset($_REQUEST['subname_enc']))
+		$_REQUEST['subname'] = urldecode($_REQUEST['subname_enc']);
+
 	$context['not_selected'] = array(
 		'num_messages' => 0,
 		'start' => empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'],

+ 19 - 0
Sources/Subs-Menu.php

@@ -238,6 +238,25 @@ function createMenu($menuData, $menuOptions = array())
 	// What about the toggle url?
 	$menu_context['toggle_url'] = isset($menuOptions['toggle_url']) ? $menuOptions['toggle_url'] : $menu_context['base_url'] . (!empty($menu_context['current_area']) ? ';area=' . $menu_context['current_area'] : '') . (!empty($menu_context['current_subsection']) ? ';sa=' . $menu_context['current_subsection'] : '') . $menu_context['extra_parameters'] . ';togglebar';
 
+	// If there are sections quickly goes through all the sections to check if the base menu has an url
+	if (!empty($menu_context['current_section']))
+	{
+		$menu_context['sections'][$menu_context['current_section']]['selected'] = true;
+		$menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['selected'] = true;
+		if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]))
+			$menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true;
+
+		foreach ($menu_context['sections'] as $section_id => $section)
+			foreach ($section['areas'] as $area_id => $area)
+			{
+				if (!isset($menu_context['sections'][$section_id]['url']))
+				{
+					$menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id;
+					break;
+				}
+			}
+	}
+
 	// If we didn't find the area we were looking for go to a default one.
 	if (isset($backup_area) && empty($found_section))
 		$menu_context['current_area'] = $backup_area;

+ 3 - 3
Sources/Subs-Post.php

@@ -3227,12 +3227,12 @@ function loadEmailTemplate($template, $replacements = array(), $lang = '', $load
 	if ($loadLang)
 		loadLanguage('EmailTemplates', $lang);
 
-	if (!isset($txt['emails_' . $template . '_subject']) || !isset($txt['emails_' . $template . '_body']))
+	if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body']))
 		fatal_lang_error('email_no_template', 'template', array($template));
 
 	$ret = array(
-		'subject' => $txt['emails_' . $template . '_subject'],
-		'body' => $txt['emails_' . $template . '_body'],
+		'subject' => $txt[$template . '_subject'],
+		'body' => $txt[$template . '_body'],
 	);
 
 	// Add in the default replacements.

+ 2 - 2
Sources/Subs.php

@@ -3016,6 +3016,7 @@ function template_header()
 				if (!file_exists($boarddir . '/' . $securityFile))
 					unset($securityFiles[$i]);
 			}
+
 			// We are already checking so many files...just few more doesn't make any difference! :P
 			if (!empty($modSettings['currentAttachmentUploadDir']))
 			{
@@ -3092,9 +3093,8 @@ function template_header()
 
 /**
  * Show the copyright.
- * @param bool $get_it = false
  */
-function theme_copyright($get_it = false)
+function theme_copyright()
 {
 	global $forum_copyright, $context, $boardurl, $forum_version, $txt, $modSettings;
 

+ 1 - 1
Themes/core/index.template.php

@@ -268,7 +268,7 @@ function template_body_above()
 	{
 		echo '
 				<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
-				<form class="windowbg" id="guest_form" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
+				<form class="windowbg" id="guest_form" action="', $scripturl, '?action=login2;quicklogin" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
 					', $context['can_register'] ? $txt['login_or_register'] : $txt['please_login'], '<br />
 					<input type="text" name="user" size="10" class="input_text" />
 					<input type="password" name="passwrd" size="10" class="input_password" />

+ 4 - 0
Themes/default/Display.template.php

@@ -781,6 +781,10 @@ function template_main()
 						sRestoreButtonLabel: \'', $txt['quick_mod_restore'], '\',
 						sRestoreButtonImage: \'restore_selected.gif\',
 						sRestoreButtonConfirm: \'', $txt['quickmod_confirm'], '\',
+						bCanSplit: ', $context['can_split'] ? 'true' : 'false', ',
+						sSplitButtonLabel: \'', $txt['quickmod_split_selected'], '\',
+						sSplitButtonImage: \'split_selected.gif\',
+						sSplitButtonConfirm: \'', $txt['quickmod_confirm'], '\',
 						sFormId: \'quickModForm\'
 					});';
 

+ 7 - 20
Themes/default/GenericMenu.template.php

@@ -126,15 +126,8 @@ function template_generic_menu_dropdown_above()
 	// Main areas first.
 	foreach ($menu_context['sections'] as $section)
 	{
-		if ($section['id'] == $menu_context['current_section'])
-		{
-			echo '
-			<li><a class="active firstlevel" href="#"><span class="firstlevel">', $section['title'] , '</span></a>
-				<ul>';
-		}
-		else
-			echo '
-			<li><a class="firstlevel" href="#"><span class="firstlevel">', $section['title'] , '</span></a>
+		echo '
+			<li><a class="', !empty($section['selected']) ? 'active ' : '', 'firstlevel" href="', $section['url'], $menu_context['extra_parameters'], '"><span class="firstlevel">', $section['title'] , '</span></a>
 				<ul>';
 
 		// For every area of this section show a link to that area (bold if it's currently selected.)
@@ -148,18 +141,12 @@ function template_generic_menu_dropdown_above()
 			echo '
 					<li', (++$additional_items > 6 && !empty($area['subsections'])) ? ' class="additional_items subsections"' : (($additional_items > 6) ? ' class="additional_items"' : ((!empty($area['subsections'])) ? ' class="subsections"' : '')), '>';
 
-			// Is this the current area, or just some area?
-			if ($i == $menu_context['current_area'])
-			{
-				echo '
-						<a class="chosen" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '"><span>', $area['icon'], $area['label'], !empty($area['subsections']) ? '...' : '', '</span></a>';
+			echo '
+						<a ', !empty($area['selected']) ? 'class="chosen" ' : '', 'href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '"><span>', $area['icon'], $area['label'], !empty($area['subsections']) ? '...' : '', '</span></a>';
 
-				if (empty($context['tabs']))
+			// Is this the current area, or just some area?
+			if (!empty($area['selected']) && empty($context['tabs']))
 					$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
-			}
-			else
-				echo '
-						<a href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '"><span>', $area['icon'], $area['label'], !empty($area['subsections']) ? '...' : '', '</span></a>';
 
 			// Is there any subsections?
 			$additional_items_sub = 0;
@@ -177,7 +164,7 @@ function template_generic_menu_dropdown_above()
 
 					echo '
 							<li', (++$additional_items_sub > 6) ? ' class="additional_items"' : '' ,'>
-								<a ', !empty($sub['selected']) ? 'class="active" ' : '', 'href="', $url, $menu_context['extra_parameters'], '"><span>', $sub['label'], '</span></a>
+								<a ', !empty($sub['selected']) ? 'class="chosen" ' : '', 'href="', $url, $menu_context['extra_parameters'], '"><span>', $sub['label'], '</span></a>
 							</li>';
 				}
 

+ 1 - 1
Themes/default/index.template.php

@@ -266,7 +266,7 @@ function template_body_above()
 	{
 		echo '
 				<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
-				<form id="guest_form" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
+				<form id="guest_form" action="', $scripturl, '?action=login2;quicklogin" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
 					<div class="info">', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $scripturl . '?action=login'), '</div>
 					<input type="text" name="user" size="10" class="input_text" />
 					<input type="password" name="passwrd" size="10" class="input_password" />

+ 1 - 0
Themes/default/languages/index.english.php

@@ -643,6 +643,7 @@ $txt['show_unread_replies'] = 'Show new replies to your posts.';
 $txt['change_color'] = 'Change Color';
 
 $txt['quickmod_delete_selected'] = 'Remove Selected';
+$txt['quickmod_split_selected'] = 'Split Selected';
 
 // In this string, don't use entities. (&amp;, etc.)
 $txt['show_personal_messages'] = 'You have received one or more new personal messages.\\nWould you like to open a new window to view them?';

+ 26 - 0
Themes/default/scripts/topic.js

@@ -453,6 +453,16 @@ InTopicModeration.prototype.handleClick = function(oCheckbox)
 				sCustom: ' onclick="return ' + this.opt.sSelf + '.handleSubmit(\'restore\')"'
 			});
 
+		// Add the 'split selected items' button.
+		if (this.opt.bCanSplit)
+			smf_addButton(this.opt.sButtonStrip, this.opt.bUseImageButton, {
+				sId: this.opt.sSelf + '_split_button',
+				sText: this.opt.sSplitButtonLabel,
+				sImage: this.opt.sSplitButtonImage,
+				sUrl: '#',
+				sCustom: ' onclick="return ' + this.opt.sSelf + '.handleSubmit(\'split\')"'
+			});
+
 		// Adding these buttons once should be enough.
 		this.bButtonsShown = true;
 	}
@@ -473,6 +483,12 @@ InTopicModeration.prototype.handleClick = function(oCheckbox)
 		document.getElementById(this.opt.sSelf + '_restore_button').style.display = this.iNumSelected < 1 ? "none" : "";
 	}
 
+	if (this.opt.bCanSplit && !this.opt.bUseImageButton)
+	{
+		setInnerHTML(document.getElementById(this.opt.sSelf + '_split_button'), this.opt.sSplitButtonLabel + ' [' + this.iNumSelected + ']');
+		document.getElementById(this.opt.sSelf + '_split_button').style.display = this.iNumSelected < 1 ? "none" : "";
+	}
+
 	// Try to restore the correct position.
 	var aItems = document.getElementById(this.opt.sButtonStrip).getElementsByTagName('span');
 	if (aItems.length > 3)
@@ -507,6 +523,7 @@ InTopicModeration.prototype.handleSubmit = function (sSubmitType)
 			if (!confirm(this.opt.sRemoveButtonConfirm))
 				return false;
 
+			oForm.action = oForm.action.replace(/;split_selection=1/, '');
 			oForm.action = oForm.action.replace(/;restore_selected=1/, '');
 		break;
 
@@ -514,9 +531,18 @@ InTopicModeration.prototype.handleSubmit = function (sSubmitType)
 			if (!confirm(this.opt.sRestoreButtonConfirm))
 				return false;
 
+			oForm.action = oForm.action.replace(/;split_selection=1/, '');
 			oForm.action = oForm.action + ';restore_selected=1';
 		break;
 
+		case 'split':
+			if (!confirm(this.opt.sRestoreButtonConfirm))
+				return false;
+
+			oForm.action = oForm.action.replace(/;restore_selected=1/, '');
+			oForm.action = oForm.action + ';split_selection=1';
+		break;
+
 		default:
 			return false;
 		break;