Skip to content

Commit

Permalink
Support is added for Formidable Form
Browse files Browse the repository at this point in the history
  • Loading branch information
coderscom committed Mar 23, 2017
1 parent cdd467c commit 65b20cc
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 2 deletions.
6 changes: 5 additions & 1 deletion includes/class-wp-odoo-form-integrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,13 @@ private function define_form_hooks() {
if (isset($wp_odoo_form_modules)){
foreach ($wp_odoo_form_modules as $module) {
$object = new $module();
$this->loader->add_action( $object->get_action_tag(), $object, 'handle_callback' );
$this->loader->add_action( $object->get_action_tag(),
$object,
'handle_callback',
10, $object->get_callback_argument_count());
}
}

require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wp-odoo-client.php';
$client = new Wp_Odoo_Client(get_option('cc_odoo_integrator_odoo_url'),
get_option('cc_odoo_integrator_odoo_database'),
Expand Down
10 changes: 10 additions & 0 deletions modules/wp-odoo-form-integrator-form-contact-7.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ public function get_form_fields($form_id){
return $result;
}

/**
* Callback argument count
*
* @since 1.0.0
*/
public function get_callback_argument_count(){
return 1;
}

/**
* Register the stylesheets for the admin area.
*
Expand All @@ -92,6 +101,7 @@ public function handle_callback($contact_form){
if ( $submission ) {
$form_id = $contact_form->id();
$posted_data = $submission->get_posted_data();
error_log("CF7 ".print_r($posted_data, TRUE), 0);
do_action( 'wp_odoo_form_integrator_push_to_odoo', __CLASS__, $form_id, $posted_data );
}
}
Expand Down
110 changes: 110 additions & 0 deletions modules/wp-odoo-form-integrator-formidable-forms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php
/**
* The admin-specific functionality of the plugin.
*
* @link http://www.coderscom.com/
* @since 1.0.0
*
* @package Wp_Odoo_Form_Integrator
* @subpackage Wp_Odoo_Form_Integrator/admin
*/

/**
* The admin-specific functionality of the plugin.
*
* Defines the plugin name, version, and two examples hooks for how to
* enqueue the admin-specific stylesheet and JavaScript.
*
* @package Wp_Odoo_Form_Integrator
* @subpackage Wp_Odoo_Form_Integrator/admin
* @author Coderscom <[email protected]>
*/

class Wp_Odoo_Form_Integrator_Formidable_Forms {

/**
* Register the stylesheets for the admin area.
*
* @since 1.0.0
*/
public function get_plugin_slug(){
return "formidable";
}

/**
* Register the stylesheets for the admin area.
*
* @since 1.0.0
*/
public function get_action_tag(){
return "frm_after_create_entry";
}

/**
* Register the stylesheets for the admin area.
*
* @since 1.0.0
*/
public function get_plugin_name(){
return "Formidable Forms";
}

/**
* Register the stylesheets for the admin area.
*
* @since 1.0.0
*/
public function get_all_forms(){
global $wpdb;
$query = 'select id, name from ' . $wpdb->prefix . 'frm_forms';
$formidable_forms = $wpdb->get_results( $query );
foreach( $formidable_forms as $form ) {
$result[] = array( 'id' => $form->id , 'label' => $form->name );
}
return $result;
}

/**
* Register the stylesheets for the admin area.
*
* @since 1.0.0
*/
public function get_form_fields($form_id){
global $wpdb;
$query = 'select id,default_value,name from '. $wpdb->prefix . 'frm_fields where form_id=%d';
$form_fields = $wpdb->get_results(
$wpdb->prepare(
$query,
$form_id
)
);

foreach ( $form_fields as $field ) {
$label = empty( $field->name )? $field->default_value : $field->name;
$result[] = array( 'id' => $field->id, 'label' => $label );
}
return $result;
}

/**
* Callback argument count
*
* @since 1.0.0
*/
public function get_callback_argument_count(){
return 2;
}

/**
* Register the stylesheets for the admin area.
*
* @since 1.0.0
*/
public function handle_callback($entry_id, $form_id){
error_log("entry_id = $entry_id", 0);
error_log("form_id = $form_id", 0);
$posted_data = $_POST['item_meta'];
error_log( print_r($posted_data, TRUE) );
do_action( 'wp_odoo_form_integrator_push_to_odoo', __CLASS__, $form_id, $posted_data );
}
}
9 changes: 9 additions & 0 deletions modules/wp-odoo-form-integrator-ninja-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ public function get_form_fields($form_id){
return $result;
}

/**
* Callback argument count
*
* @since 1.0.0
*/
public function get_callback_argument_count(){
return 1;
}

/**
* Register the stylesheets for the admin area.
*
Expand Down
3 changes: 2 additions & 1 deletion wp-odoo-form-integrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

// Register class name of modules here.
$wp_odoo_form_modules = array( 'Wp_Odoo_Form_Integrator_Form_Contact_7',
'Wp_Odoo_Form_Integrator_Ninja_Forms' );
'Wp_Odoo_Form_Integrator_Ninja_Forms',
'Wp_Odoo_Form_Integrator_Formidable_Forms' );


/**
Expand Down

0 comments on commit 65b20cc

Please sign in to comment.