protected function isSetIdenticalToTriggerValues(RedBeanOneToManyRelatedModels $multipleCustomFieldValues)
 {
     if ($multipleCustomFieldValues->count() != count($this->trigger->value)) {
         return false;
     }
     foreach ($multipleCustomFieldValues as $customFieldValue) {
         if (!in_array($customFieldValue->value, $this->trigger->value)) {
             return false;
         }
     }
     return true;
 }
 public static function getRecipientsContent(RedBeanOneToManyRelatedModels $recipients, $type = null, $additionalParams = array())
 {
     assert('$type == null || $type == EmailMessageRecipient::TYPE_TO ||
                 EmailMessageRecipient::TYPE_CC || EmailMessageRecipient::TYPE_BCC');
     $existingModels = array();
     if ($recipients->count() == 0) {
         return;
     }
     foreach ($recipients as $recipient) {
         if ($type == null || $recipient->type == $type) {
             $existingPersonsOrAccounts = array();
             if ($recipient->personsOrAccounts->count() == 0) {
                 $existingPersonsOrAccounts[] = $recipient->toAddress . ' ' . $recipient->toName;
             } else {
                 foreach ($recipient->personsOrAccounts as $personOrAccount) {
                     try {
                         $castedDownModel = self::castDownItem($personOrAccount);
                         if (strval($castedDownModel) != null) {
                             $params = array('label' => strval($castedDownModel), 'wrapLabel' => false);
                             if (get_class($castedDownModel) == 'Contact') {
                                 $moduleClassName = ContactsStateMetadataAdapter::getModuleClassNameByModel($castedDownModel);
                             } else {
                                 $moduleClassName = $castedDownModel->getModuleClassName();
                             }
                             $moduleId = $moduleClassName::getDirectoryName();
                             $element = new DetailsLinkActionElement('default', $moduleId, $castedDownModel->id, array_merge($params, $additionalParams));
                             $existingPersonsOrAccounts[] = $element->render();
                         }
                     } catch (AccessDeniedSecurityException $e) {
                         $existingPersonsOrAccounts[] = $recipient->toAddress . ' ' . $recipient->toName;
                     } catch (NotSupportedException $e) {
                         //If the personOrAccount no longer exists or something else isn't right with the model
                         $existingPersonsOrAccounts[] = $recipient->toAddress . ' ' . $recipient->toName;
                     }
                 }
             }
             $recipientString = self::resolveStringValueModelsDataToStringContent($existingPersonsOrAccounts);
             if (count($existingPersonsOrAccounts) > 1) {
                 $existingModels[] = $recipient->toAddress . '(' . $recipientString . ')';
             } else {
                 $existingModels[] = $recipientString;
             }
         }
     }
     return self::resolveStringValueModelsDataToStringContent($existingModels);
 }
 public static function getRecipientsContent(RedBeanOneToManyRelatedModels $recipients, $type = null)
 {
     assert('$type == null || $type == EmailMessageRecipient::TYPE_TO ||
                 EmailMessageRecipient::TYPE_CC || EmailMessageRecipient::TYPE_BCC');
     $existingModels = array();
     if ($recipients->count() == 0) {
         return;
     }
     foreach ($recipients as $recipient) {
         if ($type == null || $recipient->type == $type) {
             if ($recipient->personOrAccount->id < 0) {
                 $existingModels[] = $recipient->toAddress . ' ' . $recipient->toName;
             } else {
                 $castedDownModel = self::castDownItem($recipient->personOrAccount);
                 try {
                     if (strval($castedDownModel) != null) {
                         $params = array('label' => strval($castedDownModel), 'wrapLabel' => false);
                         $moduleClassName = $castedDownModel->getModuleClassName();
                         $moduleId = $moduleClassName::getDirectoryName();
                         $element = new DetailsLinkActionElement('default', $moduleId, $castedDownModel->id, $params);
                         $existingModels[] = $element->render();
                     }
                 } catch (AccessDeniedSecurityException $e) {
                     $existingModels[] = $recipient->toAddress . ' ' . $recipient->toName;
                 }
             }
         }
     }
     return self::resolveStringValueModelsDataToStringContent($existingModels);
 }