hosting_site.api.php

Hooks provided by the hosting site module.

Functions

Namesort descending Description
hook_hosting_site_options_alter
hook_hosting_site_site_list_filters Defines which filters are allowed to be used on the hosting site list.
hook_hosting_site_site_list_filters_alter Alters which filters are allowed to be used on the hosting site list.

File

site/hosting_site.api.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by the hosting site module.
  5. */
  6. /**
  7. * @addtogroup hostinghooks
  8. * @{
  9. */
  10. /**
  11. *
  12. * @param $return
  13. * An array of arrays, keys are fields on the $node and values are valid
  14. * options for those fields.
  15. * @param $node
  16. * The node object that represents the site.
  17. *
  18. * @see hosting_site_available_options()
  19. */
  20. function hook_hosting_site_options_alter(&$return, $node) {
  21. // From: hosting_ssl_hosting_site_options_alter().
  22. // Disable the ssl key fields by default.
  23. if (!sizeof(hosting_ssl_get_servers())) {
  24. $return['ssl_enabled'] = FALSE;
  25. }
  26. $return['ssl_key'] = false;
  27. $return['ssl_key_new'] = false;
  28. // Test if ssl has been enabled.
  29. if ($node->ssl_enabled != 0) {
  30. $keys = hosting_ssl_get_keys($node->client, TRUE);
  31. // return the list of valid keys, including the special 'new key' option.
  32. $return['ssl_key'] = array_keys($keys);
  33. // properly default this value so things dont fall apart later.
  34. if (sizeof($return['ssl_key']) == 1) {
  35. $node->ssl_key = HOSTING_SSL_CUSTOM_KEY;
  36. }
  37. // the user has chosen to enter a new key
  38. if ($node->ssl_key == HOSTING_SSL_CUSTOM_KEY) {
  39. // default the new key to the site's domain name, after filtering.
  40. $default = hosting_ssl_filter_key($node->title);
  41. $return['ssl_key_new'] = (!empty($default)) ? $default : true;
  42. }
  43. // we need to ensure that the return value is properly indexed, otherwise it
  44. // gets interpreted as an object by jquery.
  45. $return['profile'] = array_values(array_intersect($return['profile'], hosting_ssl_get_profiles()));
  46. $return['platform'] = array_values(array_intersect($return['platform'], hosting_ssl_get_platforms()));
  47. }
  48. }
  49. /**
  50. * Defines which filters are allowed to be used on the hosting site list.
  51. *
  52. * The list of sites can be filtered via the query string, and to avoid nasty
  53. * security exploits you must explicitly define what people can filter by.
  54. *
  55. * @return array
  56. * An array of possible filter strings.
  57. *
  58. * @see hosting_site_get_possible_site_list_filters()
  59. * @see hosting_sites()
  60. * @see hook_hosting_site_site_list_filters_alter()
  61. */
  62. function hook_hosting_site_site_list_filters() {
  63. // From hosting_platform.
  64. return array('platform');
  65. }
  66. /**
  67. * Alters which filters are allowed to be used on the hosting site list.
  68. *
  69. * The list of sites can be filtered via the query string, and to avoid nasty
  70. * security exploits you must explicitly define what people can filter by.
  71. *
  72. * @param $filters
  73. * The array of filters defined by other modules.
  74. *
  75. * @see hosting_site_get_possible_site_list_filters()
  76. * @see hosting_sites()
  77. * @see hook_hosting_site_site_list_filters()
  78. */
  79. function hook_hosting_site_site_list_filters_alter(&$filters) {
  80. // Add a filter based on another module.
  81. if (in_array('other_filter', $filters, TRUE)) {
  82. $filters[] = 'my_filter';
  83. }
  84. }
  85. /**
  86. * @} End of "addtogroup hooks".
  87. */