Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
PublicationFormatRequiredPolicy.inc.php
1 <?php
15 import('lib.pkp.classes.security.authorization.DataObjectRequiredPolicy');
16 
25  function PublicationFormatRequiredPolicy($request, &$args, $parameterName = 'publicationFormatId', $operations = null) {
26  parent::DataObjectRequiredPolicy($request, $args, $parameterName, 'user.authorization.invalidPublicationFormat', $operations);
27  }
28 
29  //
30  // Implement template methods from AuthorizationPolicy
31  //
35  function dataObjectEffect() {
36  $publicationFormatId = (int)$this->getDataObjectId();
37  if (!$publicationFormatId) return AUTHORIZATION_DENY;
38 
39  // Need a valid monograph in request.
40  $monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
41  if (!is_a($monograph, 'Monograph')) return AUTHORIZATION_DENY;
42 
43  // Make sure the publication format belongs to the monograph.
44  $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
45  $publicationFormat = $publicationFormatDao->getById($publicationFormatId, $monograph->getId());
46  if (!is_a($publicationFormat, 'PublicationFormat')) return AUTHORIZATION_DENY;
47 
48  // Save the publication format to the authorization context.
49  $this->addAuthorizedContextObject(ASSOC_TYPE_PUBLICATION_FORMAT, $publicationFormat);
50  return AUTHORIZATION_PERMIT;
51  }
52 }
53 
54 ?>
PublicationFormatRequiredPolicy($request, &$args, $parameterName= 'publicationFormatId', $operations=null)
static & getDAO($name, $dbconn=null)
Policy that ensures that the request contains a valid publication format.
Abstract base class for policies that check for a data object from a parameter.
& getAuthorizedContextObject($assocType)
addAuthorizedContextObject($assocType, &$authorizedObject)