fpa.form_alter.inc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @file
  4. * Contains form alter hooks to inject FPA functionality.
  5. */
  6. /**
  7. * Implements hook_form_FORM_ID_alter().
  8. */
  9. function fpa_form_node_type_form_alter(&$form, &$form_state) {
  10. if (!empty($form['type']['#default_value']) && user_access('administer permissions')) {
  11. fpa_fieldset($form['#node_type']->type . ' content', $form, array('#group' => 'additional_settings'));
  12. }
  13. }
  14. /**
  15. * Implements hook_form_FORM_ID_alter().
  16. */
  17. function fpa_form_user_admin_permissions_alter(&$form, &$form_state) {
  18. // Prevent duplication of memory limit warning.
  19. if (module_exists('filter_perms') && empty($form_state['input'])) {
  20. $memory_limit = ini_get('memory_limit');
  21. if (!drupal_check_memory_limit(_fpa_memory_required() . 'b', $memory_limit)) {
  22. drupal_set_message(t('If you attempt to display all roles and permissions on this page at the same time, you will most likely exceed your PHP memory limit of %memory_limit.', array('%memory_limit' => $memory_limit)), 'warning');
  23. }
  24. }
  25. $form['#theme'] = array('fpa_user_admin_permissions');
  26. $fpa_module_path = drupal_get_path('module', 'fpa');
  27. $form['#attached']['library'][] = array('system', 'jquery.cookie');
  28. $form['#attached']['css'][] = $fpa_module_path . '/css/fpa.css';
  29. $form['#attached']['js'][] = $fpa_module_path . '/js/fpa.min.js';
  30. $form['#attached']['js'][] = array(
  31. 'type' => 'setting',
  32. 'data' => array(
  33. 'fpa' => array(
  34. 'attr' => array(
  35. 'permission' => FPA_ATTR_PERMISSION,
  36. 'module' => FPA_ATTR_MODULE,
  37. 'role' => FPA_ATTR_ROLE,
  38. 'checked' => FPA_ATTR_CHECKED,
  39. 'not_checked' => FPA_ATTR_NOT_CHECKED,
  40. 'system_name' => FPA_ATTR_SYSTEM_NAME,
  41. ),
  42. ),
  43. ),
  44. );
  45. }
  46. /**
  47. * Implements hook_form_FORM_ID_alter().
  48. */
  49. function fpa_form_filter_perms_admin_perm_filter_alter(&$form, &$form_state) {
  50. $form['#submit'][] = '_fpa_reset_filter_defaults';
  51. }