コード例 #1
0
 /**
  * Send an email to a user or group of users.
  */
 function email($args)
 {
     $this->validate();
     $this->setupTemplate(true);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('helpTopicId', 'journal.users.emailUsers');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $site =& Request::getSite();
     $journal =& Request::getJournal();
     $user =& Request::getUser();
     import('classes.mail.MailTemplate');
     $email = new MailTemplate(Request::getUserVar('template'), Request::getUserVar('locale'));
     if (Request::getUserVar('send') && !$email->hasErrors()) {
         $email->send();
         Request::redirect(null, Request::getRequestedPage());
     } else {
         $email->assignParams();
         // FIXME Forces default parameters to be assigned (should do this automatically in MailTemplate?)
         if (!Request::getUserVar('continued')) {
             if (($groupId = Request::getUserVar('toGroup')) != '') {
                 // Special case for emailing entire groups:
                 // Check for a group ID and add recipients.
                 $groupDao =& DAORegistry::getDAO('GroupDAO');
                 $group =& $groupDao->getGroup($groupId);
                 if ($group && $group->getAssocId() == $journal->getId() && $group->getAssocType() == ASSOC_TYPE_JOURNAL) {
                     $groupMembershipDao =& DAORegistry::getDAO('GroupMembershipDAO');
                     $memberships =& $groupMembershipDao->getMemberships($group->getId());
                     $memberships =& $memberships->toArray();
                     foreach ($memberships as $membership) {
                         $user =& $membership->getUser();
                         $email->addRecipient($user->getEmail(), $user->getFullName());
                     }
                 }
             }
             if (count($email->getRecipients()) == 0) {
                 $email->addRecipient($user->getEmail(), $user->getFullName());
             }
         }
         $email->displayEditForm(Request::url(null, null, 'email'), array(), 'manager/people/email.tpl');
     }
 }
コード例 #2
0
 /**
  * Remove book reviewer and reset book for review.
  */
 function removeBookForReviewAuthor($args = array(), &$request)
 {
     $this->setupTemplate();
     if (empty($args)) {
         $request->redirect(null, 'editor');
     }
     $bfrPlugin =& PluginRegistry::getPlugin('generic', BOOKS_FOR_REVIEW_PLUGIN_NAME);
     $returnPage = $request->getUserVar('returnPage');
     if ($returnPage != null) {
         $validPages =& $this->getValidReturnPages();
         if (!in_array($returnPage, $validPages)) {
             $returnPage = null;
         }
     }
     $journal =& $request->getJournal();
     $journalId = $journal->getId();
     $bookId = (int) $args[0];
     $bfrDao =& DAORegistry::getDAO('BookForReviewDAO');
     // Ensure book for review is for this journal
     if ($bfrDao->getBookForReviewJournalId($bookId) == $journalId) {
         import('classes.mail.MailTemplate');
         $email = new MailTemplate('BFR_REVIEWER_REMOVED');
         $send = $request->getUserVar('send');
         // Editor has filled out mail form or skipped mail
         if ($send && !$email->hasErrors()) {
             // Update book for review
             $book =& $bfrDao->getBookForReview($bookId);
             $book->setStatus(BFR_STATUS_AVAILABLE);
             $book->setUserId(null);
             $book->setDateRequested(null);
             $book->setDateAssigned(null);
             $book->setDateDue(null);
             $book->setDateMailed(null);
             $book->setDateSubmitted(null);
             $book->setArticleId(null);
             $bfrDao->updateObject($book);
             $email->send();
             $user =& $request->getUser();
             import('classes.notification.NotificationManager');
             $notificationManager = new NotificationManager();
             $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_BOOK_AUTHOR_REMOVED);
             $request->redirect(null, 'editor', 'booksForReview', $returnPage);
             // Display mail form for editor
         } else {
             if (!$request->getUserVar('continued')) {
                 $book =& $bfrDao->getBookForReview($bookId);
                 $userFullName = $book->getUserFullName();
                 $userEmail = $book->getUserEmail();
                 $paramArray = array('authorName' => strip_tags($userFullName), 'bookForReviewTitle' => '"' . strip_tags($book->getLocalizedTitle()) . '"', 'editorialContactSignature' => String::html2text($book->getEditorContactSignature()));
                 $email->addRecipient($userEmail, $userFullName);
                 $email->setReplyTo($book->getEditorEmail(), $book->getEditorFullName());
                 $email->assignParams($paramArray);
             }
             $returnUrl = $request->url(null, 'editor', 'removeBookForReviewAuthor', $bookId, array('returnPage' => $returnPage));
             $email->displayEditForm($returnUrl);
         }
     }
     $request->redirect(null, 'editor', 'booksForReview', $returnPage);
 }
