From: <ro...@us...> - 2006-07-31 20:21:50
|
Revision: 243 Author: rouquin Date: 2006-07-31 13:21:40 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/tcdb/?rev=243&view=rev Log Message: ----------- Add enforced user rights to the Assignments page. It definately makes the code a little more complicated and ugly, but it appears to be working. We may want some more debug/comments added. Modified Paths: -------------- Website/App_Code/Assignments.cs Website/App_Code/Common.cs Website/App_Code/Users.cs Website/Includes/Assignments.ascx.cs Website/Includes/AssignmentsTree.ascx Website/Includes/AssignmentsTree.ascx.cs Website/Includes/Products.ascx Website/Right.aspx Modified: Website/App_Code/Assignments.cs =================================================================== --- Website/App_Code/Assignments.cs 2006-07-31 19:48:43 UTC (rev 242) +++ Website/App_Code/Assignments.cs 2006-07-31 20:21:40 UTC (rev 243) @@ -537,20 +537,24 @@ private int p_id; private string p_name; - private int p_creatorID; + private User p_creator; + private User p_assigned; + public WorkOrder() { p_id = 0; p_name = ""; - p_creatorID = 0; + p_creator = new User(); + p_assigned = new User(); } - public WorkOrder(int id, string name, string description, int creatorID) + public WorkOrder(int id, string name, string description, User assigned, User creator) { p_id = id; p_name = name; - p_creatorID = creatorID; + p_assigned = assigned; + p_creator = creator; } public int ID @@ -565,12 +569,18 @@ set { p_name = value; } } - public int CREATORID + public User CREATOR { - get { return p_creatorID; } - set { p_creatorID = value; } + get { return p_creator; } + set { p_creator = value; } } + public User ASSIGNED + { + get { return p_assigned; } + set { p_assigned = value; } + } + public override string ToString() { return NAME; Modified: Website/App_Code/Common.cs =================================================================== --- Website/App_Code/Common.cs 2006-07-31 19:48:43 UTC (rev 242) +++ Website/App_Code/Common.cs 2006-07-31 20:21:40 UTC (rev 243) @@ -1204,6 +1204,7 @@ // Defaults in the database public static int ANONYMOUSUSERID = 1; public static int PRODUCT_SITEID = 1; + public static int PRODUCT_ANYID = -1; public static string CODE_USER = "u"; Modified: Website/App_Code/Users.cs =================================================================== --- Website/App_Code/Users.cs 2006-07-31 19:48:43 UTC (rev 242) +++ Website/App_Code/Users.cs 2006-07-31 20:21:40 UTC (rev 243) @@ -20,6 +20,7 @@ using System.Web.SessionState; using log4net; using TCDB.Rights; +using TCDB.Products; namespace TCDB.Users { @@ -403,11 +404,25 @@ public bool HasRight(string right, int productID) { + // Any product + if (productID == Constants.PRODUCT_ANYID) + { + List<Product> products = ProductDB.GetProductList(true); + foreach (Product product in products) + { + if (HasRight(right, product.ID)) + return true; + } + return false; + } + + // Specified product if (!p_rights.ContainsKey(productID)) p_rights[productID] = RightDB.TCDB_GetUserRights(productID,p_id); if (p_rights[productID].Contains(right)) return true; + // Site rights? if (productID != Constants.PRODUCT_SITEID) { if (!p_rights.ContainsKey(Constants.PRODUCT_SITEID)) @@ -424,6 +439,22 @@ return (RightDB.TCDB_GetUserRight(productID, userID, right) != null); } + public bool HasRights(int productID) + { + if (!p_rights.ContainsKey(productID)) + p_rights[productID] = RightDB.TCDB_GetUserRights(productID, p_id); + + if (p_rights[productID].Count > 0) + return true; + + return false; + } + + public static bool HasRights(int userID, int productID) + { + return (RightDB.TCDB_GetUserRights(productID, userID).Count > 0); + } + public void AddRole(String role, int productID) { // Insert user role Product Modified: Website/Includes/Assignments.ascx.cs =================================================================== --- Website/Includes/Assignments.ascx.cs 2006-07-31 19:48:43 UTC (rev 242) +++ Website/Includes/Assignments.ascx.cs 2006-07-31 20:21:40 UTC (rev 243) @@ -12,6 +12,7 @@ using TCDB.Assignments; using TCDB.Common; using TCDB.Users; +using TCDB.Products; using log4net; /// <summary> @@ -21,46 +22,73 @@ { private static ILog m_logg = LogManager.GetLogger("Page:Assignments"); private String uid = HttpContext.Current.Request.QueryString[Constants.CODE_USER]; + private int productID = Convert.ToInt32(HttpContext.Current.Request.QueryString[Constants.CODE_PRODUCT]); private const int MAX_NAME_LENGTH = 30; protected void Page_Load(object sender, EventArgs e) { - if (!m_user.ISAUTHENTICATED) { - return; } - m_logg.Debug("Loading assignments for [" + m_user.ToString() + "]"); + if (!m_user.ISAUTHENTICATED) + { + return; + } + m_logg.Debug("Loading assignments for [" + m_user.ToString() + "]"); + if (productID == 0) + productID = Constants.PRODUCT_ANYID; + if (uid == null) { m_logg.Debug("UserID not specified in the url, checking for permissions to view multiple users assignments"); - if (m_user.HasRight(Constants.RIGHTS_SITEADMIN, Constants.PRODUCT_SITEID)) + if (m_user.HasRight("view_other_ai", productID) || m_user.HasRight("view_created_ai", productID) || + m_user.HasRight("view_other_wo", productID) || m_user.HasRight("view_created_wo", productID)) { - m_logg.Debug("User has site admin rights, display all users"); - // Admin user should get everything, so don't set any values! - Page.Title = "TCDB: All Assignments"; - header.Text = "All Assignments"; + Product product = ProductDB.GetProduct(true, Convert.ToInt32(productID)); + + if (product != null) + { + m_logg.Debug("User has product admin rights, display all product users"); + + // Admin user should get everything, so don't set any values! + Page.Title = "TCDB: " + product.NAME + " Assignments"; + header.Text = product.NAME + " Assignments"; + } } - // TODO: add code for if user has create/edit/view assignments right anywhere else { - m_logg.Debug("User has no special privledges, only display own assignments"); - uid = m_user.ID.ToString(); - Page.Title = "TCDB: My Assignments"; - header.Text = "My Assignments"; + if (m_user.HasRight("view_my_ai") || m_user.HasRight("view_my_wo")) + { + m_logg.Debug("User has no special privledges, only display own assignments"); + uid = m_user.ID.ToString(); + Page.Title = "TCDB: My Assignments"; + header.Text = "My Assignments"; + } + else // No rights to do anything + Response.Redirect("~/Default.aspx"); } } else if (uid == m_user.ID.ToString()) { - m_logg.Debug("The current user's assignments have been requested, only displaying those"); - // TODO: Set these text fields dynamically from the config/DB (and do it globally!) - Page.Title = "TCDB: My Assignments"; - header.Text = "My Assignments"; + if (m_user.HasRight("view_my_ai") || m_user.HasRight("view_my_wo")) + { + m_logg.Debug("The current user's assignments have been requested, only displaying those"); + Page.Title = "TCDB: My Assignments"; + header.Text = "My Assignments"; + } + else // No rights to do anything + Response.Redirect("~/Default.aspx"); } else { - // TODO: check permissions before displaying this! If no permission, redirect to this page with no params - String name = UserDB.GetUserInfo(Convert.ToInt32(uid)).FULLNAME; - m_logg.Debug("User requested assignments for [" + name + "]"); - Page.Title = "TCDB: " + name + "'s Assignments"; - header.Text = name + "'s Assignments"; + User user = UserDB.GetUserInfo(Convert.ToInt32(uid)); + + if (user.HasRights(productID) && + (m_user.HasRight("view_other_ai", productID) || m_user.HasRight("view_other_wo", productID) || + m_user.HasRight("view_created_ai", productID) || m_user.HasRight("view_created_wo", productID))) + { + String name = user.FULLNAME; + m_logg.Debug("User requested assignments for [" + name + "]"); + Page.Title = "TCDB: " + name + "'s Assignments"; + header.Text = name + "'s Assignments"; + } } Session.Add("uid", uid); m_logg.Debug("Databinding the AssignmentsGridView"); @@ -101,7 +129,7 @@ gRow.Cells[0].Text = "<div class=\"priority_normal\"></div>"; // Set Hyperlink URL - String cid = data["childID"].ToString(); + int cid = Convert.ToInt32(data["childID"]); String type = data["aType"].ToString(); String name = data["aName"].ToString(); String displayName; @@ -112,12 +140,34 @@ gRow.Cells[1].ToolTip = name; if (type == Constants.CODE_AI) + { + ActionItem ai = ActionItemDB.GetActionItem(cid); + + if (ai != null && + (!m_user.HasRight("view_other_ai",productID) && + !(ai.ASSIGNED.ID == m_user.ID && m_user.HasRight("view_my_ai", productID)) && + !(ai.CREATOR.ID == m_user.ID && m_user.HasRight("view_created_ai",productID)))) + gRow.Visible = false; + gRow.Cells[1].Text = "<a href=\"ActionItem.aspx?" + Constants.CODE_AI + "=" + cid + "\">" + displayName + "</a>"; + } else if (type == Constants.CODE_WO) + { + WorkOrder wo = WorkOrderDB.TCDB_GetWorkOrder(cid); + + if (wo != null && + (!m_user.HasRight("view_other_wo",productID) && + !(wo.ASSIGNED.ID == m_user.ID && m_user.HasRight("view_my_wo", productID)) && + !(wo.CREATOR.ID == m_user.ID && m_user.HasRight("view_created_wo",productID)))) + gRow.Visible = false; + gRow.Cells[1].Text = "<a href=\"WorkOrder.aspx?" + Constants.CODE_WO + "=" + cid + "\">" + name + "</a>"; + } else + { m_logg.Debug("Couldn't determine what type [" + type + "] is"); - + } + if (cboPriorityFilter.Checked) { switch (priority) @@ -200,7 +250,7 @@ if ((dateDue < from) || (dateDue > to)) gRow.Visible = false; } - if (gRow.Visible && cboFinishedFilter.Checked) + if (gRow.Visible && cboFinishedFilter.Checked && data["dateFinished"].ToString() != "") { DateTime dateFinished = Convert.ToDateTime(data["dateFinished"]); DateTime to = toFinishedDate.SelectedDate; @@ -388,66 +438,82 @@ } protected void toDate_Init(object sender, EventArgs e) { - toDate.SelectedDate = m_user.GetConfigDate("filter_show_to_assigned_date"); + if (!IsPostBack) + toDate.SelectedDate = m_user.GetConfigDate("filter_show_to_assigned_date"); } protected void toDueDate_Init(object sender, EventArgs e) { - toDueDate.SelectedDate = m_user.GetConfigDate("filter_show_to_due_date"); + if (!IsPostBack) + toDueDate.SelectedDate = m_user.GetConfigDate("filter_show_to_due_date"); } protected void toFinishedDate_Init(object sender, EventArgs e) { - toFinishedDate.SelectedDate = m_user.GetConfigDate("filter_show_to_finished_dates"); + if (!IsPostBack) + toFinishedDate.SelectedDate = m_user.GetConfigDate("filter_show_to_finished_dates"); } protected void fromDate_Init(object sender, EventArgs e) { - fromDate.SelectedDate = m_user.GetConfigDate("filter_show_from_assigned_date"); + if (!IsPostBack) + fromDate.SelectedDate = m_user.GetConfigDate("filter_show_from_assigned_date"); } protected void fromDueDate_Init(object sender, EventArgs e) { - fromDueDate.SelectedDate = m_user.GetConfigDate("filter_show_from_due_date"); + if (!IsPostBack) + fromDueDate.SelectedDate = m_user.GetConfigDate("filter_show_from_due_date"); } protected void fromFinishedDate_Init(object sender, EventArgs e) { - fromFinishedDate.SelectedDate = m_user.GetConfigDate("filter_show_from_finished_date"); + if (!IsPostBack) + fromFinishedDate.SelectedDate = m_user.GetConfigDate("filter_show_from_finished_date"); } protected void cboShowActionItems_Init(object sender, EventArgs e) { - cboShowActionItems.Checked = m_user.GetConfigBool("filter_show_action_items"); + if (!IsPostBack) + cboShowActionItems.Checked = m_user.GetConfigBool("filter_show_action_items"); } protected void cboShowWorkOrders_Init(object sender, EventArgs e) { - cboShowWorkOrders.Checked = m_user.GetConfigBool("filter_show_work_orders"); + if (!IsPostBack) + cboShowWorkOrders.Checked = m_user.GetConfigBool("filter_show_work_orders"); } protected void cboHighPriority_Init(object sender, EventArgs e) { - cboHighPriority.Checked = m_user.GetConfigBool("filter_show_high_priority"); + if (!IsPostBack) + cboHighPriority.Checked = m_user.GetConfigBool("filter_show_high_priority"); } protected void cboLowPriority_Init(object sender, EventArgs e) { - cboLowPriority.Checked = m_user.GetConfigBool("filter_show_low_priority"); + if (!IsPostBack) + cboLowPriority.Checked = m_user.GetConfigBool("filter_show_low_priority"); } protected void cboStatusFilter_Init(object sender, EventArgs e) { - cboStatusFilter.Checked = m_user.GetConfigBool("filter_enable_status_filter"); + if (!IsPostBack) + cboStatusFilter.Checked = m_user.GetConfigBool("filter_enable_status_filter"); } protected void cboDateFilter_Init(object sender, EventArgs e) { - cboDateFilter.Checked = m_user.GetConfigBool("filter_enable_assigned_date_filter"); + if (!IsPostBack) + cboDateFilter.Checked = m_user.GetConfigBool("filter_enable_assigned_date_filter"); } protected void cboDueFilter_Init(object sender, EventArgs e) { - cboDueFilter.Checked = m_user.GetConfigBool("filter_enable_due_date_filter"); + if (!IsPostBack) + cboDueFilter.Checked = m_user.GetConfigBool("filter_enable_due_date_filter"); } protected void cboFinishedFilter_Init(object sender, EventArgs e) { - cboFinishedFilter.Checked = m_user.GetConfigBool("filter_enable_finished_date_filter"); + if (!IsPostBack) + cboFinishedFilter.Checked = m_user.GetConfigBool("filter_enable_finished_date_filter"); } protected void cboTypeFilter_Init(object sender, EventArgs e) { - cboTypeFilter.Checked = m_user.GetConfigBool("filter_enable_type_filter"); + if (!IsPostBack) + cboTypeFilter.Checked = m_user.GetConfigBool("filter_enable_type_filter"); } protected void cboPriorityFilter_Init(object sender, EventArgs e) { - cboPriorityFilter.Checked = m_user.GetConfigBool("filter_enable_priority_filter"); + if (!IsPostBack) + cboPriorityFilter.Checked = m_user.GetConfigBool("filter_enable_priority_filter"); } } Modified: Website/Includes/AssignmentsTree.ascx =================================================================== --- Website/Includes/AssignmentsTree.ascx 2006-07-31 19:48:43 UTC (rev 242) +++ Website/Includes/AssignmentsTree.ascx 2006-07-31 20:21:40 UTC (rev 243) @@ -2,13 +2,11 @@ <asp:CheckBox ID="statusComplete" runat="server" Text="Show Completed" AutoPostBack="True" OnCheckedChanged="statusComplete_CheckedChanged" OnInit="statusComplete_Init"/> <asp:TreeView ID="AssignmentTree" runat="server" SelectedNodeStyle-CssClass="selectednode" - OnTreeNodePopulate="AssignmentTree_TreeNodePopulate" ExpandDepth="1" + OnTreeNodePopulate="AssignmentTree_TreeNodePopulate" OnTreeNodeCollapsed="AssignmentTree_TreeNodeCollapsed" - OnTreeNodeExpanded="AssignmentTree_TreeNodeExpanded" OnInit="AssignmentTree_Init"> + OnTreeNodeExpanded="AssignmentTree_TreeNodeExpanded" OnInit="AssignmentTree_Init" OnSelectedNodeChanged="AssignmentTree_SelectedNodeChanged" ExpandDepth="1"> <Nodes> - <asp:TreeNode Text="User Assignments" Value="Users" PopulateOnDemand="True" - SelectAction="Expand" - NavigateUrl="~/Assignments.aspx" /> + <asp:TreeNode Text="All Assignments" Value="Users" PopulateOnDemand="True" /> </Nodes> <SelectedNodeStyle CssClass="selectednode" /> </asp:TreeView> Modified: Website/Includes/AssignmentsTree.ascx.cs =================================================================== --- Website/Includes/AssignmentsTree.ascx.cs 2006-07-31 19:48:43 UTC (rev 242) +++ Website/Includes/AssignmentsTree.ascx.cs 2006-07-31 20:21:40 UTC (rev 243) @@ -25,10 +25,17 @@ m_logg.Debug("Loading AssignmentsTree page"); } + protected void AssignmentTree_Init(object sender, EventArgs e) { if (Session["AssignmentNodes"] == null) Session.Add("AssignmentNodes", new ArrayList()); + + if (!m_user.HasRight("view_other_ai", Constants.PRODUCT_ANYID) && !m_user.HasRight("view_created_ai", Constants.PRODUCT_ANYID) && + !m_user.HasRight("view_other_wo", Constants.PRODUCT_ANYID) && !m_user.HasRight("view_created_wo", Constants.PRODUCT_ANYID)) + { + AssignmentTree.Visible = false; + } } protected void AssignmentTree_TreeNodeCollapsed(object sender, TreeNodeEventArgs e) { @@ -40,6 +47,25 @@ m_logg.Debug("Collapsing node [" + nodes[index].ToString() + "]"); nodes.RemoveAt(index); } + + if (e.Node.Selected && AssignmentTree.ShowExpandCollapse == false) + { + e.Node.Selected = false; + switch (e.Node.Depth) + { + case 0: + Response.Redirect("~/Assignments.aspx"); + break; + case 1: + Response.Redirect("~/Assignments.aspx?" + Constants.CODE_PRODUCT + "=" + e.Node.Value); + break; + case 2: + Response.Redirect("~/Assignments.aspx?" + Constants.CODE_PRODUCT + "=" + e.Node.Parent.Value + "&"+ Constants.CODE_USER + "=" + e.Node.Value); + break; + default: + break; + } + } } protected void AssignmentTree_TreeNodeExpanded(object sender, TreeNodeEventArgs e) { @@ -50,30 +76,156 @@ nodes.Add(e.Node.ValuePath); m_logg.Debug("Expanding node [" + nodes[nodes.IndexOf(e.Node.ValuePath)].ToString() + "]"); } + + if (e.Node.Selected && AssignmentTree.ShowExpandCollapse == false) + { + e.Node.Selected = false; + switch (e.Node.Depth) + { + case 0: + Response.Redirect("~/Assignments.aspx"); + break; + case 1: + Response.Redirect("~/Assignments.aspx?" + Constants.CODE_PRODUCT + "=" + e.Node.Value); + break; + case 2: + Response.Redirect("~/Assignments.aspx?" + Constants.CODE_USER + "=" + e.Node.Value); + break; + default: + break; + } + } } + protected void AssignmentTree_SelectedNodeChanged(object sender, EventArgs e) + { + TreeNode node = AssignmentTree.SelectedNode; + node.Selected = false; + if (AssignmentTree.ShowExpandCollapse == false) + { + if (node.Expanded == true) + node.Collapse(); + else + node.Expand(); + } + else + { + switch (node.Depth) + { + case 0: + Response.Redirect("~/Assignments.aspx"); + break; + case 1: + Response.Redirect("~/Assignments.aspx?" + Constants.CODE_PRODUCT + "=" + node.Value); + break; + case 2: + Response.Redirect("~/Assignments.aspx?" + Constants.CODE_PRODUCT + "=" + node.Parent.Value + "&" + Constants.CODE_USER + "=" + node.Value); + break; + default: + break; + } + } + } protected void AssignmentTree_TreeNodePopulate(object sender, TreeNodeEventArgs e) { m_logg.Debug("Populating tree"); + if (AssignmentTree.Visible != true) + return; + // Call the appropriate method to populate a node at a particular level. switch (e.Node.Depth) { case 0: + BuildProductList(e.Node); + break; + case 1: BuildUserList(e.Node); break; - case 1: + case 2: BuildAssignmentList(e.Node); break; default: break; } } + private void BuildProductList(TreeNode parent) + { + ArrayList nodes = (ArrayList)Session["AssignmentNodes"]; + tcdbDataSetTableAdapters.db_productsTableAdapter pAdapter = new tcdbDataSetTableAdapters.db_productsTableAdapter(); + tcdbDataSet.db_productsDataTable pTable = pAdapter.GetData(true, null); + foreach (tcdbDataSet.db_productsRow row in pTable) + { + TreeNode child = new TreeNode(); + child.Text = row.name; + child.Value = row.productID.ToString(); + child.PopulateOnDemand = true; + child.SelectAction = TreeNodeSelectAction.Select; + parent.ChildNodes.Add(child); + if (nodes.Contains(child.ValuePath)) + child.Expand(); + else + AssignmentTree_TreeNodePopulate(AssignmentTree, new TreeNodeEventArgs(child)); + } + // If there are no children + if (parent.ChildNodes.Count == 0) + AssignmentTree.Visible = false; + + // if there's only one + if (parent.ChildNodes.Count == 1) + { + TreeNode child = parent.ChildNodes[0]; + + child.NavigateUrl = "~/Assignments.aspx?" + Constants.CODE_PRODUCT + "=" + child.Value; + AssignmentTree.Nodes[0].Text = ""; + AssignmentTree.ShowExpandCollapse = false; + child.Expand(); + } + } + private void BuildUserList(TreeNode parent) + { + m_logg.Debug("Building user list"); + ArrayList nodes = (ArrayList)Session["AssignmentNodes"]; + tcdbDataSetTableAdapters.db_roleProductUserTableAdapter rpuAdapter = new tcdbDataSetTableAdapters.db_roleProductUserTableAdapter(); + tcdbDataSet.db_roleProductUserDataTable rpuTable = rpuAdapter.GetData(null, Convert.ToInt32(parent.Value), true); + m_logg.Debug("There are currently [" + rpuTable.Count.ToString() + "] users"); + + // Assignment status + int status = Constants.ASSIGNMENT_UNFINISHED; + if (statusComplete.Checked) + status = Constants.ASSIGNMENT_FINISHEDANDUNFINISHED; + + foreach (tcdbDataSet.db_roleProductUserRow row in rpuTable) + { + User u = UserDB.GetUserInfo(row.userID); + if (u.GetAssignments(true, status).Count == 0) + continue; + + // Create the new child node. + TreeNode child = new TreeNode(); + child.Text = u.FULLNAME; + child.Value = u.ID.ToString(); + child.PopulateOnDemand = true; + child.SelectAction = TreeNodeSelectAction.Select; + parent.ChildNodes.Add(child); + if (nodes.Contains(child.ValuePath)) + child.Expand(); + else + AssignmentTree_TreeNodePopulate(AssignmentTree,new TreeNodeEventArgs(child)); + } + + // if there are no assignments + if (parent.ChildNodes.Count == 0) + parent.Parent.ChildNodes.Remove(parent); + } private void BuildAssignmentList(TreeNode parent) { m_logg.Debug("Building assignment list"); // Populate the second-level nodes with assignments int status = Constants.ASSIGNMENT_UNFINISHED; + int productID = Convert.ToInt32(parent.Parent.Value); + int userID = Convert.ToInt32(parent.Value); + if (statusComplete.Checked) status = Constants.ASSIGNMENT_FINISHEDANDUNFINISHED; List<Assignment> assignmentList = UserDB.GetUserInfo(Convert.ToInt32(parent.Value)).GetAssignments(false,status); @@ -93,82 +245,36 @@ child.Text = a.NAME; if (a.ISACTIONITEM) { - child.Value = a.ACTIONITEM.ID.ToString(); - child.NavigateUrl = "~/ActionItem.aspx?" + Constants.CODE_AI + "=" + child.Value; + if ((m_user.HasRight("view_other_ai",productID)) || + ((userID == m_user.ID) && m_user.HasRight("view_my_ai", productID)) || + ((a.ACTIONITEM.CREATOR.ID == m_user.ID) && m_user.HasRight("view_created_ai", productID))) + { + child.Value = a.ACTIONITEM.ID.ToString(); + child.NavigateUrl = "~/ActionItem.aspx?" + Constants.CODE_AI + "=" + child.Value; + } + else continue; } else { - child.Value = a.WORKORDER.ID.ToString(); - child.NavigateUrl = "~/WorkOrder.aspx?" + Constants.CODE_WO + "=" + child.Value; + if ((m_user.HasRight("view_other_wo", productID)) || + ((userID == m_user.ID) && m_user.HasRight("view_my_ai", productID)) || + ((a.WORKORDER.CREATOR.ID == m_user.ID) && m_user.HasRight("view_created_ai", productID))) + { + child.Value = a.WORKORDER.ID.ToString(); + child.NavigateUrl = "~/WorkOrder.aspx?" + Constants.CODE_WO + "=" + child.Value; + } + else continue; } - // Set the PopulateOnDemand property to true so that the child nodes can be - // dynamically populated. - child.PopulateOnDemand = true; - - // Set additional properties for the node. - child.SelectAction = TreeNodeSelectAction.Expand; - // Add the new child node to the ChildNodes collection of the parent node. parent.ChildNodes.Add(child); - child.Expand(); } + if (parent.ChildNodes.Count == 0) + parent.Parent.ChildNodes.Remove(parent); } } + - private void BuildUserList(TreeNode parent) - { - m_logg.Debug("Building user list"); - // TODO: implement security on this list - - // Populate the first-level nodes with users - List<User> userList = UserDB.TCDB_GetUserList(); - int numFoundUsers = 0; - int lastUserID = 0; - ArrayList nodes = (ArrayList)Session["AssignmentNodes"]; - - m_logg.Debug("There are currently [" + userList.Count.ToString() + "] users"); - if (userList.Count > 0) - { - foreach (User u in userList) - { - if (u.GetAssignments(true, Constants.ASSIGNMENT_FINISHEDANDUNFINISHED).Count == 0) - continue; - numFoundUsers++; - lastUserID = u.ID; - - // Create the new child node. - TreeNode child = new TreeNode(); - child.Text = u.FULLNAME; - child.Value = u.ID.ToString(); - - // Set the PopulateOnDemand property to true so that the child nodes can be - // dynamically populated. - child.PopulateOnDemand = true; - - // Set additional properties for the node. - child.SelectAction = TreeNodeSelectAction.Expand; - - // TODO: Make sure that when the node is clicked on, it brings up a list of assignments - // for the specified user as the user would see them - child.NavigateUrl = "~/Assignments.aspx?" + Constants.CODE_USER + "=" + child.Value; - - // Add the new child node to the ChildNodes collection of the parent node. - parent.ChildNodes.Add(child); - if (nodes.Contains(child.ValuePath)) - child.Expand(); - } - } - - // TODO: work out the logic on this! - // If we only found one user (the current user), hide the tree - if (!m_user.HasRight(Constants.RIGHTS_SITEADMIN, Constants.PRODUCT_SITEID)) // && numFoundUsers <= 1 && lastUserID == m_user.ID) - { - m_logg.Debug("Hiding assignments tree because there is only one user (the current user) and no admin/rights to see others"); - AssignmentTree.Visible = false; - } - } - protected void statusComplete_CheckedChanged(object sender, EventArgs e) { ArrayList nodes = (ArrayList)Session["AssignmentNodes"]; Modified: Website/Includes/Products.ascx =================================================================== --- Website/Includes/Products.ascx 2006-07-31 19:48:43 UTC (rev 242) +++ Website/Includes/Products.ascx 2006-07-31 20:21:40 UTC (rev 243) @@ -67,10 +67,10 @@ { Panel ruPanel = (Panel)sender; - tcdbDataSetTableAdapters.db_roleTableAdapter rAdapter = new tcdbDataSetTableAdapters.db_roleTableAdapter(); - tcdbDataSet.db_roleDataTable rTable = rAdapter.GetData(null, null, true); + tcdbDataSetTableAdapters.db_roleUserProductTableAdapter rupAdapter = new tcdbDataSetTableAdapters.db_roleUserProductTableAdapter(); + tcdbDataSet.db_roleUserProductDataTable rupTable = rupAdapter.GetData(null, productID, true); - foreach (tcdbDataSet.db_roleRow rRow in rTable) + foreach (tcdbDataSet.db_roleUserProductRow rRow in rupTable) { int roleID = rRow.roleID; Modified: Website/Right.aspx =================================================================== --- Website/Right.aspx 2006-07-31 19:48:43 UTC (rev 242) +++ Website/Right.aspx 2006-07-31 20:21:40 UTC (rev 243) @@ -1,4 +1,4 @@ -<%@ Page Language="C#" MasterPageFile="~/TCDB.master" AutoEventWireup="true" Title="TCDB: Right" %> +<%@ Page Language="C#" MasterPageFile="~/TCDB.master" AutoEventWireup="true" Title="TCDB: Right" ValidateRequest="false"%> <%@ Register Src="~/Includes/AdministrationTree.ascx" TagPrefix="admin" TagName="Tree" %> <%@ Register Src="~/Includes/Rights.ascx" TagPrefix="admin" TagName="Right" %> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |