Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
UnassignedSubmissionsListGridHandler.inc.php
1 <?php
2 
16 // Import grid base classes.
17 import('lib.pkp.controllers.grid.submissions.SubmissionsListGridHandler');
18 import('lib.pkp.controllers.grid.submissions.SubmissionsListGridRow');
19 
20 // Filter editor
21 define('FILTER_EDITOR_ALL', 0);
22 define('FILTER_EDITOR_ME', 1);
23 
29  parent::SubmissionsListGridHandler();
30  $this->addRoleAssignment(
31  array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR),
32  array('fetchGrid', 'fetchRow', 'deleteSubmission')
33  );
34  }
35 
36 
37  //
38  // Implement template methods from PKPHandler
39  //
43  function initialize($request) {
44  parent::initialize($request);
45 
46  // Set title.
47  $this->setTitle('common.queue.long.submissionsUnassigned');
48 
49  // Add editor specific locale component.
50  AppLocale::requireComponents(LOCALE_COMPONENT_APP_EDITOR);
51  }
52 
53 
54  //
55  // Implement template methods from SubmissionListGridHandler
56  //
60  function getSubmissions($request, $userId) {
61  $submissionDao = Application::getSubmissionDAO(); /* @var $submissionDao SubmissionDAO */
62 
63  // Determine whether this is a Sub Editor or Manager.
64  // Managers can access all submissions, Sub Editors
65  // only assigned submissions.
66  $user = $request->getUser();
67 
68  // Get all submissions for all contexts that user is
69  // enrolled in as manager or series editor.
70  $roleDao = DAORegistry::getDAO('RoleDAO');
71  $contextDao = Application::getContextDAO();
72  $contexts = $contextDao->getAll();
73  $accessibleContexts = array();
74 
75  while ($context = $contexts->next()) {
76  $isManager = $roleDao->userHasRole($context->getId(), $userId, ROLE_ID_MANAGER);
77  $isSubEditor = $roleDao->userHasRole($context->getId(), $userId, ROLE_ID_SUB_EDITOR);
78 
79  if (!$isManager && !$isSubEditor) {
80  continue;
81  }
82  $accessibleContexts[] = $context->getId();
83  }
84 
85  $accessibleSubmissions = array();
86 
87  // Don't use range info to retrieve the object, because we do
88  // some more filtering below, and that would end up breaking
89  // the range info. FIXME: to speed up the process, do all
90  // the filtering needed in SQL and use range info here.
91  $submissionFactory = $submissionDao->getBySubEditorId(
92  $accessibleContexts,
93  null,
94  false, // do not include STATUS_DECLINED submissions
95  false // include only unpublished submissions
96  );
97 
98  if (!$submissionFactory->wasEmpty()) {
99  $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
100  while ($submission = $submissionFactory->next()) {
101  if (!$stageAssignmentDao->editorAssignedToStage($submission->getId())) {
102  $accessibleSubmissions[$submission->getId()] = $submission;
103  }
104  }
105  }
106 
107  $rangeInfo = $this->getGridRangeInfo($request, $this->getId());
108  import('lib.pkp.classes.core.VirtualArrayIterator');
109  return VirtualArrayIterator::factory($accessibleSubmissions, $rangeInfo);
110  }
111 }
112 
113 ?>
Handle unassigned submissions list grid requests.
static & getDAO($name, $dbconn=null)
Handle submission list grid requests.
static requireComponents()
addRoleAssignment($roleIds, $operations)
static getSubmissionDAO()
static factory($wholeArray, $rangeInfo)
getGridRangeInfo($request, $rangeName, $contextData=null)
static getContextDAO()