/**
  * @param RedBeanModel $model
  * @param User $triggeredByUser
  * @return array
  */
 public function makeRecipients(RedBeanModel $model, User $triggeredByUser)
 {
     try {
         $group = Group::getById((int) $this->groupId);
     } catch (NotFoundException $e) {
         return array();
     }
     if ($group->name == Group::EVERYONE_GROUP_NAME) {
         $users = User::getByCriteria(true, null);
     } else {
         $users = $group->users;
     }
     $recipients = array();
     foreach ($users as $user) {
         if ($user->primaryEmail->emailAddress != null) {
             $recipient = new EmailMessageRecipient();
             $recipient->toAddress = $user->primaryEmail->emailAddress;
             $recipient->toName = strval($user);
             $recipient->type = $this->audienceType;
             $recipient->personsOrAccounts->add($user);
             $recipients[] = $recipient;
         } else {
             $this->createWorkflowTriggerUserPrimaryEmailAddressRequiredNotificationForUser($user);
         }
     }
     return $recipients;
 }
 /**
  * Any user who is a super administrator added to receive a
  * notification.
  */
 protected function loadUsers()
 {
     $superAdministratorGroup = Group::getByName(Group::SUPER_ADMINISTRATORS_GROUP_NAME);
     $users = User::getByCriteria(true, $superAdministratorGroup->id);
     foreach ($users as $user) {
         $this->addUser($user);
     }
 }