From 2648fedafeb9e6bf00c0a67413864cf563da79df Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Tue, 1 Apr 2014 06:50:58 +0300 Subject: [PATCH] updated Breadcrumb & Orgs Selector & made changes from by comments --- .../Code/PortalUtils.cs | 31 +++++++++++++++ .../Code/Helpers/ExchangeHelper.cs | 38 ------------------- .../ExchangeServer/Organizations.ascx.cs | 14 +++++++ .../SpaceOrganizationsSelector.ascx | 2 + .../SpaceOrganizationsSelector.ascx.cs | 5 ++- ...paceOrganizationsSelector.ascx.designer.cs | 9 +++++ .../SkinControls/UserSpaceBreadcrumb.ascx.cs | 5 +-- 7 files changed, 62 insertions(+), 42 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalUtils.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalUtils.cs index 45099e45..7ca0ac0c 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalUtils.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/Code/PortalUtils.cs @@ -314,6 +314,11 @@ namespace WebsitePanel.Portal return (string)HttpContext.GetGlobalResourceObject(className, resourceKey); } + public static string GetLocalizedString(string virtualPath, string resourceKey) + { + return (string)HttpContext.GetLocalResourceObject(virtualPath, resourceKey); + } + public static string GetCurrentPageId() { return HttpContext.Current.Request["pid"]; @@ -949,6 +954,32 @@ namespace WebsitePanel.Portal return navigateUrl; } + + public static string EditUrl(string keyName, string keyValue, string controlKey, params string[] additionalParams) + { + List url = new List(); + + string pageId = HttpContext.Current.Request[DefaultPage.PAGE_ID_PARAM]; + + if (!String.IsNullOrEmpty(pageId)) + url.Add(String.Concat(DefaultPage.PAGE_ID_PARAM, "=", pageId)); + + url.Add(String.Concat(DefaultPage.MODULE_ID_PARAM, "=", HttpContext.Current.Request.QueryString["mid"])); + url.Add(String.Concat(DefaultPage.CONTROL_ID_PARAM, "=", controlKey)); + + if (!String.IsNullOrEmpty(keyName) && !String.IsNullOrEmpty(keyValue)) + { + url.Add(String.Concat(keyName, "=", keyValue)); + } + + if (additionalParams != null) + { + foreach (string additionalParam in additionalParams) + url.Add(additionalParam); + } + + return "~/Default.aspx?" + String.Join("&", url.ToArray()); + } #endregion } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/ExchangeHelper.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/ExchangeHelper.cs index 82f3d12e..9d924436 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/ExchangeHelper.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/Code/Helpers/ExchangeHelper.cs @@ -34,9 +34,6 @@ using System.Text; using WebsitePanel.Providers.HostedSolution; using WebsitePanel.EnterpriseServer; -using System.Web; -using WebsitePanel.WebPortal; - namespace WebsitePanel.Portal { public class ExchangeHelper @@ -87,40 +84,5 @@ namespace WebsitePanel.Portal } #endregion - - #region Utils - - public static string BuildUrl(string keyName, string keyValue, string controlKey, params string[] additionalParams) - { - List url = new List(); - - string pageId = HttpContext.Current.Request[DefaultPage.PAGE_ID_PARAM]; - - if (!String.IsNullOrEmpty(pageId)) - url.Add(String.Concat(DefaultPage.PAGE_ID_PARAM, "=", pageId)); - - url.Add(String.Concat(DefaultPage.MODULE_ID_PARAM, "=", HttpContext.Current.Request.QueryString["mid"])); - url.Add(String.Concat(DefaultPage.CONTROL_ID_PARAM, "=", controlKey)); - - if (!String.IsNullOrEmpty(keyName) && !String.IsNullOrEmpty(keyValue)) - { - url.Add(String.Concat(keyName, "=", keyValue)); - } - - if (additionalParams != null) - { - foreach (string additionalParam in additionalParams) - url.Add(additionalParam); - } - - return "~/Default.aspx?" + String.Join("&", url.ToArray()); - } - - public static string GetLocalizedString(string virtualPath, string resourceKey) - { - return (string)HttpContext.GetLocalResourceObject(virtualPath, resourceKey); - } - - #endregion } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.cs index a8cda717..530afcda 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/Organizations.ascx.cs @@ -27,6 +27,7 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using System; +using System.Text; using System.Web.UI.WebControls; using WebsitePanel.EnterpriseServer; @@ -59,6 +60,19 @@ namespace WebsitePanel.Portal.ExchangeServer //else //if (gvOrgs.Rows.Count > 0) btnCreate.Enabled = false; + if (!Page.IsPostBack) + { + if (Request.UrlReferrer != null && PanelSecurity.SelectedUser.Role == UserRole.User) + { + var queryBuilder = new StringBuilder(); + queryBuilder.AppendFormat("?pid=Home&UserID={0}", PanelSecurity.SelectedUserId); + + if (Request.UrlReferrer.Query.Equals(queryBuilder.ToString(), StringComparison.InvariantCultureIgnoreCase) && gvOrgs.Rows.Count > 0) + { + Response.Redirect(((HyperLink)gvOrgs.Rows[0].Cells[1].Controls[1]).NavigateUrl); + } + } + } } protected void btnCreate_Click(object sender, EventArgs e) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/SpaceOrganizationsSelector.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/SpaceOrganizationsSelector.ascx index 895aa564..1497280c 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/SpaceOrganizationsSelector.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/SpaceOrganizationsSelector.ascx @@ -4,4 +4,6 @@ + | + Edit diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/SpaceOrganizationsSelector.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/SpaceOrganizationsSelector.ascx.cs index ea78c0d0..be8c6149 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/SpaceOrganizationsSelector.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/SpaceOrganizationsSelector.ascx.cs @@ -70,6 +70,9 @@ namespace WebsitePanel.Portal.SkinControls ddlSpaceOrgs.DataBind(); ddlSpaceOrgs.Items.FindByValue(PanelRequest.ItemID.ToString()).Selected = true; + + lnkOrgnsList.NavigateUrl = PortalUtils.NavigatePageURL( + PortalUtils.GetCurrentPageId(), "SpaceID", PanelSecurity.PackageId.ToString()); } } @@ -80,7 +83,7 @@ namespace WebsitePanel.Portal.SkinControls private string GetOrganizationEditUrl(string itemId) { - return ExchangeHelper.BuildUrl("SpaceID", PanelSecurity.PackageId.ToString(), "organization_home", + return PortalUtils.EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "organization_home", "ItemID=" + itemId); } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/SpaceOrganizationsSelector.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/SpaceOrganizationsSelector.ascx.designer.cs index dbe03f8c..b88a9802 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/SpaceOrganizationsSelector.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/SpaceOrganizationsSelector.ascx.designer.cs @@ -29,5 +29,14 @@ namespace WebsitePanel.Portal.SkinControls { /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.DropDownList ddlSpaceOrgs; + + /// + /// lnkOrgnsList control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.HyperLink lnkOrgnsList; } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/UserSpaceBreadcrumb.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/UserSpaceBreadcrumb.ascx.cs index d52f4cdc..2e3ed2b2 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/UserSpaceBreadcrumb.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SkinControls/UserSpaceBreadcrumb.ascx.cs @@ -114,7 +114,6 @@ namespace WebsitePanel.Portal.SkinControls // organization bool orgVisible = (PanelRequest.ItemID > 0); - //spanOrgsSelector.Visible = spanOrgn.Visible = orgVisible; spanOrgn.Visible = orgVisible; if (orgVisible) @@ -122,7 +121,7 @@ namespace WebsitePanel.Portal.SkinControls // load organization details Organization org = ES.Services.Organizations.GetOrganization(PanelRequest.ItemID); - lnkOrgn.NavigateUrl = ExchangeHelper.BuildUrl( + lnkOrgn.NavigateUrl = PortalUtils.EditUrl( "ItemID", PanelRequest.ItemID.ToString(), ORGANIZATION_CONTROL_KEY, "SpaceID=" + PanelSecurity.PackageId.ToString()); lnkOrgn.Text = org.Name; @@ -136,7 +135,7 @@ namespace WebsitePanel.Portal.SkinControls if (!String.IsNullOrEmpty(control.Src)) { - lbOrgCurPage.Text = ExchangeHelper.GetLocalizedString(DM_FOLDER_VIRTUAL_PATH + control.Src, PAGE_NANE_KEY); + lbOrgCurPage.Text = PortalUtils.GetLocalizedString(DM_FOLDER_VIRTUAL_PATH + control.Src, PAGE_NANE_KEY); } } }