/**
  * Allows editors to write emails to users associated with the journal.
  */
 function notifyUsers($args, $request)
 {
     $this->validate((int) $request->getUserVar('issue'));
     $issue =& $this->issue;
     $this->setupTemplate(EDITOR_SECTION_ISSUES);
     $userDao =& DAORegistry::getDAO('UserDAO');
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $authorDao =& DAORegistry::getDAO('AuthorDAO');
     $individualSubscriptionDao =& DAORegistry::getDAO('IndividualSubscriptionDAO');
     $institutionalSubscriptionDao =& DAORegistry::getDAO('InstitutionalSubscriptionDAO');
     $journal =& $request->getJournal();
     $user =& $request->getUser();
     $templateMgr =& TemplateManager::getManager();
     import('lib.pkp.classes.mail.MassMail');
     $email = new MassMail('PUBLISH_NOTIFY');
     if ($request->getUserVar('send') && !$email->hasErrors()) {
         $email->addRecipient($user->getEmail(), $user->getFullName());
         switch ($request->getUserVar('whichUsers')) {
             case 'allIndividualSubscribers':
                 $recipients =& $individualSubscriptionDao->getSubscribedUsers($journal->getId());
                 break;
             case 'allInstitutionalSubscribers':
                 $recipients =& $institutionalSubscriptionDao->getSubscribedUsers($journal->getId());
                 break;
             case 'allAuthors':
                 $recipients =& $authorDao->getAuthorsAlphabetizedByJournal($journal->getId(), null, null, true);
                 break;
             case 'allUsers':
                 $recipients =& $roleDao->getUsersByJournalId($journal->getId());
                 break;
             case 'allReaders':
             default:
                 $recipients =& $roleDao->getUsersByRoleId(ROLE_ID_READER, $journal->getId());
                 break;
         }
         while (!$recipients->eof()) {
             $recipient =& $recipients->next();
             $email->addRecipient($recipient->getEmail(), $recipient->getFullName());
             unset($recipient);
         }
         if ($request->getUserVar('includeToc') == '1' && isset($issue)) {
             $issue = $issueDao->getIssueById($request->getUserVar('issue'));
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $publishedArticles =& $publishedArticleDao->getPublishedArticlesInSections($issue->getId());
             $templateMgr->assign_by_ref('journal', $journal);
             $templateMgr->assign_by_ref('issue', $issue);
             $templateMgr->assign('body', $email->getBody());
             $templateMgr->assign_by_ref('publishedArticles', $publishedArticles);
             $email->setBody($templateMgr->fetch('editor/notifyUsersEmail.tpl'));
             // Stamp the "users notified" date.
             $issue->setDateNotified(Core::getCurrentDate());
             $issueDao->updateIssue($issue);
         }
         $callback = array(&$email, 'send');
         $templateMgr->setProgressFunction($callback);
         unset($callback);
         $email->setFrequency(10);
         // 10 emails per callback
         $callback = array(&$templateMgr, 'updateProgressBar');
         $email->setCallback($callback);
         unset($callback);
         $templateMgr->assign('message', 'editor.notifyUsers.inProgress');
         $templateMgr->display('common/progress.tpl');
         echo '<script type="text/javascript">window.location = "' . $request->url(null, 'editor') . '";</script>';
     } else {
         if (!$request->getUserVar('continued')) {
             $email->assignParams(array('editorialContactSignature' => $user->getContactSignature()));
         }
         $issuesIterator =& $issueDao->getIssues($journal->getId());
         $allUsersCount = $roleDao->getJournalUsersCount($journal->getId());
         // FIXME: There should be a better way of doing this.
         $authors =& $authorDao->getAuthorsAlphabetizedByJournal($journal->getId(), null, null, true);
         $authorCount = $authors->getCount();
         $email->displayEditForm($request->url(null, null, 'notifyUsers'), array(), 'editor/notifyUsers.tpl', array('issues' => $issuesIterator, 'allUsersCount' => $allUsersCount, 'allReadersCount' => $roleDao->getJournalUsersCount($journal->getId(), ROLE_ID_READER), 'allAuthorsCount' => $authorCount, 'allIndividualSubscribersCount' => $individualSubscriptionDao->getSubscribedUserCount($journal->getId()), 'allInstitutionalSubscribersCount' => $institutionalSubscriptionDao->getSubscribedUserCount($journal->getId())));
     }
 }
