コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check hash
        if (!QueryHelper.ValidateHash("hash"))
        {
            RedirectToAccessDenied(ResHelper.GetString("dialogs.badhashtitle"));
        }

        Title = GetString("abuse.ObjectTitle");

        // Set the page title
        CurrentMaster.Title.TitleText  = GetString("abuse.ObjectTitle");
        CurrentMaster.Title.TitleImage = GetImageUrl("Design/Controls/ObjectDataViewer/objectdetails.png");

        string objectType = QueryHelper.GetString("ObjectType", string.Empty);

        // Check if object type to be displayed is supproted
        if (AbuseReportInfoProvider.IsObjectTypeSupported(objectType))
        {
            ObjectDataViewer.ObjectType = objectType;
            ObjectDataViewer.ObjectID   = QueryHelper.GetInteger("ObjectID", 0);
            lblNotSupported.Visible     = false;
        }
        else
        {
            ObjectDataViewer.StopProcessing = true;
            ObjectDataViewer.Visible        = false;
            lblNotSupported.Visible         = true;
        }
    }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Ensure modal dialog opening
        ScriptHelper.RegisterDialogScript(this);

        int reportID = QueryHelper.GetInteger("reportid", 0);

        ucAbuseEdit.ReportID = reportID;

        AbuseReportInfo ar = AbuseReportInfoProvider.GetAbuseReportInfo(reportID);

        // Set edited object
        EditedObject = ar;

        if (ar != null)
        {
            // Set breadcrumb
            PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem
            {
                Text = ar.ReportTitle
            });

            // Ensure that object belongs to current site or user is global admin
            if (!MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) && (ar.ReportSiteID != SiteContext.CurrentSiteID))
            {
                RedirectToInformation(GetString("general.notassigned"));
            }
        }

        ucAbuseEdit.OnCheckPermissions += ucAbuseEdit_OnCheckPermissions;
    }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Set the page title
        CurrentMaster.Title.TitleText     = GetString("abuse.properties");
        CurrentMaster.Title.TitleImage    = GetImageUrl("Objects/CMS_AbuseReport/object.png");
        CurrentMaster.Title.HelpTopicName = "abusereport";

        int reportID = QueryHelper.GetInteger("reportid", 0);

        ucAbuseEdit.ReportID = reportID;

        // Initializes page breadcrumbs
        string[,] breadcrumbs = new string[2, 3];
        breadcrumbs[0, 0]     = GetString("abuse.reports");
        breadcrumbs[0, 1]     = "~/CMSModules/AbuseReport/AbuseReport_List.aspx";

        AbuseReportInfo ar = AbuseReportInfoProvider.GetAbuseReportInfo(reportID);

        // Set edited object
        EditedObject = ar;

        if (ar != null)
        {
            // Set breadcrumbs
            breadcrumbs[1, 0] = HTMLHelper.HTMLEncode(ar.ReportTitle);
        }

        CurrentMaster.Title.Breadcrumbs = breadcrumbs;
        ucAbuseEdit.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(ucAbuseEdit_OnCheckPermissions);
    }
コード例 #4
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);
    }
コード例 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check hash
        if (!QueryHelper.ValidateHash("hash"))
        {
            RedirectToAccessDenied(ResHelper.GetString("dialogs.badhashtitle"));
        }

        Title = GetString("abuse.ObjectTitle");

        // Set the page title
        PageTitle.TitleText = GetString("abuse.ObjectTitle");
        string objectType = QueryHelper.GetString("ObjectType", string.Empty);

        // Check if object type to be displayed is supported
        if (AbuseReportInfoProvider.IsObjectTypeSupported(objectType))
        {
            ObjectDataViewer.ObjectType = objectType;
            ObjectDataViewer.ObjectID   = QueryHelper.GetInteger("ObjectID", 0);
        }
        else
        {
            ObjectDataViewer.StopProcessing = true;
            ObjectDataViewer.Visible        = false;
            ShowError(GetString("abuse.NotSupported"));
        }
    }
コード例 #6
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"));
        }
    }
コード例 #7
0
    /// <summary>
    /// Initializes and updates breadcrumbs items.
    /// </summary>
    private void SetupBreadcrumbs()
    {
        ucBreadcrumbs.Items.Clear();

        ucBreadcrumbs.AddBreadcrumb(new BreadcrumbItem
        {
            Text          = GetString("abuse.reports"),
            OnClientClick = ControlsHelper.GetPostBackEventReference(lnkBackHidden) + "; return false;"
        });

        int reportID = ValidationHelper.GetInteger(ucAbuseEdit.ReportID, 0);

        if (!String.IsNullOrEmpty(hfEditReport.Value))
        {
            reportID = ValidationHelper.GetInteger(hfEditReport.Value, 0);
        }

        AbuseReportInfo ari = AbuseReportInfoProvider.GetAbuseReportInfo(reportID);

        if (ari != null)
        {
            ucBreadcrumbs.AddBreadcrumb(new BreadcrumbItem
            {
                Text = ari.ReportTitle,
            });
        }
    }