コード例 #3
0
ファイル: RTHandler.inc.php プロジェクト: jalperin/ocs
 /**
  * Display the "email author"
  * @param $args array
  * @param $request Request
  */
 function emailAuthor($args, &$request)
 {
     $router =& $request->getRouter();
     $this->setupTemplate();
     $paperId = isset($args[0]) ? $args[0] : 0;
     $galleyId = isset($args[1]) ? (int) $args[1] : 0;
     $this->validate($request, $paperId, $galleyId);
     $conference =& $router->getContext($request, CONTEXT_CONFERENCE);
     $schedConf =& $router->getContext($request, CONTEXT_SCHED_CONF);
     $paper =& $this->paper;
     $rtDao =& DAORegistry::getDAO('RTDAO');
     $conferenceRt =& $rtDao->getConferenceRTByConference($conference);
     $user =& $request->getUser();
     if (!$conferenceRt || !$conferenceRt->getEmailAuthor() || !$user) {
         $request->redirect(null, null, $router->getRequestedPage($request));
     }
     import('mail.MailTemplate');
     $email = new MailTemplate();
     if ($request->getUserVar('send') && !$email->hasErrors()) {
         $email->send();
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->display('rt/sent.tpl');
     } else {
         if (!$request->getUserVar('continued')) {
             $email->setSubject('[' . $schedConf->getLocalizedSetting('acronym') . '] ' . strip_tags($paper->getLocalizedTitle()));
             $authors =& $paper->getAuthors();
             $author =& $authors[0];
             $email->addRecipient($author->getEmail(), $author->getFullName());
         }
         $email->displayEditForm($router->url($request, null, null, null, 'emailAuthor', array($paperId, $galleyId)), null, 'rt/email.tpl', array('op' => 'emailAuthor'));
     }
 }
コード例 #4
0
 /**
  * Display the "email author" form
  * @param $args array
  * @param $request Request
  */
 function emailAuthor($args, &$request)
 {
     $router =& $request->getRouter();
     $this->setupTemplate();
     $articleId = isset($args[0]) ? $args[0] : 0;
     $galleyId = isset($args[1]) ? (int) $args[1] : 0;
     $this->validate($request, $articleId, $galleyId);
     $journal =& $router->getContext($request);
     $article =& $this->article;
     $rtDao =& DAORegistry::getDAO('RTDAO');
     $journalRt =& $rtDao->getJournalRTByJournal($journal);
     $user =& $request->getUser();
     if (!$journalRt || !$journalRt->getEmailAuthor() || !$user) {
         $request->redirect(null, $router->getRequestedPage($request));
     }
     import('classes.mail.MailTemplate');
     $email = new MailTemplate();
     $email->setAddressFieldsEnabled(false);
     if ($request->getUserVar('send') && !$email->hasErrors()) {
         $authors =& $article->getAuthors();
         $author =& $authors[0];
         $email->addRecipient($author->getEmail(), $author->getFullName());
         $email->send();
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->display('rt/sent.tpl');
     } else {
         if (!$request->getUserVar('continued')) {
             $email->setSubject('[' . $journal->getLocalizedSetting('initials') . '] ' . strip_tags($article->getLocalizedTitle()));
         }
         $email->displayEditForm($router->url($request, null, null, 'emailAuthor', array($articleId, $galleyId)), null, 'rt/email.tpl', array('op' => 'emailAuthor'));
     }
 }
