function legal_get_conditions in Legal 7
Same name and namespace in other branches
- 8 legal.module \legal_get_conditions()
- 5 legal.module \legal_get_conditions()
- 6.8 legal.module \legal_get_conditions()
- 6.7 legal.module \legal_get_conditions()
- 7.2 legal.module \legal_get_conditions()
- 2.0.x legal.module \legal_get_conditions()
11 calls to legal_get_conditions()
- hook_legal_accepted in ./
legal.api.php - Runs actions when legal terms are accepted
- 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().
File
- ./
legal.module, line 887 - Module file for Legal.
Code
function legal_get_conditions($language = NULL, $raw = FALSE) {
$keys = array(
'tc_id',
'version',
'revision',
'language',
'conditions',
'date',
'extras',
'changes',
'format',
);
if (!empty($language)) {
$result = db_select('legal_conditions', 'lc')
->fields('lc')
->condition('language', $language)
->orderBy('version', 'DESC')
->orderBy('revision', 'DESC')
->range(0, 1)
->addTag('legal_conditions_by_language')
->execute()
->fetchAllAssoc('tc_id');
$result = (array) array_shift($result);
}
else {
$result = db_select('legal_conditions', 'lc')
->fields('lc')
->orderBy('tc_id', 'DESC')
->addTag('legal_all_conditions')
->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']);
$conditions['format'] = empty($conditions['format']) ? filter_default_format() : $conditions['format'];
if (module_exists('token') && $raw === FALSE) {
$conditions['conditions'] = token_replace($conditions['conditions']);
}
return $conditions;
}