Browse Source

Merge pull request #1346 from Arantor/release-2.1

More things to tweak.
Arantor 10 years ago
parent
commit
38efbdb740
2 changed files with 11 additions and 13 deletions
  1. 10 12
      Sources/ManageSettings.php
  2. 1 1
      Themes/default/Profile.template.php

+ 10 - 12
Sources/ManageSettings.php

@@ -1596,26 +1596,24 @@ function EditCustomProfiles()
 			if (isset($matches[1]))
 				$colname = $initial_colname = 'cust_' . strtolower($matches[1]);
 			else
-				$colname = $initial_colname = 'cust_' . mt_rand(1, 999);
+				$colname = $initial_colname = 'cust_' . mt_rand(1, 9999);
 
 			// Make sure this is unique.
-			// @todo This may not be the most efficient way to do this.
+			$current_fields = array();
+			$request = $smcFunc['db_query']('', '
+				SELECT id_field, col_name
+				FROM {db_prefix}custom_fields');
+			while ($row = $smcFunc['db_fetch_assoc']($request))
+				$current_fields[$row['id_field']] = $row['col_name'];
+			$smcFunc['db_free_result']($request);
+
 			$unique = false;
 			for ($i = 0; !$unique && $i < 9; $i ++)
 			{
-				$request = $smcFunc['db_query']('', '
-					SELECT id_field
-					FROM {db_prefix}custom_fields
-					WHERE col_name = {string:current_column}',
-					array(
-						'current_column' => $colname,
-					)
-				);
-				if ($smcFunc['db_num_rows']($request) == 0)
+				if (!in_array($colname, $current_fields))
 					$unique = true;
 				else
 					$colname = $initial_colname . $i;
-				$smcFunc['db_free_result']($request);
 			}
 
 			// Still not a unique colum name? Leave it up to the user, then.

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

@@ -2502,7 +2502,7 @@ function template_issueWarning()
 									<div id="warning_progress" style="width: ', $context['member']['warning'], '%; height: 12pt; z-index: 1; background-color: ', $context['current_color'], ';">&nbsp;</div>
 								</div>
 								<span class="floatleft" style="padding: 0 0.5em"><a href="#" onclick="changeWarnLevel(5); return false;">[+]</a></span>
-								<div class="clear_left smalltext">', $txt['profile_warning_impact'], ': <span id="cur_level_div">', $context['level_effects'][$context['current_level']], '</span></div>
+								<div class="clear_left">', $txt['profile_warning_impact'], ': <span id="cur_level_div">', $context['level_effects'][$context['current_level']], '</span></div>
 							</div>
 							<input type="hidden" name="warning_level" id="warning_level" value="SAME">
 						</div>