Selaa lähdekoodia

! [4974] : Incorrect Help (Language String?)for Input Masks for Custom Fields

Spuds 13 vuotta sitten
vanhempi
commit
374f9b09b3

+ 6 - 1
Sources/ManageSettings.php

@@ -1717,7 +1717,12 @@ function EditCustomProfiles()
 
 		// Everyone needs a name - even the (bracket) unknown...
 		if (trim($_POST['field_name']) == '')
-			fatal_lang_error('custom_option_need_name');
+			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
+
+		// Regex you say?  Do a very basic test to see if the pattern is valid
+		if (isset($_POST['regex']) && (empty($_POST['regex']) || @preg_match($_POST['regex'], 'dummy') === false))
+			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
+			
 		$_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']);
 		$_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']);
 

+ 13 - 2
Themes/default/Admin.template.php

@@ -1010,7 +1010,7 @@ function template_show_settings()
 function template_show_custom_profile()
 {
 	global $context, $txt, $settings, $scripturl;
-
+	
 	// Standard fields.
 	template_show_list('standard_profile_fields');
 
@@ -1031,11 +1031,22 @@ function template_edit_profile_field()
 {
 	global $context, $txt, $settings, $scripturl;
 
-	// All the javascript for this page - quite a bit!
+	// All the javascript for this page - quite a bit in script.js!
 	echo '
 	<script type="text/javascript"><!-- // --><![CDATA[
 		var startOptID = ', count($context['field']['options']), ';
 	// ]]></script>';
+	
+	// any errors messages to show?
+	if (isset($_GET['msg']))
+	{
+		loadLanguage('Errors');
+		if (isset($txt['custom_option_' . $_GET['msg']]))
+			echo '
+	<div class="errorbox">',
+		$txt['custom_option_' . $_GET['msg']], '
+	</div>';
+	}
 
 	echo '
 	<div id="admincenter">

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

@@ -371,6 +371,7 @@ $txt['resend_email_success'] = 'A new activation email has successfully been sen
 
 $txt['custom_option_need_name'] = 'The profile option must have a name!';
 $txt['custom_option_not_unique'] = 'Field name is not unique!';
+$txt['custom_option_regex_error'] = 'The regex you entered is not valid';
 
 $txt['warning_no_reason'] = 'You must enter a reason for altering the warning state of a member';
 $txt['warning_notify_blank'] = 'You selected to notify the user but did not fill in the subject/message fields';

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

@@ -595,11 +595,11 @@ $helptxt['field_show_enclosed'] = 'Encloses the user input between some text or
 
 $helptxt['custom_mask'] = 'The input mask is important for your forum\'s security. Validating the input from a user can help ensure that data is not used in a way you do not expect. We have provided some simple regular expressions as hints.<br /><br />
 	<div class="smalltext" style="margin: 0 2em">
-		&quot;[A-Za-z]+&quot; - Match all upper and lower case alphabet characters.<br />
-		&quot;[0-9]+&quot; - Match all numeric characters.<br />
-		&quot;[A-Za-z0-9]{7}&quot; - Match all upper and lower case alphabet and numeric characters seven times.<br />
-		&quot;[^0-9]?&quot; - Forbid any number from being matched.<br />
-		&quot;^([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})$&quot; - Only allow 3 or 6 character hexcodes.<br />
+		&quot;~[A-Za-z]+~&quot; - Match all upper and lower case alphabet characters.<br />
+		&quot;~[0-9]+~&quot; - Match all numeric characters.<br />
+		&quot;~[A-Za-z0-9]{7}~&quot; - Match all upper and lower case alphabet and numeric characters seven times.<br />
+		&quot;~[^0-9]?~&quot; - Forbid any number from being matched.<br />
+		&quot;~^([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})$~&quot; - Only allow 3 or 6 character hexcodes.<br />
 	</div><br /><br />
 	Additionally, special metacharacters ?+*^$ and {xx} can be defined.
 	<div class="smalltext" style="margin: 0 2em">