tags:

views:

63

answers:

2

Hello everyone, this is what I'm working on. I have two lists:

  1. column user and column project that the user is assigned to.
  2. (a library): a list of all the projects.

I was wondering, how, by every row that is created in the first list (so adding a user and a project) it is possible to grant the user permissions on this project's reference in the second library (the projects library). Example: ProjectLibrary:

  • Project1
  • Project2
  • Project3

The first list:

  • user1 project1
  • user1 project2
  • user2 project2
  • user2 project3
  • user3 project3

Now I want to give each user permission to see the project he's assigned to so that when he opens a third form, a combobox filled with projects will only show the projects he has permissions on.

Thank you so much!

A: 

As far as I know there is no standard way of setting permissions on certain items in Sharepoint. Only on whole list. If you want to filter combobox - you need to implement custom form (Application Page) and filter combo in your code.

Tim
on web enabled comboboxes u cant implement a filter and u have to use a dropdown list:(
Nomz
You can use ExtJs combo or jQuery autocomplete or something different. And use HttpHadler (*.ashx file) to provide filter data for combo. It worked best for me
Tim
Im new to this so I dont really know what you're talking about.. Can u explain a bit more please?
Nomz
re: Permissions and list item. Not quite right Tim - you can set permissions for list items separate from the parent list/site. Settings > List Settings > Permissions > Actions > Edit Permissions.
Ryan
A: 

In SharePoint 2007 item level permissions are supported.

You could create a list event handler (SPItemEventReceiver). Every time an user item is changed/added the handler could update the corresponding project item.

public class EventHanlder: SPItemEventReceiver
{
    public override void ItemAdded(SPItemEventProperties properties)
    {
        // collection user and project information from the item being updated.
        SPListItem item = properties.ListItem;
        SPUser user = new SPFieldUserValue(item.Web, item["UserFieldName"] as string).User;
        int projectId = new SPFieldLookupValue(item["ProjectFieldName"]).Id;

        // create role assignment for the user on the user item.
        SPRoleAssignment ra = new SPRoleAssignment(user);
        SPRoleDefinition rd = item.Web.RoleDefinitions.GetByType(SPRoleType.Reader);
        ra.RoleDefinitionBindings.Add(rd);
        ra.Update();

        // get the project item and update the role assignments.
        SPList projectList = // retrieve project list here...
        SPListItem projectItem = projectList.GetItemById(projectId);        
        projectItem.RoleAssignments.Add(ra);
    }
}

This is just sample code. I'm not 100% sure if the thing with the SPField***Value works like that.

Now I want to give each user permission to see the project he's assigned to so that when he opens a third form, a combobox filled with projects will only show the projects he has permissions on.

This should be done automatically with a lookup field, since only items a user has permissions on will be displayed.

Jason
thank you!!!!!!
Nomz