コード例 #5
0
 /**
  * Author requests a book for review.
  */
 function requestBookForReview($args = array(), $request)
 {
     $this->setupTemplate($request);
     if (empty($args)) {
         $request->redirect(null, 'user');
     }
     $bfrPlugin = PluginRegistry::getPlugin('generic', BOOKS_FOR_REVIEW_PLUGIN_NAME);
     $journal = $request->getJournal();
     $journalId = $journal->getId();
     $bookId = (int) $args[0];
     $bfrDao = DAORegistry::getDAO('BookForReviewDAO');
     // Ensure book for review is for this journal
     if ($bfrDao->getBookForReviewJournalId($bookId) == $journalId) {
         import('lib.pkp.classes.mail.MailTemplate');
         $email = new MailTemplate('BFR_BOOK_REQUESTED');
         $send = $request->getUserVar('send');
         // Author has filled out mail form or decided to skip email
         if ($send && !$email->hasErrors()) {
             // Update book for review as requested
             $book = $bfrDao->getBookForReview($bookId);
             $status = $book->getStatus();
             $bfrPlugin->import('classes.BookForReview');
             // Ensure book for review is avaliable
             if ($status == BFR_STATUS_AVAILABLE) {
                 $user = $request->getUser();
                 $userId = $user->getId();
                 $book->setStatus(BFR_STATUS_REQUESTED);
                 $book->setUserId($userId);
                 $book->setDateRequested(date('Y-m-d H:i:s', time()));
                 $bfrDao->updateObject($book);
                 $email->send();
                 import('classes.notification.NotificationManager');
                 $notificationManager = new NotificationManager();
                 $notificationManager->createTrivialNotification($userId, NOTIFICATION_TYPE_BOOK_REQUESTED);
             }
             $request->redirect(null, 'author', 'booksForReview');
             // Display mail form for author
         } else {
             if (!$request->getUserVar('continued')) {
                 $book = $bfrDao->getBookForReview($bookId);
                 $status = $book->getStatus();
                 $bfrPlugin->import('classes.BookForReview');
                 // Ensure book for review is avaliable
                 if ($status == BFR_STATUS_AVAILABLE) {
                     $user = $request->getUser();
                     $userId = $user->getId();
                     $editorFullName = $book->getEditorFullName();
                     $editorEmail = $book->getEditorEmail();
                     $paramArray = array('editorName' => strip_tags($editorFullName), 'bookForReviewTitle' => '"' . strip_tags($book->getLocalizedTitle()) . '"', 'authorContactSignature' => String::html2text($user->getContactSignature()));
                     $email->addRecipient($editorEmail, $editorFullName);
                     $email->assignParams($paramArray);
                 }
                 $returnUrl = $request->url(null, 'author', 'requestBookForReview', $bookId);
                 $email->displayEditForm($returnUrl);
             }
         }
     }
     $request->redirect(null, 'booksForReview');
 }
コード例 #6
0
ファイル: EmailHandler.inc.php プロジェクト: Rygbee/harvester
 function email($args, $request)
 {
     $this->validate();
     $this->setupTemplate($request, true);
     $templateMgr =& TemplateManager::getManager();
     $userDao = DAORegistry::getDAO('UserDAO');
     $user =& $request->getUser();
     // See if this is the Editor or Manager and an email template has been chosen
     $template = $request->getUserVar('template');
     if (empty($template) || !Validation::isSiteAdmin()) {
         $template = null;
     }
     // Determine whether or not this account is subject to
     // email sending restrictions.
     $canSendUnlimitedEmails = Validation::isSiteAdmin();
     $unlimitedEmailRoles = array(ROLE_ID_SITE_ADMIN);
     $roleDao = DAORegistry::getDAO('RoleDAO');
     $roles =& $roleDao->getRolesByUserId($user->getId());
     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');
         }
     }
     import('classes.mail.MailTemplate');
     $email = new MailTemplate($template);
     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, 'user');
         }
         $user->setDateLastEmail(Core::getCurrentDate());
         $userDao->updateObject($user);
         $request->redirectUrl($redirectUrl);
     } else {
         $email->displayEditForm($request->url(null, null, 'email'), array('redirectUrl' => $request->getUserVar('redirectUrl')), null, array('disableSkipButton' => true));
     }
 }
