Browse Source

Merge pull request #1118 from Arantor/release-2.1

Board index changes
Arantor 11 years ago
parent
commit
fc0ac33bb1

+ 42 - 31
Sources/BoardIndex.php

@@ -55,40 +55,24 @@ function BoardIndex()
 	);
 	$context['categories'] = getBoardIndex($boardIndexOptions);
 
-	// Get the user online list.
-	require_once($sourcedir . '/Subs-MembersOnline.php');
-	$membersOnlineOptions = array(
-		'show_hidden' => allowedTo('moderate_forum'),
-		'sort' => 'log_time',
-		'reverse_sort' => true,
-	);
-	$context += getMembersOnlineStats($membersOnlineOptions);
-
-	$context['show_buddies'] = !empty($user_info['buddies']);
-
-	// Are we showing all membergroups on the board index?
-	if (!empty($settings['show_group_key']))
-		$context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array());
-
-	// Track most online statistics? (Subs-MembersOnline.php)
-	if (!empty($modSettings['trackStats']))
-		trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']);
+	// Now set up for the info center.
+	$context['info_center'] = array();
 
 	// Retrieve the latest posts if the theme settings require it.
-	if (isset($settings['number_recent_posts']) && $settings['number_recent_posts'] > 1)
+	if (!empty($settings['number_recent_posts']))
 	{
-		$latestPostOptions = array(
-			'number_posts' => $settings['number_recent_posts'],
-		);
-		$context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions));
+		if ($settings['number_recent_posts'] > 1)
+		{
+			$latestPostOptions = array(
+				'number_posts' => $settings['number_recent_posts'],
+			);
+			$context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions));
+		}
+
+		if (!empty($context['latest_posts']) || !empty($context['latest_post']))
+			$context['info_center'][] = 'recent';
 	}
 
-	$settings['display_recent_bar'] = !empty($settings['number_recent_posts']) ? $settings['number_recent_posts'] : 0;
-	$settings['show_member_bar'] &= allowedTo('view_mlist');
-	$context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']);
-	$context['show_member_list'] = allowedTo('view_mlist');
-	$context['show_who'] = allowedTo('who_view') && !empty($modSettings['who_enabled']);
-
 	// Load the calendar?
 	if (!empty($modSettings['cal_enabled']) && allowedTo('calendar_view'))
 	{
@@ -106,10 +90,37 @@ function BoardIndex()
 
 		// This is used to show the "how-do-I-edit" help.
 		$context['calendar_can_edit'] = allowedTo('calendar_edit_any');
+
+		if ($context['show_calendar'])
+			$context['info_center'][] = 'calendar';
 	}
-	else
-		$context['show_calendar'] = false;
 
+	// And stats.
+	$context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']);
+	if ($settings['show_stats_index'])
+		$context['info_center'][] = 'stats';
+
+	// Now the online stuff
+	require_once($sourcedir . '/Subs-MembersOnline.php');
+	$membersOnlineOptions = array(
+		'show_hidden' => allowedTo('moderate_forum'),
+		'sort' => 'log_time',
+		'reverse_sort' => true,
+	);
+	$context += getMembersOnlineStats($membersOnlineOptions);
+	$context['show_buddies'] = !empty($user_info['buddies']);
+	$context['show_who'] = allowedTo('who_view') && !empty($modSettings['who_enabled']);
+	$context['info_center'][] = 'online';
+
+	// Track most online statistics? (Subs-MembersOnline.php)
+	if (!empty($modSettings['trackStats']))
+		trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']);
+
+	// Are we showing all membergroups on the board index?
+	if (!empty($settings['show_group_key']))
+		$context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array());
+
+	// And back to normality.
 	$context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']);
 
 	// Mark read button

+ 5 - 1
Sources/ScheduledTasks.php

@@ -1489,9 +1489,13 @@ function scheduled_weekly_maintenance()
 			$result = $smcFunc['db_query']('', '
 				SELECT id_report
 				FROM {db_prefix}log_reported
-				WHERE time_started < {int:time_started}',
+				WHERE time_started < {int:time_started}
+					AND closed = {int:not_closed}
+					AND ignore_all = {int:not_ignored}',
 				array(
 					'time_started' => $t,
+					'not_closed' => 0,
+					'not_ignored' => 0,
 				)
 			);
 

+ 8 - 0
Sources/Subs-Attachments.php

@@ -706,6 +706,14 @@ function createAttachment(&$attachmentOptions)
 			$attachmentOptions['mime_type'] = 'image/' . $validImageTypes[$size[2]];
 	}
 
+	// It is possible we might have a MIME type that isn't actually an image but still have a size.
+	// For example, Shockwave files will be able to return size but be 'application/shockwave' or similar.
+	if (!empty($attachmentOptions['mime_type']) && strpos($attachmentOptions['mime_type'], 'image/') !== 0)
+	{
+		$attachmentOptions['width'] = 0;
+		$attachmentOptions['height'] = 0;
+	}
+
 	// Get the hash if no hash has been given yet.
 	if (empty($attachmentOptions['file_hash']))
 		$attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true);

