Browse Source

Merge pull request #6 from emanuele45/master

small changes
Spuds 13 years ago
parent
commit
71e715d41e

+ 1 - 1
Sources/Karma.php

@@ -104,7 +104,7 @@ function ModifyKarma()
 	{
 		// If you are gonna try to repeat.... don't allow it.
 		if ($action == $dir)
-			fatal_lang_error('karma_wait_time', false, array($modSettings['karmaWaitTime'], $txt['hours']));
+			fatal_lang_error('karma_wait_time', false, array($modSettings['karmaWaitTime'], ($modSettings['karmaWaitTime'] == 1 ? strtolower($txt['hour']) : $txt['hours'])));
 
 		// You decided to go back on your previous choice?
 		$smcFunc['db_query']('', '

+ 8 - 1
Sources/ManageServer.php

@@ -343,10 +343,17 @@ function ModifyCacheSettings($return_config = false)
 		saveDBSettings($config_vars);
 
 		// We have to manually force the clearing of the cache otherwise the changed settings might not get noticed.
+		$cache_enable = $modSettings['cache_enable'];
 		$modSettings['cache_enable'] = 1;
 		cache_put_data('modSettings', null, 90);
+		$modSettings['cache_enable'] = $cache_enable;
 
-		redirectexit('action=admin;area=serversettings;sa=cache;' . $context['session_var'] . '=' . $context['session_id']);
+		if ($modSettings['cache_enable'] == 0)
+		{
+			loadLanguage('ManageMaintenance');
+			createToken('admin-maint');
+			$context['template_layers'][] = 'clean_cache_button';
+		}
 	}
 
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cache;save';

+ 39 - 10
Sources/ScheduledTasks.php

@@ -16,7 +16,9 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
-// This function works out what to do!
+/**
+ * This function works out what to do!
+ */
 function AutoTask()
 {
 	global $time_start, $modSettings, $smcFunc;
@@ -135,7 +137,9 @@ function AutoTask()
 	die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B");
 }
 
-// Function to sending out approval notices to moderators etc.
+/**
+ * Function to sending out approval notices to moderators etc.
+ */
 function scheduled_approval_notification()
 {
 	global $scripturl, $modSettings, $mbname, $txt, $sourcedir, $smcFunc;
@@ -349,7 +353,9 @@ function scheduled_approval_notification()
 	return true;
 }
 
-// Do some daily cleaning up.
+/**
+ * Do some daily cleaning up.
+ */
 function scheduled_daily_maintenance()
 {
 	global $smcFunc, $modSettings, $sourcedir, $db_type;
@@ -464,7 +470,9 @@ function scheduled_daily_maintenance()
 	return true;
 }
 
-// Auto optimize the database?
+/**
+ * Auto optimize the database?
+ */
 function scheduled_auto_optimize()
 {
 	global $modSettings, $smcFunc, $db_prefix, $db_type;
@@ -819,7 +827,9 @@ function scheduled_daily_digest()
 	return true;
 }
 
-// Like the daily stuff - just seven times less regular ;)
+/**
+ * Like the daily stuff - just seven times less regular ;)
+ */
 function scheduled_weekly_digest()
 {
 	global $is_weekly;
@@ -829,7 +839,9 @@ function scheduled_weekly_digest()
 	return scheduled_daily_digest();
 }
 
-// Send a bunch of emails from the mail queue.
+/**
+ * Send a bunch of emails from the mail queue.
+ */
 function ReduceMailQueue($number = false, $override_limit = false, $force_send = false)
 {
 	global $modSettings, $smcFunc, $sourcedir;
@@ -1027,7 +1039,9 @@ function ReduceMailQueue($number = false, $override_limit = false, $force_send =
 	return true;
 }
 
-// Calculate the next time the passed tasks should be triggered.
+/**
+ * Calculate the next time the passed tasks should be triggered.
+ */
 function CalculateNextTrigger($tasks = array(), $forceUpdate = false)
 {
 	global $modSettings, $smcFunc;
@@ -1091,7 +1105,9 @@ function CalculateNextTrigger($tasks = array(), $forceUpdate = false)
 		updateSettings(array('next_task_time' => $nextTaskTime));
 }
 
-// Simply returns a time stamp of the next instance of these time parameters.
+/**
+ * Simply returns a time stamp of the next instance of these time parameters.
+ */
 function next_time($regularity, $unit, $offset)
 {
 	// Just in case!
@@ -1154,7 +1170,9 @@ function next_time($regularity, $unit, $offset)
 	return $next_time;
 }
 
-// This loads the bare minimum data to allow us to load language files!
+/**
+ * This loads the bare minimum data to allow us to load language files!
+ */
 function loadEssentialThemeData()
 {
 	global $settings, $modSettings, $smcFunc, $mbname, $context, $sourcedir;
@@ -1207,6 +1225,9 @@ function loadEssentialThemeData()
 	loadLanguage('index+Modifications');
 }
 
+/**
+ * This retieves data (e.g. last version of SMF) from sm.org
+ */
 function scheduled_fetchSMfiles()
 {
 	global $sourcedir, $txt, $language, $settings, $forum_version, $modSettings, $smcFunc;
@@ -1269,6 +1290,9 @@ function scheduled_fetchSMfiles()
 	return true;
 }
 
+/**
+ * Happy birthday!!
+ */
 function scheduled_birthdayemails()
 {
 	global $modSettings, $sourcedir, $mbname, $txt, $smcFunc, $birthdayEmails;
@@ -1346,6 +1370,9 @@ function scheduled_birthdayemails()
 	return true;
 }
 
+/**
+ * Weekly maintenance
+ */
 function scheduled_weekly_maintenance()
 {
 	global $modSettings, $smcFunc;
@@ -1529,7 +1556,9 @@ function scheduled_weekly_maintenance()
 	return true;
 }
 
-// Perform the standard checks on expiring/near expiring subscriptions.
+/**
+ * Perform the standard checks on expiring/near expiring subscriptions.
+ */
 function scheduled_paid_subscriptions()
 {
 	global $txt, $sourcedir, $scripturl, $smcFunc, $modSettings, $language;

+ 11 - 3
Sources/Security.php

@@ -1096,7 +1096,7 @@ function showEmailAddress($userProfile_hideEmail, $userProfile_id)
 {
 	global $modSettings, $user_info;
 
-	// Should this users email address be shown?
+	// Should this user's email address be shown?
 	// If you're guest and the forum is set to hide email for guests: no.
 	// If the user is post-banned: no.
 	// If it's your own profile and you've set your address hidden: yes_permission_override.
@@ -1105,8 +1105,16 @@ function showEmailAddress($userProfile_hideEmail, $userProfile_id)
 	// If the forum is set to show full email addresses: yes.
 	// Otherwise: no_through_forum.
 
-	// @todo this is really hard to understand using the ternary operator. Change to regular if/switch syntax.
-	return (!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']) || isset($_SESSION['ban']['cannot_post']) ? 'no' : ((!$user_info['is_guest'] && $user_info['id'] == $userProfile_id && !$userProfile_hideEmail) || allowedTo('moderate_forum') ? 'yes_permission_override' : ($userProfile_hideEmail ? 'no' : (!empty($modSettings['make_email_viewable']) ? 'yes' : 'no_through_forum')));
+	if ((!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']) || isset($_SESSION['ban']['cannot_post']))
+		return 'no';
+	elseif ((!$user_info['is_guest'] && $user_info['id'] == $userProfile_id && !$userProfile_hideEmail) || allowedTo('moderate_forum'))
+		return 'yes_permission_override';
+	elseif ($userProfile_hideEmail)
+		return 'no';
+	elseif (!empty($modSettings['make_email_viewable']) )
+		return 'yes';
+	else
+		return 'no_through_forum';
 }
 
 /**

+ 1 - 3
Sources/Subs-Members.php

@@ -1099,7 +1099,7 @@ function membersAllowedTo($permission, $board_id = null)
  * @param string $email = false
  * @param string $membername = false
  * @param bool $post_count = false
- * @return the number of successful reattributed posts.
+ * @return nothing
  */
 function reattributePosts($memID, $email = false, $membername = false, $post_count = false)
 {
@@ -1177,8 +1177,6 @@ function reattributePosts($memID, $email = false, $membername = false, $post_cou
 			'memID' => $memID,
 		)
 	);
-
-	return $smcFunc['db_affected_rows']();
 }
 
 /**

+ 2 - 1
Sources/Subs-Package.php

@@ -427,7 +427,7 @@ function loadInstalledPackages()
  */
 function getPackageInfo($gzfilename)
 {
-	global $boarddir, $sourcedir;
+	global $boarddir, $sourcedir, $smcFunc;
 
 	// Extract package-info.xml from downloaded file. (*/ is used because it could be in any directory.)
 	if (strpos($gzfilename, 'http://') !== false)
@@ -462,6 +462,7 @@ function getPackageInfo($gzfilename)
 	$package = $packageInfo->to_array();
 	$package['xml'] = $packageInfo;
 	$package['filename'] = $gzfilename;
+	$package['name'] = $smcFunc['htmlspecialchars']($package['name']);
 
 	if (!isset($package['type']))
 		$package['type'] = 'modification';

+ 26 - 0
Themes/default/Admin.template.php

@@ -1621,4 +1621,30 @@ function template_php_info()
 	}
 }
 
+function template_clean_cache_button_above()
+{
+}
+
+function template_clean_cache_button_below()
+{
+	global $txt, $scripturl, $context;
+
+	echo '
+	<div class="cat_bar">
+		<h3 class="catbg">', $txt['maintain_cache'], '</h3>
+	</div>
+	<div class="windowbg">
+		<span class="topslice"><span></span></span>
+		<div class="content">
+			<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=cleancache" method="post" accept-charset="', $context['character_set'], '">
+				<p>', $txt['maintain_cache_info'], '</p>
+				<span><input type="submit" value="', $txt['maintain_run_now'], '" class="button_submit" /></span>
+				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
+				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '" />
+			</form>
+		</div>
+		<span class="botslice"><span></span></span>
+	</div>';
+}
+
 ?>

+ 1 - 1
Themes/default/languages/Help.english.php

@@ -333,7 +333,7 @@ $helptxt['localCookies'] = 'SMF uses cookies to store login information on the c
 	Especially when using SSI.php, global cookies are recommended.';
 $helptxt['enableBBC'] = 'Selecting this option will allow your members to use Bulletin Board Code (BBC) throughout the forum, allowing users to format their posts with images, type formatting and more.';
 $helptxt['time_offset'] = 'Not all forum administrators want their forum to use the same time zone as the server upon which it is hosted. Use this option to specify a time difference (in hours) from which the forum should operate from the server time. Negative and decimal values are permitted.';
-$helptxt['default_timezone'] = 'The server timezone tells PHP where your server is located. You should ensure this is set correctly, preferably to the country/city in which the city is located. You can find out more information on the <a href="http://www.php.net/manual/en/timezones.php" target="_blank">PHP Site</a>.';
+$helptxt['default_timezone'] = 'The server timezone tells PHP where your server is located. You should ensure this is set correctly, preferably to the country/city in which the server is located. You can find out more information on the <a href="http://www.php.net/manual/en/timezones.php" target="_blank">PHP Site</a>.';
 $helptxt['spamWaitTime'] = 'Here you can select the amount of time that must pass between postings. This can be used to stop people from "spamming" your forum by limiting how often they can post.';
 
 $helptxt['enablePostHTML'] = 'This will allow the posting of some basic HTML tags:

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

@@ -145,7 +145,6 @@ $txt['start_date_and_time'] = 'Start Date and Time';
 $txt['end_date_and_time'] = 'End Date and Time';
 $txt['edit'] = 'EDIT';
 $txt['one_username'] = 'Please enter one username only.';
-$txt['hour'] = 'Hour';
 $txt['minute'] = 'Minute';
 $txt['error_member_not_found'] = 'The member entered could not be found';
 $txt['member_already_subscribed'] = 'This member is already subscribed to this subscription. Please edit their existing subscription.';

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

@@ -285,6 +285,8 @@ $txt['www'] = 'WWW';
 $txt['by'] = 'by';
 
 $txt['hours'] = 'hours';
+// Used upper case in Paid subscriptions management
+$txt['hour'] = 'Hour';
 $txt['days_word'] = 'days';
 
 $txt['newest_member'] = ', our newest member.';