Esempio n. 1
0
        /// <summary>
        /// The UpDown_Click server event handler on this page is
        /// used to move a portal module up or down on a tab's layout pane
        /// </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 UpDown_Click(Object sender, ImageClickEventArgs e)
        {
            string  cmd      = ((ImageButton)sender).CommandName;
            string  pane     = ((ImageButton)sender).CommandArgument;
            ListBox _listbox = (ListBox)Page.FindControl(pane);

            ArrayList modules = GetModules(pane);

            if (_listbox.SelectedIndex != -1)
            {
                int delta;
                int selection = -1;

                // Determine the delta to apply in the order number for the module
                // within the list.  +3 moves down one item; -3 moves up one item
                if (cmd == "down")
                {
                    delta = 3;
                    if (_listbox.SelectedIndex < _listbox.Items.Count - 1)
                    {
                        selection = _listbox.SelectedIndex + 1;
                    }
                }
                else
                {
                    delta = -3;
                    if (_listbox.SelectedIndex > 0)
                    {
                        selection = _listbox.SelectedIndex - 1;
                    }
                }

                ModuleItem m;
                m = (ModuleItem)modules[_listbox.SelectedIndex];

                if (PortalSecurity.IsInRoles(PortalSecurity.GetMoveModulePermissions(m.ID)))
                {
                    m.Order += delta;

                    // reorder the modules in the content pane
                    OrderModules(modules);

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

                    // Redirect to the same page to pick up changes
                    Response.Redirect(AppendModuleID(Request.RawUrl, m.ID));
                }
                else
                {
                    msgError.Visible = true;
                    return;
                }
            }
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        public JsonResult RightLeft_Click(string sourcePane, string targetPane, string pageId, string selectedIndex)
        {
            // get source arraylist
            var sourceList = this.GetModules(sourcePane, Int32.Parse(pageId));

            var index = Int32.Parse(selectedIndex);
            // get a reference to the module to move
            // and assign a high order number to send it to the end of the target list
            var m = (ModuleItem)sourceList[index];

            if (PortalSecurity.IsInRoles(PortalSecurity.GetMoveModulePermissions(m.ID)))
            {
                // add it to the database
                var admin = new ModulesDB();
                admin.UpdateModuleOrder(m.ID, 99, targetPane);

                // delete it from the source list
                sourceList.RemoveAt(index);

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

                // resave the order
                foreach (ModuleItem item in sourceList)
                {
                    admin.UpdateModuleOrder(item.ID, item.Order, sourcePane);
                }

                // reorder the modules in the target pane
                var targetList = this.GetModules(targetPane, Int32.Parse(pageId));
                var list2      = this.OrderModules(targetList);

                // resave the order
                foreach (ModuleItem item in targetList)
                {
                    admin.UpdateModuleOrder(item.ID, item.Order, targetPane);
                }

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

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

                return(Json(new { error = false, source = ls.ToString(), target = sb.ToString() }));
            }
            else
            {
                return(Json(new { error = true }));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// The RightLeft_Click server event handler on this page is
        /// used to move a portal module between layout panes on
        /// the tab 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 RightLeft_Click(Object sender, ImageClickEventArgs e)
        {
            string  sourcePane = ((ImageButton)sender).Attributes["sourcepane"];
            string  targetPane = ((ImageButton)sender).Attributes["targetpane"];
            ListBox sourceBox  = (ListBox)Page.FindControl(sourcePane);
            ListBox targetBox  = (ListBox)Page.FindControl(targetPane);

            if (sourceBox.SelectedIndex != -1)
            {
                // get source arraylist
                ArrayList sourceList = GetModules(sourcePane);

                // get a reference to the module to move
                // and assign a high order number to send it to the end of the target list
                ModuleItem m = (ModuleItem)sourceList[sourceBox.SelectedIndex];

                if (PortalSecurity.IsInRoles(PortalSecurity.GetMoveModulePermissions(m.ID)))
                {
                    // add it to the database
                    ModulesDB admin = new ModulesDB();
                    admin.UpdateModuleOrder(m.ID, 99, targetPane);

                    // delete it from the source list
                    sourceList.RemoveAt(sourceBox.SelectedIndex);

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

                    // reorder the modules in the source pane
                    sourceList = GetModules(sourcePane);
                    OrderModules(sourceList);

                    // resave the order
                    foreach (ModuleItem item in sourceList)
                    {
                        admin.UpdateModuleOrder(item.ID, item.Order, sourcePane);
                    }

                    // reorder the modules in the target pane
                    ArrayList targetList = GetModules(targetPane);
                    OrderModules(targetList);

                    // resave the order
                    foreach (ModuleItem item in targetList)
                    {
                        admin.UpdateModuleOrder(item.ID, item.Order, targetPane);
                    }

                    // Redirect to the same page to pick up changes
                    Response.Redirect(AppendModuleID(Request.RawUrl, m.ID));
                }
                else
                {
                    msgError.Visible = true;
                }
            }
        }
Esempio n. 5
0
        public JsonResult UpDown_Click(string cmd, string pane, string pageId, string selectedIndex, string length)
        {
            var modules = this.GetModules(pane, Int32.Parse(pageId));
            int delta;
            var selection = -1;
            var index     = Int32.Parse(selectedIndex);

            // Determine the delta to apply in the order number for the module
            // within the list.  +3 moves down one item; -3 moves up one item
            if (cmd == "down")
            {
                delta = 3;
                if (index < Int32.Parse(length) - 1)
                {
                    selection = index + 1;
                }
            }
            else
            {
                delta = -3;
                if (index > 0)
                {
                    selection = index - 1;
                }
            }

            ModuleItem m;

            m = (ModuleItem)modules[index];

            if (PortalSecurity.IsInRoles(PortalSecurity.GetMoveModulePermissions(m.ID)))
            {
                m.Order += delta;

                // reorder the modules in the content pane
                var list = this.OrderModules(modules);

                // resave the order
                var admin = new ModulesDB();
                foreach (ModuleItem item in modules)
                {
                    admin.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 { value = ls.ToString() }));
            }
            else
            {
                return(Json(new { value = "error" }));
            }
        }
Esempio n. 6
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. 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() }));
        }