} //canNodeType() /// <summary> /// Private logic behind canNodeType /// </summary> private bool _CanNodeTypeImpl() { bool ret = _CswNbtPermitInfo.IsUberUser; if (false == ret) { if (_CswNbtPermitInfo.shouldPermissionCheckProceed()) { ret = _CswNbtPermitInfo.NoExceptionCases; if (ret) { // Base case: does the Role have this nodetype permission string PermissionValueToCheck = CswNbtObjClassRole.MakeNodeTypePermissionValue(_CswNbtPermitInfo.NodeType.FirstVersionNodeTypeId, _CswNbtPermitInfo.NodeTypePermission); ret = ret && _CswNbtPermitInfo.Role.NodeTypePermissions.CheckValue(PermissionValueToCheck); if ((false == ret) && (_CswNbtPermitInfo.NodeTypePermission == CswEnumNbtNodeTypePermission.View)) { // Having 'Edit' grants 'View' automatically ret = _CswNbtPermitInfo.Role.NodeTypePermissions.CheckValue(CswNbtObjClassRole.MakeNodeTypePermissionValue(_CswNbtPermitInfo.NodeType.FirstVersionNodeTypeId, CswEnumNbtNodeTypePermission.Edit)); } //if we denied view permission } } //if pre-reqs are satisifed } return(ret); } // _CanNodeTypeImpl()
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 )
public override void update() { CswNbtMetaDataObjectClass RoleOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.RoleClass ); CswNbtMetaDataNodeType SiteNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Site" ); if( null != SiteNT ) { foreach( CswNbtObjClassRole RoleNode in RoleOC.getNodes( false, true, false, true ) ) { string SiteViewPermissionVal = CswNbtObjClassRole.MakeNodeTypePermissionValue( SiteNT.NodeTypeId, CswEnumNbtNodeTypePermission.View ); if( false == RoleNode.NodeTypePermissions.CheckValue( SiteViewPermissionVal ) ) { RoleNode.NodeTypePermissions.AddValue( SiteViewPermissionVal ); RoleNode.postChanges( false ); } } } } // update()
public override void update() { Int32 AdminRolePk = Int32.MinValue; CswCommaDelimitedString AdminRoles = new CswCommaDelimitedString(); // Change the visibilily of the 'Roles and Users' view to global CswNbtView RolesAndUsersView = _CswNbtSchemaModTrnsctn.restoreView( "Roles and Users" ); if( null != RolesAndUsersView ) { RolesAndUsersView.SetVisibility( CswEnumNbtViewVisibility.Global, null, null ); RolesAndUsersView.save(); // For any roles that aren't Administrator roles, remove any role permissions CswNbtMetaDataObjectClass RoleOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.RoleClass ); foreach( CswNbtObjClassRole RoleNode in RoleOC.getNodes( false, true, false ) ) { if( CswEnumTristate.True != RoleNode.Administrator.Checked ) { foreach( CswEnumNbtNodeTypePermission Permission in CswEnumNbtNodeTypePermission.Members ) { RoleNode.NodeTypePermissions.RemoveValue( CswNbtObjClassRole.MakeNodeTypePermissionValue( RoleOC.FirstNodeType.NodeTypeId, Permission ) ); } RoleNode.NodeTypePermissions.SyncGestalt(); RoleNode.postChanges( false ); } else { AdminRoles.Add( CswConvert.ToString( RoleNode.NodeId.PrimaryKey ) ); } // We need this because setting the landing page for this Role is a special case if( RoleNode.Name.Text == "Administrator" ) { AdminRolePk = RoleNode.NodeId.PrimaryKey; } } // Redirect Welcome Landingpage items CswTableUpdate TableUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "updateLandingPageItems_Case28518", "landingpage" ); DataTable LandingPageDt = TableUpdate.getTable( "where for_roleid in (" + AdminRoles.ToString() + ")" ); foreach( DataRow CurrentRow in LandingPageDt.Rows ) { if( CswConvert.ToInt32( CurrentRow["for_roleid"] ) == AdminRolePk ) { if( CswConvert.ToString( CurrentRow["to_nodeviewid"] ) == "19" ) { CurrentRow["displaytext"] = RolesAndUsersView.ViewName; } } if( CswConvert.ToString( CurrentRow["displaytext"] ) == "Roles and Users" ) { CurrentRow["to_nodeviewid"] = RolesAndUsersView.ViewId.get(); } } TableUpdate.update( LandingPageDt ); }//if( null != RolesAndUsersView ) }// update()