Example #1
0
        /// <summary>
        /// The BindData helper method is used to update the tab's
        ///   layout panes with the current configuration information
        /// </summary>
        /// <remarks>
        /// </remarks>
        private void BindData()
        {
            var page = this.PortalSettings.ActivePage;

            // Populate Page Names, etc.
            this.txtPageID.Text          = page.PageID.ToString();
            this.tabName.Text            = page.PageName;
            this.friendlyUrl.Text        = page.FriendlyURL;
            this.mobilePageName.Text     = page.MobilePageName;
            this.showMobile.Checked      = page.ShowMobile;
            this.lblCurrentPageLink.Text = HttpUrlBuilder.BuildUrl(page.PageID);

            // Populate the "ParentPage" Data
            var t     = new PagesDB();
            var items = t.GetPagesParent(this.PortalSettings.PortalID, this.PageID);

            this.parentPage.DataSource = items;
            this.parentPage.DataBind();

            if (this.parentPage.Items.FindByValue(page.ParentPageID.ToString()) != null)
            {
                // parentPage.Items.FindByValue( tab.ParentPageID.ToString() ).Selected = true;
                this.parentPage.SelectedValue = page.ParentPageID.ToString();
            }

            // Translate
            if (this.parentPage.Items.FindByText(" ROOT_LEVEL") != null)
            {
                this.parentPage.Items.FindByText(" ROOT_LEVEL").Text = General.GetString(
                    "ROOT_LEVEL", "Root Level", this.parentPage);
            }

            // Populate checkbox list with all security roles for this portal
            // and "check" the ones already configured for this tab
            var users = new UsersDB();
            var roles = users.GetPortalRoles(this.PortalSettings.PortalAlias);

            // Clear existing items in checkboxlist
            this.authRoles.Items.Clear();

            foreach (var role in roles.Where(rn => rn.Name.ToLower() != "admins"))
            {
                var item = new ListItem();
                item.Text  = role.Name;
                item.Value = role.Id.ToString();

                if (page.AuthorizedRoles.LastIndexOf(item.Text) > -1)
                {
                    item.Selected = true;
                }

                this.authRoles.Items.Add(item);
            }

            //load users
            UserPagePermissionDB userPp = new UserPagePermissionDB();

            Session["PageAuthUsers_" + this.PageID] = userPp.GetAllUsers(this.PageID, PortalSettings.CurrentUser.Identity.ProviderUserKey);
            gdvUsersAuth.DataSource = Session["PageAuthUsers_" + this.PageID];
            gdvUsersAuth.DataBind();

            // Populate the "Add Module" Data
            var m       = new ModulesDB();
            var modules = new SortedList <string, string>();
            var drCurrentModuleDefinitions = m.GetCurrentModuleDefinitions(this.PortalSettings.PortalID);
            var htmlId = "0";

            try
            {
                foreach (var item in drCurrentModuleDefinitions)
                {
                    if ((!modules.ContainsKey(item.FriendlyName)) &&
                        (PortalSecurity.IsInRoles("Admins") || !item.Admin))
                    {
                        modules.Add(

                            item.FriendlyName,
                            item.ModuleDefId.ToString());
                        if (item.FriendlyName.ToString().Equals("HTML Content"))
                        {
                            htmlId = item.ModuleDefId.ToString();
                        }
                    }
                }
            }
            finally
            {
            }

            this.moduleType.DataSource = modules;
            this.moduleType.DataBind();
            this.moduleType.SelectedValue = htmlId;
        }