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.


Custom User Profile

This is an "How to" extend the Sitecore standard user profile by adding new properties to the Sitecore standard user profile and how to create a new custom user profile.

A Sitecore user represent an individual user accessing the system, whether it’s a user logging into the Sitecore client, visiting the published website etc. Sitecore associates a user with a user profile containing a default set of properties such as full name, Email address, the roles and domains the user is associated with. The default user profile template is stored in the core database and from here, you will be able to add new properties to the default user profile or you can create your own custom user profile – without any needs of coding.

Adding new properties to the default Sitecore user profile will only include step one. Adding a new custom user profile takes step one and two:

  1. Adding properties to the existing Sitecore user profile or Creating your own new custom user profile template in the core database containing your custom properties
  2. Adding a new Item for the profile definition using your newly created custom user profile

Adding properties to existing or custom user profile

The Sitecore user profiles are stored in the Core database located at /Sitecore/templates/System/Security. To add properties to the standard user profile select the “User” template and add properties like you would, when you create new templates.


When creating a new custom user profile you could inherit from the standard user profile or you could create your own based on the standard template. In the case of this review, I create a new custom user profile, and name it “My Custom User Profile”. It inherits from the Sitecore standard user profile and I add a “Phone number” field in the “Data” field section.



Next step is to add a new item for the profile definition (letting the new custom user profile appear in the User Manager tool).

Adding an new item for the profile definition

Letting the new custom user profile appears in the User Manager you have to create a new item for the profile definition based on the new custom user profile template. The profile definition item is also places in the Core database located at /Sitecore/system/Settings/security/profiles. Instead of creating a new item based on the User profile template select your custom user profile template (The profile definition item name will be displayed in the “Change User Profile” dialog, when you change your users profile to your new custom user profile).


Now you have a new profile definition item for the custom user profile containing the “Phone number” field in the “Data” field section.


Create a new Sitecore user

Following the simple step above you will now be able to add a user and change the user profile to the custom user profile.

Open the User Manager from the Master database and create a new user. Select the “My Custom User Profile” in the “User Profile” section.


After creating the new user, open the dialog containing the properties of the user and select the “Profile” tab. The user will contain the “Phone number” property.


Managing Sitecore Custom User Profile Properties though Sitecore API

Now we have added the customer user profile properties. Managing the custom properties though Sitecore API is straight forward. 

Setting my custom user profile property:

Sitecore.Security.UserProfile curUserProfile = Sitecore.Security.Accounts.User.Current.Profile;
curUserProfile.SetCustomProperty("Phone number", "+45 12345678");
curUserProfile.Save();

Retrieving my customer user profile property (as a string):

curUserProfile.GetCustomProperty("Phone number");

If you have added multiple custom properties, you could retrieve the keys of all the custom properties as a List <string>:

curUserProfile.GetCustomPropertyNames();


Sitecore Package Installation History

Do you want to se the history of your Sitecore packages? Who created the package, when the package was installed and who installed the package?


First, to clarify which values are added to the different fields, I created a user called "Rasmus admin" who created the new package and a user called "Rasmus editor" who installed the new package.

I added the "Genereal Info" to the package project. And added "Rasmus admin" as author and publisher:



After saving the package project and created the Sitecore package, start up the Installation Wizard


When the installation has finished navigate to Core database



Open your Content Editor and navigate to /sitecore/system/Packages/Installation history/. From here Sitecore lists all the packages installed in the current Sitecore solution. In the "Data" section you find info about who created the package etc.




If you want to see who installed the package and when it was installed - Open the "Statistics" field section of the "package item":










Remove Scripts from Rich Text Editor

Troubles in pasting/adding javascripts to your Rich Text Editor?

Whenever you puslish an item, Sitecore automaticly removes any scripts, you have added into the Rich Text Editor. To change this behavior open the web.config file and navigate to the setting "HtmlEditor.RemoveScripts and set the value to false.


Sitecore Azure

When I started looking into Sitecore Azure, the following was what I needed to find - not a long technical review written like a short story - but a very short sum up of the Sitecore Azure giving me just enough info for my further readings - hope you find it usefull ...

Options for Sitecore Azure deployment

Sitecore offers 3 options for Sitecore Azure 3.0 Deployment with Development environment on-premise for all solutions. Notice that you only have one Editing Farm per Environment – though many farms around the Windows Azure locations are possible.

  1. Azure Delivery (on-premises for Sitecore installation for content editing, and multiple Sitecore Content Delivery farms in multiple Azure locations)
  2. Azure Live Mode (Master Database maintained on Azure and normal Sitecore “Live mode”)
  3. Azure Authoring + Delivery (Full scaled Azure solution with content editing and content delivery in multiple Azure locations)

Using Sitecore Azure

