Ejemplo n.º 1
0
    /// <summary>
    /// Gets and bulk updates timezones. Called when the "Get and bulk update timezones" button is pressed.
    /// Expects the CreateTimezone method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateTimezones()
    {
        // Prepare the parameters
        string where = "TimeZoneName LIKE N'MyNewTimezone%'";

        // Get the data
        DataSet timezones = TimeZoneInfoProvider.GetTimeZones(where, null);

        if (!DataHelper.DataSourceIsEmpty(timezones))
        {
            // Loop through the individual items
            foreach (DataRow timezoneDr in timezones.Tables[0].Rows)
            {
                // Create object from DataRow
                TimeZoneInfo modifyTimezone = new TimeZoneInfo(timezoneDr);

                // Update the properties
                modifyTimezone.TimeZoneDisplayName = modifyTimezone.TimeZoneDisplayName.ToUpper();

                // Save the changes
                TimeZoneInfoProvider.SetTimeZoneInfo(modifyTimezone);
            }

            return(true);
        }

        return(false);
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string errorMessage = new Validator()
            .NotEmpty(txtTimeZoneName.Text, rfvName.ErrorMessage)
            .NotEmpty(txtTimeZoneDisplayName.Text, rfvDisplayName.ErrorMessage)
            .NotEmpty(txtTimeZoneGMT.Text, rfvGMT.ErrorMessage)
            .IsCodeName(txtTimeZoneName.Text, GetString("general.invalidcodename"))
            .IsDouble(txtTimeZoneGMT.Text, rvGMTDouble.ErrorMessage)
            .Result;
        if (chkTimeZoneDaylight.Checked)
        {
            if ((!startRuleEditor.IsValid()) || (!endRuleEditor.IsValid()))
            {
                errorMessage = GetString("TimeZ.RuleEditor.NotValid");
            }
        }

        if (errorMessage == "")
        {
            // timeZoneName must to be unique
            TimeZoneInfo timeZoneObj = TimeZoneInfoProvider.GetTimeZoneInfo(txtTimeZoneName.Text.Trim());

            // if timeZoneName value is unique
            if ((timeZoneObj == null) || (timeZoneObj.TimeZoneID == zoneid))
            {
                // if timeZoneName value is unique -> determine whether it is update or insert
                if ((timeZoneObj == null))
                {
                    // get TimeZoneInfo object by primary key
                    timeZoneObj = TimeZoneInfoProvider.GetTimeZoneInfo(zoneid);
                    if (timeZoneObj == null)
                    {
                        // create new item -> insert
                        timeZoneObj = new TimeZoneInfo();
                    }
                }

                timeZoneObj.TimeZoneName = txtTimeZoneName.Text.Trim();
                timeZoneObj.TimeZoneDaylight = chkTimeZoneDaylight.Checked;
                timeZoneObj.TimeZoneDisplayName = txtTimeZoneDisplayName.Text.Trim();
                timeZoneObj.TimeZoneRuleStartIn = ValidationHelper.GetDateTime(TimeZoneInfoProvider.CreateRuleDateTime(startRuleEditor.Rule), DateTime.Now);
                timeZoneObj.TimeZoneRuleEndIn = ValidationHelper.GetDateTime(TimeZoneInfoProvider.CreateRuleDateTime(endRuleEditor.Rule), DateTime.Now);
                timeZoneObj.TimeZoneRuleStartRule = startRuleEditor.Rule;
                timeZoneObj.TimeZoneRuleEndRule = endRuleEditor.Rule;
                timeZoneObj.TimeZoneGMT = Convert.ToDouble(txtTimeZoneGMT.Text.Trim());

                TimeZoneInfoProvider.SetTimeZoneInfo(timeZoneObj);

                URLHelper.Redirect("TimeZone_Edit.aspx?zoneid=" + Convert.ToString(timeZoneObj.TimeZoneID) + "&saved=1");
            }
            else
            {
                ShowError(GetString("TimeZ.Edit.TimeZoneNameExists"));
            }
        }
        else
        {
            ShowError(errorMessage);
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// UniGrid external data bound.
    /// </summary>
    object gridDocs_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        sourceName = sourceName.ToLower();
        switch (sourceName)
        {
        // Column 'DocumentWorkflowStepID'
        case "documentworkflowstepid":
            int stepId = ValidationHelper.GetInteger(parameter, 0);
            if (stepId > 0)
            {
                // Get workflow step display name
                WorkflowStepInfo wsi = WorkflowStepInfoProvider.GetWorkflowStepInfo(stepId);
                if (wsi != null)
                {
                    return(ResHelper.LocalizeString(wsi.StepDisplayName));
                }
            }
            break;

        // Column 'Published'
        case "published":
            bool published = ValidationHelper.GetBoolean(parameter, true);
            return(published ? GetString("General.Yes") : GetString("General.No"));

        case "documentmodifiedwhen":
        case "documentmodifiedwhentooltip":

            TimeZoneInfo tzi = null;

            // Get current time for user contribution list on live site
            string result = CMSContext.GetDateTimeForControl(this, ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME), out tzi).ToString();

            // Display time zone shift if needed
            if ((tzi != null) && TimeZoneHelper.TimeZonesEnabled())
            {
                if (sourceName.EndsWith("tooltip"))
                {
                    result = TimeZoneHelper.GetGMTLongStringOffset(tzi);
                }
                else
                {
                    result += TimeZoneHelper.GetGMTStringOffset(" (GMT{0:+00.00;-00.00})", tzi);
                }
            }
            return(result);

        // Action 'edit'
        case "edit":
            ((Control)sender).Visible = AllowEdit && CheckGroupPermission("editpages");
            break;

        // Action 'delete'
        case "delete":
            ((Control)sender).Visible = AllowDelete && CheckGroupPermission("deletepages");
            break;
        }

        return(parameter);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Deletes timezone. Called when the "Delete timezone" button is pressed.
    /// Expects the CreateTimezone method to be run first.
    /// </summary>
    private bool DeleteTimezone()
    {
        // Get the timezone
        TimeZoneInfo deleteTimezone = TimeZoneInfoProvider.GetTimeZoneInfo("MyNewTimezone");

        // Delete the timezone
        TimeZoneInfoProvider.DeleteTimeZoneInfo(deleteTimezone);

        return(deleteTimezone != null);
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Gets and updates timezone. Called when the "Get and update timezone" button is pressed.
    /// Expects the CreateTimezone method to be run first.
    /// </summary>
    private bool GetAndUpdateTimezone()
    {
        // Get the timezone
        TimeZoneInfo updateTimezone = TimeZoneInfoProvider.GetTimeZoneInfo("MyNewTimezone");

        if (updateTimezone != null)
        {
            // Update the properties
            updateTimezone.TimeZoneDisplayName = updateTimezone.TimeZoneDisplayName.ToLower();

            // Save the changes
            TimeZoneInfoProvider.SetTimeZoneInfo(updateTimezone);

            return(true);
        }

        return(false);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Creates timezone. Called when the "Create timezone" button is pressed.
    /// </summary>
    private bool CreateTimezone()
    {
        // Create new timezone object
        TimeZoneInfo newTimezone = new TimeZoneInfo();

        // Set the properties
        newTimezone.TimeZoneDisplayName   = "My new timezone";
        newTimezone.TimeZoneName          = "MyNewTimezone";
        newTimezone.TimeZoneGMT           = -12;
        newTimezone.TimeZoneDaylight      = true;
        newTimezone.TimeZoneRuleStartRule = "MAR|SUN|1|LAST|3|0|1";
        newTimezone.TimeZoneRuleEndRule   = "OCT|SUN|1|LAST|3|0|0";
        newTimezone.TimeZoneRuleStartIn   = TimeZoneInfoProvider.CreateRuleDateTime(newTimezone.TimeZoneRuleStartRule);
        newTimezone.TimeZoneRuleEndIn     = TimeZoneInfoProvider.CreateRuleDateTime(newTimezone.TimeZoneRuleEndRule);

        // Save the timezone
        TimeZoneInfoProvider.SetTimeZoneInfo(newTimezone);

        return(true);
    }
    /// <summary>
    /// Creates timezone. Called when the "Create timezone" button is pressed.
    /// </summary>
    private bool CreateTimezone()
    {
        // Create new timezone object
        TimeZoneInfo newTimezone = new TimeZoneInfo();

        // Set the properties
        newTimezone.TimeZoneDisplayName = "My new timezone";
        newTimezone.TimeZoneName = "MyNewTimezone";
        newTimezone.TimeZoneGMT = -12;
        newTimezone.TimeZoneDaylight = true;
        newTimezone.TimeZoneRuleStartRule = "MAR|SUN|1|LAST|3|0|1";
        newTimezone.TimeZoneRuleEndRule = "OCT|SUN|1|LAST|3|0|0";
        newTimezone.TimeZoneRuleStartIn = TimeZoneInfoProvider.CreateRuleDateTime(newTimezone.TimeZoneRuleStartRule);
        newTimezone.TimeZoneRuleEndIn = TimeZoneInfoProvider.CreateRuleDateTime(newTimezone.TimeZoneRuleEndRule);

        // Save the timezone
        TimeZoneInfoProvider.SetTimeZoneInfo(newTimezone);

        return true;
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (this.StopProcessing || CMSContext.CurrentDocument == null || CMSContext.CurrentDocument.NodeClassName.ToLower() != "cms.bookingevent")
        {
            // Do nothing
            this.Visible = false;
        }
        else
        {
            // Get current event document
            EventNode = CMSContext.CurrentDocument;

            // Get event date, open from/to, capacity and possibility to register over capacity information
            eventDate = ValidationHelper.GetDateTime(EventNode.GetValue("EventDate"), DataHelper.DATETIME_NOT_SELECTED);
            openFrom  = ValidationHelper.GetDateTime(EventNode.GetValue("EventOpenFrom"), DataHelper.DATETIME_NOT_SELECTED);
            openTo    = ValidationHelper.GetDateTime(EventNode.GetValue("EventOpenTo"), DataHelper.DATETIME_NOT_SELECTED);
            capacity  = ValidationHelper.GetInteger(EventNode.GetValue("EventCapacity"), 0);
            allowRegistrationOverCapacity = ValidationHelper.GetBoolean(EventNode.GetValue("EventAllowRegistrationOverCapacity"), false);

            // Display registration section
            DisplayRegistration();

            // Display link to iCalendar file which adds this event to users Outlook
            if (this.AllowExportToOutlook)
            {
                TimeZoneInfo tzi = null;
                CMSContext.GetDateTimeForControl(this, DateTime.Now, out tzi);
                string timeZoneId = string.Empty;
                if (tzi != null)
                {
                    timeZoneId = "&timezoneid=" + tzi.TimeZoneID;
                }

                lnkOutlook.NavigateUrl = "~/CMSModules/EventManager/CMSPages/AddToOutlook.aspx?eventid=" + EventNode.NodeID.ToString() + timeZoneId;
                lnkOutlook.Target      = "_blank";
                lnkOutlook.Text        = GetString("eventmanager.exporttooutlook");
                lnkOutlook.Visible     = true;
            }
        }
    }
Ejemplo n.º 9
0
    /// <summary>
    /// Load data of editing timeZone.
    /// </summary>
    /// <param name="timeZoneObj">TimeZone object</param>
    protected void LoadData(TimeZoneInfo timeZoneObj)
    {
        txtTimeZoneName.Text        = timeZoneObj.TimeZoneName;
        txtTimeZoneDisplayName.Text = timeZoneObj.TimeZoneDisplayName;
        txtTimeZoneGMT.Text         = Convert.ToString(timeZoneObj.TimeZoneGMT);
        chkTimeZoneDaylight.Checked = timeZoneObj.TimeZoneDaylight;
        if (timeZoneObj.TimeZoneDaylight)
        {
            lblTimeZoneRuleStart.Text = timeZoneObj.TimeZoneRuleStartIn.ToString();
            lblTimeZoneRuleEnd.Text   = timeZoneObj.TimeZoneRuleEndIn.ToString();
            startRuleEditor.Rule      = timeZoneObj.TimeZoneRuleStartRule;
            endRuleEditor.Rule        = timeZoneObj.TimeZoneRuleEndRule;
        }

        if (lblTimeZoneRuleStart.Text.Trim() == String.Empty)
        {
            lblTimeZoneRuleStart.Text = GetString("general.na");
        }

        if (lblTimeZoneRuleEnd.Text.Trim() == String.Empty)
        {
            lblTimeZoneRuleEnd.Text = GetString("general.na");
        }
    }
Ejemplo n.º 10
0
    public override void ReloadData()
    {
        // Hide control for one culture version
        if ((DataSource == null) || DataHelper.DataSourceIsEmpty(SiteCultures) || (SiteCultures.Tables[0].Rows.Count <= 1))
        {
            Visible = false;
        }
        else
        {
            // Check the data source
            if (!(DataSource is GroupedDataSource))
            {
                throw new Exception("[DocumentFlags]: Only GroupedDataSource is supported as a data source.");
            }

            // Register tooltip script
            ScriptHelper.RegisterTooltip(Page);

            // Get appropriate table from the data source
            GroupedDataSource gDS   = (GroupedDataSource)DataSource;
            DataTable         table = gDS.GetGroupDataTable(NodeID);

            // Get document in the default site culture
            DateTime  defaultLastModification = DateTimeHelper.ZERO_TIME;
            DateTime  defaultLastPublished    = DateTimeHelper.ZERO_TIME;
            bool      defaultCultureExists    = false;
            DataRow[] rows = null;
            if (table != null)
            {
                rows = table.Select("DocumentCulture='" + DefaultSiteCulture + "'");
                defaultCultureExists = (rows.Length > 0);
            }

            if (defaultCultureExists)
            {
                defaultLastModification = ValidationHelper.GetDateTime(rows[0]["DocumentModifiedWhen"], DateTimeHelper.ZERO_TIME);
                defaultLastPublished    = ValidationHelper.GetDateTime(rows[0]["DocumentLastPublished"], DateTimeHelper.ZERO_TIME);
            }

            // Build the content
            StringBuilder sb = new StringBuilder();

            sb.Append("<table cellpadding=\"1\" cellspacing=\"0\" class=\"DocumentFlags\">\n<tr>\n");
            int colsInRow = 0;
            int cols      = 0;
            int colsCount = SiteCultures.Tables[0].Rows.Count;
            if (colsCount < RepeatColumns)
            {
                RepeatColumns = colsCount;
            }

            foreach (DataRow dr in SiteCultures.Tables[0].Rows)
            {
                ++cols;
                ++colsInRow;
                DateTime lastModification    = DateTimeHelper.ZERO_TIME;
                string   versionNumber       = null;
                TranslationStatusEnum status = TranslationStatusEnum.NotAvailable;
                string cultureName           = ValidationHelper.GetString(DataHelper.GetDataRowValue(dr, "CultureName"), "-");
                string cultureCode           = ValidationHelper.GetString(DataHelper.GetDataRowValue(dr, "CultureCode"), "-");

                // Get document for given culture
                if (table != null)
                {
                    rows = table.Select("DocumentCulture='" + cultureCode + "'");
                    // Document doesn't exist
                    if (rows.Length != 0)
                    {
                        versionNumber = ValidationHelper.GetString(DataHelper.GetDataRowValue(rows[0], "VersionNumber"), null);

                        // Check if document is outdated
                        if (versionNumber != null)
                        {
                            lastModification = ValidationHelper.GetDateTime(rows[0]["DocumentLastPublished"], DateTimeHelper.ZERO_TIME);
                            status           = (lastModification < defaultLastPublished) ? TranslationStatusEnum.Outdated : TranslationStatusEnum.Translated;
                        }
                        else
                        {
                            lastModification = ValidationHelper.GetDateTime(rows[0]["DocumentModifiedWhen"], DateTimeHelper.ZERO_TIME);
                            status           = (lastModification < defaultLastModification) ? TranslationStatusEnum.Outdated : TranslationStatusEnum.Translated;
                        }
                    }
                }

                sb.Append("<td class=\"", GetStatusCSSClass(status), "\">");
                sb.Append("<img onmouseout=\"UnTip()\" style=\"cursor:pointer;\" onclick=\"", SelectJSFunction, "('", NodeID, "','", cultureCode, "'," + Convert.ToInt32((status != TranslationStatusEnum.NotAvailable)) + "," + ScriptHelper.GetString(ItemUrl + "?" + URLHelper.LanguageParameterName + "=" + cultureCode) + ")\" onmouseover=\"DF_Tip('", GetFlagIconUrl(cultureCode, "48x48"), "', '", cultureName, "', '", GetStatusString(status), "', '");

                sb.Append(versionNumber ?? string.Empty);
                sb.Append("', '");
                TimeZoneInfo ti = null;
                sb.Append((lastModification != DateTimeHelper.ZERO_TIME) ? TimeZoneHelper.GetCurrentTimeZoneDateTimeString(lastModification,
                                                                                                                           CMSContext.CurrentUser, CMSContext.CurrentSite, out ti)
                              : string.Empty);
                sb.Append("')\" src=\"");
                sb.Append(GetFlagIconUrl(cultureCode, "16x16"));
                sb.Append("\" alt=\"");
                sb.Append(cultureName);
                sb.Append("\" /></td>\n");

                // Ensure repeat columns
                if (((colsInRow % RepeatColumns) == 0) && (cols != colsCount))
                {
                    sb.Append("</tr><tr>\n");
                    colsInRow = 0;
                }
            }

            // Ensure rest of the table cells
            if ((colsInRow != RepeatColumns) && (colsInRow != 0))
            {
                while (colsInRow < RepeatColumns)
                {
                    sb.Append("<td>&nbsp;</td>\n");
                    ++colsInRow;
                }
            }
            sb.Append("</tr>\n</table>\n");
            ltlFlags.Text = sb.ToString();
        }
    }
Ejemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.Page.Title = "Time Zone - Edit";

        // Set context help
        CurrentMaster.Title.HelpTopicName = "time_zones_edit";
        CurrentMaster.Title.HelpName      = "helpTopic";

        // Control initialization
        rfvName.ErrorMessage        = GetString("TimeZ.Edit.rfvName");
        rfvDisplayName.ErrorMessage = GetString("TimeZ.Edit.rfvDisplayName");
        rfvGMT.ErrorMessage         = GetString("TimeZ.Edit.rfvGMT");
        rvGMTDouble.ErrorMessage    = GetString("TimeZ.Edit.rvGMTDouble");
        rvGMTDouble.MinimumValue    = (-12.0).ToString();
        rvGMTDouble.MaximumValue    = (13.0).ToString();

        string currentTimeZone = GetString("TimeZ.Edit.NewItem");

        // Get timeZone id from querystring
        zoneid = QueryHelper.GetInteger("zoneid", 0);
        if (zoneid > 0)
        {
            TimeZoneInfo timeZoneObj = TimeZoneInfoProvider.GetTimeZoneInfo(zoneid);
            if (timeZoneObj != null)
            {
                currentTimeZone = timeZoneObj.TimeZoneDisplayName;

                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(timeZoneObj);

                    // Show that the timeZone was created or updated successfully
                    if ((ValidationHelper.GetString(Request.QueryString["saved"], "") == "1") && !URLHelper.IsPostback())
                    {
                        ShowChangesSaved();
                    }
                }
            }
        }
        else
        {
            plcDSTInfo.Visible = false;
        }

        // Initializes page title control
        string[,] breadcrumbs           = new string[2, 3];
        breadcrumbs[0, 0]               = GetString("TimeZ.Edit.ItemList");
        breadcrumbs[0, 1]               = "~/CMSModules/TimeZones/Pages/TimeZone_List.aspx";
        breadcrumbs[0, 2]               = "";
        breadcrumbs[1, 0]               = currentTimeZone;
        breadcrumbs[1, 1]               = "";
        breadcrumbs[1, 2]               = "";
        CurrentMaster.Title.Breadcrumbs = breadcrumbs;
        if (QueryHelper.GetString("zoneid", "") != "")
        {
            CurrentMaster.Title.TitleText  = GetString("timez.edit.properties");
            CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_TimeZone/object.png");
        }
        else
        {
            CurrentMaster.Title.TitleText  = GetString("timez.edit.newtimezone");
            CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_TimeZone/new.png");
        }


        startRuleEditor.Enabled = chkTimeZoneDaylight.Checked;
        endRuleEditor.Enabled   = chkTimeZoneDaylight.Checked;
    }
    /// <summary>
    /// Load data of editing timeZone.
    /// </summary>
    /// <param name="timeZoneObj">TimeZone object</param>
    protected void LoadData(TimeZoneInfo timeZoneObj)
    {
        txtTimeZoneName.Text = timeZoneObj.TimeZoneName;
        txtTimeZoneDisplayName.Text = timeZoneObj.TimeZoneDisplayName;
        txtTimeZoneGMT.Text = Convert.ToString(timeZoneObj.TimeZoneGMT);
        chkTimeZoneDaylight.Checked = timeZoneObj.TimeZoneDaylight;
        if (timeZoneObj.TimeZoneDaylight)
        {
            lblTimeZoneRuleStart.Text = timeZoneObj.TimeZoneRuleStartIn.ToString();
            lblTimeZoneRuleEnd.Text = timeZoneObj.TimeZoneRuleEndIn.ToString();
            startRuleEditor.Rule = timeZoneObj.TimeZoneRuleStartRule;
            endRuleEditor.Rule = timeZoneObj.TimeZoneRuleEndRule;
        }

        if (lblTimeZoneRuleStart.Text.Trim() == String.Empty)
        {
            lblTimeZoneRuleStart.Text = GetString("general.na");
        }

        if (lblTimeZoneRuleEnd.Text.Trim() == String.Empty)
        {
            lblTimeZoneRuleEnd.Text = GetString("general.na");
        }
    }
Ejemplo n.º 13
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string errorMessage = new Validator()
                              .NotEmpty(txtTimeZoneName.Text, rfvName.ErrorMessage)
                              .NotEmpty(txtTimeZoneDisplayName.Text, rfvDisplayName.ErrorMessage)
                              .NotEmpty(txtTimeZoneGMT.Text, rfvGMT.ErrorMessage)
                              .IsCodeName(txtTimeZoneName.Text, GetString("general.invalidcodename"))
                              .IsDouble(txtTimeZoneGMT.Text, rvGMTDouble.ErrorMessage)
                              .Result;

        if (chkTimeZoneDaylight.Checked)
        {
            if ((!startRuleEditor.IsValid()) || (!endRuleEditor.IsValid()))
            {
                errorMessage = GetString("TimeZ.RuleEditor.NotValid");
            }
        }

        if (errorMessage == "")
        {
            // timeZoneName must to be unique
            TimeZoneInfo timeZoneObj = TimeZoneInfoProvider.GetTimeZoneInfo(txtTimeZoneName.Text.Trim());

            // if timeZoneName value is unique
            if ((timeZoneObj == null) || (timeZoneObj.TimeZoneID == zoneid))
            {
                // if timeZoneName value is unique -> determine whether it is update or insert
                if ((timeZoneObj == null))
                {
                    // get TimeZoneInfo object by primary key
                    timeZoneObj = TimeZoneInfoProvider.GetTimeZoneInfo(zoneid);
                    if (timeZoneObj == null)
                    {
                        // create new item -> insert
                        timeZoneObj = new TimeZoneInfo();
                    }
                }

                timeZoneObj.TimeZoneName          = txtTimeZoneName.Text.Trim();
                timeZoneObj.TimeZoneDaylight      = chkTimeZoneDaylight.Checked;
                timeZoneObj.TimeZoneDisplayName   = txtTimeZoneDisplayName.Text.Trim();
                timeZoneObj.TimeZoneRuleStartIn   = ValidationHelper.GetDateTime(TimeZoneInfoProvider.CreateRuleDateTime(startRuleEditor.Rule), DateTime.Now);
                timeZoneObj.TimeZoneRuleEndIn     = ValidationHelper.GetDateTime(TimeZoneInfoProvider.CreateRuleDateTime(endRuleEditor.Rule), DateTime.Now);
                timeZoneObj.TimeZoneRuleStartRule = startRuleEditor.Rule;
                timeZoneObj.TimeZoneRuleEndRule   = endRuleEditor.Rule;
                timeZoneObj.TimeZoneGMT           = Convert.ToDouble(txtTimeZoneGMT.Text.Trim());

                TimeZoneInfoProvider.SetTimeZoneInfo(timeZoneObj);

                URLHelper.Redirect("TimeZone_Edit.aspx?zoneid=" + Convert.ToString(timeZoneObj.TimeZoneID) + "&saved=1");
            }
            else
            {
                ShowError(GetString("TimeZ.Edit.TimeZoneNameExists"));
            }
        }
        else
        {
            ShowError(errorMessage);
        }
    }
