diff --git a/Site/App_GlobalResources/Global.designer.cs b/Site/App_GlobalResources/Global.designer.cs
index 02d5c537..b39be29e 100644
--- a/Site/App_GlobalResources/Global.designer.cs
+++ b/Site/App_GlobalResources/Global.designer.cs
@@ -1491,6 +1491,15 @@ namespace Resources {
}
}
+ ///
+ /// Looks up a localized string similar to This doesn't look like a valid phone number, but we're storing it as written here..
+ ///
+ internal static string Master_EditPersonWarning_Phone {
+ get {
+ return ResourceManager.GetString("Master_EditPersonWarning_Phone", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to You are currently logged into <strong>{0}</strong>. Would you like to switch to another organization?.
///
diff --git a/Site/App_GlobalResources/Global.resx b/Site/App_GlobalResources/Global.resx
index c0339e2c..2b725c60 100644
--- a/Site/App_GlobalResources/Global.resx
+++ b/Site/App_GlobalResources/Global.resx
@@ -755,4 +755,8 @@
Mail a password-reset link
+
+ This doesn't look like a valid phone number, but we're storing it as written here.
+ Trigges as a notice if phone misses a regexp.
+
\ No newline at end of file
diff --git a/Site/Automation/SwarmFunctions.aspx.cs b/Site/Automation/SwarmFunctions.aspx.cs
index 10bdcee6..494adae1 100644
--- a/Site/Automation/SwarmFunctions.aspx.cs
+++ b/Site/Automation/SwarmFunctions.aspx.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Text.RegularExpressions;
using System.Web;
using System.Web.Services;
using System.Web.UI;
@@ -263,6 +264,11 @@ namespace Swarmops.Frontend.Automation
[WebMethod]
public static AjaxInputCallResult SetPersonEditorData(int personId, string field, string newValue)
{
+ if (newValue == null || field == null)
+ {
+ throw new ArgumentNullException();
+ }
+
AuthenticationData authData = GetAuthenticationDataAndCulture();
bool self = false;
@@ -279,7 +285,7 @@ namespace Swarmops.Frontend.Automation
return new AjaxInputCallResult
{
Success = false,
- DisplayMessage = JavascriptEscape(Resources.Global.Global_FieldCannotBeEmpty),
+ DisplayMessage = Resources.Global.Global_FieldCannotBeEmpty,
FailReason = AjaxInputCallResult.ErrorInvalidFormat,
NewValue = GetPersonValue (personId, field)
};
@@ -301,6 +307,8 @@ namespace Swarmops.Frontend.Automation
}
string oldValue;
+ string displayMessage = string.Empty;
+ newValue = newValue.Trim().Replace (" ", " ");
switch (field)
{
@@ -315,8 +323,17 @@ namespace Swarmops.Frontend.Automation
case "Phone":
oldValue = affectedPerson.Phone;
affectedPerson.Phone = newValue;
+ if (!Regex.IsMatch (newValue, @"^[0-9 \(\)\-\+]+$"))
+ {
+ // using characters not typically seen in a phone number? Warn
+ displayMessage = Resources.Global.Master_EditPersonWarning_Phone;
+ }
break;
case "TwitterId":
+ if (newValue.StartsWith ("@"))
+ {
+ newValue = newValue.Substring (1);
+ }
oldValue = affectedPerson.TwitterId;
affectedPerson.TwitterId = newValue;
break;
@@ -329,7 +346,7 @@ namespace Swarmops.Frontend.Automation
ActingPersonId = authData.CurrentUser.PersonId,
AffectedPersonId = affectedPerson.PersonId,
Field = field,
- IpAddress = HttpContext.Current.Request.UserHostAddress,
+ IpAddress = SupportFunctions.GetMostLikelyRemoteIPAddress(),
OldValue = oldValue,
NewValue = newValue
});
@@ -342,7 +359,8 @@ namespace Swarmops.Frontend.Automation
return new AjaxInputCallResult
{
Success = true,
- NewValue = newValue
+ NewValue = newValue,
+ DisplayMessage = displayMessage
};
}
diff --git a/Site/Master-v5.master b/Site/Master-v5.master
index 57f9e2a7..d6ab6c09 100644
--- a/Site/Master-v5.master
+++ b/Site/Master-v5.master
@@ -420,10 +420,13 @@
console.log(result);
if (result.Success) {
window[controlName + "_updateSuccessAnimate"](result.NewValue);
+ if (result.DisplayMessage != '') {
+ alertify.log(result.DisplayMessage);
+ }
} else {
window[controlName + "_updateFailAnimate"](result.NewValue);
if (result.DisplayMessage != '') {
- alertify.error(SwarmopsJS.unescape(result.DisplayMessage));
+ alertify.error(result.DisplayMessage);
}
}
},