Sitecore has created applications inside the Sitecore Desktop for creating and managing the Sitecore Azure environment, making it easy for you to manage your Sitecore Azure solution. This includes installations of Sitecore Azure, setting up the Azure environment and specifying the number of instances, size of the virtual machine, database options etc., deploy solution to the Azure cloud (for development, test or production environment) based on each Azure location.

Note: 
Some Sitecore Azure operations will course ASP.NET to restart. 
Sitecore Azure user interface may seem unresponsive because of long-running remote service calls.

Before starting up

Before starting up your Sitecore Azure project there are a lot consideration you should be aware of. To give you an idea hereof a couple of those could be:
  • Azure instances are volatile by design – design your architecture to reflect this
  • Consider any of your integrations to internal applications
  • For ASP.NET session management you should use the DistributedCacheSessionStateStoreProvider
  • SQL Azure limits the maximum database size to 150GB (At the moment)
  • Sitecore Azure does not support file media

Deployment of Sitecore DMS with Azure

It is posible to deploy Sitecore DMS on Microsoft Azure (Sitecoer Azuer 3) but you ave to follow certain guidelines considering three areas
  1. Computing resources
  2. Server chace for session state data
  3. Your database resources

Available Azure deployment locations

North Europe, West Europe, East Asia, South East Asia, South Central US, North Central US, East US, West US.

 Two types of subscriptions

  1. Microsoft Azure Subscription 
  2. Sitecore-Managed Azure Subscription (benefits of Sitecore’s automated features for managing Azure installations, licensing benefits to bursting and prioritized support etc)

Benefits of using Sitecore Azure

  • Scalability, stability (99,9%)
  • Easily create more environments as needed (a full size copy of production environment for performance testing, spin up environment when need it, an extra training environment for just 1 week or so…)
  • Deployment of new code without taking down the environment or restarting IIS (managed by Azure load balancer)
  • Load balancers, firewalls, sql redundancy is out of the box
  • Low cost – no need of in house servers

 Further readings

Microsoft Azure: http://www.windowsazure.com/en-us/
Microsoft Azure Privacy: http://www.windowsazure.com/en-us/support/trust-center/privacy/
Microsoft Azure pricing: http://www.windowsazure.com/en-us/pricing/calculator/
Sitecore Azure: http://sdn.sitecore.net/Products/Sitecore%20Azure/Sitecore%20Azure%203/Documentation.aspx

Custom Experience Buttons - Enhancing the Page Editor

Adding Custom Experience Buttons

Have you ever wondered how to edit your List Type field from the Page Editor whit out opening the content editor? Preparing Sitecore to enabling you to do that is actually straight forward.

Adding a Custom Experience button to the Page Editor takes the following two steps:
  • Create a new Custom Experience button item in the Core database
  • Assigning the Custom Experience button to the sublayout where the Custom Experience button should be displayed

Creating the new Custom Experience Button

First you have to create the new Custom Experience Button (CEB) item which should be displayed in the Page Editor. Open the content editor in the core database and navigate to “/sitecore/content/Applications/WebEdit/Custom Experience Buttons”. When you create the new CEB item from the “Custom Experience Buttons” item folder, you can choose among a couple of “
Edit” buttons. Select the “Field Editor Button.


The CEB item contains four fields in the “Data” field section. The “Header” field defines the header of the CEB. The “Icon” field defines the icon displayed in the Page Editor, where the CEB is assigned. In the “Fields – pipe …” field you define the list of field names you should be able to edit from the specific Custom Experience Button. The value in the last field, the “Tooltip” field, will be displayed when you hover the mouse over the button in the Page Editor.


Assigning the Custom Experience Button

After creating the CEB item and filled in the fields at the item, you go back to the Content Editor for the Master database and assigning the new CEB to the sublayouts from where the CEB should be accessed. In the “Editor Options” field section find the “Page Editor Buttons” multilist and select your CEB item.


Validate the Custom Editor Button 

Open your Page Editor and navigate to a page where the sublayout is used and you will find your new Custom Editor Button.


Selecting the button and you will get a dialog box containing your fields added at on the fields added at your Custom Editor Button in the Core database.




Managing the "Source" of the Content Editor

Are you tired of switching between the Master, Web and Core database while developing?!

You can easily add a new Content Editor application (or actually an application shortcut pointing at the Core or Web database) displaying the items from Core or Web, respectively.


How to do that?

Open the Content Editor at the Core database. Navigate to “/Sitecore/content/Documents and Settings/All Users/Start menu/Left”. Create an item based on the “Application shortcut” template (or copying the existing “Content Editor” item).


You should use the “Parameters” field to manage from which database (Web or Core) the Content Editor displays the content.

(Remember to change/add values that clearly specify which database the current Content Editor displays. It’s also a good idea to setup the security settings for the new Content Editors, so it’s only the administrator/developer accessing the new Content Editors)