/// ----------------------------------------------------------------------------- /// <summary> /// FormatExpiryDate formats the expiry/effective date and filters out nulls /// </summary> /// <history> /// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> /// ----------------------------------------------------------------------------- public string FormatUser(int UserID, string DisplayName) { return("<a href=\"" + Globals.LinkClick("userid=" + UserID, TabId, ModuleId) + "\" class=\"CommandButton\">" + DisplayName + "</a>"); }
void cmdUpdate_Click(object sender, EventArgs e) { if (_hasUpdatePermission) { try { //warning message of validation has failed var warningMessage = string.Empty; warningMessage = _editControls.Values.Where(edit => !edit.IsValid()) .Aggregate(warningMessage, (current, edit) => current + string.Format( "<li><b>{0}</b><br />{1}</li>", edit.FieldTitle, edit.ValidationMessage)); if (CaptchaNeeded() && !_ctlCaptcha.IsValid) { warningMessage += string.Format("<li><b>{0}</b><br />{1}</li>", Localization.GetString("Captcha.Text", LocalResourceFile), Localization.GetString("CaptchaError.Text", LocalResourceFile)); } if (ModuleContext.PortalSettings.UserId == -1 && Settings.ForceCaptchaForAnonymous && Settings.PreferReCaptcha) { string encodedResponse = Request.Form["g-recaptcha-response"]; if (!ReCaptcha.Validate(encodedResponse, Settings.ReCaptchaSecretKey)) { warningMessage += string.Format("<li><b>{0}</b><br />{1}</li>", Localization.GetString("ReCaptcha.Text", LocalResourceFile), Localization.GetString("ReCaptchaError.Text", LocalResourceFile)); } } if (warningMessage == string.Empty) { //'Save values for every field separately foreach (var edit in _editControls.Values) { var value = edit.Value; CurrentRow[edit.FieldTitle] = value; } UdtController.UpdateRow(Data); RecordUpdated(); switch (Settings.ListOrForm) { case "List": Response.Redirect(Globals.NavigateURL(ModuleContext.TabId), true); break; case "FormAndList": case "ListAndForm": var url = IsNewRow ? Request.RawUrl : Globals.NavigateURL(ModuleContext.TabId); Response.Redirect(url, true); break; case "Form": switch (Settings.UponSubmitAction) { case "Text": divForm.Visible = false; ShowUponSubmit(); break; case "Form": Response.Redirect( Globals.NavigateURL(ModuleContext.TabId, "", string.Format("OnSubmit={0}", ModuleId)), true); break; default: var strRedirectUrl = Settings.UponSubmitRedirect ?? Globals.NavigateURL(ModuleContext.TabId); Response.Redirect(Globals.LinkClick(strRedirectUrl, ModuleContext.TabId, ModuleContext.ModuleId)); break; } break; } } else { var moduleControl = (PortalModuleBase)(((Parent.Parent) is PortalModuleBase) ? Parent.Parent : this); UI.Skins.Skin.AddModuleMessage(moduleControl, string.Format("<ul style=\"padding-left:1.6em;padding-bottom:0;\">{0}</ul>", warningMessage), ModuleMessage.ModuleMessageType.RedError); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } if (ModuleId == HrDbData.ListOfHrsModuleId) { UpdateActiveHRsInVacancies(); UpdateActiveHRsInCamps(); } } }
/// <summary> /// Gets the plain URL version of a link. /// </summary> /// <param name="link">The link to convert into a URL.</param> /// <returns>A URL pointing to the <paramref name="link"/> without LinkClick tracking</returns> protected string GetPlainUrl(string link) { return(Globals.LinkClick(link, this.TabId, this.ModuleId, false, false)); }
void FillTypeColumns(int moduleId, TokenReplace objTokenReplace, PortalSettings portalSettings, TabController tabCtrl, DataRow row, FieldSetting field) { var link = row[field.Title].ToString(); //Link showed to the user bool openInNewWindow; if (field.ShowOpenInNewWindow) //mit URL gepeicherten Wert lesen { openInNewWindow = UrlUtil.OpenUrlInNewWindow(link); } else { switch (Globals.GetURLType(UrlUtil.StripURL(link))) { case TabType.File: openInNewWindow = true; break; case TabType.Tab: //link to internal tab openInNewWindow = false; break; default: openInNewWindow = link.Like(Globals.ApplicationMapPath + "*"); break; } } //set caption: var caption = field.OutputFormat; if (!string.IsNullOrEmpty(caption)) { caption = objTokenReplace.ReplaceEnvironmentTokens(caption, row); } var isLink = true; //Link readable by browsers link = UrlUtil.StripURL(link); var url = Globals.LinkClick(link, portalSettings.ActiveTab.TabID, moduleId, field.TrackDownloads, field.EnforceDownload); if (link != string.Empty) { switch (Globals.GetURLType(link)) { case TabType.Tab: var tab = tabCtrl.GetTab(int.Parse(link), portalSettings.PortalId, false); if (tab != null) { if (caption == string.Empty) { if (!field.Abbreviate) { var strPath = string.Empty; if (tab.BreadCrumbs != null && tab.BreadCrumbs.Count > 0) { foreach (TabInfo b in tab.BreadCrumbs) { var strLabel = b.TabName; if (strPath != string.Empty) { strPath += string.Format( "<img src=\"{0}/images/breadcrumb.gif\" border=\"0\" alt=\"Spacer\"/>", Globals.ApplicationPath); } strPath += strLabel; } } caption = tab.TabPath.Replace("//", string.Format( "<img src=\"{0}/images/breadcrumb.gif\" border=\"0\" alt=\"Spacer\"/>", Globals.ApplicationPath)); } else { caption = tab.TabName; } } url = field.EnforceDownload ? url : Globals.NavigateURL(int.Parse(link)); } else { caption = Localization.GetString("PageNotFound.ErrorMessage", Globals.ResolveUrl( string.Format("~{0}{1}/SharedResources.resx", Definition.PathOfModule, Localization.LocalResourceDirectory))); url = string.Empty; isLink = false; } break; case TabType.File: if (caption == string.Empty) { if (link.ToLowerInvariant().StartsWith("fileid=")) { var file = FileManager.Instance.GetFile(int.Parse(link.Substring(7))); if (file != null) { if (!field.Abbreviate) { caption = file.Folder + file.FileName; } else { caption = file.FileName; } } } else if (field.Abbreviate && link.IndexOf("/", StringComparison.Ordinal) > -1) { caption = link.Substring(Convert.ToInt32(link.LastIndexOf("/", StringComparison.Ordinal) + 1)); } else { caption = link; } } break; case TabType.Url: case TabType.Normal: if (caption == string.Empty) { if (field.Abbreviate && link.IndexOf("/", StringComparison.Ordinal) > -1) { caption = link.Substring(Convert.ToInt32(link.LastIndexOf("/", StringComparison.Ordinal) + 1)); } else { caption = link; } } if (!field.TrackDownloads) { url = link; } break; } if (field.EnforceDownload) { url += "&forcedownload=true"; } string strFieldvalue; if (isLink) { strFieldvalue = string.Format("<!--{1}--><a href=\"{0}\"{2}>{1}</a>", url, caption, (openInNewWindow ? " target=\"_blank\"" : "")); } else { strFieldvalue = caption; } row[field.Title] = strFieldvalue; row[field.Title + DataTableColumn.Appendix_Caption] = caption; row[field.Title + DataTableColumn.Appendix_Original] = link; row[field.Title + DataTableColumn.Appendix_Url] = url; } }
public override void RenderValuesToHtmlInsideDataSet(DataSet ds, int moduleId, bool noScript) { if (ds != null) { var fields = new ArrayList(); //List of columns that contains URLs var tableData = ds.Tables[DataSetTableName.Data]; var tokenReplace = new TokenReplace { ModuleId = moduleId }; foreach (DataRow row in ds.Tables[DataSetTableName.Fields].Rows) { if (row[FieldsTableColumn.Type].ToString() == Name) { var fieldId = (int)row[FieldsTableColumn.Id]; var field = new FieldSettings { Title = row[FieldsTableColumn.Title].ToString(), OutputFormat = row[FieldsTableColumn.OutputSettings].AsString(), Abbreviate = GetFieldSetting("Abbreviate", fieldId, ds).AsBoolean(), ShowOpenInNewWindow = GetFieldSetting("ShowOpenInNewWindow", fieldId, ds).AsBoolean(), EnforceDownload = GetFieldSetting("EnforceDownload", fieldId, ds).AsBoolean() }; fields.Add(field); tableData.Columns.Add(new DataColumn(field.Title + DataTableColumn.Appendix_Url, typeof(string))); tableData.Columns.Add(new DataColumn(field.Title + DataTableColumn.Appendix_Caption, typeof(string))); tableData.Columns.Add(new DataColumn(field.Title + DataTableColumn.Appendix_Original, typeof(string))); } } if (fields.Count > 0) { var portalSettings = PortalController.GetCurrentPortalSettings(); foreach (DataRow row in tableData.Rows) { foreach (FieldSettings field in fields) { var strFieldvalue = string.Empty; var strFileId = row[field.Title].ToString(); var openInNewWindow = !field.ShowOpenInNewWindow || UrlUtil.OpenUrlInNewWindow(strFileId); strFileId = UrlUtil.StripURL(strFileId); var strUrl = ""; //Link readable by browsers var strCaption = string.Empty; if (strFileId != string.Empty) { strUrl = HttpUtility.HtmlEncode(Globals.LinkClick(strFileId, portalSettings.ActiveTab.TabID, moduleId)); var fName = ""; var strDisplayName = ""; if (strFileId.Like("FileID=*")) { var f = FileManager.Instance.GetFile(int.Parse(UrlUtils.GetParameterValue(strFileId))); if (f != null) { fName = f.FileName; if (field.Abbreviate) { strDisplayName = (f.Folder + fName); } else { strDisplayName = fName; } } } else { fName = Globals.ResolveUrl(strUrl); strDisplayName = field.Abbreviate ? fName.Substring(Convert.ToInt32(fName.LastIndexOf("/", StringComparison.Ordinal) + 1)) : fName; } strCaption = field.OutputFormat; strCaption = string.IsNullOrEmpty(strCaption) ? fName : tokenReplace.ReplaceEnvironmentTokens(strCaption, row); if (field.EnforceDownload) { strUrl += "&forcedownload=true"; } strFieldvalue = string.Format("<!--{0}--><a href=\"{1}\" {2}>{3}</a>", strDisplayName, strUrl, (openInNewWindow ? " target=\"_blank\"" : ""), strCaption); } row[field.Title] = strFieldvalue; row[field.Title + DataTableColumn.Appendix_Caption] = strCaption; row[field.Title + DataTableColumn.Appendix_Original] = strFileId; row[field.Title + DataTableColumn.Appendix_Url] = strUrl; } } } } }
public override void RenderValuesToHtmlInsideDataSet(DataSet ds, int moduleId, bool noScript) { if (ds != null) { var fields = new ArrayList(); var tableData = ds.Tables[DataSetTableName.Data]; var tokenReplace = new TokenReplace { ModuleId = moduleId }; foreach (DataRow row in ds.Tables[DataSetTableName.Fields].Rows) { if (row[FieldsTableColumn.Type].ToString() == Name) { var fieldId = (int)row[FieldsTableColumn.Id]; var field = new FieldSetting { Title = row[FieldsTableColumn.Title].ToString(), TokenText = GetFieldSetting("TokenText", fieldId, ds).AsString(), ShowUserName = GetFieldSetting("ShowUserName", fieldId, ds).AsBoolean(), OpenInNewWindow = GetFieldSetting("OpenInNewWindow", fieldId, ds).AsBoolean() }; fields.Add(field); tableData.Columns.Add(new DataColumn(field.Title + DataTableColumn.Appendix_Url, typeof(string))); tableData.Columns.Add(new DataColumn(field.Title + DataTableColumn.Appendix_Original, typeof(string))); tableData.Columns.Add(new DataColumn(field.Title + DataTableColumn.Appendix_Caption, typeof(string))); } } if (fields.Count > 0) { PortalSettings portalSettings = null; if (HttpContext.Current != null) { portalSettings = PortalController.GetCurrentPortalSettings(); } var mc = new ModuleController(); var settings = mc.GetModuleSettings(moduleId); foreach (DataRow row in tableData.Rows) { foreach (FieldSetting field in fields) { var strFieldvalue = string.Empty; //Link showed to the user var link = row[field.Title].ToString(); //set caption: var caption = field.TokenText; var url = string.Empty; //Link readable by browsers link = UrlUtil.StripURL(link); if (link != string.Empty) //valid link { //var isLink = true; var intUser = Convert.ToInt32(-1); if (link.Like("userid=*") && portalSettings != null) { try { intUser = int.Parse(link.Substring(7)); tokenReplace.User = new UserController().GetUser(portalSettings.PortalId, intUser); } catch { } } if (intUser == -1) { tokenReplace.User = new UserInfo { Username = "******" }; } if (caption == string.Empty) { caption = field.ShowUserName ? "[User:DisplayName]" : "[User:UserName]"; } caption = tokenReplace.ReplaceEnvironmentTokens(caption, row); if (caption == string.Empty) //DisplayName empty { caption = tokenReplace.ReplaceEnvironmentTokens("[User:username]"); } url = HttpUtility.HtmlEncode(Globals.LinkClick(link, portalSettings.ActiveTab.TabID, moduleId)); strFieldvalue = string.Format("<!--{1}--><a href=\"{0}\"{2}>{1}</a>", url, caption, (field.OpenInNewWindow ? " target=\"_blank\"" : "")); } row[field.Title] = strFieldvalue; row[field.Title + DataTableColumn.Appendix_Original] = link; row[field.Title + DataTableColumn.Appendix_Url] = url; row[field.Title + DataTableColumn.Appendix_Caption] = caption; } } } } }
public override void RenderValuesToHtmlInsideDataSet(DataSet ds, int moduleId, bool noScript) { var colCreatedBy = new ArrayList(); var tableData = ds.Tables[DataSetTableName.Data]; var asLink = false; var openInNewWindow = false; var preferDisplayName = false; foreach (DataRow row in ds.Tables[DataSetTableName.Fields].Rows) { if (row[FieldsTableColumn.Type].ToString() == Name) { var fieldId = (int)row[FieldsTableColumn.Id]; asLink = GetFieldSetting("AsLink", fieldId, ds).AsBoolean( ); openInNewWindow = GetFieldSetting("OpenInNewWindow", fieldId, ds).AsBoolean(); preferDisplayName = GetFieldSetting("PreferDisplayName", fieldId, ds).AsBoolean(); var title = row[FieldsTableColumn.Title].ToString(); colCreatedBy.Add(title); tableData.Columns.Add(new DataColumn(title + DataTableColumn.Appendix_Original, typeof(string))); tableData.Columns.Add(new DataColumn(title + DataTableColumn.Appendix_Caption, typeof(string))); tableData.Columns.Add(new DataColumn(title + DataTableColumn.Appendix_Url, typeof(string))); } } if (colCreatedBy.Count > 0) { var portalId = Null.NullInteger; var tabId = Null.NullInteger; if (HttpContext.Current != null) { var portalSettings = PortalController.Instance.GetCurrentPortalSettings(); portalId = portalSettings.PortalId; tabId = portalSettings.ActiveTab.TabID; } foreach (DataRow row in tableData.Rows) { foreach (string fieldName in colCreatedBy) { var strCreatedBy = row[fieldName].ToString(); var strCaption = strCreatedBy; var strUrl = string.Empty; if (!preferDisplayName) { strCaption = ModuleSecurity.BestUserName(strCreatedBy, portalId); } if (asLink) { var userId = ModuleSecurity.UserId(strCreatedBy, portalId); if (userId > 0) { strUrl = HttpUtility.HtmlEncode(Globals.LinkClick(("userid=" + userId), tabId, moduleId)); } } string strFieldvalue; if (asLink && strUrl != string.Empty) { strFieldvalue = string.Format("<!--{1}--><a href=\"{0}\"{2}>{1}</a>", strUrl, strCaption, (openInNewWindow ? " target=\"_blank\"" : "")); } else { strFieldvalue = strCaption; } row[fieldName] = strFieldvalue; row[fieldName + DataTableColumn.Appendix_Original] = strCreatedBy; row[fieldName + DataTableColumn.Appendix_Caption] = strCaption; if (strUrl != string.Empty) { row[fieldName + DataTableColumn.Appendix_Url] = strUrl; } } } } }
/// <summary> /// The Page_Load server event handler on this page is used to populate the role information for the page /// </summary> protected void Page_Load(object sender, EventArgs e) { try { //this needs to execute always to the client script code is registred in InvokePopupCal cmdStartCalendar.NavigateUrl = Calendar.InvokePopupCal(txtStartDate); cmdEndCalendar.NavigateUrl = Calendar.InvokePopupCal(txtEndDate); if (!Page.IsPostBack) { if (!String.IsNullOrEmpty(_URL)) { lblLogURL.Text = URL; // saved for loading Log grid TabType URLType = Globals.GetURLType(_URL); if (URLType == TabType.File && _URL.ToLower().StartsWith("fileid=") == false) { // to handle legacy scenarios before the introduction of the FileServerHandler FileController objFiles = new FileController(); lblLogURL.Text = "FileID=" + objFiles.ConvertFilePathToFileId(_URL, PortalSettings.PortalId); } UrlController objUrls = new UrlController(); UrlTrackingInfo objUrlTracking = objUrls.GetUrlTracking(PortalSettings.PortalId, lblLogURL.Text, ModuleID); if (objUrlTracking != null) { if (_FormattedURL == "") { if (!URL.StartsWith("http") && !URL.StartsWith("mailto")) { lblURL.Text = Globals.AddHTTP(Request.Url.Host); } lblURL.Text += Globals.LinkClick(URL, PortalSettings.ActiveTab.TabID, ModuleID, false); } else { lblURL.Text = _FormattedURL; } lblCreatedDate.Text = objUrlTracking.CreatedDate.ToString(); if (objUrlTracking.TrackClicks) { pnlTrack.Visible = true; if (_TrackingURL == "") { if (!URL.StartsWith("http")) { lblTrackingURL.Text = Globals.AddHTTP(Request.Url.Host); } lblTrackingURL.Text += Globals.LinkClick(URL, PortalSettings.ActiveTab.TabID, ModuleID, objUrlTracking.TrackClicks); } else { lblTrackingURL.Text = _TrackingURL; } lblClicks.Text = objUrlTracking.Clicks.ToString(); if (!Null.IsNull(objUrlTracking.LastClick)) { lblLastClick.Text = objUrlTracking.LastClick.ToString(); } } if (objUrlTracking.LogActivity) { pnlLog.Visible = true; txtStartDate.Text = DateAndTime.DateAdd(DateInterval.Day, -6, DateTime.Today).ToShortDateString(); txtEndDate.Text = DateAndTime.DateAdd(DateInterval.Day, 1, DateTime.Today).ToShortDateString(); } } } else { this.Visible = false; } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }