Example #1
0
        public string GetItemPageUrl(int itemId, int spaceId)
        {
            string res = "";

            switch (ItemTypeName)
            {
            case type_WebSite:
                res = PortalUtils.NavigatePageURL(PID_SPACE_WEBSITES, "ItemID", itemId.ToString(),
                                                  PortalUtils.SPACE_ID_PARAM + "=" + spaceId, DefaultPage.CONTROL_ID_PARAM + "=" + "edit_item",
                                                  "moduleDefId=websites");
                break;

            case type_Domain:
                res = PortalUtils.NavigatePageURL(PID_SPACE_DIMAINS, "DomainID", itemId.ToString(),
                                                  PortalUtils.SPACE_ID_PARAM + "=" + spaceId, DefaultPage.CONTROL_ID_PARAM + "=" + "edit_item",
                                                  "moduleDefId=domains");
                break;

            case type_Organization:
                res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                  PortalUtils.SPACE_ID_PARAM + "=" + spaceId, DefaultPage.CONTROL_ID_PARAM + "=" + "organization_home",
                                                  "moduleDefId=ExchangeServer");
                break;
            }

            return(res);
        }
Example #2
0
        protected string GetNavigateBandwidthDetails(int packageId)
        {
            DateTime startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            DateTime endDate   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month));

            return
                (PortalUtils.NavigatePageURL("BandwidthReport", PortalUtils.SPACE_ID_PARAM, packageId.ToString(),
                                             "StartDate=" + startDate.Ticks.ToString(),
                                             "EndDate=" + endDate.Ticks.ToString(), "ctl=edit", "moduleDefId=BandwidthReport"));
        }
        protected override MenuItem CreateMenuItem(string text, string key, string img)
        {
            string PID_SPACE_EXCHANGE_SERVER = "SpaceExchangeServer";

            MenuItem item = new MenuItem();

            item.Text        = GetLocalizedString("Text." + text);
            item.NavigateUrl = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGE_SERVER, "ItemID", ItemID.ToString(),
                                                           PortalUtils.SPACE_ID_PARAM + "=" + PackageId, DefaultPage.CONTROL_ID_PARAM + "=" + key,
                                                           "moduleDefId=exchangeserver");

            if (img == null)
            {
                item.ImageUrl = PortalUtils.GetThemedIcon("Icons/tool_48.png");
            }
            else
            {
                item.ImageUrl = PortalUtils.GetThemedIcon(img);
            }

            return(item);
        }
Example #4
0
 protected void cmdSearch_Click(object sender, ImageClickEventArgs e)
 {
     if (tbObjectId.Text.Length > 0)
     {
         Response.Redirect(PortalUtils.GetUserHomePageUrl(Int32.Parse(tbObjectId.Text)));
     }
     else
     {
         String strText = tbSearchText.Text;
         if (strText.Length > 0)
         {
             Response.Redirect(NavigatePageURL(PortalUtils.GetUserCustomersPageId(),
                                               PortalUtils.USER_ID_PARAM, PanelSecurity.SelectedUserId.ToString(),
                                               "FilterColumn=" + ddlFilterColumn.SelectedValue,
                                               "FilterValue=" + Server.UrlEncode(FilterValue)));
         }
         else
         {
             Response.Redirect(PortalUtils.NavigatePageURL(PortalUtils.GetObjectSearchPageId(),
                                                           PortalUtils.USER_ID_PARAM, PanelSecurity.SelectedUserId.ToString(),
                                                           "Query=" + Server.UrlEncode(tbSearch.Text), "FullType=Users"));
         }
     }
 }
