/**
  * @covers ValidatorEmail
  * @covers ValidatorRegExp
  */
 public function testValidatorEmail()
 {
     $validator = new ValidatorEmail();
     self::assertTrue($validator->isValid('*****@*****.**'));
     self::assertFalse($validator->isValid('anything else'));
     self::assertEquals('/^[-a-z0-9!#\\$%&\'\\*\\+\\/=\\?\\^_\\`\\{\\|\\}~]+(\\.[-a-z0-9!#\\$%&\'\\*\\+\\/=\\?\\^_\\`\\{\\|\\}~]+)*@(([a-z0-9]([-a-z0-9]*[a-z0-9]+)?){1,63}\\.)+([a-z0-9]([-a-z0-9]*[a-z0-9]+)?){2,63}$/i', ValidatorEmail::getRegexp());
 }
 /**
  * Constructor
  * @param $plugin object
  */
 function PaperPackageUpForm(&$plugin)
 {
     parent::Form($plugin->getTemplatePath() . 'index.tpl');
     $journal =& Request::getJournal();
     import('plugins.generic.paperPackageUp.FormValidatorUpload');
     import('plugins.generic.paperPackageUp.FormValidatorFileType');
     import('plugins.generic.paperPackageUp.FormValidatorHandle');
     import('plugins.generic.paperPackageUp.FormValidatorHandleOrFile');
     $this->addCheck(new FormValidatorPost($this));
     $this->addCheck(new FormValidator($this, 'sectionId', 'required', 'author.submit.form.sectionRequired'));
     $this->addCheck(new FormValidatorUpload($this, 'submissionHandle', 'required', 'plugins.generic.paperPackageUpload.submissionHandleRequired', 'tempFileId'));
     $this->addCheck(new FormValidatorUpload($this, 'supplHandle', 'required', 'plugins.generic.paperPackageUpload.supplHandleRequired', 'tempSupplFileId'));
     $this->addCheck(new FormValidatorHandle($this, 'submissionHandle', 'required', 'plugins.generic.paperPackageUpload.submissionHandleIsWrong'));
     $this->addCheck(new FormValidatorHandle($this, 'supplHandle', 'required', 'plugins.generic.paperPackageUpload.supplHandleIsWrong'));
     $this->addCheck(new FormValidatorHandleOrFile($this, 'submissionHandle', 'required', 'plugins.generic.paperPackageUpload.submissionHandleOrFile', 'tempFileId'));
     $this->addCheck(new FormValidatorHandleOrFile($this, 'supplHandle', 'required', 'plugins.generic.paperPackageUpload.supplHandleOrFile', 'tempSupplFileId'));
     $this->addCheck(new FormValidatorFileType($this, 'tempSupplFileId', 'required', 'plugins.generic.paperPackageUpload.supplUnpackable'));
     $this->addCheck(new FormValidatorCustom($this, 'datePublished', 'required', 'plugins.generic.paperPackageUpload.dateRequired', create_function('$destination, $form', 'return is_int($form->getData(\'datePublished\'));'), array(&$this)));
     $this->addCheck(new FormValidatorCustom($this, 'sectionId', 'required', 'author.submit.form.sectionRequired', array(DAORegistry::getDAO('SectionDAO'), 'sectionExists'), array($journal->getId())));
     $this->addCheck(new FormValidatorCustom($this, 'authors', 'required', 'author.submit.form.authorRequired', create_function('$authors', 'return count($authors) > 0;')));
     //		$this->addCheck(new FormValidatorCustom($this, 'destination', 'required', 'plugins.generic.paperPackageUpload.issueRequired', create_function('$destination, $form', 'return $destination == \'queue\'? true : ($form->getData(\'issueId\') > 0);'), array(&$this)));
     $this->addCheck(new FormValidatorArray($this, 'authors', 'required', 'plugins.generic.paperPackageUpload.authorRequiredFields', array('firstName', 'lastName')));
     //$this->addCheck(new FormValidator($this, 'authors-0-firstName', 'required', 'plugins.generic.paperPackageUpload.authorRequiredFirst'));
     //$this->addCheck(new FormValidator($this, 'authors-0-lastName', 'required', 'plugins.generic.paperPackageUpload.authorRequiredLast'));
     $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.emailRequired', create_function('$email, $regExp', 'return empty($email) ? true : String::regexp_match($regExp, $email);'), array(ValidatorEmail::getRegexp()), false, array('email')));
     $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.urlInvalid', create_function('$url, $regExp', 'return empty($url) ? true : String::regexp_match($regExp, $url);'), array(ValidatorUrl::getRegexp()), false, array('url')));
     $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.form.titleRequired'));
     // 		$this->addCheck(new FormValidatorLocale($this, 'originalJournal', 'required', 'plugins.generic.paperPackageUpload.originalJournalRequired'));
 }
