Example #1
0
        public static bool CheckGroupQuotaEnabled(int packageId, string groupName, string quotaName)
        {
            // load package context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(packageId);

            if (cntx == null)
            {
                return(false);
            }

            // check group
            if (!cntx.Groups.ContainsKey(groupName))
            {
                return(false);
            }

            // check wildcard quota name
            if (!string.IsNullOrEmpty(groupName) && quotaName.Substring(groupName.Length) == ".*")
            {
                return(true);
            }

            // check quota
            if (cntx.Quotas.ContainsKey(quotaName))
            {
                return(!cntx.Quotas[quotaName].QuotaExhausted);
            }

            return(false);
        }
Example #2
0
        public void BindQuota()
        {
            try
            {
                // load package context
                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

                // get quota
                if (cntx.Quotas.ContainsKey(QuotaName))
                {
                    QuotaValueInfo quota = cntx.Quotas[QuotaName];
                    quotaViewer.QuotaTypeId    = quota.QuotaTypeId;
                    quotaViewer.QuotaUsedValue = quota.QuotaUsedValue;
                    quotaViewer.QuotaValue     = quota.QuotaAllocatedValue;
                    quotaViewer.QuotaAvailable = -1;
                    //this.Visible = quota.QuotaAllocatedValue != 0;
                }
                else
                {
                    this.Visible               = false;
                    quotaViewer.QuotaTypeId    = 1; // bool
                    quotaViewer.QuotaUsedValue = 0;
                    quotaViewer.QuotaValue     = 0;
                    quotaViewer.QuotaAvailable = -1;
                }
            }
            catch
            {
                /* do nothing */
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lnkBackup.NavigateUrl          = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "backup");
            lnkRestore.NavigateUrl         = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "restore");
            lnkImportResources.NavigateUrl = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "import");

            lnkBackup.Visible          = lnkRestore.Visible = PortalUtils.PageExists("Backup");
            lnkImportResources.Visible = (PanelSecurity.PackageId >= 1 &&
                                          PanelSecurity.LoggedUser.Role == UserRole.Administrator);

            if (PanelSecurity.SelectedUser.RoleId.Equals(1))
            {
                lnkBackup.Visible = lnkRestore.Visible = ToolsHeader.Visible;
            }


            UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);

            if (user != null)
            {
                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
                if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
                {
                    lnkBackup.Visible = lnkRestore.Visible = ToolsHeader.Visible = false;
                }
            }
        }
        private void BindValues()
        {
            Organization   org  = ES.Services.Organizations.GetOrganization(PanelRequest.ItemID);
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            string quotaName = "";

            if (cntx.Groups.ContainsKey(ResourceGroups.HostedCRM2013))
            {
                quotaName = Quotas.CRM2013_MAXDATABASESIZE;
            }
            else if (cntx.Groups.ContainsKey(ResourceGroups.HostedCRM))
            {
                quotaName = Quotas.CRM_MAXDATABASESIZE;
            }

            int limitDBSize = cntx.Quotas[quotaName].QuotaAllocatedValue;

            //maxStorageSettingsValue.ParentQuotaValue = limitDBSize;
            maxStorageSettingsValue.ParentQuotaValue = -1;

            long maxDBSize = ES.Services.CRM.GetMaxDBSize(PanelRequest.ItemID, PanelSecurity.PackageId);
            long DBSize    = ES.Services.CRM.GetDBSize(PanelRequest.ItemID, PanelSecurity.PackageId);

            DBSize    = DBSize > 0 ? DBSize = DBSize / (1024 * 1024) : DBSize;
            maxDBSize = maxDBSize > 0 ? maxDBSize = maxDBSize / (1024 * 1024) : maxDBSize;

            maxStorageSettingsValue.QuotaValue = Convert.ToInt32(maxDBSize);

            lblDBSize.Text    = SizeValueToString(DBSize);
            lblMAXDBSize.Text = SizeValueToString(maxDBSize);

            lblLimitDBSize.Text = SizeValueToString(limitDBSize);
        }
