Permissions and workflow

Posted by Community Admin on 04-Aug-2018 18:01

Permissions and workflow

All Replies

Posted by Community Admin on 18-Mar-2013 00:00

Is it possible to have multiple workflows for pages enabled at the same time?  One workflow for "Business Section" and another for "Human Resources" section?  The would be independent of each other.  I'm wondering if this scenario is possible.  I'm finding that there is very little documentation on extending workflows.

Also, is it possible to "break inheritance" on a localized version of a page?  Or all all language versions considered the same?

Posted by Community Admin on 21-Mar-2013 00:00

Hello David,

This would require the creation of a custom workflow. You can read more about custom workflows here:

www.sitefinity.com/.../custom-workflow

 We have actually started developing a sample for a workflow that sets different approvers on different parts of the SiteMap. The class is still not finished, but you can used it as an example:

protected override void Execute(CodeActivityContext context)
        
            if (ClaimsManager.IsUnrestricted())
                return;
  
            var workflowDefinition = (WorkflowDefinition)context.DataContext.GetProperties()["workflowDefinition"].GetValue(context.DataContext);
  
            //gets the permissions
            //var permissions = WorkflowPermissions.Split(new string[] "," , StringSplitOptions.RemoveEmptyEntries);
            bool userHasWorkflowPermission = false;
  
            //gets currently approved pageNode
            var item = context.DataContext.GetProperties()["workflowItem"];
            var page = item.GetValue(context.DataContext) as ISecuredObject;
            var pageManager = PageManager.GetManager();
            var node = pageManager.GetPageNode(page.Id);
  
            //gets current user
            var userID = SecurityManager.GetCurrentUserId();
            var roleManager = RoleManager.GetManager();
            var role = roleManager.GetRoles().Where(r => r.Name == "HomePageApprover").FirstOrDefault();
            bool isUserInRole = roleManager.IsUserInRole(userID, role.Id);
  
                    if (node.Title == "homepage")
                    
                        if (isUserInRole)
                        
                            userHasWorkflowPermission = true;
                        
                        else
                        
                            throw new WorkflowSecurityException(String.Format("User should be in role 0", "TestRole"));
                        
  
                    
                    else
                    
                        if (isUserInRole)
                        
                            throw new WorkflowSecurityException(String.Format("User should not be in role 0", "TestRole"));
                        
                        else
                        
                            userHasWorkflowPermission = true;
                        
                    
 
As for your other question, if your pages are synced, they will be represented by one node, so the permissions, which are set to the first page, will be set to its multilingual equivelent, as well. However, if you have split pages, you will be able to set different permissions for them.

All the best,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 25-Mar-2013 00:00

If the page that I'm working with is multilingual, how would I get the ApprovalWorkflowState of each language? 
This is what I've done so far, but its only getting the current page's state.

01.//gets currently approved pageNode
02.            var item = context.DataContext.GetProperties()["workflowItem"];
03.             
04.            var page = item.GetValue(context.DataContext) as ISecuredObject;
05.            var pageManager = PageManager.GetManager();
06.            var node = pageManager.GetPageNode(page.Id);
07.            var pageProperties = pageManager.GetProperties();
08. 
09.            Telerik.Sitefinity.Pages.Model.PageData pageData = pageManager.GetPageData(node.PageId);
10.             
11.             
12.            //gets current user
13.            var userID = SecurityManager.GetCurrentUserId();
14.            var roleManager = RoleManager.GetManager();
15.            var role = roleManager.GetRoles().Where(r => r.Name == "HomepageApprover").FirstOrDefault();
16.             
17.            bool isUserInRole = roleManager.IsUserInRole(userID, role.Id);
18.            string emailString = "";
19.            string vmNotes = "";
20.            string sState="";
21.            string sTitle = "";
22.             
23.            foreach (var curLang in node.AvailableLanguages)
24.                
25.                sTitle = node.Title;
26.                sState = node.ApprovalWorkflowState;
27.                GetUsersOfLanguage(curLang.ToString());
28.                
I'm thinking that each language for the page has it's own guid that I need to use to get it's ApprovalWorkflowState? Tips on doing this?

Posted by Community Admin on 27-Mar-2013 00:00

This will get the info you want:

var childNodes = App.WorkWith().Pages().LocatedIn(PageLocation.Frontend).Where(p => p.Parent.Id == parentId).Get().ToList();
int AwaitingPublishingChildNodes = childNodes.Where(cnt => cnt.ApprovalWorkflowState == "AwaitingPublishing").Count();

Posted by Community Admin on 28-Mar-2013 00:00

David,

After working with Matt on this for quite some time -- we found out there are two ways to get the status of Localized pages.

 1) Synced Pages
       If your pages are synced -- you can get all information from your current node properties -- just
       use the culture desired as a filter -- see this post for more help: http://bit.ly/170jqrZ
     

//gets currently approved pageNode
var item = context.DataContext.GetProperties()["workflowItem"];
var page = item.GetValue(context.DataContext) as ISecuredObject;
var pageManager = PageManager.GetManager();
var node = pageManager.GetPageNode(page.Id);          
var currentLanguage = node.Page.UiCulture.ToString();               
     
//Get Page Permissions
var pagePermissions = page.GetActivePermissions();
 
List<System.Globalization.CultureInfo> pageCultures = new List<System.Globalization.CultureInfo>(node.AvailableCultures);
int AwaitingPublishingCount  = 0;
bool EnglishAwaitingApproval = false;
List<string> PagesAwaitingApproval = new List<string>();
int localizedPagesCount = 0;
 
if (node.Page.LocalizationStrategy == Telerik.Sitefinity.Localization.LocalizationStrategy.Synced)
    //Pages are synced -- get all localized statuses from the current node
    localizedPagesCount = pageCultures.Count();
 
    foreach (var pc in pageCultures)
    
        if (node.ApprovalWorkflowState[pc.Name] == "AwaitingPublishing")
        
            AwaitingPublishingCount++;
 
            if (pc.Name == "en")
            
                EnglishAwaitingApproval = true;
            
        
    
      
2) Separate Pages
    If the pages are NOT synced -- you can get at all the statuses through the
    node.Page.PageLanguageLink object.
//gets currently approved pageNode
var item = context.DataContext.GetProperties()["workflowItem"];
var page = item.GetValue(context.DataContext) as ISecuredObject;
var pageManager = PageManager.GetManager();
var node = pageManager.GetPageNode(page.Id);          
var currentLanguage = node.Page.UiCulture.ToString();               
     
//Get Page Permissions
var pagePermissions = page.GetActivePermissions();
 
List<System.Globalization.CultureInfo> pageCultures = new List<System.Globalization.CultureInfo>(node.AvailableCultures);
int AwaitingPublishingCount  = 0;
bool EnglishAwaitingApproval = false;
List<string> PagesAwaitingApproval = new List<string>();
int localizedPagesCount = 0;
  
if (node.Page.PageLanguageLink != null)
    //Pages are separate
    List<PageData> localizedPages = node.Page.PageLanguageLink.LanguageLinks.ToList();
    localizedPagesCount = localizedPages.Count();
 
    foreach (var lp in localizedPages)
    
        if (lp.NavigationNode.ApprovalWorkflowState == "AwaitingPublishing")
        
            AwaitingPublishingCount++;
 
            if (lp.UiCulture == "en")
            
                EnglishAwaitingApproval = true;
            
        
    

Hope this helps!!

This thread is closed