From b197c92c8dd1643a22a30248e39c6dfd0fbce6c3 Mon Sep 17 00:00:00 2001 From: Marek Isalski Date: Sun, 13 Mar 2016 10:14:07 +0100 Subject: [PATCH] initial version --- fulcrm_webhook.admin.inc | 50 ++++++++++++++++++++++++++++++++++++++++ fulcrm_webhook.info | 6 +++++ fulcrm_webhook.install | 6 +++++ fulcrm_webhook.module | 32 +++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 fulcrm_webhook.admin.inc create mode 100644 fulcrm_webhook.info create mode 100644 fulcrm_webhook.install create mode 100644 fulcrm_webhook.module diff --git a/fulcrm_webhook.admin.inc b/fulcrm_webhook.admin.inc new file mode 100644 index 0000000..eedeb9c --- /dev/null +++ b/fulcrm_webhook.admin.inc @@ -0,0 +1,50 @@ + 'item', + '#title' => 'fulcrm webhook Settings', + '#description' => '', + ); + + if ( $is_https ) { + $form[ 'webhook_url' ] = array( '#type' => 'textfield', + '#disabled' => TRUE, + '#title' => 'Webhook URL (to be registered with fulcrm)', + '#default_value' => url( 'services/fulcrm/webhook/' . variable_get( 'fulcrm_webhook_url' ), array( 'absolute' => TRUE, 'https' => TRUE ) ), + '#size' => 150, + '#max_length' => 200, + '#required' => FALSE, + ); + + $form[ 'actions' ] = array( '#type' => 'actions' ); + $form[ 'actions' ][ 'save' ] = array( '#type' => 'submit', + '#value' => t('Save'), + '#submit' => array( 'fulcrm_webhook_admin_form_submit' ), + ); + } else { + $form[ 'no_https' ] = array( '#type' => 'fieldset', + '#title' => 'HTTPS Missing!', + '#collapsible' => FALSE, + '#collapsed' => FALSE, + 'detail' => array( '#type' => 'item', + '#title' => '', + '#markup' => '

You need to enable SSL on this Drupal instance to continue.

fulcrm will only send data to HTTPS webhooks.

' ), + ); + $form[ 'actions' ] = array( '#type' => 'actions' ); + $form[ 'actions' ][ 'save' ] = array( '#type' => 'link', + '#title' => t('Reload'), + '#href' => str_replace( 'http://', 'https://', url( 'admin/config/services/fulcrm/webhook', array( 'absolute' => TRUE ) ) ), + ); + } + + return $form; +} + +function fulcrm_webhook_admin() { + return drupal_get_form( 'fulcrm_webhook_admin_form' ); +} diff --git a/fulcrm_webhook.info b/fulcrm_webhook.info new file mode 100644 index 0000000..49c030f --- /dev/null +++ b/fulcrm_webhook.info @@ -0,0 +1,6 @@ +name = fulcrm webhook +description = fulcrm webhooks +core = 7.x +package = fulcrm +configure = admin/config/services/fulcrm/webhook +dependencies[] = fulcrm_uuid diff --git a/fulcrm_webhook.install b/fulcrm_webhook.install new file mode 100644 index 0000000..69f3d9b --- /dev/null +++ b/fulcrm_webhook.install @@ -0,0 +1,6 @@ + array( 'title' => t('Administer fulcrm webhooks'), + 'description' => t('Perform main installation/administration tasks for fulcrm webhooks.'), + ), + ); +} + +function fulcrm_webhook_menu() { + /* + $items[ 'admin/config/services/fulcrm' ] = array( 'page callback' => 'system_admin_menu_block_page', + 'file' => 'system.admin.inc', + 'file path' => drupal_get_path('module', 'system'), + 'title' => 'fulcrm', + 'description' => 'Configuration integration with fulcrm.org.', + 'position' => 'right', + 'access callback' => 'user_access', + 'access arguments' => array('access administration pages'), + ); + */ + $items[ 'admin/config/services/fulcrm/webhook' ] = array( 'page callback' => 'fulcrm_webhook_admin', + 'file' => 'fulcrm_webhook.admin.inc', + 'title' => 'fulcrm webhook', + 'description' => 'Configuring webhooks for fulcrm.org.', + 'access callback' => 'user_access', + 'access arguments' => array('administer fulcrm webhooks'), + ); + + return $items; +} +