protected void btSave_Click(object sender, EventArgs e) { try { string id = Request["id"]; Category category; IList <Category> categories = GetAllViewableCategories(); //Edit if (id != null) { category = DocoManager.GetCategory(id); category.DisplayName = txtDisplayName.Text; } else //New { category = DocoManager.CreateCategory(txtDisplayName.Text); } Category parentCategory = categories[cmbParentCategory.SelectedIndex]; // The parent category can be assiged as the same category, do not allow this. // Also do not allow the root category (with parent null) to be changed. if (!parentCategory.Id.Equals(category.Id) && category.ParentCategory != null) { category.ParentCategory = categories[cmbParentCategory.SelectedIndex]; } category.Description = txtDescription.Text; DocoManager.UpdateCategory(category); IList <Access> currentAccess = AccessManager.GetItemAccess(category.Id); foreach (Access access in currentAccess) { AccessManager.RemoveAccess(access.Id); } foreach (Access a in AccessControl1.AccessList) { a.Id = null; a.ItemId = category.Id; a.ItemType = ItemType.DocoCategory; AccessManager.AddAccess(a); } ((IFeedback)this.Page.Master).QueueFeedback( BusiBlocksConstants.Blocks.Documents.LongName, "Category", Feedback.Actions.Saved, category.DisplayName ); Navigation.Admin_ManageDoco().Redirect(this); } catch (Exception ex) { throw ex; ((IFeedback)Master).SetException(GetType(), ex); } }
protected void btSave_Click(object sender, EventArgs e) { try { string forumId = Request["id"]; BusiBlocks.CommsBlock.Forums.Category forum; //Edit if (forumId != null) { forum = BusiBlocks.CommsBlock.Forums.ForumsManager.GetCategory(forumId); forum.DisplayName = txtDisplayName.Text; } else //New { forum = BusiBlocks.CommsBlock.Forums.ForumsManager.CreateCategory(txtName.Text, txtDisplayName.Text); } forum.AttachEnabled = chkEnabledAttach.Checked; forum.AttachExtensions = txtAttachExtensions.Text; forum.AttachMaxSize = int.Parse(txtAttachMaxSize.Text); BusiBlocks.CommsBlock.Forums.ForumsManager.UpdateCategory(forum); IList <Access> currentAccess = AccessManager.GetItemAccess(forum.Id); foreach (Access access in currentAccess) { AccessManager.RemoveAccess(access.Id); } foreach (Access a in ctrlAccess.AccessList) { a.Id = null; a.ItemId = forum.Id; a.ItemType = BusiBlocks.ItemType.ForumTopic; AccessManager.AddAccess(a); } Navigation.Admin_ManageComm().Redirect(this); } catch (Exception ex) { throw ex; ((IFeedback)Master).SetException(GetType(), ex); } }
private IList <User> GetTotalUsers() { IList <User> totalUsers = new List <BusiBlocks.Membership.User>();//total number of users who have viewed the announcement List <User> viewUsers = new List <BusiBlocks.Membership.User>(); IList <Access> accesses = AccessManager.GetItemAccess(Item.Category.Id); const string allGroupsLabel = "All Groups"; const string allLocationsLabel = "All Sites"; foreach (Access access in accesses) { PersonType personType = null; Site site = null; if (!string.IsNullOrEmpty(access.PersonTypeId)) { personType = PersonManager.GetPersonTypeById(access.PersonTypeId); } if (!string.IsNullOrEmpty(access.SiteId)) { site = SiteManager.GetSiteById(access.SiteId); } if (personType != null || site != null || access.AllSites || access.AllPersonTypes || access.AllUsers) { IList <Person> persons = PersonManager.GetAllPersons(); foreach (Person person in persons) { User user = MembershipManager.GetUserByPerson(person); bool add = false; if (SecurityHelper.CanUserView(user.Name, Item.Category.Id)) { if (access.AllUsers || access.AllPersonTypes || access.AllSites) { add = true; } else if (personType != null) { if (PersonManager.IsPersonInPersonType(person, personType)) { add = true; } } else if (site != null) { if (PersonManager.IsPersonInPersonSite(person, site)) { add = true; } } if (add && totalUsers.Contains(user) == false) { totalUsers.Add(user); } } } } } return(totalUsers); }
private void LoadPermissionsView() { // Copied from Controls/AccessControl.ascx.cs const string allGroupsLabel = "All Groups"; const string allLocationsLabel = "All Sites"; IList <string> viewingItems = new List <string>(); IList <string> editingItems = new List <string>(); if (!string.IsNullOrEmpty(CategoryId)) { foreach (Access access in AccessManager.GetItemAccess(CategoryId)) { string personType = string.Empty; string site = string.Empty; if (access.AllPersonTypes) { personType = allGroupsLabel; } else { if (!string.IsNullOrEmpty(access.PersonTypeId)) { personType = PersonManager.GetPersonTypeById(access.PersonTypeId).Name; } } if (access.AllSites) { site = allLocationsLabel; } else { if (!string.IsNullOrEmpty(access.SiteId)) { site = SiteManager.GetSiteById(access.SiteId).Name; } } if (!string.IsNullOrEmpty(personType) && !string.IsNullOrEmpty(site)) { string listItem = string.Format("{0} from {1}", personType, site); if (access.AccessType == AccessType.View) { viewingItems.Add(listItem); } else if (access.AccessType == AccessType.Edit) { editingItems.Add(listItem); } } } } lstSummaryViewing.DataSource = viewingItems; lstSummaryViewing.DataBind(); lstSummaryEditing.DataSource = editingItems; lstSummaryEditing.DataBind(); }
protected void btSave_Click(object sender, EventArgs e) { try { string id = Request["id"]; Category category; //Edit if (id != null) { category = NewsManager.GetCategory(id); category.Name = txtDisplayName.Text; } else //New { category = NewsManager.CreateCategory(txtDisplayName.Text); } IList <Category> categories = GetAllViewableCategories(id); // Remove this category from the categories list. var indexOfThisCategory = from x in categories where x.Name.Equals(category.Name) select categories.IndexOf(x); if (indexOfThisCategory.Any()) { categories.RemoveAt(indexOfThisCategory.First()); } if (categories.Count > 0) { if (cmbParentCategory.SelectedIndex >= 0) { Category parentCategory = categories[cmbParentCategory.SelectedIndex]; // The parent category can be assiged as the same category, do not allow this. if (!parentCategory.Id.Equals(category.Id)) { category.ParentCategory = categories[cmbParentCategory.SelectedIndex]; } } } category.Description = txtDescription.Text; NewsManager.UpdateCategory(category); IList <Access> currentAccess = AccessManager.GetItemAccess(category.Id); foreach (Access access in currentAccess) { AccessManager.RemoveAccess(access.Id); } foreach (Access a in AccessControl1.AccessList) { a.Id = null; a.ItemId = category.Id; a.ItemType = BusiBlocks.ItemType.NewsItem; AccessManager.AddAccess(a); } ((IFeedback)this.Page.Master).QueueFeedback( BusiBlocksConstants.Blocks.Communication.LongName, "Category", Feedback.Actions.Saved, category.Name ); Navigation.Admin_ManageComm().Redirect(this); } catch (Exception ex) { throw ex; ((IFeedback)Master).SetException(GetType(), ex); } }
private List <BindingItem> GetUserStatus(Article item) { var userStatus = new List <BindingItem>(); IList <Access> accesses = AccessManager.GetItemAccess(item.Category.Id); var users = new List <BusiBlocks.Membership.User>(); foreach (Access access in accesses) { users.AddRange(AccessManager.GetAccessibleItemUsers(access)); } foreach (BusiBlocks.Membership.User user in users) { if (item.RequiresAck) { if (!item.HasUserActioned(user.Name, AuditRecord.AuditAction.Acknowledged)) { if (!userStatus.Exists(delegate(BindingItem bi) { return(bi.Username == user.Name); })) { userStatus.Add(new BindingItem() { Username = user.Name, ViewedOrAcked = false, RequiresAck = item.RequiresAck }); } } else { if (!userStatus.Exists(delegate(BindingItem bi) { return(bi.Username == user.Name); })) { userStatus.Add(new BindingItem() { Username = user.Name, ViewedOrAcked = true, RequiresAck = item.RequiresAck }); } } } else { if (!item.HasUserActioned(user.Name, AuditRecord.AuditAction.Viewed)) { if (!userStatus.Exists(delegate(BindingItem bi) { return(bi.Username == user.Name); })) { userStatus.Add(new BindingItem() { Username = user.Name, ViewedOrAcked = false, RequiresAck = item.RequiresAck }); } } else { if (!userStatus.Exists(delegate(BindingItem bi) { return(bi.Username == user.Name); })) { userStatus.Add(new BindingItem() { Username = user.Name, ViewedOrAcked = true, RequiresAck = item.RequiresAck }); } } } } return(userStatus); }
public void BindViewSummaryLists(string CategoryId) { lstSummaryViewing.Items.Clear(); lstSummaryEditing.Items.Clear(); lstSummaryApproving.Items.Clear(); lstSummaryContributing.Items.Clear(); if (!string.IsNullOrEmpty(CategoryId)) { foreach (Access access in AccessManager.GetItemAccess(CategoryId)) { string personType = string.Empty; string site = string.Empty; string user = string.Empty; if (access.AllPersonTypes) { personType = AllGroupsLabel; } else { if (!string.IsNullOrEmpty(access.PersonTypeId)) { personType = PersonManager.GetPersonTypeById(access.PersonTypeId).Name; } } if (access.AllSites) { site = AllLocationsLabel; } else { if (!string.IsNullOrEmpty(access.SiteId)) { site = SiteManager.GetSiteById(access.SiteId).Name; } } if (!string.IsNullOrEmpty(personType) && !string.IsNullOrEmpty(site)) { string id = (access.AllPersonTypes ? "0" : access.PersonTypeId); id += "|" + (access.AllSites ? "0" : access.SiteId); ListItem listItem = new ListItem(string.Format("{0} from {1}", personType, site), id); if (access.AccessType == AccessType.View) { lstSummaryViewing.Items.Add(listItem); } else if (access.AccessType == AccessType.Edit) { lstSummaryEditing.Items.Add(listItem); } else if (access.AccessType == AccessType.Contribute) { lstSummaryContributing.Items.Add(listItem); } // else // lstSummaryApproving.Items.Add(listItem); } } } }