public static bool CheckSecurityForObject(ObjectTypes objectType, int ObjectId, int UserId) { bool isValid = false; if (objectType == ObjectTypes.Project) { Project.ProjectSecurity sec = Project.GetSecurity(ObjectId, UserId); isValid = sec.IsManager || sec.IsExecutiveManager || sec.IsTeamMember || sec.IsSponsor || sec.IsStakeHolder; } else if (objectType == ObjectTypes.Task) { Task.TaskSecurity sec = Task.GetSecurity(ObjectId, UserId); isValid = sec.IsManager || sec.IsRealTaskResource; } else if (objectType == ObjectTypes.ToDo) { ToDo.ToDoSecurity sec = ToDo.GetSecurity(ObjectId, UserId); isValid = sec.IsManager || sec.IsResource || sec.IsCreator; } else if (objectType == ObjectTypes.CalendarEntry) { CalendarEntry.EventSecurity sec = CalendarEntry.GetSecurity(ObjectId, UserId); isValid = sec.IsManager || sec.IsResource; } else if (objectType == ObjectTypes.Document) { Document.DocumentSecurity sec = Document.GetSecurity(ObjectId, UserId); isValid = sec.IsManager || sec.IsResource || sec.IsCreator; } return(isValid); }
private void BindToolbar() { string sharedreq = ""; if (SharedID > 0) { sharedreq = "&SharedId=" + SharedID; } secHeader.Title = LocRM.GetString("tTitle"); bool canUpdate = CalendarEntry.CanUpdate(EventId); bool canDelete = CalendarEntry.CanDelete(EventId); bool isExternal = Security.CurrentUser.IsExternal; ComponentArt.Web.UI.MenuItem topMenuItem = new ComponentArt.Web.UI.MenuItem(); topMenuItem.Text = /*"<img border='0' src='../Layouts/Images/downbtn.gif' width='9px' height='5px' align='absmiddle'/> " + */ LocRM2.GetString("Actions"); topMenuItem.Look.LeftIconUrl = ResolveUrl("~/Layouts/Images/downbtn1.gif"); topMenuItem.Look.LeftIconHeight = Unit.Pixel(5); topMenuItem.Look.LeftIconWidth = Unit.Pixel(16); topMenuItem.LookId = "TopItemLook"; ComponentArt.Web.UI.MenuItem subItem; #region Edit: Event if (canUpdate && !isExternal) { ComponentArt.Web.UI.MenuItem editItem = new ComponentArt.Web.UI.MenuItem(); editItem.Text = LocRM.GetString("Edit"); editItem.Look.RightIconUrl = "../Layouts/Images/arrow_right.gif"; editItem.Look.HoverRightIconUrl = "../Layouts/Images/arrow_right_hover.gif"; editItem.Look.RightIconWidth = Unit.Pixel(15); editItem.Look.RightIconHeight = Unit.Pixel(10); #region Edit Event subItem = new ComponentArt.Web.UI.MenuItem(); subItem.Look.LeftIconUrl = "~/Layouts/Images/icons/event_edit.gif"; subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.Look.LeftIconHeight = Unit.Pixel(16); subItem.NavigateUrl = "../Events/EventEdit.aspx?EventId=" + EventId + sharedreq; subItem.Text = LocRM.GetString("EditEvent"); editItem.Items.Add(subItem); #endregion #region Reccurence subItem = new ComponentArt.Web.UI.MenuItem(); subItem.Look.LeftIconUrl = "~/Layouts/Images/icons/recurrence.gif"; subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.Look.LeftIconHeight = Unit.Pixel(16); subItem.NavigateUrl = "../Events/RecEditor.aspx?EventId=" + EventId + sharedreq; subItem.Text = LocRM4.GetString("Recurrence"); editItem.Items.Add(subItem); #endregion /* #region Edit General Info * subItem = new ComponentArt.Web.UI.MenuItem(); * subItem.ClientSideCommand = "javascript:ShowWizard('EditGeneralInfo.aspx?IncidentId=" + IncidentId + "', 500, 400);"; * subItem.Text = LocRM2.GetString("EditGeneralInfo"); * editItem.Items.Add(subItem); #endregion * #region Edit Categories * subItem = new ComponentArt.Web.UI.MenuItem(); * subItem.ClientSideCommand = "javascript:ShowWizard('EditCategories.aspx?IncidentId=" + IncidentId + "', 300, 350);"; * subItem.Text = LocRM2.GetString("EditCategories"); * editItem.Items.Add(subItem); #endregion */ topMenuItem.Items.Add(editItem); } #endregion #region Modyfy Resources if (canUpdate && !isExternal) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.Look.LeftIconUrl = "~/Layouts/Images/icons/editgroup.gif"; subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.Look.LeftIconHeight = Unit.Pixel(16); CommandManager cm = CommandManager.GetCurrent(this.Page); CommandParameters cp = new CommandParameters("MC_PM_EventParticipants"); string cmd = cm.AddCommand("Event", "", "EventView", cp); cmd = cmd.Replace("\"", """); subItem.ClientSideCommand = "javascript:" + cmd; //subItem.ClientSideCommand = "javascript:ShowWizard('ParticipantsEditor.aspx?EventId=" + EventId + "', 650, 350);"; subItem.Text = LocRM.GetString("EventParticipants"); topMenuItem.Items.Add(subItem); if (!IsPostBack && Request["Assign"] == "1") { ClientScript.RegisterStartupScript(this.Page, this.GetType(), Guid.NewGuid().ToString(), "function Assign(){" + cmd + "} setTimeout('Assign()', 400);", true); //Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "<script language='javascript'>ShowWizard('ParticipantsEditor.aspx?EventId=" + EventId + "', 650, 350);</script>"); } } #endregion #region Delete if (canDelete) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.Look.LeftIconUrl = "~/Layouts/Images/icons/event_delete.gif"; subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.Look.LeftIconHeight = Unit.Pixel(16); subItem.ClientSideCommand = "javascript:DeleteEvent()"; subItem.Text = LocRM.GetString("Delete"); topMenuItem.Items.Add(subItem); } #endregion #region --- Seperator --- if (canUpdate || canDelete) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.LookId = "BreakItem"; topMenuItem.Items.Add(subItem); } #endregion #region Add Comments subItem = new ComponentArt.Web.UI.MenuItem(); subItem.Look.LeftIconUrl = "~/Layouts/Images/icons/comments.gif"; subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.Look.LeftIconHeight = Unit.Pixel(16); string commentaddlink = "../Common/CommentAdd.aspx?"; if (Security.CurrentUser.IsExternal) { commentaddlink = "../External/ExternalCommentAdd.aspx?"; } subItem.ClientSideCommand = String.Format("javascript:OpenWindow('{0}EventId={1}',{2},false);", commentaddlink, EventId, (Security.CurrentUser.IsExternal) ? "800,600" : "520,270"); subItem.Text = LocRM2.GetString("CreateComment"); topMenuItem.Items.Add(subItem); #endregion #region Timesheet // OR [2007-08-23]: We should use IbnNext TimeTracking /* * if(Configuration.ProjectManagementEnabled) * { * subItem = new ComponentArt.Web.UI.MenuItem(); * subItem.Look.LeftIconUrl = "~/Layouts/Images/icons/timesheet.gif"; * subItem.Look.LeftIconWidth = Unit.Pixel(16); * subItem.Look.LeftIconHeight = Unit.Pixel(16); * string sPath = (Security.CurrentUser.IsExternal) ? "../External/ExternalTimeTracking.aspx" : "../TimeTracking/TimeTrackingWeek.aspx"; * subItem.ClientSideCommand = String.Format("javascript:ShowWizard('{0}?EventId={1}', {2});", * sPath, EventId, (Security.CurrentUser.IsExternal) ? "800,600" : "450, 200"); * subItem.Text = LocRM2.GetString("AddTimeSheet"); * topMenuItem.Items.Add(subItem); * } */ #endregion #region UpdateHistory if (!isExternal) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.ClientSideCommand = String.Format("javascript:ShowWizard('../Common/SystemEventsByObject.aspx?ObjectId={0}&ObjectTypeId={1}', 750, 466);", EventId, (int)ObjectTypes.CalendarEntry); subItem.Text = LocRM5.GetString("UpdateHistory"); topMenuItem.Items.Add(subItem); } #endregion #region Latest Visitors if (!isExternal) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.ClientSideCommand = String.Format("javascript:ShowWizard('../Common/LatestVisitors.aspx?ObjectId={0}&ObjectTypeId={1}', 450, 266);", EventId, (int)ObjectTypes.CalendarEntry); subItem.Text = LocRM5.GetString("LatestVisitors"); topMenuItem.Items.Add(subItem); } #endregion #region System Notifications if (!isExternal) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.Look.LeftIconUrl = "~/Layouts/Images/accept_1.gif"; subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.Look.LeftIconHeight = Unit.Pixel(16); subItem.NavigateUrl = String.Format("../Directory/SystemNotificationForObject.aspx?ObjectId={0}&ObjectTypeId={1}", EventId, ((int)ObjectTypes.CalendarEntry).ToString()); subItem.Text = LocRM2.GetString("SystemNotifications"); topMenuItem.Items.Add(subItem); } #endregion #region System Reminder if (!isExternal) { CalendarEntry.EventSecurity sec = CalendarEntry.GetSecurity(EventId); if (sec.IsManager || sec.IsResource) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.Look.LeftIconUrl = "~/Layouts/Images/reminder.gif"; subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.Look.LeftIconHeight = Unit.Pixel(16); subItem.ClientSideCommand = String.Format("javascript:ShowWizard('../Directory/SystemRemindersForObject.aspx?ObjectTypeId={0}&ObjectId={1}', 420, 150)", (int)ObjectTypes.CalendarEntry, EventId); subItem.Text = LocRM2.GetString("EditReminder"); topMenuItem.Items.Add(subItem); } } #endregion #region Favorites if (!CalendarEntry.CheckFavorites(EventId) && !isExternal) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.Look.LeftIconUrl = "~/Layouts/Images/Favorites.gif"; subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.Look.LeftIconHeight = Unit.Pixel(16); subItem.ClientSideCommand = "javascript:" + Page.ClientScript.GetPostBackEventReference(btnAddToFavorites, ""); subItem.Text = LocRM.GetString("AddToFavorites"); topMenuItem.Items.Add(subItem); } #endregion secHeader.ActionsMenu.Items.Add(topMenuItem); }
private void BindReminders() { CalendarEntry.EventSecurity sec = CalendarEntry.GetSecurity(EventID); bool IsMember = sec.IsManager || sec.IsResource; if (IsMember && (TargetStartDate > DateTime.UtcNow || TargetFinishDate > DateTime.UtcNow && HasRecurrence)) { int Lag = -1; bool IsActive = false; using (IDataReader reader = Schedule.GetReminderSubscriptionPersonalForObject(DateTypes.CalendarEntry_StartDate, EventID)) { if (reader.Read()) { Lag = (int)reader["Lag"]; IsActive = (bool)reader["IsActive"]; } } if (IsActive) { imgReminderStart.ToolTip = String.Format("{0}: {1}", LocRM2.GetString("Start"), CommonHelper.GetIntervalString(Lag)); } else { imgReminderStart.ToolTip = CommonHelper.GetIntervalString(-1); if (imgReminderStart.ToolTip.StartsWith("[")) { imgReminderStart.ToolTip = imgReminderStart.ToolTip.Substring(1); } if (imgReminderStart.ToolTip.EndsWith("]")) { imgReminderStart.ToolTip = imgReminderStart.ToolTip.Substring(0, imgReminderStart.ToolTip.Length - 1); } imgReminderStart.ImageUrl = "~/Layouts/Images/reminder2.gif"; } } else { imgReminderStart.Visible = false; } if (IsMember && TargetFinishDate > DateTime.UtcNow) { int Lag = -1; bool IsActive = false; using (IDataReader reader = Schedule.GetReminderSubscriptionPersonalForObject(DateTypes.CalendarEntry_FinishDate, EventID)) { if (reader.Read()) { Lag = (int)reader["Lag"]; IsActive = (bool)reader["IsActive"]; } } if (IsActive) { imgReminderFinish.ToolTip = String.Format("{0}: {1}", LocRM2.GetString("Finish"), CommonHelper.GetIntervalString(Lag)); } else { imgReminderFinish.ToolTip = CommonHelper.GetIntervalString(-1); if (imgReminderFinish.ToolTip.StartsWith("[")) { imgReminderFinish.ToolTip = imgReminderFinish.ToolTip.Substring(1); } if (imgReminderFinish.ToolTip.EndsWith("]")) { imgReminderFinish.ToolTip = imgReminderFinish.ToolTip.Substring(0, imgReminderFinish.ToolTip.Length - 1); } imgReminderFinish.ImageUrl = "~/Layouts/Images/reminder2.gif"; } } else { imgReminderFinish.Visible = false; } }