Example #5
0
        private MenuItem CreateMenuItem(PackageContext cntx, XmlNode xmlNode)
        {
            string pageId = GetXmlAttribute(xmlNode, "pageID");

            if (!PortalUtils.PageExists(pageId))
            {
                return(null);
            }

            string url           = GetXmlAttribute(xmlNode, "url");
            string title         = GetXmlAttribute(xmlNode, "title");
            string imageUrl      = GetXmlAttribute(xmlNode, "imageUrl");
            string target        = GetXmlAttribute(xmlNode, "target");
            string resourceGroup = GetXmlAttribute(xmlNode, "resourceGroup");
            string quota         = GetXmlAttribute(xmlNode, "quota");
            bool   disabled      = Utils.ParseBool(GetXmlAttribute(xmlNode, "disabled"), false);

            string titleresourcekey = GetXmlAttribute(xmlNode, "titleresourcekey");

            if (!String.IsNullOrEmpty(titleresourcekey))
            {
                title = GetLocalizedString(titleresourcekey + ".Text");
            }

            // get custom page parameters
            XmlNodeList   xmlParameters = xmlNode.SelectNodes("Parameters/Add");
            List <string> parameters    = new List <string>();

            foreach (XmlNode xmlParameter in xmlParameters)
            {
                parameters.Add(xmlParameter.Attributes["name"].Value
                               + "=" + xmlParameter.Attributes["value"].Value);
            }

            // add menu item
            string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL(
                pageId, PortalUtils.SPACE_ID_PARAM, cntx.Package.PackageId.ToString(), parameters.ToArray());
            string   pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId);
            MenuItem item     = new MenuItem(pageName, pageId, "", disabled ? null : pageUrl);

            item.ImageUrl = PortalUtils.GetThemedIcon(imageUrl);

            if (!String.IsNullOrEmpty(target))
            {
                item.Target = target;
            }
            item.Selectable = !disabled;

            // check groups/quotas
            bool display = true;

            if (cntx != null)
            {
                display = (String.IsNullOrEmpty(resourceGroup) ||
                           cntx.Groups.ContainsKey(resourceGroup)) &&
                          (String.IsNullOrEmpty(quota) ||
                           (cntx.Quotas.ContainsKey(quota) &&
                            cntx.Quotas[quota].QuotaAllocatedValue != 0));
            }

            // process nested menu items
            XmlNodeList xmlMenuNodes = xmlNode.SelectNodes("Icon");

            if (xmlMenuNodes.Count == 0)
            {
                xmlMenuNodes = xmlNode.SelectNodes("MenuItems/MenuItem");
            }
            foreach (XmlNode xmlMenuNode in xmlMenuNodes)
            {
                MenuItem menuItem = CreateMenuItem(cntx, xmlMenuNode);
                if (menuItem != null)
                {
                    item.ChildItems.Add(menuItem);
                }
            }

            // test
            //return item;

            if (display && !(disabled && item.ChildItems.Count == 0))
            {
                return(item);
            }

            return(null);
        }
Example #6
0
        public string GetItemPageUrl(string fullType, string itemType, int itemId, int spaceId, int accountId, string textSearch = "")
        {
            string res = "";

            if (fullType.Equals("AccountHome"))
            {
                res = PortalUtils.GetUserHomePageUrl(itemId);
            }
            else
            {
                switch (itemType)
                {
                case TYPE_WEBSITE:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_WEBSITES, "ItemID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId, DefaultPage.CONTROL_ID_PARAM + "=" + "edit_item",
                                                      "moduleDefId=websites");
                    break;

                case TYPE_DOMAIN:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_DIMAINS, "DomainID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId, DefaultPage.CONTROL_ID_PARAM + "=" + "edit_item",
                                                      "moduleDefId=domains");
                    break;

                case TYPE_ORGANIZATION:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId, DefaultPage.CONTROL_ID_PARAM + "=" + "organization_home",
                                                      "moduleDefId=ExchangeServer");
                    break;

                case TYPE_EXCHANGEACCOUNT:
                    if (fullType.Equals("Mailbox"))
                    {
                        res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                          PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=edit_user",
                                                          "AccountID=" + accountId, "Context=Mailbox", "moduleDefId=ExchangeServer");
                    }
                    else if (fullType.Equals("Room"))
                    {
                        res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                          PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=edit_user",
                                                          "AccountID=" + accountId, "Context=Mailbox", "moduleDefId=ExchangeServer");
                    }
                    else if (fullType.Equals("SharedMailbox"))
                    {
                        res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                          PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=edit_user",
                                                          "AccountID=" + accountId, "Context=Mailbox", "moduleDefId=ExchangeServer");
                    }
                    else if (fullType.Equals("Equipment"))
                    {
                        res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                          PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=edit_user",
                                                          "AccountID=" + accountId, "Context=Mailbox", "moduleDefId=ExchangeServer");
                    }
                    else if (fullType.Equals("User"))
                    {
                        res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                          PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=edit_user",
                                                          "AccountID=" + accountId, "Context=User", "moduleDefId=ExchangeServer");
                    }
                    else if (fullType.Equals("Contact"))
                    {
                        res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                          PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=contact_settings",
                                                          "AccountID=" + accountId, "moduleDefId=ExchangeServer");
                    }
                    else if (fullType.Equals("PublicFolder"))
                    {
                        res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                          PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=public_folder_settings",
                                                          "AccountID=" + accountId, "moduleDefId=ExchangeServer");
                    }
                    else if (fullType.Equals("DistributionList"))
                    {
                        res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                          PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=dlist_settings",
                                                          "AccountID=" + accountId, "moduleDefId=ExchangeServer");
                    }
                    else if (fullType.Equals("DefaultSecurityGroup"))
                    {
                        res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                          PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=secur_group_settings",
                                                          "AccountID=" + accountId, "moduleDefId=ExchangeServer");
                    }
                    else if (fullType.Equals("SecurityGroup"))
                    {
                        res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                          PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=secur_group_settings",
                                                          "AccountID=" + accountId, "moduleDefId=ExchangeServer");
                    }
                    else
                    {
                        res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                          PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=edit_user",
                                                          "AccountID=" + accountId, "Context=User", "moduleDefId=ExchangeServer");
                    }
                    break;

                case TYPE_RDSCOLLECTION:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=rds_edit_collection",
                                                      "CollectionId=" + accountId, "moduleDefId=ExchangeServer");
                    break;

                case TYPE_LYNC:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId.ToString(), "ctl=edit_lync_user",
                                                      "AccountID=" + accountId, "moduleDefId=ExchangeServer");
                    break;

                case TYPE_SFB:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId.ToString(), "ctl=edit_sfb_user",
                                                      "AccountID=" + accountId, "moduleDefId=ExchangeServer");
                    break;

                case TYPE_FOLDER:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId.ToString(), "ctl=enterprisestorage_folder_settings",
                                                      "FolderID=" + textSearch, "moduleDefId=ExchangeServer");
                    break;

                case TYPE_SHAREPOINT:
                case TYPE_SHAREPOINTENTERPRISE:
                    res = PortalUtils.NavigatePageURL(PID_SPACE_EXCHANGESERVER, "ItemID", itemId.ToString(),
                                                      PortalUtils.SPACE_ID_PARAM + "=" + spaceId, "ctl=" + (itemType == TYPE_SHAREPOINT ? "sharepoint_edit_sitecollection" : "sharepoint_enterprise_edit_sitecollection"),
                                                      "SiteCollectionID=" + accountId, "moduleDefId=ExchangeServer");
                    break;

                default:
                    res = PortalUtils.GetSpaceHomePageUrl(spaceId);
                    break;
                }
            }

            return(res);
        }
Example #7
0
 public string NavigatePageURL(string pageId, string keyName, string keyValue, params string[] additionalParams)
 {
     return(PortalUtils.NavigatePageURL(pageId, keyName, keyValue, additionalParams));
 }