+ 110 - 115
Themes/default/BoardIndex.template.php

@@ -12,16 +12,6 @@
 
 function template_boardindex_outer_above()
 {
-	global $context, $settings, $options, $txt, $scripturl, $modSettings;
-
-	// Show some statistics if stat info is off.
-	if (!$settings['show_stats_index'])
-		echo '
-	<div id="index_common_stats">
-		', $txt['members'], ': ', $context['common_stats']['total_members'], ' &nbsp;&#8226;&nbsp; ', $txt['posts_made'], ': ', $context['common_stats']['total_posts'], ' &nbsp;&#8226;&nbsp; ', $txt['topics_made'], ': ', $context['common_stats']['total_topics'], '<br />
-		', $settings['show_latest_member'] ? ' ' . sprintf($txt['welcome_newest_member'], ' <strong>' . $context['common_stats']['latest_member']['link'] . '</strong>') : '' , '
-	</div>';
-
 	template_newsfader();
 }
 
@@ -236,6 +226,9 @@ function template_info_center()
 {
 	global $context, $settings, $options, $txt, $scripturl, $modSettings;
 
+	if (empty($context['info_center']))
+		return;
+
 	// Here's where the "Info Center" starts...
 	echo '
 	<div class="roundframe" id="info_center">
@@ -247,10 +240,59 @@ function template_info_center()
 		</div>
 		<div id="upshrinkHeaderIC"', empty($options['collapse_header_ic']) ? '' : ' style="display: none;"', '>';
 
-	// This is the "Recent Posts" bar.
-	if (!empty($settings['number_recent_posts']) && (!empty($context['latest_posts']) || !empty($context['latest_post'])))
+	foreach ($context['info_center'] as $block)
 	{
-		echo '
+		$func = 'template_ic_block_' . $block;
+		$func();
+	}
+
+	echo '
+		</div>
+	</div>';
+
+	// Info center collapse object.
+	echo '
+	<script type="text/javascript"><!-- // --><![CDATA[
+		var oInfoCenterToggle = new smc_Toggle({
+			bToggleEnabled: true,
+			bCurrentlyCollapsed: ', empty($options['collapse_header_ic']) ? 'false' : 'true', ',
+			aSwappableContainers: [
+				\'upshrinkHeaderIC\'
+			],
+			aSwapImages: [
+				{
+					sId: \'upshrink_ic\',
+					altExpanded: ', JavaScriptEscape($txt['hide']), ',
+					altCollapsed: ', JavaScriptEscape($txt['show']), '
+				}
+			],
+			aSwapLinks: [
+				{
+					sId: \'upshrink_link\',
+					msgExpanded: ', JavaScriptEscape(sprintf($txt['info_center_title'], $context['forum_name_html_safe'])), ',
+					msgCollapsed: ', JavaScriptEscape(sprintf($txt['info_center_title'], $context['forum_name_html_safe'])), '
+				}
+			],
+			oThemeOptions: {
+				bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
+				sOptionName: \'collapse_header_ic\',
+				sSessionId: smf_session_id,
+				sSessionVar: smf_session_var,
+			},
+			oCookieOptions: {
+				bUseCookie: ', $context['user']['is_guest'] ? 'true' : 'false', ',
+				sCookieName: \'upshrinkIC\'
+			}
+		});
+	// ]]></script>';
+}
+
+function template_ic_block_recent()
+{
+	global $context, $scripturl, $settings, $txt;
+
+	// This is the "Recent Posts" bar.
+	echo '
 			<div class="title_barIC">
 				<h4 class="titlebg">
 					<a href="', $scripturl, '?action=recent"><img class="icon" src="', $settings['images_url'], '/post/xx.png" alt="" />', $txt['recent_posts'], '</a>
@@ -262,19 +304,19 @@ function template_info_center()
 					<a rel="feedurl" href="', $scripturl, '?action=.xml;type=webslice">', $txt['subscribe_webslice'], '</a>
 				</div>';
 
-		// Only show one post.
-		if ($settings['number_recent_posts'] == 1)
-		{
-			// latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
-			echo '
+	// Only show one post.
+	if ($settings['number_recent_posts'] == 1)
+	{
+		// latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
+		echo '
 				<p id="infocenter_onepost" class="inline">
 					<a href="', $scripturl, '?action=recent">', $txt['recent_view'], '</a>&nbsp;&quot;', sprintf($txt['is_recent_updated'], '&quot;' . $context['latest_post']['link'], '&quot;'), ' (', $context['latest_post']['time'], ')<br />
 				</p>';
-		}
-		// Show lots of posts.
-		elseif (!empty($context['latest_posts']))
-		{
-			echo '
+	}
+	// Show lots of posts.
+	elseif (!empty($context['latest_posts']))
+	{
+		echo '
 				<table id="ic_recentposts">
 					<tr>
 						<th class="recentpost first_th">', $txt['message'], '</th>
@@ -283,74 +325,78 @@ function template_info_center()
 						<th class="recenttime last_th">', $txt['date'], '</th>
 					</tr>';
 
-			/* Each post in latest_posts has:
-					board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
-					subject, short_subject (shortened with...), time, link, and href. */
-			foreach ($context['latest_posts'] as $post)
-				echo '
+		/* Each post in latest_posts has:
+				board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
+				subject, short_subject (shortened with...), time, link, and href. */
+		foreach ($context['latest_posts'] as $post)
+			echo '
 					<tr>
 						<td class="recentpost"><strong>', $post['link'], '</strong></td>
 						<td class="recentposter">', $post['poster']['link'], '</td>
 						<td class="recentboard">', $post['board']['link'], '</td>
 						<td class="recenttime">', $post['time'], '</td>
 					</tr>';
-			echo '
-				</table>';
-		}
 		echo '
-			</div>';
+				</table>';
 	}
+	echo '
+			</div>';
+}
+
+function template_ic_block_calendar()
+{
+	global $context, $scripturl, $txt, $settings;
 
 	// Show information about events, birthdays, and holidays on the calendar.
-	if ($context['show_calendar'])
-	{
-		echo '
+	echo '
 			<div class="title_barIC">
 				<h4 class="titlebg">
 					<a href="', $scripturl, '?action=calendar' . '"><img class="icon" src="', $settings['images_url'], '/icons/calendar.png', '" alt="" />', $context['calendar_only_today'] ? $txt['calendar_today'] : $txt['calendar_upcoming'], '</a>
 				</h4>
 			</div>';
 
-		// Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P.
-		if (!empty($context['calendar_holidays']))
-			echo '
+	// Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P.
+	if (!empty($context['calendar_holidays']))
+		echo '
 				<p class="inline holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $context['calendar_holidays']), '</p>';
 
-		// People's birthdays. Like mine. And yours, I guess. Kidding.
-		if (!empty($context['calendar_birthdays']))
-		{
-			echo '
+	// People's birthdays. Like mine. And yours, I guess. Kidding.
+	if (!empty($context['calendar_birthdays']))
+	{
+		echo '
 				<p class="inline">
 					<span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span>';
-			// Each member in calendar_birthdays has: id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?)
-			foreach ($context['calendar_birthdays'] as $member)
-				echo '
-					<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong class="fix_rtl_names">' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', ';
+		// Each member in calendar_birthdays has: id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?)
+		foreach ($context['calendar_birthdays'] as $member)
 			echo '
+					<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong class="fix_rtl_names">' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', ';
+		echo '
 				</p>';
-		}
+	}
 
-		// Events like community get-togethers.
-		if (!empty($context['calendar_events']))
-		{
-			echo '
+	// Events like community get-togethers.
+	if (!empty($context['calendar_events']))
+	{
+		echo '
 				<p class="inline">
 					<span class="event">', $context['calendar_only_today'] ? $txt['events'] : $txt['events_upcoming'], '</span> ';
 
-			// Each event in calendar_events should have:
-			//		title, href, is_last, can_edit (are they allowed?), modify_href, and is_today.
-			foreach ($context['calendar_events'] as $event)
-				echo '
-					', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><img src="' . $settings['images_url'] . '/icons/calendar_modify.png" alt="*" class="centericon" /></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br />' : ', ';
+		// Each event in calendar_events should have:
+		//		title, href, is_last, can_edit (are they allowed?), modify_href, and is_today.
+		foreach ($context['calendar_events'] as $event)
 			echo '
+					', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><img src="' . $settings['images_url'] . '/icons/calendar_modify.png" alt="*" class="centericon" /></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br />' : ', ';
+		echo '
 				</p>';
-		}
 	}
+}
+
+function template_ic_block_stats()
+{
+	global $scripturl, $txt, $context, $settings;
 
 	// Show statistical style information...
-	if ($settings['show_stats_index'])
-	{
-		echo '
+	echo '
 			<div class="title_barIC">
 				<h4 class="titlebg">
 					<a href="', $scripturl, '?action=stats" title="', $txt['more_stats'], '"><span class="stats_icon boards"></span>', $txt['forum_stats'], '</a>
@@ -361,8 +407,11 @@ function template_info_center()
 				', (!empty($context['latest_post']) ? $txt['latest_post'] . ': <strong>&quot;' . $context['latest_post']['link'] . '&quot;</strong>  ( ' . $context['latest_post']['time'] . ' )<br />' : ''), '
 				<a href="', $scripturl, '?action=recent">', $txt['recent_view'], '</a>
 			</p>';
-	}
+}
 
+function template_ic_block_online()
+{
+	global $context, $scripturl, $txt, $modSettings;
 	// "Users online" - in order of activity.
 	echo '
 			<div class="title_barIC">
@@ -404,59 +453,5 @@ function template_info_center()
 
 	echo '
 			</p>';
-
-	// If they are logged in, but statistical information is off... show a personal message bar.
-	if ($context['user']['is_logged'] && !$settings['show_stats_index'])
-	{
-		echo '
-			<div class="title_barIC">
-				<h4 class="titlebg">
-					', $context['allow_pm'] ? '<a href="' . $scripturl . '?action=pm">' : '', '<span class="pm_icons inbox icon"></span>', $txt['personal_message'], '', $context['allow_pm'] ? '</a>' : '', '
-				</h4>
-			</div>
-			<p class="pminfo">
-					', empty($context['user']['messages']) ? $txt['you_have_no_msg'] : ($context['user']['messages'] == 1 ? sprintf($txt['you_have_one_msg'], $scripturl . '?action=pm') : sprintf($txt['you_have_many_msgs'], $scripturl . '?action=pm', $context['user']['messages'])), '
-			</p>';
-	}
-
-	echo '
-		</div>
-	</div>';
-
-	// Info center collapse object.
-	echo '
-	<script type="text/javascript"><!-- // --><![CDATA[
-		var oInfoCenterToggle = new smc_Toggle({
-			bToggleEnabled: true,
-			bCurrentlyCollapsed: ', empty($options['collapse_header_ic']) ? 'false' : 'true', ',
-			aSwappableContainers: [
-				\'upshrinkHeaderIC\'
-			],
-			aSwapImages: [
-				{
-					sId: \'upshrink_ic\',
-					altExpanded: ', JavaScriptEscape($txt['hide']), ',
-					altCollapsed: ', JavaScriptEscape($txt['show']), '
-				}
-			],
-			aSwapLinks: [
-				{
-					sId: \'upshrink_link\',
-					msgExpanded: ', JavaScriptEscape(sprintf($txt['info_center_title'], $context['forum_name_html_safe'])), ',
-					msgCollapsed: ', JavaScriptEscape(sprintf($txt['info_center_title'], $context['forum_name_html_safe'])), '
-				}
-			],
-			oThemeOptions: {
-				bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
-				sOptionName: \'collapse_header_ic\',
-				sSessionId: smf_session_id,
-				sSessionVar: smf_session_var,
-			},
-			oCookieOptions: {
-				bUseCookie: ', $context['user']['is_guest'] ? 'true' : 'false', ',
-				sCookieName: \'upshrinkIC\'
-			}
-		});
-	// ]]></script>';
 }
 ?>

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

@@ -25,6 +25,7 @@ $txt['mailqueue_recipient'] = 'Recipient';
 $txt['mailqueue_subject'] = 'Subject';
 $txt['mailqueue_clear_list'] = 'Send mail queue now';
 $txt['mailqueue_no_items'] = 'The mail queue is currently empty';
+$txt['personal_message'] = 'Personal Message';
 // Do not use numeric entities in below string.
 $txt['mailqueue_clear_list_warning'] = 'Are you sure you wish to send the whole mail queue now? This will override any limits you have set.';
 

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

@@ -82,8 +82,6 @@ $txt['position'] = 'Position';
 
 $txt['profile_of'] = 'View the profile of';
 $txt['total'] = 'Total';
-$txt['posts_made'] = 'Posts';
-$txt['topics_made'] = 'Topics';
 $txt['website'] = 'Website';
 $txt['register'] = 'Register';
 $txt['warning_status'] = 'Warning Status';
@@ -160,7 +158,6 @@ $txt['topic_alert_none'] = 'No messages...';
 $txt['pm_alert_none'] = 'No messages...';
 
 $txt['online_users'] = 'Users Online';
-$txt['personal_message'] = 'Personal Message';
 $txt['jump_to'] = 'Jump to';
 $txt['go'] = 'Go';
 $txt['are_sure_remove_topic'] = 'Are you sure you want to remove this topic?';
@@ -353,10 +350,6 @@ $txt['latest_member'] = 'Latest Member';
 $txt['total_cats'] = 'Total Categories';
 $txt['latest_post'] = 'Latest Post';
 
-$txt['you_have_no_msg'] = 'You don\'t have any message...';
-$txt['you_have_one_msg'] = 'You\'ve got 1 message... Click <a href="%1$s">here</a> to view it';
-$txt['you_have_many_msgs'] = 'You\'ve got %2$d messages... Click <a href="%1$s">here</a> to view them';
-
 $txt['total_boards'] = 'Total Boards';
 
 $txt['print_page'] = 'Print Page';