瀏覽代碼

Merge pull request #712 from Arantor/release-2.1

! I have no idea why drafts are disabled by default, that seems insane. ...
Arantor 11 年之前
父節點
當前提交
24f3247c28

+ 0 - 1
Sources/Admin.php

@@ -213,7 +213,6 @@ function AdminMain()
 					'function' => 'ModifyDraftSettings',
 					'icon' => 'drafts.png',
 					'permission' => array('admin_forum'),
-					'enabled' => in_array('dr', $context['admin_features']),
 				),
 				'managecalendar' => array(
 					'label' => $txt['manage_calendar'],

+ 1 - 1
Sources/Display.php

@@ -1115,7 +1115,7 @@ function Display()
 	$context['can_restore_msg'] &= !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $board && !empty($topicinfo['id_previous_topic']);
 
 	// Check if the draft functions are enabled and that they have permission to use them (for quick reply.)
-	$context['drafts_save'] = !empty($modSettings['drafts_enabled']) && !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply'];
+	$context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply'];
 	$context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']) && allowedTo('post_autosave_draft');
 	if (!empty($context['drafts_save']))
 		loadLanguage('Drafts');

+ 24 - 12
Sources/Drafts.php

@@ -33,7 +33,7 @@ function SaveDraft(&$post_errors)
 	global $context, $user_info, $smcFunc, $modSettings, $board;
 
 	// can you be, should you be ... here?
-	if (empty($modSettings['drafts_enabled']) || empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft']))
+	if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft']))
 		return false;
 
 	// read in what they sent us, if anything
@@ -183,7 +183,7 @@ function SavePMDraft(&$post_errors, $recipientList)
 	global $context, $user_info, $smcFunc, $modSettings;
 
 	// PM survey says ... can you stay or must you go
-	if (empty($modSettings['drafts_enabled']) || empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft']))
+	if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft']))
 		return false;
 
 	// read in what you sent us
@@ -848,7 +848,7 @@ function showPMDrafts($memID = -1)
  */
 function ModifyDraftSettings($return_config = false)
 {
-	global $context, $txt, $sourcedir, $scripturl;
+	global $context, $txt, $sourcedir, $scripturl, $smcFunc;
 
 	isAllowedTo('admin_forum');
 
@@ -885,23 +885,35 @@ function ModifyDraftSettings($return_config = false)
 		checkSession();
 
 		// Protect them from themselves.
-		$_POST['drafts_autosave_frequency'] = $_POST['drafts_autosave_frequency'] < 30 ? 30 : $_POST['drafts_autosave_frequency'];
+		$_POST['drafts_autosave_frequency'] = !isset($_POST['drafts_autosave_frequency']) || $_POST['drafts_autosave_frequency'] < 30 ? 30 : $_POST['drafts_autosave_frequency'];
+
+		// Also disable the scheduled task if we're not using it.
+		$smcFunc['db_query']('', '
+			UPDATE {db_prefix}scheduled_tasks
+			SET disabled = {int:disabled}
+			WHERE task = {string:task}',
+			array(
+				'disabled' => !empty($_POST['drafts_keep_days']) ? 0 : 1,
+				'task' => 'remove_old_drafts',
+			)
+		);
+		require_once($sourcedir . '/ScheduledTasks.php');
+		CalculateNextTrigger();
+
+		// Save everything else and leave.
 		saveDBSettings($config_vars);
 		redirectexit('action=admin;area=managedrafts');
 	}
 
 	// some javascript to enable / disable the frequency input box
 	$context['settings_post_javascript'] = '
-		var autosave = document.getElementById(\'drafts_autosave_enabled\');
-		createEventListener(autosave)
-		autosave.addEventListener(\'change\', toggle);
-		toggle();
-
 		function toggle()
 		{
-			var select_elem = document.getElementById(\'drafts_autosave_frequency\');
-			select_elem.disabled = !autosave.checked;
-		}
+			$("#drafts_autosave_frequency").prop("disabled", !($("#drafts_autosave_enabled").prop("checked")));
+		};
+		toggle();
+
+		$("#drafts_autosave_enabled").click(function() { toggle(); });
 	';
 
 	// Final settings...

+ 0 - 25
Sources/ManageSettings.php

@@ -195,31 +195,6 @@ function ModifyCoreFeatures($return_config = false)
 				'cal_enabled' => 1,
 			),
 		),
-		// dr = drafts
-		'dr' => array(
-			'url' => 'action=admin;area=managedrafts',
-			'settings' => array(
-				'drafts_enabled' => 1,
-				'drafts_post_enabled' => 2,
-				'drafts_pm_enabled' => 2,
-				'drafts_autosave_enabled' => 2,
-				'drafts_show_saved_enabled' => 2,
-			),
-			'setting_callback' => create_function('$value', '
-				global $smcFunc, $sourcedir;
-
-				// Set the correct disabled value for the scheduled task.
-				$smcFunc[\'db_query\'](\'\', \'
-					UPDATE {db_prefix}scheduled_tasks
-					SET disabled = {int:disabled}
-					WHERE task = {string:task}\',
-					array(
-						\'disabled\' => $value ? 0 : 1,
-						\'task\' => \'remove_old_drafts\',
-					)
-				);
-			'),
-		),
 		// k = karma.
 		'k' => array(
 			'url' => 'action=admin;area=featuresettings;sa=karma',

+ 2 - 2
Sources/PersonalMessage.php

@@ -175,7 +175,7 @@ function MessageMain()
 	$context['can_issue_warning'] = in_array('w', $context['admin_features']) && allowedTo('issue_warning') && $modSettings['warning_settings'][0] == 1;
 
 	// Are PM drafts enabled?
-	$context['drafts_pm_save'] = !empty($modSettings['drafts_enabled']) && !empty($modSettings['drafts_pm_enabled']) && allowedTo('pm_draft');
+	$context['drafts_pm_save'] = !empty($modSettings['drafts_pm_enabled']) && allowedTo('pm_draft');
 	$context['drafts_autosave'] = !empty($context['drafts_pm_save']) && !empty($modSettings['drafts_autosave_enabled']) && allowedTo('pm_autosave_draft');
 
 	// Build the linktree for all the actions...
@@ -247,7 +247,7 @@ function messageIndexBar($area)
 					'label' => $txt['drafts_show'],
 					'custom_url' => $scripturl . '?action=pm;sa=showpmdrafts',
 					'permission' => allowedTo('pm_draft'),
-					'enabled' => !empty($modSettings['drafts_enabled']) && !empty($modSettings['drafts_pm_enabled']),
+					'enabled' => !empty($modSettings['drafts_pm_enabled']),
 				),
 			),
 		),

+ 6 - 6
Sources/Post.php

@@ -1034,7 +1034,7 @@ function Post($post_errors = array())
 	$context['message'] = str_replace(array('"', '<', '>', '&nbsp;'), array('&quot;', '&lt;', '&gt;', ' '), $form_message);
 
 	// Are post drafts enabled?
-	$context['drafts_save'] = !empty($modSettings['drafts_enabled']) && !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft');
+	$context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft');
 	$context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']) && allowedTo('post_autosave_draft');
 
 	// Build a list of drafts that they can load in to the editor
@@ -1208,7 +1208,7 @@ function Post2()
 	loadLanguage('Post');
 
 	// Drafts enabled and needed?
-	if (!empty($modSettings['drafts_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft'])))
+	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft'])))
 		require_once($sourcedir . '/Drafts.php');
 
 	// First check to see if they are trying to delete any current attachments.
@@ -1331,7 +1331,7 @@ function Post2()
 			unset($_POST['sticky']);
 
 		// If drafts are enabled, then pass this off
-		if (!empty($modSettings['drafts_enabled']) && isset($_POST['save_draft']))
+		if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft']))
 		{
 			SaveDraft($post_errors);
 			return Post();
@@ -1376,7 +1376,7 @@ function Post2()
 			unset($_POST['sticky']);
 
 		// Saving your new topic as a draft first?
-		if (!empty($modSettings['drafts_enabled']) && isset($_POST['save_draft']))
+		if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft']))
 		{
 			SaveDraft($post_errors);
 			return Post();
@@ -1459,7 +1459,7 @@ function Post2()
 		}
 
 		// If drafts are enabled, then lets send this off to save
-		if (!empty($modSettings['drafts_enabled']) && isset($_POST['save_draft']))
+		if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft']))
 		{
 			SaveDraft($post_errors);
 			return Post();
@@ -1831,7 +1831,7 @@ function Post2()
 	}
 
 	// If we had a draft for this, its time to remove it since it was just posted
-	if (!empty($modSettings['drafts_enabled']) && !empty($_POST['id_draft']))
+	if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft']))
 		DeleteDraft($_POST['id_draft']);
 
 	// Editing or posting an event?

+ 1 - 1
Sources/Profile.php

@@ -121,7 +121,7 @@ function ModifyProfile($post_errors = array())
 					'label' => $txt['drafts_show'],
 					'file' => 'Drafts.php',
 					'function' => 'showProfileDrafts',
-					'enabled' => !empty($modSettings['drafts_enabled']) && $context['user']['is_owner'],
+					'enabled' => !empty($modSettings['drafts_post_enabled']) && $context['user']['is_owner'],
 					'permission' => array(
 						'own' => 'profile_view_own',
 						'any' =>  array(),

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

@@ -1127,7 +1127,7 @@ function template_send()
 	</form>';
 
 	// If the admin enabled the pm drafts feature, show a draft selection box
-	if (!empty($modSettings['drafts_enabled']) && !empty($context['drafts_pm_save']) && !empty($context['drafts']) && !empty($options['drafts_show_saved_enabled']))
+	if (!empty($context['drafts_pm_save']) && !empty($context['drafts']) && !empty($options['drafts_show_saved_enabled']))
 	{
 		echo '
 			<br />

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

@@ -490,7 +490,7 @@ function template_main()
 		echo '
 					</div>';
 	// If the admin enabled the drafts feature, show a draft selection box
-	if (!empty($modSettings['drafts_enabled']) && !empty($context['drafts']) && !empty($options['drafts_show_saved_enabled']))
+	if (!empty($modSettings['drafts_post_enabled']) && !empty($context['drafts']) && !empty($options['drafts_show_saved_enabled']))
 	{
 		echo '
 					<div id="postDraftOptionsHeader" class="title_bar">

+ 3 - 3
Themes/default/Profile.template.php

@@ -104,7 +104,7 @@ function template_summary()
 	echo '
 					<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '">', $txt['showPosts'], '</a><br />';
 
-	if ($context['user']['is_owner'] && !empty($modSettings['drafts_enabled']))
+	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled']))
 		echo '
 					<a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '">', $txt['drafts_show'], '</a><br />';
 
@@ -1638,7 +1638,7 @@ function template_profile_theme_settings()
 								</select>
 							</dd>';
 
-	if (!empty($modSettings['drafts_enabled']) && !empty($modSettings['drafts_autosave_enabled']))
+	if ((!empty($modSettings['drafts_post_enabled']) || !empty($modSettings['drafts_pm_enabled'])) && !empty($modSettings['drafts_autosave_enabled']))
 		echo '
 							<dt>
 								<label for="drafts_autosave_enabled">', $txt['drafts_autosave_enabled'], '</label>
@@ -1647,7 +1647,7 @@ function template_profile_theme_settings()
 								<input type="hidden" name="default_options[drafts_autosave_enabled]" value="0" />
 								<label for="drafts_autosave_enabled"><input type="checkbox" name="default_options[drafts_autosave_enabled]" id="drafts_autosave_enabled" value="1"', !empty($context['member']['options']['drafts_autosave_enabled']) ? ' checked="checked"' : '', ' class="input_check" /></label>
 							</dd>';
-	if (!empty($modSettings['drafts_enabled']) && !empty($modSettings['drafts_show_saved_enabled']))
+	if ((!empty($modSettings['drafts_post_enabled']) || !empty($modSettings['drafts_pm_enabled'])) && !empty($modSettings['drafts_show_saved_enabled']))
 		echo '
 							<dt>
 								<label for="drafts_show_saved_enabled">', $txt['drafts_show_saved_enabled'], '</label>

二進制
Themes/default/images/admin/feature_dr.png


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

@@ -298,8 +298,6 @@ $txt['core_settings_welcome_msg'] = 'Welcome to Your New Forum';
 $txt['core_settings_welcome_msg_desc'] = 'To get you started we suggest you select which of SMF\'s core features you want to enable. We\'d recommend only enabling with those features you need!';
 $txt['core_settings_item_cd'] = 'Calendar';
 $txt['core_settings_item_cd_desc'] = 'Enabling this feature will open up a selection of options to enable your users to view the calendar, add and review events, see users birthdates on a calendar and much, much more.';
-$txt['core_settings_item_dr'] = 'Drafts';
-$txt['core_settings_item_dr_desc'] = 'Enabling this feature will allow users to save drafts of their posts so they can return later to post them.';
 $txt['core_settings_item_k'] = 'Karma';
 $txt['core_settings_item_k_desc'] = 'Karma is a feature that shows the popularity of a member. Members, if allowed, can \'applaud\' or \'smite\' other members, which is how their popularity is calculated.';
 $txt['core_settings_item_ml'] = 'Moderation, Administration and User Logs';

+ 2 - 0
other/install_2-1_mysql.sql

@@ -1869,6 +1869,8 @@ VALUES ('smfVersion', '{$smf_version}'),
 	('avatar_reencode', '1'),
 	('avatar_paranoid', '0'),
 	('enable_unwatch', '0'),
+	('drafts_post_enabled', '1'),
+	('drafts_pm_enabled', '1'),
 	('drafts_autosave_enabled', '1'),
 	('drafts_show_saved_enabled', '1'),
 	('drafts_keep_days', '7');

+ 2 - 0
other/install_2-1_postgresql.sql

@@ -2369,6 +2369,8 @@ INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachment_thumb_png
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_reencode', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_paranoid', '0');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enable_unwatch', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_post_enabled', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_pm_enabled', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_autosave_enabled', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_show_saved_enabled', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_keep_days', '7');

+ 2 - 0
other/install_2-1_sqlite.sql

@@ -2018,6 +2018,8 @@ INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachment_thumb_png
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_reencode', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_paranoid', '0');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enable_unwatch', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_post_enabled', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_pm_enabled', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_autosave_enabled', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_show_saved_enabled', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_keep_days', '7');

+ 2 - 0
other/install_2-1_sqlite3.sql

@@ -2018,6 +2018,8 @@ INSERT INTO {$db_prefix}settings (variable, value) VALUES ('attachment_thumb_png
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_reencode', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_paranoid', '0');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enable_unwatch', '0');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_post_enabled', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_pm_enabled', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_autosave_enabled', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_show_saved_enabled', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('drafts_keep_days', '7');