Ejemplo n.º 14
0
    /// <summary>
    /// Gets iCalendar file content.
    /// </summary>
    /// <param name="row">Datarow</param>
    protected byte[] GetContent(IDataContainer data, int timeZoneId)
    {
        if (data != null)
        {
            // Get time zone info for shifting event time to specific time zone
            TimeZoneInfo tzi = null;
            if (timeZoneId > 0)
            {
                tzi = TimeZoneInfoProvider.GetTimeZoneInfo(timeZoneId);
            }

            if ((tzi == null) && (TimeZoneHelper.TimeZonesEnabled()))
            {
                // Get time zone for current site
                tzi = TimeZoneHelper.GetSiteTimeZoneInfo(CMSContext.CurrentSite);
            }

            // Get event start time
            DateTime eventStart = ValidationHelper.GetDateTime(data.GetValue("EventDate"), DataHelper.DATETIME_NOT_SELECTED);

            // Shift current time to GMT
            DateTime currentDateGMT = DateTime.Now;
            currentDateGMT = TimeZoneHelper.ConvertTimeZoneDateTimeToGMT(currentDateGMT, tzi);

            // Get if it is all day event
            bool isAllDay = ValidationHelper.GetBoolean(data.GetValue("EventAllDay"), false);

            // Create content
            StringBuilder content = new StringBuilder();
            content.AppendLine("BEGIN:vCalendar");
            content.AppendLine("METHOD:PUBLISH");
            content.AppendLine("BEGIN:vEvent");
            content.Append("DTSTAMP:").Append(currentDateGMT.ToString("yyyyMMdd'T'HHmmss")).AppendLine("Z");
            content.Append("DTSTART");
            if (isAllDay)
            {
                content.Append(";VALUE=DATE:").AppendLine(eventStart.ToString("yyyyMMdd"));
            }
            else
            {
                // Shift event start time to GMT
                eventStart = TimeZoneHelper.ConvertTimeZoneDateTimeToGMT(eventStart, tzi);

                content.Append(":").Append(eventStart.ToString("yyyyMMdd'T'HHmmss")).AppendLine("Z");
            }

            // Get event end time
            DateTime eventEnd = ValidationHelper.GetDateTime(data.GetValue("EventEndDate"), DataHelper.DATETIME_NOT_SELECTED);
            if (eventEnd != DataHelper.DATETIME_NOT_SELECTED)
            {
                content.Append("DTEND");
                if (isAllDay)
                {
                    content.Append(";VALUE=DATE:").AppendLine(eventEnd.AddDays(1).ToString("yyyyMMdd"));
                }
                else
                {
                    // Shift event end time to GMT
                    eventEnd = TimeZoneHelper.ConvertTimeZoneDateTimeToGMT(eventEnd, tzi);

                    content.Append(":").Append(eventEnd.ToString("yyyyMMdd'T'HHmmss")).AppendLine("Z");
                }
            }

            // Get location
            string location = ValidationHelper.GetString(data.GetValue("EventLocation"), string.Empty);

            // Include location if specified
            if (!String.IsNullOrEmpty(location))
            {
                content.Append("LOCATION:").AppendLine(HTMLHelper.StripTags(HttpUtility.HtmlDecode(location)));
            }

            content.Append("DESCRIPTION:").AppendLine(HTMLHelper.StripTags(HttpUtility.HtmlDecode(ValidationHelper.GetString(data.GetValue("EventDetails"), "")).Replace("\r\n", "").Replace("<br />", "\\n")) + "\\n\\n" + HTMLHelper.StripTags(HttpUtility.HtmlDecode(ValidationHelper.GetString(data.GetValue("EventLocation"), "")).Replace("\r\n", "").Replace("<br />", "\\n")));
            content.Append("SUMMARY:").AppendLine(HttpUtility.HtmlDecode(ValidationHelper.GetString(data.GetValue("EventName"), "")));
            content.AppendLine("PRIORITY:3");
            content.AppendLine("BEGIN:vAlarm");
            content.AppendLine("TRIGGER:P0DT0H15M");
            content.AppendLine("ACTION:DISPLAY");
            content.AppendLine("DESCRIPTION:Reminder");
            content.AppendLine("END:vAlarm");
            content.AppendLine("END:vEvent");
            content.AppendLine("END:vCalendar");

            // Return byte array
            return(Encoding.UTF8.GetBytes(content.ToString()));
        }

        return(null);
    }
