예제 #1
0
        private bool IsFieldExcludedResourcesLevel()
        {
            if (Web.CurrentUser.IsSiteAdmin ||
                string.Equals(
                    CoreFunctions.GetRealUserName(SPContext.Current.Web.CurrentUser.LoginName),
                    ownerusername,
                    StringComparison.InvariantCultureIgnoreCase))
            {
                var act     = new Act(Web);
                var actType = 0;

                var levels = act.GetLevelsFromSite(out actType, string.Empty);

                return(actType <= 2);
            }

            return(true);
        }
예제 #2
0
        protected override void CreateChildControls()
        {
            if (Field == null)
            {
                return;
            }
            base.CreateChildControls();

            if (ControlMode == SPControlMode.Display)
            {
                return;
            }

            ddlLevels = (RadioButtonList)this.TemplateContainer.FindControl("ddlLevels");

            string username = "";

            try
            {
                SPFieldUserValue uv = new SPFieldUserValue(Web, ListItem["SharePointAccount"].ToString());
                if (uv.User.LoginName != "")
                {
                    username = CoreFunctions.GetRealUserName(uv.User.LoginName, Web.Site);
                }
            }
            catch { }

            if (username != "" || ControlMode == SPControlMode.New)
            {
                Act act = new Act(Web);
                bIsOnline = act.IsOnline;

                if (!bIsOnline || (bIsOnline && (Web.CurrentUser.IsSiteAdmin || CoreFunctions.GetRealUserName(Web.CurrentUser.LoginName, Web.Site).ToLower() == act.OwnerUsername.ToLower())))
                {
                    int actType = 0;

                    ArrayList Levels = act.GetLevelsFromSite(out actType, username);

                    if (actType > 2)
                    {
                        foreach (ActLevel Level in Levels)
                        {
                            ListItem li = new ListItem(GetLevelName(Level, act), Level.id.ToString());

                            try
                            {
                                if (Level.isUserInLevel)
                                {
                                    li.Selected = true;
                                }
                            }
                            catch { }

                            if (Level.availableactivations <= 0 && Level.id != 0 && !Level.isUserInLevel)
                            {
                                li.Enabled = false;
                            }

                            ddlLevels.Items.Add(li);
                        }

                        if (ControlMode == SPControlMode.New)
                        {
                            foreach (ListItem li in ddlLevels.Items)
                            {
                                if (li.Value.ToString() == "1" && li.Enabled)
                                {
                                    li.Selected = true;
                                }
                            }
                        }
                    }
                }
            }
        }