• Main Page
  • Modules
  • Classes
  • Files
  • File List

controllers/grid/files/SignoffOnSignoffGridColumn.inc.php

00001 <?php
00002 
00016 import('controllers.grid.files.BaseSignoffStatusColumn');
00017 
00018 class SignoffOnSignoffGridColumn extends BaseSignoffStatusColumn {
00024    function SignoffOnSignoffGridColumn($title = null, $userIds = array(), $requestArgs, $flags = array()) {
00025       parent::BaseSignoffStatusColumn('considered', $title, null, $userIds, $requestArgs, $flags);
00026    }
00027 
00028    //
00029    // Overridden methods from GridColumn
00030    //
00034    function getCellActions($request, $row) {
00035       $status = $this->_getSignoffStatus($row);
00036       $signoff =& $row->getData();
00037       $user =& $request->getUser();
00038 
00039       // Assemble the request arguments for the signoff action.
00040       $actionArgs = $this->getRequestArgs();
00041       $actionArgs['signoffId'] = $signoff->getId();
00042 
00043       $router =& $request->getRouter();
00044       $actions = array();
00045 
00046       switch ($status) {
00047          case 'accepted':
00048          case 'new':
00049             // Instantiate the signoff action.
00050             import('lib.pkp.classes.linkAction.request.AjaxAction');
00051             $signoffAction = new LinkAction(
00052                'fileSignoff',
00053                new AjaxAction(
00054                   $router->url(
00055                      $request, null, null, 'signOffsignOff',
00056                      null, $actionArgs
00057                   )
00058                ),
00059                __('common.signoff'),
00060                $status
00061             );
00062             $actions[] = $signoffAction;
00063             break;
00064          case 'completed':
00065             // Instantiate the delete signoff action.
00066             import('lib.pkp.classes.linkAction.request.AjaxAction');
00067             $signoffAction = new LinkAction(
00068                'fileUnconsider',
00069                new AjaxAction(
00070                   $router->url(
00071                      $request, null, null, 'deleteSignOffSignOff',
00072                      null, $actionArgs
00073                   )
00074                ),
00075                __('common.signoff'),
00076                $status
00077             );
00078             $actions[] = $signoffAction;
00079             break;
00080       }
00081 
00082       return $actions;
00083    }
00084 
00085 
00086    //
00087    // Private helper methods
00088    //
00094    function _getSignoffStatus(&$row) {
00095       $signoffInQuestion =& $row->getData();
00096 
00097       // Disabled status until the signoff is completed.
00098       if (!$signoffInQuestion->getDateCompleted()) {
00099          return 'unfinished';
00100       }
00101 
00102       $signoffDao =& DAORegistry::getDAO('SignoffDAO'); /* @var $signoff SignoffDAO */
00103       $viewsDao =& DAORegistry::getDAO('ViewsDAO'); /* @var $viewsDao ViewsDAO */
00104       $viewed = false;
00105       $fileIdAndRevision = $signoffInQuestion->getFileId() . '-' . $signoffInQuestion->getFileRevision();
00106       foreach ($this->getUserIds() as $userId) {
00107          $signoff =& $signoffDao->getBySymbolic('SIGNOFF_SIGNOFF',
00108                                        ASSOC_TYPE_SIGNOFF, $signoffInQuestion->getId(),
00109                                        $userId);
00110          // somebody in one of the user groups signed off on the file
00111          if ($signoff && $signoff->getDateCompleted()) {
00112             return 'completed';
00113          } else {
00114             // Find out whether someone in the user group already downloaded
00115             // (=viewed) the file.
00116             $viewed = $viewed ||
00117                $viewsDao->getLastViewDate(ASSOC_TYPE_MONOGRAPH_FILE, $fileIdAndRevision, $userId);
00118          }
00119          unset($signoff);
00120       }
00121 
00122       // Any view means we can mark green.
00123       if($viewed) {
00124          return 'accepted';
00125       } else {
00126          return 'new';
00127       }
00128    }
00129 }
00130 
00131 
00132 ?>

Generated on Mon Sep 17 2012 13:58:56 for Open Monograph Press by  doxygen 1.7.1