protected void Page_Load(object sender, EventArgs e)
        {
            _web = SPContext.Current.Web;
            _list = _web.Lists[new Guid(Request["ListId"])];
            _field = _list.Fields.TryGetFieldByStaticName(Request["ColumnName"]);
            if (!_list.DoesUserHavePermissions(SPBasePermissions.ManageWeb))
                SPUtility.Redirect(SPUtility.AccessDeniedPage + "?Source=" + SPHttpUtility.UrlKeyValueEncode(_web.Site.MakeFullUrl(Request.RawUrl)), SPRedirectFlags.RelativeToLayoutsPage, Context);

            if (!IsPostBack)
                MessagesLiteral.Text = "Будет выполнено обновление значений поля \"" + _field.Title + "\" из базы данных. Продолжить?";
        }
예제 #2
0
        private bool CheckCustomRights(SPList currentList)
        {
            //SPUser currentUser = spWeb.SiteUsers[HttpContext.Current.User.Identity.Name.ToString()];
            SPUser currentUser    = spWeb.CurrentUser;
            bool   userPermission = currentList.DoesUserHavePermissions(currentUser, SPBasePermissions.ManageLists);

            if (userPermission)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            Control browseControl = FindBrowseLink(this);

            if (browseControl != null)
            {
                SPList l = GetListFromPropBag();
                if (l != null && l.DoesUserHavePermissions(SPBasePermissions.AddListItems))
                {
                    browseControl.Parent.Controls.Add(new LiteralControl(" "));
                    LiteralControl addItemButton = new LiteralControl();
                    addItemButton.Text = "<a id=\"" + this.ClientID + "_addItem\" title=\"Add Item\" onclick=\"window.epmLiveGenericEntityEditor.OpenUrlWithModal('" + l.DefaultNewFormUrl + "');return false;\" href=\"#\">" +
                                         "<IMG style=\"BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; position:relative; top:-2px;\" title=\"AddItem\" alt=\"Add item to lookup list\" src=\"/_layouts/epmlive/images/Plus14.png\">" +
                                         "</a>";

                    browseControl.Parent.Controls.Add(addItemButton);
                    Image dropImg = new Image();
                    dropImg.ImageUrl            = "/_layouts/epmlive/images/dropdown2.png";
                    dropImg.Attributes["id"]    = propBag.Field + "_ddlShowAll";
                    dropImg.Attributes["style"] = "margin-left: -5px;";
                    browseControl.Parent.Controls.AddAt(0, dropImg);

                    (browseControl.Parent as TableCell).Attributes["Style"] = "padding-left: 5px;";
                }

                //if (propBag.Required)
                //{
                //    HtmlGenericControl divClear = new HtmlGenericControl("div");
                //    divClear.Attributes.Add("style", "clear:both");

                //    HtmlGenericControl errorText = new HtmlGenericControl("textarea");
                //    errorText.ID = propBag.Field + "_errorText";
                //    errorText.Attributes.Add("class", "ms-inputuserfield");

                //    browseControl.Parent.Controls.Add(divClear);
                //    browseControl.Parent.Controls.Add(errorText);
                //    requiredErrTxtId = errorText.ClientID;
                //}
            }
        }