Example #5
0
        public static bool IsVirtualMachineManagementAllowed(int packageId)
        {
            bool           manageAllowed = false;
            PackageContext cntx          = PackagesHelper.GetCachedPackageContext(packageId);

            if (cntx.Quotas.ContainsKey(Quotas.VPSForPC_MANAGING_ALLOWED))
            {
                manageAllowed = !cntx.Quotas[Quotas.VPSForPC_MANAGING_ALLOWED].QuotaExhausted;
            }

            if (PanelSecurity.EffectiveUser.Role == UserRole.Administrator)
            {
                manageAllowed = true;
            }
            else if (PanelSecurity.EffectiveUser.Role == UserRole.Reseller)
            {
                // check if the reseller is allowed to manage on its parent level
                PackageInfo package = ES.Services.Packages.GetPackage(PanelSecurity.PackageId);
                if (package.UserId != PanelSecurity.EffectiveUserId)
                {
                    cntx = PackagesHelper.GetCachedPackageContext(package.ParentPackageId);
                    if (cntx != null && cntx.Quotas.ContainsKey(Quotas.VPSForPC_MANAGING_ALLOWED))
                    {
                        manageAllowed = !cntx.Quotas[Quotas.VPSForPC_MANAGING_ALLOWED].QuotaExhausted;
                    }
                }
            }
            return(manageAllowed);
        }
        private void BindControls()
        {
            // set navigate URLs
            DomainLink.NavigateUrl            = GetAddDomainLink("Domain");
            SubDomainLink.NavigateUrl         = GetAddDomainLink("SubDomain");
            ProviderSubDomainLink.NavigateUrl = GetAddDomainLink("ProviderSubDomain");
            DomainPointerLink.NavigateUrl     = GetAddDomainLink("DomainPointer");

            // load package context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            DomainLink.Enabled = (cntx.Quotas.ContainsKey(Quotas.OS_DOMAINS) && !cntx.Quotas[Quotas.OS_DOMAINS].QuotaExhausted);

            DomainInfo[] myDomains        = ES.Services.Servers.GetMyDomains(PanelSecurity.PackageId);
            bool         enableSubDomains = false;

            foreach (DomainInfo domain in myDomains)
            {
                if (!domain.IsSubDomain && !domain.IsInstantAlias && !domain.IsDomainPointer)
                {
                    enableSubDomains = true;
                    break;
                }
            }
            SubDomainLink.Enabled = (cntx.Quotas.ContainsKey(Quotas.OS_SUBDOMAINS) && !cntx.Quotas[Quotas.OS_SUBDOMAINS].QuotaExhausted &&
                                     enableSubDomains);

            ProviderSubDomainPanel.Visible = (cntx.Quotas.ContainsKey(Quotas.OS_SUBDOMAINS) && !cntx.Quotas[Quotas.OS_SUBDOMAINS].QuotaExhausted &&
                                              ES.Services.Servers.GetResellerDomains(PanelSecurity.PackageId).Length > 0);

            DomainPointerLink.Enabled = (cntx.Quotas.ContainsKey(Quotas.OS_DOMAINPOINTERS) && !cntx.Quotas[Quotas.OS_DOMAINPOINTERS].QuotaExhausted);
        }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // load package context
            cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            // bind root node
            BindMenu(menu.Items, PortalUtils.GetModuleMenuItems(this));
        }
Example #8
0
        private void BindQuotas()
        {
            // load package context
            cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            int packageId = ES.Services.Packages.GetPackage(PanelSecurity.PackageId).PackageId;

            lnkViewBandwidthDetails.NavigateUrl = GetNavigateBandwidthDetails(packageId);
            lnkViewDiskspaceDetails.NavigateUrl = GetNavigateDiskspaceDetails(packageId);
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // load package context
            cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            // bind root node
            MenuItem rootItem = new MenuItem(locMenuTitle.Text);

            rootItem.Selectable = false;

            menu.Items.Add(rootItem);

            BindMenu(rootItem.ChildItems, PortalUtils.GetModuleMenuItems(this));
        }
