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

classes/security/authorization/internal/MonographFileMatchesMonographPolicy.inc.php

00001 <?php
00017 import('classes.security.authorization.internal.MonographFileBaseAccessPolicy');
00018 
00019 class MonographFileMatchesMonographPolicy extends MonographFileBaseAccessPolicy {
00024    function MonographFileMatchesMonographPolicy(&$request, $fileIdAndRevision = null) {
00025       parent::MonographFileBaseAccessPolicy($request, $fileIdAndRevision);
00026    }
00027 
00028 
00029    //
00030    // Implement template methods from AuthorizationPolicy
00031    //
00035    function effect() {
00036       // Get the monograph file
00037       $request =& $this->getRequest();
00038       $monographFile =& $this->getMonographFile($request);
00039       if (!is_a($monographFile, 'MonographFile')) return AUTHORIZATION_DENY;
00040 
00041       // Get the monograph
00042       $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00043       if (!is_a($monograph, 'Monograph')) return AUTHORIZATION_DENY;
00044 
00045       // Check if the monograph file belongs to the monograph.
00046       if ($monographFile->getMonographId() == $monograph->getId()) {
00047          // We add this monograph file to the context monograph files array.
00048          $monographFilesArray = $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH_FILES);
00049          if (is_null($monographFilesArray)) {
00050             $monographFilesArray = array();
00051          }
00052          array_push($monographFilesArray, $monographFile);
00053          $this->addAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH_FILES, $monographFilesArray);
00054 
00055          // Save the monograph to the authorization context.
00056          $this->addAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH_FILE, $monographFile);
00057          return AUTHORIZATION_PERMIT;
00058       } else {
00059          return AUTHORIZATION_DENY;
00060       }
00061    }
00062 }
00063 
00064 ?>

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