Example #1
0
 /**
  * Given the locally set Login and CommListEntry link, and given an array of Person[] objects all which
  * represent the FromEmailAddress, iterate through the array of CommunicationList objects to see which ones
  * the sender can send to.  Associate any valid ones to this object as a new EmailMessageRoute.
  * Return any invalid (e.g. unauthorized) ones as an array.
  * @param CommunicationList[] $objCommunicationListArray
  * @param mixed[] $objSenderArray
  * @return CommunicationList[] returns any unauthorized CommLists that the sender is not allowed to send to
  */
 protected function SetupCommunicationListRoutes($objCommunicationListArray, $objSenderArray)
 {
     // Pull out the components of the $objSenderArray
     $objLogin = $objSenderArray[0];
     $objCommunicationListEntry = $objSenderArray[1];
     $objPersonArray = $objSenderArray[2];
     $objUnauthorizedArray = array();
     // Do the calculation for Each CommList being attempted to emailed to
     foreach ($objCommunicationListArray as $objCommunicationList) {
         $objSource = null;
         // Figure out if there is a valid "Source" of this email that is authorized
         // to send to $objCommunicaitonList
         if ($objLogin && $objCommunicationList->IsLoginCanSendEmail($objLogin)) {
             $objSource = $objLogin;
         } else {
             if ($objCommunicationListEntry && $objCommunicationList->IsCommunicationListEntryCanSendEmail($objCommunicationListEntry)) {
                 $objSource = $objCommunicationListEntry;
             } else {
                 foreach ($objPersonArray as $objPerson) {
                     if ($objCommunicationList->IsPersonCanSendEmail($objPerson)) {
                         $objSource = $objPerson;
                         break;
                     }
                 }
             }
         }
         // If a Valid Source, or if a PublicList, create the EmailRoute for the CommList,
         // otherwise, add the CommList to the list of Unauthorized
         if ($objSource || $objCommunicationList->IsAnyoneCanSendEmail()) {
             EmailMessageRoute::CreateNewRoute($this, $objSource, $objCommunicationList);
         } else {
             $objUnauthorizedArray[] = $objCommunicationList;
         }
     }
     return $objUnauthorizedArray;
 }