Duplicate User Module - Sitecore

Do you have a web organization based on users helping creating the content in a given period, and afterwards the needs of disabling the same users? Or do you need to duplicate a user who is on vacation, or a longer leave, letting a temporary user (placed at the same domain, containing the same domains to administrate and associated with the same roles) to do the work of the user, who is on leave? And are you tired of manually administrate who should be enabled and who should be disabled?


Would it not be nice to have a Sitecore Client Application allowing users (with access to the User Manager) to duplicate a given user in Sitecore into a new user, where the new user is placed in the same domain, containing the same domains to administrate and associated with the same roles as the original user? And finally letting the new user containing an expiration date, from when the new user will be disabled?


The objective of my Duplicate User module is to be able to do this in a quick way with functionality integrated directly into the User Manager in Sitecore.

Getting started with the Duplicate User Module

The Duplicate User application is into the User Manager. So getting started with the Duplicate User module, open the User Manager and you will find the "Duplicate Users" chunk and the "Duplicate User" command.


Select a user to duplicate and select the command, Sitecore will open the Duplicate User dialog containing the standard user data (Username, comment, fullname and Email). In addition, an expiration date, for the newly created user, is added. Furthermore, the Duplicate User dialog displays information about the user who is duplicated, who is duplicating the user (Created by) as well as the security settings of the duplicated user (The new user is created based on the custom user profile "Duplicated User". The Duplicate User diaolog:


Duplicate User Module Settings

The module settings are stored at “/sitecore/System/Modules/Duplicate User/”. The “Duplicated User Settings” item contain the ProfileItemID of the ProfileItem, which will be used as profileItem whenever a user is duplicated.

The folder “Domains” contains the domains, as sub items, from where the module will check for duplicated users to disable.

Sitecore Task

The Duplicate User module uses a single Sitecore task, to check duplicated users to disabled. By default, the Disable Duplicate Users task is scheduled to run one time pr. The schedule is placed at “/sitecore/system/tasks/Schedules/Duplicated User/Check Duplicated Users” and the command is placed at “/sitecore/system/tasks/Commands/Duplicated User/Disable duplicated users”.


You can find the Duplicate User Module at Sitecores Marketplace.

Add Custom Command

Do you need to customize one of your Sitecore Client applications with a new command for handling something new functionality? Enhancing a Sitecore Client application is straight forward and takes only the following three steps:
  • Add Custom Command item definition in the Core database
    • Create a new Chunk item
    • Create a new Custom Command item (Based on the “Small Button” template)
  • Add the Custom Command Class Code
  • Add A Custom Command definition in the Command.config file
In the case of illustrating how to create your own Custom Command, I just want to create a very simple Custom Command (called “Refresh”), which only will refresh the User Manager – nothing more and nothing less. I want to add the Custom Command into a new Chunk (called “Refresh”).

Add Custom Command Item definition in the Core database

First, navigate to the Core Database and locate the Sitecore app you want to enhance. In this case, I want to enhance the User Manager located at “/Sitecore/content/Applications/Security/User Manager“.


If you want to create a new chunk containing your custom command, navigate to the “Ribbon” definition item and create your custom chunk (based on the “/System/Ribbon/Chunk” template. In this case, I name my new chunk “Refresh”:

After creating the custom chunk (or navigated to an existing chunk) , you can create your Custom Command. Select the “/System/Ribbon/Small Button” template:


The Custom Command definition item contains seven fields. Most important is:
  • “Header”: The name of the custom command displayed in the chunk of the Sitecore application).
  • Click”: Bind your Custom Command Item definition to your Custom Command Class Code. In this case “MyCommands:Refresh”.
  • “Icon”: The icon to be displayed.

The Custom Command Class code

Now it is time for do the coding. In the case of my Refresh command I only need the following code:

Adding the Custom Command definition to Command.config

The final step is to create the custom command definition in the “/App_Config/Commands.config” file, or even better into an include file places at “/App_Config/Include/MyProject.Command.config”:

Validate The Refresh Command in the User Manager

Open your User Manager and select your Custom Command “Refresh”:


Furthermore

You can add parameters to you custom command:


In this case, Sitecore will pass the ID of the selected item to the command.

If you want to run an ASPX file as the custom application, you could do this simple by adding:


Remove Template Language Version

Have you created a new language version of a template by accident and now you want to remove the language version?

By default the template Manager in Sitecore does not provide the functionality you need to remove a language version of a template (in this case, I have created a danish language version):


If you want to delete the language version, you should open your dbbrowser (http://[your domain]/sitecore/admin/dbbrowser.aspx). Select the template and make sure, you have selected the correct language version (in this case - the Danish language) and select the "Delete version" command.


Going back to the Template Manager and select the template. Now the danish language version of the template has been deleted.