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 })); } }
/// <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"></param> /// <param name="e"></param> private 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(Security.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(TabID, 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; } } }
/// <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"></param> /// <param name="e"></param> private 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(Security.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; } } }
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)); }
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" })); } }
/// <summary> /// The reorder. /// </summary> /// <param name="modulesByPane"> /// The modules by pane. /// </param> public static void Reorder(Dictionary <string, ArrayList> modulesByPane) { // var settings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; // var pageId = settings.ActivePage.PageID; var sdb = new ModulesDB(); foreach (var str in modulesByPane.Keys) { var list = modulesByPane[str]; var moduleOrder = 0; foreach (int num3 in list) { sdb.UpdateModuleOrder(num3, moduleOrder, str); moduleOrder++; } } }
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 })); }
/// <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> /// <remarks> /// </remarks> protected void RightLeft_Click(object sender, ImageClickEventArgs e) { var sourcePane = ((ImageButton)sender).Attributes["sourcepane"]; var targetPane = ((ImageButton)sender).Attributes["targetpane"]; var sourceBox = (ListBox)this.Page.FindControl(sourcePane); if (sourceBox == null) { sourceBox = (ListBox)this.Page.Master.FindControl("Content").FindControl(sourcePane); } var targetBox = (ListBox)this.Page.FindControl(targetPane); if (targetBox == null) { targetBox = (ListBox)this.Page.Master.FindControl("Content").FindControl(targetPane); } if (sourceBox.SelectedIndex != -1) { // get source arraylist var sourceList = this.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 var m = (ModuleItem)sourceList[sourceBox.SelectedIndex]; 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(sourceBox.SelectedIndex); // reload the portalSettings from the database HttpContext.Current.Items["PortalSettings"] = PortalSettings.GetPortalSettings( this.PageID, this.PortalSettings.PortalAlias); this.PortalSettings = (PortalSettings)this.Context.Items["PortalSettings"]; // reorder the modules in the source pane sourceList = this.GetModules(sourcePane); 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); this.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 this.Response.Redirect(this.AppendModuleID(this.Request.RawUrl, m.ID)); } else { this.msgError.Visible = true; } } }