Example #10
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"));
                        }
                    }
                }

                // no VPS resources found
                // redirect to space home
                if (packages.Length == 1)
                {
                    Response.Redirect(PortalUtils.GetSpaceHomePageUrl(packages[0].PackageId));
                }
            }
        }
Example #11
0
        protected int ChangeUsersServiceLevel(List <int> userIds)
        {
            if (ddlServiceLevels.SelectedItem == null)
            {
                return(0);
            }

            string levelName = ddlServiceLevels.SelectedItem.Text;

            if (string.IsNullOrEmpty(levelName))
            {
                return(0);
            }

            int levelId;

            if (!int.TryParse(ddlServiceLevels.SelectedItem.Value, out levelId))
            {
                return(0);
            }


            string quotaName = Quotas.SERVICE_LEVELS + levelName;

            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            if (!cntx.Quotas.ContainsKey(quotaName))
            {
                return(0);
            }


            List <OrganizationUser> users = new List <OrganizationUser>();

            foreach (int id in userIds)
            {
                users.Add(ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID, id));
            }


            int usersCount = users.Count - users.Where(x => (x.LevelId == levelId)).Count();

            if (!CheckServiceLevelQuota(cntx.Quotas[quotaName], usersCount))
            {
                return(-1);
            }

            return(ChangeUsersSettings(userIds, null, levelId, null));
        }
Example #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Remove Service Level item and VIP item from Action List if current Hosting plan does not allow Service Levels
            if (!PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId).Groups.ContainsKey(ResourceGroups.ServiceLevels))
            {
                RemoveActionItem(UserActionTypes.SetServiceLevel);
                RemoveActionItem(UserActionTypes.SetVIP);
                RemoveActionItem(UserActionTypes.UnsetVIP);
            }

            if (!ShowSetMailboxPlan)
            {
                RemoveActionItem(UserActionTypes.SetMailboxPlan);
            }
        }
        private void Save()
        {
            try
            {
                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

                string quotaName = "";
                if (cntx.Groups.ContainsKey(ResourceGroups.HostedCRM2013))
                {
                    quotaName = Quotas.CRM2013_MAXDATABASESIZE;
                }
                else if (cntx.Groups.ContainsKey(ResourceGroups.HostedCRM))
                {
                    quotaName = Quotas.CRM_MAXDATABASESIZE;
                }

                long limitSize = cntx.Quotas[quotaName].QuotaAllocatedValue;

                long maxSize = maxStorageSettingsValue.QuotaValue;

                if (limitSize != -1)
                {
                    if (maxSize == -1)
                    {
                        maxSize = limitSize;
                    }
                    if (maxSize > limitSize)
                    {
                        maxSize = limitSize;
                    }
                }

                if (maxSize > 0)
                {
                    maxSize = maxSize * 1024 * 1024;
                }

                ES.Services.CRM.SetMaxDBSize(PanelRequest.ItemID, PanelSecurity.PackageId, maxSize);

                messageBox.ShowSuccessMessage("HOSTED_SHAREPOINT_UPDATE_QUOTAS");

                BindValues();
            }
            catch (Exception)
            {
                messageBox.ShowErrorMessage("HOSTED_SHAREPOINT_UPDATE_QUOTAS");
            }
        }
Example #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // bind quotas
            BindQuotas();

            UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);

            if (user != null)
            {
                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
                if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
                {
                    btnViewQuotas.Visible = lnkViewDiskspaceDetails.Visible = false;
                }
            }
        }
