Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
SubmissionFileMatchesSubmissionPolicy.inc.php
1 <?php
18 import('lib.pkp.classes.security.authorization.internal.SubmissionFileBaseAccessPolicy');
19 
25  function SubmissionFileMatchesSubmissionPolicy($request, $fileIdAndRevision = null) {
26  parent::SubmissionFileBaseAccessPolicy($request, $fileIdAndRevision);
27  }
28 
29 
30  //
31  // Implement template methods from AuthorizationPolicy
32  //
36  function effect() {
37  // Get the submission file
38  $request = $this->getRequest();
39  $submissionFile = $this->getSubmissionFile($request);
40  if (!is_a($submissionFile, 'SubmissionFile')) return AUTHORIZATION_DENY;
41 
42  // Get the submission
43  $submission =& $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
44  if (!is_a($submission, 'Submission')) return AUTHORIZATION_DENY;
45 
46  // Check if the submission file belongs to the submission.
47  if ($submissionFile->getSubmissionId() == $submission->getId()) {
48  // We add this submission file to the context submission files array.
49  $submissionFilesArray = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION_FILES);
50  if (is_null($submissionFilesArray)) {
51  $submissionFilesArray = array();
52  }
53  array_push($submissionFilesArray, $submissionFile);
54  $this->addAuthorizedContextObject(ASSOC_TYPE_SUBMISSION_FILES, $submissionFilesArray);
55 
56  // Save the submission to the authorization context.
57  $this->addAuthorizedContextObject(ASSOC_TYPE_SUBMISSION_FILE, $submissionFile);
58  return AUTHORIZATION_PERMIT;
59  } else {
60  return AUTHORIZATION_DENY;
61  }
62  }
63 }
64 
65 ?>
& getAuthorizedContextObject($assocType)
addAuthorizedContextObject($assocType, &$authorizedObject)
Submission file policy to check if the file belongs to the submission.
Abstract class for submission file access policies.
SubmissionFileMatchesSubmissionPolicy($request, $fileIdAndRevision=null)