00001 <?php
00002
00015 import('lib.pkp.classes.controllers.grid.GridCellProvider');
00016
00017 class SignoffGridCellProvider extends GridCellProvider {
00019 var $_monographId;
00020
00022 var $_stageId;
00023
00027 function SignoffGridCellProvider($monographId, $stageId) {
00028 $this->_monographId = $monographId;
00029 $this->_stageId = $stageId;
00030 parent::GridCellProvider();
00031 }
00032
00033
00034
00035
00036 function getMonographId() {
00037 return $this->_monographId;
00038 }
00039
00040 function getStageId() {
00041 return $this->_stageId;
00042 }
00043
00051 function getCellActions(&$request, &$row, &$column, $position = GRID_ACTION_POSITION_DEFAULT) {
00052 if ($column->getId() == 'name') {
00053 $user =& $request->getUser();
00054 $actionArgs = array_merge($row->getRequestArgs(),
00055 array('signoffId' => $row->getId()));
00056 $signoff =& $row->getData();
00057 $actions = array();
00058 if($signoff->getDateCompleted()) {
00059 import('controllers.informationCenter.linkAction.SignoffNotesLinkAction');
00060 $actions[] = new SignoffNotesLinkAction($request, $signoff, $this->getMonographId(), $this->getStageId());
00061 } else if (time() > strtotime($signoff->getDateUnderway())) {
00062 import('controllers.api.task.SendReminderLinkAction');
00063 $actions[] = new SendReminderLinkAction($request, 'editor.monograph.proof.reminder', $actionArgs);
00064 }
00065
00066 if (!$signoff->getDateCompleted() && $signoff->getUserId() == $user->getId()) {
00067
00068 import('controllers.api.signoff.linkAction.AddSignoffFileLinkAction');
00069 $addFileAction = new AddSignoffFileLinkAction(
00070 $request, $this->getMonographId(),
00071 $this->getStageId(), $signoff->getSymbolic(), $signoff->getId(),
00072 __('submission.upload.signoff'), __('submission.upload.signoff')
00073 );
00074
00075
00076 $addFileAction->_title = null;
00077 $actions[] = $addFileAction;
00078 }
00079 }
00080
00081 return array_merge(parent::getCellActions($request, $row, $column, $position), $actions);
00082 }
00083
00091 function getTemplateVarsFromRowColumn(&$row, &$column) {
00092 $signoff =& $row->getData();
00093 $columnId = $column->getId();
00094 assert(is_a($signoff, 'Signoff') && !empty($columnId));
00095
00096 if ($columnId == 'name') {
00097 return array('label' => $this->_getLabel($signoff));
00098 }
00099
00100 return parent::getTemplateVarsFromRowColumn($row, $column);
00101 }
00102
00106 function _getLabel(&$signoff) {
00107 $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
00108 $userDao =& DAORegistry::getDAO('UserDAO');
00109 $userGroup =& $userGroupDao->getById($signoff->getUserGroupId());
00110 $user =& $userDao->getById($signoff->getUserId());
00111
00112 return $user->getFullName() . ' (' . $userGroup->getLocalizedName() . ')';
00113 }
00114 }
00115
00116 ?>