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

Forums / Developing with Sitefinity / WikiItemPermission

WikiItemPermission

5 posts, 0 answered
  1. MNP
    MNP avatar
    79 posts
    Registered:
    23 Apr 2008
    04 Dec 2009
    Link to this post
    I'm overwriting the WikiSingleItem.ascx control to hide the tabs if a user does not have permission to create or modify a wiki.

      Dim perms As Telerik.Wiki.Security.WikiGlobalPermission 
            Dim mgr As New Telerik.Wiki.WikiManager("Wiki"
     
            perms = mgr.GetPermission(Permissions.CrudRights.Create) 
            If Not perms.CheckDemand(Permissions.CrudRights.Modify) Then 
                wikiTabs.Visible = False 
            End If 

    However as you can see this is GlobalPermissions. If I have more the one wiki with separated permissions for each one, how would I find the singleItemPermission.

    I know the WikiManager.GetPermission is overloaded with GetPermission(iWiki) as SingleItemPermission, but how would I get the iWIki from the current url that I'm on? I'm overwriting the WikiSingleItem.ascx so could I grab it from that control somehow?

    Thanks..your help is always appreciated.

    -Matt
  2. MNP
    MNP avatar
    79 posts
    Registered:
    23 Apr 2008
    04 Dec 2009
    Link to this post
    Actually found my answer. Can you let me know if this is the correct procedure or is there a better way right in the control to get the iWiki information.

    Follow the directions from http://www.sitefinity.com/support/forums/sitefinity-3-x/suggestions/add-last-modified-date-to-wiki.aspx

    Then in your WikiViewExtended class set a hidden field to keep the ParentID.
     Me.ParentID.Value = item.ParentID.ToString 
     
     Public ReadOnly Property ParentID() As HiddenField 
                Get 
                    Return MyBase.WikiSingleContainer.GetControl(Of HiddenField)("litParentID"False, Telerik.Framework.Web.TraverseMethod.BreadthFirst) 
                End Get 
            End Property 
     
     

    Is this the correct way to do it?
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    06 Dec 2009
    Link to this post
    Hello Matt,

    Each Wiki has a permissions tab in the backend from where you can set permissions for View, Create, Modify. Is there any reason for not using the backend UI?

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  4. MNP
    MNP avatar
    79 posts
    Registered:
    23 Apr 2008
    07 Dec 2009
    Link to this post
    Hi Ivan,

    I was looking to modify the WikiSingleItem.ascx because I wanted to hide the tabs if a user did not have Create/Modify permissions. If all the user has is View permissions then it looks a lot cleaner without tabs. I'm not too concerned about those "view only" users seeing history or searching as my search is on the page itself.

    I'm not looking to modify the permissions, simply seeing what permissions the user has on that specific wiki.

    Thanks

    -Matt
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Dec 2009
    Link to this post
    Hi Matt,

    You can create a custom control that inherits from WikiView and override SetSingleItemContent, then use logic similar to this one that the sample below illustrates.

    protected override void SetSingleItemContent(Telerik.Cms.Engine.IContent item)
    {
        base.SetSingleItemContent(item);
        // GET THE CURRENT USER ROLE - FOR DEMONSTATION. YOU CAN USE OTHER PARAMATERS
        if (UserManager.IsCurrentUserInRole("SOMEROLE"))
        {
            //THIS WILL HIDE THE WHOLE TAB FROM THE TAB STRIP CONTROL.
            //RadTab tab = this.WikiSingleContainer.WikiTabs.FindTabByText("Search");
            //if(tab !=null)
            //{
            //    tab.Visible = false;
            //}
     
     
            // THIS SHOWS THE TAB BUT NOT THE CONTROLS
            // I ADDED A PERMISSION MESSAGE TO NOTIFY THE USER
            RadPageView wikiSearch = this.WikiSingleContainer.WikiPages.FindPageViewByID("wikiSearch");
            if (wikiSearch != null)
            {
                foreach (Control control in wikiSearch.Controls)
                {
                    control.Visible = false;
                    
                }
                Literal literal = new Literal();
                literal.Text = "<span style=\"color:red;\"> you do not have permissions to view this wiki single item</span>";
                wikiSearch.Controls.Add(literal);
            }
     
        }
        
    }


    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
5 posts, 0 answered