コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * 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();
     }
 }
コード例 #3
0
ファイル: MeetingAction.inc.php プロジェクト: elavaud/hrp_ct
 /**
  * Notify an investigator of a new meeting set by section editor
  * Added by EL on February 28th 2013
  * And moved from SectionEditorAction to here
  */
 function notifyInvestigatorMeeting($meeting, $informationType, $investigatorAttendance, $attendanceIncrementNumber, $mSectionDecisions, $send = false)
 {
     $journal =& Request::getJournal();
     $user =& Request::getUser();
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $sectionDecisionDao =& DAORegistry::getDAO('SectionDecisionDAO');
     $num = 1;
     $submissions = (string) '';
     foreach ($mSectionDecisions as $mSectionDecision) {
         $sectionDecision = $sectionDecisionDao->getSectionDecision($mSectionDecision->getSectionDecisionId());
         $submission = $articleDao->getArticle($sectionDecision->getArticleId(), $journal->getId(), false);
         if ($submission->getUserId() == $investigatorAttendance->getUserId()) {
             $submissions .= $num . ". '" . $submission->getScientificTitle() . "'\n";
             $num++;
         }
     }
     $userDao =& DAORegistry::getDAO('UserDAO');
     $investigator =& $userDao->getUser($investigatorAttendance->getUserId());
     import('classes.mail.MailTemplate');
     $email = new MailTemplate($informationType);
     if ($send && !$email->hasErrors()) {
         HookRegistry::call('MeetingAction::notifyInvestigatorMeeting', array(&$meeting, &$informationType, &$investigator, $attendanceIncrementNumber, &$submissions, &$email));
         $email->send();
         return true;
     } else {
         if (!Request::getUserVar('continued')) {
             // Add email of the submitter
             $email->addRecipient($investigator->getEmail(), $investigator->getFullName());
             // Add emails of the investigator(s) if different from the submitter
             foreach ($mSectionDecisions as $mSectionDecision) {
                 $sectionDecision = $sectionDecisionDao->getSectionDecision($mSectionDecision->getSectionDecisionId());
                 $submission = $articleDao->getArticle($sectionDecision->getArticleId(), $journal->getId(), false);
                 if ($submission->getUserId() == $investigatorAttendance->getUserId()) {
                     $authors = $submission->getAuthors();
                     foreach ($authors as $author) {
                         if ($author->getEmail() != $investigator->getEmail()) {
                             $email->addRecipient($author->getEmail(), $author->getFirstName() . ' ' . $author->getLastName());
                         }
                     }
                 }
             }
         }
         // CC the secretary(ies) of the committee
         $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
         $secretaries =& $sectionEditorsDao->getEditorsBySectionId($journal->getId(), $user->getSecretaryCommitteeId());
         foreach ($secretaries as $secretary) {
             $email->addCc($secretary->getEmail(), $secretary->getFullName());
         }
         if (!Request::getUserVar('continued')) {
             $dateLocation = (string) '';
             if ($meeting->getDate() != null) {
                 $dateLocation .= Locale::translate('editor.reports.meetingDate') . ': ' . strftime('%B %d, %Y %I:%M %p', strtotime($meeting->getDate())) . "\n";
             }
             if ($meeting->getLength() != null) {
                 $dateLocation .= Locale::translate('editor.meeting.length') . ': ' . $meeting->getLength() . "mn\n";
             }
             if ($meeting->getLocation() != null) {
                 $dateLocation .= Locale::translate('editor.meeting.location') . ': ' . $meeting->getLocation() . "\n";
             }
             $dateLocation .= Locale::translate('editor.meeting.numberOfProposalsToReview') . ': ' . count($mSectionDecisions) . "\n";
             $replyUrl = (string) '';
             $investigatorFullName = (string) $investigator->getFullName();
             $urlFirst = true;
             foreach ($mSectionDecisions as $mSectionDecision) {
                 $sectionDecision = $sectionDecisionDao->getSectionDecision($mSectionDecision->getSectionDecisionId());
                 $submission = $articleDao->getArticle($sectionDecision->getArticleId(), $journal->getId(), false);
                 if ($urlFirst) {
                     $replyUrl .= Request::url(null, 'author', 'submission', array($sectionDecision->getArticleId(), 'submissionReview'));
                     $urlFirst = false;
                 } else {
                     $replyUrl .= '    ' . Locale::translate("common.or") . ':    ' . Request::url(null, 'author', 'submission', array($sectionDecision->getArticleId(), 'submissionReview'));
                 }
                 // Add name of the investigators if different from submitter
                 if ($submission->getUserId() == $investigatorAttendance->getUserId()) {
                     $authors = $submission->getAuthors();
                     foreach ($authors as $author) {
                         if ($author->getFirstName() != $investigator->getFirstName() || $author->getLastName() != $investigator->getLastName()) {
                             $investigatorFullName .= ', ' . $author->getFirstName() . ' ' . $author->getLastName();
                         }
                     }
                 }
             }
             $sectionDao =& DAORegistry::getDAO('SectionDAO');
             $erc =& $sectionDao->getSection($meeting->getUploader());
             $paramArray = array('ercTitle' => $erc->getLocalizedTitle(), 'investigatorFullName' => $investigatorFullName, 'submissions' => $submissions, 'dateLocation' => $dateLocation, 'replyUrl' => nl2br($replyUrl), 'secretaryName' => $user->getFullName(), 'secretaryFunctions' => $user->getErcFunction($meeting->getUploader()));
             $email->assignParams($paramArray);
         }
         $email->displayEditForm(Request::url(null, null, 'notifyInvestigatorsMeeting', array($meeting->getId(), $attendanceIncrementNumber, $informationType)));
         return false;
     }
     return true;
 }