file.install 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for File module.
  5. */
  6. /**
  7. * Implements hook_field_schema().
  8. */
  9. function file_field_schema($field) {
  10. return array(
  11. 'columns' => array(
  12. 'fid' => array(
  13. 'description' => 'The {file_managed}.fid being referenced in this field.',
  14. 'type' => 'int',
  15. 'not null' => FALSE,
  16. 'unsigned' => TRUE,
  17. ),
  18. 'display' => array(
  19. 'description' => 'Flag to control whether this file should be displayed when viewing content.',
  20. 'type' => 'int',
  21. 'size' => 'tiny',
  22. 'unsigned' => TRUE,
  23. 'not null' => TRUE,
  24. 'default' => 1,
  25. ),
  26. 'description' => array(
  27. 'description' => 'A description of the file.',
  28. 'type' => 'text',
  29. 'not null' => FALSE,
  30. ),
  31. ),
  32. 'indexes' => array(
  33. 'fid' => array('fid'),
  34. ),
  35. 'foreign keys' => array(
  36. 'fid' => array(
  37. 'table' => 'file_managed',
  38. 'columns' => array('fid' => 'fid'),
  39. ),
  40. ),
  41. );
  42. }
  43. /**
  44. * Implements hook_requirements().
  45. *
  46. * Display information about getting upload progress bars working.
  47. */
  48. function file_requirements($phase) {
  49. $requirements = array();
  50. // Check the server's ability to indicate upload progress.
  51. if ($phase == 'runtime') {
  52. $implementation = file_progress_implementation();
  53. $apache = strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== FALSE;
  54. $fastcgi = strpos($_SERVER['SERVER_SOFTWARE'], 'mod_fastcgi') !== FALSE || strpos($_SERVER["SERVER_SOFTWARE"], 'mod_fcgi') !== FALSE;
  55. $description = NULL;
  56. if (!$apache) {
  57. $value = t('Not enabled');
  58. $description = t('Your server is not capable of displaying file upload progress. File upload progress requires an Apache server running PHP with mod_php.');
  59. $severity = REQUIREMENT_INFO;
  60. }
  61. elseif ($fastcgi) {
  62. $value = t('Not enabled');
  63. $description = t('Your server is not capable of displaying file upload progress. File upload progress requires PHP be run with mod_php and not as FastCGI.');
  64. $severity = REQUIREMENT_INFO;
  65. }
  66. elseif (!$implementation && extension_loaded('apc')) {
  67. $value = t('Not enabled');
  68. $description = t('Your server is capable of displaying file upload progress through APC, but it is not enabled. Add <code>apc.rfc1867 = 1</code> to your php.ini configuration. Alternatively, it is recommended to use <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>, which supports more than one simultaneous upload.');
  69. $severity = REQUIREMENT_INFO;
  70. }
  71. elseif (!$implementation) {
  72. $value = t('Not enabled');
  73. $description = t('Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> (preferred) or to install <a href="http://us2.php.net/apc">APC</a>.');
  74. $severity = REQUIREMENT_INFO;
  75. }
  76. elseif ($implementation == 'apc') {
  77. $value = t('Enabled (<a href="http://php.net/manual/en/apc.configuration.php#ini.apc.rfc1867">APC RFC1867</a>)');
  78. $description = t('Your server is capable of displaying file upload progress using APC RFC1867. Note that only one upload at a time is supported. It is recommended to use the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> if possible.');
  79. $severity = REQUIREMENT_OK;
  80. }
  81. elseif ($implementation == 'uploadprogress') {
  82. $value = t('Enabled (<a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>)');
  83. $severity = REQUIREMENT_OK;
  84. }
  85. $requirements['file_progress'] = array(
  86. 'title' => t('Upload progress'),
  87. 'value' => $value,
  88. 'severity' => $severity,
  89. 'description' => $description,
  90. );
  91. }
  92. return $requirements;
  93. }