Hello Emar,
You will need to create different alternative forms according to your needs. Let’s assume that I have two roles (
RoleA and
RoleB) and
CMS.News document type. So, I can create two alternative forms in
Site Manager -> Development -> Document types -> edit CMS.News -> Alternative forms. The first alternative form will be used for users of role
RoleA, so I will call it
insertRoleA, the second one will be used when editor of role RoleB creates document of type
CMS.News, so I will call it
insertRoleB.
Now, you need to modify
~\CMSModules\Content\CMSDesk\Edit\Edit.aspx.cs file and change the
AlternativeFormFullName property of the
CMSForm control dynamically depending on the role of the current user. So please go to
OnInit method and add following code marked as CUSTOM CODE:
formElem.FormMode = FormModeEnum.Insert;
string newClassName = ci.ClassName;
formElem.FormName = newClassName + ".default";
//////////////CUSTOM CODE////////////////
if (newClassName.Equals("CMS.News"))
{
if (CMS.CMSHelper.CMSContext.CurrentUser.IsInRole("RoleA", CMS.CMSHelper.CMSContext.CurrentSiteName))
{
formElem.AlternativeFormFullName = newClassName + ".insertRoleA";
}
else if (CMS.CMSHelper.CMSContext.CurrentUser.IsInRole("RoleB", CMS.CMSHelper.CMSContext.CurrentSiteName))
{
formElem.AlternativeFormFullName = newClassName + ".insertRoleB";
}
}
////////////////////////////////////////
}
else if (newculture)
You could do the same for updating alternative forms, for example
updateRoleA and
updateRoleB alternative forms.
In this case the following code needs to be used:
else
{
formElem.FormMode = FormModeEnum.Update;
ci = DataClassInfoProvider.GetDataClass(node.NodeClassName);
//////////////CUSTOM CODE////////////////
string newClassName = ci.ClassName;
if (newClassName.Equals("CMS.News"))
{
if (CMS.CMSHelper.CMSContext.CurrentUser.IsInRole("RoleA", CMS.CMSHelper.CMSContext.CurrentSiteName))
{
formElem.AlternativeFormFullName = newClassName + ".updateRoleA";
}
else if (CMS.CMSHelper.CMSContext.CurrentUser.IsInRole("RoleB", CMS.CMSHelper.CMSContext.CurrentSiteName))
{
formElem.AlternativeFormFullName = newClassName + ".updateRoleB";
}
}
////////////////////////////////////////
}
formElem.Visible = true;
I hope this will help you.
Best regards,
Michal Legen