function weight_view_weight_form_submit in Weight 6
Same name and namespace in other branches
- 7 weight.views.inc \weight_view_weight_form_submit()
Save the changed weights.
1 string reference to 'weight_view_weight_form_submit'
- weight_view_weight_form in ./
weight.module - Display a view as a weight changing table.
File
- ./
weight.module, line 377 - This module uses the sticky column of the node table to add weighting to nodes.
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;
}
db_query("UPDATE {node} SET sticky = %d WHERE nid = %d", $node->sticky, $nid);
if (module_exists('i18nsync') && in_array('sticky', i18nsync_node_fields($node->type))) {
$nodes = translation_node_get_translations($node->tnid);
if (count($nodes)) {
foreach ($nodes as $tnode) {
if ($tnode->nid != $node->nid) {
db_query("UPDATE {node} SET sticky = %d WHERE nid = %d", $node->sticky, $tnode->nid);
}
}
$synced = TRUE;
}
}
}
if ($synced) {
drupal_set_message(t('Your weight changes have been saved and synchronized.'));
}
else {
drupal_set_message(t('Your weight changes have been saved.'));
}
}