Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
PKPAuditorReminderForm.inc.php
1 <?php
2 
16 import('lib.pkp.classes.form.Form');
17 
20  var $_signoff;
21 
24 
26  var $_stageId;
27 
31  function PKPAuditorReminderForm(&$signoff, $submissionId, $stageId) {
32  parent::Form('controllers/grid/files/fileSignoff/form/auditorReminderForm.tpl'); // context-specific.
33  $this->_signoff = $signoff;
34  $this->_submissionId = $submissionId;
35  $this->_stageId = $stageId;
36 
37  // Validation checks for this form
38  $this->addCheck(new FormValidatorPost($this));
39  }
40 
41  //
42  // Getters and Setters
43  //
48  function &getSignoff() {
49  return $this->_signoff;
50  }
51 
56  function getSubmissionId() {
57  return $this->_submissionId;
58  }
59 
64  function getStageId() {
65  return $this->_stageId;
66  }
67 
68  //
69  // Overridden template methods
70  //
76  function initData($args, $request) {
77  $userDao = DAORegistry::getDAO('UserDAO');
78  $user = $request->getUser();
79  $context = $request->getContext();
80 
81  $signoff = $this->getSignoff();
82  $auditorId = $signoff->getUserId();
83  $auditor = $userDao->getById($auditorId);
84 
85  $submissionDao = Application::getSubmissionDAO();
86  $submission = $submissionDao->getById($this->getSubmissionId());
87 
88  $email = $this->_getMailTemplate($submission);
89 
90  // Format the review due date
91  $signoffDueDate = strtotime($signoff->getDateUnderway());
92  $dateFormatShort = Config::getVar('general', 'date_format_short');
93  if ($signoffDueDate == -1) $signoffDueDate = $dateFormatShort; // Default to something human-readable if no date specified
94  else $signoffDueDate = strftime($dateFormatShort, $signoffDueDate);
95 
96  import('lib.pkp.controllers.grid.submissions.SubmissionsListGridCellProvider');
97  list($page, $operation) = SubmissionsListGridCellProvider::getPageAndOperationByUserRoles($request, $submission, $auditor->getId());
98 
99  $dispatcher = $request->getDispatcher();
100  $auditUrl = $dispatcher->url($request, ROUTE_PAGE, null, $page, $operation, array('submissionId' => $submission->getId()));
101 
102  $paramArray = array(
103  'reviewerName' => $auditor->getFullName(),
104  'reviewDueDate' => $signoffDueDate,
105  'editorialContactSignature' => $user->getContactSignature(),
106  'auditorUserName' => $auditor->getUsername(),
107  'passwordResetUrl' => $dispatcher->url($request, ROUTE_PAGE, null, 'login', 'resetPassword', $auditor->getUsername(), array('confirm' => Validation::generatePasswordResetHash($auditor->getId()))),
108  'submissionReviewUrl' => $auditUrl,
109  'contextName' => $context->getLocalizedName(),
110  'submissionTitle' => $submission->getLocalizedTitle(),
111  );
112  $email->assignParams($paramArray);
113 
114  $this->setData('submissionId', $submission->getId());
115  $this->setData('stageId', $this->getStageId());
116  $this->setData('signoffId', $signoff->getId());
117  $this->setData('signoff', $signoff);
118  $this->setData('auditorName', $auditor->getFullName());
119  $this->setData('message', $email->getBody() . "\n" . $context->getSetting('emailSignature'));
120  }
121 
126  function readInputData() {
127  $this->readUserVars(array('message'));
128 
129  }
130 
136  function execute($args, $request) {
137  $userDao = DAORegistry::getDAO('UserDAO');
138  $submissionDao = Application::getSubmissionDAO();
139 
140  $signoff = $this->getSignoff();
141  $auditorId = $signoff->getUserId();
142  $auditor = $userDao->getById($auditorId);
143  $submission = $submissionDao->getById($this->getSubmissionId());
144 
145  $email = $this->_getMailTemplate($submission);
146 
147  $email->addRecipient($auditor->getEmail(), $auditor->getFullName());
148  $email->setBody($this->getData('message'));
149  $email->send($request);
150  }
151 
157  function _getMailTemplate($submission) {
158  assert(false); // overridden in subclasses.
159  }
160 }
161 
162 ?>
static & getDAO($name, $dbconn=null)
addCheck($formValidator)
Definition: Form.inc.php:396
setData($key, $value)
Definition: Form.inc.php:219
static generatePasswordResetHash($userId)
Form validation check to make sure the form is POSTed.
readUserVars($vars)
Definition: Form.inc.php:364
Class defining basic operations for handling HTML forms.
Definition: Form.inc.php:47
getData($key)
Definition: Form.inc.php:210
static getVar($section, $key, $default=null)
Definition: Config.inc.php:35
static getSubmissionDAO()
PKPAuditorReminderForm(&$signoff, $submissionId, $stageId)
static getPageAndOperationByUserRoles($request, $submission, $userId=null)
Base Form for sending a singoff reminder to an auditor.