You are here

function rb_misc_condition_user_has_permission in Rules Bonus Pack 7

The 'rb_misc_condition_user_has_permission' permission.

File

./rb_misc.rules.inc, line 516
Miscellaneous conditions and actions for Rules.

Code

function rb_misc_condition_user_has_permission($account, $permissions, $operation = 'AND') {
  switch ($operation) {
    case 'OR':
      foreach ($permissions as $perm) {
        if (user_access($perm, $account)) {
          return TRUE;
        }
      }
      return FALSE;
    case 'AND':
      foreach ($permissions as $perm) {
        if (!user_access($perm, $account)) {
          return FALSE;
        }
      }
      return TRUE;
  }
}