You are here

function tvi_load_settings in Taxonomy Views Integrator 7

Same name and namespace in other branches
  1. 6 includes/tvi.query.inc \tvi_load_settings()

Load a setting from the database or return a default.

Parameters

string|int $xid: The identifier of the object for which we are loading these settings. It can be an integer or and UUID.

string $type: The type of the object for which we are loading these settings. It can be TVI_TYPE_TERM or TVI_TYPE_VOCAB.

bool $return_default: A boolean to decide if we want to return default settings if no settings are set for this object.

Return value

bool|object FALSE if no settings are set for this object and $return_default is TRUE. Otherwise, the settings object corresponding to the given term/vocabulary.

5 calls to tvi_load_settings()
tvi_get_term_info in ./tvi.module
Return different data sets for a specified term id.
tvi_settings_form in includes/tvi.admin.inc
Create the main settings form.
tvi_term_form in includes/tvi.admin.inc
Adds TVI administration form to the term edit page.
tvi_update_7003 in ./tvi.install
Add inherit parameters to settings where it's missing.
tvi_vocab_form in includes/tvi.admin.inc
Adds TVI administration form to the vocabulary edit page.

File

includes/tvi.query.inc, line 54
Database interface for the tvi module.

Code

function tvi_load_settings($xid, $type = TVI_TYPE_TERM, $return_default = TRUE) {
  $xid = _tvi_get_xid($xid, $type);
  $settings = variable_get('tvi_' . $type . '_' . $xid, FALSE);
  $settings = is_array($settings) ? (object) $settings : $settings;
  $settings = tvi_validate_settings($settings);
  if ($settings === FALSE && $return_default) {
    return tvi_default_settings($type, $xid);
  }

  // Avoid loss during tid/uuid conversion.
  if (!empty($settings)) {
    $settings->xid = $xid;
    $settings->type = $type;
  }
  return $settings;
}