Ejemplo n.º 15
0
    /// <summary>
    /// Gets and bulk updates timezones. Called when the "Get and bulk update timezones" button is pressed.
    /// Expects the CreateTimezone method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateTimezones()
    {
        // Prepare the parameters
        string where = "TimeZoneName LIKE N'MyNewTimezone%'";

        // Get the data
        DataSet timezones = TimeZoneInfoProvider.GetTimeZones(where, null);
        if (!DataHelper.DataSourceIsEmpty(timezones))
        {
            // Loop through the individual items
            foreach (DataRow timezoneDr in timezones.Tables[0].Rows)
            {
                // Create object from DataRow
                TimeZoneInfo modifyTimezone = new TimeZoneInfo(timezoneDr);

                // Update the properties
                modifyTimezone.TimeZoneDisplayName = modifyTimezone.TimeZoneDisplayName.ToUpper();

                // Save the changes
                TimeZoneInfoProvider.SetTimeZoneInfo(modifyTimezone);
            }

            return true;
        }

        return false;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register WOpener script
        ScriptHelper.RegisterWOpenerScript(Page);

        if (QueryHelper.GetBoolean("rollbackok", false))
        {
            ShowConfirmation(GetString("VersionProperties.RollbackOK"));
        }

        noCompare = QueryHelper.GetBoolean("noCompare", false);
        versionHistoryId = QueryHelper.GetInteger("versionhistoryid", 0);
        versionCompare = QueryHelper.GetInteger("compareHistoryId", 0);

        // Converting modified time to correct time zone
        TimeZoneHelper.GetCurrentTimeZoneDateTimeString(DateTime.Now, CurrentUser, CMSContext.CurrentSite, out usedTimeZone);
        serverTimeZone = TimeZoneHelper.ServerTimeZone;

        // No comparing available in Recycle bin
        pnlControl.Visible = !noCompare;

        if (versionHistoryId > 0)
        {
            try
            {
                // Get original version of document
                Node = VersionManager.GetVersion(versionHistoryId, null);
                CompareNode = VersionManager.GetVersion(versionCompare, null);

                if (Node != null)
                {
                    // Check read permissions
                    if (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Read) != AuthorizationResultEnum.Allowed)
                    {
                        RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), Node.NodeAliasPath));
                    }

                    if (!RequestHelper.IsPostBack())
                    {
                        LoadDropDown(Node.DocumentID, versionHistoryId);
                        ReloadData();
                    }

                    drpCompareTo.SelectedIndexChanged += drpCompareTo_SelectedIndexChanged;
                }
                else
                {
                    ShowInformation(GetString("editeddocument.notexists"));
                    pnlAdditionalControls.Visible = false;
                }
            }
            catch (Exception ex)
            {
                if (Node == null)
                {
                    RedirectToInformation(GetString("editeddocument.notexists"));
                }
                else
                {
                    ShowError(GetString("document.viewversionerror") + " " + ex.Message);
                }

                EventLogProvider.LogException("Content", "VIEWVERSION", ex);
            }
        }
    }
