getRolesByUserId($user->getUserId(), $conference->getConferenceId()); foreach ($roles as $role) { if (in_array($role->getRoleId(), $unlimitedEmailRoles)) $canSendUnlimitedEmails = true; } } // Check when this user last sent an email, and if it's too // recent, make them wait. if (!$canSendUnlimitedEmails) { $dateLastEmail = $user->getDateLastEmail(); if ($dateLastEmail && strtotime($dateLastEmail) + ((int) Config::getVar('email', 'time_between_emails')) > strtotime(Core::getCurrentDate())) { $templateMgr->assign('pageTitle', 'email.compose'); $templateMgr->assign('message', 'email.compose.tooSoon'); $templateMgr->assign('backLink', 'javascript:history.back()'); $templateMgr->assign('backLinkLabel', 'email.compose'); return $templateMgr->display('common/message.tpl'); } } $email = null; if ($paperId = Request::getUserVar('paperId')) { // This message is in reference to a paper. // Determine whether the current user has access // to the paper in some form, and if so, use an // PaperMailTemplate. $paperDao =& DAORegistry::getDAO('PaperDAO'); $paper =& $paperDao->getPaper($paperId); $hasAccess = false; // First, conditions where access is OK. // 1. User is submitter if ($paper && $paper->getUserId() == $user->getUserId()) $hasAccess = true; // 2. User is director $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO'); $editAssignments =& $editAssignmentDao->getEditAssignmentsByPaperId($paperId); while ($editAssignment =& $editAssignments->next()) { if ($editAssignment->getDirectorId() === $user->getUserId()) $hasAccess = true; } if (Validation::isDirector()) $hasAccess = true; // 3. User is reviewer $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); foreach ($reviewAssignmentDao->getReviewAssignmentsByPaperId($paperId) as $reviewAssignment) { if ($reviewAssignment->getReviewerId() === $user->getUserId()) $hasAccess = true; } // Last, "deal-breakers" -- access is not allowed. if ($paper && $paper->getSchedConfId() !== $schedConf->getSchedConfId()) $hasAccess = false; if ($hasAccess) { import('mail.PaperMailTemplate'); $email =& new PaperMailTemplate($paperDao->getPaper($paperId)); } } if ($email === null) { import('mail.MailTemplate'); $email = &new MailTemplate(); } if (Request::getUserVar('send') && !$email->hasErrors()) { $recipients = $email->getRecipients(); $ccs = $email->getCcs(); $bccs = $email->getBccs(); // Make sure there aren't too many recipients (to // prevent use as a spam relay) $recipientCount = 0; if (is_array($recipients)) $recipientCount += count($recipients); if (is_array($ccs)) $recipientCount += count($ccs); if (is_array($bccs)) $recipientCount += count($bccs); if ($canSendUnlimitedEmails && $recipientCount > ((int) Config::getVar('email', 'max_recipients'))) { $templateMgr->assign('pageTitle', 'email.compose'); $templateMgr->assign('message', 'email.compose.tooManyRecipients'); $templateMgr->assign('backLink', 'javascript:history.back()'); $templateMgr->assign('backLinkLabel', 'email.compose'); return $templateMgr->display('common/message.tpl'); } $email->send(); $redirectUrl = Request::getUserVar('redirectUrl'); if (empty($redirectUrl)) $redirectUrl = Request::url(null, null, 'user'); $user->setDateLastEmail(Core::getCurrentDate()); $userDao->updateUser($user); Request::redirectUrl($redirectUrl); } else { if (!Request::getUserVar('continued')) { // Check for special cases. // 1. If the parameter presentersPaperId is set, preload // the template with all the presenters of the specified // paper ID as recipients and use the paper title // as a subject. if (Request::getUserVar('presentersPaperId')) { $paperDao = &DAORegistry::getDAO('PaperDAO'); $paper = $paperDao->getPaper(Request::getUserVar('presentersPaperId')); if (isset($paper) && $paper != null) { foreach ($paper->getPresenters() as $presenter) { $email->addRecipient($presenter->getEmail(), $presenter->getFullName()); } $email->setSubject($email->getSubject() . strip_tags($paper->getPaperTitle())); } } } $email->displayEditForm(Request::url(null, null, null, 'email'), array('redirectUrl' => Request::getUserVar('redirectUrl'), 'paperId' => $paperId), null, array('disableSkipButton' => true)); } } } ?>