You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
3.1 KiB

  1. <?php
  2. function fulcrm_apiv2_admin_form_submit( $form, &$form_state ) {
  3. variable_set( 'fulcrm_apiv2_hostname', $form_state[ 'values' ][ 'hostname' ] );
  4. variable_set( 'fulcrm_apiv2_user', $form_state[ 'values' ][ 'apiuser' ] );
  5. variable_set( 'fulcrm_apiv2_key', $form_state[ 'values' ][ 'apikey' ] );
  6. variable_set( 'fulcrm_apiv2_client_id', $form_state[ 'values' ][ 'clientid' ] );
  7. }
  8. function fulcrm_apiv2_admin_form( $form, &$form_state ) {
  9. $form[ 'title' ] = array( '#type' => 'item',
  10. '#title' => 'fulcrm APIv2 Settings',
  11. '#description' => '',
  12. );
  13. $form[ 'api' ] = array( '#type' => 'fieldset',
  14. '#title' => 'fulcrm.org APIv2 Credentials',
  15. );
  16. $form[ 'api' ][ 'hostname' ] = array( '#type' => 'select',
  17. '#title' => 'Instance',
  18. '#description' => 'fulcrm.org APIv2 instance',
  19. '#options' => array( 'fulcrm.org' => 'LIVE',
  20. 'test.fulcrm.org' => 'TEST (live data, pre-production code)',
  21. 'dev.fulcrm.org' => 'DEV (test data, in-development code)',
  22. ),
  23. '#default_value' => variable_get( 'fulcrm_apiv2_hostname', 'fulcrm.org' ),
  24. );
  25. $form[ 'api' ][ 'apiuser' ] = array( '#type' => 'textfield',
  26. '#title' => 'API Username',
  27. '#description' => 'fulcrm.org APIv2 username',
  28. '#default_value' => variable_get( 'fulcrm_apiv2_user', '' ),
  29. );
  30. $form[ 'api' ][ 'apikey' ] = array( '#type' => 'textfield',
  31. '#title' => 'API Key',
  32. '#description' => 'fulcrm.org APIv2 key',
  33. '#default_value' => variable_get( 'fulcrm_apiv2_key', '' ),
  34. );
  35. $form[ 'api' ][ 'clientid' ] = array( '#type' => 'textfield',
  36. '#title' => 'Client ID',
  37. '#description' => 'fulcrm.org APIv2 client ID',
  38. '#default_value' => variable_get( 'fulcrm_apiv2_client_id', '' ),
  39. );
  40. $form[ 'actions' ] = array( '#type' => 'actions' );
  41. $form[ 'actions' ][ 'save' ] = array( '#type' => 'submit',
  42. '#value' => t('Save'),
  43. '#submit' => array( 'fulcrm_apiv2_admin_form_submit' ),
  44. );
  45. return $form;
  46. }
  47. function fulcrm_apiv2_admin() {
  48. return drupal_get_form( 'fulcrm_apiv2_admin_form' );
  49. }