You are here

function field_weight_multiple_get_revision_weight in Field display weights (per node) 7.2

Parameters

$vid:

Return value

mixed

2 calls to field_weight_multiple_get_revision_weight()
field_weight_multiple_form_field_weight_display_overview_form_alter in modules/field_weight_multiple.module
Implements hook_form_FORM_ID_alter().
field_weight_multiple_get_weight in modules/field_weight_multiple.module
Helper function to get weights from field_weight table for nids passed in.

File

modules/field_weight_multiple.module, line 285

Code

function field_weight_multiple_get_revision_weight($vid) {
  $result = db_select('field_weight_multiple', 'fwm')
    ->fields('fwm', array(
    'field_weights',
  ))
    ->condition('vid', $vid)
    ->execute()
    ->fetchField();
  $weights = unserialize($result);
  if (!$weights) {

    // See if the published node revision has weights, and fall back to these.
    // This should not normally happen, but it can if, for example, the user
    // has clicked Reset on a specific revision.
    $node = node_load(NULL, $vid);
    $node_result = db_select('field_weight_multiple', 'fwm')
      ->fields('fwm', array(
      'field_weights',
    ))
      ->condition('nid', $node->nid)
      ->execute()
      ->fetchField();
  }
  $weights = unserialize($node_result);
  return $weights;
}