You are here

function legal_get_conditions in Legal 7.2

Same name and namespace in other branches
  1. 8 legal.module \legal_get_conditions()
  2. 5 legal.module \legal_get_conditions()
  3. 6.8 legal.module \legal_get_conditions()
  4. 6.7 legal.module \legal_get_conditions()
  5. 7 legal.module \legal_get_conditions()
  6. 2.0.x legal.module \legal_get_conditions()
9 calls to legal_get_conditions()
legal_administration in ./legal.admin.inc
Module settings form.
legal_conditions_updated in ./legal.admin.inc
Check if T&Cs have been updated.
legal_form_user_profile_form_alter in ./legal.module
Implements hook_form_FORM_ID_alter().
legal_form_user_register_form_alter in ./legal.module
Implements hook_form_FORM_ID_alter().
legal_login in ./legal.module
Require registered users to accept new T&C.

... See full list

File

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

Code

function legal_get_conditions($language = NULL) {
  $keys = array(
    'tc_id',
    'version',
    'revision',
    'language',
    'conditions',
    'date',
    'extras',
    'changes',
  );
  if (!empty($language)) {
    $result = db_select('legal_conditions', 'lc')
      ->fields('lc')
      ->condition('language', $language)
      ->orderBy('version', 'DESC')
      ->orderBy('revision', 'DESC')
      ->range(0, 1)
      ->execute()
      ->fetchAllAssoc('tc_id');
    $result = (array) array_shift($result);
  }
  else {
    $result = db_select('legal_conditions', 'lc')
      ->fields('lc')
      ->orderBy('tc_id', 'DESC')
      ->execute()
      ->fetchAllAssoc('tc_id');
    $result = (array) array_shift($result);
  }
  foreach ($keys as $key) {
    $conditions[$key] = isset($result[$key]) ? $result[$key] : '';
  }
  $conditions['extras'] = empty($conditions['extras']) ? array() : unserialize($conditions['extras']);
  return $conditions;
}