Пример #1
0
 /**
  * This will QUEUE a message for delivery.
  * @param string $strToAddress
  * @param string $strFromAddress if null, it will look up from Registry
  * @param string $strSubject
  * @param string $strBody
  * @param string $strCc
  * @param string $strBcc
  */
 public static function QueueMessage($strToAddress, $strFromAddress, $strSubject, $strBody, $strCc = null, $strBcc = null)
 {
     $objEmailMessage = new OutgoingEmailQueue();
     $objEmailMessage->ToAddress = $strToAddress;
     $objEmailMessage->FromAddress = $strFromAddress ? $strFromAddress : Registry::GetValue('system_email_address');
     $objEmailMessage->CcAddress = $strCc;
     $objEmailMessage->BccAddress = $strBcc;
     $objEmailMessage->Subject = $strSubject;
     $objEmailMessage->Body = $strBody;
     $objEmailMessage->DateQueued = QDateTime::Now();
     $objEmailMessage->ErrorFlag = false;
     $objEmailMessage->Save();
 }
Пример #2
0
 /**
  * This queues up and sends an email requesting the registrant to confirm
  * the registration.
  */
 public function SendConfirmationEmail()
 {
     // Template
     $strTemplateName = 'registration';
     // Calculate Email Address - THIS WILL RETURN if none is found
     $strFromAddress = 'ALCF my.alcf Registration <*****@*****.**>';
     $strToAddress = $this->strEmailAddress;
     $strSubject = 'Your Online Registration';
     // Setup the SubstitutionArray
     $strArray = array();
     // Setup Always-Used Fields
     $strArray['PERSON_NAME'] = $this->strFirstName . ' ' . $this->strLastName;
     // Add Payment Info
     $strArray['URL'] = $this->ConfirmationUrl . '/' . $this->strConfirmationCode;
     $strArray['CODE'] = $this->strConfirmationCode;
     $strArray['USERNAME'] = $this->PublicLogin->Username;
     $strArray['CONTACT'] = strip_tags(Registry::GetValue('contact_sentence_my_alcf_support'));
     OutgoingEmailQueue::QueueFromTemplate($strTemplateName, $strArray, $strToAddress, $strFromAddress, $strSubject);
 }
Пример #3
0
 /**
  * This will reset this publiclogin's password and will email the new password to the email account on file.
  * If no primary email address this will throw an exception.
  * @return string
  */
 public function ResetPassword()
 {
     if (!$this->Person->PrimaryEmail->Address) {
         throw new QCallerException('ResetPassword for a PublicLogin record with no attached primary email: ' . $this->Id);
     }
     $strTemporaryPassword = str_replace('0', '', str_replace('1', '', md5(microtime())));
     $strTemporaryPassword = substr($strTemporaryPassword, 0, 6);
     $this->SetPassword($strTemporaryPassword);
     $this->TemporaryPasswordFlag = true;
     $this->Save();
     // Setup email info
     $strFromAddress = 'ALCF my.alcf Account Support <*****@*****.**>';
     $strToAddress = $this->Person->PrimaryEmail->Address;
     $strSubject = 'Account Support: Your Temporary Password';
     // Setup the SubstitutionArray
     $strArray = array();
     // Setup Always-Used Fields
     $strArray['PERSON_NAME'] = $this->Person->Name;
     $strArray['PASSWORD'] = $strTemporaryPassword;
     $strArray['CONTACT'] = strip_tags(Registry::GetValue('contact_sentence_my_alcf_support'));
     OutgoingEmailQueue::QueueFromTemplate('reset_password', $strArray, $strToAddress, $strFromAddress, $strSubject);
     return $strTemporaryPassword;
 }
Пример #4
0
<?php

