You are here

function bueditor_user_eids in BUEditor 7

Same name and namespace in other branches
  1. 6.2 bueditor.inc \bueditor_user_eids()
  2. 6 bueditor.module \bueditor_user_eids()

Return the editor ids assigned to the user.

1 call to bueditor_user_eids()
_bueditor_textarea in ./bueditor.inc
Integrate the editor into textarea element.

File

./bueditor.inc, line 190
Implements commonly used functions for bueditor.

Code

function bueditor_user_eids($user) {

  // User #1
  if ($user->uid == 1) {
    return array(
      variable_get('bueditor_user1', 1),
      variable_get('bueditor_user1_alt', 0),
    );
  }
  $roles = variable_get('bueditor_roles', array());

  // Anonymous user
  if (empty($user->uid)) {
    $rid = DRUPAL_ANONYMOUS_RID;
    return isset($roles[$rid]) ? array(
      $roles[$rid]['editor'],
      $roles[$rid]['alt'],
    ) : array(
      '',
      '',
    );
  }

  // Other users
  foreach ($roles as $rid => $role) {
    if (isset($user->roles[$rid]) && ($role['editor'] || $role['alt'])) {
      return array(
        $role['editor'],
        $role['alt'],
      );
    }
  }
  return array(
    '',
    '',
  );
}