From: <ro...@us...> - 2006-07-31 21:46:49
|
Revision: 247 Author: rouquin Date: 2006-07-31 14:46:44 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/tcdb/?rev=247&view=rev Log Message: ----------- Added rights to the ActionItems page. I'd still like to filter the assignedTo list, but that'll wait for another day. Modified Paths: -------------- Website/Includes/ActionItems.ascx Website/Includes/ActionItems.ascx.cs Website/Includes/Assignments.ascx Website/Includes/Assignments.ascx.cs Website/Includes/AssignmentsTree.ascx.cs Modified: Website/Includes/ActionItems.ascx =================================================================== --- Website/Includes/ActionItems.ascx 2006-07-31 21:10:19 UTC (rev 246) +++ Website/Includes/ActionItems.ascx 2006-07-31 21:46:44 UTC (rev 247) @@ -31,14 +31,14 @@ <label> Status:</label><asp:DropDownList ID="statusList" runat="server" AutoPostBack="True" OnSelectedIndexChanged="statusChanged" DataSourceID="StatusDataSource" DataTextField="statusName" - DataValueField="statusID" AppendDataBoundItems="True" SelectedValue='<%# Bind("statusID") %>'> + DataValueField="statusID" AppendDataBoundItems="True" SelectedValue='<%# Bind("statusID") %>' OnInit="statusList_Init"> </asp:DropDownList> </div> <div class="buttons"> <label> % Complete:</label><asp:RadioButtonList ID="percentList" runat="server" RepeatDirection="Horizontal" AutoPostBack="True" OnSelectedIndexChanged="percentChanged" SelectedValue='<%# Bind("percentComplete") %>' - CssClass="buttons"> + CssClass="buttons" OnInit="percentList_Init"> <asp:ListItem>0</asp:ListItem> <asp:ListItem>25</asp:ListItem> <asp:ListItem>50</asp:ListItem> @@ -100,9 +100,9 @@ <div class="left"> <div class="bottom"> <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" - Text="New" /> | <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" - CommandName="Edit" Text="Edit" /> | <asp:LinkButton ID="DeleteButton" runat="server" - CausesValidation="False" CommandName="deleteItem" Text="Delete" OnCommand="deleteItem" /> + Text="New" OnInit="NewButton_Init" /> | <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" + CommandName="Edit" Text="Edit" OnInit="EditButton_Init" /> | <asp:LinkButton ID="DeleteButton" runat="server" + CausesValidation="False" CommandName="deleteItem" Text="Delete" OnCommand="deleteItem" OnInit="DeleteButton_Init" /> </div> </div> <div class="right"> @@ -170,7 +170,7 @@ Finished:</label><div class="calendar"><ew:CalendarPopup ID="dateFinished" runat="server" PopupLocation="Left" ShowClearDate="true" ShowGoToToday="True" NullableLabelText="Select a date" ControlDisplay="LabelImage" ImageUrl="../App_Themes/Python/Images/calendar.gif" Nullable="True" OnDateChanged="dateFinished_DateChanged" - SelectedDate="" UpperBoundDate="12/31/9999 23:59:59" VisibleDate="" AutoPostBack="True"> + SelectedDate="" UpperBoundDate="12/31/9999 23:59:59" VisibleDate="" AutoPostBack="True" OnInit="dateFinished_Init"> </ew:CalendarPopup></div> </div> </div> @@ -206,7 +206,7 @@ <div class="item"> <label> Assigned To:</label><asp:DropDownList ID="assignedTo" runat="server" DataSourceID="UserDataSource" - DataTextField="fullName" DataValueField="userID" SelectedValue='<%# Bind("assignedID") %>'> + DataTextField="fullName" DataValueField="userID" SelectedValue='<%# Bind("assignedID") %>' OnDataBound="assignedTo_DataBound"> </asp:DropDownList> </div> </div> @@ -288,7 +288,7 @@ <label> Assigned To:</label><asp:DropDownList ID="assignedTo" runat="server" DataSourceID="UserDataSource" DataTextField="fullName" DataValueField="userID" AppendDataBoundItems="True" - SelectedValue='<%# Bind("assignedID") %>'> + SelectedValue='<%# Bind("assignedID") %>' OnDataBound="assignedTo_DataBound"> </asp:DropDownList></div> </div> <div class="end"> Modified: Website/Includes/ActionItems.ascx.cs =================================================================== --- Website/Includes/ActionItems.ascx.cs 2006-07-31 21:10:19 UTC (rev 246) +++ Website/Includes/ActionItems.ascx.cs 2006-07-31 21:46:44 UTC (rev 247) @@ -20,28 +20,43 @@ public partial class ActionItems : SiteUserControl { private static ILog m_logg = LogManager.GetLogger("Page:ActionItems"); - private int item_id = Convert.ToInt32(HttpContext.Current.Request.QueryString[Constants.CODE_AI]); + 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"]; protected void Page_Load(object sender, EventArgs e) { if (!m_user.ISAUTHENTICATED) { return; } + if (productID == 0) + productID = Constants.PRODUCT_SITEID; m_logg.Debug("Loading page ActionItems"); - if (item_id == 0) + if (item_id == null) { m_logg.Debug("Unable to locate action item ID in query string"); - if (mode == null) + if (mode != "new") { m_logg.Debug("Mode not set, redirecting to Assignments page"); Response.Redirect("Assignments.aspx?" + Constants.CODE_USER + "=" + m_user.ID); } } + else + { + ai = ActionItemDB.GetActionItem(Convert.ToInt32(item_id)); + 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)))) + Response.Redirect("~/Assignments.aspx?"+Constants.CODE_USER+"="+m_user.ID); + } + Session.Add("item_id", item_id); + Session.Add("productID", productID); Session.Add("tableName", "tcdb_actionItem"); - if (mode == "new") + if (mode == "new" && (m_user.HasRight("create_my_ai") || m_user.HasRight("create_other_ai"))) ActionItemsView.ChangeMode(FormViewMode.Insert); } @@ -51,6 +66,7 @@ DropDownList statusList = (DropDownList)ActionItemsView.FindControl("statusList"); Object dateFinished = ActionItemsView.FindControl("dateFinished"); Nullable<DateTime> date; + int id = Convert.ToInt32(item_id); if (ActionItemsView.CurrentMode == FormViewMode.ReadOnly) { @@ -68,13 +84,13 @@ // Update Database tcdbDataSetTableAdapters.db_actionItemsTableAdapter aiAdapter = new tcdbDataSetTableAdapters.db_actionItemsTableAdapter(); - aiAdapter.upd_actionItemStatus(item_id, Convert.ToInt32(statusList.SelectedValue), Convert.ToInt32(percentList.SelectedValue), date); + aiAdapter.upd_actionItemStatus(id, Convert.ToInt32(statusList.SelectedValue), Convert.ToInt32(percentList.SelectedValue), date); m_logg.Debug("Action Item updated, preparing to send email"); if (date == null) - ActionItemDB.SendUpdatedActionItemMail(item_id, m_user); + ActionItemDB.SendUpdatedActionItemMail(id, m_user); else - ActionItemDB.SendCompletedActionItemMail(item_id, m_user); + ActionItemDB.SendCompletedActionItemMail(id, m_user); } @@ -263,7 +279,7 @@ protected void deleteItem(object sender, CommandEventArgs e) { tcdbDataSetTableAdapters.db_actionItemsTableAdapter aiAdapter = new tcdbDataSetTableAdapters.db_actionItemsTableAdapter(); - aiAdapter.Delete(item_id, 0); + aiAdapter.Delete(Convert.ToInt32(item_id), 0); Response.Redirect("Assignments.aspx?" + Constants.CODE_USER + "=" + m_user.ID); } @@ -277,7 +293,7 @@ true); if (aiTable.Count > 0) { - int id = Convert.ToInt32(aiTable[aiTable.Count - 1]["childID"]); + int id = aiTable[aiTable.Count - 1].childID; m_logg.Info("Action Item #" + id + "Created"); //set the content' @@ -298,4 +314,69 @@ updateStatus(); Response.Redirect("ActionItem.aspx?" + Constants.CODE_AI + "=" + item_id.ToString()); } + protected void statusList_Init(object sender, EventArgs e) + { + DropDownList statusList = (DropDownList)sender; + + if (ai != null && + (!m_user.HasRight("status_other_ai", productID) && + !(ai.ASSIGNED.ID == m_user.ID && m_user.HasRight("status_my_ai", productID)) && + !(ai.CREATOR.ID == m_user.ID && m_user.HasRight("status_created_ai", productID)))) + statusList.Enabled = false; + } + protected void percentList_Init(object sender, EventArgs e) + { + RadioButtonList percentList = (RadioButtonList) sender; + + if (ai != null && + (!m_user.HasRight("status_other_ai", productID) && + !(ai.ASSIGNED.ID == m_user.ID && m_user.HasRight("status_my_ai", productID)) && + !(ai.CREATOR.ID == m_user.ID && m_user.HasRight("status_created_ai", productID)))) + percentList.Enabled = false; + } + protected void dateFinished_Init(object sender, EventArgs e) + { + CalendarPopup dateFinished = (CalendarPopup) sender; + + if (ai != null && + (!m_user.HasRight("status_other_ai", productID) && + !(ai.ASSIGNED.ID == m_user.ID && m_user.HasRight("status_my_ai", productID)) && + !(ai.CREATOR.ID == m_user.ID && m_user.HasRight("status_created_ai", productID)))) + dateFinished.Enabled = false; + } + protected void assignedTo_DataBound(object sender, EventArgs e) + { + DropDownList assignedTo = (DropDownList)ActionItemsView.FindControl("assignedTo"); + + if (!m_user.HasRight("create_other_ai", Constants.PRODUCT_ANYID)) + assignedTo.Enabled = false; + } + protected void NewButton_Init(object sender, EventArgs e) + { + LinkButton newBtn = (LinkButton)sender; + + if (ai != null && + !m_user.HasRight("create_my_ai", Constants.PRODUCT_ANYID) && !m_user.HasRight("create_other_ai", Constants.PRODUCT_ANYID)) + newBtn.Visible = false; + } + protected void EditButton_Init(object sender, EventArgs e) + { + LinkButton editBtn = (LinkButton)sender; + + if (ai != null && + !m_user.HasRight("edit_other_ai", productID) && + !(ai.ASSIGNED.ID == m_user.ID && m_user.HasRight("edit_my_ai", productID)) && + !(ai.CREATOR.ID == m_user.ID && m_user.HasRight("edit_created_ai", productID))) + editBtn.Visible = false; + } + protected void DeleteButton_Init(object sender, EventArgs e) + { + LinkButton deleteBtn = (LinkButton)sender; + + if (ai != null && + !m_user.HasRight("delete_other_ai", productID) && + !(ai.ASSIGNED.ID == m_user.ID && m_user.HasRight("delete_my_ai", productID)) && + !(ai.CREATOR.ID == m_user.ID && m_user.HasRight("delete_created_ai", productID))) + deleteBtn.Visible = false; + } } Modified: Website/Includes/Assignments.ascx =================================================================== --- Website/Includes/Assignments.ascx 2006-07-31 21:10:19 UTC (rev 246) +++ Website/Includes/Assignments.ascx 2006-07-31 21:46:44 UTC (rev 247) @@ -22,7 +22,7 @@ </div> <div class="right"> <div class="buttons"> - <asp:LinkButton ID="newActionItem" runat="server" PostBackUrl="~/ActionItem.aspx?mode=new">New Action Item</asp:LinkButton> + <asp:LinkButton ID="newActionItem" runat="server" PostBackUrl="~/ActionItem.aspx?mode=new" OnInit="newActionItem_Init">New Action Item</asp:LinkButton> <!-- <asp:LinkButton ID="newWorkOrder" runat="server" PostBackUrl="~/WorkOrder.aspx?mode=new">New Work Order</asp:LinkButton> --> </div> Modified: Website/Includes/Assignments.ascx.cs =================================================================== --- Website/Includes/Assignments.ascx.cs 2006-07-31 21:10:19 UTC (rev 246) +++ Website/Includes/Assignments.ascx.cs 2006-07-31 21:46:44 UTC (rev 247) @@ -150,7 +150,7 @@ !(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>"; + gRow.Cells[1].Text = "<a href=\"ActionItem.aspx?"+Constants.CODE_PRODUCT+"="+productID+"&" + Constants.CODE_AI + "=" + cid + "\">" + displayName + "</a>"; } else if (type == Constants.CODE_WO) { @@ -162,7 +162,7 @@ !(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>"; + gRow.Cells[1].Text = "<a href=\"WorkOrder.aspx?" + Constants.CODE_PRODUCT + "=" + productID + "&" + Constants.CODE_WO + "=" + cid + "\">" + name + "</a>"; } else { @@ -517,4 +517,11 @@ if (!IsPostBack) cboPriorityFilter.Checked = m_user.GetConfigBool("filter_enable_priority_filter"); } + protected void newActionItem_Init(object sender, EventArgs e) + { + LinkButton newAI = (LinkButton)sender; + + if (!m_user.HasRight("create_my_ai", Constants.PRODUCT_ANYID) && !m_user.HasRight("create_other_ai", Constants.PRODUCT_ANYID)) + newAI.Visible = false; + } } Modified: Website/Includes/AssignmentsTree.ascx.cs =================================================================== --- Website/Includes/AssignmentsTree.ascx.cs 2006-07-31 21:10:19 UTC (rev 246) +++ Website/Includes/AssignmentsTree.ascx.cs 2006-07-31 21:46:44 UTC (rev 247) @@ -195,8 +195,13 @@ if (statusComplete.Checked) status = Constants.ASSIGNMENT_FINISHEDANDUNFINISHED; + int lastID = -1; foreach (tcdbDataSet.db_roleProductUserRow row in rpuTable) { + if (row.userID == lastID) + continue; + else + lastID = row.userID; User u = UserDB.GetUserInfo(row.userID); if (u.GetAssignments(true, status).Count == 0) continue; @@ -250,7 +255,7 @@ ((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; + child.NavigateUrl = "~/ActionItem.aspx?" + Constants.CODE_PRODUCT + "=" + productID + "&" + Constants.CODE_AI + "=" + child.Value; } else continue; } @@ -261,7 +266,7 @@ ((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; + child.NavigateUrl = "~/WorkOrder.aspx?"+Constants.CODE_PRODUCT+"="+productID+"&" + Constants.CODE_WO + "=" + child.Value; } else continue; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |