/** * 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 EmailOutgoingQueueMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing EmailOutgoingQueue object creation - defaults to CreateOrEdit * @return EmailOutgoingQueueMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objEmailOutgoingQueue = EmailOutgoingQueue::Load($intId); // EmailOutgoingQueue was found -- return it! if ($objEmailOutgoingQueue) { return new EmailOutgoingQueueMetaControl($objParentObject, $objEmailOutgoingQueue); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a EmailOutgoingQueue 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 EmailOutgoingQueueMetaControl($objParentObject, new EmailOutgoingQueue()); }
public function QueueMessages() { if ($this->Group) { foreach ($this->Group->GetActiveGroupParticipationArray() as $objParticipation) { $objPerson = $objParticipation->Person; EmailOutgoingQueue::QueueMessage($this->EmailMessage, $this->Group->Token, $objPerson); // GJS: At this point, also check if there is a co-primary and include them to the list if ($objPerson->DateOfBirth && $objPerson->CoPrimary) { $objCoPrimary = Person::Load($objPerson->CoPrimary); if ($objCoPrimary) { EmailOutgoingQueue::QueueMessage($this->EmailMessage, $this->Group->Token, $objCoPrimary); } } } foreach ($this->Group->Ministry->GetLoginArray() as $objLogin) { if ($objLogin->DomainActiveFlag && $objLogin->LoginActiveFlag) { EmailOutgoingQueue::QueueMessage($this->EmailMessage, $this->Group->Token, $objLogin); } } } else { if ($this->CommunicationList) { foreach ($this->CommunicationList->GetPersonArray() as $objPerson) { EmailOutgoingQueue::QueueMessage($this->EmailMessage, $this->CommunicationList->Token, $objPerson); } foreach ($this->CommunicationList->GetCommunicationListEntryArray() as $objCommunicationListEntry) { EmailOutgoingQueue::QueueMessage($this->EmailMessage, $this->CommunicationList->Token, $objCommunicationListEntry); } foreach ($this->CommunicationList->Ministry->GetLoginArray() as $objLogin) { if ($objLogin->DomainActiveFlag && $objLogin->LoginActiveFlag) { EmailOutgoingQueue::QueueMessage($this->EmailMessage, $this->CommunicationList->Token, $objLogin); } } } } }
/** * 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 = EmailOutgoingQueue::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 EmailOutgoingQueue, given the clauses above $this->DataSource = EmailOutgoingQueue::QueryArray($objCondition, $objClauses); }
/** * This will analyze a NotYetAnalyzed message, doing the appropriate * things to setup links to related objects, queueing outgoing messages, etc. * * This will throw an exception if its MessageType is NOT NotYetAnalyzed. * @return void */ public function AnalyzeMessage() { if ($this->intEmailMessageStatusTypeId != EmailMessageStatusType::NotYetAnalyzed) { throw new QCallerException('EmailMessage that is NOT in NotYetAnalyzed status cannot be Analyzed'); } // Do Initial Cleanup and Setup Work $this->CleanupAndSetup(); // Check MessageId if (!is_null($this->strMessageIdentifier)) { // Duplicate Message -- if so, delete this an move on $objMessage = EmailMessage::LoadByMessageIdentifier($this->strMessageIdentifier); if ($objMessage && $objMessage->Id != $this->intId) { $this->Delete(); return; } } // First, Figure out what the sender Email address is $this->FromAddress = $this->LookupSenderEmailAddress(); // If not valid, then something is very wrong -- we should punt immediately if (is_null($this->FromAddress)) { $this->strErrorMessage = 'Invaid From Address'; $this->intEmailMessageStatusTypeId = EmailMessageStatusType::Error; $this->Save(); return; } // Next, ensure the entire email message is not larger than 10MB if (strlen($this->strRawMessage) > 10485750) { $this->strErrorMessage = "Message Too Large\r\n\r\nMessages sent to ALCF Groups must be less than 10MB in size."; $this->intEmailMessageStatusTypeId = EmailMessageStatusType::Error; $this->Save(); return; } // Get a PersonArray and update Login / CommListEntry links $objSenderArray = $this->CalculatePotentialSenderArray(); // Next, Figure out the totel set of *potential* recpieint(s) are $strEmailAddressArray = $this->CalculateEmailArray(); $objGroupArray = $this->LookupGroups($strEmailAddressArray); $objCommunicationListArray = $this->LookupCommunicationLists($strEmailAddressArray); // At this point, strEmailAddressArray is actually an array of Unmatched Email Addresses $strUnmatchedEmailAddressArray = $strEmailAddressArray; // Next, iterate throug EACH CommList and Group to see which ones that the sender can send to $objUnauthorizedCommuniationListArray = $this->SetupCommunicationListRoutes($objCommunicationListArray, $objSenderArray); $objUnauthorizedGroupArray = $this->SetupGroupRoutes($objGroupArray, $objSenderArray); // Next, Error Reporting $this->SetupErrorMessage($strUnmatchedEmailAddressArray, $objUnauthorizedCommuniationListArray, $objUnauthorizedGroupArray); $this->Save(); // Queue Error Message (if applicable) if ($this->ErrorMessage) { EmailOutgoingQueue::QueueError($this); } // Queue Outgoing Messages (if applicable) foreach ($this->GetEmailMessageRouteArray() as $objRoute) { $objRoute->QueueMessages(); } // Update the status $this->intEmailMessageStatusTypeId = EmailMessageStatusType::PendingSend; $this->Save(); }
/** * Deletes all associated EmailOutgoingQueues * @return void */ public function DeleteAllEmailOutgoingQueues() { if (is_null($this->intId)) { throw new QUndefinedPrimaryKeyException('Unable to call UnassociateEmailOutgoingQueue on this unsaved EmailMessage.'); } // Get the Database Object for this Class $objDatabase = EmailMessage::GetDatabase(); // Journaling if ($objDatabase->JournalingDatabase) { foreach (EmailOutgoingQueue::LoadArrayByEmailMessageId($this->intId) as $objEmailOutgoingQueue) { $objEmailOutgoingQueue->Journal('DELETE'); } } // Perform the SQL Query $objDatabase->NonQuery(' DELETE FROM `email_outgoing_queue` WHERE `email_message_id` = ' . $objDatabase->SqlVariable($this->intId) . ' '); }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, EmailOutgoingQueue::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * If the EmailMessage has an error, then this will queue the bounceback/error message * to be sent back to the Sender. * * Note that this does **NO** validation. It is assumes that the EmailMessage has a Error / Bounceback * message set. * * @param EmailMessage $objMessage * @param string $strSenderEmailAddress * @return EmailOutgoingQueue */ public static function QueueError(EmailMessage $objMessage) { $objQueue = new EmailOutgoingQueue(); $objQueue->EmailMessage = $objMessage; $objQueue->ErrorFlag = true; $objQueue->ToAddress = $objMessage->FromAddress; $objQueue->Save(); return $objQueue; }