Example #1
0
        public bool IsInherited(SPList list, SPListItem listItem)
        {
            var inheritance = new Inheritance();

            Validate(inheritance.Errors, list, listItem);
            if (!inheritance.Errors.Any())
            {
                var permissionsGetOptions = new PermissionsGetOptions(list.Id, listItem.ContentId)
                {
                    Url = list.SPWebUrl
                };
                try
                {
                    inheritance = ClientApi.Permissions.GetInheritance(permissionsGetOptions);
                }
                catch (SPInternalException ex)
                {
                    inheritance.Errors.Add(new Error(ex.GetType().ToString(), plugin.Translate(SharePointPermissionsExtension.Translations.ListItemNotFound)));
                }
                catch (Exception ex)
                {
                    string message = string.Format("An exception of type {0} occurred in the WidgetApi.V1.SharePointPermissions.Get() method for ContentId: {1} ListId: {2}. The exception message is: {3}", ex.GetType(), listItem.ContentId, list.Id, ex.Message);
                    SPLog.UnKnownError(ex, message);
                    inheritance.Errors.Add(new Error(ex.GetType().ToString(), plugin.Translate(SharePointPermissionsExtension.Translations.UnknownError)));
                }
            }
            return(inheritance.Enabled);
        }
Example #2
0
        public void ResetInheritance(SPList list, SPListItem listItem)
        {
            var resetInheritance = new AdditionalInfo();

            Validate(resetInheritance.Errors, list, listItem);
            if (!resetInheritance.Errors.Any())
            {
                var resetInheritanceOptions = new PermissionsGetOptions(list.Id, listItem.ContentId)
                {
                    Url = list.SPWebUrl
                };
                try
                {
                    ClientApi.Permissions.ResetInheritance(resetInheritanceOptions);
                }
                catch (SPInternalException) { }
                catch (Exception ex)
                {
                    string message = string.Format("An exception of type {0} occurred in the WidgetApi.V1.SharePointPermissions.ResetInheritance() method for ContentId: {1} ListId: {2}. The exception message is: {3}", ex.GetType(), listItem.ContentId, list.Id, ex.Message);
                    SPLog.UnKnownError(ex, message);
                }
            }
        }
Example #3
0
        public void Remove(SPList list, SPListItem listItem, string memberIds)
        {
            var removePermissions = new AdditionalInfo();

            Validate(removePermissions.Errors, list, listItem);
            if (!removePermissions.Errors.Any())
            {
                var removeOptions = new PermissionsGetOptions(list.Id, listItem.ContentId)
                {
                    Url = list.SPWebUrl
                };

                try
                {
                    ClientApi.Permissions.Remove(memberIds.Split(',').Select(int.Parse).ToArray(), removeOptions);
                }
                catch (SPInternalException) { }
                catch (Exception ex)
                {
                    string message = string.Format("An exception of type {0} occurred in the WidgetApi.V1.SharePointPermissions.Remove() method for ContentId: {1} ListId: {2}. The exception message is: {3}", ex.GetType(), listItem.ContentId, list.Id, ex.Message);
                    SPLog.UnKnownError(ex, message);
                }
            }
        }