function sendNotification($users, $journal, $issue) { if ($users->getCount() != 0) { import('classes.mail.MailTemplate'); $email = new MailTemplate('OPEN_ACCESS_NOTIFY'); $email->setSubject($email->getSubject($journal->getPrimaryLocale())); $email->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $email->addRecipient($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $paramArray = array('journalName' => $journal->getLocalizedTitle(), 'journalUrl' => $journal->getUrl(), 'editorialContactSignature' => $journal->getSetting('contactName') . "\n" . $journal->getLocalizedTitle()); $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_by_ref('issue', $issue); $templateMgr->assign_by_ref('publishedArticles', $publishedArticles); $email->addHeader('MIME-Version', '1.0'); $email->setContentType('multipart/alternative; boundary="' . $mimeBoundary . '"'); $email->setBody($templateMgr->fetch('subscription/openAccessNotifyEmail.tpl')); while (!$users->eof()) { $user =& $users->next(); $email->addBcc($user->getEmail(), $user->getFullName()); } $email->send(); } }
/** * Helper Function - set mail from address * @param MailTemplate $mail */ function _setMailFrom(&$mail) { $site =& Request::getSite(); $journal =& Request::getJournal(); // Set the sender based on the current context if ($journal && $journal->getSetting('supportEmail')) { $mail->setFrom($journal->getSetting('supportEmail'), $journal->getSetting('supportName')); } else { $mail->setFrom($site->getLocalizedContactEmail(), $site->getLocalizedContactName()); } }
/** * 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->setFrom($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(); }
/** * Helper Function - set mail from address * @param MailTemplate $mail */ function _setMailFrom(&$mail) { $site =& Request::getSite(); $conference =& Request::getConference(); $schedConf =& Request::getSchedConf(); // Set the sender to one of three different settings, based on context if ($schedConf && $schedConf->getSetting('supportEmail')) { $mail->setFrom($schedConf->getSetting('supportEmail'), $schedConf->getSetting('supportName')); } elseif ($conference && $conference->getSetting('contactEmail')) { $mail->setFrom($conference->getSetting('contactEmail'), $conference->getSetting('contactName')); } else { $mail->setFrom($site->getLocalizedContactEmail(), $site->getLocalizedContactName()); } }
/** * 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->setFrom($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); }
function sendReminder($subscription, $journal, $emailKey) { $userDao =& DAORegistry::getDAO('UserDAO'); $subscriptionTypeDao =& DAORegistry::getDAO('SubscriptionTypeDAO'); $journalName = $journal->getLocalizedTitle(); $journalId = $journal->getId(); $user =& $userDao->getUser($subscription->getUserId()); if (!isset($user)) { return false; } $subscriptionType =& $subscriptionTypeDao->getSubscriptionType($subscription->getTypeId()); $subscriptionName = $journal->getSetting('subscriptionName'); $subscriptionEmail = $journal->getSetting('subscriptionEmail'); $subscriptionPhone = $journal->getSetting('subscriptionPhone'); $subscriptionFax = $journal->getSetting('subscriptionFax'); $subscriptionMailingAddress = $journal->getSetting('subscriptionMailingAddress'); $subscriptionContactSignature = $subscriptionName; Locale::requireComponents(array(LOCALE_COMPONENT_PKP_USER, LOCALE_COMPONENT_APPLICATION_COMMON)); 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(), 'expiryDate' => $subscription->getDateEnd(), 'username' => $user->getUsername(), 'subscriptionContactSignature' => $subscriptionContactSignature); import('classes.mail.MailTemplate'); $mail = new MailTemplate($emailKey); $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); $mail->send(); }
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(); }
/** * Register a new user. */ function execute() { $userDao =& DAORegistry::getDAO('UserDAO'); $journal =& Request::getJournal(); if (isset($this->userId)) { $user =& $userDao->getById($this->userId); } if (!isset($user)) { $user = new User(); } $user->setSalutation($this->getData('salutation')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setLastName($this->getData('lastName')); $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->setData('orcid', $this->getData('orcid')); $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); $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) { $userId = $user->getId(); if ($this->getData('password') !== '') { if (isset($auth)) { $auth->doSetUserPassword($user->getUsername(), $this->getData('password')); $user->setPassword(Validation::encryptCredentials($userId, 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->insertUser($user); $isManager = Validation::isJournalManager(); if (!empty($this->_data['enrollAs'])) { foreach ($this->getData('enrollAs') as $roleName) { // Enroll new user into an initial role $roleDao =& DAORegistry::getDAO('RoleDAO'); $roleId = $roleDao->getRoleIdFromPath($roleName); if (!$isManager && $roleId != ROLE_ID_READER) { continue; } if ($roleId != null) { $role = new Role(); $role->setJournalId($journal->getId()); $role->setUserId($userId); $role->setRoleId($roleId); $roleDao->insertRole($role); } } } if ($sendNotify) { // Send welcome email to user import('classes.mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTER'); $mail->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName())); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } } // Insert the user interests $interests = $this->getData('interestsKeywords') ? $this->getData('interestsKeywords') : $this->getData('interestsTextOnly'); import('lib.pkp.classes.user.InterestManager'); $interestManager = new InterestManager(); $interestManager->setInterestsForUser($user, $interests); }
/** * Import papers (including metadata and files). */ function importPapers() { if ($this->hasOption('verbose')) { printf("Importing papers\n"); } import('classes.file.PaperFileManager'); import('classes.search.PaperSearchIndex'); $userDao =& DAORegistry::getDAO('UserDAO'); $roleDao =& DAORegistry::getDAO('RoleDAO'); $trackDao =& DAORegistry::getDAO('TrackDAO'); $paperDao =& DAORegistry::getDAO('PaperDAO'); $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO'); $galleyDao =& DAORegistry::getDAO('PaperGalleyDAO'); $unassignedTrackId = null; $result =& $this->importDao->retrieve('SELECT * FROM papers ORDER by id'); while (!$result->EOF) { $row =& $result->fields; $schedConf =& $this->schedConfMap[$row['cf']]; $schedConfId = $schedConf->getId(); // Bring in the primary user for this paper. $user = $userDao->getUserByUsername(Core::cleanVar($row['login'])); if (!$user) { unset($user); $user = new User(); $user->setUsername(Core::cleanVar($row['login'])); $user->setFirstName(Core::cleanVar($row['first_name'])); $user->setLastName(Core::cleanVar($row['surname'])); $user->setAffiliation(Core::cleanVar($row['affiliation']), Locale::getLocale()); $user->setEmail(Core::cleanVar($row['email'])); $user->setUrl(Core::cleanVar($row['url'])); $user->setBiography(Core::cleanVar($row['bio']), Locale::getLocale()); $user->setLocales(array()); $user->setDateRegistered($row['created']); $user->setDateLastLogin($row['created']); $user->setMustChangePassword(1); $password = Validation::generatePassword(); $user->setPassword(Validation::encryptCredentials($user->getUsername(), $password)); if ($this->hasOption('emailUsers')) { import('classes.mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTER'); $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName')); $mail->assignParams(array('username' => $user->getUsername(), 'password' => $password, 'conferenceName' => $schedConf->getFullTitle())); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } $user->setDisabled(0); $otherUser =& $userDao->getUserByEmail(Core::cleanVar($row['email'])); if ($otherUser !== null) { // User exists with this email -- munge it to make unique $user->setEmail('ocs-' . Core::cleanVar($row['login']) . '+' . Core::cleanVar($row['email'])); $this->conflicts[] = array(&$otherUser, &$user); } unset($otherUser); $userDao->insertUser($user); // Make this user a author $role = new Role(); $role->setSchedConfId($schedConf->getId()); $role->setConferenceId($schedConf->getConferenceId()); $role->setUserId($user->getId()); $role->setRoleId(ROLE_ID_AUTHOR); $roleDao->insertRole($role); unset($role); } $userId = $user->getId(); // Bring in the basic entry for the paper $paper = new Paper(); $paper->setUserId($userId); $paper->setLocale(Locale::getPrimaryLocale()); $paper->setSchedConfId($schedConfId); $oldTrackId = $row['primary_track_id']; if (!$oldTrackId || !isset($this->trackMap[$oldTrackId])) { $oldTrackId = $row['secondary_track_id']; } if (!$oldTrackId || !isset($this->trackMap[$oldTrackId])) { if (!$unassignedTrackId) { // Create an "Unassigned" track to use for submissions // that didn't have a track in OCS 1.x. $track = new Track(); $track->setSchedConfId($schedConf->getId()); $track->setTitle('UNASSIGNED', Locale::getLocale()); $track->setSequence(REALLY_BIG_NUMBER); $track->setDirectorRestricted(1); $track->setMetaReviewed(1); $unassignedTrackId = $trackDao->insertTrack($track); } $newTrackId = $unassignedTrackId; } else { $newTrackId = $this->trackMap[$oldTrackId]; } $paper->setTrackId($newTrackId); $paper->setTitle(Core::cleanVar($row['title']), Locale::getLocale()); $paper->setAbstract(Core::cleanVar($row['abstract']), Locale::getLocale()); $paper->setDiscipline(Core::cleanVar($row['discipline']), Locale::getLocale()); $paper->setSponsor(Core::cleanVar($row['sponsor']), Locale::getLocale()); $paper->setSubject(Core::cleanVar($row['topic']), Locale::getLocale()); $paper->setLanguage(Core::cleanVar($row['language'])); $paper->setDateSubmitted($row['created']); $paper->setDateStatusModified($row['timestamp']); // $paper->setTypeConst($row['present_format'] == 'multiple' ? SUBMISSION_TYPE_PANEL : SUBMISSION_TYPE_SINGLE); FIXME $paper->setCurrentRound(REVIEW_ROUND_ABSTRACT); $paper->setSubmissionProgress(0); $paper->setPages(''); // Bring in authors $firstNames = split("\n", Core::cleanVar($row['first_name'] . "\n" . $row['add_first_names'])); $lastNames = split("\n", Core::cleanVar($row['surname'] . "\n" . $row['add_surnames'])); $emails = split("\n", Core::cleanVar($row['email'] . "\n" . $row['add_emails'])); $affiliations = split("\n", Core::cleanVar($row['affiliation'] . "\n" . $row['add_affiliations'])); $urls = split("\n", Core::cleanVar($row['url'] . "\n" . $row['add_urls'])); foreach ($emails as $key => $email) { if (empty($email)) { continue; } $author = new Author(); $author->setEmail($email); $author->setFirstName($firstNames[$key]); $author->setLastName($lastNames[$key]); $author->setAffiliation($affiliations[$key], Locale::getLocale()); @$author->setUrl($urls[$key]); // Suppress warnings from inconsistent OCS 1.x data $author->setPrimaryContact($key == 0 ? 1 : 0); $paper->addAuthor($author); unset($author); } switch ($row['accepted']) { case 'true': $paper->setStatus(STATUS_PUBLISHED); $paperId = $paperDao->insertPaper($paper); $publishedPaper = new PublishedPaper(); $publishedPaper->setPaperId($paperId); $publishedPaper->setSchedConfId($schedConfId); $publishedPaper->setDatePublished(Core::getCurrentDate()); $publishedPaper->setSeq(REALLY_BIG_NUMBER); $publishedPaper->setViews(0); $publishedPaperDao->insertPublishedPaper($publishedPaper); $publishedPaperDao->resequencePublishedPapers($paper->getTrackId(), $schedConfId); break; case 'reject': $paper->setStatus(STATUS_DECLINED); $paperId = $paperDao->insertPaper($paper); break; default: $paper->setStatus(STATUS_QUEUED); $paperId = $paperDao->insertPaper($paper); } $this->paperMap[$row['id']] =& $paper; $paperFileManager = new PaperFileManager($paperId); if (!empty($row['paper']) && $row['paper'] != 'PDF') { $format = 'text/html'; $extension = $paperFileManager->getDocumentExtension($format); $fileId = $paperFileManager->writeSubmissionFile('migratedFile' . $extension, $row['paper'], $format); $paper->setSubmissionFileId($fileId); $paperDao->updatePaper($paper); $fileId = $paperFileManager->writePublicFile('migratedGalley' . $extension, $row['paper'], $format); PaperSearchIndex::updateFileIndex($paperId, PAPER_SEARCH_GALLEY_FILE, $fileId); if (strstr($format, 'html')) { $galley = new PaperHTMLGalley(); $galley->setLabel('HTML'); } else { $galley = new PaperGalley(); switch ($format) { case 'application/pdf': $galley->setLabel('PDF'); break; case 'application/postscript': $galley->setLabel('PostScript'); break; case 'application/msword': $galley->setLabel('Word'); break; case 'text/xml': $galley->setLabel('XML'); break; case 'application/powerpoint': $galley->setLabel('Slideshow'); break; default: $galley->setLabel('Untitled'); break; } } $galley->setLocale(Locale::getLocale()); $galley->setPaperId($paperId); $galley->setFileId($fileId); $galleyDao->insertGalley($galley); unset($galley); } elseif ($row['paper'] == 'PDF') { $fileId = $paperFileManager->copySubmissionFile($this->importPath . '/papers/' . $row['pdf'], 'application/pdf'); $paper->setSubmissionFileId($fileId); $paperDao->updatePaper($paper); $fileId = $paperFileManager->copyPublicFile($this->importPath . '/papers/' . $row['pdf'], 'application/pdf'); PaperSearchIndex::updateFileIndex($paperId, PAPER_SEARCH_GALLEY_FILE, $fileId); $galley = new PaperGalley(); $galley->setLabel('PDF'); $galley->setLocale(Locale::getLocale()); $galley->setPaperId($paperId); $galley->setFileId($fileId); $galleyDao->insertGalley($galley); unset($galley); } // FIXME: The following fields from OCS 1.x are UNUSED: // program_insert approach coverage format relation appendix_names appendix_dates // appendix appendix_pdf secondary_track_id multiple_* restrict_access paper_email // delete_paper comment_email unset($user); unset($paper); unset($schedConf); unset($paperFileManager); $result->MoveNext(); } $result->Close(); }
/** * Helper function - set mail From * can be overriden by child classes * @param $request PKPRequest * @param MailTemplate $mail * @param $site Site */ function _setMailFrom($request, &$mail, &$site) { $mail->setFrom($site->getLocalizedContactEmail(), $site->getLocalizedContactName()); return true; }
/** * 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(); }
/** * 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 }
/** * 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; }
/** * 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; }
/** * Register a new user. */ function execute() { $requireValidation = Config::getVar('email', 'require_validation'); if ($this->existingUser) { // If using implicit auth - we hardwire that we are working on an existing user // Existing user in the system $userDao =& DAORegistry::getDAO('UserDAO'); if ($this->implicitAuth) { // If we are using implicit auth - then use the session username variable - rather than data from the form $sessionManager =& SessionManager::getManager(); $session =& $sessionManager->getUserSession(); $user =& $userDao->getUserByUsername($session->getSessionVar('username')); } else { $user =& $userDao->getUserByUsername($this->getData('username')); } if ($user == null) { return false; } $userId = $user->getId(); } else { // New user $user = new User(); $user->setUsername($this->getData('username')); $user->setSalutation($this->getData('salutation')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setInitials($this->getData('initials')); $user->setLastName($this->getData('lastName')); $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->setFax($this->getData('fax')); $user->setMailingAddress($this->getData('mailingAddress')); $user->setBiography($this->getData('biography'), null); // Localized $user->setDateRegistered(Core::getCurrentDate()); $user->setCountry($this->getData('country')); $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); if (isset($this->defaultAuth)) { $user->setPassword($this->getData('password')); // FIXME Check result and handle failures $this->defaultAuth->doCreateUser($user); $user->setAuthId($this->defaultAuth->authId); } $user->setPassword(Validation::encryptCredentials($this->getData('username'), $this->getData('password'))); if ($requireValidation) { // The account should be created in a disabled // state. $user->setDisabled(true); $user->setDisabledReason(Locale::translate('user.login.accountNotValidated')); } $userDao =& DAORegistry::getDAO('UserDAO'); $userDao->insertUser($user); $userId = $user->getId(); if (!$userId) { return false; } // Add reviewing interests to interests table import('lib.pkp.classes.user.InterestManager'); $interestManager = new InterestManager(); $interestManager->insertInterests($userId, $this->getData('interestsKeywords'), $this->getData('interests')); $sessionManager =& SessionManager::getManager(); $session =& $sessionManager->getUserSession(); $session->setSessionVar('username', $user->getUsername()); } $press =& Request::getPress(); $roleDao =& DAORegistry::getDAO('RoleDAO'); // Roles users are allowed to register themselves in $allowedRoles = array('reader' => 'registerAsReader', 'author' => 'registerAsAuthor', 'reviewer' => 'registerAsReviewer'); $pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO'); if (!$pressSettingsDao->getSetting($press->getId(), 'allowRegReader')) { unset($allowedRoles['reader']); } if (!$pressSettingsDao->getSetting($press->getId(), 'allowRegAuthor')) { unset($allowedRoles['author']); } if (!$pressSettingsDao->getSetting($press->getId(), 'allowRegReviewer')) { unset($allowedRoles['reviewer']); } foreach ($allowedRoles as $k => $v) { $roleId = $roleDao->getRoleIdFromPath($k); if ($this->getData($v) && !$roleDao->userHasRole($press->getId(), $userId, $roleId)) { $role = new Role(); $role->setPressId($press->getId()); $role->setUserId($userId); $role->setRoleId($roleId); $roleDao->insertRole($role); } } if (!$this->existingUser) { import('classes.mail.MailTemplate'); if ($requireValidation) { // Create an access key import('lib.pkp.classes.security.AccessKeyManager'); $accessKeyManager = new AccessKeyManager(); $accessKey = $accessKeyManager->createKey('RegisterContext', $user->getId(), null, Config::getVar('email', 'validation_timeout')); // Send email validation request to user $mail = new MailTemplate('USER_VALIDATE'); $mail->setFrom($press->getSetting('contactEmail'), $press->getSetting('contactName')); $mail->assignParams(array('userFullName' => $user->getFullName(), 'activateUrl' => Request::url($press->getPath(), 'user', 'activateUser', array($this->getData('username'), $accessKey)))); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); unset($mail); } if ($this->getData('sendPassword')) { // Send welcome email to user $mail = new MailTemplate('USER_REGISTER'); $mail->setFrom($press->getSetting('contactEmail'), $press->getSetting('contactName')); $mail->assignParams(array('username' => $this->getData('username'), 'password' => String::substr($this->getData('password'), 0, 30), 'userFullName' => $user->getFullName())); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); unset($mail); } } // By default, self-registering readers will receive // press updates. (The double set is here to prevent a // duplicate insert error msg if there was a notification entry // left over from a previous role.) if (isset($allowedRoles['reader']) && $this->getData($allowedRoles['reader'])) { $notificationStatusDao =& DAORegistry::getDAO('NotificationStatusDAO'); $notificationStatusDao->setPressNotifications($press->getId(), $userId, false); $notificationStatusDao->setPressNotifications($press->getId(), $userId, true); } }
/** * Fulfill a queued payment. * @param $queuedPayment QueuedPayment * @param $payMethodPluginName string Name of payment plugin. * @return mixed Dependent on payment type. */ function fulfillQueuedPayment(&$queuedPayment, $payMethodPluginName = null) { $returner = false; if ($queuedPayment) { switch ($queuedPayment->getType()) { case PAYMENT_TYPE_MEMBERSHIP: $userDao =& DAORegistry::getDAO('UserDAO'); $user =& $userDao->getUser($queuedPayment->getuserId()); $userDao->renewMembership($user); $returner = true; break; case PAYMENT_TYPE_PURCHASE_SUBSCRIPTION: $subscriptionId = $queuedPayment->getAssocId(); $institutionalSubscriptionDao =& DAORegistry::getDAO('InstitutionalSubscriptionDAO'); $individualSubscriptionDao =& DAORegistry::getDAO('IndividualSubscriptionDAO'); if ($institutionalSubscriptionDao->subscriptionExists($subscriptionId)) { $subscription =& $institutionalSubscriptionDao->getSubscription($subscriptionId); $institutional = true; } else { $subscription =& $individualSubscriptionDao->getSubscription($subscriptionId); $institutional = false; } if (!$subscription || $subscription->getUserId() != $queuedPayment->getUserId() || $subscription->getJournalId() != $queuedPayment->getJournalId()) { // FIXME: Is this supposed to be here? error_log(print_r($subscription, true)); return false; } // Update subscription end date now that payment is completed if ($institutional) { // Still requires approval from JM/SM since includes domain and IP ranges import('classes.subscription.InstitutionalSubscription'); $subscription->setStatus(SUBSCRIPTION_STATUS_NEEDS_APPROVAL); if ($subscription->isNonExpiring()) { $institutionalSubscriptionDao->updateSubscription($subscription); } else { $institutionalSubscriptionDao->renewSubscription($subscription); } // Notify JM/SM of completed online purchase $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO'); if ($journalSettingsDao->getSetting($subscription->getJournalId(), 'enableSubscriptionOnlinePaymentNotificationPurchaseInstitutional')) { import('classes.subscription.SubscriptionAction'); SubscriptionAction::sendOnlinePaymentNotificationEmail($subscription, 'SUBSCRIPTION_PURCHASE_INSTL'); } } else { import('classes.subscription.IndividualSubscription'); $subscription->setStatus(SUBSCRIPTION_STATUS_ACTIVE); if ($subscription->isNonExpiring()) { $individualSubscriptionDao->updateSubscription($subscription); } else { $individualSubscriptionDao->renewSubscription($subscription); } // Notify JM/SM of completed online purchase $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO'); if ($journalSettingsDao->getSetting($subscription->getJournalId(), 'enableSubscriptionOnlinePaymentNotificationPurchaseIndividual')) { import('classes.subscription.SubscriptionAction'); SubscriptionAction::sendOnlinePaymentNotificationEmail($subscription, 'SUBSCRIPTION_PURCHASE_INDL'); } } $returner = true; break; case PAYMENT_TYPE_RENEW_SUBSCRIPTION: $subscriptionId = $queuedPayment->getAssocId(); $institutionalSubscriptionDao =& DAORegistry::getDAO('InstitutionalSubscriptionDAO'); if ($institutionalSubscriptionDao->subscriptionExists($subscriptionId)) { $subscription =& $institutionalSubscriptionDao->getSubscription($subscriptionId); $institutional = true; } else { $individualSubscriptionDao =& DAORegistry::getDAO('IndividualSubscriptionDAO'); $subscription =& $individualSubscriptionDao->getSubscription($subscriptionId); $institutional = false; } if (!$subscription || $subscription->getUserId() != $queuedPayment->getUserId() || $subscription->getJournalId() != $queuedPayment->getJournalId()) { // FIXME: Is this supposed to be here? error_log(print_r($subscription, true)); return false; } if ($institutional) { $institutionalSubscriptionDao->renewSubscription($subscription); // Notify JM/SM of completed online purchase $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO'); if ($journalSettingsDao->getSetting($subscription->getJournalId(), 'enableSubscriptionOnlinePaymentNotificationRenewInstitutional')) { import('classes.subscription.SubscriptionAction'); SubscriptionAction::sendOnlinePaymentNotificationEmail($subscription, 'SUBSCRIPTION_RENEW_INSTL'); } } else { $individualSubscriptionDao->renewSubscription($subscription); // Notify JM/SM of completed online purchase $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO'); if ($journalSettingsDao->getSetting($subscription->getJournalId(), 'enableSubscriptionOnlinePaymentNotificationRenewIndividual')) { import('classes.subscription.SubscriptionAction'); SubscriptionAction::sendOnlinePaymentNotificationEmail($subscription, 'SUBSCRIPTION_RENEW_INDL'); } } $returner = true; break; case PAYMENT_TYPE_FASTTRACK: $articleDao =& DAORegistry::getDAO('ArticleDAO'); $article =& $articleDao->getArticle($queuedPayment->getAssocId(), $queuedPayment->getJournalId()); $article->setFastTracked(true); $articleDao->updateArticle($article); $returner = true; break; case PAYMENT_TYPE_GIFT: $giftId = $queuedPayment->getAssocId(); $giftDao =& DAORegistry::getDAO('GiftDAO'); $gift =& $giftDao->getGift($giftId); if (!$gift) { return false; } $journalDao =& DAORegistry::getDAO('JournalDAO'); $journalId = $gift->getAssocId(); $journal =& $journalDao->getById($journalId); if (!$journal) { return false; } // Check if user account corresponding to recipient email exists in the system $userDao =& DAORegistry::getDAO('UserDAO'); $roleDao =& DAORegistry::getDAO('RoleDAO'); $recipientFirstName = $gift->getRecipientFirstName(); $recipientEmail = $gift->getRecipientEmail(); $newUserAccount = false; if ($userDao->userExistsByEmail($recipientEmail)) { // User already has account, check if enrolled as reader in journal $user =& $userDao->getUserByEmail($recipientEmail); $userId = $user->getId(); if (!$roleDao->userHasRole($journalId, $userId, ROLE_ID_READER)) { // User not enrolled as reader, enroll as reader $role = new Role(); $role->setJournalId($journalId); $role->setUserId($userId); $role->setRoleId(ROLE_ID_READER); $roleDao->insertRole($role); } } else { // User does not have an account. Create one and enroll as reader. $recipientLastName = $gift->getRecipientLastName(); $username = Validation::suggestUsername($recipientFirstName, $recipientLastName); $password = Validation::generatePassword(); $user = new User(); $user->setUsername($username); $user->setPassword(Validation::encryptCredentials($username, $password)); $user->setFirstName($recipientFirstName); $user->setMiddleName($gift->getRecipientMiddleName()); $user->setLastName($recipientLastName); $user->setEmail($recipientEmail); $user->setDateRegistered(Core::getCurrentDate()); $userDao->insertUser($user); $userId = $user->getId(); $role = new Role(); $role->setJournalId($journalId); $role->setUserId($userId); $role->setRoleId(ROLE_ID_READER); $roleDao->insertRole($role); $newUserAccount = true; } // Update gift status (make it redeemable) and add recipient user account reference import('classes.gift.Gift'); $gift->setStatus(GIFT_STATUS_NOT_REDEEMED); $gift->setRecipientUserId($userId); $giftDao->updateObject($gift); // Send gift available email to recipient, cc buyer $giftNoteTitle = $gift->getGiftNoteTitle(); $buyerFullName = $gift->getBuyerFullName(); $giftNote = $gift->getGiftNote(); $giftLocale = $gift->getLocale(); AppLocale::requireComponents(LOCALE_COMPONENT_APPLICATION_COMMON, $giftLocale); $giftDetails = $gift->getGiftName($giftLocale); $giftJournalName = $journal->getTitle($giftLocale); $giftContactSignature = $journal->getSetting('contactName'); import('classes.mail.MailTemplate'); $mail = new MailTemplate('GIFT_AVAILABLE', $giftLocale); $mail->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $mail->assignParams(array('giftJournalName' => $giftJournalName, 'giftNoteTitle' => $giftNoteTitle, 'recipientFirstName' => $recipientFirstName, 'buyerFullName' => $buyerFullName, 'giftDetails' => $giftDetails, 'giftNote' => $giftNote, 'giftContactSignature' => $giftContactSignature)); $mail->addRecipient($recipientEmail, $user->getFullName()); $mail->addCc($gift->getBuyerEmail(), $gift->getBuyerFullName()); $mail->send(); unset($mail); // Send gift login details to recipient $params = array('giftJournalName' => $giftJournalName, 'recipientFirstName' => $recipientFirstName, 'buyerFullName' => $buyerFullName, 'giftDetails' => $giftDetails, 'giftUrl' => $request->url($journal->getPath(), 'user', 'gifts'), 'username' => $user->getUsername(), 'giftContactSignature' => $giftContactSignature); if ($newUserAccount) { $mail = new MailTemplate('GIFT_USER_REGISTER', $giftLocale); $params['password'] = $password; } else { $mail = new MailTemplate('GIFT_USER_LOGIN', $giftLocale); } $mail->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $mail->assignParams($params); $mail->addRecipient($recipientEmail, $user->getFullName()); $mail->send(); unset($mail); $returner = true; break; case PAYMENT_TYPE_PURCHASE_ARTICLE: case PAYMENT_TYPE_PURCHASE_ISSUE: case PAYMENT_TYPE_DONATION: case PAYMENT_TYPE_SUBMISSION: case PAYMENT_TYPE_PUBLICATION: $returner = true; break; default: // Invalid payment type assert(false); } } $completedPaymentDao =& DAORegistry::getDAO('OJSCompletedPaymentDAO'); $completedPayment =& $this->createCompletedPayment($queuedPayment, $payMethodPluginName); $completedPaymentDao->insertCompletedPayment($completedPayment); $queuedPaymentDao =& DAORegistry::getDAO('QueuedPaymentDAO'); $queuedPaymentDao->deleteQueuedPayment($queuedPayment->getQueuedPaymentId()); return $returner; }
/** * Send the registration confirmation email. * @param $user object */ function sendConfirmationEmail($user, $password, $sendPassword) { $schedConf =& Request::getSchedConf(); import('mail.MailTemplate'); if (Config::getVar('email', 'require_validation')) { // Create an access key import('security.AccessKeyManager'); $accessKeyManager = new AccessKeyManager(); $accessKey = $accessKeyManager->createKey('RegisterContext', $user->getId(), null, Config::getVar('email', 'validation_timeout')); // Send email validation request to user $mail = new MailTemplate('USER_VALIDATE'); $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName')); $mail->assignParams(array('userFullName' => $user->getFullName(), 'activateUrl' => Request::url(null, null, 'user', 'activateUser', array($user->getUsername(), $accessKey)))); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); unset($mail); } if ($sendPassword) { // Send welcome email to user $mail = new MailTemplate('USER_REGISTER'); $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName')); $mail->assignParams(array('username' => $user->getUsername(), 'password' => String::substr($password, 0, 30))); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); unset($mail); } }
/** * 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(); import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationManager->createTrivialNotification('notification.notification', 'plugins.generic.booksForReview.notification.authorRemoved'); $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->setFrom($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); }
/** * Helper function - set mail From * can be overriden by child classes * @param MailTemplate $mail */ function _setMailFrom(&$mail) { $site =& Request::getSite(); $mail->setFrom($site->getLocalizedContactEmail(), $site->getLocalizedContactName()); return true; }
/** * Send an email to a user regarding the notification * @param $notification object Notification */ function sendNotificationEmail($notification) { $userId = $notification->getUserId(); $userDao =& DAORegistry::getDAO('UserDAO'); $user = $userDao->getUser($userId); Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON)); if ($notification->getIsLocalized()) { $params = array('param' => $notification->getParam()); $notificationTitle = Locale::translate($notification->getTitle(), $params); $notificationContents = Locale::translate($notification->getContents(), $params); } else { $notificationTitle = $notification->getTitle(); $notificationContents = $notification->getContents(); } import('classes.mail.MailTemplate'); $site =& Request::getSite(); $mail = new MailTemplate('NOTIFICATION'); $mail->setFrom($site->getLocalizedContactEmail(), $site->getLocalizedContactName()); $mail->assignParams(array('notificationTitle' => $notificationTitle, 'notificationContents' => $notificationContents, 'url' => $notification->getLocation(), 'siteTitle' => $site->getLocalizedTitle())); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); }
/** * 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(); } }
/** * Handle incoming requests/notifications */ function handle($args) { $conference =& Request::getConference(); $schedConf =& Request::getSchedConf(); $templateMgr =& TemplateManager::getManager(); $user =& Request::getUser(); $op = isset($args[0]) ? $args[0] : null; $queuedPaymentId = isset($args[1]) ? (int) $args[1] : 0; import('payment.ocs.OCSPaymentManager'); $ocsPaymentManager =& OCSPaymentManager::getManager(); $queuedPayment =& $ocsPaymentManager->getQueuedPayment($queuedPaymentId); // if the queued payment doesn't exist, redirect away from payments if (!$queuedPayment) { Request::redirect(null, null, null, 'index'); } switch ($op) { case 'notify': import('mail.MailTemplate'); Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON)); $contactName = $schedConf->getSetting('registrationName'); $contactEmail = $schedConf->getSetting('registrationEmail'); $mail = new MailTemplate('MANUAL_PAYMENT_NOTIFICATION'); $mail->setFrom($contactEmail, $contactName); $mail->addRecipient($contactEmail, $contactName); $mail->assignParams(array('schedConfName' => $schedConf->getFullTitle(), 'userFullName' => $user ? $user->getFullName() : '(' . Locale::translate('common.none') . ')', 'userName' => $user ? $user->getUsername() : '(' . Locale::translate('common.none') . ')', 'itemName' => $queuedPayment->getName(), 'itemCost' => $queuedPayment->getAmount(), 'itemCurrencyCode' => $queuedPayment->getCurrencyCode())); $mail->send(); $templateMgr->assign(array('currentUrl' => Request::url(null, null, null, 'payment', 'plugin', array('notify', $queuedPaymentId)), 'pageTitle' => 'plugins.paymethod.manual.paymentNotification', 'message' => 'plugins.paymethod.manual.notificationSent', 'backLink' => $queuedPayment->getRequestUrl(), 'backLinkLabel' => 'common.continue')); $templateMgr->display('common/message.tpl'); exit; break; } parent::handle($args); // Don't know what to do with it }
/** * 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(); } }
/** * Save review assignment * @param $args array * @param $request PKPRequest */ function execute($args, &$request) { $seriesEditorSubmissionDao =& DAORegistry::getDAO('SeriesEditorSubmissionDAO'); $submission =& $seriesEditorSubmissionDao->getSeriesEditorSubmission($this->getMonographId()); $press =& $request->getPress(); $reviewType = $this->getData('reviewType'); $round = $this->getData('round'); $reviewDueDate = $this->getData('reviewDueDate'); $responseDueDate = $this->getData('responseDueDate'); $selectionType = (int) $this->getData('selectionType'); if ($selectionType == REVIEWER_SELECT_CREATE) { $userDao =& DAORegistry::getDAO('UserDAO'); $user = new User(); $user->setFirstName($this->getData('firstname')); $user->setMiddleName($this->getData('middlename')); $user->setLastName($this->getData('lastname')); $user->setEmail($this->getData('email')); $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $auth =& $authDao->getDefaultPlugin(); $user->setAuthId($auth ? $auth->getAuthId() : 0); $user->setUsername($this->getData('username')); $password = Validation::generatePassword(); 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()); $reviewerId = $userDao->insertUser($user); // Add reviewer interests to interests table $interestDao =& DAORegistry::getDAO('InterestDAO'); $interests = Request::getUserVar('interestsKeywords'); $interests = array_map('urldecode', $interests); // The interests are coming in encoded -- Decode them for DB storage if (empty($interests)) { $interests = array(); } elseif (!is_array($interests)) { $interests = array($interests); } $interestDao->insertInterests($interests, $reviewerId, true); // Assign the selected user group ID to the user $userGroupDao =& DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */ $userGroupId = (int) $this->getData('userGroupId'); $userGroupDao->assignUserToGroup($reviewerId, $userGroupId); if ($this->getData('sendNotify')) { // Send welcome email to user import('classes.mail.MailTemplate'); $mail = new MailTemplate('REVIEWER_REGISTER'); $mail->setFrom($press->getSetting('contactEmail'), $press->getSetting('contactName')); $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName())); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } } elseif ($selectionType == REVIEWER_SELECT_ENROLL) { // Assign a reviewer user group to an existing non-reviewer $userId = $this->getData('userId'); $userGroupId = $this->getData('userGroupId'); $userGroupId = $this->getData('userGroupId'); $userGroupDao =& DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */ $userGroupDao->assignUserToGroup($userId, $userGroupId); // Set the reviewerId to the userId to return to the grid $reviewerId = $userId; } else { $reviewerId = $this->getData('reviewerId'); } import('classes.submission.seriesEditor.SeriesEditorAction'); SeriesEditorAction::addReviewer($submission, $reviewerId, $reviewType, $round, $reviewDueDate, $responseDueDate); // Get the reviewAssignment object now that it has been added $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewAssignment =& $reviewAssignmentDao->getReviewAssignment($submission->getId(), $reviewerId, $round, $reviewType); $reviewAssignment->setDateNotified(Core::getCurrentDate()); $reviewAssignment->setCancelled(0); $reviewAssignment->stampModified(); $reviewAssignmentDao->updateObject($reviewAssignment); // Update the review round status if this is the first reviewer added $reviewRoundDao =& DAORegistry::getDAO('ReviewRoundDAO'); $currentReviewRound =& $reviewRoundDao->build($this->getMonographId(), $submission->getCurrentReviewType(), $submission->getCurrentRound()); if ($currentReviewRound->getStatus() == REVIEW_ROUND_STATUS_PENDING_REVIEWERS) { $currentReviewRound->setStatus(REVIEW_ROUND_STATUS_PENDING_REVIEWS); $reviewRoundDao->updateObject($currentReviewRound); } return $reviewAssignment; }
/** * 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; }
/** * Send notification email to Subscription Manager when online payment is completed. */ function sendOnlinePaymentNotificationEmail(&$subscription, $mailTemplateKey) { $validKeys = array('SUBSCRIPTION_PURCHASE_INDL', 'SUBSCRIPTION_PURCHASE_INSTL', 'SUBSCRIPTION_RENEW_INDL', 'SUBSCRIPTION_RENEW_INSTL'); if (!in_array($mailTemplateKey, $validKeys)) { return false; } $journal =& Request::getJournal(); $subscriptionContactName = $journal->getSetting('subscriptionName'); $subscriptionContactEmail = $journal->getSetting('subscriptionEmail'); if (empty($subscriptionContactEmail)) { $subscriptionContactEmail = $journal->getSetting('contactEmail'); $subscriptionContactName = $journal->getSetting('contactName'); } if (empty($subscriptionContactEmail)) { return false; } $userDao =& DAORegistry::getDAO('UserDAO'); $user =& $userDao->getUser($subscription->getUserId()); $subscriptionTypeDao =& DAORegistry::getDAO('SubscriptionTypeDAO'); $subscriptionType =& $subscriptionTypeDao->getSubscriptionType($subscription->getTypeId()); $roleDao =& DAORegistry::getDAO('RoleDAO'); if ($roleDao->getJournalUsersRoleCount($journal->getId(), ROLE_ID_SUBSCRIPTION_MANAGER) > 0) { $rolePath = $roleDao->getRolePath(ROLE_ID_SUBSCRIPTION_MANAGER); } else { $rolePath = $roleDao->getRolePath(ROLE_ID_JOURNAL_MANAGER); } $paramArray = array('subscriptionType' => $subscriptionType->getSummaryString(), 'userDetails' => $user->getContactSignature(), 'membership' => $subscription->getMembership()); switch ($mailTemplateKey) { case 'SUBSCRIPTION_PURCHASE_INDL': case 'SUBSCRIPTION_RENEW_INDL': $paramArray['subscriptionUrl'] = Request::url($journal->getPath(), $rolePath, 'editSubscription', 'individual', array($subscription->getId())); break; case 'SUBSCRIPTION_PURCHASE_INSTL': case 'SUBSCRIPTION_RENEW_INSTL': $paramArray['subscriptionUrl'] = Request::url($journal->getPath(), $rolePath, 'editSubscription', 'institutional', array($subscription->getId())); $paramArray['institutionName'] = $subscription->getInstitutionName(); $paramArray['institutionMailingAddress'] = $subscription->getInstitutionMailingAddress(); $paramArray['domain'] = $subscription->getDomain(); $paramArray['ipRanges'] = $subscription->getIPRangesString(); break; } import('classes.mail.MailTemplate'); $mail = new MailTemplate($mailTemplateKey); $mail->setFrom($subscriptionContactEmail, $subscriptionContactName); $mail->addRecipient($subscriptionContactEmail, $subscriptionContactName); $mail->setSubject($mail->getSubject($journal->getPrimaryLocale())); $mail->setBody($mail->getBody($journal->getPrimaryLocale())); $mail->assignParams($paramArray); $mail->send(); }
/** * Import the parsed users into the system. * @param $sendNotify boolean send an email notification to each imported user containing their username and password * @param $continueOnError boolean continue to import remaining users if a failure occurs * @return boolean success */ function importUsers($sendNotify = false, $continueOnError = false) { $success = true; $this->importedUsers = array(); $this->errors = array(); $userDao =& DAORegistry::getDAO('UserDAO'); $roleDao =& DAORegistry::getDAO('RoleDAO'); if ($sendNotify) { // Set up mail template to send to added users import('classes.mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTER'); $journalDao =& DAORegistry::getDAO('JournalDAO'); $journal =& $journalDao->getById($this->journalId); $mail->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); } for ($i = 0, $count = count($this->usersToImport); $i < $count; $i++) { $user =& $this->usersToImport[$i]; // If the email address already exists in the system, // then assign the user the username associated with that email address. if ($user->getEmail() != null) { $emailExists = $userDao->getUserByEmail($user->getEmail(), true); if ($emailExists != null) { $user->setUsername($emailExists->getUsername()); } } if ($user->getUsername() == null) { $newUsername = true; $this->generateUsername($user); } else { $newUsername = false; } if ($user->getUnencryptedPassword() != null) { $user->setPassword(Validation::encryptCredentials($user->getUsername(), $user->getUnencryptedPassword())); } else { if ($user->getPassword() == null) { $this->generatePassword($user); } } if (!$newUsername) { // Check if user already exists $userExists = $userDao->getByUsername($user->getUsername(), true); if ($userExists != null) { $user->setId($userExists->getId()); } } else { $userExists = false; } if ($newUsername || !$userExists) { // Create new user account // If the user's username was specified in the data file and // the username already exists, only the new roles are added for that user if (!$userDao->insertUser($user)) { // Failed to add user! $this->errors[] = sprintf('%s: %s (%s)', __('manager.people.importUsers.failedToImportUser'), $user->getFullName(), $user->getUsername()); if ($continueOnError) { // Skip to next user $success = false; continue; } else { return false; } } } // Add reviewing interests to interests table $interestDao =& DAORegistry::getDAO('InterestDAO'); $interests = $user->getTemporaryInterests(); $interests = explode(',', $interests); $interests = array_map('trim', $interests); // Trim leading whitespace if (is_array($interests) && !empty($interests)) { $interestDao->setUserInterests($interests, $user->getId()); } // Enroll user in specified roles // If the user is already enrolled in a role, that role is skipped foreach ($user->getRoles() as $role) { $role->setUserId($user->getId()); $role->setJournalId($this->journalId); if (!$roleDao->userHasRole($role->getJournalId(), $role->getUserId(), $role->getRoleId())) { if (!$roleDao->insertRole($role)) { // Failed to add role! $this->errors[] = sprintf('%s: %s - %s (%s)', __('manager.people.importUsers.failedToImportRole'), $role->getRoleName(), $user->getFullName(), $user->getUsername()); if ($continueOnError) { // Continue to insert other roles for this user $success = false; continue; } else { return false; } } } } if ($sendNotify && !$userExists) { // Send email notification to user as if user just registered themselves $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->sendWithParams(array('journalName' => $journal->getTitle($journal->getPrimaryLocale()), 'username' => $user->getUsername(), 'password' => $user->getUnencryptedPassword() == null ? '-' : $user->getUnencryptedPassword(), 'userFullName' => $user->getFullName())); $mail->clearRecipients(); } array_push($this->importedUsers, $user); } return $success; }
/** * Register a new user. */ function execute() { $userDao =& DAORegistry::getDAO('UserDAO'); $journal =& Request::getJournal(); if (isset($this->userId)) { $user =& $userDao->getUser($this->userId); } if (!isset($user)) { $user = new User(); } $user->setSalutation($this->getData('salutation')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setLastName($this->getData('lastName')); $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->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); $user->setAuthId((int) $this->getData('authId')); $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); if ($user->getAuthId()) { $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $auth =& $authDao->getPlugin($user->getAuthId()); } if ($user->getId() != null) { $userId = $user->getId(); if ($this->getData('password') !== '') { if (isset($auth)) { $auth->doSetUserPassword($user->getUsername(), $this->getData('password')); $user->setPassword(Validation::encryptCredentials($userId, 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->insertUser($user); $isManager = Validation::isJournalManager(); // EL on March 13th 2013 // If this is used, it should be totally modified if (!empty($this->_data['enrollAs'])) { foreach ($this->getData('enrollAs') as $roleName) { // Enroll new user into an initial role $roleDao =& DAORegistry::getDAO('RoleDAO'); $roleId = $roleDao->getRoleIdFromPath($roleName); if (!$isManager && $roleId != ROLE_ID_READER) { continue; } if ($roleId != null) { $role = new Role(); $role->setJournalId($journal->getId()); $role->setUserId($userId); $role->setRoleId($roleId); $roleDao->insertRole($role); } } } if ($sendNotify) { // Send welcome email to user import('classes.mail.MailTemplate'); $mail = new MailTemplate('USER_REGISTER'); $mail->setFrom($journal->getSetting('supportEmail'), $journal->getSetting('supportName')); $mail->assignParams(array('username' => $this->getData('username'), 'password' => String::substr($this->getData('password'), 0, 30), 'supportName' => $journal->getSetting('supportName'), 'userFullName' => $user->getFullName())); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } } // 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, $userId, true); } }
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(); }
/** * Save registration. */ function execute() { $registrationDao =& DAORegistry::getDAO('RegistrationDAO'); $schedConf =& Request::getSchedConf(); if (isset($this->registrationId)) { $registration =& $registrationDao->getRegistration($this->registrationId); } if (!isset($registration)) { $registration = new Registration(); $registration->setDateRegistered(time()); } $registration->setSchedConfId($schedConf->getId()); $registration->setUserId($this->getData('userId')); $registration->setTypeId($this->getData('typeId')); $registration->setApplicationForm($this->getData('applicationForm')); $registration->setSurvey($this->getData('survey')); $registration->setMembership($this->getData('membership') ? $this->getData('membership') : null); $registration->setDomain($this->getData('domain') ? $this->getData('domain') : null); $registration->setIPRange($this->getData('ipRange') ? $this->getData('ipRange') : null); $registration->setSpecialRequests($this->getData('specialRequests') ? $this->getData('specialRequests') : null); // Send an email to the registrant informing them that their payment was received if ($this->getData('notifyPaymentEmail')) { $userDao =& DAORegistry::getDAO('UserDAO'); $schedConfName = $schedConf->getSchedConfTitle(); $schedConfId = $schedConf->getId(); $user =& $userDao->getUser($this->getData('userId')); list($registrationEmail, $registrationName, $registrationContactSignature) = $this->getRegistrationContactInformation($schedConfId); $paramArray = array('registrantName' => $user->getFullName(), 'schedConfName' => $schedConfName, 'registrationContactSignature' => $registrationContactSignature); import('mail.MailTemplate'); $mail = new MailTemplate('MANUAL_PAYMENT_RECEIVED'); $mail->setFrom($registrationEmail, $registrationName); $mail->assignParams($paramArray); $mail->addRecipient($user->getEmail(), $user->getFullName()); $mail->send(); } $registration->setDatePaid($this->getData('datePaid')); // Update or insert registration if ($registration->getId() != null) { $registrationDao->updateRegistration($registration); } else { $registrationDao->insertRegistration($registration); } $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO'); $registrationOptions =& $registrationOptionDao->getRegistrationOptionsBySchedConfId($schedConf->getId()); $registrationOptionIds = (array) $this->getData('registrationOptionIds'); $registrationOptionDao->deleteRegistrationOptionAssocByRegistrationId($this->registrationId); while ($registrationOption =& $registrationOptions->next()) { $optionId = (int) $registrationOption->getOptionId(); if (in_array($optionId, $registrationOptionIds)) { $registrationOptionDao->insertRegistrationOptionAssoc($this->registrationId, $registrationOption->getOptionId()); } unset($registrationOption); } if ($this->getData('notifyEmail')) { // Send user registration notification email $userDao =& DAORegistry::getDAO('UserDAO'); $registrationTypeDao =& DAORegistry::getDAO('RegistrationTypeDAO'); $schedConfName = $schedConf->getSchedConfTitle(); $schedConfId = $schedConf->getId(); $user =& $userDao->getUser($this->getData('userId')); $registrationType =& $registrationTypeDao->getRegistrationType($this->getData('typeId')); list($registrationEmail, $registrationName, $registrationContactSignature) = $this->getRegistrationContactInformation($schedConfId); $paramArray = array('registrantName' => $user->getFullName(), 'schedConfName' => $schedConfName, 'registrationType' => $registrationType->getSummaryString(), '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(); } }