コード例 #1
0
    /// <summary>
    /// Button OK click event handler.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check permissions
        if (!CheckPermissions("CMS.AbuseReport", "Manage"))
        {
            return;
        }

        // Check that text area is not empty
        txtCommentValue.Text = txtCommentValue.Text.Trim();
        txtCommentValue.Text = TextHelper.LimitLength(txtCommentValue.Text, txtCommentValue.MaxLength);

        if (txtCommentValue.Text.Length > 0)
        {
            // Load new values
            CurrentReport.ReportComment = txtCommentValue.Text;
            CurrentReport.ReportStatus  = (AbuseReportStatusEnum)ValidationHelper.GetInteger(drpStatus.SelectedValue, 0);

            // Save AbuseReport
            AbuseReportInfoProvider.SetAbuseReportInfo(CurrentReport);
            ShowChangesSaved();
        }
        else
        {
            ShowError(GetString("abuse.errors.comment"));
        }
    }
コード例 #2
0
    /// <summary>
    /// Gets and bulk updates abuse reports. Called when the "Get and bulk update reports" button is pressed.
    /// Expects the CreateAbuseReport method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateAbuseReports()
    {
        // Prepare the parameters
        string where = "ReportTitle LIKE N'MyNewReport%'";

        // Get the data
        DataSet reports = AbuseReportInfoProvider.GetAbuseReports(where, null);

        if (!DataHelper.DataSourceIsEmpty(reports))
        {
            // Loop through the individual items
            foreach (DataRow reportDr in reports.Tables[0].Rows)
            {
                // Create object from DataRow
                AbuseReportInfo modifyReport = new AbuseReportInfo(reportDr);

                // Update the properties
                modifyReport.ReportStatus = AbuseReportStatusEnum.Rejected;

                // Save the changes
                AbuseReportInfoProvider.SetAbuseReportInfo(modifyReport);
            }

            return(true);
        }

        return(false);
    }
コード例 #3
0
    /// <summary>
    /// Button OK click event handler.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check permissions
        if (!CheckPermissions("CMS.AbuseReport", "Manage"))
        {
            return;
        }

        // Check that text area is not empty
        txtCommentValue.Text = txtCommentValue.Text.Trim();
        if (txtCommentValue.Text.Length > 1000)
        {
            txtCommentValue.Text = txtCommentValue.Text.Substring(0, 1000);
        }

        if (txtCommentValue.Text.Length > 0)
        {
            // Load new values
            CurrentReport.ReportComment = txtCommentValue.Text;
            CurrentReport.ReportStatus  = (AbuseReportStatusEnum)ValidationHelper.GetInteger(drpStatus.SelectedValue, 0);

            // Save AbuseReport
            AbuseReportInfoProvider.SetAbuseReportInfo(CurrentReport);
            lblSaved.Visible = true;
        }
        else
        {
            lblError.Visible = true;
        }
    }
コード例 #4
0
 /// <summary>
 /// Unigrid event handler.
 /// </summary>
 /// <param name="actionName">Name of action</param>
 /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
 protected void UniGrid_OnAction(string actionName, object actionArgument)
 {
     // Edit report
     if (actionName == "edit")
     {
         if (!UseEditOnPostback)
         {
             URLHelper.Redirect(UrlResolver.ResolveUrl("AbuseReport_Edit.aspx?reportid=" + actionArgument));
         }
         else
         {
             EditReportID = ValidationHelper.GetInteger(actionArgument, 0);
         }
     }
     // Delete report
     else if (actionName == "delete")
     {
         // Check permissions
         if (CheckPermissions("CMS.AbuseReport", "Manage"))
         {
             AbuseReportInfoProvider.DeleteAbuseReportInfo(ValidationHelper.GetInteger(actionArgument, 0));
         }
     }
     // Solve report
     else if (actionName == "solve")
     {
         // Check permissions
         if (CheckPermissions("CMS.AbuseReport", "Manage"))
         {
             AbuseReportInfo ari = AbuseReportInfoProvider.GetAbuseReportInfo(ValidationHelper.GetInteger(actionArgument, 0));
             if (ari != null)
             {
                 ari.ReportStatus = AbuseReportStatusEnum.Solved;
                 AbuseReportInfoProvider.SetAbuseReportInfo(ari);
             }
         }
     }
     // Reject report
     else if (actionName == "reject")
     {
         // Check permissions
         if (CheckPermissions("CMS.AbuseReport", "Manage"))
         {
             AbuseReportInfo ari = AbuseReportInfoProvider.GetAbuseReportInfo(ValidationHelper.GetInteger(actionArgument, 0));
             if (ari != null)
             {
                 ari.ReportStatus = AbuseReportStatusEnum.Rejected;
                 AbuseReportInfoProvider.SetAbuseReportInfo(ari);
             }
         }
     }
 }
