fgcf.admin.inc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // $Id$
  3. /**
  4. * @file
  5. * Admin pages for FGCF module
  6. *
  7. * @copyright (c) 2010 Ouest Systemes Informatiques (OSInet)
  8. *
  9. * @license General Public License version 2 or later
  10. *
  11. * @author Frederic G. MARAND (fgm@osinet.fr)
  12. *
  13. */
  14. /**
  15. * Implement the former hook_settings().
  16. *
  17. * @see fgcf_admin_settings_validate()
  18. *
  19. * @return array
  20. */
  21. function fgcf_admin_settings() {
  22. $form = array();
  23. $mail_destination = 'fgcf_mail_destination';
  24. $form[$mail_destination] = array(
  25. '#type' => 'textfield',
  26. '#title' => t("Destinataire des demandes d'inscription aux formations"),
  27. '#default_value' => variable_get($mail_destination, variable_get('site_mail', 'support@osinet.fr')),
  28. );
  29. $flood = 'fgcf_subscribe_flood';
  30. $form[$flood] = array(
  31. '#type' => 'select',
  32. '#title' => t("Limite d'inscriptions"),
  33. '#options' => array(
  34. '0' => t('Pas de limite'),
  35. '1' => '1',
  36. '2' => '2',
  37. '5' => '5',
  38. '10' => '10',
  39. ),
  40. '#description' => t("Nombre maximum de demandes d'inscription toutes formations confondues, par personne et par heure"),
  41. '#default_value' => variable_get($flood, '10'),
  42. );
  43. $ret = system_settings_form($form);
  44. return $ret;
  45. }
  46. /**
  47. * Validation handler for fgcf_admin_settings().
  48. *
  49. * @param array $form
  50. * @param array $form_state
  51. *
  52. * @return void
  53. */
  54. function fgcf_admin_settings_validate($form, &$form_state) {
  55. $mail_destination = 'fgcf_mail_destination';
  56. if (!valid_email_address($form_state['values'][$mail_destination])) {
  57. form_set_error($mail_destination, t('Invalid email address'));
  58. }
  59. }