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

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

00001 <?php
00014 import('lib.pkp.classes.security.authorization.DataObjectRequiredPolicy');
00015 
00016 class PublicationFormatRequiredPolicy extends DataObjectRequiredPolicy {
00024    function PublicationFormatRequiredPolicy(&$request, &$args, $parameterName = 'publicationFormatId', $operations = null) {
00025       parent::DataObjectRequiredPolicy($request, $args, $parameterName, 'user.authorization.invalidPublicationFormat', $operations);
00026    }
00027 
00028    //
00029    // Implement template methods from AuthorizationPolicy
00030    //
00034    function dataObjectEffect() {
00035       $publicationFormatId = (int)$this->getDataObjectId();
00036       if (!$publicationFormatId) return AUTHORIZATION_DENY;
00037 
00038       // Need a valid monograph in request.
00039       $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00040       if (!is_a($monograph, 'Monograph')) return AUTHORIZATION_DENY;
00041 
00042       // Make sure the publication format belongs to the monograph.
00043       $publicationFormatDao =& DAORegistry::getDAO('PublicationFormatDAO');
00044       $publicationFormat =& $publicationFormatDao->getById($publicationFormatId, $monograph->getId());
00045       if (!is_a($publicationFormat, 'PublicationFormat')) return AUTHORIZATION_DENY;
00046 
00047       // Save the publication format to the authorization context.
00048       $this->addAuthorizedContextObject(ASSOC_TYPE_PUBLICATION_FORMAT, $publicationFormat);
00049       return AUTHORIZATION_PERMIT;
00050    }
00051 }
00052 
00053 ?>

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