You are here

function weight_view_weight_form_submit in Weight 7

Same name and namespace in other branches
  1. 6 weight.module \weight_view_weight_form_submit()

Save the changed weights.

File

./weight.views.inc, line 276
Views2 support for Weight module.

Code

function weight_view_weight_form_submit($form, &$form_state) {
  foreach ($form_state['values']['rows'] as $count => $value) {
    $weight = $value['weight'];
    $nid = $value['nid_hidden'];
    $node = node_load($nid);
    if ($node->sticky) {
      $node->sticky = -1 * $weight + 100;
    }
    else {
      $node->sticky = -1 * $weight - 100;
    }
    node_save($node);
  }
  drupal_set_message(t('Your weight changes have been saved.'));
}