コード例 #8
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;
        }
    }
コード例 #9
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);
             }
         }
     }
 }
コード例 #10
0
    /// <summary>
    /// Deletes abuse report. Called when the "Delete report" button is pressed.
    /// Expects the CreateAbuseReport method to be run first.
    /// </summary>
    private bool DeleteAbuseReport()
    {
        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 deleteReport = new AbuseReportInfo(reports.Tables[0].Rows[0]);

            // Delete the abuse report
            AbuseReportInfoProvider.DeleteAbuseReportInfo(deleteReport);

            return(true);
        }

        return(false);
    }
コード例 #11
0
    public override bool LoadData(ActivityInfo ai)
    {
        if ((ai == null) || ai.ActivityType != PredefinedActivityType.ABUSE_REPORT)
        {
            return(false);
        }

        int nodeId = ai.ActivityNodeID;

        lblDocIDVal.Text = GetLinkForDocument(nodeId, ai.ActivityCulture);

        AbuseReportInfo ari = AbuseReportInfoProvider.GetAbuseReportInfo(ai.ActivityItemID);

        if (ari != null)
        {
            txtComment.Text = ari.ReportComment;
        }

        return(true);
    }
コード例 #12
0
    protected override void OnPreRender(EventArgs e)
    {
        if ((ucAbuseReportList.EditReportID != 0) || (!String.IsNullOrEmpty(hfEditReport.Value)))
        {
            ucAbuseEdit.Visible              = true;
            ucAbuseReportList.Visible        = false;
            ucAbuseReportList.StopProcessing = true;
            ucAbuseEdit.StopProcessing       = false;

            int reportID = 0;

            ucAbuseEdit.ReportID = ucAbuseReportList.EditReportID;

            bool editForceLoad = false;
            if (ucAbuseEdit.ReportID != 0)
            {
                hfEditReport.Value = ucAbuseEdit.ReportID.ToString();
                reportID           = ucAbuseEdit.ReportID;
                editForceLoad      = true;
            }

            ucAbuseEdit.ReloadData(editForceLoad);

            //Breadcrumbs
            lblEditBack.Text = " <span class=\"TitleBreadCrumbSeparator\">&nbsp;</span> ";
            lnkEditBack.Text = GetString("abuse.reports");

            if (!String.IsNullOrEmpty(hfEditReport.Value))
            {
                reportID = ValidationHelper.GetInteger(hfEditReport.Value, 0);
            }

            AbuseReportInfo ari = AbuseReportInfoProvider.GetAbuseReportInfo(reportID);
            if (ari != null)
            {
                lblEditNew.Text = HTMLHelper.HTMLEncode(ari.ReportTitle);
            }
            pnlHeader.Visible = true;
        }
        base.OnPreRender(e);
    }
コード例 #13
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);
    }
コード例 #14
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);
    }
コード例 #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Set the page title
        CurrentMaster.Title.TitleText     = GetString("abuse.properties");
        CurrentMaster.Title.TitleImage    = GetImageUrl("Objects/CMS_AbuseReport/object.png");
        CurrentMaster.Title.HelpTopicName = "abusereport";

        int reportID = QueryHelper.GetInteger("reportid", 0);

        ucAbuseEdit.ReportID = reportID;

        // Initializes page breadcrumbs
        string[,] breadcrumbs = new string[2, 3];
        breadcrumbs[0, 0]     = GetString("abuse.reports");
        breadcrumbs[0, 1]     = "~/CMSModules/AbuseReport/AbuseReport_List.aspx";

        AbuseReportInfo ar = AbuseReportInfoProvider.GetAbuseReportInfo(reportID);

        // Set edited object
        EditedObject = ar;

        if (ar != null)
        {
            // Set breadcrumbs
            breadcrumbs[1, 0] = HTMLHelper.HTMLEncode(ar.ReportTitle);

            // Ensure that object belongs to current site or user is global admin
            if (!CMSContext.CurrentUser.IsGlobalAdministrator && (ar.ReportSiteID != CMSContext.CurrentSiteID))
            {
                RedirectToInformation(GetString("general.notassigned"));
            }
        }

        CurrentMaster.Title.Breadcrumbs = breadcrumbs;
        ucAbuseEdit.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(ucAbuseEdit_OnCheckPermissions);
    }
