Beispiel #1
0
        /// <summary>
        /// The DeleteBtn_Click server event handler on this page is
        /// used to delete a portal module from the page
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param>
        protected void DeleteBtn_Click(Object sender, ImageClickEventArgs e)
        {
            string    pane     = ((ImageButton)sender).CommandArgument;
            ListBox   _listbox = (ListBox)Page.FindControl(pane);
            ArrayList modules  = GetModules(pane);

            if (_listbox.SelectedIndex != -1)
            {
                ModuleItem m = (ModuleItem)modules[_listbox.SelectedIndex];
                if (m.ID > -1)
                {
                    // [email protected] (20/08/2004) Add role control for delete module
                    if (PortalSecurity.IsInRoles(PortalSecurity.GetDeleteModulePermissions(m.ID)))
                    {
                        // must delete from database too
                        ModulesDB moddb = new ModulesDB();
                        // TODO add userEmail and useRecycler
                        moddb.DeleteModule(m.ID);
                    }
                    else
                    {
                        msgError.Visible = true;
                        return;
                    }
                }
            }

            // Redirect to the same page to pick up changes
            Response.Redirect(Request.RawUrl);
        }
        protected void AddModuleToPane_Click(object sender, EventArgs e)
        {
            // All new modules go to the end of the content pane
            var m = new ModuleItem();

            m.Title       = this.moduleTitle.Text;
            m.ModuleDefID = Int32.Parse(this.moduleType.SelectedItem.Value);
            m.Order       = 999;

            // save to database
            var mod = new ModulesDB();

            // Change by [email protected]
            // Date: 6/2/2003
            // Original:             m.ID = _mod.AddModule(tabID, m.Order, "ContentPane", m.Title, m.ModuleDefID, 0, "Admins", "All Users", "Admins", "Admins", "Admins", false);
            // Changed by Mario Endara <*****@*****.**> (2004/11/09)
            // The new module inherits security from Pages module (current ModuleID)
            // so who can edit the tab properties/content can edit the module properties/content (except view that remains =)
            m.ID = mod.AddModule(
                this.PageID,
                m.Order,
                this.paneLocation.SelectedItem.Value,
                m.Title,
                m.ModuleDefID,
                0,
                PortalSecurity.GetEditPermissions(this.ModuleID),
                this.viewPermissions.SelectedItem.Value,
                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);

            // End Change [email protected]

            // reload the portalSettings from the database
            this.Context.Items["PortalSettings"] = PortalSettings.GetPortalSettings(this.PageID, this.PortalSettings.PortalAlias);
            this.PortalSettings = (PortalSettings)this.Context.Items["PortalSettings"];

            // reorder the modules in the content pane
            var modules = this.GetModules("ContentPane");

            this.OrderModules(modules);

            // resave the order
            foreach (ModuleItem item in modules)
            {
                mod.UpdateModuleOrder(item.ID, item.Order, "ContentPane");
            }

            // Redirect to the same page to pick up changes
            this.Response.Redirect(this.AppendModuleID(this.Request.RawUrl, m.ID));
        }
Beispiel #3
0
        public JsonResult DeleteBtn_Click(string pane, string pageId, string selectedIndex)
        {
            var modules = this.GetModules(pane, Int32.Parse(pageId));
            var index   = Int32.Parse(selectedIndex);

            var m = (ModuleItem)modules[index];

            if (m.ID > -1)
            {
                // [email protected] (20/08/2004) Add role control for delete module
                if (PortalSecurity.IsInRoles(PortalSecurity.GetDeleteModulePermissions(m.ID)))
                {
                    // must delete from database too
                    var moddb = new ModulesDB();

                    // TODO add userEmail and useRecycler
                    moddb.DeleteModule(m.ID);

                    // reorder the modules in the pane
                    modules = this.GetModules(pane, Int32.Parse(pageId));
                    var list = this.OrderModules(modules);

                    // resave the order
                    foreach (ModuleItem item in modules)
                    {
                        moddb.UpdateModuleOrder(item.ID, item.Order, pane);
                    }

                    StringBuilder ls = new StringBuilder();
                    foreach (ModuleItem md in list)
                    {
                        ls.AppendFormat("<option value=\"{0}\">{1}</option>", md.ID, md.Title);
                    }
                    return(Json(new { error = false, value = ls.ToString() }));
                }
                else
                {
                    return(Json(new { error = true }));
                }
            }
            return(Json(new { error = true }));
        }
        public JsonResult RemoveModule(int id)
        {
            string errorMessage = General.GetString("MODULE_DELETE_FAILED", "You don't have permission to delete this module", this);

            try
            {
                if (PortalSecurity.IsInRoles(PortalSecurity.GetDeleteModulePermissions(id)))
                {
                    // must delete from database too
                    var moddb = new ModulesDB();
                    moddb.DeleteModule(id);
                    return(Json(new { error = false }));
                }
                else
                {
                    return(Json(new { error = true, errorMess = errorMessage }));
                }
            }
            catch (SqlException)
            {
                return(Json(new { error = true, errorMess = errorMessage }));
            }
        }
