Пример #1
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;
            }
        }