Ejemplo n.º 17
0
    private void ReloadData()
    {
        if (Node != null)
        {
            // Log activities checkboxes
            if (!RequestHelper.IsPostBack())
            {
                bool?logVisit = Node.DocumentLogVisitActivity;
                chkLogPageVisit.Checked = (logVisit == true);
                if (Node.NodeParentID > 0)  // Init "inherit" option for child nodes (and hide option for root)
                {
                    chkPageVisitInherit.Checked = (logVisit == null);
                    if (logVisit == null)
                    {
                        chkPageVisitInherit_CheckedChanged(null, EventArgs.Empty);
                    }
                }
                chkLogPageVisit.Enabled = !chkPageVisitInherit.Checked;
            }

            // Check modify permission
            canEdit = (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) != AuthorizationResultEnum.Denied);

            // Show document group owner selector
            if (ModuleEntry.IsModuleLoaded(ModuleEntry.COMMUNITY) && canEditOwner && LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.Groups))
            {
                plcOwnerGroup.Controls.Clear();
                // Initialize table
                TableRow  rowOwner     = new TableRow();
                TableCell cellTitle    = new TableCell();
                TableCell cellSelector = new TableCell();

                // Initialize caption
                LocalizedLabel lblOwnerGroup = new LocalizedLabel();
                lblOwnerGroup.EnableViewState = false;
                lblOwnerGroup.ResourceString  = "community.group.documentowner";
                lblOwnerGroup.ID = "lblOwnerGroup";
                cellTitle.Controls.Add(lblOwnerGroup);

                // Initialize selector
                fcDocumentGroupSelector                = (FormEngineUserControl)Page.LoadUserControl("~/CMSAdminControls/UI/Selectors/DocumentGroupSelector.ascx");
                fcDocumentGroupSelector.ID             = "fcDocumentGroupSelector";
                fcDocumentGroupSelector.StopProcessing = pnlUIOwner.IsHidden;
                cellSelector.Controls.Add(fcDocumentGroupSelector);
                fcDocumentGroupSelector.Value = ValidationHelper.GetInteger(Node.GetValue("NodeGroupID"), 0);
                fcDocumentGroupSelector.SetValue("siteid", CMSContext.CurrentSiteID);
                fcDocumentGroupSelector.SetValue("nodeid", Node.NodeID);

                // Add controls to containers
                rowOwner.Cells.Add(cellTitle);
                rowOwner.Cells.Add(cellSelector);
                plcOwnerGroup.Controls.Add(rowOwner);
                plcOwnerGroup.Visible = true;
            }

            // Show owner editing only when authorized to change the permissions
            if (canEditOwner)
            {
                lblOwner.Visible = false;
                usrOwner.Visible = true;
                usrOwner.SetValue("AdditionalUsers", new int[] { Node.NodeOwner });
            }
            else
            {
                usrOwner.Visible = false;
            }

            if (!RequestHelper.IsPostBack())
            {
                if (canEditOwner)
                {
                    usrOwner.Value = Node.GetValue("NodeOwner");
                }
            }

            // Load the data
            lblName.Text      = HttpUtility.HtmlEncode(Node.GetDocumentName());
            lblNamePath.Text  = HttpUtility.HtmlEncode(Convert.ToString(Node.GetValue("DocumentNamePath")));
            lblAliasPath.Text = Convert.ToString(Node.NodeAliasPath);
            string typeName = DataClassInfoProvider.GetDataClass(Node.NodeClassName).ClassDisplayName;
            lblType.Text   = HttpUtility.HtmlEncode(ResHelper.LocalizeString(typeName));
            lblNodeID.Text = Convert.ToString(Node.NodeID);

            // Modifier
            SetUserLabel(lblLastModifiedBy, "DocumentModifiedByUserId");

            // Get modified time
            TimeZoneInfo usedTimeZone = null;
            DateTime     lastModified = ValidationHelper.GetDateTime(Node.GetValue("DocumentModifiedWhen"), DateTimeHelper.ZERO_TIME);
            lblLastModified.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(lastModified, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone);
            ScriptHelper.AppendTooltip(lblLastModified, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help");

            if (!canEditOwner)
            {
                // Owner
                SetUserLabel(lblOwner, "NodeOwner");
            }

            // Creator
            SetUserLabel(lblCreatedBy, "DocumentCreatedByUserId");
            DateTime createdWhen = ValidationHelper.GetDateTime(Node.GetValue("DocumentCreatedWhen"), DateTimeHelper.ZERO_TIME);
            lblCreated.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(createdWhen, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone);
            ScriptHelper.AppendTooltip(lblCreated, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help");


            // URL
            string liveUrl = Node.IsLink ? CMSContext.GetUrl(Node.NodeAliasPath, null) : CMSContext.GetUrl(Node.NodeAliasPath, Node.DocumentUrlPath);
            lnkLiveURL.Text        = URLHelper.ResolveUrl(liveUrl, true, false);
            lnkLiveURL.NavigateUrl = URLHelper.ResolveUrl(liveUrl);

            bool isRoot = (Node.NodeClassName.ToLowerCSafe() == "cms.root");

            // Preview URL
            if (!isRoot)
            {
                plcPreview.Visible = true;
                string path = canEdit ? "/CMSModules/CMS_Content/Properties/resetlink.png" : "/CMSModules/CMS_Content/Properties/resetlinkdisabled.png";
                btnResetPreviewGuid.ImageUrl      = GetImageUrl(path);
                btnResetPreviewGuid.ToolTip       = GetString("GeneralProperties.InvalidatePreviewURL");
                btnResetPreviewGuid.ImageAlign    = ImageAlign.AbsBottom;
                btnResetPreviewGuid.Click        += btnResetPreviewGuid_Click;
                btnResetPreviewGuid.OnClientClick = "if(!confirm('" + GetString("GeneralProperties.GeneratePreviewURLConf") + "')){return false;}";

                InitPreviewUrl();
            }

            lblGUID.Text    = Convert.ToString(Node.NodeGUID);
            lblDocGUID.Text = (Node.DocumentGUID == Guid.Empty) ? ResHelper.Dash : Node.DocumentGUID.ToString();
            lblDocID.Text   = Convert.ToString(Node.DocumentID);

            // Culture
            CultureInfo ci = CultureInfoProvider.GetCultureInfo(Node.DocumentCulture);
            lblCulture.Text = ((ci != null) ? ResHelper.LocalizeString(ci.CultureName) : Node.DocumentCulture);

            lblPublished.Text = (Node.IsPublished ? "<span class=\"DocumentPublishedYes\">" + GetString("General.Yes") + "</span>" : "<span class=\"DocumentPublishedNo\">" + GetString("General.No") + "</span>");

            if (!RequestHelper.IsPostBack())
            {
                // Init radio buttons for cache settings
                if (isRoot)
                {
                    radInherit.Visible   = false;
                    radFSInherit.Visible = false;
                    chkCssStyle.Visible  = false;
                }

                string cacheMinutes = "";

                switch (Node.NodeCacheMinutes)
                {
                case -1:
                    // Cache is off
                {
                    radNo.Checked      = true;
                    radYes.Checked     = false;
                    radInherit.Checked = false;
                    if (!isRoot)
                    {
                        radInherit.Checked = true;
                        radNo.Checked      = false;
                    }
                }
                break;

                case 0:
                    // Cache is off
                    radNo.Checked      = true;
                    radYes.Checked     = false;
                    radInherit.Checked = false;
                    break;

                default:
                    // Cache is enabled
                    radNo.Checked      = false;
                    radYes.Checked     = true;
                    radInherit.Checked = false;
                    cacheMinutes       = Node.NodeCacheMinutes.ToString();
                    break;
                }

                // Set secured radio buttons
                switch (Node.NodeAllowCacheInFileSystem)
                {
                case 0:
                    radFSNo.Checked = true;
                    break;

                case 1:
                    radFSYes.Checked = true;
                    break;

                default:
                    if (!isRoot)
                    {
                        radFSInherit.Checked = true;
                    }
                    else
                    {
                        radFSYes.Checked = true;
                    }
                    break;
                }

                txtCacheMinutes.Text = cacheMinutes;

                if (!radYes.Checked)
                {
                    txtCacheMinutes.Enabled = false;
                }

                if (Node.GetValue("DocumentStylesheetID") == null)
                {
                    // If default site not exist edit is set to -1 - disabled
                    if (CMSContext.CurrentSiteStylesheet != null)
                    {
                        ctrlSiteSelectStyleSheet.Value = "default";
                    }
                    else
                    {
                        ctrlSiteSelectStyleSheet.Value = -1;
                    }
                }
                else
                {
                    // If stylesheet is inherited from parent document
                    if (ValidationHelper.GetInteger(Node.GetValue("DocumentStylesheetID"), 0) == -1)
                    {
                        if (!isRoot)
                        {
                            chkCssStyle.Checked = true;

                            // Get parent stylesheet
                            string value = PageInfoProvider.GetParentProperty(CMSContext.CurrentSite.SiteID, Node.NodeAliasPath, "(DocumentStylesheetID <> -1 OR DocumentStylesheetID IS NULL) AND DocumentCulture = N'" + SqlHelperClass.GetSafeQueryString(Node.DocumentCulture, false) + "'", "DocumentStylesheetID");

                            if (String.IsNullOrEmpty(value))
                            {
                                // If default site stylesheet not exist edit is set to -1 - disabled
                                if (CMSContext.CurrentSiteStylesheet != null)
                                {
                                    ctrlSiteSelectStyleSheet.Value = "default";
                                }
                                else
                                {
                                    ctrlSiteSelectStyleSheet.Value = -1;
                                }
                            }
                            else
                            {
                                // Set parent stylesheet to current document
                                ctrlSiteSelectStyleSheet.Value = value;
                            }
                        }
                    }
                    else
                    {
                        ctrlSiteSelectStyleSheet.Value = Node.GetValue("DocumentStylesheetID");
                    }
                }
            }

            // Disable new button if document inherit stylesheet
            bool disableCssSelector = (!isRoot && chkCssStyle.Checked);
            ctrlSiteSelectStyleSheet.Enabled          = !disableCssSelector;
            ctrlSiteSelectStyleSheet.ButtonNewEnabled = !disableCssSelector;

            // Initialize Rating control
            RefreshCntRatingResult();

            double rating = 0.0f;
            if (Node.DocumentRatings > 0)
            {
                rating = Node.DocumentRatingValue / Node.DocumentRatings;
            }
            ratingControl.MaxRating     = 10;
            ratingControl.CurrentRating = rating;
            ratingControl.Visible       = true;
            ratingControl.Enabled       = false;

            // Initialize Reset button for rating
            btnResetRating.Text          = GetString("general.reset");
            btnResetRating.OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("GeneralProperties.ResetRatingConfirmation")) + ")) return false;";

            object[] param = new object[1];
            param[0] = Node.DocumentID;

            plcAdHocForums.Visible = hasAdHocForum;
            plcAdHocBoards.Visible = hasAdHocBoard;

            if (!canEdit)
            {
                // Disable form editing
                DisableFormEditing();
            }
        }
        else
        {
            btnResetRating.Visible = false;
        }
    }
