Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
AdminHandler.inc.php
1 <?php
2 
16 import('classes.handler.Handler');
17 
18 class AdminHandler extends Handler {
22  function AdminHandler() {
23  parent::Handler();
24 
25  $this->addRoleAssignment(
26  array(ROLE_ID_SITE_ADMIN),
27  array('index', 'settings')
28  );
29  }
30 
34  function authorize($request, &$args, $roleAssignments) {
35  import('lib.pkp.classes.security.authorization.PKPSiteAccessPolicy');
36  $this->addPolicy(new PKPSiteAccessPolicy($request, null, $roleAssignments));
37  $returner = parent::authorize($request, $args, $roleAssignments);
38 
39  // Make sure user is in a context. Otherwise, redirect.
40  $context = $request->getContext();
41  $router = $request->getRouter();
42  $requestedOp = $router->getRequestedOp($request);
43 
44  if ($requestedOp == 'settings') {
45  $contextDao = Application::getContextDAO();
46  $contextFactory = $contextDao->getAll();
47  if ($contextFactory->getCount() == 1) {
48  // Don't let users access site settings in a single context installation.
49  // In that case, those settings are available under management or are not
50  // relevant (like site appearance).
51  return false;
52  }
53  }
54 
55  return $returner;
56  }
57 
63  function index($args, $request) {
64  $templateMgr = TemplateManager::getManager($request);
65  $workingContexts = $this->getWorkingContexts($request);
66  $templateMgr->assign('multipleContexts', $workingContexts->getCount() > 1);
67  $templateMgr->display('admin/index.tpl');
68  }
69 
75  function settings($args, $request) {
76  $templateMgr = TemplateManager::getManager($request);
77  $templateMgr->display('admin/settings.tpl');
78  }
79 
85  function initialize($request, $args = null) {
86  AppLocale::requireComponents(LOCALE_COMPONENT_PKP_ADMIN, LOCALE_COMPONENT_APP_MANAGER, LOCALE_COMPONENT_APP_ADMIN, LOCALE_COMPONENT_APP_COMMON);
87  return parent::initialize($request, $args);
88  }
89 }
90 
91 ?>
addPolicy($authorizationPolicy, $addToTop=false)
initialize($request, $args=null)
static requireComponents()
settings($args, $request)
Handle requests for site administration functions.
addRoleAssignment($roleIds, $operations)
getWorkingContexts($request)
Definition: Handler.inc.php:33
Base request handler application class.
Definition: Handler.inc.php:20
Class to that makes sure that a user is logged in.
index($args, $request)
static getContextDAO()
authorize($request, &$args, $roleAssignments)