コード例 #7
0
ファイル: MeetingAction.inc.php プロジェクト: elavaud/hrp_ct
 /**
  * Remind reviewers of a meeting
  * Added by ayveemallare 7/12/2011
  * Moved from sectionEditorAction by EL on March 5th
  */
 function remindUserMeeting($meeting, $addresseeId, $mSectionDecisions, $send = false)
 {
     $journal =& Request::getJournal();
     $user =& Request::getUser();
     $sectionDecisionDao =& DAORegistry::getDAO('SectionDecisionDAO');
     $submissions = (string) '';
     $num = 1;
     foreach ($mSectionDecisions as $mSectionDecision) {
         $sectionDecision = $sectionDecisionDao->getSectionDecision($mSectionDecision->getSectionDecisionId());
         $submissions .= $num . ". '" . $sectionDecision->getLocalizedProposalTitle() . "' " . Locale::translate('common.bySomebody') . ' ' . $sectionDecision->getAuthorString(true) . "\n";
         $num++;
     }
     $userDao =& DAORegistry::getDAO('UserDAO');
     $addressee = $userDao->getUser($addresseeId);
     $reviewerAccessKeysEnabled = $journal->getSetting('reviewerAccessKeysEnabled');
     $preventAddressChanges = $reviewerAccessKeysEnabled;
     import('classes.mail.MailTemplate');
     $email = new MailTemplate('MEETING_REMIND');
     if ($preventAddressChanges) {
         $email->setAddressFieldsEnabled(false);
     }
     if ($send && !$email->hasErrors()) {
         HookRegistry::call('MeetingAction::remindUserMeeting', array(&$meeting, &$addressee, &$submissions, &$email));
         // EL on February 26th 2013
         // Replaced "reviewerAccessKyesEnabled" by "reviewerAccessKeysEnabled"
         if ($reviewerAccessKeysEnabled) {
             import('lib.pkp.classes.security.AccessKeyManager');
             import('pages.reviewer.ReviewerHandler');
             $accessKeyManager = new AccessKeyManager();
         }
         if ($preventAddressChanges) {
             // Ensure that this messages goes to the reviewers, and the reviewers ONLY.
             $email->clearAllRecipients();
             $email->addRecipient($addressee->getEmail(), $addressee->getFullName());
         }
         $email->send();
         $meetingAttendanceDao =& DAORegistry::getDAO('MeetingAttendanceDAO');
         $meetingAttendanceDao->updateDateReminded(Core::getCurrentDate(), $addresseeId, $meeting);
         return true;
     } else {
         if (!Request::getUserVar('continued') || $preventAddressChanges) {
             $email->addRecipient($addressee->getEmail(), $addressee->getFullName());
         }
         if (!Request::getUserVar('continued')) {
             $dateLocation = (string) '';
             if ($meeting->getDate() != null) {
                 $dateLocation .= Locale::translate('editor.reports.meetingDate') . ': ' . strftime('%B %d, %Y %I:%M %p', strtotime($meeting->getDate())) . "\n";
             }
             if ($meeting->getLength() != null) {
                 $dateLocation .= Locale::translate('editor.meeting.length') . ': ' . $meeting->getLength() . "mn\n";
             }
             if ($meeting->getLocation() != null) {
                 $dateLocation .= Locale::translate('editor.meeting.location') . ': ' . $meeting->getLocation() . "\n";
             }
             $dateLocation .= Locale::translate('editor.meeting.numberOfProposalsToReview') . ': ' . count($mSectionDecisions) . "\n";
             $meetingAttendanceDao =& DAORegistry::getDAO('MeetingAttendanceDAO');
             $type = $meetingAttendanceDao->getTypeOfUser($meeting->getId(), $addressee->getId());
             $replyUrl = (string) '';
             if ($type == MEETING_INVESTIGATOR) {
                 $urlFirst = true;
                 foreach ($mSectionDecisions as $mSectionDecision) {
                     $sectionDecision = $sectionDecisionDao->getSectionDecision($mSectionDecision->getSectionDecisionId());
                     if ($urlFirst) {
                         $replyUrl .= Request::url(null, 'author', 'submission', array($sectionDecision->getArticleId(), 'submissionReview'));
                         $urlFirst = false;
                     } else {
                         $replyUrl .= '   ' . Locale::translate("common.or") . ':   ' . Request::url(null, 'author', 'submission', array($sectionDecision->getArticleId(), 'submissionReview'));
                     }
                 }
             } elseif ($type == MEETING_SECRETARY) {
                 $replyUrl = Request::url(null, 'sectionEditor', 'viewMeeting', $meeting->getId());
             } elseif ($type == MEETING_EXTERNAL_REVIEWER || $type == MEETING_ERC_MEMBER) {
                 $replyUrl = Request::url(null, 'reviewer', 'viewMeeting', $meeting->getId(), $reviewerAccessKeysEnabled ? array('key' => 'ACCESS_KEY') : array());
             } else {
                 return false;
             }
             $replyUrl = Request::url(null, 'reviewer', 'viewMeeting', $meeting->getId(), $reviewerAccessKeysEnabled ? array('key' => 'ACCESS_KEY') : array());
             $sectionDao =& DAORegistry::getDAO('SectionDAO');
             $erc =& $sectionDao->getSection($meeting->getUploader());
             $paramArray = array('ercTitle' => $erc->getLocalizedTitle(), 'addresseeFullName' => $addressee->getFullName(), 'submissions' => $submissions, 'dateLocation' => $dateLocation, 'replyUrl' => $replyUrl, 'secretaryName' => $user->getFullName(), 'secretaryFunctions' => $user->getErcFunction($meeting->getUploader()));
             $email->assignParams($paramArray);
         }
         // EL on February 26th 2013
         // Replaced submissionsIds by submissionIds
         // + moved the paramters as additional parameters
         $email->displayEditForm(Request::url(null, null, 'remindUserMeeting', array($meeting->getId(), $addresseeId)));
         return false;
     }
     return true;
 }
