Example #1
0
        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);
        }
Example #2
0
        private void BindReminders()
        {
            Task.TaskSecurity sec = Task.GetSecurity(TaskID);
            bool IsMember         = sec.IsManager || sec.IsRealTaskResource;

            if (IsMember && TargetStartDate > DateTime.UtcNow)
            {
                int  Lag      = -1;
                bool IsActive = false;

                using (IDataReader reader = Schedule.GetReminderSubscriptionPersonalForObject(DateTypes.Task_StartDate, TaskID))
                {
                    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.Task_FinishDate, TaskID))
                {
                    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;
            }
        }
Example #3
0
        private void BindToolbar()
        {
            secHeader.Title = LocRM.GetString("tTitle");

            bool canUpdateConfigurationInfo = Task.CanUpdateConfigurationInfo(TaskId);
            bool canUpdate          = Task.CanUpdate(TaskId);
            bool canAddTodo         = Task.CanAddToDo(TaskId);
            bool canDelete          = Task.CanDelete(TaskId);
            bool canModifyResources = Task.CanModifyResources(TaskId);

            canViewFinances = Task.CanViewFinances(TaskId);

            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'/>&nbsp;" + */ 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;

            CommandManager    cm  = CommandManager.GetCurrent(this.Page);
            CommandParameters cp  = new CommandParameters();
            string            cmd = String.Empty;

            #region Add ToDo
            if (canAddTodo && !Security.CurrentUser.IsExternal)
            {
                subItem = new ComponentArt.Web.UI.MenuItem();
                subItem.Look.LeftIconUrl    = "~/Layouts/Images/icons/task_create.gif";
                subItem.Look.LeftIconWidth  = Unit.Pixel(16);
                subItem.Look.LeftIconHeight = Unit.Pixel(16);
                subItem.NavigateUrl         = "~/ToDo/ToDoEdit.aspx?TaskId=" + TaskId;
                subItem.Text = LocRM.GetString("tbAdd");
                topMenuItem.Items.Add(subItem);
            }
            #endregion

            #region Edit
            if (canUpdate && !Security.CurrentUser.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 Task
                subItem = new ComponentArt.Web.UI.MenuItem();
                subItem.Look.LeftIconUrl    = "~/Layouts/Images/icons/task1_edit.gif";
                subItem.Look.LeftIconWidth  = Unit.Pixel(16);
                subItem.Look.LeftIconHeight = Unit.Pixel(16);
                subItem.NavigateUrl         = "../Tasks/TaskEdit.aspx?TaskId=" + TaskId;
                subItem.Text = LocRM.GetString("EditTask");
                editItem.Items.Add(subItem);
                #endregion

                #region Edit Categories
                if (PortalConfig.CommonTaskAllowViewGeneralCategoriesField)
                {
                    subItem = new ComponentArt.Web.UI.MenuItem();
                    subItem.ClientSideCommand = "javascript:ShowWizard('../Tasks/EditCategories.aspx?TaskId=" + TaskId + "', 300, 250);";
                    subItem.Text = LocRM2.GetString("EditCategories");
                    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
                 */
                topMenuItem.Items.Add(editItem);
            }
            #endregion

            #region Modyfy Resources
            if (canModifyResources && !Security.CurrentUser.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);
                cp  = new CommandParameters("MC_PM_TaskResEdit");
                cmd = cm.AddCommand("Task", "", "TaskView", cp);
                cmd = cmd.Replace("\"", "&quot;");
                subItem.ClientSideCommand = "javascript:" + cmd;
                //subItem.ClientSideCommand = "javascript:ShowWizard('AddResources.aspx?TaskId=" + TaskId + "', 650, 350);";
                subItem.Text = LocRM.GetString("AssignWizard");
                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);
                }
            }
            #endregion

            #region Delete
            if (canDelete)
            {
                subItem = new ComponentArt.Web.UI.MenuItem();
                subItem.Look.LeftIconUrl    = "~/Layouts/Images/icons/task1_delete.gif";
                subItem.Look.LeftIconWidth  = Unit.Pixel(16);
                subItem.Look.LeftIconHeight = Unit.Pixel(16);
                subItem.ClientSideCommand   = "javascript:DeleteTask()";
                subItem.Text = LocRM.GetString("Delete");
                topMenuItem.Items.Add(subItem);
            }
            #endregion

            #region --- Seperator ---
            subItem        = new ComponentArt.Web.UI.MenuItem();
            subItem.LookId = "BreakItem";
            topMenuItem.Items.Add(subItem);
            #endregion

            #region Add Predecessors
            if (canUpdateConfigurationInfo && !isMSProject)
            {
                using (IDataReader rdr = Task.GetListVacantPredecessors(TaskId))
                {
                    if (rdr.Read())
                    {
                        subItem = new ComponentArt.Web.UI.MenuItem();
                        subItem.Look.LeftIconUrl    = "~/Layouts/Images/icons/task_predecessors.gif";
                        subItem.Look.LeftIconWidth  = Unit.Pixel(16);
                        subItem.Look.LeftIconHeight = Unit.Pixel(16);
                        cp  = new CommandParameters("MC_PM_AddPredTask");
                        cmd = cm.AddCommand("Task", "", "TaskView", cp);
                        cmd = cmd.Replace("\"", "&quot;");
                        subItem.ClientSideCommand = "javascript:" + cmd;
                        //subItem.NavigateUrl = "~/Tasks/AddPredecessor.aspx?BaseTaskID=" + TaskId;
                        subItem.Text = LocRM4.GetString("Add");
                        topMenuItem.Items.Add(subItem);
                    }
                }
            }
            #endregion

            #region Add Successors
            if (canUpdateConfigurationInfo && !isMSProject)
            {
                using (IDataReader rdr = Task.GetListVacantSuccessors(TaskId))
                {
                    if (rdr.Read())
                    {
                        subItem = new ComponentArt.Web.UI.MenuItem();
                        subItem.Look.LeftIconUrl    = "~/Layouts/Images/icons/task_sucessors.gif";
                        subItem.Look.LeftIconWidth  = Unit.Pixel(16);
                        subItem.Look.LeftIconHeight = Unit.Pixel(16);
                        cp  = new CommandParameters("MC_PM_AddSuccTask");
                        cmd = cm.AddCommand("Task", "", "TaskView", cp);
                        cmd = cmd.Replace("\"", "&quot;");
                        subItem.ClientSideCommand = "javascript:" + cmd;
                        //subItem.NavigateUrl = "~/Tasks/AddSuccessor.aspx?BaseTaskID=" + TaskId;
                        subItem.Text = LocRM4.GetString("AddSuc");
                        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 sPath = (Security.CurrentUser.IsExternal) ? "../External/ExternalCommentAdd.aspx" : "../Common/CommentAdd.aspx";
            subItem.ClientSideCommand = String.Format("javascript:OpenWindow('{0}?TaskId={1}',{2},false);",
                                                      sPath, TaskId, (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

            /*
             * 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);
             * sPath = (Security.CurrentUser.IsExternal) ? "../External/ExternalTimeTracking.aspx" : "../TimeTracking/TimeTrackingWeek.aspx";
             * subItem.ClientSideCommand = String.Format("javascript:ShowWizard('{0}?TaskId={1}', {2});",
             *      sPath, TaskId, (Security.CurrentUser.IsExternal)? "800,600" : "450, 200");
             * subItem.Text = LocRM2.GetString("AddTimeSheet");
             * topMenuItem.Items.Add(subItem);
             */
            #endregion

            #region UpdateHistory
            if (!Security.CurrentUser.IsExternal)
            {
                subItem = new ComponentArt.Web.UI.MenuItem();
                subItem.ClientSideCommand = String.Format("javascript:ShowWizard('../Common/SystemEventsByObject.aspx?ObjectId={0}&ObjectTypeId={1}', 750, 466);", TaskId, (int)ObjectTypes.Task);
                subItem.Text = LocRM6.GetString("UpdateHistory");
                topMenuItem.Items.Add(subItem);
            }
            #endregion

            #region Latest Visitors
            if (!Security.CurrentUser.IsExternal)
            {
                subItem = new ComponentArt.Web.UI.MenuItem();
                subItem.ClientSideCommand = String.Format("javascript:ShowWizard('../Common/LatestVisitors.aspx?ObjectId={0}&ObjectTypeId={1}', 450, 266);", TaskId, (int)ObjectTypes.Task);
                subItem.Text = LocRM6.GetString("LatestVisitors");
                topMenuItem.Items.Add(subItem);
            }
            #endregion

            #region System Notifications
            if (!Security.CurrentUser.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}", TaskId, ((int)ObjectTypes.Task).ToString());
                subItem.Text = LocRM2.GetString("SystemNotifications");
                topMenuItem.Items.Add(subItem);
            }
            #endregion

            #region System Reminder
            if (!Security.CurrentUser.IsExternal)
            {
                Task.TaskSecurity sec = Task.GetSecurity(TaskId);
                if (sec.IsManager || sec.IsRealTaskResource)
                {
                    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.Task, TaskId);
                    subItem.Text = LocRM2.GetString("EditReminder");
                    topMenuItem.Items.Add(subItem);
                }
            }
            #endregion

            #region Favorites
            if (!Task.CheckFavorites(TaskId) && !Security.CurrentUser.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);
        }