NotificationPublishPreferenceManager
The NotificationPublishPreferenceManager class manages preferences for notification agents that can be published.
A notification agent is a plug-able component that sends notification messages. Each Agent is responsible for sending notifications to users when CMS activity occurs. Once a Notification Agent is created and registered, users can set up notification preferences that use it.
For information about notifications, see Sending Notifications to a Community in the Ektron Reference.
Namespace
Ektron.Cms.Framework.Settings.Notifications.NotificationPublishPreferenceManager
Constructors
NotificationPublishPreferenceManager()
NotificationPublishPreferenceManager(ApiAccessMode)
Properties
ApiMode
. Gets or sets the current API access mode. If set toAdmin
, the API runs with the permissions of an administrator.ApplicationPath
. Gets the application path to the Workarea.ContentLanguage
. Gets or sets the current content language.InPreviewMode
. Gets or sets the preview mode and returns true if the site is in preview mode.IsCommerceEnabled
. Checks for a commerce license.RequestInformation
. Gets information about the current request.SitePath
. Gets the site path.UserId
. Gets or sets the ID of the currently logged-in user.
Methods
Add
Add(Ektron.Cms.Notifications.NotificationPreferenceData)
Sets the list of activity types for publishing for a given user. The method disables any Activity Types not listed.
Authenticated users
- CMS Administrators
To create anonymous user access with this method, set the API access mode (ApiMode
) in the Manager class when instantiating the class.
Fields
*=Required
*
User ID*
Activity Type ID
Parameters
userId
. ID to add notification publishing.ActivityTypeIdList
. List of Activity Type IDs to enable publishing for.
.aspx code snippet
<ol class="formFields"> <li class="clearfix"> <ektronUI:Label ID="uxUserIdLabel" AssociatedControlID="uxUserId" CssClass="span-4 last" runat="server" Text="*UserId :" /> <ektronUI:TextField ID="uxUserId" CssClass="span-6" runat="server" ValidationGroup="RegisterValidationGroup" Text="10" /> </li> <li class="clearfix"> <ektronUI:Label ID="uxActivityTypeIdsLabel" AssociatedControlID="uxActivityTypeIds" CssClass="span-4 last" runat="server" Text="*ActivityTypeIds (Comma Separated):" /> <ektronUI:TextField ID="uxActivityTypeIds" CssClass="span-6" ValidationGroup="RegisterValidationGroup" runat="server" Text="20,22" /> </li> <li class="clearfix" style="color: red;"> <ektronUI:Label ID="uxStatus" Visible="false" CssClass="span-9 last" runat="server" Text="Status:" /> </li> <ektronUI:Button ID="uxSubmit" runat="server" OnClick="uxSubmit_Click" Text="Add"></ektronUI:Button> <ektronUI:Label ID="uxRequiredLabel" CssClass="span-4" runat="server" Text="* - Required" /> </ol> <asp:Literal ID="uxMessage" runat="server"></asp:Literal>
.aspx.cs code-behind namespace
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Ektron.Site; using Ektron.Cms; using Ektron.Cms.Framework.Settings.Notifications; using Ektron.Cms.Notifications; using Ektron.Cms.Framework.User; using Ektron.Cms.Framework.Activity; using Ektron.Cms.Activity;
.aspx.cs code-behind method
protected void uxSubmit_Click(object sender, EventArgs e) { try { NotificationPublishPreferenceManager notificationPublishPreferenceManager = new NotificationPublishPreferenceManager(); long userID = long.Parse(uxUserId.Text); string[] activityTypeIds = uxActivityTypeIds.Text.Split(',', ';'); List<long> activityTypeIdList = new List<long>(); UserManager Usermanager = new UserManager(); //Get the User data for given UserID UserData Userdata = Usermanager.GetItem(userID); //Check Whether Entered User ID is valid or Not. if (Userdata != null) { ActivityTypeManager activityTypeManager = new ActivityTypeManager(); for (int i = 0; i < activityTypeIds.Length; i++) { long activityTypeID = long.Parse(activityTypeIds[i]); //Check whether Entered activityTypeID valid or Not ActivityTypeData activityTypeData = activityTypeManager.GetItem(activityTypeID); if (activityTypeData != null) { activityTypeIdList.Add(activityTypeID); if (i == activityTypeIds.Length - 1) { notificationPublishPreferenceManager.Add(userID, activityTypeIdList); MessageUtilities.UpdateMessage(uxMessage, "The list of Activity Types for publishing for a given user has been set.", Message.DisplayModes.Success); } } else { uxStatus.Visible = true; MessageUtilities.UpdateMessage(uxStatus, "Please Enter Valid Activity Type ID.", Message.DisplayModes.Error); return; } } } else { uxStatus.Visible = true; MessageUtilities.UpdateMessage(uxStatus, "Please Enter Valid User ID and Try again.", Message.DisplayModes.Error); return; } uxPageMultiView.SetActiveView(uxViewMessage); } catch (Exception ex) { MessageUtilities.UpdateMessage(uxMessage, ex.Message, Message.DisplayModes.Error); uxPageMultiView.SetActiveView(uxViewMessage); } }
AllowPublication
AllowPublication(System.Int64,System.Int64)
Retrieves true if the supplied activity type ID is enabled for publishing for the supplied User ID.
Authenticated users
- CMS Administrators
To create anonymous user access with this method, set the API access mode (ApiMode
) in the Manager class when instantiating the class.
Fields
*=Required
- * User ID
- * Activity Type ID
Parameters
userId
. ID to check publishing preferences for.activityTypeId
. Activity Type ID to check publishing preferences for.
.aspx code snippet
<ol class="formFields"> <li class="clearfix"> <ektronUI:Label ID="uxUserIdLabel" AssociatedControlID="uxUserId" CssClass="span-4 last" runat="server" Text="*UserId :" /> <ektronUI:TextField ID="uxUserId" CssClass="span-6" runat="server" ValidationGroup="RegisterValidationGroup" Text="10" /> </li> <li class="clearfix"> <ektronUI:Label ID="uxActivityTypeIdLabel" AssociatedControlID="uxActivityTypeId" CssClass="span-4 last" runat="server" Text="*ActivityTypeId :" /> <ektronUI:TextField ID="uxActivityTypeId" CssClass="span-6" ValidationGroup="RegisterValidationGroup" runat="server" Text="20" /> </li> <li class="clearfix" style="color: red;"> <ektronUI:Label ID="uxStatus" Visible="false" CssClass="span-9 last" runat="server" Text="Status:" /> </li> <ektronUI:Button ID="uxSubmit" runat="server" OnClick="uxSubmit_Click" Text="Allow"></ektronUI:Button> <ektronUI:Label ID="uxRequiredLabel" CssClass="span-4" runat="server" Text="* - Required" /> </ol> <asp:Literal ID="uxMessage" runat="server"></asp:Literal>
.aspx.cs code-behind namespace
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Ektron.Site; using Ektron.Cms; using Ektron.Cms.Framework.Settings.Notifications; using Ektron.Cms.Notifications; using Ektron.Cms.Framework.User; using Ektron.Cms.Framework.Activity; using Ektron.Cms.Activity;
.aspx.cs code-behind method
protected void uxSubmit_Click(object sender, EventArgs e) { try { NotificationPublishPreferenceManager notificationPublishPreferenceManager = new NotificationPublishPreferenceManager(); ActivityTypeManager activityTypeManager = new ActivityTypeManager(); long userID = long.Parse(uxUserId.Text); long activityTypeID = long.Parse(uxActivityTypeId.Text); UserManager Usermanager = new UserManager(); //Get the User data for given UserID UserData Userdata = Usermanager.GetItem(userID); //Check Whether Entered User ID is valid or Not. if (Userdata != null) { //Check whether Entered activityTypeID valid or Not ActivityTypeData activityTypeData = activityTypeManager.GetItem(activityTypeID); if (activityTypeData != null) { bool allow = notificationPublishPreferenceManager.AllowPublication(userID, activityTypeID); if (allow) { MessageUtilities.UpdateMessage(uxMessage,"Supplied ActivityTypeId is enabled for publishing for the supplied User Id.", Message.DisplayModes.Success); } else { MessageUtilities.UpdateMessage(uxMessage, "Supplied ActivityTypeId is NOT enabled for publishing for the supplied User Id.", Message.DisplayModes.Error); } } else { uxStatus.Visible = true; MessageUtilities.UpdateMessage(uxStatus, "Please Enter Valid Activity Type ID.", Message.DisplayModes.Error); return; } } else { uxStatus.Visible = true; MessageUtilities.UpdateMessage(uxStatus, "Please Enter Valid User ID and Try again.", Message.DisplayModes.Error); return; } uxPageMultiView.SetActiveView(uxViewMessage); } catch (Exception ex) { MessageUtilities.UpdateMessage(uxMessage, ex.Message, Message.DisplayModes.Error); uxPageMultiView.SetActiveView(uxViewMessage); } }
GetDefaultList
GetDefaultList()
Retrieves the list of default notification publishing preferences for the system.
Authenticated users
- CMS Administrators
To create anonymous user access with this method, set the API access mode (ApiMode
) in the Manager class when instantiating the class.
.aspx.cs code-behind method
protected void uxSubmit_Click(object sender, EventArgs e) { try { NotificationPublishPreferenceManager notificationPublishPreferenceManager = new NotificationPublishPreferenceManager(); List<NotificationPublishPreferenceData> notificationPublishPreferenceList = notificationPublishPreferenceManager.GetDefaultList(); uxnotificationPublishPreferenceListView.Visible = true; uxnotificationPublishPreferenceListView.DataSource = notificationPublishPreferenceList; uxnotificationPublishPreferenceListView.DataBind(); uxPageMultiView.SetActiveView(uxViewMessage); } catch (Exception ex) { MessageUtilities.UpdateMessage(uxMessage, ex.Message, Message.DisplayModes.Error); uxPageMultiView.SetActiveView(uxViewMessage); } }
GetList
GetList(System.Int64)
Retrieves the list of default notification publishing preferences for a user.
Authenticated users
- CMS Administrators
To create anonymous user access with this method, set the API access mode (ApiMode
) in the Manager class when instantiating the class.
Fields
*=Required
- * User ID
Parameters
userId
. User ID to return publishing preferences for.
.aspx code snippet
<ol class="formFields"> <li class="clearfix"> <ektronUI:Label ID="uxUserIdLabel" AssociatedControlID="uxUserId" CssClass="span-4 last" runat="server" Text="*UserId :" /> <ektronUI:TextField ID="uxUserId" CssClass="span-6" runat="server" ValidationGroup="RegisterValidationGroup" Text="10" /> </li> <li class="clearfix" style="color: red;"> <ektronUI:Label ID="uxStatus" Visible="false" CssClass="span-9 last" runat="server" Text="Status:" /> </li> <ektronUI:Button ID="uxSubmit" runat="server" OnClick="uxSubmit_Click" Text="GetList"></ektronUI:Button> <ektronUI:Label ID="uxRequiredLabel" CssClass="span-4" runat="server" Text="* - Required" /> </ol> <asp:Literal ID="uxMessage" runat="server"></asp:Literal> <asp:ListView ID="uxnotificationPublishPreferenceListView" runat="server" ItemPlaceholderID="aspItemPlaceholder" Visible="false"> <EmptyDataTemplate> Criteria did not match any records.</EmptyDataTemplate> <LayoutTemplate> <table class="devsite-api-method"> <thead> <tr> <th> ActivityTypeId </th> <th> ActivityTypeName </th> <th> ActivityTypeScope </th> <th> IsEnabled </th> </tr> </thead> <tbody> <asp:PlaceHolder ID="aspItemPlaceholder" runat="server"></asp:PlaceHolder> </tbody> </table> </LayoutTemplate> <ItemTemplate> <tr> <td class="devsite-method"> <%# Eval("ActivityTypeId")%> </td> <td class="devsite-method"> <%# Eval("ActivityTypeName")%> </td> <td class="devsite-method"> <%# Eval("ActivityTypeScope")%> </td> <td class="devsite-method"> <%# Eval("IsEnabled")%> </td> </tr> </ItemTemplate> </asp:ListView>
.aspx.cs code-behind namespace
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Ektron.Site; using Ektron.Cms; using Ektron.Cms.Framework.Settings.Notifications; using Ektron.Cms.Notifications; using Ektron.Cms.Framework.User; using Ektron.Cms.Framework.Activity; using Ektron.Cms.Activity;
.aspx.cs code-behind method
protected void uxSubmit_Click(object sender, EventArgs e) { try { NotificationPublishPreferenceManager notificationPublishPreferenceManager = new NotificationPublishPreferenceManager(); long userID = long.Parse(uxUserId.Text); UserManager Usermanager = new UserManager(); //Get the User data for given UserID UserData Userdata = Usermanager.GetItem(userID); //Check Whether Entered User ID is valid or Not. if (Userdata != null) { List<NotificationPublishPreferenceData> notificationPublishPreferenceList = notificationPublishPreferenceManager.GetList(userID); uxnotificationPublishPreferenceListView.Visible = true; uxnotificationPublishPreferenceListView.DataSource = notificationPublishPreferenceList; uxnotificationPublishPreferenceListView.DataBind(); } else { uxStatus.Visible = true; MessageUtilities.UpdateMessage(uxStatus, "Please Enter Valid User ID and Try again.", Message.DisplayModes.Error); return; } uxPageMultiView.SetActiveView(uxViewMessage); } catch (Exception ex) { MessageUtilities.UpdateMessage(uxMessage, ex.Message, Message.DisplayModes.Error); uxPageMultiView.SetActiveView(uxViewMessage); } }
UpdateDefaultPreferences
UpdateDefaultPreferences(System.Collections,Generic.List)
Updates the list of activity types for publishing for a given user.
Authenticated users
- CMS Administrators
To create anonymous user access with this method, set the API access mode (ApiMode
) in the Manager class when instantiating the class.
Fields
*=Required
*
Activity Type IDs (comma separated)
Parameters
ActivityTypeIdList
. List of Activity Type IDs to enable publishing for.
Remarks
Validate the activity type IDs with GetItem()
before you update the properties. Then, call Update
with your modified ActivityTypeData object.
NOTE: You cannot change all properties after the initial Add event, such as the ActivityTypeData.Type.
.aspx code snippet
<ol class="formFields"> <li class="clearfix"> <ektronUI:Label ID="uxActivityTypeIdsLabel" AssociatedControlID="uxActivityTypeIds" CssClass="span-4 last" runat="server" Text="*ActivityTypeIds (Comma Separated):" /> <ektronUI:TextField ID="uxActivityTypeIds" CssClass="span-6" ValidationGroup="RegisterValidationGroup" runat="server" Text="0" /> </li> <li class="clearfix" style="color: red;"> <ektronUI:Label ID="uxStatus" Visible="false" CssClass="span-9 last" runat="server" Text="Status:" /> </li> <ektronUI:Button ID="uxSubmit" runat="server" OnClick="uxSubmit_Click" Text="Update"></ektronUI:Button> <ektronUI:Label ID="uxRequiredLabel" CssClass="span-4" runat="server" Text="* - Required" /> </ol> <asp:Literal ID="uxMessage" runat="server"></asp:Literal>
.aspx.cs code-behind namespace
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Ektron.Site; using Ektron.Cms; using Ektron.Cms.Framework.Settings.Notifications; using Ektron.Cms.Notifications; using Ektron.Cms.Framework.User; using Ektron.Cms.Framework.Activity; using Ektron.Cms.Activity;
.aspx.cs code-behind method
protected void uxSubmit_Click(object sender, EventArgs e) { try { NotificationPublishPreferenceManager notificationPublishPreferenceManager = new NotificationPublishPreferenceManager(); string[] activityTypeIds = uxActivityTypeIds.Text.Split(',', ';'); List<long> activityTypeIdList = new List<long>(); ActivityTypeManager activityTypeManager = new ActivityTypeManager(); for (int i = 0; i < activityTypeIds.Length; i++) { long activityTypeID = long.Parse(activityTypeIds[i]); //Check whether Entered activityTypeID valid or Not ActivityTypeData activityTypeData = activityTypeManager.GetItem(activityTypeID); if (activityTypeData != null) { activityTypeIdList.Add(activityTypeID); if (i == activityTypeIds.Length - 1) { notificationPublishPreferenceManager.UpdateDefaultPreferences(activityTypeIdList); MessageUtilities.UpdateMessage(uxMessage, "Default list of Activity Types for publishing has been Updated.", Message.DisplayModes.Success); } } else { uxStatus.Visible = true; MessageUtilities.UpdateMessage(uxStatus, "Please Enter Valid Activity Type ID.", Message.DisplayModes.Error); return; } } uxPageMultiView.SetActiveView(uxViewMessage); } catch (Exception ex) { MessageUtilities.UpdateMessage(uxMessage, ex.Message, Message.DisplayModes.Error); uxPageMultiView.SetActiveView(uxViewMessage); } }