Example #8
0
        private void CreateHostingSpace()
        {
            if (!Page.IsValid)
            {
                return;
            }

            string spaceName = ddlPlans.SelectedItem.Text;

            string ftpAccount = (rbFtpAccountName.SelectedIndex == 0) ? null : ftpAccountName.Text;

            string domainName = txtDomainName.Text.Trim();

            PackageResult result = null;

            try
            {
                result = ES.Services.Packages.AddPackageWithResources(PanelSecurity.SelectedUserId,
                                                                      Utils.ParseInt(ddlPlans.SelectedValue, 0),
                                                                      spaceName,
                                                                      Utils.ParseInt(ddlStatus.SelectedValue, 0),
                                                                      chkPackageLetter.Checked,
                                                                      chkCreateResources.Checked, domainName, false, chkCreateWebSite.Checked,
                                                                      chkCreateFtpAccount.Checked, ftpAccount, chkCreateMailAccount.Checked, txtHostName.Text);

                if (result.Result < 0)
                {
                    ShowResultMessage(result.Result);
                    lblMessage.Text = PortalAntiXSS.Encode(GetExceedingQuotasMessage(result.ExceedingQuotas));
                    return;
                }
                else
                {
                    if ((chkIntegratedOUProvisioning.Checked) & !string.IsNullOrEmpty(domainName))
                    {
                        UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId);

                        if (user != null)
                        {
                            if (user.Role != UserRole.Reseller)
                            {
                                UserSettings settings = ES.Services.Users.GetUserSettings(user.UserId, UserSettings.EXCHANGE_POLICY);
                                string       orgId    = domainName.ToLower();

                                if (settings != null && settings["OrgIdPolicy"] != null)
                                {
                                    orgId = GetOrgId(settings["OrgIdPolicy"], domainName, result.Result);
                                }

                                ES.Services.Organizations.CreateOrganization(result.Result, orgId, domainName.ToLower(), domainName.ToLower());

                                if (result.Result < 0)
                                {
                                    ShowErrorMessage("USERWIZARD_CREATE_ACCOUNT");
                                    return;
                                }

                                //Add Mail Cleaner
                                Knom.Helpers.Net.APIMailCleanerHelper.DomainAdd(domainName, Utils.ParseInt(ddlPlans.SelectedValue, 0));
                            }
                        }
                    }
                    if ((chkCreateMailAccount.Checked) & !string.IsNullOrEmpty(domainName))
                    {
                        //Add Mail Cleaner
                        Knom.Helpers.Net.APIMailCleanerHelper.DomainAdd(domainName, Utils.ParseInt(ddlPlans.SelectedValue, 0));
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("USERWIZARD_CREATE_ACCOUNT", ex);
                return;
            }

            // Save addons
            try
            {
                int spaceId = result.Result;
                foreach (RepeaterItem item in repHostingAddons.Items)
                {
                    PackageAddonInfo addon = new PackageAddonInfo();
                    addon.PackageAddonId = 0;       //PanelRequest.PackageAddonID;
                    addon.PackageId      = spaceId; //PanelSecurity.PackageId;
                    addon.Comments       = "";
                    addon.PlanId         = Utils.ParseInt(GetDropDownListSelectedValue(item, "ddlPlan"), 0);
                    addon.StatusId       = Utils.ParseInt(ddlStatus.SelectedValue, 0);
                    addon.PurchaseDate   = DateTime.Now;
                    addon.Quantity       = Utils.ParseInt(GetTextBoxText(item, "txtQuantity"), 1);
                    PackageResult addonResult = ES.Services.Packages.AddPackageAddon(addon);
                }

                if (rbPackageQuotas.Checked)
                {
                    //TODO: add logic to recalculate quota
                    //If checked rbPackageQuotas take all addons quota, sum it and replace to main hosting quota
                    //You can look the idea from SpaceEditDetails, but in SpaceEditDetails it is manually, need automatic here
                    //At this moment here is a lot of work, maybe later.
                }

                //PackageContext cntx = PackagesHelper.GetCachedPackageContext(spaceId);
                //string resourceGroup = "VPS2012";
                //if (cntx != null && cntx.Groups.ContainsKey(resourceGroup))
                //{
                //    string pageId = "SpaceVPS2012";
                //    string pageUrl = PortalUtils.NavigatePageURL(
                //pageId, PortalUtils.SPACE_ID_PARAM, spaceId.ToString(), null);
                //    Response.Redirect(pageUrl);
                //}
            }
            catch
            {
                //If something happens here, just ignore it. Addons not so important that a Hosting Space
            }

            if (chkRedirectToCreateVPS.Checked)
            {
                string pageId  = "SpaceVPS2012";
                string pageUrl = PortalUtils.NavigatePageURL(
                    pageId, PortalUtils.SPACE_ID_PARAM, result.Result.ToString(), null);
                Response.Redirect(pageUrl);
            }
            else
            {
                // go to space home
                Response.Redirect(PortalUtils.GetSpaceHomePageUrl(result.Result));
            }
        }
Example #9
0
        private void BindMenu(MenuItemCollection items, XmlNodeList nodes)
        {
            foreach (XmlNode node in nodes)
            {
                string pageId = null;
                if (node.Attributes["pageID"] != null)
                {
                    pageId = node.Attributes["pageID"].Value;
                }

                if (!PortalUtils.PageExists(pageId))
                {
                    continue;
                }

                string url = null;
                if (node.Attributes["url"] != null)
                {
                    url = node.Attributes["url"].Value;
                }

                string title = null;
                if (node.Attributes["title"] != null)
                {
                    title = node.Attributes["title"].Value;
                }

                string target = null;
                if (node.Attributes["target"] != null)
                {
                    target = node.Attributes["target"].Value;
                }

                string resourceGroup = null;
                if (node.Attributes["resourceGroup"] != null)
                {
                    resourceGroup = node.Attributes["resourceGroup"].Value;
                }

                string quota = null;
                if (node.Attributes["quota"] != null)
                {
                    quota = node.Attributes["quota"].Value;
                }

                bool disabled = false;
                if (node.Attributes["disabled"] != null)
                {
                    disabled = Utils.ParseBool(node.Attributes["disabled"].Value, false);
                }

                // get custom page parameters
                XmlNodeList   xmlParameters = node.SelectNodes("Parameters/Add");
                List <string> parameters    = new List <string>();
                foreach (XmlNode xmlParameter in xmlParameters)
                {
                    parameters.Add(xmlParameter.Attributes["name"].Value
                                   + "=" + xmlParameter.Attributes["value"].Value);
                }

                // add menu item
                string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL(
                    pageId, PortalUtils.SPACE_ID_PARAM, currentPackage.ToString(), parameters.ToArray());
                string   pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId);
                MenuItem item     = new MenuItem(pageName, pageId, "", disabled ? null : pageUrl);

                if (!String.IsNullOrEmpty(target))
                {
                    item.Target = target;
                }
                item.Selectable = !disabled;

                // check groups/quotas
                bool   display      = true;
                String displayValue = String.Empty;
                if (cntx != null)
                {
                    display = (String.IsNullOrEmpty(resourceGroup) ||
                               cntx.Groups.ContainsKey(resourceGroup)) &&
                              (String.IsNullOrEmpty(quota) ||
                               (cntx.Quotas.ContainsKey(quota) &&
                                cntx.Quotas[quota].QuotaAllocatedValue != 0));

                    if (!String.IsNullOrEmpty(resourceGroup))
                    {
                        displayValue  = "String.IsNullOrEmpty(resourceGroup): " + String.IsNullOrEmpty(resourceGroup).ToString();
                        displayValue += "| cntx.Groups.ContainsKey(resourceGroup): " + cntx.Groups.ContainsKey(resourceGroup).ToString();
                        displayValue += "| resourceGroup: " + resourceGroup;
                    }
                    if (!String.IsNullOrEmpty(quota))
                    {
                        displayValue += "| String.IsNullOrEmpty(quota): " + String.IsNullOrEmpty(quota).ToString();
                        displayValue += "| cntx.Quotas.ContainsKey(quota): " + cntx.Quotas.ContainsKey(quota).ToString();

                        if (cntx.Quotas.ContainsKey(quota))
                        {
                            displayValue += "| cntx.Quotas[quota].QuotaAllocatedValue: " + cntx.Quotas[quota].QuotaAllocatedValue.ToString();
                        }

                        displayValue += "| quota: " + quota;
                    }
                }

                if (display)
                {
                    // process nested menu items
                    XmlNodeList xmlNestedNodes = node.SelectNodes("MenuItems/MenuItem");
                    BindMenu(item.ChildItems, xmlNestedNodes);
                }
                //item.Text += displayValue;
                //Response.Write("DisplayValue :[" + displayValue + "] ");

                //for Selected == added kuldeep
                if (Request.QueryString.Get("pid") != null)
                {
                    string pid = Request.QueryString.Get("pid").ToString();


                    if (item.NavigateUrl.IndexOf(pid) >= 0)
                    {
                        item.Selected = true;
                    }
                }

                if (display && !(disabled && item.ChildItems.Count == 0))
                {
                    items.Add(item);
                }
            }
        }