コード例 #16
0
    /// <summary>
    /// Reloads all data.
    /// </summary>
    public override void ReloadData(bool forceLoad)
    {
        if (CurrentReport != null)
        {
            // Load labels
            if (!RequestHelper.IsPostBack() || forceLoad)
            {
                // Create query parameters
                string query = "?ObjectID=" + CurrentReport.ReportObjectID;

                // Set link value
                string url = CurrentReport.ReportURL;
                if (CurrentReport.ReportCulture != String.Empty)
                {
                    url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, CurrentReport.ReportCulture);
                }
                lnkUrlValue.Text        = HTMLHelper.HTMLEncode(url);
                lnkUrlValue.NavigateUrl = url;
                lnkUrlValue.ToolTip     = HTMLHelper.HTMLEncode(url);
                lnkUrlValue.Target      = "_blank";

                // Set culture value
                var cultureInfo = CultureHelper.GetCultureInfo(CurrentReport.ReportCulture);
                lblCultureValue.Text = (cultureInfo != null) ? cultureInfo.DisplayName : ResHelper.Dash;

                // Set site value
                SiteInfo si = SiteInfoProvider.GetSiteInfo(CurrentReport.ReportSiteID);
                lblSiteValue.Text = (si != null) ? HTMLHelper.HTMLEncode(si.DisplayName) : ResHelper.Dash;

                // Set title
                lblTitleValue.Text = HTMLHelper.HTMLEncode(CurrentReport.ReportTitle);

                // Set labels
                if (!string.IsNullOrEmpty(CurrentReport.ReportObjectType))
                {
                    lblObjectTypeValue.Text = GetString("ObjectType." + ImportExportHelper.GetSafeObjectTypeName(CurrentReport.ReportObjectType));
                    query += "&ObjectType=" + CurrentReport.ReportObjectType;
                }
                else
                {
                    lblObjectTypeValue.Text = ResHelper.Dash;
                }

                // Get object display name
                lblObjectNameValue.Text = ResHelper.Dash;

                string objectType = CurrentReport.ReportObjectType;
                int    objectId   = CurrentReport.ReportObjectID;

                if ((objectId > 0) && !string.IsNullOrEmpty(objectType) && !DocumentHelper.IsDocumentObjectType(objectType))
                {
                    GeneralizedInfo obj = ProviderHelper.GetInfoById(objectType, objectId);
                    if ((obj != null) && !string.IsNullOrEmpty(obj.ObjectDisplayName))
                    {
                        lblObjectNameValue.Text = HTMLHelper.HTMLEncode(obj.ObjectDisplayName);
                    }
                }

                // Set Reported by label
                lblReportedByValue.Text = ResHelper.Dash;
                if (CurrentReport.ReportUserID != 0)
                {
                    UserInfo ui = UserInfoProvider.GetUserInfo(CurrentReport.ReportUserID);
                    lblReportedByValue.Text = (ui != null) ? HTMLHelper.HTMLEncode(ui.FullName) : GetString("general.NA");
                }

                // Set other parameters
                lblReportedWhenValue.Text = CurrentReport.ReportWhen.ToString();

                CMSPage page = Page as CMSPage;

                if ((CurrentReport.ReportObjectID > 0) && (!string.IsNullOrEmpty(CurrentReport.ReportObjectType)) && AbuseReportInfoProvider.IsObjectTypeSupported(CurrentReport.ReportObjectType))
                {
                    // Add Object details button
                    string detailUrl = "~/CMSModules/AbuseReport/AbuseReport_ObjectDetails.aspx" + query;
                    detailUrl = URLHelper.AddParameterToUrl(detailUrl, "hash", QueryHelper.GetHash(detailUrl));
                    var onClientClickScript = ScriptHelper.GetModalDialogScript(UrlResolver.ResolveUrl(detailUrl), "objectdetails", 960, 600);

                    if (page != null)
                    {
                        var headerActions = page.HeaderActions;
                        headerActions.AddAction(new HeaderAction
                        {
                            Text          = GetString("abuse.details"),
                            OnClientClick = onClientClickScript,
                            ButtonStyle   = ButtonStyle.Default
                        });
                        btnObjectDetails.Visible = false;
                    }
                    else
                    {
                        btnObjectDetails.OnClientClick = onClientClickScript;
                        ScriptHelper.RegisterDialogScript(Page);
                    }
                }
                else
                {
                    btnObjectDetails.Visible = false;
                }

                Control postback = ControlsHelper.GetPostBackControl(Page);

                // Not post-back not caused by OK button or Save action in header
                if ((postback != btnOk) && ((page == null) || (postback != page.HeaderActions)))
                {
                    txtCommentValue.Text = CurrentReport.ReportComment;
                    LoadStatus((int)CurrentReport.ReportStatus);
                }
            }
        }
    }
コード例 #17
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;
    }
コード例 #18
0
    /// <summary>
    /// Reloads all data.
    /// </summary>
    public override void ReloadData(bool forceLoad)
    {
        if (CurrentReport != null)
        {
            // Load labels
            if (!RequestHelper.IsPostBack() || forceLoad)
            {
                // Create query parameters
                string query = "?ObjectID=" + CurrentReport.ReportObjectID;

                // Set link value
                string url = CurrentReport.ReportURL;
                if (CurrentReport.ReportCulture != String.Empty)
                {
                    url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, CurrentReport.ReportCulture);
                }
                lnkUrlValue.Text        = HTMLHelper.HTMLEncode(url);
                lnkUrlValue.NavigateUrl = url;
                lnkUrlValue.ToolTip     = HTMLHelper.HTMLEncode(url);
                lnkUrlValue.Target      = "_blank";

                // Set culture value
                CultureInfo ci = CultureHelper.GetCultureInfo(CurrentReport.ReportCulture);
                lblCultureValue.Text = (ci != null) ? ci.DisplayName : ResHelper.Dash;

                // Set site value
                SiteInfo si = SiteInfoProvider.GetSiteInfo(CurrentReport.ReportSiteID);
                lblSiteValue.Text = (si != null) ? HTMLHelper.HTMLEncode(si.DisplayName) : ResHelper.Dash;

                // Set title
                lblTitleValue.Text = HTMLHelper.HTMLEncode(CurrentReport.ReportTitle);

                // Set labels
                if (!string.IsNullOrEmpty(CurrentReport.ReportObjectType))
                {
                    lblObjectTypeValue.Text = GetString("ObjectType." + ImportExportHelper.GetSafeObjectTypeName(CurrentReport.ReportObjectType));
                    query += "&ObjectType=" + CurrentReport.ReportObjectType;
                    if ((CurrentReport.ReportObjectID > 0) && (CurrentReport.ReportObjectType.ToLowerCSafe() != DocumentObjectType.DOCUMENT))
                    {
                        pnlLink.Visible = true;
                    }
                }
                else
                {
                    lblObjectTypeValue.Text = ResHelper.Dash;
                }

                // Get object display name
                lblObjectNameValue.Text = ResHelper.Dash;

                string objectType = CurrentReport.ReportObjectType;
                int    objectId   = CurrentReport.ReportObjectID;

                if ((objectId > 0) && !string.IsNullOrEmpty(objectType) && !objectType.EqualsCSafe(DocumentObjectType.DOCUMENT, true))
                {
                    GeneralizedInfo obj = CMSObjectHelper.GetObjectById(objectType, objectId);
                    if ((obj != null) && !string.IsNullOrEmpty(obj.ObjectDisplayName))
                    {
                        lblObjectNameValue.Text = HTMLHelper.HTMLEncode(obj.ObjectDisplayName);
                    }
                }

                // Set Reported by label
                lblReportedByValue.Text = ResHelper.Dash;
                if (CurrentReport.ReportUserID != 0)
                {
                    UserInfo ui = UserInfoProvider.GetUserInfo(CurrentReport.ReportUserID);
                    lblReportedByValue.Text = (ui != null) ? HTMLHelper.HTMLEncode(ui.FullName) : GetString("general.NA");
                }

                // Set other parameters
                lblReportedWhenValue.Text = CurrentReport.ReportWhen.ToString();

                if ((CurrentReport.ReportObjectID > 0) && (!string.IsNullOrEmpty(CurrentReport.ReportObjectType)) && AbuseReportInfoProvider.IsObjectTypeSupported(CurrentReport.ReportObjectType))
                {
                    lnkShowDetails.Visible = true;
                    string detailUrl = "~/CMSModules/AbuseReport/AbuseReport_ObjectDetails.aspx" + query;
                    lnkShowDetails.NavigateUrl = URLHelper.AddParameterToUrl(detailUrl, "hash", QueryHelper.GetHash(detailUrl));
                }

                Control postback = ControlsHelper.GetPostBackControl(Page);
                CMSPage page     = Page as CMSPage;

                // Not post-back not caused by OK button or Save action in header
                if ((postback != btnOk) && ((page == null) || (postback != page.HeaderActions)))
                {
                    txtCommentValue.Text = CurrentReport.ReportComment;
                    LoadStatus((int)CurrentReport.ReportStatus);
                }
            }
        }
    }
コード例 #19
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";
    }