Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
SetupGridHandler.inc.php
1 <?php
2 
16 import('lib.pkp.classes.controllers.grid.GridHandler');
17 
22  function SetupGridHandler() {
23  parent::GridHandler();
24  $this->addRoleAssignment(
25  array(ROLE_ID_MANAGER),
26  array('uploadImage')
27  );
28  }
29 
33  function initialize($request) {
34  parent::initialize($request);
35 
36  AppLocale::requireComponents(LOCALE_COMPONENT_APP_MANAGER);
37  }
38 
43  function authorize($request, &$args, $roleAssignments, $contextRequired = true) {
44  if ($contextRequired) {
45  import('lib.pkp.classes.security.authorization.PkpContextAccessPolicy');
46  $this->addPolicy(new PkpContextAccessPolicy($request, $roleAssignments));
47  }
48  return parent::authorize($request, $args, $roleAssignments);
49  }
50 
56  function uploadImage($args, $request) {
57  $router = $request->getRouter();
58  $context = $request->getContext();
59  $user = $request->getUser();
60 
61  import('lib.pkp.classes.file.TemporaryFileManager');
62  $temporaryFileManager = new TemporaryFileManager();
63  $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
64  if ($temporaryFile) {
65  $json = new JSONMessage(true);
66  $json->setAdditionalAttributes(array(
67  'temporaryFileId' => $temporaryFile->getId()
68  ));
69  } else {
70  $json = new JSONMessage(false, __('common.uploadFailed'));
71  }
72 
73  return $json->getString();
74  }
75 }
76 
77 ?>
addPolicy($authorizationPolicy, $addToTop=false)
authorize($request, &$args, $roleAssignments, $contextRequired=true)
static requireComponents()
Class defining basic operations for handling HTML grids.
Class to control access to PKP applications&#39; setup components.
addRoleAssignment($roleIds, $operations)
Class to represent a JSON (Javascript Object Notation) message.
uploadImage($args, $request)
Base class for setup grid handlers.