Ejemplo n.º 18
0
    /// <summary>
    /// On btnRegister click.
    /// </summary>
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        string currentSiteName = CMSContext.CurrentSiteName;

        // Check banned ip
        if (!BannedIPInfoProvider.IsAllowed(currentSiteName, BanControlEnum.AllNonComplete))
        {
            lblError.Visible = true;
            lblError.Text    = GetString("General.BannedIP");
            return;
        }

        // Exit if problem occurs
        if (errorOccurs)
        {
            return;
        }

        string    result = null;
        Validator val    = new Validator();

        // Check name fields if required
        if (RequireName)
        {
            result = val.NotEmpty(txtFirstName.Text.Trim(), GetString("eventmanager.firstnamerequired"))
                     .NotEmpty(txtLastName.Text.Trim(), GetString("eventmanager.lastnamerequired")).Result;
        }
        // Check e-mail field
        if (string.IsNullOrEmpty(result))
        {
            result = val.IsEmail(txtEmail.Text.Trim(), GetString("eventmanager.emailrequired")).Result;
        }
        // Check phone field if required
        if (RequirePhone && string.IsNullOrEmpty(result))
        {
            result = val.NotEmpty(txtPhone.Text.Trim(), GetString("eventmanager.phonerequired")).Result;
        }

        if (string.IsNullOrEmpty(result))
        {
            DateTime now = DateTime.Now;
            // Allow registration if opened
            if ((openFrom == DataHelper.DATETIME_NOT_SELECTED || openFrom < now) && (openTo == DataHelper.DATETIME_NOT_SELECTED || now <= openTo) && (now <= eventDate))
            {
                if (EventNode != null)
                {
                    if (!EventAttendeeInfoProvider.IsRegisteredForEvent(EventNode.NodeID, txtEmail.Text.Trim()))
                    {
                        // Add new attendant to the event
                        EventAttendeeInfo eai = AddAttendantToEvent();

                        if (eai != null)
                        {
                            // Log activity
                            Activity activity = new ActivityEventBooking(EventNode, EventNode.GetDocumentName(), eai, CMSContext.ActivityEnvironmentVariables);
                            activity.Log();

                            // Send invitation e-mail
                            TimeZoneInfo tzi = null;
                            CMSContext.GetDateTimeForControl(this, DateTime.Now, out tzi);
                            EventProvider.SendInvitation(currentSiteName, EventNode, eai, tzi);

                            lblRegInfo.Text    = GetString("eventmanager.registrationsucceeded");
                            lblRegInfo.Visible = true;
                            // Hide registration form
                            pnlReg.Visible = false;
                        }
                    }
                    else
                    {
                        // User is already registered
                        lblError.Text    = GetString("eventmanager.attendeeregistered");
                        lblError.Visible = true;
                    }
                }
                else
                {
                    // Event does not exist
                    lblError.Text    = GetString("eventmanager.eventnotexist");
                    lblError.Visible = true;
                    // Hide registration form
                    pnlReg.Visible = false;
                }
            }
            else
            {
                // Event registration is not opened
                lblError.Text    = GetString("eventmanager.notopened");
                lblError.Visible = true;
                // Hide registration form
                pnlReg.Visible = false;
            }
        }
        else
        {
            // Display error message
            lblError.Text    = result;
            lblError.Visible = true;
        }
    }