Example #3
0
 /**
  * Constructor.
  */
 function MetadataForm($paper)
 {
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $schedConf =& Request::getSchedConf();
     $user =& Request::getUser();
     $roleId = $roleDao->getRoleIdFromPath(Request::getRequestedPage());
     // If the user is a director of this paper, make the form editable.
     $this->canEdit = false;
     if ($roleId != null && ($roleId == ROLE_ID_DIRECTOR || $roleId == ROLE_ID_TRACK_DIRECTOR)) {
         $this->canEdit = true;
     }
     // Check if the author can modify metadata.
     if ($roleId == ROLE_ID_AUTHOR) {
         if (AuthorAction::mayEditPaper($paper)) {
             $this->canEdit = true;
         }
     }
     if ($this->canEdit) {
         parent::Form('submission/metadata/metadataEdit.tpl');
         $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.form.titleRequired'));
         $this->addCheck(new FormValidatorArray($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', array('firstName', 'lastName')));
         $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', create_function('$email, $regExp', 'return String::regexp_match($regExp, $email);'), array(ValidatorEmail::getRegexp()), false, array('email')));
         $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.urlInvalid', create_function('$url, $regExp', 'return empty($url) ? true : String::regexp_match($regExp, $url);'), array(ValidatorUrl::getRegexp()), false, array('url')));
     } else {
         parent::Form('submission/metadata/metadataView.tpl');
     }
     // If the user is a reviewer of this paper, do not show authors.
     $this->canViewAuthors = true;
     if ($roleId != null && $roleId == ROLE_ID_REVIEWER) {
         $this->canViewAuthors = false;
     }
     $this->paper = $paper;
     $this->addCheck(new FormValidatorPost($this));
 }
Example #4
0
 /**
  * Constructor.
  */
 function MetadataForm($article, $journal)
 {
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     $user =& Request::getUser();
     $roleId = $roleDao->getRoleIdFromPath(Request::getRequestedPage());
     // If the user is an editor of this article, make the entire form editable.
     $this->canEdit = false;
     $this->isEditor = false;
     if ($roleId != null && ($roleId == ROLE_ID_EDITOR || $roleId == ROLE_ID_SECTION_EDITOR)) {
         $this->canEdit = true;
         $this->isEditor = true;
     }
     $copyeditInitialSignoff = $signoffDao->getBySymbolic('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $article->getId());
     // If the user is an author and the article hasn't passed the Copyediting stage, make the form editable.
     if ($roleId == ROLE_ID_AUTHOR) {
         if ($article->getStatus() != STATUS_PUBLISHED && ($copyeditInitialSignoff == null || $copyeditInitialSignoff->getDateCompleted() == null)) {
             $this->canEdit = true;
         }
     }
     // Copy editors are also allowed to edit metadata, but only if they have
     // a current assignment to the article.
     if ($roleId != null && $roleId == ROLE_ID_COPYEDITOR) {
         $copyeditFinalSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $article->getId());
         if ($copyeditFinalSignoff != null && $article->getStatus() != STATUS_PUBLISHED) {
             if ($copyeditInitialSignoff->getDateNotified() != null && $copyeditFinalSignoff->getDateCompleted() == null) {
                 $this->canEdit = true;
             }
         }
     }
     if ($this->canEdit) {
         $supportedSubmissionLocales = $journal->getSetting('supportedSubmissionLocales');
         if (empty($supportedSubmissionLocales)) {
             $supportedSubmissionLocales = array($journal->getPrimaryLocale());
         }
         parent::Form('submission/metadata/metadataEdit.tpl', true, $article->getLocale(), array_flip(array_intersect(array_flip(AppLocale::getAllLocales()), $supportedSubmissionLocales)));
         $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.form.titleRequired', $this->getRequiredLocale()));
         $this->addCheck(new FormValidatorArray($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', array('firstName', 'lastName')));
         $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', create_function('$email, $regExp', 'return String::regexp_match($regExp, $email);'), array(ValidatorEmail::getRegexp()), false, array('email')));
         $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.urlInvalid', create_function('$url, $regExp', 'return empty($url) ? true : String::regexp_match($regExp, $url);'), array(ValidatorUrl::getRegexp()), false, array('url')));
         // Add ORCiD validation
         import('lib.pkp.classes.validation.ValidatorORCID');
         $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.orcidInvalid', create_function('$orcid', '$validator = new ValidatorORCID(); return empty($orcid) ? true : $validator->isValid($orcid);'), array(), false, array('orcid')));
     } else {
         parent::Form('submission/metadata/metadataView.tpl');
     }
     // If the user is a reviewer of this article, do not show authors.
     $this->canViewAuthors = true;
     if ($roleId != null && $roleId == ROLE_ID_REVIEWER) {
         $this->canViewAuthors = false;
     }
     $this->article = $article;
     $this->addCheck(new FormValidatorPost($this));
 }
 protected function doClean($value)
 {
     $clean = parent::doClean($value);
     $existing_signing = Doctrine_Core::getTable('PetitionSigning')->createQuery('s')->where('s.petition_id = ?', $this->getOption('petition_id'))->andWhere('LOWER(s.email) = LOWER(?)', $clean)->limit(1)->fetchOne();
     if ($existing_signing && !$this->getOption(self::OPTION_IS_GEO)) {
         /* @var $existing_signing PetitionSigning */
         if ($this->getOption(self::OPTION_IGNORE_PENDING) && $existing_signing->getStatus() == PetitionSigning::STATUS_PENDING) {
             return $clean;
         }
         throw new sfValidatorError($this, 'old');
     }
     return $clean;
 }
 /**
  * Constructor
  * @param $plugin object
  */
 function QuickSubmitForm(&$plugin)
 {
     parent::Form($plugin->getTemplatePath() . 'index.tpl');
     $journal =& Request::getJournal();
     $this->addCheck(new FormValidatorPost($this));
     $this->addCheck(new FormValidator($this, 'sectionId', 'required', 'author.submit.form.sectionRequired'));
     $this->addCheck(new FormValidatorCustom($this, 'tempFileId', 'required', 'plugins.importexport.quickSubmit.submissionRequired', create_function('$tempFileId', 'return $tempFileId > 0;')));
     $this->addCheck(new FormValidatorCustom($this, 'sectionId', 'required', 'author.submit.form.sectionRequired', array(DAORegistry::getDAO('SectionDAO'), 'sectionExists'), array($journal->getId())));
     $this->addCheck(new FormValidatorCustom($this, 'authors', 'required', 'author.submit.form.authorRequired', create_function('$authors', 'return count($authors) > 0;')));
     $this->addCheck(new FormValidatorCustom($this, 'destination', 'required', 'plugins.importexport.quickSubmit.issueRequired', create_function('$destination, $form', 'return $destination == \'queue\'? true : ($form->getData(\'issueId\') > 0);'), array(&$this)));
     $this->addCheck(new FormValidatorArray($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', array('firstName', 'lastName')));
     $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.emailRequired', create_function('$email, $regExp', 'return String::regexp_match($regExp, $email);'), array(ValidatorEmail::getRegexp()), false, array('email')));
     $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.urlInvalid', create_function('$url, $regExp', 'return empty($url) ? true : String::regexp_match($regExp, $url);'), array(ValidatorUrl::getRegexp()), false, array('url')));
     $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.form.titleRequired'));
 }
 /**
  * Constructor.
  */
 function AuthorSubmitStep3Form(&$article, &$journal)
 {
     parent::AuthorSubmitForm($article, 3, $journal);
     // Validation checks for this form
     $this->addCheck(new FormValidatorCustom($this, 'authors', 'required', 'author.submit.form.authorRequired', create_function('$authors', 'return count($authors) > 0;')));
     $this->addCheck(new FormValidatorArray($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', array('firstName', 'lastName')));
     $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', create_function('$email, $regExp', 'return String::regexp_match($regExp, $email);'), array(ValidatorEmail::getRegexp()), false, array('email')));
     $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.urlInvalid', create_function('$url, $regExp', 'return empty($url) ? true : String::regexp_match($regExp, $url);'), array(ValidatorUrl::getRegexp()), false, array('url')));
     $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.form.titleRequired', $this->getRequiredLocale()));
     $sectionDao =& DAORegistry::getDAO('SectionDAO');
     $section = $sectionDao->getSection($article->getSectionId());
     $abstractWordCount = $section->getAbstractWordCount();
     if (isset($abstractWordCount) && $abstractWordCount > 0) {
         $this->addCheck(new FormValidatorCustom($this, 'abstract', 'required', 'author.submit.form.wordCountAlert', create_function('$abstract, $wordCount', 'foreach ($abstract as $localizedAbstract) {return count(explode(" ",$localizedAbstract)) < $wordCount; }'), array($abstractWordCount)));
     }
 }
Example #8
0
 /**
  * Constructor.
  */
 function AuthorSubmitStep3Form($paper)
 {
     parent::AuthorSubmitForm($paper, 3);
     // Validation checks for this form
     $this->addCheck(new FormValidatorCustom($this, 'authors', 'required', 'author.submit.form.authorRequired', create_function('$authors', 'return count($authors) > 0;')));
     $this->addCheck(new FormValidatorArray($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', array('firstName', 'lastName')));
     $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', create_function('$email, $regExp', 'return String::regexp_match($regExp, $email);'), array(ValidatorEmail::getRegexp()), false, array('email')));
     $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.urlInvalid', create_function('$url, $regExp', 'return empty($url) ? true : String::regexp_match($regExp, $url);'), array(ValidatorUrl::getRegexp()), false, array('url')));
     $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.form.titleRequired'));
     $schedConf =& Request::getSchedConf();
     $reviewMode = $paper->getReviewMode();
     if ($reviewMode != REVIEW_MODE_PRESENTATIONS_ALONE) {
         $this->addCheck(new FormValidatorLocale($this, 'abstract', 'required', 'author.submit.form.abstractRequired'));
         $trackDao =& DAORegistry::getDAO('TrackDAO');
         $track = $trackDao->getTrack($paper->getTrackId());
         $abstractWordCount = $track->getAbstractWordCount();
         if (isset($abstractWordCount) && $abstractWordCount > 0) {
             $this->addCheck(new FormValidatorCustom($this, 'abstract', 'required', 'author.submit.form.wordCountAlert', create_function('$abstract, $wordCount', 'foreach ($abstract as $localizedAbstract) {return count(explode(" ",strip_tags($localizedAbstract))) < $wordCount; }'), array($abstractWordCount)));
         }
     }
 }
 /**
  * Constructor
  * @param $plugin object
  */
 function QuickSubmitForm(&$plugin, $request)
 {
     parent::Form($plugin->getTemplatePath() . 'index.tpl');
     $this->request =& $request;
     $journal =& $request->getJournal();
     $this->addCheck(new FormValidatorPost($this));
     $this->addCheck(new FormValidator($this, 'sectionId', 'required', 'author.submit.form.sectionRequired'));
     $this->addCheck(new FormValidatorCustom($this, 'tempFileId', 'required', 'plugins.importexport.quickSubmit.submissionRequired', create_function('$tempFileId', 'return $tempFileId > 0;')));
     $this->addCheck(new FormValidatorCustom($this, 'sectionId', 'required', 'author.submit.form.sectionRequired', array(DAORegistry::getDAO('SectionDAO'), 'sectionExists'), array($journal->getId())));
     $this->addCheck(new FormValidatorCustom($this, 'authors', 'required', 'author.submit.form.authorRequired', create_function('$authors', 'return count($authors) > 0;')));
     $this->addCheck(new FormValidatorCustom($this, 'destination', 'required', 'plugins.importexport.quickSubmit.issueRequired', create_function('$destination, $form', 'return $destination == \'queue\'? true : ($form->getData(\'issueId\') > 0);'), array(&$this)));
     $this->addCheck(new FormValidatorArray($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', array('firstName', 'lastName')));
     $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.emailRequired', create_function('$email, $regExp', 'return String::regexp_match($regExp, $email);'), array(ValidatorEmail::getRegexp()), false, array('email')));
     $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.urlInvalid', create_function('$url, $regExp', 'return empty($url) ? true : String::regexp_match($regExp, $url);'), array(ValidatorUrl::getRegexp()), false, array('url')));
     // Add ORCiD validation
     import('lib.pkp.classes.validation.ValidatorORCID');
     $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.orcidInvalid', create_function('$orcid', '$validator = new ValidatorORCID(); return empty($orcid) ? true : $validator->isValid($orcid);'), array(), false, array('orcid')));
     $supportedSubmissionLocales = $journal->getSetting('supportedSubmissionLocales');
     if (!is_array($supportedSubmissionLocales) || count($supportedSubmissionLocales) < 1) {
         $supportedSubmissionLocales = array($journal->getPrimaryLocale());
     }
     $this->addCheck(new FormValidatorInSet($this, 'locale', 'required', 'author.submit.form.localeRequired', $supportedSubmissionLocales));
 }
Example #10
0
 /**
  * Constructor.
  */
 function ValidatorEmail()
 {
     parent::ValidatorRegExp(ValidatorEmail::getRegexp());
 }
Example #11
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;
         }
         import('lib.pkp.classes.validation.ValidatorEmail');
         while (!$recipients->eof()) {
             $recipient =& $recipients->next();
             if (preg_match(ValidatorEmail::getRegexp(), $recipient->getEmail())) {
                 $email->addRecipient($recipient->getEmail(), $recipient->getFullName());
             } else {
                 error_log("Invalid email address: " . $recipient->getEmail());
             }
             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)));
     }
 }
 /**
  * Constructor.
  */
 function __construct()
 {
     parent::__construct(ValidatorEmail::getRegexp());
 }
 /**
  * Allows editors to write emails to users associated with the journal.
  * @param $args array
  * @param $request PKPRequest
  */
 function notifyUsers($args, $request)
 {
     $this->validate((int) $request->getUserVar('issue'));
     $issue =& $this->issue;
     $this->setupTemplate(EDITOR_SECTION_ISSUES);
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $authorDao =& DAORegistry::getDAO('AuthorDAO');
     $individualSubscriptionDao =& DAORegistry::getDAO('IndividualSubscriptionDAO');
     $institutionalSubscriptionDao =& DAORegistry::getDAO('InstitutionalSubscriptionDAO');
     $notificationMailListDao =& DAORegistry::getDAO('NotificationMailListDAO');
     /* @var $notificationMailListDao NotificationMailListDAO */
     $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()) {
         if ($request->getUserVar('ccSelf')) {
             $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':
                 $recipients =& $roleDao->getUsersByRoleId(ROLE_ID_READER, $journal->getId());
                 break;
             default:
                 $recipients = null;
         }
         import('lib.pkp.classes.validation.ValidatorEmail');
         while ($recipients && !$recipients->eof()) {
             $recipient =& $recipients->next();
             if (preg_match(ValidatorEmail::getRegexp(), $recipient->getEmail())) {
                 $email->addRecipient($recipient->getEmail(), $recipient->getFullName());
             } else {
                 error_log("Invalid email address: " . $recipient->getEmail());
             }
             unset($recipient);
         }
         if ($request->getUserVar('sendToMailList')) {
             $mailList = $notificationMailListDao->getMailList($journal->getId());
             foreach ($mailList as $mailListRecipient) {
                 $email->addRecipient($mailListRecipient);
             }
         }
         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()), 'allMailListCount' => count($notificationMailListDao->getMailList($journal->getId()))));
     }
 }