filefield_sources.api.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * @file
  4. * This file documents hooks provided by the FileField Sources module.
  5. *
  6. * Note that none of this code is executed by using FileField Sources module,
  7. * it is provided here for reference as an example how to implement these hooks
  8. * in your own module.
  9. */
  10. /**
  11. * Returns a list of widgets that are compatible with FileField Sources.
  12. *
  13. * FileField Sources works with the most common widgets used with Drupal (the
  14. * standard Image and File widgets). Any module that provides another widget
  15. * for uploading files may add compatibility with FileField Sources by
  16. * implementing this hook and returning the widgets that their module supports.
  17. */
  18. function hook_filefield_sources_widgets() {
  19. // Add any widgets that your module supports here.
  20. return array('mymodule_file_widgetname');
  21. }
  22. /**
  23. * Allows altering the sources available on a field.
  24. *
  25. * This hook allows other modules to modify the sources available to a user.
  26. *
  27. * @param array $sources
  28. * List of filefiled sources plugins.
  29. *
  30. * @param mixed $context
  31. * Contains 'enabled_sources', 'element', 'form_state'.
  32. */
  33. function hook_filefield_sources_sources_alter(&$sources, $context) {
  34. // This example will exclude sources the user doesn't have access to.
  35. foreach (array_keys($sources) as $type) {
  36. if (!user_access("use $type filefield source")) {
  37. unset($sources[$type]);
  38. }
  39. }
  40. }