Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
DashboardHandler.inc.php
1 <?php
15 import('classes.handler.Handler');
16 
17 class DashboardHandler extends Handler {
21  function DashboardHandler() {
22  parent::Handler();
23 
24  $this->addRoleAssignment(array(ROLE_ID_SITE_ADMIN, ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_AUTHOR, ROLE_ID_REVIEWER, ROLE_ID_ASSISTANT),
25  array('index', 'tasks', 'submissions', 'archives'));
26  }
27 
31  function authorize($request, &$args, $roleAssignments) {
32  import('lib.pkp.classes.security.authorization.PKPSiteAccessPolicy');
33  $this->addPolicy(new PKPSiteAccessPolicy($request, null, $roleAssignments));
34  return parent::authorize($request, $args, $roleAssignments);
35  }
36 
42  function index($args, $request) {
43  $templateMgr = TemplateManager::getManager($request);
44  $this->setupTemplate($request);
45  $templateMgr->display('dashboard/index.tpl');
46  }
47 
53  function tasks($args, $request) {
54  $templateMgr = TemplateManager::getManager($request);
55  $this->setupTemplate($request);
56 
57  // Get all the contexts in the system, to determine which 'new submission' entry point we display
58  $contextDao = Application::getContextDAO(); /* @var $contextDao ContextDAO */
59  $contexts = $contextDao->getAll();
60 
61  // Check each context to see if user has access to it.
62  $user = $request->getUser();
63  $roleDao = DAORegistry::getDAO('RoleDAO');
64  $allContextsUserRoles = $roleDao->getByUserIdGroupedByContext($user->getId());
65  $userRolesThatCanSubmit = array(ROLE_ID_AUTHOR, ROLE_ID_ASSISTANT, ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR);
66  $accessibleContexts = array();
67  while ($context = $contexts->next()) {
68  if (array_key_exists($context->getId(), $allContextsUserRoles)) {
69  $contextUserRoles = array_keys($allContextsUserRoles[$context->getId()]);
70  if (array_intersect($userRolesThatCanSubmit, $contextUserRoles)) {
71  $accessibleContexts[] = $context;
72  }
73  }
74  }
75 
76  // Assign contexts to template.
77  $contextCount = count($accessibleContexts);
78  $templateMgr->assign('contextCount', $contextCount);
79  if ($contextCount == 1) {
80  $templateMgr->assign('context', $accessibleContexts[0]);
81  } elseif ($contextCount > 1) {
82  $contexts = array();
83  foreach ($accessibleContexts as $context) {
84  $url = $request->url($context->getPath(), 'submission');
85  $contexts[$url] = $context->getLocalizedName();
86  }
87  $templateMgr->assign('contexts', $contexts);
88  }
89 
90  return $templateMgr->fetchJson('dashboard/tasks.tpl');
91  }
92 
98  function submissions($args, $request) {
99  $templateMgr = TemplateManager::getManager($request);
100  $this->setupTemplate($request);
101 
102  return $templateMgr->fetchJson('dashboard/submissions.tpl');
103  }
104 
110  function archives($args, $request) {
111  $templateMgr = TemplateManager::getManager($request);
112  $this->setupTemplate($request);
113 
114  return $templateMgr->fetchJson('dashboard/archives.tpl');
115  }
116 
121  function setupTemplate($request = null) {
122  AppLocale::requireComponents(LOCALE_COMPONENT_APP_MANAGER, LOCALE_COMPONENT_PKP_MANAGER, LOCALE_COMPONENT_APP_SUBMISSION, LOCALE_COMPONENT_PKP_SUBMISSION);
123  parent::setupTemplate($request);
124  }
125 }
126 
127 ?>
static & getDAO($name, $dbconn=null)
addPolicy($authorizationPolicy, $addToTop=false)
static requireComponents()
archives($args, $request)
addRoleAssignment($roleIds, $operations)
index($args, $request)
submissions($args, $request)
setupTemplate($request=null)
Base request handler application class.
Definition: Handler.inc.php:20
Class to that makes sure that a user is logged in.
authorize($request, &$args, $roleAssignments)
Handle requests for user&#39;s dashboard.
static getContextDAO()
tasks($args, $request)