You are here

function module_weights_system_module_submit in Util 6.3

Same name and namespace in other branches
  1. 6.2 module_weights.module \module_weights_system_module_submit()

Implements form_submit().

1 string reference to 'module_weights_system_module_submit'
module_weights_form_alter in ./module_weights.module
Implements hook_form_alter().

File

./module_weights.module, line 152
Allows module weights to be viewed and edited.

Code

function module_weights_system_module_submit($form, &$form_state) {
  foreach ($form_state['values'] as $key => $weight) {

    // Extra step of optimization, update only weights that changed
    // also skip on module names that don't match our record in fetch_module_weights().
    if (drupal_substr($key, 0, 2) == 'w_') {
      $name = drupal_substr($key, 2);
      $module_weight = fetch_module_weights($name);
      if ($module_weight !== NULL && $module_weight != $weight) {
        $query = "UPDATE {system} SET weight = %d WHERE name LIKE '%s'";
        db_query($query, (int) $weight, $name);
      }
    }
  }
}