Example #10
0
        private void BindMenu(MenuItemCollection items, XmlNodeList nodes)
        {
            foreach (XmlNode node in nodes)
            {
                string pageId = null;
                if (node.Attributes["pageID"] != null)
                {
                    pageId = node.Attributes["pageID"].Value;
                }

                if (!PortalUtils.PageExists(pageId))
                {
                    continue;
                }

                string url = null;
                if (node.Attributes["url"] != null)
                {
                    url = node.Attributes["url"].Value;
                }

                string title = null;
                if (node.Attributes["title"] != null)
                {
                    title = node.Attributes["title"].Value;
                }

                string target = null;
                if (node.Attributes["target"] != null)
                {
                    target = node.Attributes["target"].Value;
                }

                string roles = null;
                if (node.Attributes["roles"] != null)
                {
                    roles = node.Attributes["roles"].Value;
                }

                string selectedUserContext = null;
                if (node.Attributes["selectedUserContext"] != null)
                {
                    selectedUserContext = node.Attributes["selectedUserContext"].Value;
                }

                // get custom page parameters
                XmlNodeList   xmlParameters = node.SelectNodes("Parameters/Add");
                List <string> parameters    = new List <string>();
                foreach (XmlNode xmlParameter in xmlParameters)
                {
                    parameters.Add(xmlParameter.Attributes["name"].Value
                                   + "=" + xmlParameter.Attributes["value"].Value);
                }

                bool display = true;
                // set user role visibility second
                if (!String.IsNullOrEmpty(selectedUserContext))
                {
                    display = false;
                    string[] arrRoles = selectedUserContext.Split(',');
                    string   userRole = PanelSecurity.SelectedUser.Role.ToString();
                    foreach (string role in arrRoles)
                    {
                        if (String.Compare(userRole, role, true) == 0)
                        {
                            display = true;
                            break;
                        }
                    }
                }

                if ((!String.IsNullOrEmpty(roles)) & display)
                {
                    display = false;
                    string[] arrRoles = roles.Split(',');
                    string   userRole = PanelSecurity.LoggedUser.Role.ToString();
                    foreach (string role in arrRoles)
                    {
                        if (String.Compare(userRole, role, true) == 0)
                        {
                            display = true;
                            break;
                        }
                    }
                }

                //Audit Log functionality is disabled when user is in Demo mode
                if ((pageId == "AuditLog") && (PanelSecurity.SelectedUser.IsDemo))
                {
                    display = false;
                }

                // add menu item
                if (display)
                {
                    string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL(
                        pageId, PortalUtils.USER_ID_PARAM, PanelSecurity.SelectedUserId.ToString(), parameters.ToArray());
                    string   pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId);
                    MenuItem item     = new MenuItem(pageName, "", "", pageUrl);

                    if (!String.IsNullOrEmpty(target))
                    {
                        item.Target = target;
                    }

                    //for Selected == added kuldeep
                    if (Request.QueryString.Get("pid") != null)
                    {
                        string pid = Request.QueryString.Get("pid").ToString();

                        //Parent Menu Replacement
                        if (pid.Equals("SpaceHome", StringComparison.CurrentCultureIgnoreCase))
                        {
                            pid = "UserSpaces";
                        }

                        if (item.NavigateUrl.IndexOf(pid) >= 0)
                        {
                            item.Selected = true;
                        }
                    }

                    items.Add(item);

                    // process nested menu items
                    XmlNodeList xmlNestedNodes = node.SelectNodes("MenuItems/MenuItem");
                    BindMenu(item.ChildItems, xmlNestedNodes);
                }
            }
        }
