Пример #1
0
 /// <summary>
 /// Sets a permission for the given nodetype for the user
 /// </summary>
 public void set(CswEnumNbtNodeTypePermission Permission, CswNbtMetaDataNodeType NodeType, ICswNbtUser User, bool value)
 {
     if (User != null)
     {
         set(Permission, NodeType, _getRole(User.RoleId), value);
     }
 }
Пример #2
0
        } // set( CswNbtActionName ActionName, ICswNbtUser User, bool value )

        #endregion Actions

        #region Specialty

        /// <summary>
        /// Determines if the user has permission to View or Edit a node belonging to the Permission Group defined by the given GroupId
        /// </summary>
        /// <param name="Permission">Permission Type (either View or Edit)</param>
        /// <param name="PermissionGroupId">The nodeid of the PermissionGroup with which to check permissions</param>
        /// <param name="User">User for which to check permissions</param>
        public bool canNode(CswEnumNbtNodeTypePermission Permission, CswPrimaryKey PermissionGroupId, ICswNbtUser User = null, CswNbtMetaDataNodeType NodeType = null)
        {
            bool hasPermission = true;

            if (null == User)
            {
                User = _CswNbtResources.CurrentNbtUser;
            }
            if (false == (User is CswNbtSystemUser || User.Username == CswNbtObjClassUser.ChemSWAdminUsername))
            {
                if (null != User && CswTools.IsPrimaryKey(PermissionGroupId))
                {
                    CswNbtPropertySetPermission PermNode = User.getPermissionForGroup(PermissionGroupId);
                    if (null != PermNode)
                    {
                        //Case 30480: Only use InventoryGroupPermission if checking against Containers
                        if (null == NodeType ||
                            PermNode.ObjectClass.ObjectClass != CswEnumNbtObjectClass.InventoryGroupPermissionClass ||
                            NodeType.getObjectClass().ObjectClass == CswEnumNbtObjectClass.ContainerClass)
                        {
                            hasPermission = ((Permission == CswEnumNbtNodeTypePermission.View && PermNode.View.Checked == CswEnumTristate.True) ||
                                             PermNode.Edit.Checked == CswEnumTristate.True);   //edit implies edit, create, and delete
                        }
                    }
                    else if (null != _CswNbtResources.Nodes[PermissionGroupId])
                    {
                        // case 30477 - Only revoke permissions if the group's nodetype is enabled and the node is valid
                        hasPermission = false;
                    }
                }
            }
            return(hasPermission);
        }
Пример #3
0
 public CswNbtPermitInfo(CswNbtResources CswNbtResources, ICswNbtUser CswNbtUser, CswNbtObjClassRole CswNbtObjClassRole, CswNbtMetaDataNodeType NodeTypeIn, CswEnumNbtNodeTypePermission nodeTypePermissionIn, CswPrimaryKey CswPrimaryKey, CswNbtMetaDataNodeTypeProp PropTypeIn)
 {
     PropType            = PropTypeIn;
     _NodePrimeKey       = CswPrimaryKey;
     NodeType            = NodeTypeIn;
     _CswNbtResources    = CswNbtResources;
     _CswNbtUser         = CswNbtUser;
     _CswNbtObjClassRole = CswNbtObjClassRole;
     NodeTypePermission  = nodeTypePermissionIn;
 }//ctor
Пример #4
0
        }     //isPropWritable

        /// <summary>
        /// Determines if the Property is editable
        /// </summary>
        public bool isPropWritable(CswEnumNbtNodeTypePermission Permission, CswNbtMetaDataNodeTypeProp MetaDataProp, CswNbtMetaDataNodeTypeTab MetaDataTab, CswNbtNodePropWrapper NodePropWrapper, CswNbtObjClassRole Role)
        {
            bool ret = false;

            if (null != MetaDataProp)
            {
                _initPermissionInfo(Role, null, MetaDataProp.getNodeType(), Permission, ((null != NodePropWrapper) ? NodePropWrapper.NodeId : null), MetaDataProp);
                ret = _isPropWritableImpl(MetaDataTab, MetaDataProp, NodePropWrapper);
            } //if-else we have metadata prop
            return(ret);
        }     //isPropWritable
Пример #5
0
 public void set(CswEnumNbtNodeTypePermission Permission, CswNbtMetaDataNodeType NodeType, CswNbtObjClassRole Role, bool value)
 {
     if (Role != null)
     {
         //Role.NodeTypePermissions.SetValue( NodeTypePermission.ToString(), NodeType.FirstVersionNodeTypeId.ToString(), value );
         //Role.NodeTypePermissions.Save();
         if (value)
         {
             Role.NodeTypePermissions.AddValue(CswNbtObjClassRole.MakeNodeTypePermissionValue(NodeType.FirstVersionNodeTypeId, Permission));
         }
         else
         {
             Role.NodeTypePermissions.RemoveValue(CswNbtObjClassRole.MakeNodeTypePermissionValue(NodeType.FirstVersionNodeTypeId, Permission));
         }
         Role.postChanges(false);
     }
 } // set( NodeTypePermission NodeTypePermission, CswNbtMetaDataNodeType NodeType, ICswNbtUser Role, bool value )
Пример #6
0
 /// <summary>
 /// Sets a permission for the given nodetype for the user
 /// </summary>
 public void set(CswEnumNbtNodeTypePermission Permission, CswNbtMetaDataNodeType NodeType, bool value)
 {
     set(Permission, NodeType, _CswNbtResources.CurrentNbtUser, value);
 }
