You are here

function _agreement_status in Agreement 6.2

Same name and namespace in other branches
  1. 6 agreement.module \_agreement_status()
  2. 7.2 agreement.module \_agreement_status()

Internal function to get the user's "agreement status".

Parameters

object $uid[optional] - UID for which the status should be checked.: Defaults to current user.

Return value

TRUE if agreement found in db.

2 calls to _agreement_status()
agreement_init in ./agreement.module
Implementation of hook_init().
agreement_page in ./agreement.module
Callback for agreement URL

File

./agreement.module, line 480
agreement.module - Agreement module code

Code

function _agreement_status($uid = NULL) {

  // If the UID is not specified, use the current user.
  if (empty($uid)) {
    global $user;
    $uid = $user->uid;
  }

  // Make sure we weren't passed some garbage as $uid
  $uid = (int) $uid;

  // Must agree on every login
  if (variable_get('agreement_frequency', 0) == 1) {
    $query = "SELECT agreed FROM {agreement} WHERE uid = %d and sid = '%s'";
    $result = db_query_range($query, array(
      $uid,
      session_id(),
    ), 0, 1);
  }
  else {
    $query = "SELECT agreed FROM {agreement} WHERE uid = %d";
    $result = db_query_range($query, $uid, 0, 1);
  }
  return (bool) db_result($result);
}