module_missing_message_fixer.admin.inc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @file
  4. * The Missing Module Message Fixer Admin Settings file.
  5. */
  6. /**
  7. * Missing Module Message Fixer Form.
  8. */
  9. function module_missing_message_fixer_form() {
  10. $form = array();
  11. // Fancy title string.
  12. $title = t('This list comes from the system table and is checked against the drupal_get_filename() function. See <a href="@link" target="_blank">this issue</a> for more information.', array(
  13. '@link' => 'https://www.drupal.org/node/2487215',
  14. ));
  15. // Title.
  16. $form['title'] = array(
  17. '#type' => 'item',
  18. '#markup' => '<h2><center>' . $title . '</h2></center>',
  19. );
  20. // Fancy submit buttons to win this.
  21. $form['submit'] = array(
  22. '#type' => 'submit',
  23. '#value' => t('Remove These Errors!'),
  24. '#submit' => array('module_missing_message_fixer_form_submit'),
  25. '#prefix' => '<center>',
  26. '#suffix' => '</center>',
  27. );
  28. // Set the tables select to make this more granular.
  29. $form['table'] = array(
  30. '#type' => 'tableselect',
  31. '#header' => _module_missing_message_fixer_get_table_header(),
  32. '#options' => _module_missing_message_fixer_get_table_rows(),
  33. '#empty' => t('No Missing Modules Found!!!'),
  34. );
  35. return $form;
  36. }
  37. /**
  38. * Submit handler for Missing Module Message Fixer Form.
  39. *
  40. * @param array $form
  41. * @param array $form_state
  42. */
  43. function module_missing_message_fixer_form_submit(array $form, array &$form_state) {
  44. $modules = array();
  45. // Go through each record and add it to the array to win.
  46. foreach ($form_state['values']['table'] as $module) {
  47. $modules[] = $module;
  48. }
  49. // Delete if there is no modules.
  50. if (count($modules) > 0) {
  51. db_delete('system')
  52. ->condition('name', $modules, 'IN')
  53. ->execute();
  54. }
  55. }