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

controllers/grid/files/SignoffStatusFromSignoffGridColumn.inc.php

00001 <?php
00002 
00016 import('controllers.grid.files.BaseSignoffStatusColumn');
00017 
00018 class SignoffStatusFromSignoffGridColumn extends BaseSignoffStatusColumn {
00024    function SignoffStatusFromSignoffGridColumn($title = null, $requestArgs, $flags = array()) {
00025       parent::BaseSignoffStatusColumn('approved', $title, null, null, $requestArgs, $flags);
00026    }
00027 
00028    //
00029    // Overridden methods from UserGroupColumn
00030    //
00031 
00032    //
00033    // Overridden methods from GridColumn
00034    //
00038    function getCellActions($request, $row) {
00039       $status = $this->_getSignoffStatus($row);
00040       $actions = array();
00041       if (in_array($status, array('accepted', 'new'))) {
00042          // Retrieve the submission file.
00043          $monographFile =& $this->getMonographFile($row);
00044 
00045          // Retrieve the signoff
00046          $signoff =& $row->getData();
00047 
00048          // Action to signoff on a file -- Lets user interact with their own rows.;
00049          import('controllers.api.signoff.linkAction.AddSignoffFileLinkAction');
00050          $signoffAction = new AddSignoffFileLinkAction(
00051                                           $request, $monographFile->getMonographId(),
00052                                           $row->getStageId(), $signoff->getSymbolic(), $signoff->getId(),
00053                                           __('submission.upload.signoff'), __('submission.upload.signoff'));
00054          // FIXME: not ideal
00055          $signoffAction->_image = 'task ' . $status;
00056 
00057          $actions[] = $signoffAction;
00058       }
00059       return $actions;
00060    }
00061 
00062 
00063    //
00064    // Protected helper methods
00065    //
00071    function &getMonographFile($row) {
00072       $signoff =& $row->getData();
00073       assert(is_a($signoff, 'SignOff'));
00074       $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */
00075       $monographFile =& $submissionFileDao->getLatestRevision($signoff->getAssocId());
00076       assert(is_a($monographFile, 'MonographFile'));
00077       return $monographFile;
00078    }
00079 
00080    //
00081    // Private helper methods
00082    //
00088    function _getSignoffStatus(&$row) {
00089       $monographFile =& $this->getMonographFile($row);
00090       $signoff =& $row->getData();
00091 
00092       if ($signoff->getDateCompleted()) {
00093          return 'completed';
00094       }
00095 
00096       // The current user has to sign off the file
00097       $viewsDao =& DAORegistry::getDAO('ViewsDAO'); /* @var $viewsDao ViewsDAO */
00098 
00099       // Find out whether someone in the user group already downloaded
00100       // (=viewed) the file.
00101       // no users means a blank column (should not happen).
00102       $lastViewed = $viewsDao->getLastViewDate(
00103          ASSOC_TYPE_MONOGRAPH_FILE, $monographFile->getFileIdAndRevision(),
00104          $signoff->getUserId()
00105       );
00106 
00107       // Any view means we can stop looping and mark green.
00108       if($lastViewed) {
00109          return 'accepted';
00110       } else {
00111          return 'new';
00112       }
00113    }
00114 }
00115 
00116 
00117 ?>

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