Browse Source

Merge pull request #245 from emanuele45/master

fixes
emanuele45 12 years ago
parent
commit
a3118ee0a0

+ 2 - 2
SSI.php

@@ -1287,10 +1287,10 @@ function ssi_showPoll($topic = null, $output_method = 'echo')
 
 	$return = array(
 		'id' => $row['id_poll'],
-		'image' => empty($pollinfo['voting_locked']) ? 'poll' : 'locked_poll',
+		'image' => empty($row['voting_locked']) ? 'poll' : 'locked_poll',
 		'question' => $row['question'],
 		'total_votes' => $total,
-		'is_locked' => !empty($pollinfo['voting_locked']),
+		'is_locked' => !empty($row['voting_locked']),
 		'allow_vote' => $allow_vote,
 		'allow_view_results' => $allow_view_results,
 		'topic' => $topic

+ 1 - 1
Sources/Load.php

@@ -1110,7 +1110,7 @@ function loadMemberContext($user, $display_custom_fields = false)
 
 	// Load this if set isn't minimal, it is still a monstrous array...
 	if ($context['loadMemberContext_set'] != 'minimal')
-		$memberContext[$user] = array(
+		$memberContext[$user] += array(
 			'is_buddy' => $profile['buddy'],
 			'is_reverse_buddy' => in_array($user_info['id'], $buddy_list),
 			'buddies' => $buddy_list,

+ 3 - 0
Sources/ManagePermissions.php

@@ -123,6 +123,7 @@ function PermissionIndex()
 			'can_search' => false,
 			'href' => '',
 			'link' => '',
+			'help' => 'membergroup_guests',
 			'is_post_group' => false,
 			'color' => '',
 			'icons' => '',
@@ -142,6 +143,7 @@ function PermissionIndex()
 			'allow_modify' => true,
 			'can_search' => false,
 			'href' => $scripturl . '?action=moderate;area=viewgroups;sa=members;group=0',
+			'help' => 'membergroup_regular_members',
 			'is_post_group' => false,
 			'color' => '',
 			'icons' => '',
@@ -188,6 +190,7 @@ function PermissionIndex()
 			'allow_modify' => $row['id_group'] > 1,
 			'can_search' => $row['id_group'] != 3,
 			'href' => $scripturl . '?action=moderate;area=viewgroups;sa=members;group=' . $row['id_group'],
+			'help' => $row['id_group'] == 1 ? 'membergroup_administrator' : ($row['id_group'] == 3 ? 'membergroup_moderator' : ''),
 			'is_post_group' => $row['min_posts'] != -1,
 			'color' => empty($row['online_color']) ? '' : $row['online_color'],
 			'icons' => !empty($row['icons'][0]) && !empty($row['icons'][1]) ? str_repeat('<img src="' . $settings['images_url'] . '/' . $row['icons'][1] . '" alt="*" />', $row['icons'][0]) : '',

+ 0 - 15
Sources/MessageIndex.php

@@ -635,21 +635,6 @@ function MessageIndex()
 			$context['can_remove'] |= ($started && allowedTo('remove_own'));
 		}
 
-		// Find the boards/cateogories they can move their topic to.
-		if ($options['display_quick_mod'] == 1 && $context['can_move'] && !empty($context['topics']))
-		{
-			require_once($sourcedir . '/Subs-MessageIndex.php');
-			$boardListOptions = array(
-				'excluded_boards' => array($board),
-				'not_redirection' => true,
-				'use_permissions' => true,
-				'selected_board' => empty($_SESSION['move_to_topic']) ? null : $_SESSION['move_to_topic'],
-			);
-
-			// With no other boards to see, it's useless to move.
-			if (empty($context['move_to_boards']))
-				$context['can_move'] = false;
-		}
 		// Can we use quick moderation checkboxes?
 		if ($options['display_quick_mod'] == 1)
 			$context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore'];

+ 4 - 2
Sources/Security.php

@@ -106,7 +106,7 @@ function is_not_guest($message = '')
 	global $user_info, $txt, $context, $scripturl;
 
 	// Luckily, this person isn't a guest.
-	if (!$user_info['is_guest'])
+	if (isset($user_info['is_guest']) && !$user_info['is_guest'])
 		return;
 
 	// People always worry when they see people doing things they aren't actually doing...
@@ -1254,7 +1254,9 @@ RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml';
 		if ($fh) {
 			fwrite($fh, '<?php
 
-// This file is here solely to protect your ' . $directoryname . ' directory.
+/**
+ * This file is here solely to protect your ' . $directoryname . ' directory.
+ */
 
 // Look for Settings.php....
 if (file_exists(dirname(dirname(__FILE__)) . \'/Settings.php\'))

+ 41 - 3
Sources/Subs-Attachments.php

@@ -18,6 +18,12 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
+/**
+ * Check if the current directory is still valid or not.
+ * If not creates the new directory
+ *
+ * @return (bool) false if any error occurred
+ */
 function automanage_attachments_check_directory()
 {
 	global $boarddir, $modSettings, $context;
@@ -113,6 +119,13 @@ function automanage_attachments_check_directory()
 	return $outputCreation;
 }
 
+/**
+ * Creates a directory
+ *
+ * @param $updir: the directory to be created
+ *
+ * @return (bool) false on errors
+ */
 function automanage_attachments_create_directory($updir)
 {
 	global $modSettings, $initial_error, $context, $boarddir;
@@ -149,6 +162,7 @@ function automanage_attachments_create_directory($updir)
 		$count--;
 	}
 
+	// @todo: chmod (especially with some servers) is usually bad
 	if (!is_writable($directory))
 	{
 		chmod($directory, 0755);
@@ -177,7 +191,7 @@ function automanage_attachments_create_directory($updir)
 	// Only update if it's a new directory
 	if (!in_array($updir, $modSettings['attachmentUploadDir']))
 	{
-		$modSettings['currentAttachmentUploadDir'] = max(array_keys($modSettings['attachmentUploadDir'])) +1;
+		$modSettings['currentAttachmentUploadDir'] = max(array_keys($modSettings['attachmentUploadDir'])) + 1;
 		$modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']] = $updir;
 
 		updateSettings(array(
@@ -191,6 +205,12 @@ function automanage_attachments_create_directory($updir)
 	return true;
 }
 
+/**
+ * Called when a directory space limit is reached.
+ * Creates a new directory and increments the directory suffix number.
+ *
+ * @return (bool) false on erros
+ */
 function automanage_attachments_by_space()
 {
 	global $modSettings, $boarddir, $context;
@@ -198,7 +218,7 @@ function automanage_attachments_by_space()
 	if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1))
 		return;
 
-	$basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir);
+	$basedirectory = !empty($modSettings['use_subdirectories_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : $boarddir;
 	//Just to be sure: I don't want directory separators at the end
 	$sep = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\/' : DIRECTORY_SEPARATOR;
 	$basedirectory = rtrim($basedirectory, $sep);
@@ -234,6 +254,13 @@ function automanage_attachments_by_space()
 		return false;
 }
 
+/**
+ * Split a path into a list of all directories and subdirectories
+ *
+ * @param $directory a path
+ *
+ * @return (mixed) an array of all the directories and subdirectories or false on failure
+ */
 function get_directory_tree_elements ($directory)
 {
 	/*
@@ -247,7 +274,7 @@ function get_directory_tree_elements ($directory)
 		$tree = preg_split('#[\\\/]#', $directory);
 	else
 	{
-		if (substr($directory, 0, 1)!=DIRECTORY_SEPARATOR)
+		if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR)
 			return false;
 
 		$tree = explode(DIRECTORY_SEPARATOR, trim($directory,DIRECTORY_SEPARATOR));
@@ -255,6 +282,14 @@ function get_directory_tree_elements ($directory)
 	return $tree;
 }
 
+/**
+ * Return the first part of a path (i.e. c:\ or / + the first directory), used by automanage_attachments_create_directory
+ *
+ * @param $tree an array 
+ * @param $count the number of elements in $tree
+ *
+ * @return (string)
+ */
 function attachments_init_dir (&$tree, &$count)
 {
 	$directory = '';
@@ -274,6 +309,9 @@ function attachments_init_dir (&$tree, &$count)
 	return $directory;
 }
 
+/**
+ * Moves an attachment to the proper directory and set the relevant data into $_SESSION['temp_attachments']
+ */
 function processAttachments()
 {
 	global $context, $modSettings, $smcFunc, $txt, $user_info;

+ 3 - 6
Sources/Subs.php

@@ -2810,8 +2810,7 @@ function setupThemeContext($forceload = false)
 	$context['show_quick_login'] = !empty($modSettings['enableVBStyleLogin']) && $user_info['is_guest'];
 
 	// Get some news...
-	$context['news_lines'] = explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))));
-	$context['fader_news_lines'] = array();
+	$context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news'])))));
 	for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++)
 	{
 		if (trim($context['news_lines'][$i]) == '')
@@ -2819,11 +2818,9 @@ function setupThemeContext($forceload = false)
 
 		// Clean it up for presentation ;).
 		$context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i);
-
-		// Gotta be special for the javascript.
-		$context['fader_news_lines'][$i] = strtr(addslashes($context['news_lines'][$i]), array('/' => '\/', '<a href=' => '<a hre" + "f='));
 	}
-	$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
+	if (!empty($context['news_lines']))
+		$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
 
 	if (!$user_info['is_guest'])
 	{

+ 8 - 11
Themes/default/BoardIndex.template.php

@@ -23,23 +23,20 @@ function template_main()
 	</div>';
 
 	// Show the news fader?  (assuming there are things to show...)
-	if ($settings['show_newsfader'] && !empty($context['fader_news_lines']))
+	if ($settings['show_newsfader'] && !empty($context['news_lines']))
 	{
 		echo '
 	<div id="newsfader">
 		<div class="cat_bar">
 			<h3 class="catbg">
-				<img id="newsupshrink" src="', $settings['images_url'], '/collapse.png" alt="*" title="', $txt['upshrink_description'], '" align="bottom" style="display: none;" />
+				<img id="newsupshrink" src="', $settings['images_url'], '/collapse.png" alt="*" title="', $txt['hide'], '" align="bottom" style="display: none;" />
 				', $txt['news'], '
 			</h3>
 		</div>
-		<ul class="reset" id="smfFadeScroller"', empty($options['collapse_news_fader']) ? '' : ' style="display: none;"', '>';
-
-			foreach ($context['news_lines'] as $news)
-				echo '
-			<li>', $news, '</li>';
-
-	echo '
+		<ul class="reset" id="smfFadeScroller"', empty($options['collapse_news_fader']) ? '' : ' style="display: none;"', '>
+			<li>
+				', implode('</li><li>', $context['news_lines']), '
+			</li>
 		</ul>
 	</div>
 	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/fader.js"></script>
@@ -63,9 +60,9 @@ function template_main()
 				{
 					sId: \'newsupshrink\',
 					srcExpanded: smf_images_url + \'/collapse.png\',
-					altExpanded: ', JavaScriptEscape($txt['upshrink_description']), ',
+					altExpanded: ', JavaScriptEscape($txt['hide']), ',
 					srcCollapsed: smf_images_url + \'/expand.png\',
-					altCollapsed: ', JavaScriptEscape($txt['upshrink_description']), '
+					altCollapsed: ', JavaScriptEscape($txt['show']), '
 				}
 			],
 			oThemeOptions: {

+ 2 - 2
Themes/default/ManagePermissions.template.php

@@ -37,7 +37,7 @@ function template_permission_index()
 			</div>';
 
 		echo '
-			<table width="100%" class="table_grid">
+			<table class="table_grid">
 				<thead>
 					<tr class="catbg">
 						<th class="first_th">', $txt['membergroups_name'], '</th>
@@ -67,7 +67,7 @@ function template_permission_index()
 		echo '
 					<tr class="windowbg', $alternate ? '2' : '', '">
 						<td>
-							', $group['id'] == -1 ? ' <a class="help" href="' . $scripturl . '?action=helpadmin;help=membergroup_guests" onclick="return reqOverlayDiv(this.href);"><img class="icon" style="vertical-align: top" src="' . $settings['images_url'] . '/helptopics.png" alt="' . $txt['help'] . '" /></a>' : ($group['id'] == 0 ? ' <a class="help" href="' . $scripturl . '?action=helpadmin;help=membergroup_regular_members" onclick="return reqOverlayDiv(this.href);"><img class="icon" style="vertical-align: top" src="' . $settings['images_url'] . '/helptopics.png" alt="' . $txt['help'] . '" /></a>' : ($group['id'] == 1 ? ' <a class="help" href="' . $scripturl . '?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);"><img class="icon" style="vertical-align: top" src="' . $settings['images_url'] . '/helptopics.png" alt="' . $txt['help'] . '" /></a>' : ($group['id'] == 3 ? ' <a class="help" href="' . $scripturl . '?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);"><img class="icon" style="vertical-align: top" src="' . $settings['images_url'] . '/helptopics.png" alt="' . $txt['help'] . '" /></a>' : '<img class="icon" style="vertical-align: top" src="' . $settings['images_url'] . '/blank.png" width="16px" alt="' . $txt['help'] . '" />'))), '&nbsp;<span>', $group['name'], '</span>';
+							', !empty($group['help']) ? ' <a class="help" href="' . $scripturl . '?action=helpadmin;help=' . $group['help'] . '" onclick="return reqOverlayDiv(this.href);"><img class="icon" src="' . $settings['images_url'] . '/helptopics.png" alt="' . $txt['help'] . '" /></a>' : '<img class="icon" src="' . $settings['images_url'] . '/blank.png" alt="' . $txt['help'] . '" />', '&nbsp;<span>', $group['name'], '</span>';
 
 		if (!empty($group['children']))
 			echo '

+ 7 - 0
Themes/default/css/admin.css

@@ -879,6 +879,13 @@ dl.settings dd.small_caption {
 }
 /* Styles for the manage permissions section.
 ------------------------------------------------- */
+#permissionForm .table_grid {
+	width: 100%;
+}
+#permissionForm .table_grid img.icon {
+	vertical-align: top;
+	width: 16px;
+}
 dl.admin_permissions dt {
 	width: 35%;
 }

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

@@ -325,7 +325,7 @@ function template_body_above()
 	echo'
 					</div>';
 	// Show a random news item? (or you could pick one from news_lines...)
-	if (!empty($settings['enable_news']))
+	if (!empty($settings['enable_news']) && !empty($context['random_news_line']))
 		echo '
 					<div class="news">
 						<h2>', $txt['news'], ': </h2>

+ 1 - 1
Themes/default/scripts/topic.js

@@ -189,7 +189,7 @@ QuickModifyTopic.prototype.modify_topic_hide_edit = function (subject)
 // keypress event ... like enter or escape
 QuickModifyTopic.prototype.modify_topic_keypress = function (oEvent)
 {
-	if (typeof(oEvent.keyCode) != "undefined")
+	if (typeof(oEvent.keyCode) != "undefined" && this.bInEditMode)
 	{
 		if (oEvent.keyCode == 27)
 		{

+ 3 - 3
other/upgrade.php

@@ -985,7 +985,7 @@ function WelcomeLogin()
 	);
 
 	require_once($sourcedir . '/Security.php');
-	createToken('login');
+	$upcontext += createToken('login');
 
 	// Check the cache directory.
 	$cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir;
@@ -3642,8 +3642,8 @@ function template_welcome_message()
 		<script type="text/javascript" src="http://www.simplemachines.org/smf/current-version.js?version=' . SMF_VERSION . '"></script>
 		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
 			<h3>', sprintf($txt['upgrade_ready_proceed'], SMF_VERSION), '</h3>
-	<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform" ', empty($upcontext['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $upcontext['rid'] . '\', \'' . (!empty($context['login_token']) ? $context['login_token'] : '') . '\');"' : '', '>
-		<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '" />
+	<form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform" ', empty($upcontext['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $upcontext['rid'] . '\', \'' . (!empty($upcontext['login_token']) ? $upcontext['login_token'] : '') . '\');"' : '', '>
+		<input type="hidden" name="', $upcontext['login_token_var'], '" value="', $upcontext['login_token'], '" />
 		<div id="version_warning" style="margin: 2ex; padding: 2ex; border: 2px dashed #a92174; color: black; background-color: #fbbbe2; display: none;">
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br />