You are here

function workbench_email_filter_workbench_access_users in Workbench Email 7.3

Returns a list of users / emails.

Filters out users who don't have acccess to the workbench access protected section.

Parameters

int $rid: The role id.

array $accounts: The available users under a given role.

array $editors: The available Workbench Access editors..

bool $author: The author flag.

Return value

array The finalized array of permitted users.

1 call to workbench_email_filter_workbench_access_users()
workbench_email_filter_users in ./workbench_email.module
Filters out the users based on criteria.

File

./workbench_email.module, line 831
Code for the Workbench Email Module.

Code

function workbench_email_filter_workbench_access_users($rid, $accounts, $editors, $author) {
  global $user;
  $emails = array();
  foreach ($accounts as $uid => $account) {
    foreach ($editors as $e_uid => $e_account) {
      if ($e_uid == $uid && array_key_exists($rid, $account->roles)) {

        // If the current user is the author and the admin has setup the
        // transition to notify them, then we force it.
        if ($author) {
          $emails[$account->mail] = $account->name;
        }

        // If the current user is a member of a separate role they
        // probably wouldn't want to be notified they just made
        // a transition. Possible setting in the future.
        if ($user->mail != $account->mail) {
          $emails[$account->mail] = $account->name;
        }
      }
    }
  }
  return $emails;
}