/** * 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 Group 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 Group[] $objGroupArray * @param mixed[] $objSenderArray * @return Group[] returns any unauthorized Groups that the sender is not allowed to send to */ protected function SetupGroupRoutes($objGroupArray, $objSenderArray) { // Pull out the components of the $objSenderArray $objLogin = $objSenderArray[0]; $objCommunicationListEntry = $objSenderArray[1]; $objPersonArray = $objSenderArray[2]; $objUnauthorizedArray = array(); // Do the calculation for Each Group being attempted to emailed to foreach ($objGroupArray as $objGroup) { $objSource = null; // Figure out if there is a valid "Source" of this email that is authorized // to send to $objGroup if ($objLogin && $objGroup->IsLoginCanSendEmail($objLogin)) { $objSource = $objLogin; } else { foreach ($objPersonArray as $objPerson) { if ($objGroup->IsPersonCanSendEmail($objPerson)) { $objSource = $objPerson; break; } // If authorized sender then allow send also if (GroupAuthorizedSender::LoadByGroupIdPersonId($objGroup->Id, $objPerson->Id)) { $objSource = $objPerson; break; } } } // If a Valid Source, or if a PublicList, create the EmailRoute for the group, // otherwise, add the group to the list of Unauthorized if ($objSource || $objGroup->IsAnyoneCanSendEmail()) { EmailMessageRoute::CreateNewRoute($this, $objSource, $objGroup); } else { $objUnauthorizedArray[] = $objGroup; } } return $objUnauthorizedArray; }
public function RenderAuthorizedSender(Person $objPerson) { $objGroupAuthorizedsender = GroupAuthorizedSender::LoadByGroupIdPersonId($this->objGroup->Id, $objPerson->Id); if ($objGroupAuthorizedsender) { return 'Y'; } else { return ''; } }
public function btnSave_Click($strFormId, $strControlId, $strParameter) { $objArrayToDelete = array(); foreach (GroupParticipation::LoadArrayByPersonIdGroupId($this->pnlContent->objPerson->Id, $this->pnlContent->objGroup->Id) as $objParticipation) { $objArrayToDelete[$objParticipation->Id] = $objParticipation; } // Save all the participation records foreach ($this->objParticipationArray as $objParticipation) { $objParticipation->Save(); if (array_key_exists($objParticipation->Id, $objArrayToDelete)) { unset($objArrayToDelete[$objParticipation->Id]); } } // Delete any that are supposed to be deleted foreach ($objArrayToDelete as $objParticipation) { $objParticipation->Delete(); } // Update groupAuthorizedSender table if ($this->chkIsAuthorizedSender->Checked && !GroupAuthorizedSender::LoadByGroupIdPersonId($this->pnlContent->objGroup->Id, $this->pnlContent->objPerson->Id)) { $objGroupAuthorizedSender = new GroupAuthorizedSender(); $objGroupAuthorizedSender->GroupId = $this->pnlContent->objGroup->Id; $objGroupAuthorizedSender->PersonId = $this->pnlContent->objPerson->Id; $objGroupAuthorizedSender->Save(); } else { if (!$this->chkIsAuthorizedSender->Checked) { $objGroupAuthorizedSender = GroupAuthorizedSender::LoadByGroupIdPersonId($this->pnlContent->objGroup->Id, $this->pnlContent->objPerson->Id); if ($objGroupAuthorizedSender) { $objGroupAuthorizedSender->Delete(); } } } $this->pnlContent->ReturnTo($this->strReturnUrl); }