fpa.install 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * @file
  4. * Install, update, and uninstall functions for the Fast Permissions Administration module.
  5. */
  6. /**
  7. * Implements hook_requirements().
  8. */
  9. function fpa_requirements($phase) {
  10. $requirements = array();
  11. if ($phase == 'runtime') {
  12. $permissions_memory_required = _fpa_memory_required();
  13. if (!drupal_check_memory_limit($permissions_memory_required . 'b')) {
  14. $requirements['fpa_memory'] = array(
  15. 'severity' => REQUIREMENT_WARNING,
  16. 'title' => t('Insufficient memory for permissions page'),
  17. 'value' => t('~@permissions_memory_requiredM of memory required', array('@permissions_memory_required' => (int) ($permissions_memory_required / 1024 / 1024))),
  18. 'description' => t('It is likely that you will exceed your memory limit when viewing the permissions page for all roles and permissions. If you are unable to load the permissions page, this is most likely the cause.') . '<br />',
  19. );
  20. $filter_perms_link = l('Filter Permissions', 'https://drupal.org/project/filter_perms');
  21. if (!module_exists('filter_perms')) {
  22. $requirements['fpa_memory']['description'] .= t('The !filter_perms_link module can work with Fast Permissions Administration by reducing the amount of the permissions form that is rendered and thereby reducing the memory required on the permissions page.', array('!filter_perms_link' => $filter_perms_link)) . '<br />';
  23. if ($php_ini_path = get_cfg_var('cfg_file_path')) {
  24. $requirements['fpa_memory']['description'] .= t('Increase the memory limit by editing the memory_limit parameter in the file %configuration-file and then restart your web server (or contact your system administrator or hosting provider for assistance).', array('%configuration-file' => $php_ini_path)) . '<br />';
  25. }
  26. }
  27. else {
  28. $requirements['fpa_memory']['severity'] = REQUIREMENT_OK;
  29. $requirements['fpa_memory']['description'] = t('The !filter_perms_link module installed should prevent a memory issue as long as viewed permissions and roles are limited.', array('!filter_perms_link' => $filter_perms_link));
  30. }
  31. }
  32. }
  33. return $requirements;
  34. }