Ejemplo n.º 19
0
    /// <summary>
    /// On btnRegister click.
    /// </summary>
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        string currentSiteName = CMSContext.CurrentSiteName;

        // Check banned ip
        if (!BannedIPInfoProvider.IsAllowed(currentSiteName, BanControlEnum.AllNonComplete))
        {
            lblError.Visible = true;
            lblError.Text    = GetString("General.BannedIP");
            return;
        }

        // Exit if problem occurs
        if (errorOccurs)
        {
            return;
        }

        string    result = null;
        Validator val    = new Validator();

        // Check name fields if required
        if (this.RequireName)
        {
            result = val.NotEmpty(txtFirstName.Text.Trim(), GetString("eventmanager.firstnamerequired"))
                     .NotEmpty(txtLastName.Text.Trim(), GetString("eventmanager.lastnamerequired")).Result;
        }
        // Check e-mail field
        if (string.IsNullOrEmpty(result))
        {
            result = val.IsEmail(txtEmail.Text.Trim(), GetString("eventmanager.emailrequired")).Result;
        }
        // Check phone field if required
        if (this.RequirePhone && string.IsNullOrEmpty(result))
        {
            result = val.NotEmpty(txtPhone.Text.Trim(), GetString("eventmanager.phonerequired")).Result;
        }

        if (string.IsNullOrEmpty(result))
        {
            DateTime now = DateTime.Now;
            // Allow registration if opened
            if ((openFrom == DataHelper.DATETIME_NOT_SELECTED || openFrom < now) && (openTo == DataHelper.DATETIME_NOT_SELECTED || now <= openTo) && (now <= eventDate))
            {
                if (EventNode != null)
                {
                    if (!EventAttendeeInfoProvider.IsRegisteredForEvent(EventNode.NodeID, txtEmail.Text.Trim()))
                    {
                        // Add new attendant to the event
                        EventAttendeeInfo eai = AddAttendantToEvent();

                        if (eai != null)
                        {
                            // Log activity
                            if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(currentSiteName) &&
                                ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) && ActivitySettingsHelper.EventBookingEnabled(currentSiteName))
                            {
                                if (ValidationHelper.GetBoolean(EventNode.GetValue("EventLogActivity"), false))
                                {
                                    var data = new ActivityData()
                                    {
                                        ContactID    = ModuleCommands.OnlineMarketingGetCurrentContactID(),
                                        SiteID       = CMSContext.CurrentSiteID,
                                        Type         = PredefinedActivityType.EVENT_BOOKING,
                                        TitleData    = EventNode.DocumentName,
                                        ItemID       = eai.AttendeeID,
                                        URL          = URLHelper.CurrentRelativePath,
                                        ItemDetailID = EventNode.DocumentID,
                                        NodeID       = EventNode.NodeID,
                                        Culture      = EventNode.DocumentCulture,
                                        Campaign     = CMSContext.Campaign
                                    };
                                    ActivityLogProvider.LogActivity(data);
                                }
                            }

                            // Send invitation e-mail
                            TimeZoneInfo tzi = null;
                            CMSContext.GetDateTimeForControl(this, DateTime.Now, out tzi);
                            EventProvider.SendInvitation(currentSiteName, EventNode, eai, tzi);

                            lblRegInfo.Text    = GetString("eventmanager.registrationsucceeded");
                            lblRegInfo.Visible = true;
                            // Hide registration form
                            pnlReg.Visible = false;
                        }
                    }
                    else
                    {
                        // User is already registered
                        lblError.Text    = GetString("eventmanager.attendeeregistered");
                        lblError.Visible = true;
                    }
                }
                else
                {
                    // Event does not exist
                    lblError.Text    = GetString("eventmanager.eventnotexist");
                    lblError.Visible = true;
                    // Hide registration form
                    pnlReg.Visible = false;
                }
            }
            else
            {
                // Event registration is not opened
                lblError.Text    = GetString("eventmanager.notopened");
                lblError.Visible = true;
                // Hide registration form
                pnlReg.Visible = false;
            }
        }
        else
        {
            // Display error message
            lblError.Text    = result;
            lblError.Visible = true;
        }
    }
Ejemplo n.º 20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Register WOpener script
        ScriptHelper.RegisterWOpenerScript(Page);

        if (QueryHelper.GetBoolean("rollbackok", false))
        {
            lblInfo.Visible = true;
            lblInfo.Text    = GetString("VersionProperties.RollbackOK");
        }

        noCompare        = QueryHelper.GetBoolean("noCompare", false);
        versionHistoryId = QueryHelper.GetInteger("versionhistoryid", 0);
        versionCompare   = QueryHelper.GetInteger("compareHistoryId", 0);

        // Converting modified time to correct time zone
        TimeZoneHelper.GetCurrentTimeZoneDateTimeString(DateTime.Now, CurrentUser, CMSContext.CurrentSite, out usedTimeZone);
        serverTimeZone = TimeZoneHelper.ServerTimeZone;

        // No comparing available in Recycle bin
        pnlControl.Visible = !noCompare;

        if (versionHistoryId > 0)
        {
            try
            {
                // Get original version of document
                Node        = VersionManager.GetVersion(versionHistoryId, null);
                CompareNode = VersionManager.GetVersion(versionCompare, null);

                if (Node != null)
                {
                    // Check read permissions
                    if (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Read) != AuthorizationResultEnum.Allowed)
                    {
                        RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), Node.NodeAliasPath));
                    }

                    if (!RequestHelper.IsPostBack())
                    {
                        LoadDropDown(Node.DocumentID, versionHistoryId);
                        ReloadData();
                    }

                    drpCompareTo.SelectedIndexChanged += drpCompareTo_SelectedIndexChanged;
                }
                else
                {
                    lblInfo.Text                  = GetString("editeddocument.notexists");
                    plcLabels.Visible             = true;
                    lblInfo.Visible               = true;
                    pnlAdditionalControls.Visible = false;
                }
            }
            catch (Exception ex)
            {
                if (Node == null)
                {
                    RedirectToInformation(GetString("editeddocument.notexists"));
                }
                else
                {
                    lblError.Text = GetString("document.viewversionerror") + " " + ex.Message;
                }

                EventLogProvider.LogException("Content", "VIEWVERSION", ex);
            }
        }
    }
