private List<PermissionUpdate> GetPermissions() { List<PermissionUpdate> permissions = new List<PermissionUpdate>(); foreach (RepeaterItem item in rptPermissions.Items) { PermissionUpdate update = new PermissionUpdate(); var data = item.DataItem as SPRoleDefinition; var ltrPermissionName = item.FindControl("ltrPermissionName") as Literal; update.Name = ltrPermissionName.Text; var MultiLookupPicker = item.FindControl("MultiLookupPicker") as GroupedItemPicker; var chkAuthor = item.FindControl("chkAuthor") as CheckBox; var chkApprovers = item.FindControl("chkApprovers") as CheckBox; update.Ower = chkAuthor.Checked; update.Approvers = chkApprovers.Checked; update.Columns = MultiLookupPicker.SelectedIds.Cast<string>().Select(p => new Guid(p)).ToList(); var SelectCandidate = item.FindControl("SelectCandidate") as SPHtmlSelect; var SelectResult = item.FindControl("SelectResult") as SPHtmlSelect; MultiLookupPicker.CandidateControlId = SelectCandidate.ID; MultiLookupPicker.ResultControlId = SelectResult.ID; //var fields = SPContext.Current.List.Fields.Cast<SPField>() // .Where(p => !p.Hidden && (p.Type == SPFieldType.User || p.TypeAsString == "")) // .ToList(); //foreach (var f in fields) //{ // MultiLookupPicker.AddItem(f.Id.ToString(), f.Title, "", ""); //} permissions.Add(update); } return permissions; }
private List<string> GetLoginNames(PermissionUpdate item) { List<string> logins = new List<string>(); if (item.Ower) { var user = new SPFieldUserValue(Item.Web, Item[SPBuiltInFieldId.Author].ToString()); logins.Add(user.User.LoginName); } if (item.Approvers) { logins.AddRange(Approvers); } foreach (var col in item.Columns) { if (Item[col] != null) { var field = (SPFieldUser)Item.Fields[col]; if (field.AllowMultipleValues) { SPFieldUserValueCollection userCollection = (SPFieldUserValueCollection)Item[col]; foreach (SPFieldUserValue user in userCollection) { logins.Add(user.User.LoginName); } } else { var user = new SPFieldUserValue(Item.Web, Item[col].ToString()); logins.Add(user.User.LoginName); } } } return logins; }