/// <summary> /// On init /// </summary> /// <param name="e"></param> override protected void OnInit(EventArgs e) { //Controls must be created here updateButton = new Esperantus.WebControls.LinkButton(); updateButton.CssClass = "CommandButton"; PlaceHolderButtons.Controls.Add(updateButton); PlaceHolderButtons.Controls.Add(new LiteralControl(" ")); saveAndCloseButton = new Esperantus.WebControls.LinkButton(); saveAndCloseButton.TextKey = "SAVE_AND_CLOSE"; saveAndCloseButton.Text = "Save and close"; saveAndCloseButton.CssClass = "CommandButton"; PlaceHolderButtons.Controls.Add(saveAndCloseButton); this.saveAndCloseButton.Click += new System.EventHandler(this.saveAndCloseButton_Click); // Removed by Mario Endara <*****@*****.**> (2004/11/04) // if (Rainbow.Security.PortalSecurity.IsInRoles("Admins")) // { adminPropertiesButton = new Esperantus.WebControls.HyperLink(); adminPropertiesButton.TextKey = "MODULESETTINGS_BASE_SETTINGS"; adminPropertiesButton.Text = "Edit base settings"; adminPropertiesButton.CssClass = "CommandButton"; adminPropertiesButton.NavigateUrl = HttpUrlBuilder.BuildUrl("~/DesktopModules/Admin/ModuleSettings.aspx", TabID, ModuleID); PlaceHolderButtons.Controls.Add(new LiteralControl(" ")); PlaceHolderButtons.Controls.Add(adminPropertiesButton); // } PlaceHolderButtons.Controls.Add(new LiteralControl(" ")); cancelButton = new Esperantus.WebControls.LinkButton(); cancelButton.CssClass = "CommandButton"; PlaceHolderButtons.Controls.Add(cancelButton); InitializeComponent(); base.OnInit(e); }
/// <summary> /// Add a Menu Tree Node if user in in the list of Authorized roles. /// Thanks to abain for fixing authorization bug. /// </summary> /// <param name="tabIndex"> /// Index of the tab /// </param> /// <param name="mytab"> /// Tab to add to the MenuTreeNodes collection /// </param> protected override void AddMenuTreeNode(int tabIndex, PageStripDetails mytab) { if (!PortalSecurity.IsInRoles(mytab.AuthorizedRoles)) { return; } // get index and id from this page and transmit them // Obtain PortalSettings from Current Context var PortalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; var tabIdItemsRoot = PortalSettings.ActivePage.PageID; var mn = new MenuTreeNode(mytab.PageName) { // change the link to stay on the same page and call a category product Link = HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, tabIdItemsRoot, "ItemID=" + mytab.PageID), Width = this.Width }; // fixed by manu mn = this.RecourseMenu(tabIdItemsRoot, mytab.Pages, mn); this.Childs.Add(mn); }
/// <summary> /// Gives the me URL. /// </summary> /// <param name="tab"> /// The tab. /// </param> /// <param name="id"> /// The id. /// </param> /// <returns> /// The give me url. /// </returns> private string giveMeUrl(string tab, int id) { if (!this.UseTabNameInUrl) { return(HttpUrlBuilder.BuildUrl(id)); } var auxtab = string.Empty; foreach (var c in tab) { if (char.IsLetterOrDigit(c)) { auxtab += c; } else { auxtab += "_"; } } return(HttpUrlBuilder.BuildUrl("~/" + auxtab + ".aspx", id)); }
/// <summary> /// Recourses the menu shop. /// </summary> /// <param name="tabIndex">Index of the tab.</param> /// <param name="t">The t.</param> /// <param name="mn">The mn.</param> /// <param name="idShop">The id shop.</param> /// <returns></returns> protected virtual MenuTreeNode RecourseMenuShop(int tabIndex, PagesBox t, MenuTreeNode mn, int idShop) { if (t.Count > 0) { for (int c = 0; c < t.Count; c++) { PageStripDetails mySubTab = t[c]; if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles)) { MenuTreeNode mnc = new MenuTreeNode(mySubTab.PageName); mnc.Link = HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, idShop, "ItemID=" + mySubTab.PageID.ToString()); mnc.Width = mn.Width; mnc = RecourseMenuShop(tabIndex, mySubTab.Pages, mnc, idShop); mn.Childs.Add(mnc); } } } return(mn); }
/// <summary> /// Gets the link URL. /// </summary> /// <param name="itemID">The item ID.</param> /// <param name="url">The URL.</param> /// <param name="editionMode">if set to <c>true</c> [edition mode].</param> /// <returns></returns> private string GetLinkUrl(object itemID, object url, bool editionMode) { if (editionMode) { if (IsEditable) { return (HttpUrlBuilder.BuildUrl("~/DesktopModules/CommunityModules/EnhancedLinks/EnhancedLinksEdit.aspx", "ItemID=" + itemID.ToString() + "&mID=" + ModuleID.ToString())); } else { return(string.Empty); } } else { string linkStr = url.ToString(); if (linkStr.IndexOf("://") < 0) { if (IsNumeric(linkStr)) { return(HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx?tabid=" + linkStr)); } else { if (linkStr.IndexOf("~/") < 0) { linkStr = "~/" + linkStr; } return(HttpUrlBuilder.BuildUrl(linkStr)); } } return(linkStr); } }
/// <summary> /// modified to transmit the PageID and TabIndex for the item page /// </summary> /// <param name="tabIDItemsRoot">The tab ID items root.</param> /// <param name="t">The t.</param> /// <param name="mn">The mn.</param> /// <returns></returns> protected override MenuTreeNode RecourseMenu(int tabIDItemsRoot, PagesBox t, MenuTreeNode mn) { if (t.Count > 0) { for (int c = 0; c < t.Count; c++) { PageStripDetails mySubTab = (PageStripDetails)t[c]; if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles)) { MenuTreeNode mnc = new MenuTreeNode(mySubTab.PageName); // change PageID into ItemID for the product module on the same page mnc.Link = HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx", tabIDItemsRoot, "ItemID=" + mySubTab.PageID); //by manu mnc.Width = mn.Width; mnc = RecourseMenu(tabIDItemsRoot, mySubTab.Pages, mnc); mn.Childs.Add(mnc); } } } return(mn); }
/// <summary> /// Handles the ItemDataBound event of the RolesList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.Web.UI.WebControls.DataListItemEventArgs"/> instance containing the event data.</param> protected void RolesList_ItemDataBound(object sender, DataListItemEventArgs e) { // 20/7/2004 changed by Mario Endara [email protected] // don't let the user to edit or delete the role "Admins" // the rolename is an hyperlink to the list of users of the role Control dl = e.Item.FindControl("ImageButton1"); Control d2 = e.Item.FindControl("ImageButton2"); HyperLink d3 = (HyperLink)e.Item.FindControl("Name"); AppleseedRole role = ((AppleseedRole)e.Item.DataItem); // Added by Mario Endara <*****@*****.**> 2004/11/04 // if the user is not member of the "Admins" role, he can´t access to the members of the Admins role // added mID by Mario Endara <*****@*****.**> to support security check (2004/11/27) if ((d3 != null) && (PortalSecurity.IsInRoles("Admins") == true || role.Name != "Admins")) { d3.NavigateUrl = HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Roles/SecurityRoles.aspx", PageID, "mID=" + ModuleID + "&roleID=" + role.Id.ToString()); } if (dl != null) { if (role.Name.Equals("Admins")) { dl.Visible = false; } ((ImageButton)dl).Attributes.Add("OnClick", "return confirmDelete()"); } if (d2 != null) { if (role.Name.Equals("Admins")) { d2.Visible = false; } } }
public static async Task RevokeAccessTokenAsync(Configuration config, MASDevice device, MASUser user) { var url = config.GetEndpointPath(config.OAuth.SystemEndpoints.TokenRevocation); var accessToken = await user.GetAccessTokenAsync(); HttpUrlBuilder builder = new HttpUrlBuilder(url); builder.Add("token", accessToken); builder.Add("token_type_hint", "access_token"); var headers = new Dictionary <string, string> { { HttpHeaders.Authorization, device.AuthHeaderValue }, { HttpHeaders.Accept, HttpContentTypes.Json } }; await HttpRequestFactory.RequestAsync <HttpResponseBaseData>(new HttpRequestInfo() { Method = HttpMethod.DELETE, Headers = headers, Url = builder.ToString(), }); }
protected string FormatUrlShowThread(int itemID) { return(HttpUrlBuilder.BuildUrl("~/DesktopModules/Discussion/DiscussionViewThread.aspx", "ItemID=" + itemID + "&mID=" + ModuleID)); }
/// <summary> /// The Page_Load server event handler on this page is used /// to populate the role information for the page. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Page_Load(object sender, System.EventArgs e) { // Verify that the current user has access to access this page // Removed by Mario Endara <*****@*****.**> (2004/11/04) // if (PortalSecurity.IsInRoles("Admins") == false) // PortalSecurity.AccessDeniedEdit(); //Code no longer needed here, gman3001 10/06/2004 /*string RegisterPage; * * //Select the actual register page * if (portalSettings.CustomSettings["SITESETTINGS_REGISTER_TYPE"] != null && * portalSettings.CustomSettings["SITESETTINGS_REGISTER_TYPE"].ToString() != "register.aspx" ) * RegisterPage = portalSettings.CustomSettings["SITESETTINGS_REGISTER_TYPE"].ToString(); * else * RegisterPage = "register.aspx"; */ // Calculate userid if (Request.Params["userid"] != null) { userID = Int32.Parse(Request.Params["userid"]); } if (Request.Params["username"] != null) { userName = (string)Request.Params["username"]; } //Control myControl = this.LoadControl("../DesktopModules/Register/" + RegisterPage); //Control myControl = this.LoadControl(Rainbow.Settings.Path.WebPathCombine(Rainbow.Settings.Path.ApplicationRoot, "DesktopModules/Register", RegisterPage)); // Line Added by gman3001 10/06/2004, to support proper loading of a register module specified by 'Register Module ID' setting in the Portal Settings admin page Control myControl = GetCurrentProfileControl(); EditControl = ((IEditUserProfile)myControl); //EditControl.RedirectPage = HttpUrlBuilder.BuildUrl("~/Admin/UsersManage.aspx", TabID, "username="******"New User created " + DateTime.Now.ToString(); userName = "******" + i.ToString() + "@yoursite.com"; try { uid = users.AddUser(friendlyName, userName, string.Empty, portalSettings.PortalID); } catch (Exception ex) { uid = -1; lastException = ex; } i++; } if (uid == -1) { throw new Exception("New user creation failed after " + i.ToString() + " retries.", lastException); } // redirect to this page with the corrected querystring args Response.Redirect(HttpUrlBuilder.BuildUrl("~/DesktopModules/Users/UsersManage.aspx", TabID, "mID=" + ModuleID + "&userID=" + uid + "&username="******"Error creating new user", ex); ErrorLabel.Text = ex.Message; ErrorLabel.Visible = true; } } BindData(); } }
/// <summary> /// The FormatUrl method is a helper messages called by a /// databinding statement within the <asp:DataList> server /// control template. It is defined as a helper method here /// (as opposed to inline within the template) to improve /// code organization and avoid embedding logic within the /// content template.</summary> /// <param name="itemID">ID of the currently selected topic</param> /// <param name="mode"></param> /// <returns>Returns a properly formatted URL to call the DiscussionEdit page</returns> protected string FormatUrlEditItem(int itemID, string mode) { return(HttpUrlBuilder.BuildUrl("~/DesktopModules/Discussion/DiscussionEdit.aspx", "ItemID=" + itemID + "&Mode=" + mode + "&mID=" + ModuleID + "&edit=1")); }
/// <summary> /// Estableces the parametros. /// </summary> /// <remarks> /// </remarks> private void EstableceParametros() { HttpCookie cookie1; DateTime time1; var moduleInUrl = false; if (this.Page.Request.Params["mID"] != null) { moduleInUrl = int.Parse(this.Page.Request.Params["mID"]) == this.ModuleID; } this.currentMenuSeparator = "<span class='EnhancedHTMLSeparator'> | </span>"; this.currentUrl = HttpUrlBuilder.BuildUrl(this.Page.Request.Path, this.PageID, this.ModuleID); this.currentUrl = this.currentUrl.Replace("//", "/"); if (moduleInUrl) { if (this.Page.Request.Params["EhPageID"] != null) { this.ehPageId = this.Page.Request.Params["EhPageID"]; } else if (this.Page.Request.Params["ItemID"] != null) { this.ehPageId = this.Page.Request.Params["ItemID"]; } } this.currentModeUrl = this.currentUrl; string moduleCookie = "EnhancedHtml:" + this.ModuleID; this.modeId = "0"; if (this.Page.Request.Params["ModeID"] != null) { this.modeId = this.Page.Request.Params["ModeID"]; cookie1 = new HttpCookie(moduleCookie) { Value = this.modeId }; time1 = DateTime.Now; TimeSpan span1 = new TimeSpan(90, 0, 0, 0); cookie1.Expires = time1.Add(span1); base.Response.AppendCookie(cookie1); } else { if (base.Request.Cookies[moduleCookie] != null) { this.modeId = this.Request.Cookies[moduleCookie].Value; } } int num1 = this.currentModeUrl.IndexOf("ModeID="); if (num1 > 0) { this.currentModeUrl = this.currentModeUrl.Substring(0, num1 - 1); this.currentUrl = this.currentModeUrl; } num1 = this.currentUrl.IndexOf("EhPageID="); if (num1 > 0) { this.currentUrl = this.currentUrl.Substring(0, num1 - 1); } if (this.modeId == null) { this.modeId = "0"; } }
protected void cmdManage_Click(object sender, EventArgs e) { Response.Redirect(HttpUrlBuilder.BuildUrl("~/DesktopModules/UserDefinedTable/UserDefinedTableManage.aspx", TabID, "&mID=" + ModuleIDsrc() + "&def=Manage UDT")); }
public JsonResult ViewPage(int pageId) { var url = HttpUrlBuilder.BuildUrl(pageId); return(Json(url)); }
/// <summary> /// Single point logoff /// </summary> /// <remarks> /// </remarks> public static void SignOut() { SignOut(HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage), true); }
/// <summary> /// The RolesList_ItemCommand server event handler on this page /// is used to handle the user editing and deleting roles /// from the RolesList asp:datalist control /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.Web.UI.WebControls.DataListCommandEventArgs"/> instance containing the event data.</param> protected void rolesList_ItemCommand(object source, DataListCommandEventArgs e) { //http://sourceforge.net/tracker/index.php?func=detail&aid=828580&group_id=66837&atid=515929 UsersDB users = new UsersDB(); bool enable = true; // enable add - bja if (e.CommandName == "edit") { // Set editable list item index if "edit" button clicked next to the item rolesList.EditItemIndex = e.Item.ItemIndex; // disable the add function enable = false; // Repopulate the datalist control BindData(); } else if (e.CommandName == "apply") { var _roleName = ((TextBox)e.Item.FindControl("roleName")).Text; var _roleId = ((System.Web.UI.WebControls.Label)e.Item.FindControl("roleId")).Text; // update database users.UpdateRole(new Guid(_roleId), _roleName, this.PortalSettings.PortalAlias); // Disable editable list item access rolesList.EditItemIndex = -1; // Repopulate the datalist control BindData(); } else if (e.CommandName == "delete") { // [email protected]: 30th May 2004: Added Try And Catch To Delete Role // update database try { users.DeleteRole(new Guid(e.CommandArgument.ToString()), this.PortalSettings.PortalAlias); } catch { labelError.Visible = true; } // End of [email protected] Update // Ensure that item is not editable rolesList.EditItemIndex = -1; // Repopulate list BindData(); } else if (e.CommandName == "members") { string _roleId = ((System.Web.UI.WebControls.Label)e.Item.FindControl("roleId")).Text; // Role names shouldn't be editable, it's not supported by the Roles Provider API //// Save role name changes first //users.UpdateRole( selectedRole.Id, _roleName, portalSettings.PortalAlias ); // redirect to edit page Response.Redirect( HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Roles/SecurityRoles.aspx", PageID, "mID=" + ModuleID.ToString() + "&roleID=" + _roleId)); } // reset the enable state of the add // set add button -- bja AddRoleBtn.Enabled = enable; }
public JsonResult sendPasswordToken(string email) { Membership.ApplicationName = this.PortalSettings.PortalAlias; var membership = (AppleseedMembershipProvider)Membership.Provider; // Obtain single row of User information var memberUser = membership.GetUser(email, false); var message = string.Empty; if (memberUser == null) { message = General.GetString( "SIGNIN_PWD_MISSING_IN_DB", "The email you specified does not exists on our database", this); return(Json(new { ok = false, Message = message })); //throw new Exception(message); } var userId = (Guid)(memberUser.ProviderUserKey ?? Guid.Empty); // generate Token for user var token = membership.CreateResetPasswordToken(userId); String uri = HttpUrlBuilder.BuildUrl("~/Password/PasswordRecovery"); var changePasswordUrl = string.Concat(Request.Url.Host, uri, "?usr="******"N"), "&tok=", token.ToString("N")); var mail = new MailMessage(); // we check the PortalSettings in order to get if it has an sender registered if (this.PortalSettings.CustomSettings["SITESETTINGS_ON_REGISTER_SEND_FROM"] != null) { var sf = this.PortalSettings.CustomSettings["SITESETTINGS_ON_REGISTER_SEND_FROM"]; var mailFrom = sf.ToString(); try { mail.From = new MailAddress(mailFrom); } catch { // if the address is not well formed, a warning is logged. LogHelper.Logger.Log( LogLevel.Warn, string.Format( @"This is the current email address used as sender when someone want to retrieve his/her password: '******'. Is not well formed. Check the setting SITESETTINGS_ON_REGISTER_SEND_FROM of portal '{1}' in order to change this value (it's a portal setting).", mailFrom, this.PortalSettings.PortalAlias)); } } // if there is not a correct email in the portalSettings, we use the default sender specified on the web.config file in the mailSettings tag. mail.To.Add(new MailAddress(email)); mail.Subject = string.Format( "{0} - {1}", this.PortalSettings.PortalName, General.GetString("SIGNIN_PWD_LOST", "I lost my password", this)); var viewToSend = EmailSubject(memberUser.UserName, changePasswordUrl, this.PortalSettings.PortalName) as ViewResult; StringResult sr = new StringResult(); sr.ViewName = viewToSend.ViewName; sr.MasterName = viewToSend.MasterName; sr.ViewData = viewToSend.ViewData; sr.TempData = viewToSend.TempData; sr.ExecuteResult(this.ControllerContext); string emailHtml = sr.Html; mail.Body = emailHtml; mail.IsBodyHtml = false; using (var client = new SmtpClient()) { try { client.Send(mail); message = General.GetString( "SIGNIN_PWD_WAS_SENT", "Your password was sent to the address you provided", this); //this.Message.TextKey = "SIGNIN_PWD_WAS_SENT"; return(Json(new { ok = true, Message = message })); } catch (Exception exception) { message = General.GetString( "SIGNIN_SMTP_SENDING_PWD_MAIL_ERROR", "We can't send you your password. There were problems while trying to do so."); //this.Message.TextKey = "SIGNIN_SMTP_SENDING_PWD_MAIL_ERROR"; LogHelper.Logger.Log( LogLevel.Error, string.Format( "Error while trying to send the password to '{0}'. Perhaps you should check your SMTP server configuration in the web.config.", email), exception); return(Json(new { ok = false, Message = message })); } } }
static async Task <TextResponse> RequestHttpAsync(HttpMethod method, string endPointPath, PropertyCollection parameters, PropertyCollection headers, RequestType requestType, ResponseType responseType, bool attemptTokenRefresh) { if (!MASApplication.IsRegistered) { ErrorFactory.ThrowError(ErrorCode.ApplicationNotRegistered); } if (!MASDevice.Current.IsRegistered) { ErrorFactory.ThrowError(ErrorCode.DeviceNotRegistered); } string url = endPointPath; string body = null; if (method == HttpMethod.GET || method == HttpMethod.DELETE) { var builder = new HttpUrlBuilder(endPointPath); if (parameters != null) { foreach (var paramInfo in parameters.Properties) { builder.Add(paramInfo.Key, paramInfo.Value); } } url = builder.ToString(); } else if (parameters != null) { body = FormatBody(requestType, parameters.Properties); } MASUser requestUser = null; if (MASUser.Current != null && MASUser.Current.IsLoggedIn) { requestUser = MASUser.Current; } else if (MASApplication.Current.Client != null) { requestUser = MASApplication.Current.Client; } var requestHeaders = await SetupRequestHeaders(requestUser, headers?.Properties, requestType, responseType); try { var requestResponse = await HttpRequestFactory.RequestTextAsync(new HttpRequestInfo() { Url = url, Method = method, Headers = requestHeaders, Body = body, Certificate = MASDevice.Current.Certificate }); return(ToMASResponse(requestResponse)); } catch (MASException exp) { if (requestUser == null || attemptTokenRefresh == false || exp.MASErrorCode != ErrorCode.TokenAccessExpired) { throw exp; } } // Our token has expired, attempt to refresh it and try again! await requestUser.RefreshAccessTokenAsync(); // Lets not try to refresh token after our first attempt return(await RequestHttpAsync(method, endPointPath, parameters, headers, requestType, responseType, false)); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event. /// </summary> /// <param name="e"> /// The <see cref="T:System.EventArgs"/> object that contains the event data. /// </param> /// <remarks> /// </remarks> protected override void OnLoad(EventArgs e) { if (!this.Page.IsPostBack) { // Invalidate settings cache if (CurrentCache.Exists(Key.TabSettings(this.PageID))) { CurrentCache.Remove(Key.TabSettings(this.PageID)); } } base.OnLoad(e); // Confirm delete if (!this.ClientScript.IsClientScriptBlockRegistered("confirmDelete")) { string[] s = { "CONFIRM_DELETE" }; this.ClientScript.RegisterClientScriptBlock( this.GetType(), "confirmDelete", PortalSettings.GetStringResource("CONFIRM_DELETE_SCRIPT", s)); } //this.TopDeleteBtn.Attributes.Add("00", "return confirmDelete()"); //this.LeftDeleteBtn.Attributes.Add("OnClick", "return confirmDelete()"); //this.RightDeleteBtn.Attributes.Add("OnClick", "return confirmDelete()"); //this.ContentDeleteBtn.Attributes.Add("OnClick", "return confirmDelete()"); //this.BottomDeleteBtn.Attributes.Add("OnClick", "return confirmDelete()"); urlToLoadModules = "'" + HttpUrlBuilder.BuildUrl("~/Appleseed.Core/PageLayout/LoadModule") + "'"; // If first visit to the page, update all entries if (!this.Page.IsPostBack) { this.msgError.Visible = false; this.BindData(); this.SetSecurityAccess(); // 2/27/2003 Start - Ender Malkoc // After up or down button when the page is refreshed, select the previously selected // tab from the list. if (this.Request.Params["selectedmodid"] != null) { try { var modIndex = Int32.Parse(this.Request.Params["selectedmodid"]); //this.SelectModule(this.topPane, this.GetModules("TopPane"), modIndex); //this.SelectModule(this.leftPane, this.GetModules("LeftPane"), modIndex); //this.SelectModule(this.contentPane, this.GetModules("ContentPane"), modIndex); //this.SelectModule(this.rightPane, this.GetModules("RightPane"), modIndex); //this.SelectModule(this.bottomPane, this.GetModules("BottomPane"), modIndex); } catch (Exception ex) { ErrorHandler.Publish( LogLevel.Error, "After up or down button when the page is refreshed, select the previously selected tab from the list.", ex); } } // 2/27/2003 end - Ender Malkoc } // Binds custom settings to table this.EditTable.DataSource = new SortedList(this.PageSettings); this.EditTable.DataBind(); this.ModuleIdField.Value = this.ModuleID.ToString(); this.PageIdField.Value = this.PageID.ToString(); }
/// <summary> /// Initial Revision by Paul Yarrow, [email protected], 2003-07-13 /// </summary> protected void BindGrid() { if (txtStartDate.Text.Length > 0 && txtEndDate.Text.Length > 0) { // Read in the data regardless //MonitoringDB monitorDB = new MonitoringDB(); DateTime startDate = DateTime.Parse(txtStartDate.Text); DateTime endDate = DateTime.Parse(txtEndDate.Text); bool showChart = true; string chartType = string.Empty; switch (cboReportType.SelectedItem.Value) { case "Detailed Site Log": sortField = "ActivityTime"; sortDirection = "DESC"; ViewState["SortField"] = sortField; ViewState["sortDirection"] = sortDirection; showChart = false; break; case "Page Popularity": sortField = "Requests"; sortDirection = "DESC"; ViewState["SortField"] = sortField; ViewState["sortDirection"] = sortDirection; chartType = "pie"; break; case "Most Active Users": sortField = "Actions"; sortDirection = "DESC"; ViewState["SortField"] = sortField; ViewState["sortDirection"] = sortDirection; chartType = "pie"; break; case "Page Views By Day": sortField = "[Date]"; sortDirection = "ASC"; ViewState["SortField"] = sortField; ViewState["sortDirection"] = sortDirection; chartType = "bar"; break; case "Page Views By Browser Type": sortField = "[Views]"; sortDirection = "DESC"; ViewState["SortField"] = sortField; ViewState["sortDirection"] = sortDirection; chartType = "pie"; break; } DataSet monitorData = Utility.GetMonitoringStats(startDate, endDate, cboReportType.SelectedItem.Value, this.PortalSettings.ActivePage.PageID, CheckBoxIncludeMonitorPage.Checked, CheckBoxPageRequests.Checked, CheckBoxLogons.Checked, CheckBoxLogouts.Checked, CheckBoxIncludeMyIPAddress.Checked, this.PortalSettings.PortalID); myDataView = monitorData.Tables[0].DefaultView; myDataView.Sort = sortField + " " + sortDirection; myDataGrid.DataSource = myDataView; myDataGrid.DataBind(); if (monitorData.Tables[0].Rows.Count > 0) { myDataGrid.Visible = true; LabelNoData.Visible = false; } else { myDataGrid.Visible = false; LabelNoData.Visible = true; } if (showChart) { StringBuilder xValues = new StringBuilder(); StringBuilder yValues = new StringBuilder(); foreach (DataRow dr in monitorData.Tables[0].Rows) { xValues.Append(dr[0]); yValues.Append(dr[1]); xValues.Append("|"); yValues.Append("|"); } if (xValues.Length > 0 && yValues.Length > 0) { xValues.Remove(xValues.Length - 1, 1); yValues.Remove(yValues.Length - 1, 1); ChartImage.ImageUrl = HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Monitoring/ChartGenerator.aspx?" + "xValues=" + xValues.ToString() + "&yValues=" + yValues.ToString() + "&ChartType=" + chartType); ChartImage.Visible = true; } else { ChartImage.Visible = false; } } else { ChartImage.Visible = false; } } }
/// <summary> /// Handles the Click event of the RegisterBtn control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void RegisterBtn_Click(object sender, EventArgs e) { Response.Redirect(HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx")); }
public Guid SaveUserData() { if (!EditMode) { Guid result = Guid.Empty; if (Session["CameFromSocialNetwork"] == null) { MembershipCreateStatus status = MembershipCreateStatus.Success; MembershipUser user = Membership.Provider.CreateUser(tfEmail.Text, tfPwd.Text, tfEmail.Text, "question", "answer", true, Guid.NewGuid(), out status); this.lblError.Text = string.Empty; switch (status) { case MembershipCreateStatus.DuplicateEmail: case MembershipCreateStatus.DuplicateUserName: this.lblError.Text = Resources.Appleseed.USER_ALREADY_EXISTS; break; case MembershipCreateStatus.ProviderError: break; case MembershipCreateStatus.Success: UpdateProfile(); result = (Guid)user.ProviderUserKey; //if the user is registering himself (thus, is not yet authenticated) we will sign him on and send him to the home page. if (!Context.User.Identity.IsAuthenticated) { PortalSecurity.SignOn(tfEmail.Text, tfPwd.Text, false, HttpUrlBuilder.BuildUrl()); } break; // for every other error message... default: this.lblError.Text = Resources.Appleseed.USER_SAVING_ERROR; break; } return(result); } else { if ((Session["TwitterUserName"] != null) || (Session["LinkedInUserName"] != null)) { // Register Twitter or LinkedIn string userName = (Session["TwitterUserName"] != null) ? Session["TwitterUserName"].ToString() : Session["LinkedInUserName"].ToString(); string password = GeneratePasswordHash(userName); MembershipCreateStatus status = MembershipCreateStatus.Success; MembershipUser user = Membership.Provider.CreateUser(userName, password, tfEmail.Text, "question", "answer", true, Guid.NewGuid(), out status); this.lblError.Text = string.Empty; switch (status) { case MembershipCreateStatus.DuplicateEmail: case MembershipCreateStatus.DuplicateUserName: this.lblError.Text = Resources.Appleseed.USER_ALREADY_EXISTS; break; case MembershipCreateStatus.ProviderError: break; case MembershipCreateStatus.Success: UpdateProfile(); result = (Guid)user.ProviderUserKey; //if the user is registering himself (thus, is not yet authenticated) we will sign him on and send him to the home page. if (!Context.User.Identity.IsAuthenticated) { Session.Contents.Remove("CameFromSocialNetwork"); PortalSecurity.SignOn(userName, password, false, HttpUrlBuilder.BuildUrl()); } break; // for every other error message... default: this.lblError.Text = Resources.Appleseed.USER_SAVING_ERROR; break; } return(result); } else if (Session["FacebookUserName"] != null || Session["GoogleUserEmail"] != null) { // Register Facebook string userName = tfEmail.Text; string password = GeneratePasswordHash(userName); MembershipCreateStatus status = MembershipCreateStatus.Success; MembershipUser user = Membership.Provider.CreateUser(userName, password, userName, "question", "answer", true, Guid.NewGuid(), out status); this.lblError.Text = string.Empty; switch (status) { case MembershipCreateStatus.DuplicateEmail: case MembershipCreateStatus.DuplicateUserName: this.lblError.Text = Resources.Appleseed.USER_ALREADY_EXISTS; break; case MembershipCreateStatus.ProviderError: break; case MembershipCreateStatus.Success: UpdateProfile(); result = (Guid)user.ProviderUserKey; //if the user is registering himself (thus, is not yet authenticated) we will sign him on and send him to the home page. if (!Context.User.Identity.IsAuthenticated) { // Removing names from social networks of sessions if (Session["CameFromGoogleLogin"] != null) { Session.Contents.Remove("CameFromGoogleLogin"); } if (Session["GoogleUserEmail"] != null) { Session.Contents.Remove("GoogleUserEmail"); } if (Session["GoogleUserName"] != null) { Session.Contents.Remove("GoogleUserName"); } if (Session["FacebookUserName"] != null) { Session.Contents.Remove("FacebookUserName"); } if (Session["FacebookName"] != null) { Session.Contents.Remove("FacebookName"); } PortalSecurity.SignOn(userName, password, false, HttpUrlBuilder.BuildUrl()); } break; // for every other error message... default: this.lblError.Text = Resources.Appleseed.USER_SAVING_ERROR; break; } return(result); } else { return(result); } } } else { string Email = tfEmail.Text; string UserName = Membership.GetUserNameByEmail(Email); if (!UserName.Equals(Email)) { // The user Came from twitter Session["CameFromSocialNetwork"] = true; Session["TwitterUserName"] = UserName; Session["LinkedInUserName"] = UserName; Session["deleteCookies"] = true; } UpdateProfile(); return((Guid)Membership.GetUser(UserName, false).ProviderUserKey); } }
/// <summary> /// Binds the control and all its child controls to the specified data source. /// </summary> public override void DataBind() { if (HttpContext.Current != null) { //Init data ArrayList list = new ArrayList(); // Obtain PortalSettings from Current Context PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; string homeLink = "<a"; string menuLink; // added Class support by Mario Endara <*****@*****.**> 2004/10/04 if (CssClass.Length != 0) { homeLink = homeLink + " class=\"" + CssClass + "\""; } homeLink = homeLink + " href='" + HttpUrlBuilder.BuildUrl() + "'>" + General.GetString("Rainbow", "HOME") + "</a>"; // If user logged in, customize welcome message if (HttpContext.Current.Request.IsAuthenticated == true) { if (ShowWelcome) { list.Add(General.GetString("HEADER_WELCOME", "Welcome", this) + " " + PortalSettings.CurrentUser.Identity.Name + "!"); } if (ShowHome) { list.Add(homeLink); } if (ShowHelp) { list.Add(GetHelpLink()); } // Added by Mario Endara <*****@*****.**> (2004/11/06) // Find Tab module to see if the user has add/edit rights ModulesDB modules = new ModulesDB(); Guid TabGuid = new Guid("{1C575D94-70FC-4A83-80C3-2087F726CBB3}"); // Added by Xu Yiming <*****@*****.**> (2004/12/6) // Modify for support Multi or zero Pages Modules in a single portal. bool HasEditPermissionsOnTabs = false; int TabModuleID = 0; // SqlDataReader result = modules.FindModulesByGuid(portalSettings.PortalID, TabGuid); // while(result.Read()) // { // TabModuleID=(int)result["ModuleId"]; foreach (ModuleItem m in modules.FindModuleItemsByGuid(portalSettings.PortalID, TabGuid)) { HasEditPermissionsOnTabs = PortalSecurity.HasEditPermissions(m.ID); if (HasEditPermissionsOnTabs) { TabModuleID = m.ID; break; } } // If user logged in and has Edit permission in the Tab module, reach tab management just one click if ((ShowTabMan) && (HasEditPermissionsOnTabs)) { // added by Mario Endara 2004/08/06 so PageLayout can return to this page // added Class support by Mario Endara <*****@*****.**> 2004/10/04 menuLink = "<a"; if (CssClass.Length != 0) { menuLink = menuLink + " class=\"" + CssClass + "\""; } // added mID by Mario Endara <*****@*****.**> to support security check (2004/11/09) menuLink = menuLink + " href='" + HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Pages/PageLayout.aspx?PageID=") + portalSettings.ActivePage.PageID + "&mID=" + TabModuleID.ToString() + "&Alias=" + portalSettings.PortalAlias + "&lang=" + portalSettings.PortalUILanguage + "&returntabid=" + portalSettings.ActivePage.PageID + "'>" + General.GetString("HEADER_MANAGE_TAB", "Edit This Page", null) + "</a>"; list.Add(menuLink); } if (ShowEditProfile) { // 19/08/2004 Jonathan Fong // www.gt.com.au if (Context.User.Identity.AuthenticationType == "LDAP") { // added Class support by Mario Endara <*****@*****.**> 2004/10/04 menuLink = "<a"; if (CssClass.Length != 0) { menuLink = menuLink + " class=\"" + CssClass + "\""; } menuLink = menuLink + " href='" + HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx", "userName="******"'>" + "Profile" + "</a>"; list.Add(menuLink); } // If user is form add edit user link else if (!(HttpContext.Current.User is WindowsPrincipal)) { // added Class support by Mario Endara <*****@*****.**> 2004/10/04 menuLink = "<a"; if (CssClass.Length != 0) { menuLink = menuLink + " class=\"" + CssClass + "\""; } menuLink = menuLink + " href='" + HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx", "userName="******"'>" + General.GetString("HEADER_EDIT_PROFILE", "Edit profile", this) + "</a>"; list.Add(menuLink); } } // if authentication mode is Cookie, provide a logoff link if (Context.User.Identity.AuthenticationType == "Forms" || Context.User.Identity.AuthenticationType == "LDAP") { if (ShowLogOff) { // Corrections when ShowSecureLogon is true. [email protected] (05/07/2004) string href = HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Admin/Logoff.aspx"); if (ShowSecureLogon && Context.Request.IsSecureConnection) { string auxref = Context.Request.Url.AbsoluteUri; auxref = auxref.Substring(0, auxref.IndexOf(Context.Request.Url.PathAndQuery)); href = auxref + href; href = href.Replace("https", "http"); } // added Class support by Mario Endara <*****@*****.**> 2004/10/04 menuLink = "<a"; if (CssClass.Length != 0) { menuLink = menuLink + " class=\"" + CssClass + "\""; } menuLink = menuLink + " href='" + href + "'>" + General.GetString("HEADER_LOGOFF", "Logoff", null) + "</a>"; list.Add(menuLink); } } } else { if (ShowHome) { list.Add(homeLink); } if (ShowHelp) { list.Add(GetHelpLink()); } // if not authenticated and ShowLogon is true, provide a logon link if (ShowLogon) { // added Class support by Mario Endara <*****@*****.**> 2004/10/04 menuLink = "<a"; if (CssClass.Length != 0) { menuLink = menuLink + " class=\"" + CssClass + "\""; } menuLink = menuLink + " href='" + HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Admin/Logon.aspx") + "'>" + General.GetString("LOGON", "Logon", null) + "</a>"; list.Add(menuLink); } // Thierry (Tiptopweb) 5 May 2003 : Secure Logon to Secure Directory if (ShowSecureLogon) { // Added localized support. [email protected] (05/07/2004) // added Class support by Mario Endara <*****@*****.**> 2004/10/04 menuLink = "<a"; if (CssClass.Length != 0) { menuLink = menuLink + " class=\"" + CssClass + "\""; } menuLink = menuLink + " href='" + portalSettings.PortalSecurePath + "/Logon.aspx'>" + General.GetString("LOGON", "Logon", null) + "</a>"; list.Add(menuLink); } } innerDataSource = list; } base.DataBind(); }
/// <summary> /// Handles the Load event of the DesktopDefault control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="System.EventArgs"/> instance containing the event data. /// </param> private void DesktopDefault_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.Params["panelist"])) { this.RenderContentAreaList(); } // intento obtener el id de la pagina desde el query string query = Request.Url.Query; int pageId = 0; if (query.Contains("?") && query.ToLower().Contains("pageid")) { int index = query.IndexOf('?'); int indexPageId = query.ToLower().IndexOf("pageid") + 5; if (index < indexPageId - 5) { query = query.Substring(indexPageId + 2, query.Length - indexPageId - 2); index = query.IndexOf('&'); if (index > 0) // no va hasta el final el numero de pagina { query = query.Substring(0, index); } try { pageId = int.Parse(query); } catch (Exception) { pageId = 0; } } else { pageId = 0; } } else { pageId = this.PortalSettings.ActivePage.PageID; } if (pageId == 0) { pageId = Convert.ToInt32(SiteMap.RootNode.ChildNodes[0].Key); this.Response.Redirect(HttpUrlBuilder.BuildUrl(pageId)); } string urlToRedirect = ""; bool redirect = HttpUrlBuilder.ValidateProperUrl(pageId, ref urlToRedirect); if (!redirect) { this.Response.Redirect(urlToRedirect); } if (!PortalSecurity.IsInRoles(this.PortalSettings.ActivePage.AuthorizedRoles) && !this.User.IsInRole("Admins")) { PortalSecurity.AccessDenied(); } else { if (this.Request.Params["r"] == null || this.Request.Params["r"] != "0") { var user = Membership.GetUser(); } var userName = this.Request.Params["u"]; var pass = this.Request.Params["p"]; if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(pass)) { // PortalSecurity.SignOn(userName, pass, false, "~/DesktopDefault.aspx"); var rem = (this.Request.Params["rem"] ?? "0").Equals("1") ? true : false; PortalSecurity.SignOn(userName, pass, rem, "~/DesktopDefault.aspx"); this.Response.Redirect("~/DesktopDefault.aspx"); } if (string.IsNullOrEmpty(Request.Params["panelist"])) { this.LoadPage(); } } }
/// <summary> /// Handles OnLoad event at Page level<br/> /// Performs OnLoad actions that are common to all Pages. /// </summary> /// <param name="e"></param> protected override void OnLoad(EventArgs e) { base.OnLoad (e); // load the dedicated CSS if ( !this.IsCssFileRegistered("SmartError") ) this.RegisterCssFile("Mod_SmartError"); ArrayList storedError = null; StringBuilder sb = new StringBuilder(); // to build response text int _httpStatusCode = (int)HttpStatusCode.InternalServerError; // default value string _renderedEvent = string.Empty; string validStatus = "301;307;403;404;410;500;501;502;503;504"; if ( Request.QueryString[0] != null ) { // is this a "MagicUrl" request if ( Request.QueryString[0].StartsWith("404;http://") ) { Hashtable magicUrlList = null; string redirectUrl = string.Empty; string qPart = string.Empty; int qPartPos = Request.QueryString[0].LastIndexOf("/") + 1 ; qPart = qPartPos < Request.QueryString[0].Length ? Request.QueryString[0].Substring(qPartPos) : string.Empty; if ( qPart.Length > 0 ) { if ( Utils.IsInteger(qPart) ) redirectUrl = HttpUrlBuilder.BuildUrl(Int32.Parse(qPart)); else { magicUrlList = GetMagicUrlList(Portal.UniqueID); if ( magicUrlList != null && magicUrlList.ContainsKey(HttpUtility.HtmlEncode(qPart)) ) { redirectUrl = HttpUtility.HtmlDecode(magicUrlList[HttpUtility.HtmlEncode(qPart)].ToString()); if ( Utils.IsInteger(redirectUrl) ) redirectUrl = HttpUrlBuilder.BuildUrl(Int32.Parse(redirectUrl)); } } if ( redirectUrl.Length != 0 ) Response.Redirect(redirectUrl, true); else _httpStatusCode = (int)HttpStatusCode.NotFound; } } // get status code from querystring else if ( Utils.IsInteger(Request.QueryString[0]) && validStatus.IndexOf(Request.QueryString[0]) > -1 ) { _httpStatusCode = int.Parse(Request.QueryString[0]); } } // get stored error if (Request.QueryString["eid"] != null && Request.QueryString["eid"].Length > 0) { storedError = (ArrayList)CurrentCache.Get(Request.QueryString["eid"]); } if ( storedError != null && storedError[_RENDEREDEVENT_] != null ) _renderedEvent = storedError[_RENDEREDEVENT_].ToString(); else _renderedEvent = @"<p>No exception event stored or cache has expired.</p>"; // get home link string homeUrl = HttpUrlBuilder.BuildUrl(); // try localizing message try { switch ( _httpStatusCode ) { case (int)HttpStatusCode.NotFound : // 404 case (int)HttpStatusCode.Gone : // 410 case (int)HttpStatusCode.MovedPermanently : // 301 case (int)HttpStatusCode.TemporaryRedirect : // 307 sb.AppendFormat("<h3>{0}</h3>",General.GetString("SMARTERROR_404HEADING","Page Not Found", null)); sb.AppendFormat("<p>{0}</p>",General.GetString("SMARTERROR_404TEXT","We're sorry, but there is no page that matches your entry. It is possible you typed the address incorrectly, or the page may no longer exist. You may wish to try another entry or choose from the links below, which we hope will help you find what you’re looking for.", null)); break; case (int)HttpStatusCode.Forbidden : // 403 sb.AppendFormat("<h3>{0}</h3>",General.GetString("SMARTERROR_403HEADING","Not Authorised", null)); sb.AppendFormat("<p>{0}</p>",General.GetString("SMARTERROR_403TEXT","You do not have the required authority for the requested page or action.", null)); break; default : sb.AppendFormat("<h3>{0}</h3>",General.GetString("SMARTERROR_500HEADING","Our Apologies", null)); sb.AppendFormat("<p>{0}</p>",General.GetString("SMARTERROR_500TEXT","We're sorry, but we were unable to service your request. It's possible that the problem is a temporary condition.", null)); break; } sb.AppendFormat("<p><a href=\"{0}\">{1}</a></p>", homeUrl,General.GetString("HOME","Home Page",null)); } catch // default to english message { switch ( _httpStatusCode ) { case (int)HttpStatusCode.NotFound : sb.Append("<h3>Page Not Found</h3>"); sb.Append("<p>We're sorry, but there is no page that matches your entry. It is possible you typed the address incorrectly, or the page may no longer exist. You may wish to try another entry or choose from the links below, which we hope will help you find what you’re looking for.</p>"); break; case (int)HttpStatusCode.Forbidden : sb.Append("<h3>Not Authorised</h3>"); sb.Append("<p>You do not have the required authority for the requested page or action.</p>"); break; default : sb.Append("<h3>Our Apologies</h3>"); sb.AppendFormat("<p>We're sorry, but we were unable to service your request. It's possible that the problem is a temporary condition.</p>"); break; } sb.AppendFormat("<p><a href=\"{0}\">{1}</a></p>",homeUrl, "Home Page"); } // find out if user is on allowed IP Address if ( Request.UserHostAddress != null && Request.UserHostAddress.Length > 0 ) { // construct IPList string[] lockKeyHolders = Config.LockKeyHolders.Split(new char[]{';'}); //ConfigurationSettings.AppSettings["LockKeyHolders"].Split(new char[]{';'}); IPList ipList = new IPList(); try { foreach ( string lockKeyHolder in lockKeyHolders ) { if ( lockKeyHolder.IndexOf("-") > -1 ) ipList.AddRange(lockKeyHolder.Substring(0, lockKeyHolder.IndexOf("-")), lockKeyHolder.Substring(lockKeyHolder.IndexOf("-") + 1)); else ipList.Add(lockKeyHolder); } // check if requestor's IP address is in allowed list if ( ipList.CheckNumber(Request.UserHostAddress) ) { // we can show error details sb.AppendFormat("<h3>{0} - {1}</h3>",General.GetString("SMARTERROR_SUPPORTDETAILS_HEADING","Support Details", null), _httpStatusCode.ToString()); sb.Append(_renderedEvent); } } catch { // if there was a problem, let's assume that user is not authorised } } PageContent.Controls.Add(new LiteralControl(sb.ToString())); Response.StatusCode = _httpStatusCode; Response.Cache.SetCacheability(HttpCacheability.NoCache); }
/// <summary> /// Override CreateChildControls to create the control tree. /// </summary> protected override void CreateChildControls() { // Create an arraylist to fill with // the TabItems representing the Tree ArrayList crumbs; if (HttpContext.Current != null) { // Obtain PortalSettings from Current Context PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; //Display breadcrumbs if the user has click a tab link (Without hit the Database again) if (portalSettings.ActivePage.PageID > 0) { ArrayList authorizedTabs = new ArrayList(); int addedTabs = 0; for (int i = 0; i < portalSettings.DesktopPages.Count; i++) { PageStripDetails tab = (PageStripDetails)portalSettings.DesktopPages[i]; if (PortalSecurity.IsInRoles(tab.AuthorizedRoles)) { authorizedTabs.Add(tab); } addedTabs++; } crumbs = GetBreadCrumbs(portalSettings.ActivePage, authorizedTabs); crumbs.Sort(); } else { crumbs = new ArrayList(); } } else //design time { crumbs = new ArrayList(); crumbs.Add("Item1"); crumbs.Add("Item2"); crumbs.Add("Item3"); } if (crumbs.Count > 1) { StringBuilder sb = new StringBuilder(); sb.Append("<div class='"); sb.Append(CssClass); sb.Append("'>"); int ct = 0; // Build the Breadcrumbs and add them to the div foreach (PageItem item in crumbs) { if (ct > 0) { sb.Append(Separator.ToString()); } if (ct != (crumbs.Count - 1)) { sb.Append("<a href='"); sb.Append(HttpUrlBuilder.BuildUrl(item.ID)); sb.Append("'>"); sb.Append(item.Name.ToString()); sb.Append("</a>"); } else { sb.Append(item.Name.ToString()); } ct++; } sb.Append("</div>"); Text = sb.ToString(); } else { Visible = false; } }
/// <summary> /// Redirect user back to the Portal Home Page. /// Mainly used after a successful login. /// </summary> /// <remarks> /// </remarks> public static void PortalHome() { HttpContext.Current.Response.Redirect(HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage)); }
protected void BindGrid() { UserDefinedTableDB objUserDefinedTable = new UserDefinedTableDB(); string strSortField = string.Empty; string strSortOrder = string.Empty; SqlDataReader dr; if (ViewState["SortField"].ToString() != string.Empty && ViewState["SortOrder"].ToString() != string.Empty) { strSortField = ViewState["SortField"].ToString(); strSortOrder = ViewState["SortOrder"].ToString(); } else { if (Settings["SortField"].ToString() != string.Empty) { strSortField = Settings["SortField"].ToString(); } if (Settings["SortOrder"].ToString() != string.Empty) { strSortOrder = Settings["SortOrder"].ToString(); } else { strSortOrder = "ASC"; } } grdData.Columns.Clear(); dr = objUserDefinedTable.GetUserDefinedFields(ModuleID); try { while (dr.Read()) { DataGridColumn colField = null; if (dr["FieldType"].ToString() == "Image") { colField = new BoundColumn(); ((BoundColumn)colField).DataField = dr["FieldTitle"].ToString(); ((BoundColumn)colField).DataFormatString = "<img src=\"" + ((SettingItem)Settings["ImagePath"]).FullPath + "/{0}" + "\" alt=\"{0}\" border =0>"; } else if (dr["FieldType"].ToString() == "File") { colField = new HyperLinkColumn(); ((HyperLinkColumn)colField).DataTextField = dr["FieldTitle"].ToString(); ((HyperLinkColumn)colField).DataTextFormatString = "{0}"; ((HyperLinkColumn)colField).DataNavigateUrlFormatString = ((SettingItem)Settings["DocumentPath"]).FullPath + "/{0}"; ((HyperLinkColumn)colField).DataNavigateUrlField = dr["FieldTitle"].ToString(); } else { colField = new BoundColumn(); ((BoundColumn)colField).DataField = dr["FieldTitle"].ToString(); switch (dr["FieldType"].ToString()) { case "DateTime": //Changed to Italian format as it is sayed to be the default (see intro of history.txt) //Better would be to make this follow the current culture - Rob Siera, 15 jan 2005 ((BoundColumn)colField).DataFormatString = "{0:dd MMM yyyy}"; break; case "Int32": ((BoundColumn)colField).DataFormatString = "{0:#,###,##0}"; colField.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; colField.ItemStyle.HorizontalAlign = HorizontalAlign.Right; break; case "Decimal": ((BoundColumn)colField).DataFormatString = "{0:#,###,##0.00}"; colField.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; colField.ItemStyle.HorizontalAlign = HorizontalAlign.Right; break; } } colField.HeaderText = dr["FieldTitle"].ToString(); if (dr["FieldTitle"].ToString() == strSortField) { // 2004/07/04 by Ozan Sirin, FIX: It does not show sort images when running root site instead of rainbow virtual folder. if (strSortOrder == "ASC") { colField.HeaderText += "<img src='" + Rainbow.Settings.Path.WebPathCombine(Rainbow.Settings.Path.ApplicationRoot, "DesktopModules/UserDefinedTable/sortascending.gif") + "' border='0' alt='" + Esperantus.Localize.GetString("USERTABLE_SORTEDBY", "Sorted By", null) + " " + strSortField + " " + Esperantus.Localize.GetString("USERTABLE_INASCORDER", "In Ascending Order", null) + "'>"; } else { colField.HeaderText += "<img src='" + Rainbow.Settings.Path.WebPathCombine(Rainbow.Settings.Path.ApplicationRoot, "DesktopModules/UserDefinedTable/sortdescending.gif") + "' border='0' alt='" + Esperantus.Localize.GetString("USERTABLE_SORTEDBY", "Sorted By", null) + " " + strSortField + " " + Esperantus.Localize.GetString("USERTABLE_INDSCORDER", "In Descending Order", null) + "'>"; } } colField.Visible = bool.Parse(dr["Visible"].ToString()); colField.SortExpression = dr["FieldTitle"].ToString() + "|ASC"; grdData.Columns.Add(colField); } } finally { dr.Close(); } if (IsEditable) { HyperLinkColumn hc = new HyperLinkColumn(); hc.Text = "Edit"; hc.DataNavigateUrlField = "UserDefinedRowID"; hc.DataNavigateUrlFormatString = HttpUrlBuilder.BuildUrl("~/DesktopModules/UserDefinedTable/UserDefinedTableEdit.aspx", TabID, "&mID=" + ModuleID + "&UserDefinedRowID={0}"); grdData.Columns.Add(hc); } DataSet ds; ds = objUserDefinedTable.GetUserDefinedRows(ModuleID); // create a dataview to process the sort and filter options DataView dv; dv = new DataView(ds.Tables[0]); // sort data view if (strSortField != string.Empty && strSortOrder != string.Empty) { dv.Sort = strSortField + " " + strSortOrder; } grdData.DataSource = dv; grdData.DataBind(); }
/// <summary> /// Examines/combines all the variables involved and sets /// CurrentUICulture and CurrentCulture. instance containing the event data. /// </summary> /// <param name="e"></param> protected override void OnChangeLanguage(LanguageSwitcherEventArgs e) { if (Context != null) { int mID = 0; if (Context.Request.Params["Mid"] != null) { mID = Int32.Parse(Context.Request.Params["Mid"]); } int tID = 0; if (Context.Request.Params["PageID"] != null) { tID = Int32.Parse(Context.Request.Params["PageID"]); } else if (Context.Request.Params["TabID"] != null) { tID = Int32.Parse(Context.Request.Params["TabID"]); } string auxUrl = Context.Request.Url.AbsolutePath; string auxApplication = Context.Request.ApplicationPath; int index = auxUrl.ToLower().IndexOf(auxApplication.ToLower()); if (index != -1) { auxUrl = auxUrl.Substring(index + auxApplication.Length); } if (auxUrl.StartsWith("/")) { auxUrl = "~" + auxUrl; } else { auxUrl = "~/" + auxUrl; } string customParams = string.Empty; foreach (string key in Context.Request.QueryString.Keys) { if (!key.ToLower().Equals("mid") && !key.ToLower().Equals("tabid") && !key.ToLower().Equals("lang")) { customParams += "&" + key + "=" + Context.Request.Params[key]; } } string returnUrl = HttpUrlBuilder.BuildUrl(auxUrl, tID, mID, e.CultureItem.Culture, customParams, string.Empty, string.Empty); if (returnUrl.ToLower().IndexOf("lang") == -1) { customParams += "&Lang=" + e.CultureItem.Culture.Name; returnUrl = HttpUrlBuilder.BuildUrl(auxUrl, tID, mID, e.CultureItem.Culture, customParams, string.Empty, string.Empty); } //System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(e.CultureItem //LanguageCultureItem lci = new LanguageCultureItem(e.CultureItem.Culture.Name, e.CultureItem.Culture.Name) SetCurrentLanguage(e.CultureItem); Context.Response.Redirect(returnUrl); } }
/// <summary> /// Raised when the pages is loading. Here the CodeMirrorTextBox register its scripts. /// </summary> /// <param name="e"></param> protected override void OnLoad(EventArgs e) { if (!Page.ClientScript.IsClientScriptIncludeRegistered(this.GetType(), "CodeMirror")) { Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "CodeMirror", HttpUrlBuilder.BuildUrl("~/aspnet_client/CodeMirrorV5.12/js/codemirror.js")); Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "CodeMirror_mode_xml", HttpUrlBuilder.BuildUrl("~/aspnet_client/CodeMirrorV5.12/mode/xml/xml.js")); Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "CodeMirror_mode_js", HttpUrlBuilder.BuildUrl("~/aspnet_client/CodeMirrorV5.12/mode/javascript/javascript.js")); Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "CodeMirror_mode_css", HttpUrlBuilder.BuildUrl("~/aspnet_client/CodeMirrorV5.12/mode/css/css.js")); Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "CodeMirror_mode_htmlmixed", HttpUrlBuilder.BuildUrl("~/aspnet_client/CodeMirrorV5.12/mode/htmlmixed/htmlmixed.js")); Literal cssFile = new Literal() { Text = @"<link href=""" + HttpUrlBuilder.BuildUrl("~/aspnet_client/CodeMirrorV5.12/css/docs.css") + @""" type=""text/css"" rel=""stylesheet"" />" }; Page.Header.Controls.Add(cssFile); cssFile = new Literal() { Text = @"<link href=""" + HttpUrlBuilder.BuildUrl("~/aspnet_client/CodeMirrorV5.12/css/codemirror.css") + @""" type=""text/css"" rel=""stylesheet"" />" }; Page.Header.Controls.Add(cssFile); var jsToAdd = "<script type=\"text/javascript\"> $(document).ready(function(){ var editor = CodeMirror.fromTextArea(document.getElementById('" + this.ClientID + "'), { mode: \"text/html\", extraKeys: {\"Ctrl-Space\": \"autocomplete\"},value: document.getElementById('" + this.ClientID + "').innerHTML }); }); </script>"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CM_load", jsToAdd); } base.OnLoad(e); }