Ejemplo n.º 21
0
    /// <summary>
    /// Adds the field to the form.
    /// </summary>
    /// <param name="node">Document node</param>
    /// <param name="compareNode">Document compare node</param>
    /// <param name="columnName">Column name</param>
    private void AddField(TreeNode node, TreeNode compareNode, string columnName)
    {
        FormFieldInfo ffi = null;

        if (fi != null)
        {
            ffi = fi.GetFormField(columnName);
        }

        TableCell valueCell = new TableCell();

        valueCell.EnableViewState = false;
        TableCell valueCompare = new TableCell();

        valueCompare.EnableViewState = false;
        TableCell labelCell = new TableCell();

        labelCell.EnableViewState = false;
        TextComparison comparefirst  = null;
        TextComparison comparesecond = null;
        bool           switchSides   = true;
        bool           loadValue     = true;
        bool           empty         = true;
        bool           allowLabel    = true;

        // Get the caption
        if ((columnName == UNSORTED) || (ffi != null))
        {
            AttachmentInfo aiCompare = null;

            // Compare attachments
            if ((columnName == UNSORTED) || (ffi.DataType == FormFieldDataTypeEnum.DocumentAttachments))
            {
                allowLabel = false;

                string title = null;
                if (columnName == UNSORTED)
                {
                    title = GetString("attach.unsorted") + ":";
                }
                else
                {
                    title = (String.IsNullOrEmpty(ffi.Caption) ? ffi.Name : ffi.Caption) + ":";
                }

                // Prepare DataSource for original node
                loadValue = false;

                dsAttachments = new AttachmentsDataSource();
                dsAttachments.DocumentVersionHistoryID = versionHistoryId;
                if (columnName != UNSORTED)
                {
                    dsAttachments.AttachmentGroupGUID = ffi.Guid;
                }
                dsAttachments.Path        = node.NodeAliasPath;
                dsAttachments.CultureCode = CMSContext.PreferredCultureCode;
                SiteInfo si = SiteInfoProvider.GetSiteInfo(node.NodeSiteID);
                dsAttachments.SiteName        = si.SiteName;
                dsAttachments.OrderBy         = "AttachmentOrder, AttachmentName, AttachmentHistoryID";
                dsAttachments.SelectedColumns = "AttachmentHistoryID, AttachmentGUID, AttachmentImageWidth, AttachmentImageHeight, AttachmentExtension, AttachmentName, AttachmentSize, AttachmentOrder, AttachmentTitle, AttachmentDescription";
                dsAttachments.IsLiveSite      = false;
                dsAttachments.DataSource      = null;
                dsAttachments.DataBind();

                // Get the attachments table
                attachments = GetAttachmentsTable((DataSet)dsAttachments.DataSource, versionHistoryId, node.DocumentID);

                // Prepare datasource for compared node
                if (compareNode != null)
                {
                    dsAttachmentsCompare = new AttachmentsDataSource();
                    dsAttachmentsCompare.DocumentVersionHistoryID = versionCompare;
                    if (columnName != UNSORTED)
                    {
                        dsAttachmentsCompare.AttachmentGroupGUID = ffi.Guid;
                    }
                    dsAttachmentsCompare.Path            = compareNode.NodeAliasPath;
                    dsAttachmentsCompare.CultureCode     = CMSContext.PreferredCultureCode;
                    dsAttachmentsCompare.SiteName        = si.SiteName;
                    dsAttachmentsCompare.OrderBy         = "AttachmentOrder, AttachmentName, AttachmentHistoryID";
                    dsAttachmentsCompare.SelectedColumns = "AttachmentHistoryID, AttachmentGUID, AttachmentImageWidth, AttachmentImageHeight, AttachmentExtension, AttachmentName, AttachmentSize, AttachmentOrder, AttachmentTitle, AttachmentDescription";
                    dsAttachmentsCompare.IsLiveSite      = false;
                    dsAttachmentsCompare.DataSource      = null;
                    dsAttachmentsCompare.DataBind();

                    // Get the table to compare
                    attachmentsCompare = GetAttachmentsTable((DataSet)dsAttachmentsCompare.DataSource, versionCompare, node.DocumentID);

                    // Switch the sides if older version is on the right
                    if (versionHistoryId > versionCompare)
                    {
                        Hashtable dummy = attachmentsCompare;
                        attachmentsCompare = attachments;
                        attachments        = dummy;
                    }

                    // Add comparison
                    AddTableComparison(attachments, attachmentsCompare, "<strong>" + title + "</strong>", true, true);
                }
                else
                {
                    // Normal display
                    if (attachments.Count != 0)
                    {
                        bool   first     = true;
                        string itemValue = null;

                        foreach (DictionaryEntry item in attachments)
                        {
                            itemValue = ValidationHelper.GetString(item.Value, null);
                            if (!String.IsNullOrEmpty(itemValue))
                            {
                                valueCell = new TableCell();
                                labelCell = new TableCell();

                                if (first)
                                {
                                    labelCell.Text = "<strong>" + String.Format(title, item.Key) + "</strong>";
                                    first          = false;
                                }
                                valueCell.Text = itemValue;

                                AddRow(labelCell, valueCell, null, even);
                                even = !even;
                            }
                        }
                    }
                }
            }
            // Compare single file attachment
            else if (ffi.DataType == FormFieldDataTypeEnum.File)
            {
                // Get the attachment
                AttachmentInfo ai = DocumentHelper.GetAttachment(ValidationHelper.GetGuid(node.GetValue(columnName), Guid.Empty), versionHistoryId, TreeProvider, false);

                if (compareNode != null)
                {
                    aiCompare = DocumentHelper.GetAttachment(ValidationHelper.GetGuid(compareNode.GetValue(columnName), Guid.Empty), versionCompare, TreeProvider, false);
                }

                loadValue = false;
                empty     = true;

                // Prepare text comparison controls
                if ((ai != null) || (aiCompare != null))
                {
                    string textorig = null;
                    if (ai != null)
                    {
                        textorig = CreateAttachment(ai.Generalized.DataClass, versionHistoryId);
                    }
                    string textcompare = null;
                    if (aiCompare != null)
                    {
                        textcompare = CreateAttachment(aiCompare.Generalized.DataClass, versionCompare);
                    }

                    comparefirst = new TextComparison();
                    comparefirst.SynchronizedScrolling = false;
                    comparefirst.IgnoreHTMLTags        = true;
                    comparefirst.ConsiderHTMLTagsEqual = true;
                    comparefirst.BalanceContent        = false;

                    comparesecond = new TextComparison();
                    comparesecond.SynchronizedScrolling = false;
                    comparesecond.IgnoreHTMLTags        = true;

                    // Source text must be older version
                    if (versionHistoryId < versionCompare)
                    {
                        comparefirst.SourceText      = textorig;
                        comparefirst.DestinationText = textcompare;
                    }
                    else
                    {
                        comparefirst.SourceText      = textcompare;
                        comparefirst.DestinationText = textorig;
                    }

                    comparefirst.PairedControl  = comparesecond;
                    comparesecond.RenderingMode = TextComparisonTypeEnum.DestinationText;

                    valueCell.Controls.Add(comparefirst);
                    valueCompare.Controls.Add(comparesecond);
                    switchSides = false;

                    // Add both cells
                    if (compareNode != null)
                    {
                        AddRow(labelCell, valueCell, valueCompare, switchSides, null, even);
                    }
                    // Add one cell only
                    else
                    {
                        valueCell.Controls.Clear();
                        Literal ltl = new Literal();
                        ltl.Text = textorig;
                        valueCell.Controls.Add(ltl);
                        AddRow(labelCell, valueCell, null, even);
                    }
                    even = !even;
                }
            }
        }

        if (allowLabel && (labelCell.Text == ""))
        {
            labelCell.Text = "<strong>" + columnName + ":</strong>";
        }

        if (loadValue)
        {
            string textcompare = null;

            switch (columnName.ToLower())
            {
            // Document content - display content of editable regions and editable web parts
            case "documentcontent":
                EditableItems ei = new EditableItems();
                ei.LoadContentXml(ValidationHelper.GetString(node.GetValue(columnName), ""));

                // Add text comparison control
                if (compareNode != null)
                {
                    EditableItems eiCompare = new EditableItems();
                    eiCompare.LoadContentXml(ValidationHelper.GetString(compareNode.GetValue(columnName), ""));

                    // Create editable regions comparison
                    Hashtable hashtable;
                    Hashtable hashtableCompare;

                    // Source text must be older version
                    if (versionHistoryId < versionCompare)
                    {
                        hashtable        = ei.EditableRegions;
                        hashtableCompare = eiCompare.EditableRegions;
                    }
                    else
                    {
                        hashtable        = eiCompare.EditableRegions;
                        hashtableCompare = ei.EditableRegions;
                    }

                    // Add comparison
                    AddTableComparison(hashtable, hashtableCompare, "<strong>" + columnName + " ({0}):</strong>", false, false);

                    // Create editable webparts comparison
                    // Source text must be older version
                    if (versionHistoryId < versionCompare)
                    {
                        hashtable        = ei.EditableWebParts;
                        hashtableCompare = eiCompare.EditableWebParts;
                    }
                    else
                    {
                        hashtable        = eiCompare.EditableWebParts;
                        hashtableCompare = ei.EditableWebParts;
                    }

                    // Add comparison
                    AddTableComparison(hashtable, hashtableCompare, "<strong>" + columnName + " ({0}):</strong>", false, false);
                }
                // No compare node
                else
                {
                    // Editable regions
                    Hashtable hashtable = ei.EditableRegions;
                    if (hashtable.Count != 0)
                    {
                        string regionValue = null;
                        string regionKey   = null;

                        foreach (DictionaryEntry region in hashtable)
                        {
                            regionValue = ValidationHelper.GetString(region.Value, null);
                            if (!String.IsNullOrEmpty(regionValue))
                            {
                                regionKey = ValidationHelper.GetString(region.Key, null);

                                valueCell = new TableCell();
                                labelCell = new TableCell();

                                labelCell.Text = "<strong>" + columnName + " (" + MultiKeyHashtable.GetFirstKey(regionKey) + "):</strong>";
                                valueCell.Text = HttpUtility.HtmlDecode(HTMLHelper.StripTags(regionValue, false));

                                AddRow(labelCell, valueCell, null, even);
                                even = !even;
                            }
                        }
                    }

                    // Editable web parts
                    hashtable = ei.EditableWebParts;
                    if (hashtable.Count != 0)
                    {
                        string partValue = null;
                        string partKey   = null;

                        foreach (DictionaryEntry part in hashtable)
                        {
                            partValue = ValidationHelper.GetString(part.Value, null);
                            if (!String.IsNullOrEmpty(partValue))
                            {
                                partKey   = ValidationHelper.GetString(part.Key, null);
                                valueCell = new TableCell();
                                labelCell = new TableCell();

                                labelCell.Text = "<strong>" + columnName + " (" + MultiKeyHashtable.GetFirstKey(partKey) + "):</strong>";
                                valueCell.Text = HttpUtility.HtmlDecode(HTMLHelper.StripTags(partValue, false));

                                AddRow(labelCell, valueCell, null, even);
                                even = !even;
                            }
                        }
                    }
                }

                break;

            // Others, display the string value
            default:
                // Shift date time values to user time zone
                object origobject = node.GetValue(columnName);
                string textorig   = null;
                if (origobject is DateTime)
                {
                    TimeZoneInfo usedTimeZone = null;
                    textorig = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(ValidationHelper.GetDateTime(origobject, DateTimeHelper.ZERO_TIME), CurrentUser, CMSContext.CurrentSite, out usedTimeZone);
                }
                else
                {
                    textorig = ValidationHelper.GetString(origobject, "");
                }

                // Add text comparison control
                if (compareNode != null)
                {
                    // Shift date time values to user time zone
                    object compareobject = compareNode.GetValue(columnName);
                    if (compareobject is DateTime)
                    {
                        TimeZoneInfo usedTimeZone = null;
                        textcompare = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(ValidationHelper.GetDateTime(compareobject, DateTimeHelper.ZERO_TIME), CurrentUser, CMSContext.CurrentSite, out usedTimeZone);
                    }
                    else
                    {
                        textcompare = ValidationHelper.GetString(compareobject, "");
                    }

                    comparefirst = new TextComparison();
                    comparefirst.SynchronizedScrolling = false;

                    comparesecond = new TextComparison();
                    comparesecond.SynchronizedScrolling = false;
                    comparesecond.RenderingMode         = TextComparisonTypeEnum.DestinationText;

                    // Source text must be older version
                    if (versionHistoryId < versionCompare)
                    {
                        comparefirst.SourceText      = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textorig, false));
                        comparefirst.DestinationText = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textcompare, false));
                    }
                    else
                    {
                        comparefirst.SourceText      = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textcompare, false));
                        comparefirst.DestinationText = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textorig, false));
                    }

                    comparefirst.PairedControl = comparesecond;

                    if (Math.Max(comparefirst.SourceText.Length, comparefirst.DestinationText.Length) < 100)
                    {
                        comparefirst.BalanceContent = false;
                    }

                    valueCell.Controls.Add(comparefirst);
                    valueCompare.Controls.Add(comparesecond);
                    switchSides = false;
                }
                else
                {
                    valueCell.Text = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textorig, false));
                }

                empty = (String.IsNullOrEmpty(textorig)) && (String.IsNullOrEmpty(textcompare));
                break;
            }
        }

        if (!empty)
        {
            if (compareNode != null)
            {
                AddRow(labelCell, valueCell, valueCompare, switchSides, null, even);
                even = !even;
            }
            else
            {
                AddRow(labelCell, valueCell, null, even);
                even = !even;
            }
        }
    }