예제 #4
0
        //private void InsertPeopleEditor()
        //{
        //    pnlCCPeopleEditor.Controls.Clear();
        //    WEPeopleEditor wpe = new WEPeopleEditor();
        //    wpe.Height = new System.Web.UI.WebControls.Unit("10px");

        //    pnlCCPeopleEditor.Controls.Add(wpe);
        //    wpe.ID = "commentWPE";
        //    _wpeId = wpe.ID;
        //    pnlCCPeopleEditor.Height = new System.Web.UI.WebControls.Unit("10px");
        //}

        private void EnsureCommentsListExist()
        {
            SPSite cSite        = SPContext.Current.Site;
            SPWeb  cWeb         = SPContext.Current.Web;
            SPList commentsList = cWeb.Lists.TryGetList("Comments");

            if (commentsList == null)
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite eleSite = new SPSite(cWeb.Url))
                    {
                        using (SPWeb eleWeb = eleSite.OpenWeb())
                        {
                            eleWeb.AllowUnsafeUpdates = true;
                            Guid guid           = eleWeb.Lists.Add("Comments", "", SPListTemplateType.GenericList);
                            commentsList        = eleWeb.Lists[guid];
                            commentsList.Hidden = true;
                            commentsList.Fields.Add("ItemId", SPFieldType.Text, true);
                            commentsList.Fields.Add("ListId", SPFieldType.Text, true);
                            commentsList.Fields.Add("Comment", SPFieldType.Note, false);
                            commentsList.Update();

                            SPView view = commentsList.DefaultView;
                            view.ViewFields.Add("ItemId");
                            view.ViewFields.Add("ListId");
                            view.ViewFields.Add("Comment");
                            view.Update();

                            commentsList.Update();
                            eleWeb.Update();
                        }
                    }
                });
            }

            _hasPerm = commentsList.DoesUserHavePermissions(SPBasePermissions.AddListItems).ToString();
        }
        public static bool LPPFEPermissionCheck(SPList list, SPBasePermissions spBasePermissions)
        {
            bool hasPFEResourceCenterPermissions = true;

            try
            {
                if (list != null)
                {
                    switch (spBasePermissions)
                    {
                    case SPBasePermissions.AddListItems:
                    {
                        if (list.DoesUserHavePermissions(SPBasePermissions.AddListItems))
                        {
                            var      args     = new object[] { list.ParentWeb, list.ParentWeb.CurrentUser.ID, false, hasPFEResourceCenterPermissions };
                            Assembly assembly = Assembly.Load("WorkEnginePPM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5");
                            Type     type     = assembly.GetType("WorkEnginePPM.Core.ResourceManagement.Utilities", true, true);
                            type.GetMethod("CheckPFEResourceCenterPermission", BindingFlags.Public | BindingFlags.Static).Invoke(null, args);

                            hasPFEResourceCenterPermissions = Convert.ToBoolean(args[3]);
                            return(hasPFEResourceCenterPermissions);
                        }
                    }
                    break;

                    case SPBasePermissions.EditListItems:
                    {
                        if (list.DoesUserHavePermissions(SPBasePermissions.EditListItems))
                        {
                            var      args     = new object[] { list.ParentWeb, list.ParentWeb.CurrentUser.ID, false, hasPFEResourceCenterPermissions };
                            Assembly assembly = Assembly.Load("WorkEnginePPM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5");
                            Type     type     = assembly.GetType("WorkEnginePPM.Core.ResourceManagement.Utilities", true, true);
                            type.GetMethod("CheckPFEResourceCenterPermission", BindingFlags.Public | BindingFlags.Static).Invoke(null, args);

                            hasPFEResourceCenterPermissions = Convert.ToBoolean(args[3]);
                            return(hasPFEResourceCenterPermissions);
                        }
                    }
                    break;

                    case SPBasePermissions.DeleteListItems:
                    {
                        if (CoreFunctions.DoesCurrentUserHaveFullControl(list.ParentWeb))
                        {
                            var      args     = new object[] { list.ParentWeb, list.ParentWeb.CurrentUser.ID, true, hasPFEResourceCenterPermissions };
                            Assembly assembly = Assembly.Load("WorkEnginePPM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5");
                            Type     type     = assembly.GetType("WorkEnginePPM.Core.ResourceManagement.Utilities", true, true);
                            type.GetMethod("CheckPFEResourceCenterPermission", BindingFlags.Public | BindingFlags.Static).Invoke(null, args);

                            hasPFEResourceCenterPermissions = Convert.ToBoolean(args[3]);

                            return(hasPFEResourceCenterPermissions);
                        }
                    }
                    break;
                    }


                    return(false);
                }
            }
            catch
            {
                //No need to handle this exception because If PFE is not configured on Share Point site then also It should show Invite button.
                //Hence, Rather then setting hasPFEResourceCenterPermissions = false; Keeping this exception block blank.
                return(true);
            }
            return(list.DoesUserHavePermissions(spBasePermissions));
        }
 private static bool LP(SPList list, SPBasePermissions spBasePermissions)
 {
     return(list.DoesUserHavePermissions(spBasePermissions));
 }
