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

Forums / Developing with Sitefinity / File Library for Specific User

File Library for Specific User

6 posts, 0 answered
  1. mrbowling
    mrbowling avatar
    15 posts
    Registered:
    24 Apr 2007
    26 Jul 2009
    Link to this post
    What I am trying to do is create a File Library for a Specific Sitefinity User. So that when they log in they see only their files, these files would be uploaded by an admin and the admin would select the user. Is their a straightforward way to do this? I had some hack job in mind; but would rather do it the right way. How should I go about this?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    26 Jul 2009
    Link to this post
    Hello mrbowling,

    Currently there is no UI for granular permissions that will allow you to manage separate users. You can map LibraryListView template, create a code behind and check whether the current user belongs to a given role or not. Below is a sample code that checks whether logged user is in role "test" and the library name is UsersLibrary. If so the library is accessible.

     <asp:Repeater ID="allLibraries" runat="server" OnItemDataBound="allLibraries_ItemDataBound"
                    <HeaderTemplate> 
                        <ul id="modulesItemsList" class="modulesItemsList"
                    </HeaderTemplate> 
                    <ItemTemplate> 
                        <li id="libraryPanel" runat="server"
     
     .....  
         ..... 
            ..... 


     protected void allLibraries_ItemDataBound(object sender, RepeaterItemEventArgs e) 
        { 
            if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 
            { 
                ILibrary library = e.Item.DataItem as ILibrary; 
                if(library != null && library.Name == "UsersLibrary" && UserManager.IsCurrentUserInRole("test")) 
                { 
                    HtmlGenericControl libraryPanel =(HtmlGenericControl)e.Item.FindControl("libraryPanel"); 
                    libraryPanel.Visible = true
                } 
            } 


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. mrbowling
    mrbowling avatar
    15 posts
    Registered:
    24 Apr 2007
    26 Jul 2009
    Link to this post
    Thanks for the specific response. Maybe I could name the Library after the user and check the library name against the current user and then show it? Is there a way that I could extended the library control to allow me to select a name from all of the user accounts or would I just have to make surethat the admin staff typed the name correctly?

    Like I have users
       person1, person2, person3, person4.

    I would like them each to have their own library, from the admin side can I create a list that will show me these users and allow me to select that person?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    27 Jul 2009
    Link to this post
    Hello mrbowling,

    You can create a custom control which has RadComboBox control bound to MembershipUserCollection. Then use the value from the RadComboBoxItem as Library Name
    Sample code.

    namespace Telerik.Samples.Test 
        public class CustomRadCombo : SimpleControl 
        { 
            public CustomRadCombo() 
            { 
            } 
     
            protected override void CreateChildControls() 
            { 
                base.CreateChildControls(); 
                RadComboBox box = new RadComboBox(); 
                int totalRows; 
                MembershipUserCollection collection = UserManager.Default.GetAllUsers(0, 0, string.Empty, out totalRows); 
                box.DataSource = collection; 
                box.DataBind(); 
                Controls.Add(box); 
            } 
        } 


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. mrbowling
    mrbowling avatar
    15 posts
    Registered:
    24 Apr 2007
    28 Jul 2009
    Link to this post
    Sorry to keep this thread alive I just had one more quick question, I am going to have to extended the User Profile controls to add additional fields and also make a call to the zoho api to create an invoice, it is possible that when I create the user that I could simply create the library then. Like if Person1 signs up, can I then call a function to create the Library Person1Audit?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    28 Jul 2009
    Link to this post
    Hi mrbowling,

    Yes it is possible. Once the user user is created you can call CreateLibrary method.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
6 posts, 0 answered