Esempio n. 2
0
 /**
  * Allows directors to write emails to users associated with the conference.
  */
 function notifyUsers($args, $request)
 {
     $this->validate($request);
     $this->setupTemplate($request, DIRECTOR_TRACK_HOME);
     $userDao =& DAORegistry::getDAO('UserDAO');
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $authorDao =& DAORegistry::getDAO('AuthorDAO');
     $registrationDao =& DAORegistry::getDAO('RegistrationDAO');
     $conference =& $request->getConference();
     $conferenceId = $conference->getId();
     $schedConf =& $request->getSchedConf();
     $schedConfId = $schedConf->getId();
     $user =& $request->getUser();
     $templateMgr =& TemplateManager::getManager();
     import('lib.pkp.classes.mail.MassMail');
     $email = new MassMail('PUBLISH_NOTIFY');
     if ($request->getUserVar('send') && !$email->hasErrors()) {
         $email->addRecipient($user->getEmail(), $user->getFullName());
         switch ($request->getUserVar('whichUsers')) {
             case 'allPaidRegistrants':
                 $recipients =& $registrationDao->getRegisteredUsers($schedConfId);
                 break;
             case 'allRegistrants':
                 $recipients =& $registrationDao->getRegisteredUsers($schedConfId, false);
                 break;
             case 'allAuthors':
                 $recipients =& $authorDao->getAuthorsAlphabetizedBySchedConf($schedConfId, null, null, true);
                 break;
             case 'allUsers':
                 $recipients =& $roleDao->getUsersBySchedConfId($schedConfId);
                 break;
             case 'allReaders':
             default:
                 $recipients =& $roleDao->getUsersByRoleId(ROLE_ID_READER, $conferenceId, $schedConfId);
                 break;
         }
         while (!$recipients->eof()) {
             $recipient =& $recipients->next();
             $email->addRecipient($recipient->getEmail(), $recipient->getFullName());
             unset($recipient);
         }
         if ($request->getUserVar('includeToc') == '1') {
             $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
             $publishedPapers =& $publishedPaperDao->getPublishedPapersInTracks($schedConfId);
             $templateMgr->assign_by_ref('conference', $conference);
             $templateMgr->assign_by_ref('schedConf', $schedConf);
             $templateMgr->assign('body', $email->getBody());
             $templateMgr->assign_by_ref('publishedPapers', $publishedPapers);
             $email->setBody($templateMgr->fetch('director/notifyUsersEmail.tpl'));
         }
         $callback = array(&$email, 'send');
         $templateMgr->setProgressFunction($callback);
         unset($callback);
         $email->setFrequency(10);
         // 10 emails per callback
         $callback = array('TemplateManager', 'updateProgressBar');
         $email->setCallback($callback);
         unset($callback);
         $templateMgr->assign('message', 'common.inProgress');
         $templateMgr->display('common/progress.tpl');
         echo '<script type="text/javascript">window.location = "' . $request->url(null, null, 'director') . '";</script>';
     } else {
         if (!$request->getUserVar('continued')) {
             $email->assignParams(array('editorialContactSignature' => $user->getContactSignature()));
         }
         // FIXME: There should be a better way of doing this.
         $authors =& $authorDao->getAuthorsAlphabetizedBySchedConf($schedConfId, null, null, true);
         $authorCount = $authors->getCount();
         $email->displayEditForm($request->url(null, null, null, 'notifyUsers'), array(), 'director/notifyUsers.tpl', array('allReadersCount' => $roleDao->getSchedConfUsersCount($schedConfId, ROLE_ID_READER), 'allAuthorsCount' => $authorCount, 'allPaidRegistrantsCount' => $registrationDao->getRegisteredUserCount($schedConfId), 'allRegistrantsCount' => $registrationDao->getRegisteredUserCount($schedConfId, false), 'allUsersCount' => $roleDao->getSchedConfUsersCount($schedConfId)));
     }
 }
 /**
  * Allows editors to write emails to users associated with the journal.
  */
 function notifyUsers($args)
 {
     $this->validate(Request::getUserVar('issue'));
     $issue =& $this->issue;
     $this->setupTemplate(EDITOR_SECTION_ISSUES);
     $userDao =& DAORegistry::getDAO('UserDAO');
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $journal =& Request::getJournal();
     $user =& Request::getUser();
     $templateMgr =& TemplateManager::getManager();
     import('mail.MassMail');
     $email = new MassMail('PUBLISH_NOTIFY');
     if (Request::getUserVar('send') && !$email->hasErrors()) {
         $email->addRecipient($user->getEmail(), $user->getFullName());
         $recipients = $roleDao->getUsersByJournalId($journal->getId());
         while (!$recipients->eof()) {
             $recipient =& $recipients->next();
             $email->addRecipient($recipient->getEmail(), $recipient->getFullName());
             unset($recipient);
         }
         if (Request::getUserVar('includeToc') == '1' && isset($issue)) {
             $issue = $issueDao->getIssueById(Request::getUserVar('issue'));
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $publishedArticles =& $publishedArticleDao->getPublishedArticlesInSections($issue->getId());
             $templateMgr->assign_by_ref('journal', $journal);
             $templateMgr->assign_by_ref('issue', $issue);
             $templateMgr->assign('body', $email->getBody());
             $templateMgr->assign_by_ref('publishedArticles', $publishedArticles);
             $email->setBody($templateMgr->fetch('editor/notifyUsersEmail.tpl'));
             // Stamp the "users notified" date.
             $issue->setDateNotified(Core::getCurrentDate());
             $issueDao->updateIssue($issue);
         }
         $callback = array(&$email, 'send');
         $templateMgr->setProgressFunction($callback);
         unset($callback);
         $email->setFrequency(10);
         // 10 emails per callback
         $callback = array(&$templateMgr, 'updateProgressBar');
         $email->setCallback($callback);
         unset($callback);
         $templateMgr->assign('message', 'editor.notifyUsers.inProgress');
         $templateMgr->display('common/progress.tpl');
         echo '<script type="text/javascript">window.location = "' . Request::url(null, 'editor') . '";</script>';
     } else {
         if (!Request::getUserVar('continued')) {
             $email->assignParams(array('editorialContactSignature' => $user->getContactSignature()));
         }
         $allUsersCount = $roleDao->getJournalUsersCount($journal->getId());
         $issuesIterator =& $issueDao->getIssues($journal->getId());
         $email->displayEditForm(Request::url(null, null, 'notifyUsers'), array(), 'editor/notifyUsers.tpl', array('issues' => $issuesIterator, 'allUsersCount' => $allUsersCount));
     }
 }