コード例 #8
0
ファイル: DOAJPlugin.inc.php プロジェクト: philschatz/ojs
 /**
  * Send the request email to DOAJ.
  * @param $journal object
  */
 function emailRep(&$journal, $send = false)
 {
     $user =& Request::getUser();
     $issn = $journal->getSetting('printIssn');
     import('mail.MailTemplate');
     $mail = new MailTemplate('DOAJ_EMAIL_REP');
     if ($send && !$mail->hasErrors()) {
         $mail->send();
         Request::redirect(null, 'manager', 'importexport');
     } else {
         $paramArray = array('username' => $user->getFirstName() . ' ' . $user->getLastName(), 'journalName' => $journal->getLocalizedTitle(), 'isOpenAccess' => $journal->getSetting('publishingMode') == PUBLISHING_MODE_OPEN ? 'Yes' : 'No', 'altTitle' => $journal->getLocalizedSetting('abbreviation'), 'journalURL' => $journal->getUrl(), 'hasAuthorFee' => $journal->getSetting('submissionFee') > 0 ? 'Yes' : 'No', 'infoURL' => $journal->getUrl(), 'isPeerReviewed' => 'Yes', 'isOriginalResearch' => '', 'isAcademic' => '', 'isActive' => $this->compareToCurDate($journal->getId()) ? 'Yes' : 'No', 'hasPrintedForm' => $issn != '' ? 'Yes' : 'No', 'hasEmbargo' => '', 'accessFrom' => $journal->getSetting('initialYear'), 'firstVolume' => $journal->getSetting('initialVolume'), 'firstIssue' => $journal->getSetting('initialNumber'), 'issn' => $issn, 'eissn' => $journal->getSetting('onlineIssn'), 'publisherName' => $journal->getSetting('publisherInstitution'), 'country' => $user->getCountry(), 'languages' => Locale::getLocale(), 'keywords' => $journal->getLocalizedSetting('searchKeywords'), 'contactName' => $journal->getSetting('contactName'), 'contactEmail' => $journal->getSetting('contactEmail'), 'frequency' => $journal->getSetting('volumePerYear') * $journal->getSetting('issuePerVolume'), 'articlesPerIssue' => $this->getArticlesPerIssue($journal->getId()));
         $mail->assignParams($paramArray);
         $mail->addRecipient('*****@*****.**', 'Sonja Brage');
         $mail->displayEditForm(Request::url(null, 'manager', 'importexport', array('plugin', $this->getName(), 'email')));
     }
 }
