예제 #1
0
    /// <summary>
    /// Deletes notification subscription. Called when the "Delete subscription" button is pressed.
    /// Expects the CreateNotificationSubscription method to be run first.
    /// </summary>
    private bool DeleteNotificationSubscription()
    {
        // Get the gateway
        NotificationGatewayInfo gateway = NotificationGatewayInfoProvider.GetNotificationGatewayInfo("MyNewGateway");

        // Get the template
        NotificationTemplateInfo template = NotificationTemplateInfoProvider.GetNotificationTemplateInfo("MyNewTemplate", CMSContext.CurrentSiteID);

        if ((gateway != null) && (template != null))
        {
            // Prepare the parameters
            string where = "SubscriptionGatewayID = " + gateway.GatewayID + " AND SubscriptionTemplateID = " + template.TemplateID;

            // Get the notification subscription
            DataSet subscriptions = NotificationSubscriptionInfoProvider.GetSubscriptions(where, null);
            if (!DataHelper.DataSourceIsEmpty(subscriptions))
            {
                // Create object from DataRow
                NotificationSubscriptionInfo deleteSubscription = new NotificationSubscriptionInfo(subscriptions.Tables[0].Rows[0]);

                // Delete the notification subscription
                NotificationSubscriptionInfoProvider.DeleteNotificationSubscriptionInfo(deleteSubscription);

                return(deleteSubscription != null);
            }
        }

        return(false);
    }
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that threw event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "delete")
        {
            try
            {
                if (!RaiseOnCheckPermissions(PERMISSION_MODIFY, this))
                {
                    var cui = MembershipContext.AuthenticatedUser;
                    if ((cui == null) || ((UserId != cui.UserID) && !cui.IsAuthorizedPerResource("CMS.Users", PERMISSION_MODIFY)))
                    {
                        RedirectToAccessDenied("CMS.Users", PERMISSION_MODIFY);
                    }
                }

                NotificationSubscriptionInfoProvider.DeleteNotificationSubscriptionInfo(Convert.ToInt32(actionArgument));
            }
            catch (Exception ex)
            {
                // Show error message
                ShowError(ex.Message);
            }
        }
    }
예제 #3
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that threw event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "delete")
        {
            try
            {
                if (!RaiseOnCheckPermissions(CMSAdminControl.PERMISSION_MODIFY, this))
                {
                    CurrentUserInfo cui = CMSContext.CurrentUser;
                    if ((cui == null) || ((this.UserId != cui.UserID) && !cui.IsAuthorizedPerResource("CMS.Users", CMSAdminControl.PERMISSION_MODIFY)))
                    {
                        RedirectToAccessDenied("CMS.Users", CMSAdminControl.PERMISSION_MODIFY);
                    }
                }

                NotificationSubscriptionInfoProvider.DeleteNotificationSubscriptionInfo(Convert.ToInt32(actionArgument));
            }
            catch (Exception ex)
            {
                lblError.Visible = true;
                lblError.Text    = ex.Message;
            }
        }
    }