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
00030
00031
00032
00033
00034
00038 function getCellActions($request, $row) {
00039 $status = $this->_getSignoffStatus($row);
00040 $actions = array();
00041 if (in_array($status, array('accepted', 'new'))) {
00042
00043 $monographFile =& $this->getMonographFile($row);
00044
00045
00046 $signoff =& $row->getData();
00047
00048
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
00055 $signoffAction->_image = 'task ' . $status;
00056
00057 $actions[] = $signoffAction;
00058 }
00059 return $actions;
00060 }
00061
00062
00063
00064
00065
00071 function &getMonographFile($row) {
00072 $signoff =& $row->getData();
00073 assert(is_a($signoff, 'SignOff'));
00074 $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
00075 $monographFile =& $submissionFileDao->getLatestRevision($signoff->getAssocId());
00076 assert(is_a($monographFile, 'MonographFile'));
00077 return $monographFile;
00078 }
00079
00080
00081
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
00097 $viewsDao =& DAORegistry::getDAO('ViewsDAO');
00098
00099
00100
00101
00102 $lastViewed = $viewsDao->getLastViewDate(
00103 ASSOC_TYPE_MONOGRAPH_FILE, $monographFile->getFileIdAndRevision(),
00104 $signoff->getUserId()
00105 );
00106
00107
00108 if($lastViewed) {
00109 return 'accepted';
00110 } else {
00111 return 'new';
00112 }
00113 }
00114 }
00115
00116
00117 ?>