Example #15
0
        protected int ChangeUsersServiceLevel(List <int> userIds)
        {
            if (ddlServiceLevels.SelectedItem == null)
            {
                return(0);
            }

            string levelName = ddlServiceLevels.SelectedItem.Text;

            if (string.IsNullOrEmpty(levelName))
            {
                return(0);
            }

            int levelId;

            if (string.IsNullOrEmpty(ddlServiceLevels.SelectedItem.Value))
            {
                return(ChangeUsersSettings(userIds, null, 0, null));
            }

            if (!int.TryParse(ddlServiceLevels.SelectedItem.Value, out levelId))
            {
                return(0);
            }

            string quotaName = Quotas.SERVICE_LEVELS + levelName;

            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            if (!cntx.Quotas.ContainsKey(quotaName))
            {
                return(0);
            }

            OrganizationStatistics stats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID);

            List <OrganizationUser> users = userIds.Select(id => ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID, id)).ToList();
            int usersCount = users.Count - users.Count(x => x.LevelId == levelId);

            if (!CheckServiceLevelQuota(levelName, stats.ServiceLevels, usersCount))
            {
                return(-1);
            }

            return(ChangeUsersSettings(userIds, null, levelId, null));
        }
Example #16
0
        private void BindControls()
        {
            // set navigate URLs
            DomainLink.NavigateUrl            = GetAddDomainLink("Domain");
            SubDomainLink.NavigateUrl         = GetAddDomainLink("SubDomain");
            ProviderSubDomainLink.NavigateUrl = GetAddDomainLink("ProviderSubDomain");
            DomainPointerLink.NavigateUrl     = GetAddDomainLink("DomainPointer");

            // load package context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            DomainLink.Enabled = (cntx.Quotas.ContainsKey(Quotas.OS_DOMAINS) && !cntx.Quotas[Quotas.OS_DOMAINS].QuotaExhausted);

            if (DomainLink.Enabled)
            {
                UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);

                if (user != null)
                {
                    if (user.Role == UserRole.User)
                    {
                        DomainLink.Enabled = !Utils.CheckQouta(Quotas.OS_NOTALLOWTENANTCREATEDOMAINS, cntx);
                    }
                }
            }



            DomainInfo[] myDomains        = ES.Services.Servers.GetMyDomains(PanelSecurity.PackageId);
            bool         enableSubDomains = false;

            foreach (DomainInfo domain in myDomains)
            {
                if (!domain.IsSubDomain && !domain.IsInstantAlias && !domain.IsDomainPointer)
                {
                    enableSubDomains = true;
                    break;
                }
            }
            SubDomainLink.Enabled = (cntx.Quotas.ContainsKey(Quotas.OS_SUBDOMAINS) && !cntx.Quotas[Quotas.OS_SUBDOMAINS].QuotaExhausted &&
                                     enableSubDomains);

            ProviderSubDomainPanel.Visible = (cntx.Quotas.ContainsKey(Quotas.OS_SUBDOMAINS) && !cntx.Quotas[Quotas.OS_SUBDOMAINS].QuotaExhausted &&
                                              ES.Services.Servers.GetResellerDomains(PanelSecurity.PackageId).Length > 0);

            DomainPointerLink.Enabled = (cntx.Quotas.ContainsKey(Quotas.OS_DOMAINPOINTERS) && !cntx.Quotas[Quotas.OS_DOMAINPOINTERS].QuotaExhausted);
        }
Example #17
0
        public void FillDatabaseVersions(int packageId, ListItemCollection items, List <string> versions)
        {
            if (versions == null)
            {
                return;
            }

            // load package context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(packageId);

            items.Clear();
            AddDatabaseVersion(cntx, ResourceGroups.MsSql2000, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MsSql2005, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MsSql2008, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MySql4, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MySql5, items, versions);
        }
