PHP User::getByCriteria Examples

PHP User::getByCriteria - 2 examples found. These are the top rated real world PHP examples of User::getByCriteria extracted from open source projects. You can rate examples to help us improve the quality of examples.
 /**
  * @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);
     }
 }