Esempio n. 1
0
        /// <summary>
        /// The AddTabButton_Click server event handler
        /// on this page is used to add a new portal module
        /// into the tab
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddTabButton_Click(Object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                // Hide error message in case there was a previous error.
                moduleError.Visible = false;

                // This allows the user to pick what type of people can view the module being added.
                // If Authorised Roles is selected from the dropdown then every role that has view permission for the
                // Add Role module will be added to the view permissions of the module being added.
                string viewPermissionRoles = PermissionDropDown.SelectedValue.ToString();
                if (viewPermissionRoles == "Authorised Roles")
                {
                    viewPermissionRoles = PortalSecurity.GetViewPermissions(ModuleID);
                }

                try
                {
                    // New tabs go to the end of the list
                    PageItem t = new PageItem();
                    t.Name  = TabTitleTextBox.Text;
                    t.ID    = -1;
                    t.Order = 990000;

                    // Get Parent Tab Id Convert only once used many times
                    var parentTabID = int.Parse(parentTabDropDown.SelectedValue);


                    // write tab to database
                    PagesDB tabs = new PagesDB();
                    t.ID =
                        tabs.AddPage(this.PortalSettings.PortalID, parentTabID, t.Name, t.Order, viewPermissionRoles,
                                     cb_ShowMobile.Checked, tb_MobileTabName.Text);

                    CurrentCache.RemoveAll("_TabNavigationSettings_");

                    AppleseedSiteMapProvider.ClearAllAppleseedSiteMapCaches();

                    //Jump to Page option
                    string returnTab = string.Empty;
                    if (rbl_JumpToTab.SelectedValue.ToString() == "Yes")
                    {
                        // Redirect to New Page/Tab - Mike Stone 30/12/2004
                        // modified by Hongwei Shen 9/25/2005
                        // returnTab = HttpUrlBuilder.BuildUrl(""~/"+HttpUrlBuilder.DefaultPage", t.ID, "SelectedTabID=" + t.ID.ToString());
                        string newPage = "~/" + t.Name.Trim().Replace(" ", "_") + ".aspx";
                        returnTab = HttpUrlBuilder.BuildUrl(newPage, t.ID);
                    }
                    else
                    {
                        // Do NOT Redirect to New Form - Mike Stone 30/12/2004
                        // I guess every .aspx page needs to have a module tied to it.
                        // or you will get an error about edit access denied.

                        // Modified by Hongwei Shen 9/25/2005 to fix: QueryString["tabID"] maybe null.
                        // returnTab = HttpUrlBuilder.BuildUrl("~/"+HttpUrlBuilder.DefaultPage, int.Parse(Request.QueryString["tabID"]), "SelectedTabID=" + t.ID.ToString());
                        returnTab =
                            HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, PageID, "SelectedTabID=" + t.ID.ToString());
                    }
                    Response.Redirect(returnTab);
                }
                catch (Exception ex)
                {
                    moduleError.Visible = true;
                    ErrorHandler.Publish(LogLevel.Error,
                                         "There was an error with the Add Tab Module while trying to add a new tab.", ex);
                    return;
                }
                // Reload page to pick up changes
                Response.Redirect(Request.RawUrl, false);
            }
        }