// Up the Memory Limit
ini_set('memory_limit', '256M');
// Ensure we are NOT running
QApplication::CliProcessEnsureUnique();
// Setup a Lock File
QApplication::CliProcessSetupLockFile();
// Run the Logic/Code
while (QApplication::CliProcessIsLockFileValid()) {
    // Analyze only 10 at a time, starting with the oldest (E.g. lowest ID) first
    $objMessageArray = OutgoingEmailQueue::LoadArrayByErrorFlag(false, array(QQ::OrderBy(QQN::OutgoingEmailQueue()->Id), QQ::LimitInfo(10)));
    foreach ($objMessageArray as $objMessage) {
        // Send up to 100 at a time for any given EmailMessage
        $objMessage->Send();
    }
    sleep(10);
}
Пример #5
0
 /**
  * This will send a confirmation email for the OnlineDonation item
  * @param string $strToAddress an explicitly set EmailAddress to send, or if null, it will try and deduce it from the attached person record
  */
 public function SendConfirmationEmail($strToAddress = null)
 {
     // Template
     $strTemplateName = 'online_donation';
     // Calculate Email Address - THIS WILL RETURN if none is found
     $strFromAddress = 'ALCF Online Donation <*****@*****.**>';
     if (!$strToAddress) {
         $strToAddress = $this->CalculateConfirmationEmailAddress();
     }
     if (!$strToAddress) {
         return;
     }
     $strSubject = 'Your Online Donation';
     // Setup the SubstitutionArray
     $strArray = array();
     // Setup Always-Used Fields
     $strArray['PERSON_NAME'] = $this->Person->Name;
     $strArray['ONLINE_DONATION_ID'] = sprintf('%05s', $this->Id);
     // Add Payment Info
     $strArray['AMOUNT'] = QApplication::DisplayCurrency($this->Amount);
     $strArray['CREDIT_CARD'] = $this->CreditCardPayment->CreditCardDescription;
     $strProductArray = array();
     foreach ($this->GetOnlineDonationLineItemArray() as $objLineItem) {
         $strProductArray[] = sprintf('%s  -  %s', $objLineItem->StewardshipFund ? $objLineItem->StewardshipFund->ExternalName : $objLineItem->Other, QApplication::DisplayCurrency($objLineItem->Amount));
     }
     $strArray['PAYMENT_ITEMS'] = implode("\r\n", $strProductArray);
     OutgoingEmailQueue::QueueFromTemplate($strTemplateName, $strArray, $strToAddress, $strFromAddress, $strSubject, null, trim(Registry::GetValue('donation_receipt_bcc')));
 }
