You are here

function signature_forum_user_exception in Signatures for Forums 6

Same name and namespace in other branches
  1. 5.2 signature_forum.module \signature_forum_user_exception()
  2. 5 signature_forum.module \signature_forum_user_exception()

Find if uid is in exception lists.

Parameters

$uid: User ID.

$op: Which exception list, this may be:

  • "min_length".
  • "show_once".

Return value

TRUE if uid is in exception list. FALSE otherwise.

1 call to signature_forum_user_exception()
signature_forum_get_signature in ./signature_forum.module
Retrieve signature for a given user.

File

./signature_forum.module, line 496
Tweaks signatures in ways inspired by other traditional forum software:

Code

function signature_forum_user_exception($uid = 0, $op) {
  static $cache = array();
  $settings = variable_get('signature_forum_settings', signature_forum_defaults());
  if (!isset($cache[$uid]) || !is_array($cache[$uid])) {
    $result = db_query("SELECT r.rid AS rid FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d", $uid);
    $cache[$uid] = array();
    while ($role = db_fetch_object($result)) {
      $cache[$uid][$role->rid] = $role->rid;
    }
    if ($uid > 0) {
      $cache[$uid][DRUPAL_AUTHENTICATED_RID] = DRUPAL_AUTHENTICATED_RID;
    }
  }
  foreach ($cache[$uid] as $rid) {
    switch ($op) {
      case 'min_length':
        if ($settings['signature_forum_roles'][$rid] == $rid) {
          return TRUE;
        }
        break;
      case 'show_once':
        if ($settings['signature_forum_show_once_roles'][$rid] == $rid) {
          return TRUE;
        }
        break;
    }
  }
  return FALSE;
}