コード例 #9
0
 function email($args)
 {
     $this->validate();
     $this->setupTemplate(true);
     $templateMgr =& TemplateManager::getManager();
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $journal =& Request::getJournal();
     $user =& Request::getUser();
     // See if this is the Editor or Manager and an email template has been chosen
     $template = Request::getUserVar('template');
     if (!$journal || empty($template) || !Validation::isJournalManager($journal->getId()) && !Validation::isEditor($journal->getId()) && !Validation::isSectionEditor($journal->getId())) {
         $template = null;
     }
     // Determine whether or not this account is subject to
     // email sending restrictions.
     $canSendUnlimitedEmails = Validation::isSiteAdmin();
     $unlimitedEmailRoles = array(ROLE_ID_JOURNAL_MANAGER, ROLE_ID_EDITOR, ROLE_ID_SECTION_EDITOR);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     if ($journal) {
         $roles =& $roleDao->getRolesByUserId($user->getId(), $journal->getId());
         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 ($articleId = Request::getUserVar('articleId')) {
         // This message is in reference to an article.
         // Determine whether the current user has access
         // to the article in some form, and if so, use an
         // ArticleMailTemplate.
         $articleDao =& DAORegistry::getDAO('ArticleDAO');
         $article =& $articleDao->getArticle($articleId);
         $hasAccess = false;
         // First, conditions where access is OK.
         // 1. User is submitter
         if ($article && $article->getUserId() == $user->getId()) {
             $hasAccess = true;
         }
         // 2. User is section editor of article or full editor
         $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
         $editAssignments =& $editAssignmentDao->getEditAssignmentsByArticleId($articleId);
         while ($editAssignment =& $editAssignments->next()) {
             if ($editAssignment->getEditorId() === $user->getId()) {
                 $hasAccess = true;
             }
         }
         if (Validation::isEditor($journal->getId())) {
             $hasAccess = true;
         }
         // 3. User is reviewer
         $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
         foreach ($reviewAssignmentDao->getBySubmissionId($articleId) as $reviewAssignment) {
             if ($reviewAssignment->getReviewerId() === $user->getId()) {
                 $hasAccess = true;
             }
         }
         // 4. User is copyeditor
         $copyedSignoff =& $signoffDao->getBySymbolic('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $articleId);
         if ($copyedSignoff && $copyedSignoff->getUserId() === $user->getId()) {
             $hasAccess = true;
         }
         // 5. User is layout editor
         $layoutSignoff =& $signoffDao->getBySymbolic('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
         if ($layoutSignoff && $layoutSignoff->getUserId() === $user->getId()) {
             $hasAccess = true;
         }
         // 6. User is proofreader
         $proofSignoff =& $signoffDao->getBySymbolic('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId);
         if ($proofSignoff && $proofSignoff->getUserId() === $user->getId()) {
             $hasAccess = true;
         }
         // Last, "deal-breakers" -- access is not allowed.
         if (!$article || $article && $article->getJournalId() !== $journal->getId()) {
             $hasAccess = false;
         }
         if ($hasAccess) {
             import('classes.mail.ArticleMailTemplate');
             $email = new ArticleMailTemplate($articleDao->getArticle($articleId, $template));
         }
     }
     if ($email === null) {
         import('classes.mail.MailTemplate');
         $email = new MailTemplate($template);
     }
     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, 'user');
         }
         $user->setDateLastEmail(Core::getCurrentDate());
         $userDao->updateObject($user);
         Request::redirectUrl($redirectUrl);
     } else {
         $email->displayEditForm(Request::url(null, null, 'email'), array('redirectUrl' => Request::getUserVar('redirectUrl'), 'articleId' => $articleId), null, array('disableSkipButton' => true, 'articleId' => $articleId));
     }
 }
コード例 #10
0
ファイル: EmailHandler.inc.php プロジェクト: ramonsodoma/ocs
 function email($args)
 {
     $this->validate();
     $this->setupTemplate(true);
     $conference =& Request::getConference();
     $schedConf =& Request::getSchedConf();
     $templateMgr =& TemplateManager::getManager();
     $userDao =& DAORegistry::getDAO('UserDAO');
     $user =& Request::getUser();
     // See if this is the Director or Manager and an email template has been chosen
     $template = Request::getUserVar('template');
     if (!$conference || empty($template) || !Validation::isConferenceManager() && !Validation::isDirector() && !Validation::isTrackDirector()) {
         $template = null;
     }
     // Determine whether or not this account is subject to
     // email sending restrictions.
     $canSendUnlimitedEmails = Validation::isSiteAdmin();
     $unlimitedEmailRoles = array(ROLE_ID_CONFERENCE_MANAGER, ROLE_ID_DIRECTOR, ROLE_ID_TRACK_DIRECTOR);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     if ($conference) {
         $roles =& $roleDao->getRolesByUserId($user->getId(), $conference->getId());
         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->getId()) {
             $hasAccess = true;
         }
         // 2. User is director
         $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
         $editAssignments =& $editAssignmentDao->getEditAssignmentsByPaperId($paperId);
         while ($editAssignment =& $editAssignments->next()) {
             if ($editAssignment->getDirectorId() === $user->getId()) {
                 $hasAccess = true;
             }
         }
         if (Validation::isDirector()) {
             $hasAccess = true;
         }
         // 3. User is reviewer
         $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
         foreach ($reviewAssignmentDao->getBySubmissionId($paperId) as $reviewAssignment) {
             if ($reviewAssignment->getReviewerId() === $user->getId()) {
                 $hasAccess = true;
             }
         }
         // Last, "deal-breakers" -- access is not allowed.
         if ($paper && $paper->getSchedConfId() !== $schedConf->getId()) {
             $hasAccess = false;
         }
         if ($hasAccess) {
             import('classes.mail.PaperMailTemplate');
             $email = new PaperMailTemplate($paperDao->getPaper($paperId));
         }
     }
     if ($email === null) {
         import('classes.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->updateObject($user);
         Request::redirectUrl($redirectUrl);
     } else {
         $email->displayEditForm(Request::url(null, null, null, 'email'), array('redirectUrl' => Request::getUserVar('redirectUrl'), 'paperId' => $paperId), null, array('disableSkipButton' => true));
     }
 }
コード例 #11
0
 function sendEmailRTOs($send = false)
 {
     import('classes.mail.MailTemplate');
     $email = new MailTemplate();
     if ($send && !$email->hasErrors()) {
         HookRegistry::call('SendEmailHandler::sendEmailRTOs', array(&$send));
         $email->send();
         Request::redirect(null, null, 'index');
     } else {
         $sender =& Request::getUser();
         $journal =& Request::getJournal();
         $roleDao =& DAORegistry::getDAO('RoleDAO');
         //Get RTOs
         $authors = $roleDao->getUsersByRoleId(ROLE_ID_AUTHOR);
         //Get already added recipients
         $recipients =& $email->getRecipients();
         if (isset($recipients)) {
             $totalRecipients = count($recipients);
         } else {
             $totalRecipients = 0;
         }
         while (!$authors->eof()) {
             $author =& $authors->next();
             // Check if new recipient is not already added
             $isNotInTheList = true;
             if (isset($recipients)) {
                 foreach ($recipients as $recipient) {
                     if ($recipient['email'] == $author->getEmail()) {
                         $isNotInTheList = false;
                     }
                 }
             }
             //Add new recipients
             if ($sender->getId() != $author->getId() && $isNotInTheList == true) {
                 $email->addRecipient($author->getEmail(), $author->getFullName());
                 $totalRecipients++;
             }
             unset($author);
         }
         $email->displayEditForm(Request::url(null, null, 'sendEmailRTOs', 'send'), null, 'email/email_hiderecipients.tpl', array('totalRecipients' => $totalRecipients));
     }
 }