Procházet zdrojové kódy

Use logActions() to log multiple custom profile field changes in one go

Add hooks:
integrate_load_profile_fields
integrate_save_custom_profile_fields

Signed-off-by: John Rayes <[email protected]>
John Rayes před 12 roky
rodič
revize
8ade59da3f
2 změnil soubory, kde provedl 15 přidání a 12 odebrání
  1. 2 2
      Sources/MoveTopic.php
  2. 13 10
      Sources/Profile-Modify.php

+ 2 - 2
Sources/MoveTopic.php

@@ -296,7 +296,7 @@ function MoveTopic2()
 			$txt['movetopic_auto_board'] => '[url=' . $scripturl . '?board=' . $_POST['toboard'] . '.0]' . $board_name . '[/url]',
 			$txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $topic . '.0[/iurl]'
 		));
-		
+
 		// auto remove this MOVED redirection topic in the future?
 		$redirect_expires = !empty($_POST['redirect_expires']) ? ((int) ($_POST['redirect_expires'] * 60) + time()) : 0;
 
@@ -392,7 +392,7 @@ function moveTopics($topics, $toBoard)
 	// Empty array?
 	if (empty($topics))
 		return;
-		
+
 	// Only a single topic.
 	if (is_numeric($topics))
 		$topics = array($topics);

+ 13 - 10
Sources/Profile-Modify.php

@@ -671,6 +671,8 @@ function loadProfileFields($force_reload = false)
 		),
 	);
 
+	call_integration_hook('integrate_load_profile_fields', array($profile_fields));
+
 	$disabled_fields = !empty($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array();
 	// For each of the above let's take out the bits which don't apply - to save memory and security!
 	foreach ($profile_fields as $key => $field)
@@ -1261,6 +1263,8 @@ function makeCustomFieldChanges($memID, $area, $sanitize = true)
 	}
 	$smcFunc['db_free_result']($request);
 
+	call_integration_hook('integrate_save_custom_profile_fields', array($changes, $log_changes, $memID, $area, $sanitize));
+
 	// Make those changes!
 	if (!empty($changes) && empty($context['password_auth_failed']))
 	{
@@ -1273,8 +1277,7 @@ function makeCustomFieldChanges($memID, $area, $sanitize = true)
 		if (!empty($log_changes) && !empty($modSettings['modlog_enabled']))
 		{
 			require_once($sourcedir . '/Logging.php');
-			foreach ($log_changes as $log_change)
-				logAction($log_change['action'], $log_change['extra'], $log_change['log_type']);
+			logActions($log_changes);
 		}
 	}
 }
@@ -2879,21 +2882,21 @@ function profileValidateSignature(&$value)
 		$disabledTags = !empty($sig_bbc) ? explode(',', $sig_bbc) : array();
 
 		$unparsed_signature = strtr(un_htmlspecialchars($value), array("\r" => '', '&#039' => '\''));
-		
+
 		// Too many lines?
 		if (!empty($sig_limits[2]) && substr_count($unparsed_signature, "\n") >= $sig_limits[2])
 		{
 			$txt['profile_error_signature_max_lines'] = sprintf($txt['profile_error_signature_max_lines'], $sig_limits[2]);
 			return 'signature_max_lines';
 		}
-		
+
 		// Too many images?!
 		if (!empty($sig_limits[3]) && (substr_count(strtolower($unparsed_signature), '[img') + substr_count(strtolower($unparsed_signature), '<img')) > $sig_limits[3])
 		{
 			$txt['profile_error_signature_max_image_count'] = sprintf($txt['profile_error_signature_max_image_count'], $sig_limits[3]);
 			return 'signature_max_image_count';
 		}
-		
+
 		// What about too many smileys!
 		$smiley_parsed = $unparsed_signature;
 		parsesmileys($smiley_parsed);
@@ -2905,7 +2908,7 @@ function profileValidateSignature(&$value)
 			$txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]);
 			return 'signature_max_smileys';
 		}
-		
+
 		// Maybe we are abusing font sizes?
 		if (!empty($sig_limits[7]) && preg_match_all('~\[size=([\d\.]+)?(px|pt|em|x-large|larger)~i', $unparsed_signature, $matches) !== false && isset($matches[2]))
 		{
@@ -2929,7 +2932,7 @@ function profileValidateSignature(&$value)
 				}
 			}
 		}
-		
+
 		// The difficult one - image sizes! Don't error on this - just fix it.
 		if ((!empty($sig_limits[5]) || !empty($sig_limits[6])))
 		{
@@ -3014,7 +3017,7 @@ function profileValidateSignature(&$value)
 					$value = str_replace(array_keys($replaces), array_values($replaces), $value);
 			}
 		}
-		
+
 		// Any disabled BBC?
 		$disabledSigBBC = implode('|', $disabledTags);
 		if (!empty($disabledSigBBC))
@@ -3029,7 +3032,7 @@ function profileValidateSignature(&$value)
 	}
 
 	preparsecode($value);
-	
+
 	// Too long?
 	if (!allowedTo('admin_forum') && !empty($sig_limits[1]) && $smcFunc['strlen'](str_replace('<br />', "\n", $value)) > $sig_limits[1])
 	{
@@ -3072,7 +3075,7 @@ function profileValidateEmail($email, $memID = 0)
 			'email_address' => $email,
 		)
 	);
-	
+
 	if ($smcFunc['db_num_rows']($request) > 0)
 		return 'email_taken';
 	$smcFunc['db_free_result']($request);