/// <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); } }
/// <summary> /// UniGrid external data bound. /// </summary> private object gridDocs_OnExternalDataBound(object sender, string sourceName, object parameter) { sourceName = sourceName.ToLowerCSafe(); 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 = TimeZoneMethods.GetDateTimeForControl(this, ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME), out tzi).ToString(); // Display time zone shift if needed if ((tzi != null) && TimeZoneHelper.TimeZonesEnabled) { if (sourceName.EndsWithCSafe("tooltip")) { result = TimeZoneHelper.GetUTCLongStringOffset(tzi); } else { result += TimeZoneHelper.GetUTCStringOffset(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); }
/// <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); }
/// <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 (String.IsNullOrEmpty(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 or create new one timeZoneObj = TimeZoneInfoProvider.GetTimeZoneInfo(zoneId) ?? new TimeZoneInfo(); } timeZoneObj.TimeZoneName = txtTimeZoneName.Text.Trim(); timeZoneObj.TimeZoneDaylight = chkTimeZoneDaylight.Checked; timeZoneObj.TimeZoneDisplayName = txtTimeZoneDisplayName.Text.Trim(); timeZoneObj.TimeZoneRuleStartRule = startRuleEditor.Rule; timeZoneObj.TimeZoneRuleEndRule = endRuleEditor.Rule; timeZoneObj.TimeZoneGMT = Convert.ToDouble(txtTimeZoneGMT.Text.Trim()); TimeZoneInfoProvider.SetTimeZoneInfo(timeZoneObj); URLHelper.Redirect(UrlResolver.ResolveUrl("TimeZone_Edit.aspx?zoneid=" + Convert.ToString(timeZoneObj.TimeZoneID) + "&saved=1")); } else { ShowError(GetString("TimeZ.Edit.TimeZoneNameExists")); } } else { ShowError(errorMessage); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); // Retrieve customer from the database CustomerInfo customer = CustomerInfo.Provider.Get(FilterCustomerID); // If a valid customer is specified, disable filtering by customer's properties if (customer != null) { CustomerFilterEnabled = false; } // Initialize the control with values All, Yes and No InitializeThreeStateDropDownList(drpOrderIsPaid); // If this control is associated with an UniGrid control, disable UniGrid's buttons and initialize the Reset button UniGrid grid = FilteredControl as UniGrid; if (grid != null) { grid.HideFilterButton = true; // Reset button is available only when UniGrid remembers its state if (grid.RememberState) { btnReset.Text = GetString("general.reset"); btnReset.Click += btnReset_Click; } else { btnReset.Visible = false; } } // Initialize the Show button btnFilter.Text = GetString("general.filter"); btnFilter.Click += btnFilter_Click; // Hide unwanted elements plcAdvancedGroup.Visible = false; plcSimpleFilter.Visible = false; // Use timezones for DateTimePickers TimeZoneInfo timeZone = TimeZoneHelper.GetTimeZoneInfo(MembershipContext.AuthenticatedUser, SiteContext.CurrentSite); dtpFrom.TimeZone = TimeZoneTypeEnum.Custom; dtpFrom.CustomTimeZone = timeZone; dtpCreatedTo.TimeZone = TimeZoneTypeEnum.Custom; dtpCreatedTo.CustomTimeZone = timeZone; }
/// <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; plcDSTInfo.Visible = true; } }
/// <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); }
/// <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"; // 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); }
/// <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"); } }
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 = (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) != AuthorizationResultEnum.Denied); // Show document group owner selector if (ModuleManager.IsModuleLoaded(ModuleName.COMMUNITY) && canEditOwner && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.Groups)) { plcOwnerGroup.Controls.Clear(); // Initialize panel content Panel rowWrapperPanel = new Panel(); rowWrapperPanel.CssClass = "form-group"; Panel lblPanel = new Panel(); lblPanel.CssClass = "editing-form-label-cell"; Panel ctrlPanel = new Panel(); ctrlPanel.CssClass = "editing-form-value-cell"; // Initialize caption LocalizedLabel lblOwnerGroup = new LocalizedLabel(); lblOwnerGroup.EnableViewState = false; lblOwnerGroup.ResourceString = "community.group.documentowner"; lblOwnerGroup.ID = "lblOwnerGroup"; lblOwnerGroup.CssClass = "control-label"; lblPanel.Controls.Add(lblOwnerGroup); // Initialize selector fcDocumentGroupSelector = (FormEngineUserControl)Page.LoadUserControl("~/CMSAdminControls/UI/Selectors/DocumentGroupSelector.ascx"); fcDocumentGroupSelector.ID = "fcDocumentGroupSelector"; fcDocumentGroupSelector.StopProcessing = pnlUIOwner.IsHidden; ctrlPanel.Controls.Add(fcDocumentGroupSelector); fcDocumentGroupSelector.Value = ValidationHelper.GetInteger(Node.GetValue("NodeGroupID"), 0); fcDocumentGroupSelector.SetValue("siteid", SiteContext.CurrentSiteID); fcDocumentGroupSelector.SetValue("nodeid", Node.NodeID); // Add controls to containers rowWrapperPanel.Controls.Add(lblPanel); rowWrapperPanel.Controls.Add(ctrlPanel); plcOwnerGroup.Controls.Add(rowWrapperPanel); 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.GetDataClassInfo(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, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblLastModified, TimeZoneHelper.GetUTCLongStringOffset(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, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblCreated, TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone), "help"); // URL string liveUrl = Node.IsLink ? DocumentURLProvider.GetUrl(Node.NodeAliasPath, null) : DocumentURLProvider.GetUrl(Node.NodeAliasPath, Node.DocumentUrlPath); lnkLiveURL.Text = URLHelper.ResolveUrl(liveUrl, true, false); lnkLiveURL.NavigateUrl = URLHelper.ResolveUrl(liveUrl); string permanentUrl = DocumentURLProvider.GetPermanentDocUrl(Node.NodeGUID, Node.NodeAlias, Node.NodeSiteName, PageInfoProvider.PREFIX_CMS_GETDOC, ".aspx"); lnkPermanentUrl.Text = URLHelper.ResolveUrl(permanentUrl, true, false); lnkPermanentUrl.NavigateUrl = URLHelper.ResolveUrl(permanentUrl); bool isRoot = (Node.NodeClassName.ToLowerCSafe() == "cms.root"); // Preview URL if (!isRoot) { plcPreview.Visible = true; btnResetPreviewGuid.ToolTip = GetString("GeneralProperties.InvalidatePreviewURL"); btnResetPreviewGuid.Click += btnResetPreviewGuid_Click; btnResetPreviewGuid.OnClientClick = "if(!confirm(" + ScriptHelper.GetLocalizedString("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>"); // Load page info for inherited cache settings currentPage = PageInfoProvider.GetPageInfo(Node.DocumentGUID); if (!RequestHelper.IsPostBack()) { // Init radio buttons for cache settings if (isRoot) { radInherit.Visible = false; radFSInherit.Visible = false; chkCssStyle.Visible = false; } else { // Show what is inherited value radInherit.Text = GetString("GeneralProperties.radInherit") + " (" + GetInheritedCacheCaption("NodeCacheMinutes") + ")"; radFSInherit.Text = GetString("GeneralProperties.radInherit") + " (" + GetInheritedCacheCaption("NodeAllowCacheInFileSystem") + ")"; } string cacheMinutes = ""; switch (Node.NodeCacheMinutes) { case -1: // Cache setting is inherited { radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; if (!isRoot) { radInherit.Checked = true; radNo.Checked = false; if ((currentPage != null) && (currentPage.NodeCacheMinutes > 0)) { cacheMinutes = currentPage.NodeCacheMinutes.ToString(); } } } 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) { ctrlSiteSelectStyleSheet.Value = GetDefaultStylesheet(); } 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(SiteContext.CurrentSite.SiteID, Node.NodeAliasPath, "(DocumentStylesheetID <> -1 OR DocumentStylesheetID IS NULL) AND DocumentCulture = N'" + SqlHelper.GetSafeQueryString(Node.DocumentCulture, false) + "'", "DocumentStylesheetID"); if (String.IsNullOrEmpty(value)) { ctrlSiteSelectStyleSheet.Value = GetDefaultStylesheet(); } 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; } }
/// <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> /// Gets iCalendar file content. /// </summary> /// <param name="data">Data container.</param> protected byte[] GetContent(IDataContainer data) { if (data != null) { // Get server time zone TimeZoneInfo serverTimeZone = TimeZoneHelper.ServerTimeZone; // Shift current time (i.e. server time) to GMT DateTime currentDateGMT = DateTime.Now; currentDateGMT = TimeZoneHelper.ConvertTimeToUTC(currentDateGMT, serverTimeZone); // Get event start time (i.e. server time) DateTime eventStart = ValidationHelper.GetDateTime(data.GetValue("EventDate"), DateTimeHelper.ZERO_TIME); // Get if it is all day event bool isAllDay = ValidationHelper.GetBoolean(data.GetValue("EventAllDay"), false); // Get Guid of the event, it's required and must be unique -> throw exception if null var eventGuid = (Guid)data.GetValue("NodeGUID"); // Get current site var currentSite = SiteInfoProvider.GetSiteInfo(CurrentSiteName); // Create content var content = new StringBuilder(); content.AppendLine("BEGIN:VCALENDAR"); content.AppendLine("PRODID:-//Kentico Software//NONSGML Kentico CMS//EN"); content.AppendLine("VERSION:2.0"); content.AppendLine("BEGIN:VEVENT"); content.Append("UID:").Append(eventGuid).Append("@").AppendLine(currentSite.DomainName); 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.ConvertTimeToUTC(eventStart, serverTimeZone); content.Append(":").Append(eventStart.ToString("yyyyMMdd'T'HHmmss")).AppendLine("Z"); } // Get event end time DateTime eventEnd = ValidationHelper.GetDateTime(data.GetValue("EventEndDate"), DateTimeHelper.ZERO_TIME); if (eventEnd != DateTimeHelper.ZERO_TIME) { content.Append("DTEND"); if (isAllDay) { content.Append(";VALUE=DATE:").AppendLine(eventEnd.AddDays(1).ToString("yyyyMMdd")); } else { // Shift event end time to GMT eventEnd = TimeZoneHelper.ConvertTimeToUTC(eventEnd, serverTimeZone); 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); }
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;"); if (!RequestHelper.IsPostBack()) { DateTime now = TimeZoneHelper.GetUserDateTime(MembershipContext.AuthenticatedUser); // 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.GetUTCStringOffset(tzi); ScriptHelper.AppendTooltip(lblGMTShift, TimeZoneHelper.GetUTCLongStringOffset(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(); }
/// <summary> /// Gets iCalendar file content. /// </summary> /// <param name="row">Datarow</param> protected byte[] GetContent(IDataContainer data) { if (data != null) { // Get server time zone TimeZoneInfo serverTimeZone = TimeZoneHelper.ServerTimeZone; // Shift current time (i.e. server time) to GMT DateTime currentDateGMT = DateTime.Now; currentDateGMT = TimeZoneHelper.ConvertTimeToUTC(currentDateGMT, serverTimeZone); // Get event start time (i.e. server time) DateTime eventStart = ValidationHelper.GetDateTime(data.GetValue("EventDate"), DateTimeHelper.ZERO_TIME); // 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.ConvertTimeToUTC(eventStart, serverTimeZone); content.Append(":").Append(eventStart.ToString("yyyyMMdd'T'HHmmss")).AppendLine("Z"); } // Get event end time DateTime eventEnd = ValidationHelper.GetDateTime(data.GetValue("EventEndDate"), DateTimeHelper.ZERO_TIME); if (eventEnd != DateTimeHelper.ZERO_TIME) { content.Append("DTEND"); if (isAllDay) { content.Append(";VALUE=DATE:").AppendLine(eventEnd.AddDays(1).ToString("yyyyMMdd")); } else { // Shift event end time to GMT eventEnd = TimeZoneHelper.ConvertTimeToUTC(eventEnd, serverTimeZone); 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); }
/// <summary> /// On btnRegister click. /// </summary> protected void btnRegister_Click(object sender, EventArgs e) { string currentSiteName = SiteContext.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 == DateTimeHelper.ZERO_TIME || openFrom < now) && (openTo == DateTimeHelper.ZERO_TIME || 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, AnalyticsContext.ActivityEnvironmentVariables); activity.Log(); // Send invitation e-mail TimeZoneInfo tzi = null; TimeZoneMethods.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; } }
protected override void OnInit(EventArgs e) { base.OnInit(e); // Retrieve customer from the database CustomerInfo customer = CustomerInfoProvider.GetCustomerInfo(FilterCustomerID); // If a valid customer is specified, disable filtering by customer's properties if (customer != null) { CustomerFilterEnabled = false; } // If the current user is a global administrator, he or she is allowed to filter by site, otherwise, disable filtering by site if ((MembershipContext.AuthenticatedUser != null) && MembershipContext.AuthenticatedUser.IsGlobalAdministrator) { // If a valid customer is specified and he or she is associated with a CMS user, display only sites that the user can access, otherwise, disable filtering by site if (customer != null) { if (customer.CustomerIsRegistered) { siteSelector.UserId = customer.CustomerUserID; } else { SiteFilterEnabled = false; } } } else { SiteFilterEnabled = false; } // Initialize the control with values All, Yes and No InitializeThreeStateDropDownList(drpOrderIsPaid); // If this control is associated with an UniGrid control, disable UniGrid's buttons and initialize the Reset button UniGrid grid = FilteredControl as UniGrid; if (grid != null) { grid.HideFilterButton = true; // Reset button is available only when UniGrid remembers its state if (grid.RememberState) { btnReset.Text = GetString("general.reset"); btnReset.Click += btnReset_Click; } else { btnReset.Visible = false; } } // Initialize the Show button btnFilter.Text = GetString("general.filter"); btnFilter.Click += btnFilter_Click; // Hide unwanted elements plcAdvancedGroup.Visible = false; plcSimpleFilter.Visible = false; // Initialize site selector siteSelector.UniSelector.OnSelectionChanged += DropDownSingleSelect_SelectedIndexChanged; CurrencySelector.SiteID = statusSelector.SiteID; // Use timezones for DateTimePickers CMS.Globalization.TimeZoneInfo timeZone = TimeZoneHelper.GetTimeZoneInfo(MembershipContext.AuthenticatedUser, SiteContext.CurrentSite); dtpFrom.TimeZone = TimeZoneTypeEnum.Custom; dtpFrom.CustomTimeZone = timeZone; dtpCreatedTo.TimeZone = TimeZoneTypeEnum.Custom; dtpCreatedTo.CustomTimeZone = timeZone; // Preselect current siteID by default when siteSelector is enabled if (!URLHelper.IsPostback()) { siteSelector.SiteID = SiteContext.CurrentSiteID; } }
protected void Page_Load(object sender, EventArgs e) { editGrid.RowDataBound += editGrid_RowDataBound; btnOk.Click += (s, args) => Save(); // Get main currency mMainCurrency = CurrencyInfoProvider.GetMainCurrency(ConfiguredSiteID); rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname"); // Help image iconHelpGlobalExchangeRate.ToolTip = GetString("ExchangeTable_Edit.ExchangeRateHelp"); iconHelpMainExchangeRate.ToolTip = GetString("ExchangeTable_Edit.ExchangeRateHelp"); // Use time zones for DateTimePickers CMS.Globalization.TimeZoneInfo tzi = TimeZoneHelper.GetTimeZoneInfo(MembershipContext.AuthenticatedUser, SiteContext.CurrentSite); dtPickerExchangeTableValidFrom.TimeZone = TimeZoneTypeEnum.Custom; dtPickerExchangeTableValidFrom.CustomTimeZone = tzi; dtPickerExchangeTableValidTo.TimeZone = TimeZoneTypeEnum.Custom; dtPickerExchangeTableValidTo.CustomTimeZone = tzi; // Get exchangeTable id from query string mExchangeTableId = QueryHelper.GetInteger("exchangeid", 0); if (mExchangeTableId > 0) { exchangeTableObj = EditedObject as ExchangeTableInfo; if (exchangeTableObj != null) { // Check tables site id CheckEditedObjectSiteID(exchangeTableObj.ExchangeTableSiteID); LoadData(exchangeTableObj); // Fill editing form if (!RequestHelper.IsPostBack()) { // Show that the exchangeTable was created or updated successfully if (QueryHelper.GetString("saved", "") == "1") { // Show message ShowChangesSaved(); } } } // Init Copy from global link InitCopyFromGlobalLink(); // Check presence of main currency plcGrid.Visible = CheckMainCurrency(ConfiguredSiteID); plcRateFromGlobal.Visible = IsFromGlobalRateNeeded(); } // Creating a new exchange table else { if (!RequestHelper.IsPostBack()) { // Preset valid from date ExchangeTableInfo tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(ConfiguredSiteID); if (tableInfo != null) { dtPickerExchangeTableValidFrom.SelectedDateTime = tableInfo.ExchangeTableValidTo; } } // Grids are visible only in edit mode plcGrid.Visible = false; } // Register bootstrap tooltip over help icons ScriptHelper.RegisterBootstrapTooltip(Page, ".info-icon > i"); }
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 usedTimeZone = TimeZoneHelper.GetTimeZoneInfo(CurrentUser, SiteContext.CurrentSite); 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 (MembershipContext.AuthenticatedUser.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); } } }