4

Looking in the User Manager, I see a "Reset Settings" button under the "Change Password" button in the ribbon, and I cannot find any information online (docs or blog posts) on what it actually does. Can anyone describe the functionality of this button?

enter image description here

I am on Sitecore 8.1.2, but this button has been around for quite a while.

4

This code is execute when you click this button :

[Serializable]
public class ResetSettings : Command, ISupportsContinuation
{
    /// <summary>
    /// Executes the command in the specified context.
    /// </summary>
    /// <param name="context">The context.</param>
    public override void Execute(CommandContext context)
    {
        Assert.ArgumentNotNull(context, "context");
        string text = context.Parameters["username"];
        if (!ValidationHelper.ValidateUserWithMessage(text))
        {
            return;
        }
        System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection();
        nameValueCollection["username"] = text;
        ClientPipelineArgs args = new ClientPipelineArgs(nameValueCollection);
        ContinuationManager.Current.Start(this, "Run", args);
    }

    /// <summary>
    /// Runs the pipeline.
    /// </summary>
    /// <param name="args">The args.</param>
    protected void Run(ClientPipelineArgs args)
    {
        Assert.ArgumentNotNull(args, "args");
        ListString listString = new ListString(args.Parameters["username"]);
        if (args.IsPostBack)
        {
            if (args.Result == "yes")
            {
                foreach (string current in listString)
                {
                    User user = User.FromName(current, true);
                    Assert.IsNotNull(user, typeof(User));
                    UserProfile profile = user.Profile;
                    List<string> customPropertyNames = profile.GetCustomPropertyNames();
                    string value = "/" + current + "/";
                    foreach (string current2 in customPropertyNames)
                    {
                        if (current2.StartsWith(value, StringComparison.InvariantCultureIgnoreCase))
                        {
                            profile.RemoveCustomProperty(current2);
                        }
                    }
                    profile.Save();
                    RegistryCache registryCache = CacheManager.GetRegistryCache(Context.Site);
                    if (registryCache != null)
                    {
                        registryCache.Clear();
                    }
                    Log.Audit(this, "Reset settings: {0}", new string[]
                    {
                        user.Name
                    });
                }
                AjaxScriptManager.Current.Dispatch("usermanager:refresh");
                return;
            }
        }
        else
        {
            if (listString.Count == 1)
            {
                User user2 = User.FromName(listString[0], true);
                Assert.IsNotNull(user2, typeof(User));
                SheerResponse.Confirm(Translate.Text("Are you sure you want to reset the settings of {0}?", new object[]
                {
                    user2.GetLocalName()
                }));
            }
            else
            {
                SheerResponse.Confirm(Translate.Text("Are you sure you want to reset the settings of these {0} users?", new object[]
                {
                    listString.Count
                }));
            }
            args.WaitForPostBack();
        }
    }
}

Update:

Reset should remove only custom information like size of the dialogs or preselect options in some controls.

Example: You click on right corner Show Database Name for an editor.

enter image description here

If you press Reset Settings for that editor, Database Name will be reset and will not be shown on the bottom right corner.

  • Can you tell me a little about what the code is actually doing? – Zachary Kniebel Dec 12 '16 at 21:19
  • Reset should remove only custom information like size of the dialogs or preselect options in some controls. – Vlad Iobagiu Dec 12 '16 at 21:21
  • Honestly, this is not a good answer, as it stands right now. You need to describe what the button does. Just pasting the code is not enough! Especially when the code is so long and difficult to understand (unless you read such code all the time). – Dmytro Shevchenko Dec 13 '16 at 7:46
2

The "Reset Settings" button in the User Manager calls the usermanager:resetsettings command, which in turn executes the Sitecore.Shell.Framework.Commands.UserManager.ResetSettings command class.

On confirmation ("[Yes, I want to reset the settings of the user]"), the command loops through all of the custom properties of the UserProfile of the selected user with property names that start with /{username}/ (where {username} is the user's UserName), clearing each as it goes, and then ultimately saves the profile and refreshes the User Manager.

(Credit to Vlad Iobagiu for this detail) The custom properties that this button is meant to clear are properties that Sitecore uses to manage things like dialog size, pre-selected control options, and other user settings for the Sitecore client.

Note that the usermanager:resetsettings command can reset multiple users at the same time.

  • I tried to reset user custom property but it doesn't work. Looks like just some properties are reset. – Vlad Iobagiu Dec 12 '16 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.