Browse Source

! cleanup some comments and indentation
! change compare to a straight logical

Signed-off-by: Spuds <[email protected]>

Spuds 11 years ago
parent
commit
04272dd5ee
2 changed files with 24 additions and 24 deletions
  1. 22 22
      Sources/Drafts.php
  2. 2 2
      Themes/default/scripts/drafts.js

+ 22 - 22
Sources/Drafts.php

@@ -39,7 +39,7 @@ function SaveDraft(&$post_errors)
 	$draft_info = ReadDraft($id_draft);
 
 	// A draft has been saved less than 5 seconds ago, let's not do the autosave again
-	if (!empty($draft_info['poster_time']) && time() < $draft_info['poster_time'] + 5  && isset($_REQUEST['xml']))
+	if (isset($_REQUEST['xml']) && !empty($draft_info['poster_time']) && time() < $draft_info['poster_time'] + 5)
 	{
 		$context['draft_saved_on'] = $draft_info['poster_time'];
 
@@ -165,8 +165,8 @@ function SaveDraft(&$post_errors)
 
 /**
  * Saves a PM draft in the user_drafts table
- * The core draft feature must be enable, as well as the pm draft option
- * Determines if this is a new or and update to an existing draft
+ * The core draft feature must be enabled, as well as the pm draft option
+ * Determines if this is a new or and update to an existing pm draft
  *
  * @global type $context
  * @global type $user_info
@@ -189,11 +189,11 @@ function SavePMDraft(&$post_errors, $recipientList)
 	$draft_info = ReadDraft($id_pm_draft, 1);
 
 	// 5 seconds is the same limit we have for posting
-	if (!empty($draft_info['poster_time']) && time() < $draft_info['poster_time'] + 5  && isset($_REQUEST['xml']))
+	if (isset($_REQUEST['xml']) && !empty($draft_info['poster_time']) && time() < $draft_info['poster_time'] + 5)
 	{
 		$context['draft_saved_on'] = $draft_info['poster_time'];
 
-		// Send something back to the javascript
+		// Send something back to the javascript caller
 		if (!empty($id_draft))
 			XmlDraft($id_draft);
 
@@ -215,7 +215,7 @@ function SavePMDraft(&$post_errors, $recipientList)
 	$draft['body'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
 	$draft['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
 
-	// message and subject still need a bit more massaging
+	// message and subject always need a bit more work
 	preparsecode($draft['body']);
 	if ($smcFunc['strlen']($draft['subject']) > 100)
 		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
@@ -237,8 +237,8 @@ function SavePMDraft(&$post_errors, $recipientList)
 			array(
 				'id_reply' => $reply_id,
 				'type' => 1,
-				'poster_time' =>  time(),
-				'subject' =>  $draft['subject'],
+				'poster_time' => time(),
+				'subject' => $draft['subject'],
 				'body' => $draft['body'],
 				'id_pm_draft' => $id_pm_draft,
 				'to_list' => serialize($recipientList),
@@ -283,7 +283,7 @@ function SavePMDraft(&$post_errors, $recipientList)
 		// get the new id
 		$id_pm_draft = $smcFunc['db_insert_id']('{db_prefix}user_drafts', 'id_draft');
 
-		// everything go as expected, if not toss an error
+		// everything go as expected, if not toss back an error
 		if (!empty($id_pm_draft))
 		{
 			$context['draft_saved'] = true;
@@ -319,7 +319,7 @@ function ReadDraft($id_draft, $type = 0, $check = true, $load = false)
 {
 	global $context, $user_info, $smcFunc, $modSettings;
 
-	// always clean to be sure
+	// like purell always clean to be sure
 	$id_draft = (int) $id_draft;
 	$type = (int) $type;
 
@@ -547,7 +547,7 @@ function showProfileDrafts($memID, $draft_type = 0)
 
 	// Default to 10.
 	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
-		$_REQUEST['viewscount'] = '10';
+		$_REQUEST['viewscount'] = 10;
 
 	// Get the count of applicable drafts on the boards they can (still) see ...
 	// @todo .. should we just let them see their drafts even if they have lost board access ?
@@ -646,7 +646,7 @@ function showProfileDrafts($memID, $draft_type = 0)
 	}
 	$smcFunc['db_free_result']($request);
 
-	// All drafts were retrieved in reverse order, get them right again.
+	// If the drafts were retrieved in reverse order, get them right again.
 	if ($reverse)
 		$context['drafts'] = array_reverse($context['drafts'], true);
 
@@ -702,12 +702,12 @@ function showPMDrafts($memID = -1)
 
 	// Default to 10.
 	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
-		$_REQUEST['viewscount'] = '10';
+		$_REQUEST['viewscount'] = 10;
 
 	// Get the count of applicable drafts
 	$request = $smcFunc['db_query']('', '
 		SELECT COUNT(id_draft)
-		FROM {db_prefix}user_drafts AS ud
+		FROM {db_prefix}user_drafts
 		WHERE id_member = {int:id_member}
 			AND type={int:draft_type}' . (!empty($modSettings['drafts_keep_days']) ? '
 			AND poster_time > {int:time}' : ''),
@@ -847,14 +847,14 @@ function ModifyDraftSettings($return_config = false)
 
 	// Here are all the draft settings, a bit lite for now, but we can add more :P
 	$config_vars = array(
-			// Draft settings ...
-			array('check', 'drafts_post_enabled'),
-			array('check', 'drafts_pm_enabled'),
-			array('check', 'drafts_show_saved_enabled', 'subtext' => $txt['drafts_show_saved_enabled_subnote']),
-			array('int', 'drafts_keep_days', 'postinput' => $txt['days_word'], 'subtext' => $txt['drafts_keep_days_subnote']),
-			'',
-			array('check', 'drafts_autosave_enabled', 'subtext' => $txt['drafts_autosave_enabled_subnote']),
-			array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']),
+		// Draft settings ...
+		array('check', 'drafts_post_enabled'),
+		array('check', 'drafts_pm_enabled'),
+		array('check', 'drafts_show_saved_enabled', 'subtext' => $txt['drafts_show_saved_enabled_subnote']),
+		array('int', 'drafts_keep_days', 'postinput' => $txt['days_word'], 'subtext' => $txt['drafts_keep_days_subnote']),
+		'',
+		array('check', 'drafts_autosave_enabled', 'subtext' => $txt['drafts_autosave_enabled_subnote']),
+		array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']),
 	);
 
 	if ($return_config)

+ 2 - 2
Themes/default/scripts/drafts.js

@@ -77,7 +77,7 @@ smf_DraftAutoSave.prototype.draftSave = function ()
 	var sPostdata = $('#' + this.opt.sSceditorID).data("sceditor").getText(true);
 
 	// nothing to save or already posting or nothing changed?
-	if (isEmptyText(sPostdata) || smf_formSubmitted || this.sCheckDraft.localeCompare(sPostdata) == 0)
+	if (isEmptyText(sPostdata) || smf_formSubmitted || this.sCheckDraft == sPostdata)
 		return false;
 	
 	// Still saving the last one or other?
@@ -124,7 +124,7 @@ smf_DraftAutoSave.prototype.draftPMSave = function ()
 	var sPostdata = $('#' + this.opt.sSceditorID).data("sceditor").getText();
 	
 	// nothing to save or already posting or nothing changed?
-	if (isEmptyText(sPostdata) || smf_formSubmitted || this.sCheckDraft.localeCompare(sPostdata) == 0)
+	if (isEmptyText(sPostdata) || smf_formSubmitted || this.sCheckDraft == sPostdata)
 		return false;
 
 	// Still saving the last one or some other?