Example #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindSpace();

                UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);

                if (user != null)
                {
                    PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
                    if ((user.Role == UserRole.User) & (Utils.CheckQouta(Quotas.EXCHANGE2007_ISCONSUMER, cntx)))
                    {
                        lnkSummaryLetter.Visible = false;
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            domainsSelectDomainControl.PackageId = PanelSecurity.PackageId;

            if (!IsPostBack)
            {
                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

                //if (Utils.CheckQouta(Quotas.WEB_ENABLEHOSTNAMESUPPORT, cntx))
                //{
                txtHostName.Visible = lblTheDotInTheMiddle.Visible = true;
                UserSettings settings = ES.Services.Users.GetUserSettings(PanelSecurity.LoggedUserId, UserSettings.WEB_POLICY);
                txtHostName.Text = String.IsNullOrEmpty(settings["HostName"]) ? "" : settings["HostName"];
                //}
                //else
                //txtHostName.Visible = lblTheDotInTheMiddle.Visible = false;
            }
        }
Example #20
0
        protected void FillServiceLevelsList()
        {
            if (GridView == null || String.IsNullOrWhiteSpace(CheckboxesName))
            {
                return;
            }

            List <int> ids = Utils.GetCheckboxValuesFromGrid <int>(GridView, CheckboxesName);
            List <OrganizationUser> users = new List <OrganizationUser>();

            foreach (int id in ids)
            {
                users.Add(ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID, id));
            }

            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            if (cntx.Groups.ContainsKey(ResourceGroups.ServiceLevels))
            {
                List <ServiceLevel> enabledServiceLevels = new List <ServiceLevel>();

                foreach (var quota in cntx.Quotas.Where(x => x.Key.Contains(Quotas.SERVICE_LEVELS)))
                {
                    foreach (ServiceLevel serviceLevel in ES.Services.Organizations.GetSupportServiceLevels())
                    {
                        int usersCount = users.Count - users.Where(x => (x.LevelId == serviceLevel.LevelId)).Count();

                        if (quota.Key.Replace(Quotas.SERVICE_LEVELS, "") == serviceLevel.LevelName && CheckServiceLevelQuota(quota.Value, usersCount))
                        {
                            enabledServiceLevels.Add(serviceLevel);
                        }
                    }
                }

                ddlServiceLevels.DataSource     = enabledServiceLevels;
                ddlServiceLevels.DataTextField  = "LevelName";
                ddlServiceLevels.DataValueField = "LevelId";
                ddlServiceLevels.DataBind();

                ddlServiceLevels.Items.Insert(0, new ListItem("<Select Service Level>", string.Empty));
                ddlServiceLevels.Items.FindByValue(string.Empty).Selected = true;
            }
        }
        private void ToggleControls()
        {
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            rowDedicatedIP.Visible = rbDedicatedIP.Checked;
            
            if (Utils.CheckQouta(Quotas.WEB_ENABLEHOSTNAMESUPPORT, cntx))
            {
                txtHostName.Visible = chkIgnoreGlobalDNSRecords.Visible = lblIgnoreGlobalDNSRecords.Visible = lblTheDotInTheMiddle.Visible = true;
                UserSettings settings = ES.Services.Users.GetUserSettings(PanelSecurity.LoggedUserId, UserSettings.WEB_POLICY);
                txtHostName.Text = String.IsNullOrEmpty(settings["HostName"]) ? "" : settings["HostName"];
                chkIgnoreGlobalDNSRecords.Checked = false;
            }
            else
            {
                txtHostName.Visible = chkIgnoreGlobalDNSRecords.Visible = lblIgnoreGlobalDNSRecords.Visible = lblTheDotInTheMiddle.Visible = false;
                chkIgnoreGlobalDNSRecords.Checked = true;
                txtHostName.Text = "";
                domainsSelectDomainControl.HideWebSites = true;
            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // bind controls
                BindControls();

                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

                if (Utils.CheckQouta(Quotas.WEB_ENABLEHOSTNAMESUPPORT, cntx))
                {
                    lblHostName.Visible = txtHostName.Visible = true;
                    UserSettings settings = ES.Services.Users.GetUserSettings(PanelSecurity.LoggedUserId, UserSettings.WEB_POLICY);
                    txtHostName.Text = String.IsNullOrEmpty(settings["HostName"]) ? "" : settings["HostName"];
                }
                else
                {
                    lblHostName.Visible = txtHostName.Visible = false;
                    txtHostName.Text    = "";
                }

                DomainType type = GetDomainType(Request["DomainType"]);

                if ((PanelSecurity.LoggedUser.Role == UserRole.User) & (type != DomainType.SubDomain))
                {
                    if (cntx.Groups.ContainsKey(ResourceGroups.Dns))
                    {
                        if (!PackagesHelper.CheckGroupQuotaEnabled(PanelSecurity.PackageId, ResourceGroups.Dns, Quotas.DNS_EDITOR))
                        {
                            this.DisableControls = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("DOMAIN_GET_DOMAIN", ex);
            }
        }
        private void ApplyPackageContextRestrictions(int packageId)
        {
            // load context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(packageId);

            bool intervalTasksAllowed = (cntx.Quotas.ContainsKey(Quotas.OS_SCHEDULEDINTERVALTASKS) &&
                                         cntx.Quotas[Quotas.OS_SCHEDULEDINTERVALTASKS].QuotaAllocatedValue != 0);

            if (!intervalTasksAllowed)
            {
                ddlSchedule.Items.Remove(ddlSchedule.Items.FindByValue("Interval"));
            }

            // check if this an admin
            if (PanelSecurity.LoggedUser.Role != UserRole.Administrator)
            {
                // remove "high" priorities
                ddlPriority.Items.Remove(ddlPriority.Items.FindByValue("Highest"));
                ddlPriority.Items.Remove(ddlPriority.Items.FindByValue("AboveNormal"));
                ddlPriority.Items.Remove(ddlPriority.Items.FindByValue("Normal"));
            }
        }
Example #24
0
        private int EnableDns(bool enable, List <int> ids)
        {
            foreach (var id in ids)
            {
                // load domain
                DomainInfo domain = ES.Services.Servers.GetDomain(id);
                if (domain == null)
                {
                    continue;
                }

                // load package context
                PackageContext cntx       = PackagesHelper.GetCachedPackageContext(domain.PackageId);
                bool           dnsEnabled = cntx.Groups.ContainsKey(ResourceGroups.Dns);
                if (!dnsEnabled)
                {
                    continue;
                }

                int result;

                if (enable)
                {
                    result = ES.Services.Servers.EnableDomainDns(id);
                }
                else
                {
                    result = ES.Services.Servers.DisableDomainDns(id);
                }


                if (result < 0)
                {
                    return(result);
                }
            }

            return(0);
        }
Example #25
0
        protected void FillServiceLevelsList()
        {
            if (GridView == null || String.IsNullOrWhiteSpace(CheckboxesName))
            {
                return;
            }

            List <int> ids = Utils.GetCheckboxValuesFromGrid <int>(GridView, CheckboxesName);
            List <OrganizationUser> users = ids.Select(id => ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID, id)).ToList();
            OrganizationStatistics  stats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID);

            PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);

            if (cntx.Groups.ContainsKey(ResourceGroups.ServiceLevels))
            {
                List <ServiceLevel> enabledServiceLevels = new List <ServiceLevel>();

                foreach (ServiceLevel serviceLevel in ES.Services.Organizations.GetSupportServiceLevels())
                {
                    int usersCount = users.Count - users.Count(x => (x.LevelId == serviceLevel.LevelId));

                    if (CheckServiceLevelQuota(serviceLevel.LevelName, stats.ServiceLevels, usersCount))
                    {
                        enabledServiceLevels.Add(serviceLevel);
                    }
                }

                ddlServiceLevels.DataSource     = enabledServiceLevels;
                ddlServiceLevels.DataTextField  = "LevelName";
                ddlServiceLevels.DataValueField = "LevelId";
                ddlServiceLevels.DataBind();

                ddlServiceLevels.Items.Insert(0, new ListItem("<Select Service Level>", string.Empty));
                ddlServiceLevels.Items.FindByValue(string.Empty).Selected = true;
            }
        }
        public MenuItemCollection GetIconsDataSource(int packageId)
        {
            // load package context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(packageId);

            // init collection
            MenuItemCollection items = new MenuItemCollection();

            // get icons list
            foreach (XmlNode xmlNode in xmlIcons)
            {
                // create icon item
                MenuItem iconItem = CreateMenuItem(cntx, xmlNode);
                if (iconItem == null)
                {
                    continue;
                }

                // add into list
                items.Add(iconItem);
            }

            return(items);
        }
