protected void LoadModules()
        {
            List <WebModuleInfo> modules = WebModule.GetModules(_instanceId);

            ModulesGridView.DataSource = modules;
            ModulesGridView.DataBind();
        }
        protected void EditDeleteButton_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            //prevent malicious deletes.
            if (_page.InstanceId == Webpage.RootNavigationId)
            {
                throw new InvalidOperationException("The portal root may not be deleted.");
            }
            if (_page.ParentInstanceId == Webpage.RootNavigationId)
            {
                throw new InvalidOperationException("Root pages (website roots) may not be deleted.");
            }

            if (!_page.IsAlias)
            {
                if (_page.Children.Count > 0)
                {
                    throw new InvalidOperationException("Pages with children may not be deleted.");
                }

                System.Collections.Generic.List <WebModuleInfo> modules = WebModule.GetModules(_instanceId);
                if (modules.Count > 0)
                {
                    throw new InvalidOperationException("Pages with modules may not be deleted.");
                }
            }

            _urlReferrer += _page.ParentInstanceId.Value;
            Webpage.DeleteWebpage(_instanceId);
            Response.Redirect(_urlReferrer);
        }
Beispiel #3
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            if (PlaceholderDropDownList.Items.Count == 0)
            {
                throw new InvalidOperationException("The template (master page) must have a content placeholder.");
            }

            WebModuleType selectedModuleType = GetSelectedModuleType();
            WebModuleInfo module             = null;
            int           aliasModuleId      = -1;
            string        placeholder        = PlaceholderDropDownList.SelectedItem.ToString();
            string        instanceName       = ModuleNameTextBox.Text.Trim();

            if (string.IsNullOrEmpty(instanceName))
            { //auto-generate a unique name for the module instance
                int i = 1;
                List <WebModuleInfo> pageModules = WebModule.GetModules(_instanceId);
                do
                {
                    instanceName = selectedModuleType.Name + " " + i++;
                } while (pageModules.Exists(
                             delegate(WebModuleInfo m) { return(m.Name == instanceName); }));
            }

            if (UseExistingModule.Checked)
            {
                aliasModuleId = int.Parse(ExistingModulesPagesSelect.Text);
            }

            module = WebModule.CreateModule(
                instanceName,
                selectedModuleType.WebApplicationType.Name,
                selectedModuleType.Name,
                _pageId,
                placeholder,
                aliasModuleId);

            Response.Redirect(module.GetAddUrl());
        }
Beispiel #4
0
        List <PageSetting> GetPageSettings(WebpageInfo page)
        {
            List <PageSetting> pageSettings = new List <PageSetting>();

            // check IsAlias before checking ExternalUrl (otherwise an alias
            //_to_ an external link will look like an external link).
            if (page.IsAlias)
            {
                //TODO: add alias settings
                //if (AllowEditPage()) pageSettings.Add(new PageSetting("AliasSettings", "Alias Settings", "Settings"));

                if (!_isSystemRoot && Permission.AllowDeletePage())
                {
                    pageSettings.Add(new PageSetting("PageDelete", "Delete Alias", "Delete"));
                }
            }
            else if (!string.IsNullOrEmpty(page.ExternalUrl))
            { //the navigation instance is an external link.
                if (Permission.AllowManagePage())
                {
                    pageSettings.Add(new PageSetting("LinkSettings", "Link Settings", "Settings"));
                }
                if (!_isSystemRoot && Permission.AllowDeletePage())
                {
                    bool bEnableDelete = false;
                    if (page.Children.Count == 0)
                    {
                        bEnableDelete = true;
                    }

                    string strDisabledToolTip = "This link cannot be deleted because it contains subpages.  Please first delete all subpages before attempting to delete this link.";
                    pageSettings.Add(new PageSetting("PageDelete", "Delete Link", "Delete", bEnableDelete, strDisabledToolTip));
                }
            }
            else
            {
                if (_isSystemRoot)
                { //the page is the system root.
                  //if (Permission.AllowManageSystem()) pageSettings.Add(new PageSetting("WebsiteEdit", "Manage Websites", "Settings"));
                  //pageSettings.Add(new PageSetting("PagesModulesList", "Manage Modules", "Settings"));
                }
                else
                {
                    if (Permission.AllowManagePage())
                    {
                        pageSettings.Add(new PageSetting("PageSettings", "Page Settings", "Settings"));
                    }

                    if (page.ParentInstanceId.HasValue && page.ParentInstanceId.Value == Webpage.RootNavigationId)
                    { //the page is a website root page.
                        pageSettings.Add(new PageSetting("PagesModulesList", "Website Modules", "Settings"));
                        if (Permission.AllowManageSystem())
                        {
                            pageSettings.Add(new PageSetting("WebsiteEdit", "Website Settings", "Settings"));
                        }
                    }
                    else
                    { //the page is not a website root page.
                        if (Permission.AllowManagePage())
                        {
                            pageSettings.Add(new PageSetting("PageSecurity", "Page Security", "Security"));
                        }

                        bool bEnableDelete = false;

                        if (page.Children.Count == 0)
                        {
                            List <WebModuleInfo> modules = WebModule.GetModules(_instanceId);
                            if (modules.Count == 0)
                            {
                                bEnableDelete = true;
                            }
                        }

                        string strDisabledToolTip = "This page cannot be deleted because it contains modules and/or subpages.  Please first delete all modules and subpages before attempting to delete this page.";
                        if (Permission.AllowDeletePage())
                        {
                            pageSettings.Add(new PageSetting("PageDelete", "Delete Page", "Delete", bEnableDelete, strDisabledToolTip));
                        }
                    }
                }
            }

            return(pageSettings);
        }