Beispiel #5
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;
            }
        }
        public JsonResult Clone(int id, int parentId)
        {
            try
            {
                var      generalModuleDef = Guid.Parse("F9F9C3A4-6E16-43B4-B540-984DDB5F1CD2");
                object[] queryargs        = { generalModuleDef, PortalSettings.PortalID };

                int moduleDefinition;

                try
                {
                    moduleDefinition =
                        new rb_ModuleDefinitions().All(where : "GeneralModDefID = @0 and PortalID = @1", args: queryargs).Single().ModuleDefID;
                }
                catch (Exception e)
                {
                    // Shortcut module doesn't exist in current Portal

                    var modules = new ModulesDB();

                    modules.UpdateModuleDefinitions(
                        generalModuleDef,
                        PortalSettings.PortalID,
                        true);

                    moduleDefinition =
                        new rb_ModuleSettings().All(where : "GeneralModDefID = @0 and PortalID = @1", args: queryargs).Single().ModuleDefID;
                }

                var db = new PagesDB();

                PortalPages = db.GetPagesFlat(PortalSettings.PortalID);
                var t = new PageItem
                {
                    Name  = General.GetString("TAB_NAME", "New Page Name"),
                    ID    = -1,
                    Order = 990000
                };

                PortalPages.Add(t);

                var tabs = new PagesDB();
                t.ID = tabs.AddPage(PortalSettings.PortalID, t.Name, t.Order);

                db.UpdatePageParent(t.ID, parentId, PortalSettings.PortalID);

                OrderPages();
                //JsonResult treeData = GetTreeData();

                // Coping Modules



                var pagesModules = new rb_Modules().All(where : "TabID = @0", args: id);

                foreach (var module in pagesModules)
                {
                    var m = new ModuleItem();
                    m.Title       = module.ModuleTitle;
                    m.ModuleDefID = moduleDefinition;
                    m.Order       = module.ModuleOrder;

                    // save to database
                    var mod = new ModulesDB();

                    m.ID = mod.AddModule(
                        t.ID,
                        m.Order,
                        module.PaneName,
                        module.ModuleTitle,
                        m.ModuleDefID,
                        0,
                        module.AuthorizedEditRoles,
                        module.AuthorizedViewRoles,
                        module.AuthorizedAddRoles,
                        module.AuthorizedDeleteRoles,
                        module.AuthorizedPropertiesRoles,
                        module.AuthorizedMoveModuleRoles,
                        module.AuthorizedDeleteModuleRoles,
                        false,
                        PortalSecurity.GetDeleteModulePermissions(module.ModuleID),
                        false,
                        false,
                        false);

                    var settings = new rb_ModuleSettings();
                    settings.Insert(new { ModuleID = m.ID, SettingName = "LinkedModule", SettingValue = module.ModuleID });
                }



                return(Json(new { pageId = t.ID }));
            }
            catch (Exception e)
            {
                ErrorHandler.Publish(LogLevel.Error, e);
                Response.StatusCode = 500;
                return(Json(""));
            }
        }
Beispiel #7
0
        //
        // GET: /Module/

        public JsonResult AddModule(string title, string moduleType, string paneLocation, string viewPermission, string pageId, string ModuleId)
        {
            // All new modules go to the end of the content pane
            var m = new ModuleItem();

            m.Title       = title;
            m.ModuleDefID = Int32.Parse(moduleType);
            m.Order       = 999;

            // save to database
            var mod   = new ModulesDB();
            var modId = Int32.Parse(ModuleId);

            m.ID = mod.AddModule(
                Int32.Parse(pageId),
                m.Order,
                paneLocation,
                m.Title,
                m.ModuleDefID,
                0,
                PortalSecurity.GetEditPermissions(modId),
                viewPermission,
                PortalSecurity.GetAddPermissions(modId),
                PortalSecurity.GetDeletePermissions(modId),
                PortalSecurity.GetPropertiesPermissions(modId),
                PortalSecurity.GetMoveModulePermissions(modId),
                PortalSecurity.GetDeleteModulePermissions(modId),
                false,
                PortalSecurity.GetPublishPermissions(modId),
                false,
                false,
                false);

            // End Change [email protected]

            //// reload the portalSettings from the database

            //this.Context.Items["PortalSettings"] = new PortalSettings(this.PageID, this.PortalSettings.PortalAlias);
            //this.PortalSettings = (PortalSettings)this.Context.Items["PortalSettings"];

            // reorder the modules in the content pane
            //var modules = GetModules("ContentPane", Int32.Parse(pageId), Int32.Parse(portalId));
            //this.OrderModules(modules);

            //// resave the order
            //foreach (ModuleItem item in modules) {
            //    mod.UpdateModuleOrder(item.ID, item.Order, "ContentPane");
            //}

            //// Redirect to the same page to pick up changes
            ////this.Response.Redirect(this.AppendModuleID(this.Request.RawUrl, m.ID));
            var list = GetModules(paneLocation, Int32.Parse(pageId));

            StringBuilder ls = new StringBuilder();

            foreach (ModuleItem md in list)
            {
                ls.AppendFormat("<option value=\"{0}\">{1}</option>", md.ID, md.Title);
            }

            return(Json(new { value = ls.ToString() }));
        }