Example #11
0
        private void ShortcutRedirect()
        {
            if (PanelSecurity.EffectiveUser.Role == UserRole.Administrator)
            {
                return; // not for administrators
            }
            string shortcut = Request["shortcut"];

            if ("vps".Equals(shortcut, StringComparison.InvariantCultureIgnoreCase))
            {
                // load hosting spaces
                PackageInfo[] packages = ES.Services.Packages.GetMyPackages(PanelSecurity.EffectiveUserId);
                if (packages.Length == 0)
                {
                    return; // no spaces - exit
                }
                // check if some package has VPS resource enabled
                foreach (PackageInfo package in packages)
                {
                    int            packageId = package.PackageId;
                    PackageContext cntx      = PackagesHelper.GetCachedPackageContext(packageId);
                    if (cntx.Groups.ContainsKey(ResourceGroups.VPS))
                    {
                        // VPS resource found
                        // check created VPS
                        VirtualMachineMetaItemsPaged vms = ES.Services.VPS.GetVirtualMachines(packageId, "", "", "", 0, Int32.MaxValue, false);
                        if (vms.Items.Length == 1)
                        {
                            // one VPS - redirect to its properties screen
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPS", "SpaceID", packageId.ToString(),
                                                                          "ItemID=" + vms.Items[0].ItemID.ToString(), "ctl=vps_general", "moduleDefId=VPS"));
                        }
                        else
                        {
                            // several VPS - redirect to VPS list page
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPS", "SpaceID", packageId.ToString(),
                                                                          "ctl=", "moduleDefId=VPS"));
                        }
                    }


                    if (cntx.Groups.ContainsKey(ResourceGroups.VPS2012))
                    {
                        // VPS resource found
                        // check created VPS
                        VirtualMachineMetaItemsPaged vms = ES.Services.VPS2012.GetVirtualMachines(packageId, "", "", "", 0, Int32.MaxValue, false);
                        if (vms.Items.Length == 1)
                        {
                            // one VPS - redirect to its properties screen
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPS2012", "SpaceID", packageId.ToString(),
                                                                          "ItemID=" + vms.Items[0].ItemID.ToString(), "ctl=vps_general", "moduleDefId=VPS2012"));
                        }
                        else
                        {
                            // several VPS - redirect to VPS list page
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPS2012", "SpaceID", packageId.ToString(),
                                                                          "ctl=", "moduleDefId=VPS2012"));
                        }
                    }


                    if (cntx.Groups.ContainsKey(ResourceGroups.VPSForPC))
                    {
                        // VPS resource found
                        // check created VPS
                        VirtualMachineMetaItemsPaged vms = ES.Services.VPSPC.GetVirtualMachines(packageId, "", "", "", 0, Int32.MaxValue, false);
                        if (vms.Items.Length == 1)
                        {
                            // one VPS - redirect to its properties screen
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPSForPC", "SpaceID", packageId.ToString(),
                                                                          "ItemID=" + vms.Items[0].ItemID.ToString(), "ctl=vps_general", "moduleDefId=VPSForPC"));
                        }
                        else
                        {
                            // several VPS - redirect to VPS list page
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPSForPC", "SpaceID", packageId.ToString(),
                                                                          "ctl=", "moduleDefId=VPSForPC"));
                        }
                    }
                }

                // no VPS resources found
                // redirect to space home
                if (packages.Length == 1)
                {
                    Response.Redirect(PortalUtils.GetSpaceHomePageUrl(packages[0].PackageId));
                }
            }
        }
Example #12
0
 protected string GetNavigateDiskspaceDetails(int packageId)
 {
     return(PortalUtils.NavigatePageURL("DiskspaceReport", PortalUtils.SPACE_ID_PARAM, packageId.ToString(),
                                        "ctl=edit", "moduleDefId=DiskspaceReport"));
 }