예제 #7
0
        public static bool HasPermissionLevel(SPList list, string permissionLevel)
        {
            var roleDefinition = GetRoleDefinition(list.ParentWeb, permissionLevel);
            if (roleDefinition == null)
            {
                return false;
            }

            return list.DoesUserHavePermissions(roleDefinition.BasePermissions);
        }
예제 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SPWeb  web    = SPContext.Current.Web;
            string resUrl = "";

            web.Site.CatchAccessDeniedException = false;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(SPContext.Current.Site.ID))
                {
                    using (SPWeb aweb = site.OpenWeb(web.ID))
                    {
                        resUrl = CoreFunctions.getConfigSetting(aweb, "EPMLiveResourceURL", true, false);
                    }
                }
            });

            //bool canManageAGroup = false;
            SPListItem oLi      = null;
            SPList     oList    = null;
            bool       bUseTeam = false;

            Guid listid = Guid.Empty;
            int  itemid = 0;

            try
            {
                listid = new Guid(Request["listid"]);
                itemid = int.Parse(Request["id"]);

                oList = web.Lists[listid];
                oLi   = oList.GetItemById(itemid);
                GridGanttSettings gSettings = new GridGanttSettings(oList);
                bUseTeam = gSettings.BuildTeam;
            }
            catch (Exception)
            {
                try
                {
                    APITeam.VerifyProjectTeamWorkspace(web, out itemid, out listid);
                    if (itemid > 0 && listid != Guid.Empty)
                    {
                        try
                        {
                            while (!web.IsRootWeb) //Inherit | Open
                            {
                                if (web.IsRootWeb)
                                {
                                    break;
                                }
                                web = web.ParentWeb;
                            }

                            oList = web.Lists[listid];
                            GridGanttSettings gSettings = ListCommands.GetGridGanttSettings(oList);
                            bUseTeam = gSettings.BuildTeam;
                            oLi      = oList.GetItemById(itemid);
                        }
                        catch { }
                    }
                }
                catch { }
            }

            if (bUseTeam)
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite tSite = new SPSite(web.Site.ID))
                    {
                        using (SPWeb tWeb = tSite.OpenWeb(web.ID))
                        {
                            SPListItem spListItem = null;
                            SPList tList          = tWeb.Lists[listid];
                            try
                            {
                                spListItem = tList.GetItemById(itemid);
                            }
                            catch (ArgumentException ex)
                            {
                                throw new SPException("The associated project does not exist or has been deleted.", ex);
                            }
                            web.Site.CatchAccessDeniedException = false;

                            foreach (SPRoleAssignment assn in spListItem.RoleAssignments)
                            {
                                if (assn.Member.GetType() == typeof(Microsoft.SharePoint.SPGroup))
                                {
                                    try
                                    {
                                        SPGroup group = web.SiteGroups.GetByID(assn.Member.ID);

                                        if (group.CanCurrentUserEditMembership)
                                        {
                                            string[] sG = group.Name.Split(' ');
                                            if (sG[sG.Length - 1] == "Member")
                                            {
                                                sDefaultGroup = group.ID.ToString();
                                            }

                                            bCanEditTeam = "true";
                                        }
                                    }
                                    catch { }
                                }
                            }
                        }
                    }
                });
            }
            else
            {
                foreach (SPGroup g in web.Groups)
                {
                    string[] sG = g.Name.Split(' ');
                    if (sG[sG.Length - 1] == "Member")
                    {
                        sDefaultGroup = g.ID.ToString();
                    }

                    if (g.CanCurrentUserEditMembership)
                    {
                        bCanEditTeam = "true";
                    }
                }
            }

            if (itemid > 0 && listid != Guid.Empty && PfeData.ConnectionProvider.AllowDatabaseConnections(web))
            {
                // collect pfe database project id for processing in UI part
                var repository = new PfeData.ProjectRepository();
                projectIdInPfe = repository.FindProjectId(web, listid, itemid);
            }

            if (web.Features[new Guid("84520a2b-8e2b-4ada-8f48-60b138923d01")] == null && !bUseTeam)
            {
                sDisable = "_spBodyOnLoadFunctionNames.push(\"ShowDisable\");";
                SPList teamlist = web.Lists["Team"];
                //if(web.DoesUserHavePermissions(SPBasePermissions.ManagePermissions))
                //{
                //    bCanEditTeam = "true";
                //}
            }
            else
            {
                try
                {
                    using (SPSite rsite = new SPSite(resUrl))
                    {
                        using (SPWeb rweb = rsite.OpenWeb())
                        {
                            SPList list = rweb.Lists["Resources"];
                            //DataTable dtTemp = list.Items.GetDataTable();
                            bCanAccessResourcePool = "true";
                            if (list.DoesUserHavePermissions(SPBasePermissions.AddListItems))
                            {
                                bCanAddResource = "true";
                                sNewResUrl      = list.Forms[PAGETYPE.PAGE_NEWFORM].ServerRelativeUrl;
                            }
                        }
                    }
                }
                catch { }

                XmlDocument doc = new XmlDocument();
                doc.LoadXml("<Grid/>");



                if (bUseTeam)
                {
                    try
                    {
                        if (oLi.DoesUserHavePermissions(SPBasePermissions.EditListItems))
                        {
                            bCanEditTeam = "true";
                        }

                        XmlAttribute attr = doc.CreateAttribute("WebId");
                        attr.Value = Convert.ToString(web.ID);
                        doc.FirstChild.Attributes.Append(attr);

                        attr       = doc.CreateAttribute("ListId");
                        attr.Value = Convert.ToString(listid);
                        doc.FirstChild.Attributes.Append(attr);

                        attr       = doc.CreateAttribute("ItemId");
                        attr.Value = Convert.ToString(itemid);
                        doc.FirstChild.Attributes.Append(attr);
                    }
                    catch
                    {
                    }
                }
                else
                {
                    SPList teamlist = web.Lists.TryGetList("Team");

                    if (teamlist == null)
                    {
                        web.AllowUnsafeUpdates = true;
                        web.Lists.Add("Team", "Use this list to manage your project team", SPListTemplateType.GenericList);
                        teamlist = web.Lists.TryGetList("Team");
                        try
                        {
                            teamlist.Fields.Add("ResID", SPFieldType.Number, false);
                            teamlist.Update();
                        }
                        catch { }
                    }
                }

                sLayoutParam = HttpUtility.HtmlEncode(doc.OuterXml);

                if (bCanEditTeam == "true")
                {
                    sResPool = Properties.Resources.txtBuildTeamResPool.Replace("#LayoutParam#", sLayoutParam).Replace("#DataParam#", sLayoutParam);
                    sResGrid = @"TreeGrid(   { 
                    Layout:{ Url:""../../_vti_bin/WorkEngine.asmx"",Timeout:0, Method:""Soap"",Function:""Execute"",Namespace:""workengine.com"",Param:{Function:""GetResourceGridLayout"",Dataxml:""" + sLayoutParam + @""" } } ,
                    Data:{ Url:""../../_vti_bin/WorkEngine.asmx"",Timeout:0, Method:""Soap"",Function:""Execute"",Namespace:""workengine.com"",Param:{Function:""GetResourceGridData"",Dataxml:""" + sLayoutParam + @""" } }, 
                    Debug:"""",SuppressMessage:""3""
                    }, 
	                ""divResPool"" );"    ;
                }
            }

            sUserInfoList = web.SiteUserInfoList.ID.ToString().ToUpper();

            if (Request["isDlg"] == "1")
            {
                sClose = "SP.SOD.execute('SP.UI.Dialog.js', 'SP.UI.ModalDialog.commonModalDialogClose', SP.UI.DialogResult.OK, '');";
            }
            else
            {
                if (String.IsNullOrEmpty(Request["Source"]))
                {
                    sClose = "location.href='" + ((web.ServerRelativeUrl == "/") ? "" : web.ServerRelativeUrl) + "'";
                }
                else
                {
                    sClose = "location.href='" + Request["Source"] + "'";
                }
            }
        }
예제 #9
0
        private string GetNewItemButtonLists()
        {
            SPWeb myworkWeb = SPContext.Current.Web;

            string newItemButtonLists = string.Empty;
            var    newItemLists       = new List <string>();

            List <myworksettings.MWList> excludedMyWorkLists =
                myworksettings.GetMyWorkListsFromDb(myworkWeb, EPMLiveCore.API.MyWork.GetArchivedWebs(myworkWeb.Site.ID));

            if (!UseCentralizedSettings)
            {
                foreach (
                    string myWorkSelectedList in
                    MyWorkSelectedLst.Where(myWorkSelectedList => !string.IsNullOrEmpty(myWorkSelectedList)))
                {
                    newItemLists.Add(myWorkSelectedList);
                    excludedMyWorkLists.RemoveAll(l => l.Name.Equals(myWorkSelectedList));
                }

                foreach (string selectedList in SelectedLst.Where(selectedList => !string.IsNullOrEmpty(selectedList))
                         )
                {
                    newItemLists.Add(selectedList);
                    excludedMyWorkLists.RemoveAll(l => l.Name.Equals(selectedList));
                }
            }
            else
            {
                SPWeb theWeb    = SPContext.Current.Web;
                Guid  lockedWeb = CoreFunctions.getLockedWeb(theWeb);

                using (SPWeb configWeb = (theWeb.ID != lockedWeb
                    ? theWeb.Site.OpenWeb(lockedWeb)
                    : theWeb.Site.OpenWeb(theWeb.ID)))
                {
                    myworkWeb = configWeb;

                    foreach (
                        string list in
                        CoreFunctions.getConfigSetting(configWeb, myworksettings.GeneralSettingsSelectedMyWorkLists)
                        .Split(new[] { ',' }).Where(list => !string.IsNullOrEmpty(list)))
                    {
                        newItemLists.Add(list);
                        excludedMyWorkLists.RemoveAll(l => l.Name.Equals(list));
                    }

                    foreach (
                        string list in
                        CoreFunctions.getConfigSetting(configWeb, myworksettings.GeneralSettingsSelectedLists)
                        .Split(new[] { ',' }).Where(list => !string.IsNullOrEmpty(list)))
                    {
                        newItemLists.Add(list);
                        excludedMyWorkLists.RemoveAll(l => l.Name.Equals(list));
                    }
                }
            }

            newItemLists = newItemLists.Distinct().OrderBy(l => l).ToList();

            if (newItemLists.Count > 0)
            {
                var newItemListsFormatted = new List <string>();

                foreach (string newItemList in newItemLists)
                {
                    SPList spList = myworkWeb.Lists.TryGetList(newItemList);


                    if (spList == null)
                    {
                        continue;
                    }

                    var gSettings = new GridGanttSettings(spList);

                    string rollupLists = gSettings.RollupLists;
                    bool   usePopUp    = gSettings.UsePopup;

                    if (string.IsNullOrEmpty(rollupLists))
                    {
                        if (spList.Hidden || !spList.DoesUserHavePermissions(SPBasePermissions.AddListItems) ||
                            gSettings.HideNewButton)
                        {
                            continue;
                        }

                        newItemListsFormatted.Add(string.Format(@"{{Name:'{0}',ListID:'{1}',UsePopUp:'{2}',Rollup:false}}", newItemList, spList.ID, usePopUp));
                    }
                    else
                    {
                        newItemListsFormatted.Add(string.Format(@"{{Name:'{0}',ListID:'{1}',UsePopUp:'{2}',Rollup:true}}", newItemList, spList.ID, usePopUp));
                    }
                }

                newItemButtonLists = string.Join(",", newItemListsFormatted.ToArray());
            }

            return(newItemButtonLists);
        }
예제 #10
0
        public static RibbonProperties GetRibbonProps(SPList list)
        {
            RibbonProperties rp = new RibbonProperties();

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(SPContext.Current.Web.Url))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        GridGanttSettings gSettings = GetGridGanttSettings(list);

                        string pubPC  = EPMLiveCore.CoreFunctions.getLockConfigSetting(web, "EPMLivePublisherProjectCenter", false);
                        string pubTC  = EPMLiveCore.CoreFunctions.getLockConfigSetting(web, "EPMLivePublisherTaskCenter", false);
                        bool foundmpp = false;

                        try
                        {
                            SPDocumentLibrary lib = (SPDocumentLibrary)web.Lists["Project Schedules"];
                            if (lib != null)
                            {
                                if (lib.ContentTypesEnabled)
                                {
                                    foreach (SPContentType ct in lib.ContentTypes)
                                    {
                                        string template = ct.DocumentTemplateUrl;
                                        if (template.Substring(template.Length - 3, 3) == "mpp")
                                        {
                                            foundmpp = true;
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    string template = lib.DocumentTemplateUrl;
                                    if (template.Substring(template.Length - 3, 3) == "mpp")
                                    {
                                        foundmpp = true;
                                    }
                                }
                            }
                        }
                        catch { }

                        if (gSettings.BuildTeam && list.Fields.GetFieldByInternalName("AssignedTo") != null)
                        {
                            if (list.DoesUserHavePermissions(SPBasePermissions.EditListItems))
                            {
                                rp.bBuildTeam = true;
                            }
                        }

                        bool.TryParse(EPMLiveCore.CoreFunctions.getConfigSetting(web, "EPMLiveDisablePublishing"), out rp.bDisableProject);
                        bool.TryParse(EPMLiveCore.CoreFunctions.getConfigSetting(web, "EPMLiveDisablePlanners"), out rp.bDisablePlan);

                        if (site.Features[new Guid("158c5682-d839-4248-b780-82b4710ee152")] != null)
                        {
                            ArrayList arr = new ArrayList(EPMLiveCore.CoreFunctions.getConfigSetting(site.RootWeb, "EPKLists").ToLower().Split(','));
                            if (arr.Contains(list.Title.ToLower()))
                            {
                                string menus = "";
                                menus        = EPMLiveCore.CoreFunctions.getConfigSetting(site.RootWeb, "EPK" + list.Title.Replace(" ", "") + "_menus");
                                if (menus == "")
                                {
                                    menus = EPMLiveCore.CoreFunctions.getConfigSetting(site.RootWeb, "EPKMenus");
                                }

                                rp.aEPKButtons = new ArrayList(menus.Split('|'));

                                string noactivex = "";
                                noactivex        = EPMLiveCore.CoreFunctions.getConfigSetting(site.RootWeb, "EPK" + list.Title.Replace(" ", "") + "_nonactivexs");
                                if (noactivex == "")
                                {
                                    noactivex = EPMLiveCore.CoreFunctions.getConfigSetting(site.RootWeb, "epknonactivexs");
                                }

                                rp.aEPKActivex = new ArrayList(noactivex.Split('|'));
                            }
                        }
                    }
                }
            });
            return(rp);
        }
        protected bool CurrentUserHaveResourceCenterPermission(SPBasePermissions itemPermission)
        {
            SPWeb currentWeb = SPContext.Current.Web;
            Guid  lockedWeb  = CoreFunctions.getLockedWeb(currentWeb);
            bool  hasPFEResourceCenterPermissions = true;

            try
            {
                using (SPWeb configWeb = (currentWeb.ID != lockedWeb
                    ? currentWeb.Site.OpenWeb(lockedWeb)
                    : currentWeb.Site.OpenWeb(currentWeb.ID)))
                {
                    SPList resourceList = configWeb.Lists.TryGetList("Resources");
                    if (resourceList != null)
                    {
                        switch (itemPermission)
                        {
                        case SPBasePermissions.AddListItems:
                        {
                            if (resourceList.DoesUserHavePermissions(SPBasePermissions.AddListItems))
                            {
                                if (WorkEnginePPM.Core.ResourceManagement.Utilities.CheckPFEResourceCenterPermission(currentWeb, SPContext.Current.Web.CurrentUser.ID, false, out hasPFEResourceCenterPermissions))
                                {
                                    return(hasPFEResourceCenterPermissions);
                                }
                                return(false);
                            }
                        }
                        break;

                        case SPBasePermissions.EditListItems:
                        {
                            if (resourceList.DoesUserHavePermissions(SPBasePermissions.EditListItems))
                            {
                                if (WorkEnginePPM.Core.ResourceManagement.Utilities.CheckPFEResourceCenterPermission(currentWeb, SPContext.Current.Web.CurrentUser.ID, false, out hasPFEResourceCenterPermissions))
                                {
                                    return(hasPFEResourceCenterPermissions);
                                }
                                return(false);
                            }
                        }
                        break;

                        case SPBasePermissions.DeleteListItems:
                        {
                            if (CoreFunctions.DoesCurrentUserHaveFullControl(resourceList.ParentWeb))
                            {
                                if (WorkEnginePPM.Core.ResourceManagement.Utilities.CheckPFEResourceCenterPermission(currentWeb, SPContext.Current.Web.CurrentUser.ID, true, out hasPFEResourceCenterPermissions))
                                {
                                    return(hasPFEResourceCenterPermissions);
                                }
                                return(false);
                            }
                        }
                        break;
                        }

                        return(false);
                    }
                }
            }
            catch
            {
                //No need to handle this exception because If PFE is not configured on Share Point site then also It should show Invite button.
                //Hence, Rather then setting hasPFEResourceCenterPermissions = false; Keeping this exception block blank.
                return(true);
            }
            return(true);
        }
        private bool ProcessDataList(SPWeb web, XmlNode newNode)
        {
            var    canPublish = false;
            SPList list       = null;

            try
            {
                list = web.Lists[HttpUtility.UrlDecode(Request["List"])];
            }
            catch (Exception ex)
            {
                DebugTrace.TraceError("Exception swallowed: {0}", ex);
            }

            if (list != null)
            {
                if (!list.Hidden)
                {
                    var gSettings = new GridGanttSettings(list);

                    if (gSettings.HideNewButton)
                    {
                        list = null;
                    }
                }
                else
                {
                    list = null;
                }
            }

            var newCell = doc.CreateNode(XmlNodeType.Element, "userdata", doc.NamespaceURI);

            if (list != null)
            {
                newCell.InnerText = list.Forms[PAGETYPE.PAGE_NEWFORM].ServerRelativeUrl;
                var attrName = doc.CreateAttribute("name");
                attrName.Value = "NewItemURL";
                newCell.Attributes.Append(attrName);
                newNode.AppendChild(newCell);

                newCell           = doc.CreateNode(XmlNodeType.Element, "userdata", doc.NamespaceURI);
                newCell.InnerText = "No";
                attrName          = doc.CreateAttribute("name");
                attrName.Value    = "CanPublish";
                newCell.Attributes.Append(attrName);

                if (list.DoesUserHavePermissions(SPBasePermissions.AddListItems))
                {
                    newCell.InnerText = "Yes";
                    canPublish        = true;
                }
            }

            newNode.AppendChild(newCell);
            newCell           = doc.CreateNode(XmlNodeType.Element, "cell", doc.NamespaceURI);
            newCell.InnerText = web.Title;
            newNode.AppendChild(newCell);
            newCell           = doc.CreateNode(XmlNodeType.Element, "cell", doc.NamespaceURI);
            newCell.InnerText = web.ServerRelativeUrl;
            newNode.AppendChild(newCell);
            newCell           = doc.CreateNode(XmlNodeType.Element, "userdata", doc.NamespaceURI);
            newCell.InnerText = web.ID.ToString();

            var attributeName = doc.CreateAttribute("name");

            attributeName.Value = "webid";
            newCell.Attributes.Append(attributeName);
            newNode.AppendChild(newCell);

            return(canPublish);
        }
예제 #13
0
        protected override void   CreateChildControls()
        {
            try
            {
                //Check if all properites are set
                if (!AllPropertiesSet())
                {
                    ShowMessage(LoadResource("PropertiesEmpty"));
                }
                else
                {
                    //Required properties are set
                    //Check if a valid the given URL is for an existing document library.
                    if (!IsValidDocumentLibrary())
                    {
                        ShowMessage(LoadResource("InvalidDocumentLibrary"));
                    }
                    else
                    {
                        SPList documentLibrary = GetDocumentLibraryFromUrl(SourceDocumentLibrary);
                        if (!documentLibrary.DoesUserHavePermissions(SPBasePermissions.ViewListItems))
                        {
                            ShowMessage(String.Format(LoadResource("NoPermissions"), documentLibrary.Title, documentLibrary.DefaultViewUrl));
                            return;
                        }
                        searchFormTable = new Table();
                        //valid document library
                        //Get Content types

                        List <SPContentType> allowedCtypes = GetAllowedContentTypes(documentLibrary);
                        if (allowedCtypes.Count == 0)
                        {//display error message
                            ShowMessage(LoadResource("NoContentTypesAttached"));
                        }
                        else
                        {
                            //Build UI
                            Controls.Add(searchFormTable);
                            //Add the search header
                            ctypeid = BuildSearchFormHeader(searchFormTable, allowedCtypes);
                            //Add the row that will holds the text boxes popualted
                            BuildFormRow(searchFormTable);
                            //Add the row holding the search button
                            BuildSearchRow(searchFormTable);
                            //Add the results grid
                            BuildResultsRow(searchFormTable);



                            //For the first time loading
                            //If there is nothing have been selected , then use the content type Id returned from building the UI
                            object temp = this.ViewState[ContentTypeViewStateKey];
                            if (temp != null)
                            {
                                ctypeid = temp.ToString();
                            }
                            else
                            {
                                AddContentTypeIDToViewState(ctypeid);
                            }


                            //After all parent controls have been added
                            //Build the search form textboxes and labels depending on the selected content type
                            BuildSearchForm(GetContentTypeByID(ctypeid));

                            //Register the script requred after all controlshave been added
                            RegisterRequiredScripts();

                            //  Get the results table form cache
                            if (this.ViewState[SearchKeywordsVSKey] != null)
                            {
                                Hashtable keywords = (Hashtable)this.ViewState[SearchKeywordsVSKey];
                                if (keywords.Count == 0)
                                {
                                    ShowMessage(LoadResource("NoSearchWords"));
                                }
                                else
                                {
                                    Search(keywords);
                                }
                            }
                        }
                    }
                }
            }



            catch (Exception ex)
            {
                ShowError(ex);
            }
        }