Exemple #1
0
        internal static SPFeatureCollection GetFeatureCollection(SPSite spSite, bool elevatedPrivileges)
        {
            SPFeatureCollection featureCollection;

            if (elevatedPrivileges)
            {
                featureCollection = SpSiteElevation.SelectAsSystem(spSite, GetFeatureCollection);
            }
            else
            {
                featureCollection = spSite.Features;
            }

            return(featureCollection);
        }
Exemple #2
0
        /// <summary>
        /// get web based on location id
        /// </summary>
        /// <param name="location">location of sharepoint object to return as SPWeb</param>
        /// <returns>undisposed SPWeb object</returns>
        /// <remarks>please dispose, if not needed anymore</remarks>
        internal static SPWeb GetWeb(Location location, bool elevatedPrivileges)
        {
            if (location == null)
            {
                return(null);
            }

            SPSite spSite = new SPSite(StringHelper.UniqueIdToGuid(location.ParentId));

            if (elevatedPrivileges)
            {
                return(SpSiteElevation.SelectAsSystem(spSite, GetWeb, location.Id));
            }
            else
            {
                return(spSite.OpenWeb(location.Id));
            }

            //TODO: hm, think how to refactor so that it is possible to dispose the spsite object here
        }