You are here

function legal_get_accept in Legal 7

Same name and namespace in other branches
  1. 8 legal.module \legal_get_accept()
  2. 5 legal.module \legal_get_accept()
  3. 6.8 legal.module \legal_get_accept()
  4. 6.7 legal.module \legal_get_accept()
  5. 7.2 legal.module \legal_get_accept()
  6. 2.0.x legal.module \legal_get_accept()
5 calls to legal_get_accept()
legal_display_changes in ./legal.module
Get all changes since user last accepted.
legal_form_user_profile_form_alter in ./legal.module
Implements hook_form_FORM_ID_alter().
legal_login in ./legal.module
Require registered users to accept new T&C.
legal_user_login in ./legal.module
Implements hook_user_login().
legal_version_check in ./legal.module
Check if user has accepted latest version of T&C.

File

./legal.module, line 830
Module file for Legal.

Code

function legal_get_accept($uid) {
  $keys = array(
    'legal_id',
    'version',
    'revision',
    'language',
    'uid',
    'accepted',
  );
  $result = db_select('legal_accepted', 'la')
    ->fields('la')
    ->condition('uid', $uid)
    ->orderBy('version', 'DESC')
    ->orderBy('revision', 'DESC')
    ->addTag('legal_get_accepted')
    ->execute()
    ->fetchAllAssoc('legal_id');
  $result = count($result) ? array_shift($result) : array();
  $accept = array();
  foreach ($keys as $key) {
    if (isset($result->{$key})) {
      $accept[$key] = $result->{$key};
    }
  }
  return $accept;
}