From: <ro...@us...> - 2006-08-10 14:51:43
|
Revision: 296 Author: rouquin Date: 2006-08-10 07:51:27 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/tcdb/?rev=296&view=rev Log Message: ----------- Fixed Administration rights bug that Matt found. I was calling the wrong rights function. Modified Paths: -------------- Website/App_Code/Common.cs Website/Includes/ActionItems.ascx.cs Website/Includes/Administration.ascx.cs Website/Includes/Assignments.ascx.cs Website/Includes/Authenticate.ascx.cs Modified: Website/App_Code/Common.cs =================================================================== --- Website/App_Code/Common.cs 2006-08-10 14:13:50 UTC (rev 295) +++ Website/App_Code/Common.cs 2006-08-10 14:51:27 UTC (rev 296) @@ -1395,6 +1395,7 @@ public static int PRODUCT_ANYID = -1; public static int PRODUCT_CREATED = -2; + public static int ROLE_ADMIN = 1; public static string CODE_USER = "u"; public static string CODE_AI = "ai"; Modified: Website/Includes/ActionItems.ascx.cs =================================================================== --- Website/Includes/ActionItems.ascx.cs 2006-08-10 14:13:50 UTC (rev 295) +++ Website/Includes/ActionItems.ascx.cs 2006-08-10 14:51:27 UTC (rev 296) @@ -21,15 +21,32 @@ { private static Logger m_logg = new Logger("TCDB.ActionItems"); private ActionItem ai; - private String item_id = HttpContext.Current.Request.QueryString[Constants.CODE_AI]; - private int productID = Convert.ToInt32(HttpContext.Current.Request.QueryString[Constants.CODE_PRODUCT]); - private String mode = HttpContext.Current.Request.QueryString["mode"]; + private String item_id = ""; + private int productID = 0; + private String mode = ""; protected void Page_Load(object sender, EventArgs e) { if (productID == 0) productID = Constants.PRODUCT_SITEID; + // Load session data + try + { + item_id = Session[Constants.CODE_AI].ToString(); + } + catch { } + try + { + mode = Session[Constants.CODE_MODE].ToString(); + } + catch { } + try + { + productID = Convert.ToInt32(Session[Constants.CODE_PRODUCT]); + } + catch { } + m_logg.Debug("Loading page ActionItems"); if (item_id == null) { Modified: Website/Includes/Administration.ascx.cs =================================================================== --- Website/Includes/Administration.ascx.cs 2006-08-10 14:13:50 UTC (rev 295) +++ Website/Includes/Administration.ascx.cs 2006-08-10 14:51:27 UTC (rev 296) @@ -37,9 +37,10 @@ if (!m_user.HasRight("view_my_roles", Constants.PRODUCT_ANYID) && !m_user.HasRight("view_other_roles", Constants.PRODUCT_ANYID)) userRole.Visible = false; } - + protected void productList_Init(object sender, EventArgs e) { + List<Product> products = ProductDB.GetProductList(active); foreach (Product product in products) @@ -52,7 +53,8 @@ productList.Items.Add(item); } - productList_SelectedIndexChanged(sender, e); + if (!IsPostBack) + productList_SelectedIndexChanged(sender, e); } protected void productList_SelectedIndexChanged(object sender, EventArgs e) { @@ -74,9 +76,10 @@ protected void userList_Init(object sender, EventArgs e) { + List<Product> products = ProductDB.GetProductList(active); List<User> users = UserDB.TCDB_GetUserList(); - + foreach (User user in users) { foreach (Product product in products) @@ -94,7 +97,8 @@ break; } } - userList_SelectedIndexChanged(sender, e); + if (!IsPostBack) + userList_SelectedIndexChanged(sender, e); } protected void userList_SelectedIndexChanged(object sender, EventArgs e) { @@ -108,7 +112,6 @@ userDelete.Visible = false; foreach (Product product in products) { - if (product.ID == Constants.PRODUCT_SITEID) continue; if (!userView.Visible && m_user.HasRight("view_my_settings", product.ID)) userView.Visible = true; if (!userEdit.Visible && m_user.HasRight("edit_my_settings", product.ID)) @@ -122,13 +125,12 @@ userDelete.Visible = true; foreach (Product product in products) { - if (product.ID == Constants.PRODUCT_SITEID) continue; - if (user.HasRights(product.ID)) + if (!userView.Visible && m_user.HasRight("view_other_settings", user, product.ID)) + userView.Visible = true; + if (!userEdit.Visible && m_user.HasRight("edit_other_settings", user, product.ID)) + userEdit.Visible = true; + if (product.ID != Constants.PRODUCT_SITEID && user.HasRights(product.ID)) { - if (!userView.Visible && m_user.HasRight("view_other_settings", product.ID)) - userView.Visible = true; - if (!userEdit.Visible && m_user.HasRight("edit_other_settings", product.ID)) - userEdit.Visible = true; if (userDelete.Visible && !m_user.HasRight("delete_user", product.ID)) userDelete.Visible = false; } Modified: Website/Includes/Assignments.ascx.cs =================================================================== --- Website/Includes/Assignments.ascx.cs 2006-08-10 14:13:50 UTC (rev 295) +++ Website/Includes/Assignments.ascx.cs 2006-08-10 14:51:27 UTC (rev 296) @@ -362,6 +362,23 @@ Session["rows"] = Convert.ToInt32(Session["rows"]) + 1; } } + protected void AssignmentsGridView_RowCommand(object sender, GridViewCommandEventArgs e) + { + if (e.CommandName == "View") + { + Assignment a = AssignmentDB.GetAssignment(int.Parse(e.CommandArgument.ToString())); + if (a.ISACTIONITEM) + { + Session[Constants.CODE_AI] = a.ACTIONITEM.ID; + Response.Redirect("~/ActionItem.aspx"); + } + else if (a.ISWORKORDER) + { + Session[Constants.CODE_WO] = a.WORKORDER.ID; + Response.Redirect("~/WorkOrder.aspx"); + } + } + } protected void cboShowCompleted_CheckedChanged(object sender, EventArgs e) { @@ -814,22 +831,5 @@ Session[Constants.CODE_MODE] = "new"; Response.Redirect("~/WorkOrder.aspx"); } - protected void AssignmentsGridView_RowCommand(object sender, GridViewCommandEventArgs e) - { - if (e.CommandName == "View") - { - Assignment a = AssignmentDB.GetAssignment(int.Parse(e.CommandArgument.ToString())); - if (a.ISACTIONITEM) - { - Session[Constants.CODE_AI] = a.ACTIONITEM.ID; - Response.Redirect("~/ActionItem.aspx"); - } - else if (a.ISWORKORDER) - { - Session[Constants.CODE_WO] = a.WORKORDER.ID; - Response.Redirect("~/WorkOrder.aspx"); - } - } - } } } Modified: Website/Includes/Authenticate.ascx.cs =================================================================== --- Website/Includes/Authenticate.ascx.cs 2006-08-10 14:13:50 UTC (rev 295) +++ Website/Includes/Authenticate.ascx.cs 2006-08-10 14:51:27 UTC (rev 296) @@ -105,8 +105,13 @@ // TODO: The default redirect should be pulled from the DB if (Request.RawUrl.Contains("efault.aspx")) - // TODO: Discuss this line... In my opinion it shouldn't be needed unless specifying a user other than the current one - Response.Redirect("~/Assignments.aspx?" + Constants.CODE_USER + "=" + myUser.ID); + { + Session[Constants.CODE_USER] = myUser.ID; + Session.Remove(Constants.CODE_MODE); + Session.Remove(Constants.CODE_PRODUCT); + Session.Remove(Constants.CODE_CREATED); + Response.Redirect("~/Assignments.aspx"); + } else Response.Redirect(Request.RawUrl); //Response.Redirect(FormsAuthentication.GetRedirectUrl(LoginUser.UserName, LoginUser.RememberMeSet)); @@ -161,7 +166,11 @@ m_logg.Info("New user action item successfully sent to [" + admin.ToString() + "]"); Results.Text = ConfigDB.GetConfigString("user_created"); - Response.Redirect("~/Assignments.aspx?" + Constants.CODE_USER + "=" + newUser.ID); + Session[Constants.CODE_USER] = newUser.ID; + Session.Remove(Constants.CODE_MODE); + Session.Remove(Constants.CODE_PRODUCT); + Session.Remove(Constants.CODE_CREATED); + Response.Redirect("~/Assignments.aspx"); } else { @@ -199,30 +208,19 @@ private User GetProductAdmin(Product product) { - // TODO: FIX THIS CODE!!!!! It needs to look up the product admin by role now - User admin = new User(); - /* - if (product.QALEAD.HasRight(Constants.RIGHTS_ASSIGNPERMISSION, product.ID)) + tcdbDataSetTableAdapters.db_roleProductUserTableAdapter rpuAdapter = new tcdbDataSetTableAdapters.db_roleProductUserTableAdapter(); + tcdbDataSet.db_roleProductUserDataTable rpuTable = rpuAdapter.GetData(Constants.ROLE_ADMIN, product.ID, true); + + if (rpuTable.Count > 0) { - m_logg.Debug("The QA lead [" + product.QALEAD.ToString() + "] has rights to assign permissions for product [" + product.ToString() + "]"); - admin = product.QALEAD; - } - else if (product.QAMANAGER.HasRight(Constants.RIGHTS_ASSIGNPERMISSION, product.ID)) - { - m_logg.Debug("The QA lead [" + product.QALEAD.ToString() + "] does not have rights to assign permissions for product [" + product.ToString() + "], checking QA Manager"); + tcdbDataSet.db_roleProductUserRow row = rpuTable[0]; - m_logg.Debug("The QA manager [" + product.QAMANAGER.ToString() + "] has rights to assign permissions for product [" + product.ToString() + "]"); - admin = product.QAMANAGER; + return UserDB.GetUserInfo(row.userID); } else { - m_logg.Debug("The QA manager [" + product.QAMANAGER.ToString() + "] does not have rights to assign permissions for product [" + product.ToString() + "], checking QA Manager"); - - admin = UserDB.GetUserInfo(ConfigDB.GetConfigInt("site_admin")); - m_logg.Debug("The site admin [" + admin.ToString() + "] has rights to assign permissions for product [" + product.ToString() + "]"); + return new User(); } - */ - return admin; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |