You are here

function node_gallery_api_sort_items_form_remove_weights_submit in Node Gallery 7

Submit function to reset all image weights in a gallery to 0, effectively removing any custom sort.

1 string reference to 'node_gallery_api_sort_items_form_remove_weights_submit'
node_gallery_api_sort_items_form in ./node_gallery_api.pages.inc
Form function for the "Sort Items" tab.

File

./node_gallery_api.pages.inc, line 187
Node Gallery module.

Code

function node_gallery_api_sort_items_form_remove_weights_submit($form, &$form_state) {
  $result = db_update('node_gallery_relationship')
    ->fields(array(
    'weight' => 0,
  ))
    ->condition('ngid', $form_state['values']['ngid'])
    ->execute();
  if ($result === FALSE) {
    $message = t("There was a problem updating your images.");
  }
  else {
    $message = t("All image weights have been reset. The global sorting is now active again.");
  }
  node_gallery_api_clear_gallery_caches($form_state['values']['ngid']);
  drupal_set_message(check_plain($message));
}