timefield.install 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * @file
  4. * Install file for timefield module.
  5. */
  6. /**
  7. * Implements hook_field_schema().
  8. */
  9. function timefield_field_schema($field) {
  10. $db_columns = array();
  11. // We are using an integer to store time values. This in not a UNIX timestamp
  12. // however, rather offset from 12:00 AM midnight. Values that are greater
  13. // than 24 * 60 * 60, or the value of 24-hour period are condidered +1 day.
  14. $db_columns['value'] = array(
  15. 'type' => 'int',
  16. 'not null' => FALSE,
  17. );
  18. // If second time is needed for 'To time', just make a copy of the first one.
  19. if (!empty($field['settings']['totime'])) {
  20. $db_columns['value2'] = $db_columns['value'];
  21. }
  22. // If a weekly schedule option selected add in additional columns.
  23. if (!empty($field['settings']['weekly_summary'])) {
  24. $db_columns += array(
  25. 'label' => array(
  26. 'description' => 'A label for this weekly schedule',
  27. 'type' => 'varchar',
  28. 'length' => 255,
  29. 'not null' => FALSE,
  30. 'default' => '',
  31. ),
  32. 'mon' => array(
  33. 'type' => 'int',
  34. 'unsigned' => TRUE,
  35. 'not null' => TRUE,
  36. 'default' => 0,
  37. 'size' => 'tiny',
  38. ),
  39. 'tue' => array(
  40. 'type' => 'int',
  41. 'unsigned' => TRUE,
  42. 'not null' => TRUE,
  43. 'default' => 0,
  44. 'size' => 'tiny',
  45. ),
  46. 'wed' => array(
  47. 'type' => 'int',
  48. 'unsigned' => TRUE,
  49. 'not null' => TRUE,
  50. 'default' => 0,
  51. 'size' => 'tiny',
  52. ),
  53. 'thu' => array(
  54. 'type' => 'int',
  55. 'unsigned' => TRUE,
  56. 'not null' => TRUE,
  57. 'default' => 0,
  58. 'size' => 'tiny',
  59. ),
  60. 'fri' => array(
  61. 'type' => 'int',
  62. 'unsigned' => TRUE,
  63. 'not null' => TRUE,
  64. 'default' => 0,
  65. 'size' => 'tiny',
  66. ),
  67. 'sat' => array(
  68. 'type' => 'int',
  69. 'unsigned' => TRUE,
  70. 'not null' => TRUE,
  71. 'default' => 0,
  72. 'size' => 'tiny',
  73. ),
  74. 'sun' => array(
  75. 'type' => 'int',
  76. 'unsigned' => TRUE,
  77. 'not null' => TRUE,
  78. 'default' => 0,
  79. 'size' => 'tiny',
  80. ),
  81. );
  82. }
  83. return array('columns' => $db_columns);
  84. }
  85. /**
  86. * Implements hook_requirements().
  87. */
  88. function timefield_requirements($phase) {
  89. $requirements = array();
  90. if ($phase == 'runtime') {
  91. $t = get_t();
  92. $libraries = libraries_get_libraries();
  93. if (array_key_exists('jquery.timepicker', $libraries)) {
  94. $requirements['jquery_timepicker'] = array(
  95. 'title' => $t('jQuery Timepicker plugin'),
  96. 'severity' => REQUIREMENT_OK,
  97. 'value' => $t('jQuery Timepicker plugin is installed'),
  98. );
  99. }
  100. else {
  101. $requirements['jquery_timepicker'] = array(
  102. 'title' => $t('jQuery Timepicker plugin'),
  103. 'value' => $t('jQuery Timepicker plugin is not installed'),
  104. 'severity' => REQUIREMENT_INFO,
  105. 'description' => $t('While not a requirement, timefield module\'s utility is greatly enhanced by including the !link', array('!link' => l($t("jQuery Timepicker plugin"), "http://fgelinas.com/code/timepicker"))),
  106. );
  107. }
  108. }
  109. return $requirements;
  110. }