/** * 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(); }