public int SavePermissions(int groupId, int forumId, Permission permission) { string[] fieldNames = {"GroupID", "ForumID"}; string[] fieldValues = {groupId.ToString(), forumId.ToString()}; SharePointListItem listItem = Provider.GetListItemByField(ForumConstants.Lists_ForumAccess, fieldNames, fieldValues); int rc = 0; if (listItem == null) { string[] values = { "Title", permission.ToString(), "GroupID", groupId.ToString(), "ForumID", forumId.ToString(), }; listItem = new SharePointListItem(0, values); rc = Provider.AddListItem(ForumConstants.Lists_ForumAccess, listItem); } else { listItem["Title"] = permission.ToString(); rc = Provider.UpdateListItem(ForumConstants.Lists_ForumAccess, listItem); } return rc; }
public override void AddSampleData() { if (ListExists) { Permission perm = new Permission(); string[] values = new string[6]; perm.SetPermission(Permission.Rights.Read, true); values[0] = "Title"; values[1] = perm.ToString(); values[2] = "ForumID"; values[3] = "1"; values[4] = "GroupID"; values[5] = "1"; // reader AddListValues(values); perm.SetPermission(Permission.Rights.Read, true); values[0] = "Title"; values[1] = perm.ToString(); values[2] = "ForumID"; values[3] = "0"; // default (non-existant) forum values[4] = "GroupID"; values[5] = "1"; // reader AddListValues(values); perm.SetPermission(Permission.Rights.Add, true); perm.SetPermission(Permission.Rights.Edit, true); perm.SetPermission(Permission.Rights.Reply, true); perm.SetPermission(Permission.Rights.Delete, true); values[0] = "Title"; values[1] = perm.ToString(); values[2] = "ForumID"; values[3] = "1"; values[4] = "GroupID"; values[5] = "2"; // contributor AddListValues(values); perm.SetPermission(Permission.Rights.Add, true); perm.SetPermission(Permission.Rights.Edit, true); perm.SetPermission(Permission.Rights.Reply, true); perm.SetPermission(Permission.Rights.Delete, true); values[0] = "Title"; values[1] = perm.ToString(); values[2] = "ForumID"; values[3] = "0"; // default forum values[4] = "GroupID"; values[5] = "2"; // contributor AddListValues(values); perm.SetPermission(Permission.Rights.Admin, true); values[0] = "Title"; values[1] = perm.ToString(); values[2] = "ForumID"; values[3] = "1"; values[4] = "GroupID"; values[5] = "3"; // administrator AddListValues(values); perm.SetPermission(Permission.Rights.Admin, true); values[0] = "Title"; values[1] = perm.ToString(); values[2] = "ForumID"; values[3] = "0"; // default forum values[4] = "GroupID"; values[5] = "3"; // administrator AddListValues(values); } }