00001 <?php
00002
00016 import('controllers.grid.files.BaseSignoffStatusColumn');
00017
00018 class SignoffStatusFromFileGridColumn extends BaseSignoffStatusColumn {
00019
00020 var $_symbolic;
00021
00022
00023 var $_allowSignoffs;
00024
00036 function SignoffStatusFromFileGridColumn($id, $title, $titleTranslated, $symbolic, $userIds, $requestArgs, $allowSignoffs = false, $flags = array()) {
00037 $this->_symbolic = $symbolic;
00038 $this->_allowSignoffs = $allowSignoffs;
00039
00040 parent::BaseSignoffStatusColumn(
00041 $id,
00042 $title,
00043 $titleTranslated,
00044 $userIds,
00045 $requestArgs,
00046 $flags
00047 );
00048 }
00049
00050
00051
00052
00053 function getSymbolic() {
00054 return $this->_symbolic;
00055 }
00056
00057
00058
00059
00063 function getCellActions($request, $row) {
00064 $status = $this->_getSignoffStatus($row);
00065 $actions = array();
00066 if (in_array($status, array('accepted', 'new')) && $this->_allowSignoffs) {
00067
00068 $monographFile =& $this->getMonographFile($row);
00069
00070
00071 $actionArgs = $this->getRequestArgs();
00072 $actionArgs['fileId'] = $monographFile->getFileId();
00073
00074
00075 $router =& $request->getRouter();
00076 import('lib.pkp.classes.linkAction.request.AjaxAction');
00077 $signoffAction = new LinkAction(
00078 'fileSignoff',
00079 new AjaxAction(
00080 $router->url(
00081 $request, null, null, 'signOffFile',
00082 null, $actionArgs
00083 )
00084 ),
00085 __('common.signoff'),
00086 'task '.$status
00087 );
00088 $actions[] = $signoffAction;
00089 }
00090 return $actions;
00091 }
00092
00093
00094
00095
00096
00102 function &getMonographFile($row) {
00103 $submissionFileData =& $row->getData();
00104 assert(isset($submissionFileData['submissionFile']));
00105 $monographFile =& $submissionFileData['submissionFile'];
00106 assert(is_a($monographFile, 'MonographFile'));
00107 return $monographFile;
00108 }
00109
00110
00111
00112
00118 function _getSignoffStatus(&$row) {
00119 $monographFile =& $this->getMonographFile($row);
00120
00121 $userIds = $this->getUserIds();
00122 if (in_array($monographFile->getUploaderUserId(), $userIds)) {
00123 return 'uploaded';
00124
00125 } else {
00126
00127 $signoffDao =& DAORegistry::getDAO('SignoffDAO');
00128 $viewsDao =& DAORegistry::getDAO('ViewsDAO');
00129 $lastViewed = false;
00130 foreach ($userIds as $userId) {
00131 $signoffs =& $signoffDao->getAllBySymbolic(
00132 $this->getSymbolic(),
00133 ASSOC_TYPE_MONOGRAPH_FILE, $monographFile->getFileId(),
00134 $userId
00135 );
00136
00137
00138 while($signoff =& $signoffs->next()) {
00139 if ($signoff->getDateCompleted()) {
00140 return 'completed';
00141 }
00142 unset($signoff);
00143 }
00144
00145 if (!$lastViewed) {
00146
00147
00148
00149
00150 $lastViewed = $viewsDao->getLastViewDate(
00151 ASSOC_TYPE_MONOGRAPH_FILE, $monographFile->getFileIdAndRevision(),
00152 $userId
00153 );
00154 }
00155 }
00156
00157 if($lastViewed) {
00158 return 'accepted';
00159 }
00160
00161
00162 return 'new';
00163 }
00164 }
00165 }
00166
00167 ?>