Пример #1
0
        /// <summary>
        /// Назначить права на элемент
        /// </summary>
        /// <param name="item">Элемент</param>
        public void ApplyPermission(SPListItem item)
        {
            item.BreakRoleInheritance(true);

            if (this.AuthorRoles.Any(x => x.Name.Equals(PortalConstant.Role.Seller, StringComparison.InvariantCulture) || x.Name.Equals(PortalConstant.Role.Responsible, StringComparison.InvariantCulture)))
            {
                item.AddPermission(this.Author, this.ElevatedWeb, PortalConstant.Role.Editor);
            }

            if (this.AuthorRoles.Any(x => x.Name.Equals(PortalConstant.Role.Lead, StringComparison.InvariantCulture)))
            {
                item.AddPermission(this.Author, this.ElevatedWeb, PortalConstant.Role.Archivator);
            }
        }
        private void InitIfParentitemIsMine(SPListItem item, SPFieldLookupValue parentLookupValue)
        {
            var parentList       = item.ParentList;
            var parentItem       = parentList.GetItemById(parentLookupValue.LookupId);
            var parentItemAuthor = parentItem.UserValue(this.ElevatedWeb, CoreConstant.Field.Author.Id);

            if (!this.Author.LoginName.Equals(parentItemAuthor.User.LoginName))
            {
                return;
            }

            item.AddPermission(this.Author, this.ElevatedWeb, PortalConstant.Role.Reader);
        }
        /// <summary>
        /// Назначить права на элемент
        /// </summary>
        /// <param name="item">Элемент</param>
        public void ApplyPermission(SPListItem item)
        {
            if (!this.AuthorRoles.Any(x => x.Name.Equals(PortalConstant.Role.Seller, StringComparison.InvariantCulture)))
            {
                return;
            }

            item.BreakRoleInheritance(true);
            item.AddPermission(this.Author, this.ElevatedWeb, PortalConstant.Role.Archivator);

            var parentLookupValue = item.LookupValue(PortalConstant.Field.KsupContract.Id);

            if (parentLookupValue?.LookupValue == null)
            {
                return;
            }

            this.InitIfParentitemIsMine(item, parentLookupValue);
        }
Пример #4
0
 /// <summary>
 /// Назначить права на элемент
 /// </summary>
 /// <param name="item">Элемент</param>
 public void ApplyPermission(SPListItem item)
 {
     item.BreakRoleInheritance(true);
     item.AddPermission(this.Author, this.ElevatedWeb, PortalConstant.Role.Editor);
 }