• Main Page
  • Modules
  • Classes
  • Files
  • File List

classes/security/authorization/OmpMonographFileAccessPolicy.inc.php

00001 <?php
00015 import('classes.security.authorization.internal.PressPolicy');
00016 import('lib.pkp.classes.security.authorization.RoleBasedHandlerOperationPolicy');
00017 
00018 // Define the bitfield for monograph file access levels
00019 define('MONOGRAPH_FILE_ACCESS_READ', 1);
00020 define('MONOGRAPH_FILE_ACCESS_MODIFY', 2);
00021 
00022 class OmpMonographFileAccessPolicy extends PressPolicy {
00033    function OmpMonographFileAccessPolicy(&$request, $args, $roleAssignments, $mode, $fileIdAndRevision = null, $submissionParameterName = 'monographId') {
00034       // TODO: Refine file access policies. Differentiate between
00035       // read and modify access using bitfield:
00036       // $mode & MONOGRAPH_FILE_ACCESS_...
00037 
00038       parent::PressPolicy($request);
00039 
00040       // We need a submission matching the file in the request.
00041       import('classes.security.authorization.internal.MonographRequiredPolicy');
00042       $this->addPolicy(new MonographRequiredPolicy($request, $args, $submissionParameterName));
00043       import('classes.security.authorization.internal.MonographFileMatchesMonographPolicy');
00044       $this->addPolicy(new MonographFileMatchesMonographPolicy($request, $fileIdAndRevision));
00045 
00046       // Authors, press managers and series editors potentially have
00047       // access to submission files. We'll have to define
00048       // differentiated policies for those roles in a policy set.
00049       $fileAccessPolicy = new PolicySet(COMBINING_PERMIT_OVERRIDES);
00050 
00051 
00052       //
00053       // Managerial role
00054       //
00055       if (isset($roleAssignments[ROLE_ID_PRESS_MANAGER])) {
00056          // Press managers have all access to all submissions.
00057          $fileAccessPolicy->addPolicy(new RoleBasedHandlerOperationPolicy($request, ROLE_ID_PRESS_MANAGER, $roleAssignments[ROLE_ID_PRESS_MANAGER]));
00058       }
00059 
00060 
00061       //
00062       // Series editor role
00063       //
00064       if (isset($roleAssignments[ROLE_ID_SERIES_EDITOR])) {
00065          // 1) Series editors can access all operations on submissions ...
00066          $seriesEditorFileAccessPolicy = new PolicySet(COMBINING_DENY_OVERRIDES);
00067          $seriesEditorFileAccessPolicy->addPolicy(new RoleBasedHandlerOperationPolicy($request, ROLE_ID_SERIES_EDITOR, $roleAssignments[ROLE_ID_SERIES_EDITOR]));
00068 
00069          // 2) ... but only if the requested submission is part of their series.
00070          import('classes.security.authorization.internal.SeriesAssignmentPolicy');
00071          $seriesEditorFileAccessPolicy->addPolicy(new SeriesAssignmentPolicy($request));
00072          $fileAccessPolicy->addPolicy($seriesEditorFileAccessPolicy);
00073       }
00074 
00075 
00076       //
00077       // Author role
00078       //
00079       if (isset($roleAssignments[ROLE_ID_AUTHOR])) {
00080          // 1) Author role user groups can access whitelisted operations ...
00081          $authorFileAccessPolicy = new PolicySet(COMBINING_DENY_OVERRIDES);
00082          $authorFileAccessPolicy->addPolicy(new RoleBasedHandlerOperationPolicy($request, ROLE_ID_AUTHOR, $roleAssignments[ROLE_ID_AUTHOR]));
00083 
00084          // 2) ...if they are assigned to the workflow stage.
00085          import('classes.security.authorization.OmpWorkflowStageAccessPolicy');
00086          $authorFileAccessPolicy->addPolicy(new OmpWorkflowStageAccessPolicy($request, $args, $roleAssignments, 'monographId', $request->getUserVar('stageId')));
00087 
00088          // 3) ...and if they meet one of the following requirements:
00089          $authorFileAccessOptionsPolicy = new PolicySet(COMBINING_PERMIT_OVERRIDES);
00090 
00091          // 3a) If the file was uploaded by the current user, allow...
00092          import('classes.security.authorization.internal.MonographFileUploaderAccessPolicy');
00093          $authorFileAccessOptionsPolicy->addPolicy(new MonographFileUploaderAccessPolicy($request, $fileIdAndRevision));
00094 
00095          // 3b) ...or if the file is a file in a review round with requested revision decision, allow...
00096          import('classes.security.authorization.internal.MonographFileRequestedRevisionRequiredPolicy');
00097          $authorFileAccessOptionsPolicy->addPolicy(new MonographFileRequestedRevisionRequiredPolicy($request, $fileIdAndRevision));
00098 
00099          // ...or if we don't want to modify the file...
00100          if (!($mode & MONOGRAPH_FILE_ACCESS_MODIFY)) {
00101 
00102             // 3c) ...and the file is at submission stage...
00103             import('classes.security.authorization.internal.MonographFileSubmissionStageRequiredPolicy');
00104             $authorFileAccessOptionsPolicy->addPolicy(new MonographFileSubmissionStageRequiredPolicy($request, $fileIdAndRevision));
00105 
00106             // 3d) ...or the file is a viewable reviewer response...
00107             import('classes.security.authorization.internal.MonographFileViewableReviewerResponseRequiredPolicy');
00108             $authorFileAccessOptionsPolicy->addPolicy(new MonographFileViewableReviewerResponseRequiredPolicy($request, $fileIdAndRevision));
00109 
00110             // 3e) ...or if the file is part of a signoff assigned to the user, allow.
00111             import('classes.security.authorization.internal.MonographFileAssignedAuditorAccessPolicy');
00112             $authorFileAccessOptionsPolicy->addPolicy(new MonographFileAssignedAuditorAccessPolicy($request, $fileIdAndRevision));
00113          }
00114 
00115          // Add the rules from 3)
00116          $authorFileAccessPolicy->addPolicy($authorFileAccessOptionsPolicy);
00117 
00118          $fileAccessPolicy->addPolicy($authorFileAccessPolicy);
00119       }
00120 
00121 
00122       //
00123       // Reviewer role
00124       //
00125       if (isset($roleAssignments[ROLE_ID_REVIEWER])) {
00126          // 1) Reviewers can access whitelisted operations ...
00127          $reviewerFileAccessPolicy = new PolicySet(COMBINING_DENY_OVERRIDES);
00128          $reviewerFileAccessPolicy->addPolicy(new RoleBasedHandlerOperationPolicy($request, ROLE_ID_REVIEWER, $roleAssignments[ROLE_ID_REVIEWER]));
00129 
00130          // 2) ...if they meet one of the following requirements:
00131          $reviewerFileAccessOptionsPolicy = new PolicySet(COMBINING_PERMIT_OVERRIDES);
00132 
00133          // 2a) If the file was uploaded by the current user, allow.
00134          import('classes.security.authorization.internal.MonographFileUploaderAccessPolicy');
00135          $reviewerFileAccessOptionsPolicy->addPolicy(new MonographFileUploaderAccessPolicy($request, $fileIdAndRevision));
00136 
00137          // 2b) If the file is part of an assigned review, and we're not
00138          // trying to modify it, allow.
00139          import('classes.security.authorization.internal.MonographFileAssignedReviewerAccessPolicy');
00140          if (!($mode & MONOGRAPH_FILE_ACCESS_MODIFY)) {
00141             $reviewerFileAccessOptionsPolicy->addPolicy(new MonographFileAssignedReviewerAccessPolicy($request, $fileIdAndRevision));
00142          }
00143 
00144          // Add the rules from 2)
00145          $reviewerFileAccessPolicy->addPolicy($reviewerFileAccessOptionsPolicy);
00146 
00147          // Add this policy set
00148          $fileAccessPolicy->addPolicy($reviewerFileAccessPolicy);
00149       }
00150 
00151 
00152       //
00153       // Press assistant role.
00154       //
00155       if (isset($roleAssignments[ROLE_ID_PRESS_ASSISTANT])) {
00156          // 1) Press assistants can access whitelisted operations...
00157          $pressAssistantFileAccessPolicy = new PolicySet(COMBINING_DENY_OVERRIDES);
00158          $pressAssistantFileAccessPolicy->addPolicy(new RoleBasedHandlerOperationPolicy($request, ROLE_ID_PRESS_ASSISTANT, $roleAssignments[ROLE_ID_PRESS_ASSISTANT]));
00159 
00160          // 2) ... but only if they have been assigned to the submission workflow.
00161          import('classes.security.authorization.OmpWorkflowStageAccessPolicy');
00162          $pressAssistantFileAccessPolicy->addPolicy(new OmpWorkflowStageAccessPolicy($request, $args, $roleAssignments, 'monographId', $request->getUserVar('stageId')));
00163          $fileAccessPolicy->addPolicy($pressAssistantFileAccessPolicy);
00164       }
00165 
00166       $this->addPolicy($fileAccessPolicy);
00167    }
00168 }
00169 
00170 ?>

Generated on Mon Sep 17 2012 13:58:55 for Open Monograph Press by  doxygen 1.7.1