protected void Page_PreRender(object sender, EventArgs e) { // Display the current subscription settings listSubscriptions.Items.Clear(); bool allowEditInGeneral = false; int[] organizationIds = (int[])this.ViewState["Organizations"]; foreach (int orgId in organizationIds) { // Retrieve the list of newsletter feeds bool allowEdit = _authority.HasPermission(Permission.CanEditMemberSubscriptions, orgId, -1, Authorization.Flag.Default); allowEdit = allowEdit || (DisplayedPerson.Identity == _currentUser.Identity); allowEditInGeneral = allowEditInGeneral || allowEdit; Organization org = Organization.FromIdentity(orgId); NewsletterFeeds feeds = org.GetNewsletterFeeds(); foreach (NewsletterFeed feed in feeds) { if (feed.NewsletterFeedId == NewsletterFeed.TypeID.OfficerUpwardCopies) { continue; } if (feed.NewsletterFeedId == NewsletterFeed.TypeID.OfficerNewMembers) { continue; } AddFeed(allowEdit, feed); } } allowEditInGeneral = allowEditInGeneral || (DisplayedPerson == _currentUser); //the two below is not organisation dependent AddFeed(allowEditInGeneral, NewsletterFeed.FromIdentity(NewsletterFeed.TypeID.OfficerUpwardCopies)); AddFeed(allowEditInGeneral, NewsletterFeed.FromIdentity(NewsletterFeed.TypeID.OfficerNewMembers)); string activistText = GetLocalResourceObject("activist").ToString(); ListItem itemA = new ListItem(activistText, "activist"); itemA.Selected = DisplayedPerson.IsActivist; itemA.Enabled = allowEditInGeneral; listSubscriptions.Items.Add(itemA); }
public virtual void SetSubscription(int newsletterFeedId, bool subscribe) { bool?subscription = HasExplicitSubscription(newsletterFeedId); if (subscription != null && subscription != subscribe) { SwarmDb.GetDatabaseForWriting().SetNewsletterSubscription(PersonId, newsletterFeedId, subscribe); } else { NewsletterFeed feed = NewsletterFeed.FromIdentity(newsletterFeedId); if (subscribe != feed.DefaultSubscribed) { SwarmDb.GetDatabaseForWriting().SetNewsletterSubscription(PersonId, newsletterFeedId, subscribe); } } this.subscriptions[newsletterFeedId] = subscribe; }
public bool IsSubscribing(int newsletterFeedId) { bool?subscription = HasExplicitSubscription(newsletterFeedId); if (subscription != null) { return((bool)subscription); } try { //Added try catch, throws exception on nonexisting feed id NewsletterFeed feed = NewsletterFeed.FromIdentity(newsletterFeedId); return(feed.DefaultSubscribed); } catch { return(false); } }