Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
NotifyUsersListbuilderHandler.inc.php
1 <?php
2 
16 import('lib.pkp.classes.controllers.listbuilder.ListbuilderHandler');
17 
23  parent::ListbuilderHandler();
24  $this->addRoleAssignment(
25  array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT, ROLE_ID_AUTHOR),
26  array('fetch', 'fetchRow', 'fetchOptions')
27  );
28  }
29 
30  //
31  // Getters/Setters
32  //
37  function getSubmission() {
38  return $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
39  }
40 
41  function getStageId() {
42  return $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
43  }
44 
45  //
46  // Overridden parent class functions
47  //
51  function getRequestArgs() {
52  $submission = $this->getSubmission();
53  return array(
54  'submissionId' => $submission->getId(),
55  'stageId' => $this->getStageId()
56  );
57  }
58 
59  //
60  // Implement protected template methods from PKPHandler
61  //
65  function initialize($request) {
66  parent::initialize($request);
67 
68  // Load submission-specific translations
69  AppLocale::requireComponents(LOCALE_COMPONENT_PKP_USER);
70 
71  $this->setTitle('email.recipients');
72 
73  import('lib.pkp.classes.linkAction.request.NullAction');
74  $this->addAction(
75  new LinkAction(
76  'addItem',
77  new NullAction(),
78  __('grid.action.addUser'),
79  'add_user'
80  )
81  );
82 
83  // Basic configuration.
84  $this->setSourceType(LISTBUILDER_SOURCE_TYPE_SELECT);
85  $this->setSaveType(LISTBUILDER_SAVE_TYPE_EXTERNAL);
86  $this->setSaveFieldName('users');
87 
88  // Name column
89  $nameColumn = new ListbuilderGridColumn($this, 'name', 'common.name');
90  import('lib.pkp.controllers.listbuilder.users.UserListbuilderGridCellProvider');
91  $cellProvider = new UserListbuilderGridCellProvider();
92  $nameColumn->setCellProvider($cellProvider);
93  $this->addColumn($nameColumn);
94  }
95 
99  function authorize($request, &$args, $roleAssignments) {
100  import('classes.security.authorization.SubmissionAccessPolicy');
101  $this->addPolicy(new SubmissionAccessPolicy($request, $args, $roleAssignments, 'submissionId'));
102  return parent::authorize($request, $args, $roleAssignments);
103  }
104 
105  //
106  // Implement methods from ListbuilderHandler
107  //
111  function getRowDataElement($request, $rowId) {
112  // fallback on the parent if a rowId is found
113  if ( !empty($rowId) ) {
114  return parent::getRowDataElement($request, $rowId);
115  }
116 
117  // Otherwise return from the newRowId
118  // FIXME: Validate user ID?
119  $newRowId = $this->getNewRowId($request);
120  $userId = (int) $newRowId['name'];
121  $userDao = DAORegistry::getDAO('UserDAO');
122  return $userDao->getById($userId);
123  }
124 
128  function getOptions() {
129  // Initialize the object to return
130  $items = array(
131  array()
132  );
133 
134  $userStageAssignmentDao = DAORegistry::getDAO('UserStageAssignmentDAO');
135  $submission = $this->getSubmission();
136 
137  // FIXME: add stage id?
138  $users = $userStageAssignmentDao->getUsersBySubmissionAndStageId($submission->getId());
139  while ($user = $users->next()) {
140  $items[0][$user->getId()] = $user->getFullName() . ' <' . $user->getEmail() . '>';
141  }
142  return $items;
143  }
144 
148  function loadData($request) {
149  $userId = (int) $request->getUserVar('userId');
150  $userStageAssignmentDao = DAORegistry::getDAO('UserStageAssignmentDAO');
151  $submission = $this->getSubmission();
152 
153  $users = $userStageAssignmentDao->getUsersBySubmissionAndStageId($submission->getId(), null, null, null, $userId);
154  $user = $users->next();
155 
156  if ($user) {
157  $items[0] = $user;
158  return $items;
159  }
160  }
161 }
162 
163 ?>
static & getDAO($name, $dbconn=null)
addPolicy($authorizationPolicy, $addToTop=false)
static requireComponents()
addAction($action, $position=GRID_ACTION_POSITION_ABOVE)
addColumn($column)
Class defining basic operations for handling Listbuilder UI elements.
addRoleAssignment($roleIds, $operations)
Class to control (write) access to submissions and (read) access to submission details in OMP...
Represents a column within a listbuilder.
Base class for a cell provider that can retrieve labels from arrays.
authorize($request, &$args, $roleAssignments)
& getAuthorizedContextObject($assocType)
Base class defining an action that can be performed by the user in the user interface.
Class for adding participants to a stage.
This action does nothing.