Ejemplo n.º 22
0
    protected void Page_Load(Object sender, EventArgs e)
    {
        // Get parameters
        selDate    = QueryHelper.GetString("selDate", "");
        allowEmpty = QueryHelper.GetBoolean("allowempty", false);
        editTime   = QueryHelper.GetBoolean("editTime", false);
        controlId  = QueryHelper.GetText("controlid", "");

        SetBrowserClass();

        ScriptHelper.RegisterTooltip(Page);

        // Disable caching
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        pagetitle = GetString("Calendar.Title");

        // Fill in the dropdown values
        if (drpHours.Items.Count == 0)
        {
            FillNumbers(drpHours, 0, 23);
        }
        if (drpMinutes.Items.Count == 0)
        {
            FillNumbers(drpMinutes, 0, 59);
        }
        if (drpSeconds.Items.Count == 0)
        {
            FillNumbers(drpSeconds, 0, 59);
        }

        // Fill in the month selector
        if (drpMonth.Items.Count == 0)
        {
            FillMonths(drpMonth, mCulture);
        }

        // Setup the buttons
        btnCancel.Text = GetString("general.cancel");
        btnCancel.Attributes.Add("onclick", "return CloseDialog();");

        if (editTime)
        {
            btnNow.Text = GetString("Calendar.Now");
        }
        else
        {
            btnNow.Text = GetString("Calendar.Today");
        }

        btnOk.Text = GetString("general.ok");
        btnNA.Text = GetString("general.na");
        btnNA.Attributes.Add("onclick", "CloseWindow(" + ScriptHelper.GetString(controlId) + ", ''); return false;");

        // Set content direction according to current culture (LTR/RTL)
        if (CultureHelper.IsCultureRTL(mCulture))
        {
            tblLayout.Attributes.Remove("dir");
            tblLayout.Attributes.Add("dir", "rtl");
        }
        else
        {
            tblLayout.Attributes.Remove("dir");
            tblLayout.Attributes.Add("dir", "ltr");
        }

        if (!RequestHelper.IsPostBack())
        {
            DateTime now = TimeZoneHelper.GetUserDateTime(CMSContext.CurrentUser);

            // Selected date
            if (selDate == "")
            {
                SetTime(now, true);
            }
            else
            {
                SetTime(ValidationHelper.GetDateTime(selDate, now), true);
            }

            // Allow empty ?
            if (!allowEmpty)
            {
                btnNA.Visible = false;
            }
            else
            {
                btnNA.Visible = true;
            }

            // Edit time ?
            if (editTime)
            {
                pnlTime.Visible = true;
            }
            else
            {
                pnlTime.Visible = false;
            }
        }

        // Display time zone in form 'GMT+1:00'
        int timeZoneId = QueryHelper.GetInteger("timezoneid", 0);

        if (timeZoneId > 0)
        {
            TimeZoneInfo tzi = TimeZoneInfoProvider.GetTimeZoneInfo(timeZoneId);
            if (tzi != null)
            {
                lblGMTShift.Visible = true;
                lblGMTShift.Text    = TimeZoneHelper.GetGMTStringOffset(tzi);
                ScriptHelper.AppendTooltip(lblGMTShift, TimeZoneHelper.GetGMTLongStringOffset(tzi), "help");
            }
        }

        // Next and previous month images
        calDate.NextMonthText = "<img src=\"" + GetImageUrl("Design/Controls/Calendar/next.png") + "\" />";
        calDate.PrevMonthText = "<img src=\"" + GetImageUrl("Design/Controls/Calendar/previous.png") + "\" />";

        RegisterModalPageScripts();
        RegisterEscScript();
    }