Пример #7
0
        } // _initPermissionGroupDict()

        #endregion Nodes

        #region Setters

        /// <summary>
        /// Sets a permission for the given nodetype for the user
        /// </summary>
        public void set(CswEnumNbtNodeTypePermission Permission, Int32 NodeTypeId, bool value)
        {
            set(Permission, _CswNbtResources.MetaData.getNodeType(NodeTypeId), value);
        }
Пример #8
0
        }//isNodeWritable()

        public bool isNodeWritable(CswEnumNbtNodeTypePermission Permission, CswNbtMetaDataNodeType NodeType, CswPrimaryKey NodeId, CswNbtObjClassRole Role)
        {
            _initPermissionInfo(Role, null, NodeType, Permission, NodeId);
            return(_isNodeWritableImpl());
        }//isNodeWritable()
Пример #9
0
        }//_isPropWritableImpl()

        #endregion Props

        #region Nodes

        public bool isNodeWritable(CswEnumNbtNodeTypePermission Permission, CswNbtMetaDataNodeType NodeType, CswPrimaryKey NodeId, ICswNbtUser User = null)
        {
            _initPermissionInfo(null, User, NodeType, Permission, NodeId);
            return(_isNodeWritableImpl());
        }//isNodeWritable()
Пример #10
0
        }//canAnyTab()

        /// <summary>
        /// Determines if the Role has permission on the NodeType or any Tab on the NodeType
        /// </summary>
        public bool canAnyTab(CswEnumNbtNodeTypePermission Permission, CswNbtMetaDataNodeType NodeType, CswNbtObjClassRole Role, CswPrimaryKey NodeId = null)
        {
            _initPermissionInfo(Role, null, NodeType, Permission, NodeId);
            return(_canAnyTabImpl());
        }//canAnyTab()
Пример #11
0
        }//_canTablImpl()

        /// <summary>
        /// Determines if the User has permission on the NodeType or any Tab on the NodeType
        /// </summary>
        public bool canAnyTab(CswEnumNbtNodeTypePermission Permission, CswNbtMetaDataNodeType NodeType, ICswNbtUser User = null, CswPrimaryKey NodeId = null)
        {
            _initPermissionInfo(null, User, NodeType, Permission, NodeId);
            return(_canAnyTabImpl());
        }//canAnyTab()
Пример #12
0
 /// <summary>
 /// Does this User have this NodeTypePermission on this nodetype?
 /// </summary>
 public bool canNodeType(CswEnumNbtNodeTypePermission Permission, CswNbtMetaDataNodeType NodeType, CswNbtObjClassRole Role)
 {
     _initPermissionInfo(Role, null, NodeType, Permission);
     return(_CanNodeTypeImpl());
 } //canNodeType()
Пример #13
0
 /// <summary>
 /// Does this User have this NodeTypePermission on this nodetype?
 /// </summary>
 public bool canNodeType(CswEnumNbtNodeTypePermission Permission, CswNbtMetaDataNodeType NodeType, ICswNbtUser User = null)
 {
     _initPermissionInfo(null, User, NodeType, Permission);
     return(_CanNodeTypeImpl());
 }
Пример #14
0
        private void _initPermissionInfo(CswNbtObjClassRole CswNbtObjClassRole, ICswNbtUser CswNbtUser, CswNbtMetaDataNodeType NodeType, CswEnumNbtNodeTypePermission Permission, CswPrimaryKey CswPrimaryKey = null, CswNbtMetaDataNodeTypeProp PropType = null)
        {
            if (null == CswNbtObjClassRole)
            {
                CswPrimaryKey RoleId = null;
                if (null != CswNbtUser)
                {
                    RoleId = CswNbtUser.RoleId;
                }
                else
                {
                    if (null != _CswNbtResources.CurrentNbtUser)
                    {
                        CswNbtUser = _CswNbtResources.CurrentNbtUser;
                        RoleId     = CswNbtUser.RoleId;
                    }
                }//if the user we got is null

                if (null != RoleId)
                {
                    CswNbtObjClassRole = _getRole(RoleId);
                } //if we were able to get a roleid
            }     //if the role we got is null

            if (null != CswNbtObjClassRole)
            {
                CswNbtPermitInfoKey CswNbtPermitInfoKey = new CswNbtPermitInfoKey(CswNbtObjClassRole, NodeType);
                if (_PermitInfoItems.ContainsKey(CswNbtPermitInfoKey))
                {
                    _CswNbtPermitInfo = _PermitInfoItems[CswNbtPermitInfoKey];

                    //must reset these per-request because they change per request for the same role and nodetype (e.g., see allowAny() )
                    if (null != CswPrimaryKey)
                    {
                        _CswNbtPermitInfo.NodePrimeKey = CswPrimaryKey;
                    }

                    if (null != PropType)
                    {
                        _CswNbtPermitInfo.PropType = PropType;
                    }

                    _CswNbtPermitInfo.NodeTypePermission = Permission;
                }
                else
                {
                    _CswNbtPermitInfo = new CswNbtPermitInfo(_CswNbtResources, CswNbtUser, CswNbtObjClassRole, NodeType, Permission, CswPrimaryKey, PropType);
                    _PermitInfoItems.Add(CswNbtPermitInfoKey, _CswNbtPermitInfo);
                }
            }
            else //the permit info in this case is not catalogued, and permit info won't allow any ops to proceed
            {
                _CswNbtPermitInfo = new CswNbtPermitInfo(_CswNbtResources, CswNbtUser, CswNbtObjClassRole, NodeType, Permission, CswPrimaryKey, PropType);
            } //if we were able to retrieve a role
        }     //_initPermissionInfo()