Example #27
0
        public static bool CheckGroupQuotaEnabled(int packageId, string groupName, string quotaName)
        {
            // load package context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(packageId);

            if (cntx == null)
            {
                return(false);
            }

            // check group
            if (!cntx.Groups.ContainsKey(groupName))
            {
                return(false);
            }

            // check quota
            if (cntx.Quotas.ContainsKey(quotaName))
            {
                return(!cntx.Quotas[quotaName].QuotaExhausted);
            }

            return(false);
        }
Example #28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Remove DNS items if current Hosting plan does not allow it
            if (!PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId).Groups.ContainsKey(ResourceGroups.Dns))
            {
                RemoveActionItem(DomainActionTypes.EnableDns);
                RemoveActionItem(DomainActionTypes.DisableDns);
            }

            // Remove Instant Alias items if current Hosting plan does not allow it
            PackageSettings packageSettings = ES.Services.Packages.GetPackageSettings(PanelSecurity.PackageId, PackageSettings.INSTANT_ALIAS);

            if (packageSettings == null || String.IsNullOrEmpty(packageSettings["InstantAlias"]))
            {
                RemoveActionItem(DomainActionTypes.CreateInstantAlias);
                RemoveActionItem(DomainActionTypes.DeleteInstantAlias);
            }

            // hide control if no actions allowed
            if (ActionsList.Items.Count <= 1)
            {
                Visible = false;
            }
        }
