/** * Assign parameters to template * @param $paramArray array */ function assignParams($paramArray = array()) { $submission = $this->submission; $application = PKPApplication::getApplication(); $request = $application->getRequest(); parent::assignParams(array_merge(array('submissionTitle' => strip_tags($submission->getLocalizedTitle()), 'submissionId' => $submission->getId(), 'submissionAbstract' => PKPString::html2text($submission->getLocalizedAbstract()), 'authorString' => strip_tags($submission->getAuthorString())), $paramArray)); }
function sendNotification($users, $journal, $issue) { if ($users->getCount() != 0) { import('lib.pkp.classes.mail.MailTemplate'); $email = new MailTemplate('OPEN_ACCESS_NOTIFY', $journal->getPrimaryLocale()); $email->setSubject($email->getSubject($journal->getPrimaryLocale())); $email->setReplyTo(null); $email->addRecipient($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $paramArray = array('journalName' => $journal->getLocalizedName(), 'journalUrl' => Request::url($journal->getPath()), 'editorialContactSignature' => $journal->getSetting('contactName') . "\n" . $journal->getLocalizedName()); $email->assignParams($paramArray); $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticles = $publishedArticleDao->getPublishedArticlesInSections($issue->getId()); $mimeBoundary = '==boundary_' . md5(microtime()); $templateMgr = TemplateManager::getManager(); $templateMgr->assign('body', $email->getBody($journal->getPrimaryLocale())); $templateMgr->assign('templateSignature', $journal->getSetting('emailSignature')); $templateMgr->assign('mimeBoundary', $mimeBoundary); $templateMgr->assign('issue', $issue); $templateMgr->assign('publishedArticles', $publishedArticles); $email->addHeader('MIME-Version', '1.0'); $email->setContentType('multipart/alternative; boundary="' . $mimeBoundary . '"'); $email->setBody($templateMgr->fetch('subscription/openAccessNotifyEmail.tpl')); while ($user = $users->next()) { $email->addBcc($user->getEmail(), $user->getFullName()); } $email->send(); } }
function sendReminder($subscription, $journal, $emailKey) { $userDao = DAORegistry::getDAO('UserDAO'); $subscriptionTypeDao = DAORegistry::getDAO('SubscriptionTypeDAO'); $journalName = $journal->getLocalizedName(); $user = $userDao->getById($subscription->getUserId()); if (!isset($user)) { return false; } $subscriptionType = $subscriptionTypeDao->getSubscriptionType($subscription->getTypeId()); $subscriptionName = $journal->getSetting('subscriptionName'); $subscriptionEmail = $journal->getSetting('subscriptionEmail'); $subscriptionPhone = $journal->getSetting('subscriptionPhone'); $subscriptionMailingAddress = $journal->getSetting('subscriptionMailingAddress'); $subscriptionContactSignature = $subscriptionName; AppLocale::requireComponents(LOCALE_COMPONENT_PKP_USER, LOCALE_COMPONENT_APP_COMMON); if ($subscriptionMailingAddress != '') { $subscriptionContactSignature .= "\n" . $subscriptionMailingAddress; } if ($subscriptionPhone != '') { $subscriptionContactSignature .= "\n" . AppLocale::Translate('user.phone') . ': ' . $subscriptionPhone; } $subscriptionContactSignature .= "\n" . AppLocale::Translate('user.email') . ': ' . $subscriptionEmail; $paramArray = array('subscriberName' => $user->getFullName(), 'journalName' => $journalName, 'subscriptionType' => $subscriptionType->getSummaryString(), 'expiryDate' => $subscription->getDateEnd(), 'username' => $user->getUsername(), 'subscriptionContactSignature' => $subscriptionContactSignature); import('lib.pkp.classes.mail.MailTemplate'); $mail = new MailTemplate($emailKey, $journal->getPrimaryLocale(), $journal, false); $mail->setReplyTo($subscriptionEmail, $subscriptionName); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->setSubject($mail->getSubject($journal->getPrimaryLocale())); $mail->setBody($mail->getBody($journal->getPrimaryLocale())); $mail->assignParams($paramArray); $mail->send(); }
function assignParams($paramArray = array()) { $submission = $this->submission; $application = PKPApplication::getApplication(); $request = $application->getRequest(); $paramArray['submissionTitle'] = strip_tags($submission->getLocalizedTitle()); $paramArray['submissionId'] = $submission->getId(); $paramArray['submissionAbstract'] = String::html2text($submission->getLocalizedAbstract()); $paramArray['authorString'] = strip_tags($submission->getAuthorString()); parent::assignParams($paramArray); }
function assignParams($paramArray = array()) { $article =& $this->article; $journal = isset($this->journal) ? $this->journal : Request::getJournal(); $paramArray['articleTitle'] = strip_tags($article->getArticleTitle()); $paramArray['articleId'] = $article->getArticleId(); $paramArray['journalName'] = strip_tags($journal->getJournalTitle()); $paramArray['sectionName'] = strip_tags($article->getSectionTitle()); $paramArray['articleAbstract'] = strip_tags($article->getArticleAbstract()); $paramArray['authorString'] = strip_tags($article->getAuthorString()); parent::assignParams($paramArray); }
function assignParams($paramArray = array()) { $monograph =& $this->monograph; $press = isset($this->press) ? $this->press : Request::getPress(); $paramArray['monographTitle'] = strip_tags($monograph->getLocalizedTitle()); $paramArray['monographId'] = $monograph->getId(); $paramArray['pressName'] = strip_tags($press->getLocalizedName()); $paramArray['seriesName'] = strip_tags($monograph->getSeriesTitle()); $paramArray['monographAbstract'] = String::html2text($monograph->getLocalizedAbstract()); $paramArray['authorString'] = strip_tags($monograph->getAuthorString()); parent::assignParams($paramArray); }
function assignParams($paramArray = array()) { $article =& $this->article; $journal = isset($this->journal) ? $this->journal : Request::getJournal(); $sectionDao =& DAORegistry::getDAO('SectionDAO'); $section =& $sectionDao->getSection($this->sectionDecision->getSectionId()); $paramArray['articleTitle'] = strip_tags($article->getScientificTitle()); $paramArray['articleId'] = $article->getProposalId(); $paramArray['journalName'] = strip_tags($journal->getLocalizedTitle()); $paramArray['sectionName'] = strip_tags($section->getLocalizedTitle()); parent::assignParams($paramArray); }
/** * Send email to a book for review author */ function sendReminder($book, $journal, $emailKey) { $journalId = $journal->getId(); $paramArray = array('authorName' => strip_tags($book->getUserFullName()), 'bookForReviewTitle' => '"' . strip_tags($book->getLocalizedTitle()) . '"', 'bookForReviewDueDate' => date('l, F j, Y', strtotime($book->getDateDue())), 'submissionUrl' => Request::url(null, 'author', 'submit'), 'editorialContactSignature' => strip_tags($book->getEditorContactSignature())); import('classes.mail.MailTemplate'); $mail = new MailTemplate($emailKey); $mail->setReplyTo($book->getEditorEmail(), $book->getEditorFullName()); $mail->addRecipient($book->getUserEmail(), $book->getUserFullName()); $mail->setSubject($mail->getSubject($journal->getPrimaryLocale())); $mail->setBody($mail->getBody($journal->getPrimaryLocale())); $mail->assignParams($paramArray); $mail->send(); }
function assignParams($paramArray = array()) { $paper =& $this->paper; $conference = isset($this->conference) ? $this->conference : Request::getConference(); $schedConf = isset($this->schedConf) ? $this->schedConf : Request::getSchedConf(); $paramArray['paperTitle'] = strip_tags($paper->getLocalizedTitle()); $paramArray['conferenceName'] = strip_tags($conference->getConferenceTitle()); $paramArray['schedConfName'] = strip_tags($schedConf->getSchedConfTitle()); $paramArray['trackName'] = strip_tags($paper->getTrackTitle()); $paramArray['paperAbstract'] = strip_tags($paper->getLocalizedAbstract()); $paramArray['authorString'] = strip_tags($paper->getAuthorString()); parent::assignParams($paramArray); }
/** * Send the email * @param $args array * @param $request PKPRequest */ function execute($args, $request) { $userDao = DAORegistry::getDAO('UserDAO'); $toUser = $userDao->getById($this->userId); $fromUser = $request->getUser(); import('lib.pkp.classes.mail.MailTemplate'); $email = new MailTemplate(); $email->addRecipient($toUser->getEmail(), $toUser->getFullName()); $email->setReplyTo($fromUser->getEmail(), $fromUser->getFullName()); $email->setSubject($this->getData('subject')); $email->setBody($this->getData('message')); $email->assignParams(); $email->send(); }
function assignParams($paramArray = array()) { $paper =& $this->paper; $conference = isset($this->conference) ? $this->conference : Request::getConference(); $schedConf = isset($this->schedConf) ? $this->schedConf : Request::getSchedConf(); $paramArray['paperTitle'] = strip_tags($paper->getLocalizedTitle()); $paramArray['conferenceName'] = strip_tags($conference->getConferenceTitle()); $paramArray['conferenceName'] = preg_replace('/\\s+/', '', $paramArray['conferenceName']); $paramArray['schedConfName'] = strip_tags($schedConf->getSchedConfTitle()); $paramArray['trackName'] = strip_tags($paper->getTrackTitle()); $paramArray['paperAbstract'] = strip_tags($paper->getLocalizedAbstract()); if ($paramArray['paperAbstract'] === "") { $paramArray['paperAbstract'] = __("common.noData"); } $paramArray['authorString'] = strip_tags($paper->getAuthorString()); parent::assignParams($paramArray); }
function assignParams($paramArray = array()) { $article =& $this->article; $journal = isset($this->journal) ? $this->journal : Request::getJournal(); $sectionDao =& DAORegistry::getDAO('SectionDAO'); $section =& $sectionDao->getSection($this->sectionDecision->getSectionId()); $abstract =& $article->getLocalizedAbstract(); $paramArray['articleTitle'] = strip_tags($abstract->getScientificTitle()); $paramArray['articleId'] = $article->getProposalId(); $paramArray['journalName'] = strip_tags($journal->getLocalizedTitle()); $paramArray['sectionName'] = strip_tags($section->getLocalizedTitle()); $paramArray['articleBackground'] = String::html2text($abstract->getBackground()); $paramArray['articleObjectives'] = String::html2text($abstract->getObjectives()); $paramArray['articleStudyMethods'] = String::html2text($abstract->getStudyMethods()); $paramArray['articleExpectedOutcomes'] = String::html2text($abstract->getExpectedOutcomes()); $paramArray['authorString'] = strip_tags($article->getAuthorString()); parent::assignParams($paramArray); }
/** * Send email to object for review author * @param $ofrAssignment ObjectForReviewAssignment * @param $journal Journal * @param $emailKey string */ function sendReminder($ofrAssignment, $journal, $emailKey) { $journalId = $journal->getId(); $author =& $ofrAssignment->getUser(); $objectForReview =& $ofrAssignment->getObjectForReview(); $editor =& $objectForReview->getEditor(); $paramArray = array('authorName' => strip_tags($author->getFullName()), 'objectForReviewTitle' => '"' . strip_tags($objectForReview->getTitle()) . '"', 'objectForReviewDueDate' => date('l, F j, Y', strtotime($ofrAssignment->getDateDue())), 'submissionUrl' => Request::url($journal->getPath(), 'author', 'submit'), 'editorialContactSignature' => strip_tags($editor->getContactSignature())); import('classes.mail.MailTemplate'); $mail = new MailTemplate($emailKey); $mail->setReplyTo($editor->getEmail(), $editor->getFullName()); $mail->addRecipient($author->getEmail(), $author->getFullName()); $mail->setSubject($mail->getSubject($journal->getPrimaryLocale())); $mail->setBody($mail->getBody($journal->getPrimaryLocale())); $mail->assignParams($paramArray); $mail->send(); $ofrAssignment->setDateReminded(Core::getCurrentDate()); $ofrAssignmentDao =& DAORegistry::getDAO('ObjectForReviewAssignmentDAO'); $ofrAssignmentDao->updateObject($ofrAssignment); }
/** * Send an email to a user or group of users. */ function email($args) { $this->validate(); $this->setupTemplate(true); $conference =& Request::getConference(); $schedConf =& Request::getSchedConf(); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('helpTopicId', 'conference.users.emailUsers'); $userDao =& DAORegistry::getDAO('UserDAO'); $site =& Request::getSite(); $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, 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, ASSOC_TYPE_SCHED_CONF, $schedConf->getId()); if ($group) { $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, null, 'email'), array(), 'manager/people/email.tpl'); } }
function sendReminder($registration, $conference, $schedConf, $emailKey) { $userDao =& DAORegistry::getDAO('UserDAO'); $registrationTypeDao =& DAORegistry::getDAO('RegistrationTypeDAO'); $schedConfName = $schedConf->getSchedConfTitle(); $schedConfId = $schedConf->getId(); $user =& $userDao->getUser($registration->getUserId()); if (!isset($user)) { return false; } $registrationType =& $registrationTypeDao->getRegistrationType($registration->getTypeId()); $registrationName = $schedConf->getSetting('registrationName'); $registrationEmail = $schedConf->getSetting('registrationEmail'); $registrationPhone = $schedConf->getSetting('registrationPhone'); $registrationFax = $schedConf->getSetting('registrationFax'); $registrationMailingAddress = $schedConf->getSetting('registrationMailingAddress'); $registrationContactSignature = $registrationName; if ($registrationMailingAddress != '') { $registrationContactSignature .= "\n" . $registrationMailingAddress; } if ($registrationPhone != '') { $registrationContactSignature .= "\n" . AppLocale::Translate('user.phone') . ': ' . $registrationPhone; } if ($registrationFax != '') { $registrationContactSignature .= "\n" . AppLocale::Translate('user.fax') . ': ' . $registrationFax; } $registrationContactSignature .= "\n" . AppLocale::Translate('user.email') . ': ' . $registrationEmail; $paramArray = array('registrantName' => $user->getFullName(), 'conferenceName' => $conferenceName, 'schedConfName' => $schedConfName, 'registrationType' => $registrationType->getSummaryString(), 'expiryDate' => $registration->getDateEnd(), 'username' => $user->getUsername(), 'registrationContactSignature' => $registrationContactSignature); import('mail.MailTemplate'); $mail = new MailTemplate($emailKey, $conference->getPrimaryLocale()); $mail->setFrom($registrationEmail, $registrationName); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->setSubject($mail->getSubject($conference->getPrimaryLocale())); $mail->setBody($mail->getBody($conference->getPrimaryLocale())); $mail->assignParams($paramArray); $mail->send(); }
/** * Create or update a user. * @param $args array * @param $request PKPRequest */ function &execute($args, $request) { parent::execute($request); $userDao = DAORegistry::getDAO('UserDAO'); $context = $request->getContext(); if (isset($this->userId)) { $userId = $this->userId; $user = $userDao->getById($userId); } if (!isset($user)) { $user = $userDao->newDataObject(); $user->setInlineHelp(1); // default new users to having inline help visible } $user->setSalutation($this->getData('salutation')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setLastName($this->getData('lastName')); $user->setSuffix($this->getData('suffix')); $user->setInitials($this->getData('initials')); $user->setGender($this->getData('gender')); $user->setAffiliation($this->getData('affiliation'), null); // Localized $user->setSignature($this->getData('signature'), null); // Localized $user->setEmail($this->getData('email')); $user->setUrl($this->getData('userUrl')); $user->setPhone($this->getData('phone')); $user->setOrcid($this->getData('orcid')); $user->setMailingAddress($this->getData('mailingAddress')); $user->setCountry($this->getData('country')); $user->setBiography($this->getData('biography'), null); // Localized $user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0); $user->setAuthId((int) $this->getData('authId')); $site = $request->getSite(); $availableLocales = $site->getSupportedLocales(); $locales = array(); foreach ($this->getData('userLocales') as $locale) { if (AppLocale::isLocaleValid($locale) && in_array($locale, $availableLocales)) { array_push($locales, $locale); } } $user->setLocales($locales); if ($user->getAuthId()) { $authDao = DAORegistry::getDAO('AuthSourceDAO'); $auth =& $authDao->getPlugin($user->getAuthId()); } if ($user->getId() != null) { if ($this->getData('password') !== '') { if (isset($auth)) { $auth->doSetUserPassword($user->getUsername(), $this->getData('password')); $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword())); // Used for PW reset hash only } else { $user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password'))); } } if (isset($auth)) { // FIXME Should try to create user here too? $auth->doSetUserInfo($user); } $userDao->updateObject($user); } else { $user->setUsername($this->getData('username')); if ($this->getData('generatePassword')) { $password = Validation::generatePassword(); $sendNotify = true; } else { $password = $this->getData('password'); $sendNotify = $this->getData('sendNotify'); } if (isset($auth)) { $user->setPassword($password); // FIXME Check result and handle failures $auth->doCreateUser($user); $user->setAuthId($auth->authId); $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword())); // Used for PW reset hash only } else { $user->setPassword(Validation::encryptCredentials($this->getData('username'), $password)); } $user->setDateRegistered(Core::getCurrentDate()); $userId = $userDao->insertObject($user); if ($sendNotify) { // Send welcome email to user import('lib.pkp.classes.mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTER'); $mail->setReplyTo($context->getSetting('contactEmail'), $context->getSetting('contactName')); $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName())); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } } import('lib.pkp.classes.user.InterestManager'); $interestManager = new InterestManager(); $interestManager->setInterestsForUser($user, $this->getData('interests')); return $user; }
/** * 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); }
/** * Internal function to prepare notification email */ function &_prepareNotificationEmail($mailTemplateKey) { $userDao =& DAORegistry::getDAO('UserDAO'); $subscriptionTypeDao =& DAORegistry::getDAO('SubscriptionTypeDAO'); $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO'); $journal =& Request::getJournal(); $journalName = $journal->getLocalizedTitle(); $journalId = $journal->getId(); $user =& $userDao->getUser($this->subscription->getUserId()); $subscriptionType =& $subscriptionTypeDao->getSubscriptionType($this->subscription->getTypeId()); $subscriptionName = $journalSettingsDao->getSetting($journalId, 'subscriptionName'); $subscriptionEmail = $journalSettingsDao->getSetting($journalId, 'subscriptionEmail'); $subscriptionPhone = $journalSettingsDao->getSetting($journalId, 'subscriptionPhone'); $subscriptionFax = $journalSettingsDao->getSetting($journalId, 'subscriptionFax'); $subscriptionMailingAddress = $journalSettingsDao->getSetting($journalId, 'subscriptionMailingAddress'); $subscriptionContactSignature = $subscriptionName; if ($subscriptionMailingAddress != '') { $subscriptionContactSignature .= "\n" . $subscriptionMailingAddress; } if ($subscriptionPhone != '') { $subscriptionContactSignature .= "\n" . Locale::translate('user.phone') . ': ' . $subscriptionPhone; } if ($subscriptionFax != '') { $subscriptionContactSignature .= "\n" . Locale::translate('user.fax') . ': ' . $subscriptionFax; } $subscriptionContactSignature .= "\n" . Locale::translate('user.email') . ': ' . $subscriptionEmail; $paramArray = array('subscriberName' => $user->getFullName(), 'journalName' => $journalName, 'subscriptionType' => $subscriptionType->getSummaryString(), 'username' => $user->getUsername(), 'subscriptionContactSignature' => $subscriptionContactSignature); import('classes.mail.MailTemplate'); $mail = new MailTemplate($mailTemplateKey); $mail->setFrom($subscriptionEmail, $subscriptionName); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->setSubject($mail->getSubject($journal->getPrimaryLocale())); $mail->setBody($mail->getBody($journal->getPrimaryLocale())); $mail->assignParams($paramArray); return $mail; }
/** * Save thesis. */ function execute() { $thesisPlugin =& PluginRegistry::getPlugin('generic', $this->parentPluginName); $thesisPlugin->import('Thesis'); $thesisDao =& DAORegistry::getDAO('ThesisDAO'); $journal =& Request::getJournal(); $journalId = $journal->getId(); $thesis = new Thesis(); $thesis->setJournalId($journalId); $thesis->setStatus(THESIS_STATUS_INACTIVE); $thesis->setDegree($this->getData('degree')); $thesis->setDegreeName($this->getData('degreeName')); $thesis->setDepartment($this->getData('department')); $thesis->setUniversity($this->getData('university')); $thesis->setTitle($this->getData('title')); $thesis->setDateApproved($this->getData('dateApprovedYear') . '-' . $this->getData('dateApprovedMonth') . '-' . $this->getData('dateApprovedDay')); $thesis->setUrl(strtolower($this->getData('url'))); $thesis->setAbstract($this->getData('abstract')); $thesis->setComment($this->getData('comment')); $thesis->setStudentFirstName($this->getData('studentFirstName')); $thesis->setStudentMiddleName($this->getData('studentMiddleName')); $thesis->setStudentLastName($this->getData('studentLastName')); $thesis->setStudentEmail($this->getData('studentEmail')); $thesis->setStudentEmailPublish($this->getData('studentEmailPublish') == null ? 0 : 1); $thesis->setStudentBio($this->getData('studentBio')); $thesis->setSupervisorFirstName($this->getData('supervisorFirstName')); $thesis->setSupervisorMiddleName($this->getData('supervisorMiddleName')); $thesis->setSupervisorLastName($this->getData('supervisorLastName')); $thesis->setSupervisorEmail($this->getData('supervisorEmail')); $thesis->setDiscipline($this->getData('discipline')); $thesis->setSubjectClass($this->getData('subjectClass')); $thesis->setSubject($this->getData('keyword')); $thesis->setCoverageGeo($this->getData('coverageGeo')); $thesis->setCoverageChron($this->getData('coverageChron')); $thesis->setCoverageSample($this->getData('coverageSample')); $thesis->setMethod($this->getData('method')); $thesis->setLanguage($this->getData('language')); $thesis->setDateSubmitted(Core::getCurrentDate()); $thesisDao->insertThesis($thesis); // Send supervisor confirmation email if (!empty($this->uploadCodeEnabled)) { $uploadCode = $thesisPlugin->getSetting($journalId, 'uploadCode'); $submittedUploadCode = $this->getData('uploadCode'); } if (empty($uploadCode) || $uploadCode != $submittedUploadCode) { $journalName = $journal->getLocalizedTitle(); $thesisName = $thesisPlugin->getSetting($journalId, 'thesisName'); $thesisEmail = $thesisPlugin->getSetting($journalId, 'thesisEmail'); $thesisPhone = $thesisPlugin->getSetting($journalId, 'thesisPhone'); $thesisFax = $thesisPlugin->getSetting($journalId, 'thesisFax'); $thesisMailingAddress = $thesisPlugin->getSetting($journalId, 'thesisMailingAddress'); $thesisContactSignature = $thesisName; if (!empty($thesisMailingAddress)) { $thesisContactSignature .= "\n" . $thesisMailingAddress; } if (!empty($thesisPhone)) { $thesisContactSignature .= "\n" . Locale::Translate('user.phone') . ': ' . $thesisPhone; } if (!empty($thesisFax)) { $thesisContactSignature .= "\n" . Locale::Translate('user.fax') . ': ' . $thesisFax; } $thesisContactSignature .= "\n" . Locale::Translate('user.email') . ': ' . $thesisEmail; $studentName = $thesis->getStudentFirstName() . ' ' . $thesis->getStudentLastName(); $supervisorName = $thesis->getSupervisorFirstName() . ' ' . $thesis->getSupervisorLastName(); $paramArray = array('journalName' => $journalName, 'thesisName' => $thesisName, 'thesisEmail' => $thesisEmail, 'title' => $thesis->getTitle(), 'studentName' => $studentName, 'degree' => Locale::Translate($thesis->getDegreeString()), 'degreeName' => $thesis->getDegreeName(), 'department' => $thesis->getDepartment(), 'university' => $thesis->getUniversity(), 'dateApproved' => $thesis->getDateApproved(), 'supervisorName' => $supervisorName, 'abstract' => $thesis->getAbstract(), 'thesisContactSignature' => $thesisContactSignature); import('classes.mail.MailTemplate'); $mail = new MailTemplate('THESIS_ABSTRACT_CONFIRM'); $mail->setFrom($thesisEmail, "\"" . $thesisName . "\""); $mail->assignParams($paramArray); $mail->addRecipient($thesis->getSupervisorEmail(), "\"" . $supervisorName . "\""); $mail->addCc($thesis->getStudentEmail(), "\"" . $studentName . "\""); $mail->send(); } }
/** * Register a new user. * @return $userId int */ function execute() { $userDao =& DAORegistry::getDAO('UserDAO'); $user = new User(); $user->setSalutation($this->getData('salutation')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setLastName($this->getData('lastName')); $user->setGender($this->getData('gender')); $user->setInitials($this->getData('initials')); $user->setAffiliation($this->getData('affiliation')); $user->setEmail($this->getData('email')); $user->setUrl($this->getData('userUrl')); $user->setPhone($this->getData('phone')); $user->setFax($this->getData('fax')); $user->setMailingAddress($this->getData('mailingAddress')); $user->setCountry($this->getData('country')); $user->setBiography($this->getData('biography'), null); // Localized $user->setInterests($this->getData('interests'), null); // Localized $user->setGossip($this->getData('gossip'), null); // Localized $user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0); $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $auth =& $authDao->getDefaultPlugin(); $user->setAuthId($auth ? $auth->getAuthId() : 0); $site =& Request::getSite(); $availableLocales = $site->getSupportedLocales(); $locales = array(); foreach ($this->getData('userLocales') as $locale) { if (AppLocale::isLocaleValid($locale) && in_array($locale, $availableLocales)) { array_push($locales, $locale); } } $user->setLocales($locales); $user->setUsername($this->getData('username')); $password = Validation::generatePassword(); $sendNotify = $this->getData('sendNotify'); if (isset($auth)) { $user->setPassword($password); // FIXME Check result and handle failures $auth->doCreateUser($user); $user->setAuthId($auth->authId); $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword())); // Used for PW reset hash only } else { $user->setPassword(Validation::encryptCredentials($this->getData('username'), $password)); } $user->setDateRegistered(Core::getCurrentDate()); $userId = $userDao->insertUser($user); $roleDao =& DAORegistry::getDAO('RoleDAO'); $schedConf =& Request::getSchedConf(); $role = new Role(); $role->setConferenceId($schedConf->getConferenceId()); $role->setSchedConfId($schedConf->getId()); $role->setUserId($userId); $role->setRoleId(ROLE_ID_REVIEWER); $roleDao->insertRole($role); if ($sendNotify) { // Send welcome email to user import('mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTER'); $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName')); $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password)); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } return $userId; }
/** * Send an update to all users on the mailing list * @param $notification object Notification */ function sendToMailingList($notification) { $notificationSettingsDao =& DAORegistry::getDAO('NotificationSettingsDAO'); $mailList = $notificationSettingsDao->getMailList(); Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON)); foreach ($mailList as $email) { if ($notification->getIsLocalized()) { $params = array('param' => $notification->getParam()); $notificationContents = Locale::translate($notification->getContents(), $params); } else { $notificationContents = $notification->getContents(); } import('mail.MailTemplate'); $context =& Request::getContext(); $site =& Request::getSite(); $mail = new MailTemplate('NOTIFICATION_MAILLIST'); $mail->setFrom($site->getLocalizedContactEmail(), $site->getLocalizedContactName()); $mail->assignParams(array('notificationContents' => $notificationContents, 'url' => $notification->getLocation(), 'siteTitle' => $context->getLocalizedTitle(), 'unsubscribeLink' => Request::url(null, 'notification', 'unsubscribeMailList'))); $mail->addRecipient($email); $mail->send(); } }
/** * Fetch the form. * @param $request Request * @param $template string the template to render the form * @return string the rendered form */ function fetch($request, $template = CITATION_FORM_FULL_TEMPLATE) { // Instantiate objects used throughout. $user =& $request->getUser(); $router =& $request->getRouter(); $context =& $router->getContext($request); $citation =& $this->getCitation(); $assocObject =& $this->getAssocObject(); $citationDao =& DAORegistry::getDAO('CitationDAO'); /* @var $citationDao CitationDAO */ ///////////////////////////////////////////////////// // Raw citation editing and citation comparison // (comparison template and full template): // // 1) Messages // // Add the citation to the template. $templateMgr =& TemplateManager::getManager($request); $templateMgr->assign_by_ref('citation', $citation); // Does the form contain unsaved changes? $templateMgr->assign('unsavedChanges', $this->getUnsavedChanges()); if ($citation->getId()) { // // 2) Citation output preview // // Either the initData() or validate() method should have prepared // a meta-data representation of the citation. // NB: Our template and output filters currently only handle // one meta-data description. Any others but the first one are ignored. assert(!empty($this->_metadataDescriptions)); $metadataDescription = array_pop($this->_metadataDescriptions); // Generate the formatted citation output from the description. $citationOutputFilter =& $citationDao->instantiateCitationOutputFilter($context); $generatedCitation = $citationOutputFilter->execute($metadataDescription); foreach ($citationOutputFilter->getErrors() as $citationGenerationError) { $this->addError('rawCitation', $citationGenerationError); } $citationOutputFilter->clearErrors(); // Strip formatting and the Google Scholar tag so that we get a plain // text string that is comparable with the raw citation. $generatedCitation = trim(str_replace(GOOGLE_SCHOLAR_TAG, '', strip_tags($generatedCitation))); // Compare the raw and the formatted citation and add the result to the template. $citationDiff = String::diff($this->getData('rawCitation'), $generatedCitation); $templateMgr->assign('citationDiff', $citationDiff); $templateMgr->assign('currentOutputFilter', $citationOutputFilter->getDisplayName()); // // 3) Raw citation editing // // Retrieve all available citation filters $availableParserFilters =& $citationDao->getCitationFilterInstances($context->getId(), CITATION_PARSER_FILTER_GROUP, array(), true); $templateMgr->assign_by_ref('availableParserFilters', $availableParserFilters); $availableLookupFilters =& $citationDao->getCitationFilterInstances($context->getId(), CITATION_LOOKUP_FILTER_GROUP, array(), true); $templateMgr->assign_by_ref('availableLookupFilters', $availableLookupFilters); // Did the user disable the raw citation editing warning? $userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO'); $rawCitationEditingWarningHide = (bool) $userSettingsDao->getSetting($user->getId(), 'citation-editor-hide-raw-editing-warning'); $templateMgr->assign('rawCitationEditingWarningHide', $rawCitationEditingWarningHide); } if ($template == CITATION_FORM_FULL_TEMPLATE) { ///////////////////////////////////////////////////// // Citation improvement options // (full template only): // // 1) Manual editing // // Available fields $availableFields = array(); foreach ($this->_citationProperties as $fieldName => $property) { // Prepare property information for the view. $availableFields[$fieldName] = array('displayName' => __($property->getDisplayName()), 'required' => $property->getMandatory() ? 'true' : 'false'); // In the case of vocabulary based properties: Retrieve // the vocabulary to be displayed as a drop down. $availableFields[$fieldName]['options'] = null; $controlledVocabDao = null; foreach ($property->getAllowedTypes() as $allowedType => $allowedTypeParams) { if ($allowedType == METADATA_PROPERTY_TYPE_VOCABULARY) { assert(count($allowedTypeParams) == 1); $vocabName = $allowedTypeParams[0]; $vocabNameParts = explode(':', $vocabName); $vocabNamePartsCount = count($vocabNameParts); assert($vocabNamePartsCount == 1 || $vocabNamePartsCount == 3); if ($vocabNamePartsCount == 1) { // assume a site-wide vocabulary $symbolic = $vocabName; $assocType = $assocId = 0; } else { // assume a context-specific vocabulary list($symbolic, $assocType, $assocId) = $vocabNameParts; } // Enumerate the identified vocabulary. if (is_null($controlledVocabDao)) { $controlledVocabDao =& DAORegistry::getDAO('ControlledVocabDAO'); } $availableFields[$fieldName]['options'] = $controlledVocabDao->enumerateBySymbolic($symbolic, $assocType, $assocId); } } } // Sort available fields alphabetically. $availableFields = $this->_orderByDisplayName($availableFields); $templateMgr->assign_by_ref('availableFields', $availableFields); // // 2) Citation Services Query // // Nothing to do: Lookup filters have already been assigned for // raw citation editing (see above). // // 3) Google Scholar // // Nothing to do. // // 4) Author Query // // Add the author query text to the template. $author =& $assocObject->getUser(); $user =& $request->getUser(); $emailParams = array('authorFirstName' => strip_tags($author->getFirstName()), 'authorLastName' => strip_tags($author->getLastName()), 'userFirstName' => strip_tags($user->getFirstName()), 'userLastName' => strip_tags($user->getLastName()), 'articleTitle' => strip_tags($assocObject->getLocalizedTitle()), 'rawCitation' => strip_tags($citation->getRawCitation())); import('classes.mail.MailTemplate'); $mail = new MailTemplate('CITATION_EDITOR_AUTHOR_QUERY', null, false, null, true, true); $mail->assignParams($emailParams); $templateMgr->assign('authorQuerySubject', $mail->getSubject()); $templateMgr->assign('authorQueryBody', $mail->getBody()); ///////////////////////////////////////////////////// // Expert Citation Services Results // (full template only): // // Citation source tabs $citationSourceTabs = array(); $locale = AppLocale::getLocale(); // Run through all source descriptions and extract statements. $sourceDescriptions =& $citation->getSourceDescriptions(); assert(is_array($sourceDescriptions)); foreach ($sourceDescriptions as $sourceDescription) { $sourceDescriptionId = $sourceDescription->getId(); $metadataSchema =& $sourceDescription->getMetadataSchema(); // Use the display name of the description for the tab. // We can safely use the 'displayName' key here as // the keys representing statements will be namespaced. $citationSourceTabs[$sourceDescriptionId]['displayName'] = $sourceDescription->getDisplayName(); // Prepare the description's statements as a sub-array. $thisDescription = array(); foreach ($sourceDescription->getStatements() as $propertyName => $value) { $property =& $metadataSchema->getProperty($propertyName); // Handle translation if ($property->getTranslated()) { assert(isset($value[$locale])); $value = $value[$locale]; } $sourcePropertyId = $sourceDescriptionId . '-' . $metadataSchema->getNamespacedPropertyId($propertyName); $sourcePropertyValue = $this->_getStringValueFromMetadataStatement($property, $value); $thisDescription[$sourcePropertyId] = array('displayName' => $property->getDisplayName(), 'value' => $sourcePropertyValue); } // Order description properties in the sub-array by display name. $thisDescription = $this->_orderByDisplayName($thisDescription); // Add the description sub-array to the descriptons list. $citationSourceTabs[$sourceDescriptionId]['statements'] = $thisDescription; unset($thisDescription); // Remove source descriptions that don't have data. if (!isset($citationSourceTabs[$sourceDescriptionId]['statements'])) { unset($citationSourceTabs[$sourceDescriptionId]); } } $templateMgr->assign_by_ref('citationSourceTabs', $citationSourceTabs); ///////////////////////////////////////////////////// // Form level actions // (full template only): // // Set the approval state. $citationApproved = $citation->getCitationState() == CITATION_APPROVED ? true : false; $templateMgr->assign('citationApproved', $citationApproved); // Auto-add client-side validation // FIXME: Move to JS framework's AjaxFormHandler, also see #6442 $templateMgr->assign('validateId', 'citationForm'); } return parent::fetch($request, $template); }
/** * Display the "Email Colleague" form * @param $args array * @param $request Request */ function emailColleague($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->getEmailOthers() || !$user) { $request->redirect(null, null, $router->getRequestedPage($request)); } import('mail.MailTemplate'); $email = new MailTemplate('EMAIL_LINK'); if ($request->getUserVar('send') && !$email->hasErrors()) { $email->send(); $templateMgr =& TemplateManager::getManager(); $templateMgr->display('rt/sent.tpl'); } else { if (!$request->getUserVar('continued')) { $primaryAuthor = $paper->getAuthors(); $primaryAuthor = $primaryAuthor[0]; $email->setSubject('[' . $schedConf->getLocalizedSetting('acronym') . '] ' . strip_tags($paper->getLocalizedTitle())); $email->assignParams(array('paperTitle' => strip_tags($paper->getLocalizedTitle()), 'schedConf' => $schedConf->getSchedConfTitle(), 'authorName' => $primaryAuthor->getFullName(), 'paperUrl' => $router->url($request, null, null, 'paper', 'view', array($paper->getBestPaperId())))); } $email->displayEditForm($router->url($request, null, null, null, 'emailColleague', array($paperId, $galleyId)), null, 'rt/email.tpl', array('op' => 'emailColleague')); } }
/** * Handle incoming requests/notifications * @param $args array * @param $request PKPRequest */ function handle($args, $request) { $press = $request->getPress(); $templateMgr = TemplateManager::getManager($request); $user = $request->getUser(); $op = isset($args[0]) ? $args[0] : null; $queuedPaymentId = isset($args[1]) ? (int) $args[1] : 0; import('classes.payment.omp.OMPPaymentManager'); $ompPaymentManager = new OMPPaymentManager($request); $queuedPayment =& $ompPaymentManager->getQueuedPayment($queuedPaymentId); // if the queued payment doesn't exist, redirect away from payments if (!$queuedPayment) { return $request->redirect(null, 'index'); } switch ($op) { case 'notify': import('lib.pkp.classes.mail.MailTemplate'); AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON); $contactName = $press->getSetting('contactName'); $contactEmail = $press->getSetting('contactEmail'); $mail = new MailTemplate('MANUAL_PAYMENT_NOTIFICATION'); $mail->setReplyTo($contactEmail, $contactName); $mail->addRecipient($contactEmail, $contactName); $mail->assignParams(array('pressName' => $press->getLocalizedName(), 'userFullName' => $user ? $user->getFullName() : '(' . __('common.none') . ')', 'userName' => $user ? $user->getUsername() : '(' . __('common.none') . ')', 'itemName' => $queuedPayment->getName(), 'itemCost' => $queuedPayment->getAmount(), 'itemCurrencyCode' => $queuedPayment->getCurrencyCode())); $mail->send(); $templateMgr->assign(array('currentUrl' => $request->url(null, null, 'payment', 'plugin', array('notify', $queuedPaymentId)), 'pageTitle' => 'plugins.paymethod.manual.paymentNotification', 'message' => 'plugins.paymethod.manual.notificationSent', 'backLink' => $queuedPayment->getRequestUrl(), 'backLinkLabel' => 'common.continue')); return $templateMgr->display('frontend/pages/message.tpl'); } return parent::handle($args, $request); // Don't know what to do with it }
/** * Static function to send an email to a mailing list user regarding signup or a lost password * @param $email string * @param $password string the user's password * @param $template string The mail template to use */ function sendMailingListEmail($email, $password, $template) { import('mail.MailTemplate'); $conference = Request::getConference(); $site = Request::getSite(); $params = array('password' => $password, 'siteTitle' => $conference->getConferenceTitle(), 'unsubscribeLink' => Request::url(null, null, 'notification', 'unsubscribeMailList')); if ($template == 'NOTIFICATION_MAILLIST_WELCOME') { $keyHash = md5($password); $confirmLink = Request::url(null, null, 'notification', 'confirmMailListSubscription', array($keyHash, $email)); $params["confirmLink"] = $confirmLink; } $mail = new MailTemplate($template); $mail->setFrom($site->getLocalizedContactEmail(), $site->getLocalizedContactName()); $mail->assignParams($params); $mail->addRecipient($email); $mail->send(); }
/** * Register a new user. * @return userId int * Last modified: EL on February 22th 2013 */ function execute() { $userDao =& DAORegistry::getDAO('UserDAO'); $user = new User(); $user->setSalutation($this->getData('salutation')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setLastName($this->getData('lastName')); $user->setGender($this->getData('gender')); $user->setInitials($this->getData('initials')); $user->setAffiliation($this->getData('affiliation'), null); // Localized $user->setEmail($this->getData('email')); $user->setUrl($this->getData('userUrl')); $user->setPhone($this->getData('phone')); $user->setFax($this->getData('fax')); $user->setMailingAddress($this->getData('mailingAddress')); $user->setCountry($this->getData('country')); $user->setBiography($this->getData('biography'), null); // Localized $user->setGossip($this->getData('gossip'), null); // Localized $user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0); $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $auth =& $authDao->getDefaultPlugin(); $user->setAuthId($auth ? $auth->getAuthId() : 0); $site =& Request::getSite(); $availableLocales = $site->getSupportedLocales(); $locales = array(); foreach ($this->getData('userLocales') as $locale) { if (Locale::isLocaleValid($locale) && in_array($locale, $availableLocales)) { array_push($locales, $locale); } } $user->setLocales($locales); $user->setUsername($this->getData('username')); $password = Validation::generatePassword(); $sendNotify = $this->getData('sendNotify'); if (isset($auth)) { $user->setPassword($password); // FIXME Check result and handle failures $auth->doCreateUser($user); $user->setAuthId($auth->authId); $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword())); // Used for PW reset hash only } else { $user->setPassword(Validation::encryptCredentials($this->getData('username'), $password)); } $user->setDateRegistered(Core::getCurrentDate()); $userId = $userDao->insertUser($user); // Add reviewing interests to interests table $interestDao =& DAORegistry::getDAO('InterestDAO'); $interests = is_array(Request::getUserVar('interestsKeywords')) ? Request::getUserVar('interestsKeywords') : array(); if (is_array($interests)) { $interests = array_map('urldecode', $interests); // The interests are coming in encoded -- Decode them for DB storage $interestTextOnly = Request::getUserVar('interests'); if (!empty($interestsTextOnly)) { // If JS is disabled, this will be the input to read $interestsTextOnly = explode(",", $interestTextOnly); } else { $interestsTextOnly = null; } if ($interestsTextOnly && !isset($interests)) { $interests = $interestsTextOnly; } elseif (isset($interests) && !is_array($interests)) { $interests = array($interests); } $interestDao->insertInterests($interests, $user->getId(), true); } $interestDao->insertInterests($interests, $user->getId(), true); $roleDao =& DAORegistry::getDAO('RoleDAO'); $journal =& Request::getJournal(); $ercStatus = $this->getData('ercStatus'); if ($ercStatus == "Secretary") { $role = new Role(); $role->setJournalId($journal->getId()); $role->setUserId($userId); $role->setRoleId(ROLE_ID_SECTION_EDITOR); $roleDao->insertRole($role); $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO'); $sectionEditorsDao->insertEditor($journal->getId(), $this->sectionId, $userId, 1, 1); } elseif ($ercStatus == "Chair" || $ercStatus == "Vice-Chair" || $ercStatus == "Member") { $role = new Role(); $role->setJournalId($journal->getId()); $role->setUserId($userId); $role->setRoleId(ROLE_ID_REVIEWER); $roleDao->insertRole($role); $ercReviewersDao =& DAORegistry::getDAO('ErcReviewersDAO'); if ($ercStatus == "Chair") { $ercReviewersDao->insertReviewer($journal->getId(), $this->sectionId, $userId, 1); } elseif ($ercStatus == "Vice-Chair") { $ercReviewersDao->insertReviewer($journal->getId(), $this->sectionId, $userId, 2); } if ($ercStatus == "Member") { $ercReviewersDao->insertReviewer($journal->getId(), $this->sectionId, $userId, 3); } } if ($sendNotify) { $sectionDao =& DAORegistry::getDAO('SectionDAO'); $erc =& $sectionDao->getSection($this->sectionId); $thisUser =& Request::getUser(); // Send welcome email to user import('classes.mail.MailTemplate'); $mail = new MailTemplate('COMMITTEE_REGISTER'); $mail->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName(), 'ercStatus' => $ercStatus, 'ercTitle' => $erc->getLocalizedTitle(), 'editProfile' => Request::url(null, 'user', 'profile'), 'secretaryFullName' => $thisUser->getFullName(), 'secretaryFunctions' => $thisUser->getErcFunction($this->sectionId))); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } return $userId; }
/** * Handle incoming requests/notifications */ function handle($args) { $templateMgr =& TemplateManager::getManager(); $journal =& Request::getJournal(); if (!$journal) { return parent::handle($args); } // Just in case we need to contact someone import('classes.mail.MailTemplate'); $contactName = $journal->getSetting('contactName'); $contactEmail = $journal->getSetting('contactEmail'); $mail = new MailTemplate('PAYPAL_INVESTIGATE_PAYMENT'); $mail->setFrom($contactEmail, $contactName); $mail->addRecipient($contactEmail, $contactName); $paymentStatus = Request::getUserVar('payment_status'); switch (array_shift($args)) { case 'ipn': // Build a confirmation transaction. $req = 'cmd=_notify-validate'; if (get_magic_quotes_gpc()) { foreach ($_POST as $key => $value) { $req .= '&' . urlencode(stripslashes($key)) . '=' . urlencode(stripslashes($value)); } } else { foreach ($_POST as $key => $value) { $req .= '&' . urlencode($key) . '=' . urlencode($value); } } // Create POST response $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->getSetting($journal->getId(), 'paypalurl')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Content-Length: ' . strlen($req))); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); $ret = curl_exec($ch); $curlError = curl_error($ch); curl_close($ch); // Check the confirmation response and handle as necessary. if (strcmp($ret, 'VERIFIED') == 0) { switch ($paymentStatus) { case 'Completed': $payPalDao =& DAORegistry::getDAO('PayPalDAO'); $transactionId = Request::getUserVar('txn_id'); if ($payPalDao->transactionExists($transactionId)) { // A duplicate transaction was received; notify someone. $mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Duplicate transaction ID: {$transactionId}", 'serverVars' => print_r($_SERVER, true))); $mail->send(); exit; } else { // New transaction succeeded. Record it. $payPalDao->insertTransaction($transactionId, Request::getUserVar('txn_type'), Request::getUserVar('payer_email'), Request::getUserVar('receiver_email'), Request::getUserVar('item_number'), Request::getUserVar('payment_date'), Request::getUserVar('payer_id'), Request::getUserVar('receiver_id')); $queuedPaymentId = Request::getUserVar('custom'); import('classes.payment.ojs.OJSPaymentManager'); $ojsPaymentManager =& OJSPaymentManager::getManager(); // Verify the cost and user details as per PayPal spec. $queuedPayment =& $ojsPaymentManager->getQueuedPayment($queuedPaymentId); if (!$queuedPayment) { // The queued payment entry is missing. Complain. $mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Missing queued payment ID: {$queuedPaymentId}", 'serverVars' => print_r($_SERVER, true))); $mail->send(); exit; } //NB: if/when paypal subscriptions are enabled, these checks will have to be adjusted // because subscription prices may change over time if (($queuedAmount = $queuedPayment->getAmount()) != ($grantedAmount = Request::getUserVar('mc_gross')) && $queuedAmount > 0 || ($queuedCurrency = $queuedPayment->getCurrencyCode()) != ($grantedCurrency = Request::getUserVar('mc_currency')) || ($grantedEmail = Request::getUserVar('receiver_email')) != ($queuedEmail = $this->getSetting($journal->getId(), 'selleraccount'))) { // The integrity checks for the transaction failed. Complain. $mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Granted amount: {$grantedAmount}\n" . "Queued amount: {$queuedAmount}\n" . "Granted currency: {$grantedCurrency}\n" . "Queued currency: {$queuedCurrency}\n" . "Granted to PayPal account: {$grantedEmail}\n" . "Configured PayPal account: {$queuedEmail}", 'serverVars' => print_r($_SERVER, true))); $mail->send(); exit; } // Update queued amount if amount set by user (e.g. donation) if ($queuedAmount == 0 && $grantedAmount > 0) { $queuedPaymentDao =& DAORegistry::getDAO('QueuedPaymentDAO'); $queuedPayment->setAmount($grantedAmount); $queuedPayment->setCurrencyCode($grantedCurrency); $queuedPaymentDao->updateQueuedPayment($queuedPaymentId, $queuedPayment); } // Fulfill the queued payment. if ($ojsPaymentManager->fulfillQueuedPayment($queuedPayment, $this->getName())) { exit; } // If we're still here, it means the payment couldn't be fulfilled. $mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Queued payment ID {$queuedPaymentId} could not be fulfilled.", 'serverVars' => print_r($_SERVER, true))); $mail->send(); } exit; case 'Pending': // Ignore. exit; default: // An unhandled payment status was received; notify someone. $mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Payment status: {$paymentStatus}", 'serverVars' => print_r($_SERVER, true))); $mail->send(); exit; } } else { // An unknown confirmation response was received; notify someone. $mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Confirmation return: {$ret}\nCURL error: {$curlError}", 'serverVars' => print_r($_SERVER, true))); $mail->send(); exit; } break; case 'cancel': Handler::setupTemplate(); $templateMgr->assign(array('currentUrl' => Request::url(null, 'index'), 'pageTitle' => 'plugins.paymethod.paypal.purchase.cancelled.title', 'message' => 'plugins.paymethod.paypal.purchase.cancelled', 'backLink' => Request::getUserVar('ojsReturnUrl'), 'backLinkLabel' => 'common.continue')); $templateMgr->display('common/message.tpl'); exit; break; } parent::handle($args); // Don't know what to do with it }
/** * 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'); }
function notifyEmail($typeId) { $schedConf =& Request::getSchedConf(); // Send user registration notification email $userDao =& DAORegistry::getDAO('UserDAO'); $registrationTypeDao =& DAORegistry::getDAO('RegistrationTypeDAO'); $schedConfName = $schedConf->getSchedConfTitle(); $schedConfId = $schedConf->getId(); $user = Request::getUser(); $registrationType =& $registrationTypeDao->getRegistrationType($typeId); list($registrationEmail, $registrationName, $registrationContactSignature) = $this->getRegistrationContactInformation($schedConfId); $paramArray = array('registrantName' => $user->getFullName(), 'schedConfName' => $schedConfName, 'registrationType' => $registrationType->getRegistrationTypeName(), 'username' => $user->getEmail(), 'registrationContactSignature' => $registrationContactSignature); import('mail.MailTemplate'); $mail = new MailTemplate('REGISTRATION_NOTIFY', null, null, null, null, false); $mail->setFrom($registrationEmail, $registrationName); $mail->assignParams($paramArray); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); }
/** * Display the "Email Colleague" form * @param $args array * @param $request Request */ function emailColleague($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); $issue =& $this->issue; $article =& $this->article; $rtDao =& DAORegistry::getDAO('RTDAO'); $journalRt =& $rtDao->getJournalRTByJournal($journal); $user =& $request->getUser(); if (!$journalRt || !$journalRt->getEmailOthers() || !$user) { $request->redirect(null, $router->getRequestedPage($request)); } import('classes.mail.MailTemplate'); $email = new MailTemplate('EMAIL_LINK'); if ($request->getUserVar('send') && !$email->hasErrors()) { $email->send(); $templateMgr =& TemplateManager::getManager(); $templateMgr->display('rt/sent.tpl'); } else { if (!$request->getUserVar('continued')) { $primaryAuthor = $article->getAuthors(); $primaryAuthor = $primaryAuthor[0]; $email->setSubject('[' . $journal->getLocalizedSetting('initials') . '] ' . strip_tags($article->getLocalizedTitle())); $email->assignParams(array('articleTitle' => strip_tags($article->getLocalizedTitle()), 'volume' => $issue ? $issue->getVolume() : null, 'number' => $issue ? $issue->getNumber() : null, 'year' => $issue ? $issue->getYear() : null, 'authorName' => $primaryAuthor->getFullName(), 'articleUrl' => $router->url($request, null, 'article', 'view', array($article->getBestArticleId())))); } $email->displayEditForm($router->url($request, null, null, 'emailColleague', array($articleId, $galleyId)), null, 'rt/email.tpl', array('op' => 'emailColleague')); } }