+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / How to notify roles that a page has been sent through workflow

How to notify roles that a page has been sent through workflow

3 posts, 0 answered
  1. Byzza
    Byzza avatar
    89 posts
    Registered:
    09 Jul 2007
    09 Mar 2010
    Link to this post
    OK I'm trying to implement the code from this page:
    http://www.sitefinity.com/support/kb/sitefinity-3-x/how-to-notify-roles-that-a-page-has-been-sent-through-workflow.aspx

    Now it works 100% fine as is, but I was hoping to make 2 enhancments which I haven't been able to make happen. 

    1) Replace  
    string approversRole = "MMS Help"
    string[] usernames = Telerik.Security.UserManager.Default.GetUsersInRole(approversRole); 
    //For every user, send him or her an e-mail 
    foreach (string username in usernames)
    {
       System.Web.Security.
       MembershipUser user = Telerik.Security.UserManager.Default.GetUser(username); 
       mailMsg.To.Add(user.Email);
    }

     

     

     

     

    with something along the lines of

      

     

    string[] approversRoles = Telerik.<someMethod>.<GetRolesInPageWithPermission(Page,Permission)>; 
    foreach (string approversRole in approversRoles) 
      string[] usernames = Telerik.Security.UserManager.Default.GetUsersInRole(approversRole);  
      //For every user, send him or her an e-mail  
      foreach (string username in usernames)  
      
        System.Web.Security.MembershipUser user = Telerik.Security.UserManager.Default.GetUser(username);  
        mailMsg.To.Add(user.Email); 
      
    }

     


    Any help would be appreciated.

     

     

     

    Thanks in advance

     

     

     

  2. Byzza
    Byzza avatar
    89 posts
    Registered:
    09 Jul 2007
    09 Mar 2010
    Link to this post
    (By permssion above I mean "Approval status")

    Oh I forgot the second item.

    The Second item was to get it working for all Approval levels.

    ie "For Approval" --> Emails everyone allowed to approve
    "Approved" --> Emails everyone allowed to publish
    "Published" --> Emails Owner and modifier that its been published.

    Thank you
    Regards
    Byron
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    09 Mar 2010
    Link to this post
    Hi Byzza,

    Here is a sample code that illustrates how to get the Workflow permissions for a given role


          var cmsManager1 = new CmsManager();
          ICmsPage p = (ICmsPage)cmsManager1.GetPage(new Guid("3B451DB9-26A1-4D23-A0E6-08D990D55260"));
          ISecured secObject = p as ISecured;
          ApplicationPermission appPerm;
          bool hasApprovePermission = false;
          IDictionary<string, ApplicationPermission> applicationPermissions = secObject.Permissions;
     
                if (applicationPermissions.TryGetValue("test", out appPerm))
                 {
                     hasApprovePermission = HasPermission(appPerm, WorkflowRights.Approve);
                     if (hasApprovePermission)
                     {
                                                                    // send to approvers role
                     }
                 }
     
     
             ....
                   ....
     
    private bool HasPermission(ApplicationPermission perm, int right)
          {
                 return ((perm.Grant & right) == right) && ((perm.Deny & right) == 0);
          }


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
3 posts, 0 answered