Example #29
0
        private void BindDomain()
        {
            try
            {
                // load domain
                DomainInfo domain = ES.Services.Servers.GetDomain(PanelRequest.DomainID);
                if (domain == null)
                {
                    RedirectToBrowsePage();
                }


                // load package context
                PackageContext cntx = PackagesHelper.GetCachedPackageContext(domain.PackageId);

                DomainName.Text = domain.DomainName;

                bool webEnabled  = cntx.Groups.ContainsKey(ResourceGroups.Web);
                bool mailEnabled = cntx.Groups.ContainsKey(ResourceGroups.Mail);
                bool dnsEnabled  = cntx.Groups.ContainsKey(ResourceGroups.Dns);

                // web site
                if (webEnabled && domain.WebSiteId > 0)
                {
                    WebSitePanel.Visible      = true;
                    WebSiteAliasPanel.Visible = true;

                    WebSiteName.Text            = domain.WebSiteName;
                    WebSiteParkedPanel.Visible  = (String.Compare(domain.WebSiteName, domain.DomainName, true) == 0);
                    WebSitePointedPanel.Visible = !WebSiteParkedPanel.Visible;

                    BrowseWebSite.NavigateUrl = "http://" + domain.DomainName;
                }

                // mail domain
                if (mailEnabled && domain.MailDomainId > 0)
                {
                    MailDomainPanel.Visible      = true;
                    MailDomainAliasPanel.Visible = true;

                    MailDomainName.Text          = domain.MailDomainName;
                    MailEnabledPanel.Visible     = (String.Compare(domain.MailDomainName, domain.DomainName, true) == 0);
                    PointMailDomainPanel.Visible = !MailEnabledPanel.Visible;
                }

                // DNS
                if (dnsEnabled)
                {
                    DnsPanel.Visible         = true;
                    DnsEnabledPanel.Visible  = (domain.ZoneItemId > 0);
                    DnsDisabledPanel.Visible = !DnsEnabledPanel.Visible;

                    // dns editor
                    EditDnsRecords.Visible = (cntx.Quotas.ContainsKey(Quotas.DNS_EDITOR) &&
                                              cntx.Quotas[Quotas.DNS_EDITOR].QuotaAllocatedValue != 0) ||
                                             PanelSecurity.LoggedUser.Role == UserRole.Administrator;
                }

                // instant alias
                bool instantAliasAllowed = !String.IsNullOrEmpty(domain.InstantAliasName);
                bool instantAliasExists  = (domain.InstantAliasId > 0);
                if (dnsEnabled &&
                    instantAliasAllowed &&
                    !domain.IsDomainPointer && !domain.IsInstantAlias)
                {
                    InstantAliasPanel.Visible    = true;
                    InstantAliasEnabled.Visible  = instantAliasExists;
                    InstantAliasDisabled.Visible = !instantAliasExists;

                    // load instant alias
                    DomainInfo instantAlias = ES.Services.Servers.GetDomain(domain.InstantAliasId);
                    if (instantAlias != null)
                    {
                        WebSiteAliasPanel.Visible    = (instantAlias.WebSiteId > 0);
                        MailDomainAliasPanel.Visible = (instantAlias.MailDomainId > 0);
                    }

                    // instant alias
                    InstantAliasName.Text = domain.InstantAliasName;

                    // web site alias
                    WebSiteAlias.Text = WebSiteAlias.NavigateUrl = "http://" + domain.InstantAliasName;

                    // mail domain alias
                    MailDomainAlias.Text = "@" + domain.InstantAliasName;
                }

                // resellers
                AllowSubDomains.Checked = domain.HostingAllowed;
                if (PanelSecurity.EffectiveUser.Role != UserRole.User &&
                    !(domain.IsDomainPointer || domain.IsSubDomain || domain.IsInstantAlias))
                {
                    ResellersPanel.Visible = true;
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("DOMAIN_GET_DOMAIN", ex);
                return;
            }
        }
Example #30
0
        private void BindItem()
        {
            try
            {
                if (!IsPostBack)
                {
                    // load item if required
                    if (PanelRequest.ItemID > 0)
                    {
                        // existing item
                        try
                        {
                            item = ES.Services.MailServers.GetMailAccount(PanelRequest.ItemID);
                        }
                        catch (Exception ex)
                        {
                            ShowErrorMessage("MAIL_GET_ACCOUNT", ex);
                            return;
                        }

                        if (item != null)
                        {
                            // save package info
                            ViewState["PackageId"]    = item.PackageId;
                            mailEditAddress.PackageId = item.PackageId;
                            passwordControl.SetPackagePolicy(item.PackageId, UserSettings.MAIL_POLICY, "AccountPasswordPolicy");
                        }
                        else
                        {
                            RedirectToBrowsePage();
                        }
                    }
                    else
                    {
                        // new item
                        ViewState["PackageId"]    = PanelSecurity.PackageId;
                        mailEditAddress.PackageId = PanelSecurity.PackageId;
                        passwordControl.SetPackagePolicy(PanelSecurity.PackageId, UserSettings.MAIL_POLICY, "AccountPasswordPolicy");
                    }
                }

                // load provider control
                LoadProviderControl((int)ViewState["PackageId"], "Mail", providerControl, "EditAccount.ascx");
                // load package context
                PackageContext cntx = PackagesHelper.GetCachedPackageContext((int)ViewState["PackageId"]);

                if (!IsPostBack)
                {
                    // set messagebox size textbox visibility
                    HandleMaxMailboxSizeLimitDisplay(cntx);
                    // bind item to controls
                    if (item != null)
                    {
                        // bind item to controls
                        mailEditAddress.Email    = item.Name;
                        mailEditAddress.EditMode = true;
                        passwordControl.EditMode = true;
                        // Display currently set max mailbox size limit
                        SetMaxMailboxSizeLimit(item.MaxMailboxSize);
                        // other controls
                        IMailEditAccountControl ctrl = (IMailEditAccountControl)providerControl.Controls[0];
                        ctrl.BindItem(item);
                    }
                }
            }
            catch
            {
                ShowWarningMessage("INIT_SERVICE_ITEM_FORM");
                DisableFormControls(this, btnCancel);
                return;
            }
        }