Changeset 1222
- Timestamp:
- Nov 30, 2010, 2:10:42 PM (13 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/RestController.groovy
r1199 r1222 256 256 if(study) { 257 257 // Check whether the person is allowed to read the data of this study 258 /*259 258 if( !study.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) { 260 259 response.sendError(401) 261 260 return false 262 261 } 263 */264 262 265 263 def assays = [] … … 283 281 284 282 assays.each{ assay -> 285 if (assay.module.url.equals(params.consumer 283 if (assay.module.url.equals(params.consumer)) { 286 284 if(assay) { 287 285 def map = [:] -
trunk/grails-app/controllers/dbnp/exporter/ExporterController.groovy
r1220 r1222 45 45 def c = dbnp.studycapturing.Study.createCriteria() 46 46 47 def studies 48 if( user == null ) { 49 studies = c.list { 50 maxResults(max) 51 and { 52 eq( "published", true ) 53 eq( "publicstudy", true ) 54 } 55 } 56 } else { 57 studies = c.list { 58 maxResults(max) 59 or { 60 eq( "owner", user ) 61 writers { 62 eq( "id", user.id ) 63 } 64 and { 65 readers { 66 eq( "id", user.id ) 67 } 68 eq( "published", true ) 69 } 70 } 71 } 72 } 47 def studies = Study.giveReadableStudies(user, max); 73 48 [studyInstanceList: studies, studyInstanceTotal: studies.count()] 74 49 } -
trunk/grails-app/controllers/dbnp/studycapturing/StudyController.groovy
r1213 r1222 3 3 import grails.converters.* 4 4 import grails.plugins.springsecurity.Secured 5 6 5 7 6 /** … … 25 24 def max = Math.min(params.max ? params.int('max') : 10, 100) 26 25 27 def c = Study.createCriteria() 28 29 def studies 30 if( user == null ) { 31 studies = c.list { 32 maxResults(max) 33 and { 34 eq( "published", true ) 35 eq( "publicstudy", true ) 36 } 37 } 38 } else { 39 studies = c.list { 40 maxResults(max) 41 or { 42 eq( "owner", user ) 43 writers { 44 eq( "id", user.id ) 45 } 46 and { 47 readers { 48 eq( "id", user.id ) 49 } 50 eq( "published", true ) 51 } 52 } 53 } 54 } 55 26 def studies = Study.giveReadableStudies( user, max ); 27 56 28 [studyInstanceList: studies, studyInstanceTotal: studies.count(), loggedInUser: user] 57 29 } -
trunk/grails-app/controllers/nmc/PilotController.groovy
r1204 r1222 16 16 17 17 import dbnp.studycapturing.*; 18 import grails.plugins.springsecurity.Secured 19 18 20 19 21 class PilotController { … … 37 39 } 38 40 39 def index = { 41 @Secured(['IS_AUTHENTICATED_REMEMBERED']) 42 def index = { 40 43 41 44 session.pilot = true 42 45 43 46 def user = authenticationService.getLoggedInUser() 44 47 def max = Math.min(params.max ? params.int('max') : 10, 100) 45 46 def c = Study.createCriteria() 47 48 def studies 49 if( user == null ) { 50 //login and return here... 51 redirect(controller:"login", action:"auth") 52 return false 53 54 } else { 55 studies = c.list { 56 maxResults(max) 57 or { 58 eq( "owner", user ) 59 writers { 60 eq( "id", user.id ) 61 } 62 and { 63 readers { 64 eq( "id", user.id ) 65 } 66 eq( "published", true ) 67 } 68 } 69 } 70 } 48 def studies = Study.giveReadableStudies(user, max); 71 49 72 50 def studyInstance = new Study() -
trunk/grails-app/domain/dbnp/authentication/SecRole.groovy
r1159 r1222 1 1 package dbnp.authentication 2 2 3 class SecRole {3 class SecRole implements Serializable { 4 4 5 5 String authority -
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r1036 r1222 410 410 } 411 411 412 // Administrators are allowed to read every study 413 if( loggedInUser.hasAdminRights() ) { 414 return true; 415 } 416 412 417 // Owners and writers are allowed to read this study 413 418 if( this.owner == loggedInUser || this.writers.contains(loggedInUser) ) { … … 430 435 return false; 431 436 } 437 438 // Administrators are allowed to write every study 439 if( loggedInUser.hasAdminRights() ) { 440 return true; 441 } 442 432 443 return this.owner == loggedInUser || this.writers.contains(loggedInUser) 433 444 } … … 443 454 } 444 455 456 /** 457 * Returns a list of studies that are writable for the given user 458 */ 459 public static giveWritableStudies(SecUser user, int max) { 460 // User that are not logged in, are not allowed to write to a study 461 if( user == null ) 462 return []; 463 464 def c = Study.createCriteria() 465 466 // Administrators are allowed to read everything 467 if( user.hasAdminRights() ) { 468 return c.list { 469 maxResults(max) 470 } 471 } 472 473 return c.list { 474 maxResults(max) 475 or { 476 eq( "owner", user ) 477 writers { 478 eq( "id", user.id ) 479 } 480 } 481 } 482 } 483 484 /** 485 * Returns a list of studies that are readable by the given user 486 */ 487 public static giveReadableStudies(SecUser user, int max) { 488 def c = Study.createCriteria() 489 490 // Administrators are allowed to read everything 491 if( user == null ) { 492 return c.list { 493 maxResults(max) 494 and { 495 eq( "published", true ) 496 eq( "publicstudy", true ) 497 } 498 } 499 } else if( user.hasAdminRights() ) { 500 return c.list { 501 maxResults(max) 502 } 503 } else { 504 return c.list { 505 maxResults(max) 506 or { 507 eq( "owner", user ) 508 writers { 509 eq( "id", user.id ) 510 } 511 and { 512 readers { 513 eq( "id", user.id ) 514 } 515 eq( "published", true ) 516 } 517 } 518 } 519 } 520 } 445 521 } -
trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy
r1206 r1222 653 653 */ 654 654 def studySelect = { attrs -> 655 // Find all studies the user has access to 656 def user = AuthenticationService.getLoggedInUser() 657 658 def c = Study.createCriteria() 659 attrs.from = c.list { 660 or { 661 eq( "owner", user ) 662 writers { 663 eq( "id", user.id ) 664 } 665 } 666 } 655 // Find all studies the user has access to (max 100) 656 attrs.from = Study.giveWritableStudies(AuthenticationService.getLoggedInUser(), 100); 667 657 668 658 // got a name?
Note: See TracChangeset
for help on using the changeset viewer.