コード例 #5
0
    /// <summary>
    /// Creates abuse report. Called when the "Create report" button is pressed.
    /// </summary>
    private bool CreateAbuseReport()
    {
        // Create new abuse report object
        AbuseReportInfo newReport = new AbuseReportInfo();

        // Set the properties
        newReport.ReportTitle   = "MyNewReport";
        newReport.ReportComment = "This is an example abuse report.";

        newReport.ReportURL     = URLHelper.GetAbsoluteUrl(RequestContext.CurrentURL);
        newReport.ReportCulture = LocalizationContext.PreferredCultureCode;
        newReport.ReportSiteID  = SiteContext.CurrentSiteID;
        newReport.ReportUserID  = MembershipContext.AuthenticatedUser.UserID;
        newReport.ReportWhen    = DateTime.Now;
        newReport.ReportStatus  = AbuseReportStatusEnum.New;

        // Save the abuse report
        AbuseReportInfoProvider.SetAbuseReportInfo(newReport);

        return(true);
    }
コード例 #6
0
    /// <summary>
    /// Gets and updates abuse report. Called when the "Get and update report" button is pressed.
    /// Expects the CreateAbuseReport method to be run first.
    /// </summary>
    private bool GetAndUpdateAbuseReport()
    {
        string where = "ReportTitle LIKE N'MyNewReport%'";

        // Get the report
        DataSet reports = AbuseReportInfoProvider.GetAbuseReports(where, null);

        if (!DataHelper.DataSourceIsEmpty(reports))
        {
            // Create the object from DataRow
            AbuseReportInfo updateReport = new AbuseReportInfo(reports.Tables[0].Rows[0]);

            // Update the properties
            updateReport.ReportStatus = AbuseReportStatusEnum.Solved;

            // Save the changes
            AbuseReportInfoProvider.SetAbuseReportInfo(updateReport);

            return(true);
        }

        return(false);
    }
