Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
SignoffOnSignoffGridColumn.inc.php
1 <?php
16 import('lib.pkp.controllers.grid.files.BaseSignoffStatusColumn');
17 
24  function SignoffOnSignoffGridColumn($title = null, $userIds = array(), $requestArgs, $flags = array()) {
25  parent::BaseSignoffStatusColumn('considered', $title, null, $userIds, $requestArgs, $flags);
26  }
27 
28  //
29  // Overridden methods from GridColumn
30  //
34  function getCellActions($request, $row) {
35  $status = $this->_getSignoffStatus($row);
36  $signoff = $row->getData();
37  $user = $request->getUser();
38 
39  // Assemble the request arguments for the signoff action.
40  $actionArgs = $this->getRequestArgs();
41  $actionArgs['signoffId'] = $signoff->getId();
42 
43  $router = $request->getRouter();
44  $actions = array();
45 
46  switch ($status) {
47  case 'accepted':
48  case 'new':
49  // Instantiate the signoff action.
50  import('lib.pkp.classes.linkAction.request.AjaxAction');
51  $signoffAction = new LinkAction(
52  'fileSignoff',
53  new AjaxAction(
54  $router->url(
55  $request, null, null, 'signOffsignOff',
56  null, $actionArgs
57  )
58  ),
59  __('common.signoff'),
60  $status
61  );
62  $actions[] = $signoffAction;
63  break;
64  case 'completed':
65  // Instantiate the delete signoff action.
66  import('lib.pkp.classes.linkAction.request.AjaxAction');
67  $signoffAction = new LinkAction(
68  'fileUnconsider',
69  new AjaxAction(
70  $router->url(
71  $request, null, null, 'deleteSignOffSignOff',
72  null, $actionArgs
73  )
74  ),
75  __('common.signoff'),
76  $status
77  );
78  $actions[] = $signoffAction;
79  break;
80  }
81 
82  return $actions;
83  }
84 
85 
86  //
87  // Private helper methods
88  //
94  function _getSignoffStatus($row) {
95  $signoffInQuestion =& $row->getData();
96 
97  // Disabled status until the signoff is completed.
98  if (!$signoffInQuestion->getDateCompleted()) {
99  return 'unfinished';
100  }
101 
102  $signoffDao = DAORegistry::getDAO('SignoffDAO'); /* @var $signoff SignoffDAO */
103  $viewsDao = DAORegistry::getDAO('ViewsDAO'); /* @var $viewsDao ViewsDAO */
104  $viewed = false;
105  $fileIdAndRevision = $signoffInQuestion->getFileId() . '-' . $signoffInQuestion->getFileRevision();
106  foreach ($this->getUserIds() as $userId) {
107  $signoff = $signoffDao->getBySymbolic(
108  'SIGNOFF_SIGNOFF',
109  ASSOC_TYPE_SIGNOFF, $signoffInQuestion->getId(),
110  $userId
111  );
112  // somebody in one of the user groups signed off on the file
113  if ($signoff && $signoff->getDateCompleted()) {
114  return 'completed';
115  } else {
116  // Find out whether someone in the user group already downloaded
117  // (=viewed) the file.
118  $viewed = $viewed || $viewsDao->getLastViewDate(ASSOC_TYPE_SUBMISSION_FILE, $fileIdAndRevision, $userId);
119  }
120  }
121 
122  // Any view means we can mark green.
123  if($viewed) {
124  return 'accepted';
125  } else {
126  return 'new';
127  }
128  }
129 }
130 
131 
132 ?>
static & getDAO($name, $dbconn=null)
Implements a grid column that displays the signoff status of a file.
SignoffOnSignoffGridColumn($title=null, $userIds=array(), $requestArgs, $flags=array())
Class defining an AJAX action.
Implements a grid column for a user group/signoff column.
Base class defining an action that can be performed by the user in the user interface.