Esempio n. 2
0
        /*[Ajax.AjaxMethod]*/

        /*
         * public System.Collections.Specialized.StringCollection ModuleChangeStrings(string moduleType, string moduleName)
         * {
         *  SetDatata(moduleType);
         *  moduleTitle.Text = moduleName;
         *
         *  System.Collections.Specialized.StringCollection s = new System.Collections.Specialized.StringCollection();
         *
         *  s.Add(moduleTitle.Text);
         *
         *  if (AddModuleHelp.Visible)
         *  {
         *      s.Add(AddModuleHelp.Attributes["onclick"].ToString());
         *      s.Add(AddModuleHelp.NavigateUrl);
         *      s.Add(AddModuleHelp.ImageUrl);
         *      s.Add(AddModuleHelp.ToolTip);
         *  }
         *
         *  return s;
         * }
         * */

        /// <summary>
        /// The AddModule_Click server event handler
        ///   on this page is used to add a new portal module
        ///   into the tab
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.
        /// </param>
        /// <remarks>
        /// </remarks>
        private void AddModule_Click(object sender, EventArgs e)
        {
            // TODO: IF PAGE ID = 0 Then we know it's home page, cant we get from db the id?
            // PagesDB _d = new PagesDB();
            var pid = this.PageID;

            if (pid == 0)
            {
                pid = PagesDB.PortalHomePageId(this.PortalID);
            }

            if (pid != 0)
            {
                // All new modules go to the end of the content pane
                var selectedModule = this.moduleType.SelectedItem.Value;
                var start          = selectedModule.IndexOf("|");
                var moduleID       = Convert.ToInt32(selectedModule.Substring(0, start).Trim());

                // Hide error message in case there was a previous error.
                this.moduleError.Visible = false;

                // This allows the user to pick what type of people can view the module being added.
                // If Authorized Roles is selected from the dropdown then every role that has view permission for the
                // Add Role module will be added to the view permissions of the module being added.
                var viewPermissionRoles = this.viewPermissions.SelectedValue;
                if (viewPermissionRoles == "Authorised Roles")
                {
                    viewPermissionRoles = PortalSecurity.GetViewPermissions(this.ModuleID);
                }

                try
                {
                    var m = new ModuleItem {
                        Title = this.TitleTextBox.Value, ModuleDefID = moduleID, Order = 999
                    };

                    // save to database
                    var mod = new ModulesDB();
                    m.ID = mod.AddModule(
                        pid,
                        m.Order,
                        this.paneLocation.SelectedValue,
                        m.Title,
                        m.ModuleDefID,
                        0,
                        PortalSecurity.GetEditPermissions(this.ModuleID),
                        viewPermissionRoles,
                        PortalSecurity.GetAddPermissions(this.ModuleID),
                        PortalSecurity.GetDeletePermissions(this.ModuleID),
                        PortalSecurity.GetPropertiesPermissions(this.ModuleID),
                        PortalSecurity.GetMoveModulePermissions(this.ModuleID),
                        PortalSecurity.GetDeleteModulePermissions(this.ModuleID),
                        false,
                        PortalSecurity.GetPublishPermissions(this.ModuleID),
                        false,
                        false,
                        false);
                }
                catch (Exception ex)
                {
                    this.moduleError.Visible = true;
                    ErrorHandler.Publish(
                        LogLevel.Error,
                        "There was an error with the Add Module Module while trying to add a new module.",
                        ex);
                }
                finally
                {
                    if (this.moduleError.Visible == false)
                    {
                        // Reload page to pick up changes
                        this.Response.Redirect(this.Request.RawUrl, false);
                    }
                }
            }
            else
            {
                // moduleError.TextKey = "ADDMODULE_HOMEPAGEERROR";
                this.moduleError.Text = General.GetString(
                    "ADDMODULE_HOMEPAGEERROR",
                    "You are currently on the homepage using the default virtual ID (The default ID is set when no specific page is selected. e.g. www.yourdomain.com. Please select your homepage from the Navigation menu e.g. 'Home' so that you can add a module against the page's actual ID.");
                this.moduleError.Visible = true;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// The AddTabButton_Click server event handler
        /// on this page is used to add a new portal module
        /// into the tab
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddTabButton_Click(Object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                // Hide error message in case there was a previous error.
                moduleError.Visible = false;

                // This allows the user to pick what type of people can view the module being added.
                // If Authorised Roles is selected from the dropdown then every role that has view permission for the
                // Add Role module will be added to the view permissions of the module being added.
                string viewPermissionRoles = PermissionDropDown.SelectedValue.ToString();
                if (viewPermissionRoles == "Authorised Roles")
                {
                    viewPermissionRoles = PortalSecurity.GetViewPermissions(ModuleID);
                }

                try
                {
                    // New tabs go to the end of the list
                    PageItem t = new PageItem();
                    t.Name  = TabTitleTextBox.Text;
                    t.ID    = -1;
                    t.Order = 990000;

                    // Get Parent Tab Id Convert only once used many times
                    int parentTabID = int.Parse(parentTabDropDown.SelectedValue);


                    // write tab to database
                    PagesDB tabs = new PagesDB();
                    //t.ID = tabs.AddTab(portalSettings.PortalID, t.Name, viewPermissionRoles, t.Order);

                    // Changed to use new method in TabsDB.cs now all parms are possible
                    // By Mike Stone ([email protected]) - 30/12/2004
                    t.ID =
                        tabs.AddPage(portalSettings.PortalID, parentTabID, t.Name, t.Order, viewPermissionRoles,
                                     cb_ShowMobile.Checked, tb_MobileTabName.Text);

                    //TODO.. the only way to update a parent id is throught update :S
                    // Changed to AddTab method now supports the parm
                    // Mike Stone - 30/12/2004
                    //tabs.UpdateTab(portalSettings.PortalID, t.ID, parentTabID, t.Name, t.Order, viewPermissionRoles, t.Name, false);

                    //Invalidate cache
                    // Changed to access form directly
                    // mike stone - 30/12/2004
                    //   Cache.Remove(Rainbow.Framework.Settings.Cache.Key.TabSettings(parentTabID));
                    // Copied to here 29/12/2004 by Mike Stone
                    CurrentCache.RemoveAll("_TabNavigationSettings_");
                    //Debug.WriteLine("************* Remove " + Key.TabSettings(parentTabID));

                    //Clear SiteMaps Cache
                    RainbowSiteMapProvider.ClearAllRainbowSiteMapCaches();

                    //Jump to Page option
                    string returnTab = string.Empty;
                    if (rbl_JumpToTab.SelectedValue.ToString() == "Yes")
                    {
                        // Redirect to New Page/Tab - Mike Stone 30/12/2004
                        // modified by Hongwei Shen 9/25/2005
                        // returnTab = HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx", t.ID, "SelectedTabID=" + t.ID.ToString());
                        string newPage = "~/" + t.Name.Trim().Replace(" ", "_") + ".aspx";
                        returnTab = HttpUrlBuilder.BuildUrl(newPage, t.ID);
                    }
                    else
                    {
                        // Do NOT Redirect to New Form - Mike Stone 30/12/2004
                        // I guess every .aspx page needs to have a module tied to it.
                        // or you will get an error about edit access denied.

                        // Modified by Hongwei Shen 9/25/2005 to fix: QueryString["tabID"] maybe null.
                        // returnTab = HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx", int.Parse(Request.QueryString["tabID"]), "SelectedTabID=" + t.ID.ToString());
                        returnTab =
                            HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx", PageID, "SelectedTabID=" + t.ID.ToString());
                    }
                    Response.Redirect(returnTab);
                }
                catch (Exception ex)
                {
                    moduleError.Visible = true;
                    ErrorHandler.Publish(LogLevel.Error,
                                         "There was an error with the Add Tab Module while trying to add a new tab.", ex);
                    return;
                }
                // Reload page to pick up changes
                Response.Redirect(Request.RawUrl, false);
            }
        }