コード例 #7
0
    /// <summary>
    /// Performs reporting of abuse.
    /// </summary>
    public void PerformAction()
    {
        // Check banned ip
        if (!BannedIPInfoProvider.IsAllowed(SiteContext.CurrentSiteName, BanControlEnum.AllNonComplete))
        {
            ShowError(GetString("General.BannedIP"));
            return;
        }

        string report = txtText.Text;

        // Check that text area is not empty or too long
        report = report.Trim();
        report = TextHelper.LimitLength(report, txtText.MaxLength);

        if (report.Length > 0)
        {
            // Create new AbuseReport
            AbuseReportInfo abuseReport = new AbuseReportInfo();
            if (ReportTitle != "")
            {
                // Set AbuseReport properties
                // Decode first, from forums it can be encoded
                ReportTitle = Server.HtmlDecode(ReportTitle);
                // Remove BBCode tags
                ReportTitle               = DiscussionMacroResolver.RemoveTags(ReportTitle);
                abuseReport.ReportTitle   = TextHelper.LimitLength(ReportTitle, 100);
                abuseReport.ReportURL     = URLHelper.GetAbsoluteUrl(ReportURL);
                abuseReport.ReportCulture = LocalizationContext.PreferredCultureCode;
                if (ReportObjectID > 0)
                {
                    abuseReport.ReportObjectID = ReportObjectID;
                }

                if (ReportObjectType != "")
                {
                    abuseReport.ReportObjectType = ReportObjectType;
                }

                abuseReport.ReportComment = report;

                if (MembershipContext.AuthenticatedUser.UserID > 0)
                {
                    abuseReport.ReportUserID = MembershipContext.AuthenticatedUser.UserID;
                }

                abuseReport.ReportWhen   = DateTime.Now;
                abuseReport.ReportStatus = AbuseReportStatusEnum.New;
                abuseReport.ReportSiteID = SiteContext.CurrentSite.SiteID;

                // Save AbuseReport
                AbuseReportInfoProvider.SetAbuseReportInfo(abuseReport);

                ShowConfirmation(GetString(ConfirmationText), true);
                txtText.Visible      = false;
                ReportButton.Visible = false;
            }
            else
            {
                ShowError(GetString("abuse.errors.reporttitle"));
            }
        }
        else
        {
            ShowError(GetString("abuse.errors.reportcomment"));
        }

        // Additional form modification
        ReportButton.Visible = false;
    }
コード例 #8
0
    /// <summary>
    /// Performes reporting of abuse.
    /// </summary>
    public void PerformAction()
    {
        // Check banned ip
        if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.AllNonComplete))
        {
            lblSaved.CssClass = "ErrorLabel";
            lblSaved.Text     = GetString("General.BannedIP");
            return;
        }

        string report = txtText.Text;

        // Check that text area is not empty or too long
        report = report.Trim();
        report = TextHelper.LimitLength(report, 1000);

        if (report.Length > 0)
        {
            // Create new AbuseReport
            AbuseReportInfo abuseReport = new AbuseReportInfo();
            if (ReportTitle != "")
            {
                // Set AbuseReport properties
                // Decode first, from forums it can be encoded
                ReportTitle = Server.HtmlDecode(ReportTitle);
                // Remove BBCode tags
                ReportTitle               = DiscussionMacroHelper.RemoveTags(ReportTitle);
                abuseReport.ReportTitle   = TextHelper.LimitLength(ReportTitle, 100);
                abuseReport.ReportURL     = ReportURL;
                abuseReport.ReportCulture = CMSContext.PreferredCultureCode;
                if (ReportObjectID > 0)
                {
                    abuseReport.ReportObjectID = ReportObjectID;
                }

                if (ReportObjectType != "")
                {
                    abuseReport.ReportObjectType = ReportObjectType;
                }

                abuseReport.ReportComment = report;

                if (CMSContext.CurrentUser.UserID > 0)
                {
                    abuseReport.ReportUserID = CMSContext.CurrentUser.UserID;
                }

                abuseReport.ReportWhen   = DateTime.Now;
                abuseReport.ReportStatus = AbuseReportStatusEnum.New;
                abuseReport.ReportSiteID = CMSContext.CurrentSite.SiteID;

                // Save AbuseReport
                AbuseReportInfoProvider.SetAbuseReportInfo(abuseReport);

                LogActivity(abuseReport);

                lblSaved.ResourceString = ConfirmationText;
                lblSaved.Visible        = true;
                txtText.Visible         = false;
                ReportButton.Visible    = false;
            }
            else
            {
                lblSaved.ResourceString = "abuse.errors.reporttitle";
                lblSaved.CssClass       = "ErrorLabel";
                lblSaved.Visible        = true;
            }
        }
        else
        {
            lblSaved.ResourceString = "abuse.errors.reportcomment";
            lblSaved.CssClass       = "ErrorLabel";
            lblSaved.Visible        = true;
        }

        // Additional form modification
        ReportButton.Visible        = false;
        CancelButton.ResourceString = "general.close";
    }