Пример #6
0
 /**
  * Queues a "confirmation email" to be sent out to the person signing up
  * @param SignupPayment $objSignupPayment an OPTIONAL SignupPayment for the payment that was "just submitted" and to be incorporated into the email message
  */
 public function SendConfirmationEmail(SignupPayment $objSignupPayment = null)
 {
     // Setup the SubstitutionArray
     $strArray = array();
     // Setup Always-Used Fields
     if (!$this->PersonId) {
         $strArray['PERSON_NAME'] = sprintf("%s %s", $this->CommunicationsEntry->FirstName, $this->CommunicationsEntry->LastName);
     } else {
         $strArray['PERSON_NAME'] = $this->Person->Name;
     }
     $strArray['SIGNUP_FORM_NAME'] = $this->SignupForm->Name;
     $strArray['SIGNUP_ENTRY_ID'] = sprintf('%05s', $this->Id);
     $strArray['SUPPORT_EMAIL'] = $this->SignupForm->SupportEmail;
     // Add a Description
     $strArray['SIGNUP_DESCRIPTION'] = null;
     if ($strDescription = trim($this->SignupForm->Description)) {
         $strArray['SIGNUP_DESCRIPTION'] = $strDescription;
     } else {
         switch ($this->SignupForm->SignupFormTypeId) {
             case SignupFormType::Event:
                 if ($strDescription = $this->SignupForm->EventSignupForm->GeneratedDescription) {
                     $strArray['SIGNUP_DESCRIPTION'] = 'Event ' . trim(substr($strDescription, 1)) . '.';
                 }
                 break;
         }
     }
     // Add URL to the Description (if applicable)
     if ($strUrl = trim($this->SignupForm->InformationUrl)) {
         $strArray['SIGNUP_DESCRIPTION'] = trim($strArray['SIGNUP_DESCRIPTION'] . '  For more information, please go to ' . $strUrl);
     }
     // Add Payment Info (if applicable)
     if ($objSignupPayment) {
         $strArray['AMOUNT'] = QApplication::DisplayCurrency($objSignupPayment->Amount);
         $strArray['CREDIT_CARD'] = $objSignupPayment->TransactionDescription;
         $strProductArray = array();
         foreach ($this->GetSignupProductArray(QQ::OrderBy(QQN::SignupProduct()->FormProduct->FormProductTypeId, QQN::SignupProduct()->FormProduct->OrderNumber)) as $objSignupProduct) {
             $strProductArray[] = sprintf('%s  -  Qty %s  -  %s', $objSignupProduct->FormProduct->Name, $objSignupProduct->Quantity, QApplication::DisplayCurrency($objSignupProduct->Quantity * $objSignupProduct->Amount));
         }
         $strArray['PAYMENT_ITEMS'] = implode("\r\n", $strProductArray);
         $strTemplateName = 'signup_entry_paid';
     } else {
         $strTemplateName = 'signup_entry_unpaid';
     }
     // Calculate Email Address
     $strFromAddress = 'ALCF Signup System <*****@*****.**>';
     if (!($strToAddress = $this->CalculateConfirmationEmailAddress())) {
         $strToAddress = $strFromAddress;
     }
     $strBccAddress = trim($this->SignupForm->EmailNotification);
     $strSubject = 'Your Signup for ' . $this->SignupForm->Name;
     OutgoingEmailQueue::QueueFromTemplate($strTemplateName, $strArray, $strToAddress, $strFromAddress, $strSubject, null, $strBccAddress);
 }
Пример #7
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, OutgoingEmailQueue::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
 /**
  * Main utility method to aid with data binding.  It is used by the default BindAllRows() databinder but
  * could and should be used by any custom databind methods that would be used for instances of this
  * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. 
  *
  * If a paginator is set on this DataBinder, it will use it.  If not, then no pagination will be used.
  * It will also perform any sorting (if applicable).
  *
  * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself
  * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query		 
  * @return void
  */
 public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null)
 {
     // Setup input parameters to default values if none passed in
     if (!$objCondition) {
         $objCondition = QQ::All();
     }
     $objClauses = $objOptionalClauses ? $objOptionalClauses : array();
     // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = OutgoingEmailQueue::QueryCount($objCondition, $objClauses);
     }
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be a Query result from OutgoingEmailQueue, given the clauses above
     $this->DataSource = OutgoingEmailQueue::QueryArray($objCondition, $objClauses);
 }
 /**
  * Static Helper Method to Create using PK arguments
  * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
  * edit, or if we are also allowed to create a new one, etc.
  * 
  * @param mixed $objParentObject QForm or QPanel which will be using this OutgoingEmailQueueMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing OutgoingEmailQueue object creation - defaults to CreateOrEdit
  * @return OutgoingEmailQueueMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objOutgoingEmailQueue = OutgoingEmailQueue::Load($intId);
         // OutgoingEmailQueue was found -- return it!
         if ($objOutgoingEmailQueue) {
             return new OutgoingEmailQueueMetaControl($objParentObject, $objOutgoingEmailQueue);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a OutgoingEmailQueue object with PK arguments: ' . $intId);
             }
         }
         // If EditOnly is specified, throw an exception
     } else {
         if ($intCreateType == QMetaControlCreateType::EditOnly) {
             throw new QCallerException('No PK arguments specified');
         }
     }
     // If we are here, then we need to create a new record
     return new OutgoingEmailQueueMetaControl($objParentObject, new OutgoingEmailQueue());
 }